COIN-OR::LEMON - Graph Library

source: glemon-0.x/main_win.h @ 154:65c1b103443d

Last change on this file since 154:65c1b103443d was 154:65c1b103443d, checked in by Hegyi Péter, 18 years ago

Node view

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