| [1871] | 1 | // -*- C++ -*- // | 
|---|
|  | 2 |  | 
|---|
|  | 3 | #ifndef ALGOWIN_H | 
|---|
|  | 4 | #define ALGOWIN_H | 
|---|
|  | 5 |  | 
|---|
|  | 6 | class AlgoWin; | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #include <all_include.h> | 
|---|
| [1879] | 9 | //#include <mapstorage.h> | 
|---|
| [1871] | 10 | #include <algobox.h> | 
|---|
|  | 11 | #include <libgnomecanvasmm.h> | 
|---|
|  | 12 | #include <libgnomecanvasmm/polygon.h> | 
|---|
|  | 13 |  | 
|---|
| [1879] | 14 | class MapStorage; | 
|---|
|  | 15 |  | 
|---|
| [1896] | 16 | ///Algorithm identifiers. | 
|---|
| [1876] | 17 | enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs; | 
|---|
| [1871] | 18 |  | 
|---|
| [1896] | 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. | 
|---|
| [1876] | 35 | class AlgoWin : public Gtk::Window | 
|---|
| [1871] | 36 | { | 
|---|
|  | 37 | private: | 
|---|
| [1896] | 38 | ///Algorithm specific part of \ref AlgoWin | 
|---|
| [1871] | 39 | AlgoBox * ab; | 
|---|
| [1896] | 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. | 
|---|
| [1876] | 47 | Gtk::Button * runbutton; | 
|---|
| [1896] | 48 |  | 
|---|
|  | 49 | ///Close button. If pressed, \ref AlgoWin should close. | 
|---|
| [1876] | 50 | Gtk::Button * closebutton; | 
|---|
| [1871] | 51 |  | 
|---|
|  | 52 | protected: | 
|---|
| [1896] | 53 | ///Signal emitted upon close of window | 
|---|
|  | 54 |  | 
|---|
|  | 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; | 
|---|
| [1871] | 84 |  | 
|---|
|  | 85 | public: | 
|---|
| [1896] | 86 | ///Close window if escape key is pressed. | 
|---|
| [1876] | 87 | bool closeIfEscapeIsPressed(GdkEventKey* e); | 
|---|
| [1871] | 88 |  | 
|---|
| [1896] | 89 | ///Returns \ref signal_closed to be bindable somewhere. | 
|---|
| [1876] | 90 | sigc::signal<void, AlgoWin *> signal_closing(); | 
|---|
| [1896] | 91 |  | 
|---|
|  | 92 | ///Returns \ref signal_maplist_need to be bindable somewhere. | 
|---|
| [1876] | 93 | sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed(); | 
|---|
| [1871] | 94 |  | 
|---|
| [1896] | 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. | 
|---|
| [1876] | 99 | void emit_tab_change(std::string); | 
|---|
| [1896] | 100 |  | 
|---|
|  | 101 | ///Forwards signal emitted by \ref AlgoBox, in which it indicates need for \ref NewMapWin. | 
|---|
| [1884] | 102 | void emit_new_map_signal(std::string tabname, bool itisedge){signal_newmapwin_need.emit(tabname, itisedge);}; | 
|---|
| [1871] | 103 |  | 
|---|
| [1896] | 104 | ///Constructor | 
|---|
| [1876] | 105 |  | 
|---|
| [1896] | 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. | 
|---|
| [1876] | 119 | void update_tablist(std::vector<std::string> tabnames); | 
|---|
| [1896] | 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. | 
|---|
| [1879] | 126 | void update_maplist(MapStorage *); | 
|---|
| [1876] | 127 |  | 
|---|
| [1896] | 128 | ///Called when window is closing. | 
|---|
|  | 129 |  | 
|---|
|  | 130 | ///\ref AlgoWin has to be deregistrated in \ref MainWin | 
|---|
|  | 131 | ///thereforeit emits signal \ref signal_closed. | 
|---|
| [1876] | 132 | void on_hide(); | 
|---|
| [1871] | 133 | }; | 
|---|
|  | 134 | #endif //ALGOWIN_H | 
|---|