Forgot the meat.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
24 #include "mapstorage.h"
26 //#include "eps_win.h"
28 #include "design_win.h"
29 #include "graph_displayer_canvas.h"
30 #include <libgnomecanvasmm.h>
31 #include <libgnomecanvasmm/polygon.h>
33 ///One tab in the Notebook that is placed in the main window (\ref MainWin).
35 ///One graph and all of its accessories like maps are assigned to one tab in the notebook.
36 ///\ref NoteBookTab is responsible for the user defined display of the graph: view can be
37 ///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
38 ///view of graph. This is \ref Mapwin window.
40 ///\ref NoteBookTab is also
41 ///responsible for modify the graph if it is
42 ///requested. Therefore it is responsible for translating user events to modifications to
43 ///do on graph, like node/edge addition/deletion, map modification, addition and so on.
45 ///To be able to solve these tasks the help of \ref MainWin is also needed, for example to
46 ///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab.
48 ///Some information in the other direction is needed as well: for example when new map creation is requested for this tab
49 ///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals
50 ///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary.
51 class NoteBookTab : public Gtk::VBox
55 ///Constructor of \ref NoteBookTab
57 ///It initiates the \re GraphDisplayerCanvas, on which the graph will be drawn
58 ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
61 ///Maps assigned to the graph displayed in this \ref NoteBookTab of notebook.
62 MapStorage mapstorage;
64 ///Title changement indicator.
66 ///If graph is loaded from disk or saved to disk or changed its name somehow
67 ///this signal will be emit to let
68 ///\ref MainWin know that it has to modify the title of the main window.
69 ///It contains the new title.
70 sigc::signal<void, std::string> signal_title;
72 ///Returns \ref signal_title to be the caller able to connect it to a callback function.
73 sigc::signal<void, std::string> signal_title_ch();
75 ///Indicates that new map window should be popped up.
77 ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
78 ///The signal contains whether an edgemap or a nodemap should be popped up. \ref NewMapWin
79 ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
80 ///but for example \ref MainWin and \ref AlgoWin s as well.
81 sigc::signal<void, NoteBookTab *, bool> signal_newmap;
83 ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
84 sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
86 ///Loads the given file.
88 ///The given file will be load in the \ref MapStorage and afeter that
89 ///\ref GraphDisplayerCanvas will be requested to display the graph.
90 ///\ref GraphDisplayer will get datas from the recently set \ref MapStorage.
91 void readFile(const std::string &);
93 ///The graph will be drawn on this \ref GraphDisplayerCanvas
94 GraphDisplayerCanvas * gd_canvas;
96 ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
99 ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
100 bool designwinexists;
102 ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
105 ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
107 ///Only one of this window can be opened at the same time (\ref mapwinexists),
108 ///because there is no need for more, one per tab is enough.
109 ///There won1t be benefit of more than one, but it would be
110 ///more complicated to synchronize them.
113 ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
115 ///Only one of this window can be opened at the same time (\ref designwinexists),
116 ///because there is no need for more, one per tab is enough.
117 ///There won't be benefit of more than one, but it would be
118 ///more complicated to synchronize them.
119 DesignWin * designwin;
121 ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
123 ///Only one of this window can be opened at the same time (\ref epswinexists),
124 ///because there is no need for more, one per tab is enough.
125 ///There won't be benefit of more than one.
129 ///Callback for 'FileNew' action.
130 virtual void newFile();
131 ///Callback for 'FileOpen' action.
132 virtual void openFile();
133 ///Callback for 'FileSave' action.
134 virtual void saveFile();
135 ///Callback for 'FileSaveAs' action.
136 virtual void saveFileAs();
137 ///Callback for 'Close' action.
138 virtual void close();
140 ///Handles changement of view of graph.
142 ///If the user changes the map to show by a property to a nother in \ref MapWin,
143 ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
144 ///the new map to display by the changed property. After that \ref MapStorage will
145 ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the
146 ///appropriate parts of graph.
147 ///\param itiesedge whether the changed property is edge property or node property
148 ///\param prop id of property, see all_include.h
149 ///\param mapname name of the recently selected map
150 void propertyChange(bool itisedge, int prop, std::string mapname);
152 ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
154 ///This function is called by \ref MapWin.
155 ///\param itisedge whether the new map should be an edgemap or a nodemap.
156 void popupNewMapWin(bool itisedge);
158 ///Returns the actually selected edgemap to visualize by the given property.
160 ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
161 ///\param prop property to inquire.
162 std::string getActiveEdgeMap(int prop);
164 ///Returns the actually selected nodemap to visualize by the given property.
166 ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
167 ///\param prop property to inquire.
168 std::string getActiveNodeMap(int prop);
170 ///Registers recently created edgemap in \ref MapWin.
172 ///After creation of new map \ref MapStorage emits a signal.
173 ///This signal is bound to this callback function, that will call
174 ///a function with the same name and same parameterin \ref MapWin.
175 ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
176 ///\param mapname name of new map
177 void registerNewEdgeMap(std::string mapname);
179 ///Registers recently created nodemap in \ref MapWin.
181 ///After creation of new map \ref MapStorage emits a signal.
182 ///This signal is bound to this callback function, that will call
183 ///a function with the same name and same parameter in \ref MapWin.
184 ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
185 ///\param mapname name of new map
186 void registerNewNodeMap(std::string mapname);
188 ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
192 void createMapWin(std::string);
194 ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
198 void createDesignWin(std::string);
200 ///Pops up a window, that can dump graph to EPS
202 ///Different parameters can be set here.
203 void createExportToEPSWin(std::string);
205 ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
211 ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
215 bool closeDesignWin(GdkEventAny *);
217 ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
223 ///Sets node representation settings
224 void setView(bool, bool, double, double);
226 ///Gets node representation settings
227 void getView(bool &, bool &, double&, double&);
229 ///Let the graph redesign, based on gravity and edge elasticity.
230 void reDesignGraph();
232 ///Lets Mapstorage export the graph to EPS
233 void exportGraphToEPS(std::vector<bool>, std::string);
235 ///\ref MapWin calls this function when it updates the maplist in comboboxes.
236 void active_maps_needed();
239 ///Signal connection from \ref MapStorage to \ref MapWin
241 ///If \ref MapWin is closed this connection has to be disconnected,
242 ///therefore we have to store it.
243 sigc::connection mapst2mapwin;
245 ///Signal connection from \ref MapStorage to \ref DesignWin
247 ///If \ref DesignWin is closed this connection has to be disconnected,
248 ///therefore we have to store it.
249 sigc::connection mapst2designwin;