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