Graph redesign starts with an initial kick of the first node.
6 #include "all_include.h"
9 #include "new_map_win.h"
11 #include <libgnomecanvasmm.h>
12 #include <libgnomecanvasmm/polygon.h>
15 ///This class is the main window of GUI.
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.
20 class MainWin : public Gtk::Window
22 ///Container in which the menus and the notebook is.
27 ///Container in which the toolbar and the node parametrizer is.
30 ///Should nodes be autoscaled or not?
31 Gtk::CheckButton * auto_scale;
33 ///Should node size track zoom factor?
34 Gtk::CheckButton * zoom_track;
36 ///Minimum and maximum node radius entry
37 Gtk::SpinButton * radius_size, * edge_width;
39 ///The notebook that has tabs (\ref NoteBookTab) with different graphs.
40 Gtk::Notebook notebook;
42 ///The tool selected to manipulate graph.
44 ///It has to be stored, because in case of tabswitching
45 ///the correct tool has to be set for the actual graph.
48 ///The number of active tab in the notebook.
51 ///Vector of existing tabs in the notebook.
52 std::vector<NoteBookTab *> tabs;
54 ///Vector of the name of tabs.
56 ///All \ref NoteBookTab has a name that is stored here. The index of the name
57 ///is the same as the index of the \ref NoteBookTab in \ref tabs.
58 std::vector<std::string> tabnames;
60 ///Counter of occurence of the same file names.
62 ///If a file is opened more than once we have to score
63 ///the occurences to let the titles on tabs different.
64 ///If more than one occurence is present, from the second
65 ///one near the filename the number of the occurence appear.
66 std::map<std::string, int> strinst;
68 ///Set of opened \ref AlgoWin s.
70 ///More than one \refAlgoWin can be opened. We have to
71 ///communicate with them in case of new \ref NoteBookTab creation,
72 ///\ref NoteBookTab close, or map change. Therefore we have to score
74 std::set< AlgoWin* > aws;
78 ///Constructor of the \ref MainWin.
80 ///It creates the menus, the toolbar and the notebook in which
81 ///\ref NoteBookTab s take place. \ref NoteBookTab s are the
82 ///holder of the canvases on which the graphs are drawn.
85 ///Sets title of tabs.
87 ///It alse registrates it in \ref tabnames. If more than one
88 ///occurence is in the notebook of the same file it has to
89 ///extend tabname with the number of occurence.
90 void set_tabtitle(std::string);
92 ///ActionGroup for menu
93 Glib::RefPtr<Gtk::ActionGroup> ag;
96 Glib::RefPtr<Gtk::UIManager> uim;
98 ///Creates a new \ref NoteBookTab and opens the given file.
100 ///It is called only with command line parameters at stratup.
101 void readFile(const std::string &);
104 Gtk::Tooltips tooltips;
106 //Call-backs of buttons
108 ///Callback for 'FileNew' action.
109 virtual void newFile();
110 ///Callback for 'FileOpen' action.
111 virtual void openFile();
112 ///Callback for 'FileSave' action.
113 virtual void saveFile();
114 ///Callback for 'FileSaveAs' action.
115 virtual void saveFileAs();
116 ///Callback for 'Close' action.
117 virtual void close();
121 ///Callback for 'zoomIn' action.
123 ///It calls the appropriate function in
124 ///\ref GraphDisplayerCanvas
125 virtual void zoomIn();
126 ///Callback for 'zoomOut' action.
128 ///It calls the appropriate function in
129 ///\ref GraphDisplayerCanvas
130 virtual void zoomOut();
131 ///Callback for 'zoomFit' action.
133 ///It calls the appropriate function in
134 ///\ref GraphDisplayerCanvas
135 virtual void zoomFit();
136 ///Callback for 'zoom100' action.
138 ///It calls the appropriate function in
139 ///\ref GraphDisplayerCanvas
140 virtual void zoom100();
142 ///Callback for Show Maps menupoint.
144 ///It calls the appropriate function in
146 virtual void createMapWin();
148 ///Callback for Show Design menupoint.
150 ///It calls the appropriate function in
152 virtual void createDesignWin();
154 ///Pops up an Algorithm window.
156 ///It not only creates but registrates the newly created \ref AlgoWin.
157 ///It is necessary, because in case of changement between tabs or maps
158 ///we have to communicate with it. Signals are also have to be connected
159 ///to it, because \ref AlgoWin emits signals if it needs anything (maplist, deregistration).
160 ///\param algo type of the algorithm to run.
161 virtual void createAlgoWin(int algo);
163 ///Deregisters AlgoWin
165 ///This is the function connected to the closing signal of \ref AlgoWin.
166 ///It only deletes the sender \ref AlgoWin from \ref aws. This function
167 ///is called only by the closing \ref AlgoWin itself.
168 ///\param aw the \ref AlgoWin to delete.
169 virtual void deRegisterAlgoWin(AlgoWin * aw);
171 ///Updates list of tabs in all of the \ref AlgoWin
173 ///When \ref NoteBookTab inserted somewhere or closed one tablist in all \ref AlgoWin
174 ///have to be updated. That is why we score all the opened \ref AlgoWin.
175 ///During update \ref tabnames will be passed to each \ref AlgoWin.
176 virtual void updateAlgoWinTabs();
178 ///Refresh list of maps in the AlgoWin that requested it.
180 ///In an \ref AlgoWin there is a ComboBoxText, in which
181 ///a \ref NoteBookTab can be chosen that contains the graph and the maps,
182 ///on which we would like to run algorithms. If we change the
183 ///tab the available maps also have to be updated, because
184 ///in the different tabs different maps are available. Therefore
185 ///on tab change the \ref AlgoWin emits a signal that contains itself
186 ///so that the appropriate maps can be sent to it. For the sake of simplicity
187 ///the program answers this call with the mapstorage of the newly selected tab.
188 ///\param aw the caller \ref AlgoWin
189 ///\param tabname the newly selected tab in the \ref AlgoWin
190 virtual void updateAlgoWinMaps(AlgoWin * aw, std::string tabname);
192 ///Registrates the new graph-editor tool in hand.
194 ///The editor-tool in hand is global, it is the same for all tab
195 ///at the same time. Therefore the active tool has to be scored here (\ref active_tool).
196 ///This function is the callback function of the editor-tool buttons. It sets \ref active_tool
197 ///to the correct value.
198 ///\param tool the newly selected graph-editor tool (See all_include.h)
199 virtual void changeEditorialTool(int tool);
201 ///Pops up a \ref NewMapWin dialog after requested by a \ref MapWin
203 ///Each tab can pop-up a \ref MapWin. In \ref MapWin new tab can be created.
204 ///In this case \ref NoteBookTab emits a signal. This function is connected to that signal.
205 ///It sends the caller \ref NoteBookTab and whether an edgemap or a nodemap should be created.
206 ///Caller \ref NoteBookTab is necessary for the window to be able to place the new map in its
208 ///\param nbt the caller tab
209 ///\param itisedge true if edgemap has to be created, false if nodemap
210 virtual void createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge);
212 ///Pops up a \ref NewMapWin dialog after requested by an \ref AlgoWin
214 ///\ref AlgoWin can also can request a \ref NewMapWin to pop-up.
215 ///It emits a signal in this case. This function is bound to that signal.
216 ///The signal contains the name of \ref NoteBookTab in which the new map has to be
217 ///placed and whether the new map is an edgemap or a nodemap.
218 ///\ref tabname the tab in which the new map has to be placed
219 ///\ref itisedge true if the new map will be edge map, false if it will be nodemap
220 virtual void createNewMapWinTabString(std::string tabname, bool itisedge);
222 ///Pops up a \ref NewMapWin dialog if button on \ref MainWin has been pressed.
224 ///In this case a general \ref NewMapWin will be popped up. This means that
225 ///both edge and nodemap can be created by it. The new map will be placed in
226 ///\MapStorage of the actual selected \ref NoteBookTab.
227 virtual void createNewMapWin();
230 ///Callback for 'FileNewTab' action.
231 virtual void newTab();
233 ///Callback for 'FileCloseTab' action.
235 ///It closes the actual \ref NoteBookTab and registrates this event:
236 ///data is shifted to the correct places in vectors.
237 virtual void closeTab();
239 ///Tabswitching handler
241 ///Sets the variables that have to store the actual state, and it
242 ///updates the title of window to the actually selected \ref NoteBookTab.
243 virtual void onChangeTab(GtkNotebookPage*, guint);
245 virtual void nodeViewChanged();
247 virtual void reDesignGraph();