[1871] | 1 | // -*- C++ -*- // |
---|
| 2 | |
---|
| 3 | #ifndef ALGOBOX_H |
---|
| 4 | #define ALGOBOX_H |
---|
| 5 | |
---|
| 6 | class AlgoBox; |
---|
| 7 | |
---|
| 8 | #include <all_include.h> |
---|
[1878] | 9 | #include <mapstorage.h> |
---|
[1884] | 10 | #include <mapselector.h> |
---|
[1871] | 11 | #include <libgnomecanvasmm.h> |
---|
| 12 | #include <libgnomecanvasmm/polygon.h> |
---|
| 13 | |
---|
[1896] | 14 | ///Ancestor class of algorithm graphical interface classes. |
---|
| 15 | |
---|
| 16 | ///It also demonstrates, how should an algorithm graphical interface |
---|
| 17 | ///work. Children of this class have the same functions and attributes, |
---|
| 18 | ///therefore with all of them can the holder \ref AlgoWin communicate |
---|
| 19 | ///in the same way. |
---|
| 20 | /// |
---|
| 21 | ///IMPORTANT! In a child class only the following tasks are to do: |
---|
| 22 | /// |
---|
| 23 | ///-call \ref init function with correct parameters from correctly parametrized constructor |
---|
| 24 | /// |
---|
| 25 | ///-implement \ref build_box function |
---|
| 26 | /// |
---|
| 27 | ///-implement \ref run function |
---|
| 28 | /// |
---|
| 29 | ///because all other thing is automatically done in \ref init function! |
---|
| 30 | |
---|
[1871] | 31 | class AlgoBox : public Gtk::VBox |
---|
| 32 | { |
---|
[1896] | 33 | ///Signal emitted in case of need for list of maps. |
---|
| 34 | |
---|
| 35 | ///If the user has selected different tab to work on |
---|
| 36 | ///new maps are selected as well. These new maps should be |
---|
| 37 | ///provided for \ref AlgoBox. To get these maps, \ref AlgoBox |
---|
| 38 | ///emits this signal. |
---|
| 39 | sigc::signal<void, std::string> signal_maplist_need; |
---|
| 40 | |
---|
| 41 | ///Signal emitted in case of need for \ref NewMapWin. |
---|
| 42 | |
---|
| 43 | ///If user wants to create a new for an input, or output |
---|
| 44 | ///it can let \ref NewMapWin popped up from here as well. |
---|
| 45 | ///In that case will be this signal emitted. |
---|
| 46 | sigc::signal<void, std::string, bool> signal_newmapwin_need; |
---|
[1876] | 47 | |
---|
| 48 | protected: |
---|
[1896] | 49 | ///Holder of tabnames. |
---|
[1884] | 50 | Gtk::ComboBoxText tabcbt; |
---|
[1896] | 51 | |
---|
| 52 | ///Holder of widgets, in which nodemaps can be selected to work on. |
---|
[1884] | 53 | std::vector<MapSelector *> nodemapcbts; |
---|
[1896] | 54 | |
---|
| 55 | ///Holder of widgets, in which edgemaps can be selected to work on. |
---|
[1884] | 56 | std::vector<MapSelector *> edgemapcbts; |
---|
[1878] | 57 | |
---|
[1896] | 58 | ///Maps of selected tabs. |
---|
[1878] | 59 | MapStorage * mapstorage; |
---|
| 60 | |
---|
[1876] | 61 | public: |
---|
[1896] | 62 | ///Empty constructor called by children. |
---|
[1876] | 63 | AlgoBox(){}; |
---|
[1871] | 64 | |
---|
[1896] | 65 | ///Constructor |
---|
| 66 | |
---|
| 67 | ///Calls \ref init function |
---|
| 68 | ///with the provided parameters. \ref init function |
---|
| 69 | ///is needed, because it is virtual, therefore the |
---|
| 70 | ///functions of the proper class will be called when |
---|
| 71 | ///running. |
---|
| 72 | ///\param tablist list of tabs in \ref MainWin |
---|
| 73 | AlgoBox(std::vector<std::string> tablist); |
---|
| 74 | |
---|
| 75 | ///Initiates \ref AlgoBox. |
---|
| 76 | |
---|
| 77 | ///Creates the graphical interface for the realized algorithm, initiates variables, connects signals. |
---|
| 78 | /// |
---|
| 79 | ///List of tabs in \ref MainWin is required, but no one |
---|
| 80 | ///will be selected automatically. Every other |
---|
| 81 | ///entry field remains empty (unselected), until a \ref NoteBookTab |
---|
| 82 | ///is selected. |
---|
| 83 | /// |
---|
| 84 | ///It also have to bind all the signals to the correct place. |
---|
| 85 | ///This function is virtual, in all type of children of |
---|
| 86 | ///\ref AlgoBox the correct function willbe called. |
---|
| 87 | /// |
---|
| 88 | ///Therefore it is IMPORTANT that only \ref run and \ref build_box |
---|
| 89 | ///has to be implemented in children of \ref AlgoBox, every other |
---|
| 90 | ///thing will automatically work properly by the help of this |
---|
| 91 | ///function that must be called in constructor of child!!! |
---|
[1878] | 92 | virtual void init(std::vector<std::string>); |
---|
[1871] | 93 | |
---|
[1896] | 94 | ///Signal emitted, when selected tab changes, and new list of maps required. |
---|
| 95 | sigc::signal<void, std::string> signal_maplist_needed(); |
---|
| 96 | |
---|
| 97 | ///Emitted if user wants to create a new map for inpuit or output. |
---|
| 98 | sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;}; |
---|
| 99 | |
---|
| 100 | ///Emits signal that requires list of maps for the recently selected \ref NoteBookTab. |
---|
[1876] | 101 | void emit_tab_change(); |
---|
[1871] | 102 | |
---|
[1896] | 103 | ///Interface, through which \ref AlgoBox can be notified about tab addition, deletion in \ref MainWin |
---|
| 104 | |
---|
| 105 | ///\param tl list |
---|
| 106 | ///of new tab state. |
---|
[1876] | 107 | void update_tablist( std::vector< std::string > tl ); |
---|
[1878] | 108 | |
---|
[1896] | 109 | ///Interface, through which \ref AlgoBox can get the maps of the recently selected \ref NoteBookTab |
---|
| 110 | |
---|
| 111 | ///\param ms the maps |
---|
| 112 | ///of the recently selected \ref NoteBookTab |
---|
| 113 | void update_maplist( MapStorage * ms); |
---|
| 114 | |
---|
| 115 | ///Interface, through which \ref AlgoBox can be notified about nodemap addition. |
---|
| 116 | |
---|
| 117 | ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab |
---|
| 118 | ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s |
---|
| 119 | ///in \ref nodemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text) |
---|
[1878] | 120 | void nodemaplist_changed(std::string); |
---|
[1896] | 121 | |
---|
| 122 | ///Interface, through which \ref AlgoBox can be notified about edgemap addition. |
---|
| 123 | |
---|
| 124 | ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab |
---|
| 125 | ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s |
---|
| 126 | ///in \ref edgemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text) |
---|
[1878] | 127 | void edgemaplist_changed(std::string); |
---|
[1871] | 128 | |
---|
[1896] | 129 | ///Aid function to provide data for a given entry. |
---|
| 130 | |
---|
| 131 | ///At the moment it is only used for updating info |
---|
| 132 | ///in \ref tabcbt. It clears it first, after that |
---|
| 133 | ///inserts the data got from caller, and if there |
---|
| 134 | ///was previously selected item it switches entry |
---|
| 135 | ///to that. |
---|
| 136 | ///\param tl list of entries (at the moment tabs in \ref MainWin) |
---|
| 137 | ///\param cbt the entry to update (at the moment only \ref tabcbt) |
---|
| 138 | void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText & cbt); |
---|
| 139 | |
---|
| 140 | ///Runs the ralized algorithm. |
---|
| 141 | |
---|
| 142 | ///Prepare the data for it |
---|
| 143 | ///and after that postprocess it if necessary. |
---|
| 144 | ///This is only a demo here, but in children it |
---|
| 145 | ///runs the algorithm really. |
---|
[1876] | 146 | virtual void run(); |
---|
[1896] | 147 | |
---|
| 148 | ///Creates the layout of the \ref AlgoBox |
---|
| 149 | |
---|
| 150 | ///Place all the entries |
---|
| 151 | ///required. Run and close button is not |
---|
| 152 | ///its responsibility! |
---|
[1876] | 153 | virtual void build_box(); |
---|
[1884] | 154 | |
---|
[1896] | 155 | ///Emits \ref signal_newmapwin_need if user wants to create new input or output map. |
---|
[1886] | 156 | |
---|
[1896] | 157 | ///Called in case of pressing \ref MapSelector::newbut. |
---|
| 158 | ///\param itisedge edge or nodemap is required. |
---|
| 159 | virtual void emit_new_map_signal(bool itisedge); |
---|
| 160 | |
---|
| 161 | ///Aid function to make addition of \ref MapSelector easy in \ref build_box. |
---|
| 162 | |
---|
| 163 | ///\param label label to show in \ref MapSelector |
---|
| 164 | ///\param itisedge whether edge or nodemaps stored in \ref MapSelector |
---|
| 165 | void addMapSelector(std::string label, bool itisedge); |
---|
[1871] | 166 | }; |
---|
| 167 | #endif //ALGOBOX_H |
---|