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