gui/algowin.h
changeset 2012 224cd6aacfc1
parent 1884 9c061834b33b
equal deleted inserted replaced
4:fb5a4366be48 5:1ab699d733b3
    11 #include <libgnomecanvasmm.h>
    11 #include <libgnomecanvasmm.h>
    12 #include <libgnomecanvasmm/polygon.h>
    12 #include <libgnomecanvasmm/polygon.h>
    13 
    13 
    14 class MapStorage;
    14 class MapStorage;
    15 
    15 
       
    16 ///Algorithm identifiers.
    16 enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs;
    17 enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs;
    17 
    18 
       
    19 ///Window displaying graphical interface for different algorithms.
       
    20 
       
    21 ///This class displays a graphical interface to set up
       
    22 ///and run different algorithms. Different algorithms need
       
    23 ///different inputs, running methods, etc. Therefore
       
    24 ///class \ref AlgoWin is only a holder of a base class, the so
       
    25 ///called AlgoBox. \ref AlgoBox is the ancestor of other
       
    26 ///classes. These child classes realize interfaces of different
       
    27 ///algorithms, but as their common ancestor is \ref AlgoBox
       
    28 ///the interface of them is the same. \ref AlgoWin communicates
       
    29 ///with these classes through this common interface. But it the
       
    30 ///real object to be placed in \ref AlgoWin depends on the algorithm
       
    31 ///which the \ref AlgoWin actually has to display. It gets the
       
    32 ///id of algorithm to display at initialization, and therefore it is
       
    33 ///able to place in itself the requested child of \ref AlgoBox
       
    34 /// visualizing the appropriate algorithm.
    18 class AlgoWin : public Gtk::Window
    35 class AlgoWin : public Gtk::Window
    19 {
    36 {
    20 private:
    37 private:
       
    38   ///Algorithm specific part of \ref AlgoWin
    21   AlgoBox * ab;
    39   AlgoBox * ab;
       
    40 
       
    41   ///Run button.
       
    42 
       
    43   ///If pressed, algorithm should run.
       
    44   ///That is why common ancestor of different
       
    45   ///algorithm realizer classes have to be. In case of
       
    46   ///pressing run button a common method can be called.
    22   Gtk::Button * runbutton;
    47   Gtk::Button * runbutton;
       
    48 
       
    49   ///Close button. If pressed, \ref AlgoWin should close.
    23   Gtk::Button * closebutton;
    50   Gtk::Button * closebutton;
    24 
    51 
    25 protected:
    52 protected:
    26   sigc::signal<void, AlgoWin *> signal_closed;  
    53   ///Signal emitted upon close of window
    27   sigc::signal<void, AlgoWin *, std::string> signal_maplist_need;  
    54 
    28   sigc::signal<void, std::string, bool> signal_newmapwin_need;  
    55   ///It is necessary, because \ref MainWin have to
       
    56   ///score the opened \ref AlgoWin s, to be able to communicate
       
    57   ///with them: let them know about changement in tabs, maps, etc.
       
    58   ///If \ref AlgoWin is closed, \ref MainWin has to deregistrate it.
       
    59   ///Therefore signal contains address of emitter \ref AlgoWin.
       
    60   sigc::signal<void, AlgoWin *> signal_closed;
       
    61 
       
    62   ///Signal indicating that informatino on certain maplist is required.
       
    63 
       
    64   ///It is just a forwarded signal from \ref AlgoBox, benefit of common ancestor
       
    65   ///algorithm class. User can select the graph (the holder \ref NoteBookTab) on
       
    66   ///which the algorithm should run. But different graphs (\ref NoteBookTab) have
       
    67   ///different maps. If selected tab changes this signal is emitted by \ref AlgoBox,
       
    68   ///caught and reemitted by \ref AlgoWin.
       
    69   ///
       
    70   ///Signal contains the address of \ref AlgoWin to let \ref MainWin know
       
    71   ///where should the information needed forwarded, and the name of
       
    72   ///\ref NoteBookTab, of which maps are inquired.
       
    73   sigc::signal<void, AlgoWin *, std::string> signal_maplist_need;
       
    74 
       
    75   ///Signal that indicates that a \ref NewMapWin should be popped up.
       
    76 
       
    77   ///This is a forwarded signal. If \ref AlgoBox emits a signal
       
    78   ///to let a \ref NewMapWin pop up, |ref AlgoWin catch and reemit it.
       
    79   ///
       
    80   ///Signal contains the name of \ref NoteBookTab, in which the new map
       
    81   ///should be created and a boolean that indicates whether an edge or a
       
    82   ///nodemap should be created.
       
    83   sigc::signal<void, std::string, bool> signal_newmapwin_need;
    29 
    84 
    30 public:
    85 public:
       
    86   ///Close window if escape key is pressed.
    31   bool closeIfEscapeIsPressed(GdkEventKey* e);
    87   bool closeIfEscapeIsPressed(GdkEventKey* e);
    32 
    88 
       
    89   ///Returns \ref signal_closed to be bindable somewhere.
    33   sigc::signal<void, AlgoWin *> signal_closing();
    90   sigc::signal<void, AlgoWin *> signal_closing();
       
    91 
       
    92   ///Returns \ref signal_maplist_need to be bindable somewhere.
    34   sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed();
    93   sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed();
    35   sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};  
       
    36 
    94 
       
    95   ///Returns \ref signal_newmapwin_need to be bindable somewhere.
       
    96   sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
       
    97 
       
    98   ///Forwards signal emitted by \ref AlgoBox, in which it indicates changement in selection of tabs.
    37   void emit_tab_change(std::string);
    99   void emit_tab_change(std::string);
       
   100 
       
   101   ///Forwards signal emitted by \ref AlgoBox, in which it indicates need for \ref NewMapWin.
    38   void emit_new_map_signal(std::string tabname, bool itisedge){signal_newmapwin_need.emit(tabname, itisedge);};
   102   void emit_new_map_signal(std::string tabname, bool itisedge){signal_newmapwin_need.emit(tabname, itisedge);};
    39 
   103 
    40   AlgoWin(int, std::vector<std::string>);
   104   ///Constructor
    41 
   105 
       
   106   ///It builds the window according to the information provided
       
   107   ///by the creator. It needs the identifier of the algorithm
       
   108   ///to visualize, and a list of name of \ref NoteBookTab s that can
       
   109   ///be found in \ref MainWin.
       
   110   ///\param algoid identifier of algorithm to show
       
   111   ///\param tablist list of tabs in \ref MainWin
       
   112   AlgoWin(int algoid, std::vector<std::string> tablist);
       
   113 
       
   114   ///Forwards list of \ref NoteBookTabs toward \ref AlgoBox
       
   115 
       
   116   ///In case of changement in tabs in \ref MainWin
       
   117   ///\ref MainWin automatically updates tablist in
       
   118   ///\ref AlgoWin s.
    42   void update_tablist(std::vector<std::string> tabnames);
   119   void update_tablist(std::vector<std::string> tabnames);
       
   120 
       
   121   ///Forwards list of requested maps toward \ref AlgoBox
       
   122 
       
   123   ///Upon catching the signal in which \ref AlgoBox requests
       
   124   ///list of maps \ref MainWin responds
       
   125   ///through this function.
    43   void update_maplist(MapStorage *);
   126   void update_maplist(MapStorage *);
    44 
   127 
       
   128   ///Called when window is closing.
       
   129 
       
   130   ///\ref AlgoWin has to be deregistrated in \ref MainWin
       
   131   ///thereforeit emits signal \ref signal_closed.
    45   void on_hide();
   132   void on_hide();
    46 };
   133 };
    47 #endif //ALGOWIN_H
   134 #endif //ALGOWIN_H