[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 | */ |
---|
[6] | 18 | |
---|
| 19 | #ifndef MAIN_WIN_H |
---|
| 20 | #define MAIN_WIN_H |
---|
| 21 | |
---|
[53] | 22 | #include "all_include.h" |
---|
[6] | 23 | #include <libgnomecanvasmm.h> |
---|
| 24 | #include <libgnomecanvasmm/polygon.h> |
---|
| 25 | |
---|
[194] | 26 | class AlgoWin; |
---|
| 27 | class NoteBookTab; |
---|
[96] | 28 | |
---|
[6] | 29 | ///This class is the main window of GUI. |
---|
[119] | 30 | |
---|
| 31 | ///It has menus, and a notebook. Notebook has different pages, |
---|
| 32 | ///the so called tabs (\ref NoteBookTab). Each \ref NoteBookTab contains a canvas on which graphs can be drawn. |
---|
| 33 | ///To manage creation and close of tabs and tabswitching is the task of MainWin. |
---|
[6] | 34 | class MainWin : public Gtk::Window |
---|
| 35 | { |
---|
[119] | 36 | ///Container in which the menus and the notebook is. |
---|
[154] | 37 | //Gtk::VBox vbox; |
---|
| 38 | Gtk::Table table; |
---|
| 39 | Gtk::Table table2; |
---|
| 40 | |
---|
| 41 | ///Container in which the toolbar and the node parametrizer is. |
---|
| 42 | Gtk::HBox hbox; |
---|
| 43 | |
---|
| 44 | ///Should nodes be autoscaled or not? |
---|
| 45 | Gtk::CheckButton * auto_scale; |
---|
| 46 | |
---|
[156] | 47 | ///Should node size track zoom factor? |
---|
| 48 | Gtk::CheckButton * zoom_track; |
---|
| 49 | |
---|
[154] | 50 | ///Minimum and maximum node radius entry |
---|
[157] | 51 | Gtk::SpinButton * radius_size, * edge_width; |
---|
[96] | 52 | |
---|
[119] | 53 | ///The notebook that has tabs (\ref NoteBookTab) with different graphs. |
---|
[96] | 54 | Gtk::Notebook notebook; |
---|
| 55 | |
---|
[119] | 56 | ///The tool selected to manipulate graph. |
---|
| 57 | |
---|
| 58 | ///It has to be stored, because in case of tabswitching |
---|
| 59 | ///the correct tool has to be set for the actual graph. |
---|
[96] | 60 | int active_tool; |
---|
| 61 | |
---|
[119] | 62 | ///The number of active tab in the notebook. |
---|
[96] | 63 | int active_tab; |
---|
[119] | 64 | |
---|
| 65 | ///Vector of existing tabs in the notebook. |
---|
[96] | 66 | std::vector<NoteBookTab *> tabs; |
---|
[119] | 67 | |
---|
| 68 | ///Vector of the name of tabs. |
---|
| 69 | |
---|
| 70 | ///All \ref NoteBookTab has a name that is stored here. The index of the name |
---|
| 71 | ///is the same as the index of the \ref NoteBookTab in \ref tabs. |
---|
[96] | 72 | std::vector<std::string> tabnames; |
---|
| 73 | |
---|
[119] | 74 | ///Counter of occurence of the same file names. |
---|
| 75 | |
---|
| 76 | ///If a file is opened more than once we have to score |
---|
| 77 | ///the occurences to let the titles on tabs different. |
---|
| 78 | ///If more than one occurence is present, from the second |
---|
| 79 | ///one near the filename the number of the occurence appear. |
---|
[104] | 80 | std::map<std::string, int> strinst; |
---|
| 81 | |
---|
[119] | 82 | ///Set of opened \ref AlgoWin s. |
---|
| 83 | |
---|
| 84 | ///More than one \refAlgoWin can be opened. We have to |
---|
| 85 | ///communicate with them in case of new \ref NoteBookTab creation, |
---|
| 86 | ///\ref NoteBookTab close, or map change. Therefore we have to score |
---|
| 87 | ///their occurences. |
---|
[103] | 88 | std::set< AlgoWin* > aws; |
---|
| 89 | |
---|
[6] | 90 | public: |
---|
[96] | 91 | |
---|
[119] | 92 | ///Constructor of the \ref MainWin. |
---|
| 93 | |
---|
| 94 | ///It creates the menus, the toolbar and the notebook in which |
---|
| 95 | ///\ref NoteBookTab s take place. \ref NoteBookTab s are the |
---|
| 96 | ///holder of the canvases on which the graphs are drawn. |
---|
[68] | 97 | MainWin(); |
---|
[53] | 98 | |
---|
[119] | 99 | ///Sets title of tabs. |
---|
| 100 | |
---|
| 101 | ///It alse registrates it in \ref tabnames. If more than one |
---|
| 102 | ///occurence is in the notebook of the same file it has to |
---|
| 103 | ///extend tabname with the number of occurence. |
---|
[96] | 104 | void set_tabtitle(std::string); |
---|
[6] | 105 | |
---|
| 106 | ///ActionGroup for menu |
---|
| 107 | Glib::RefPtr<Gtk::ActionGroup> ag; |
---|
| 108 | |
---|
| 109 | ///UIManager for menu |
---|
| 110 | Glib::RefPtr<Gtk::UIManager> uim; |
---|
| 111 | |
---|
[119] | 112 | ///Creates a new \ref NoteBookTab and opens the given file. |
---|
| 113 | |
---|
| 114 | ///It is called only with command line parameters at stratup. |
---|
[96] | 115 | void readFile(const std::string &); |
---|
[6] | 116 | |
---|
[50] | 117 | ///Tooltips |
---|
[190] | 118 | Gtk::Tooltips * tooltips; |
---|
[50] | 119 | |
---|
[96] | 120 | //Call-backs of buttons |
---|
| 121 | |
---|
[6] | 122 | ///Callback for 'FileNew' action. |
---|
| 123 | virtual void newFile(); |
---|
| 124 | ///Callback for 'FileOpen' action. |
---|
| 125 | virtual void openFile(); |
---|
| 126 | ///Callback for 'FileSave' action. |
---|
| 127 | virtual void saveFile(); |
---|
| 128 | ///Callback for 'FileSaveAs' action. |
---|
| 129 | virtual void saveFileAs(); |
---|
[53] | 130 | ///Callback for 'Close' action. |
---|
| 131 | virtual void close(); |
---|
[94] | 132 | |
---|
[96] | 133 | //Toolbar |
---|
[119] | 134 | |
---|
| 135 | ///Callback for 'zoomIn' action. |
---|
| 136 | |
---|
| 137 | ///It calls the appropriate function in |
---|
| 138 | ///\ref GraphDisplayerCanvas |
---|
[96] | 139 | virtual void zoomIn(); |
---|
[119] | 140 | ///Callback for 'zoomOut' action. |
---|
| 141 | |
---|
| 142 | ///It calls the appropriate function in |
---|
| 143 | ///\ref GraphDisplayerCanvas |
---|
[96] | 144 | virtual void zoomOut(); |
---|
[119] | 145 | ///Callback for 'zoomFit' action. |
---|
| 146 | |
---|
| 147 | ///It calls the appropriate function in |
---|
| 148 | ///\ref GraphDisplayerCanvas |
---|
[96] | 149 | virtual void zoomFit(); |
---|
[119] | 150 | ///Callback for 'zoom100' action. |
---|
| 151 | |
---|
| 152 | ///It calls the appropriate function in |
---|
| 153 | ///\ref GraphDisplayerCanvas |
---|
[96] | 154 | virtual void zoom100(); |
---|
[94] | 155 | |
---|
[119] | 156 | ///Callback for Show Maps menupoint. |
---|
| 157 | |
---|
| 158 | ///It calls the appropriate function in |
---|
| 159 | ///\ref NoteBookTab |
---|
[96] | 160 | virtual void createMapWin(); |
---|
[94] | 161 | |
---|
[160] | 162 | ///Callback for Show Design menupoint. |
---|
| 163 | |
---|
| 164 | ///It calls the appropriate function in |
---|
| 165 | ///\ref NoteBookTab |
---|
| 166 | virtual void createDesignWin(); |
---|
| 167 | |
---|
[119] | 168 | ///Pops up an Algorithm window. |
---|
| 169 | |
---|
| 170 | ///It not only creates but registrates the newly created \ref AlgoWin. |
---|
| 171 | ///It is necessary, because in case of changement between tabs or maps |
---|
| 172 | ///we have to communicate with it. Signals are also have to be connected |
---|
| 173 | ///to it, because \ref AlgoWin emits signals if it needs anything (maplist, deregistration). |
---|
| 174 | ///\param algo type of the algorithm to run. |
---|
| 175 | virtual void createAlgoWin(int algo); |
---|
| 176 | |
---|
| 177 | ///Deregisters AlgoWin |
---|
| 178 | |
---|
| 179 | ///This is the function connected to the closing signal of \ref AlgoWin. |
---|
| 180 | ///It only deletes the sender \ref AlgoWin from \ref aws. This function |
---|
| 181 | ///is called only by the closing \ref AlgoWin itself. |
---|
| 182 | ///\param aw the \ref AlgoWin to delete. |
---|
| 183 | virtual void deRegisterAlgoWin(AlgoWin * aw); |
---|
| 184 | |
---|
| 185 | ///Updates list of tabs in all of the \ref AlgoWin |
---|
| 186 | |
---|
| 187 | ///When \ref NoteBookTab inserted somewhere or closed one tablist in all \ref AlgoWin |
---|
| 188 | ///have to be updated. That is why we score all the opened \ref AlgoWin. |
---|
| 189 | ///During update \ref tabnames will be passed to each \ref AlgoWin. |
---|
[106] | 190 | virtual void updateAlgoWinTabs(); |
---|
[103] | 191 | |
---|
[119] | 192 | ///Refresh list of maps in the AlgoWin that requested it. |
---|
[94] | 193 | |
---|
[119] | 194 | ///In an \ref AlgoWin there is a ComboBoxText, in which |
---|
| 195 | ///a \ref NoteBookTab can be chosen that contains the graph and the maps, |
---|
| 196 | ///on which we would like to run algorithms. If we change the |
---|
| 197 | ///tab the available maps also have to be updated, because |
---|
| 198 | ///in the different tabs different maps are available. Therefore |
---|
| 199 | ///on tab change the \ref AlgoWin emits a signal that contains itself |
---|
| 200 | ///so that the appropriate maps can be sent to it. For the sake of simplicity |
---|
| 201 | ///the program answers this call with the mapstorage of the newly selected tab. |
---|
| 202 | ///\param aw the caller \ref AlgoWin |
---|
| 203 | ///\param tabname the newly selected tab in the \ref AlgoWin |
---|
| 204 | virtual void updateAlgoWinMaps(AlgoWin * aw, std::string tabname); |
---|
| 205 | |
---|
| 206 | ///Registrates the new graph-editor tool in hand. |
---|
| 207 | |
---|
| 208 | ///The editor-tool in hand is global, it is the same for all tab |
---|
| 209 | ///at the same time. Therefore the active tool has to be scored here (\ref active_tool). |
---|
| 210 | ///This function is the callback function of the editor-tool buttons. It sets \ref active_tool |
---|
| 211 | ///to the correct value. |
---|
| 212 | ///\param tool the newly selected graph-editor tool (See all_include.h) |
---|
| 213 | virtual void changeEditorialTool(int tool); |
---|
| 214 | |
---|
| 215 | ///Pops up a \ref NewMapWin dialog after requested by a \ref MapWin |
---|
| 216 | |
---|
| 217 | ///Each tab can pop-up a \ref MapWin. In \ref MapWin new tab can be created. |
---|
| 218 | ///In this case \ref NoteBookTab emits a signal. This function is connected to that signal. |
---|
| 219 | ///It sends the caller \ref NoteBookTab and whether an edgemap or a nodemap should be created. |
---|
| 220 | ///Caller \ref NoteBookTab is necessary for the window to be able to place the new map in its |
---|
| 221 | ///correct place. |
---|
| 222 | ///\param nbt the caller tab |
---|
| 223 | ///\param itisedge true if edgemap has to be created, false if nodemap |
---|
| 224 | virtual void createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge); |
---|
| 225 | |
---|
| 226 | ///Pops up a \ref NewMapWin dialog after requested by an \ref AlgoWin |
---|
| 227 | |
---|
| 228 | ///\ref AlgoWin can also can request a \ref NewMapWin to pop-up. |
---|
| 229 | ///It emits a signal in this case. This function is bound to that signal. |
---|
| 230 | ///The signal contains the name of \ref NoteBookTab in which the new map has to be |
---|
| 231 | ///placed and whether the new map is an edgemap or a nodemap. |
---|
| 232 | ///\ref tabname the tab in which the new map has to be placed |
---|
| 233 | ///\ref itisedge true if the new map will be edge map, false if it will be nodemap |
---|
| 234 | virtual void createNewMapWinTabString(std::string tabname, bool itisedge); |
---|
| 235 | |
---|
| 236 | ///Pops up a \ref NewMapWin dialog if button on \ref MainWin has been pressed. |
---|
| 237 | |
---|
| 238 | ///In this case a general \ref NewMapWin will be popped up. This means that |
---|
| 239 | ///both edge and nodemap can be created by it. The new map will be placed in |
---|
| 240 | ///\MapStorage of the actual selected \ref NoteBookTab. |
---|
[96] | 241 | virtual void createNewMapWin(); |
---|
| 242 | |
---|
| 243 | //Notebook handlers |
---|
| 244 | ///Callback for 'FileNewTab' action. |
---|
| 245 | virtual void newTab(); |
---|
[119] | 246 | |
---|
| 247 | ///Callback for 'FileCloseTab' action. |
---|
| 248 | |
---|
| 249 | ///It closes the actual \ref NoteBookTab and registrates this event: |
---|
| 250 | ///data is shifted to the correct places in vectors. |
---|
[97] | 251 | virtual void closeTab(); |
---|
[119] | 252 | |
---|
| 253 | ///Tabswitching handler |
---|
| 254 | |
---|
| 255 | ///Sets the variables that have to store the actual state, and it |
---|
| 256 | ///updates the title of window to the actually selected \ref NoteBookTab. |
---|
[96] | 257 | virtual void onChangeTab(GtkNotebookPage*, guint); |
---|
[154] | 258 | |
---|
| 259 | virtual void nodeViewChanged(); |
---|
[160] | 260 | |
---|
| 261 | virtual void reDesignGraph(); |
---|
[184] | 262 | |
---|
[191] | 263 | virtual void exportToEPS(); |
---|
| 264 | |
---|
[184] | 265 | void createBackgroundChooser(); |
---|
[6] | 266 | }; |
---|
| 267 | |
---|
| 268 | #endif //MAIN_WIN_H |
---|