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
26 class GraphDisplayerCanvas;
28 #include <libgnomecanvasmm.h>
29 #include <libgnomecanvasmm/polygon.h>
31 ///One tab in the Notebook that is placed in the main window (\ref MainWin).
33 ///One graph and all of its accessories like maps are assigned to one tab in the notebook.
34 ///\ref NoteBookTab is responsible for the user defined display of the graph: view can be
35 ///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
36 ///view of graph. This is \ref Mapwin window.
38 ///\ref NoteBookTab is also
39 ///responsible for modify the graph if it is
40 ///requested. Therefore it is responsible for translating user events to modifications to
41 ///do on graph, like node/edge addition/deletion, map modification, addition and so on.
43 ///To be able to solve these tasks the help of \ref MainWin is also needed, for example to
44 ///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab.
46 ///Some information in the other direction is needed as well: for example when new map creation is requested for this tab
47 ///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals
48 ///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary.
49 class NoteBookTab : public Gtk::VBox
53 ///Constructor of \ref NoteBookTab
55 ///It initiates the \re GraphDisplayerCanvas, on which the graph will be drawn
56 ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
59 ///Maps assigned to the graph displayed in this \ref NoteBookTab of notebook.
60 MapStorage * mapstorage;
62 ///Title changement indicator.
64 ///If graph is loaded from disk or saved to disk or changed its name somehow
65 ///this signal will be emit to let
66 ///\ref MainWin know that it has to modify the title of the main window.
67 ///It contains the new title.
68 sigc::signal<void, std::string> signal_title;
70 ///Returns \ref signal_title to be the caller able to connect it to a callback function.
71 sigc::signal<void, std::string> signal_title_ch();
73 ///Indicates that new map window should be popped up.
75 ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
76 ///The signal contains whether an edgemap or a nodemap should be popped up. \ref NewMapWin
77 ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
78 ///but for example \ref MainWin and \ref AlgoWin s as well.
79 sigc::signal<void, NoteBookTab *, bool> signal_newmap;
81 ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
82 sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
84 ///Loads the given file.
86 ///The given file will be load in the \ref MapStorage and afeter that
87 ///\ref GraphDisplayerCanvas will be requested to display the graph.
88 ///\ref GraphDisplayer will get datas from the recently set \ref MapStorage.
89 void readFile(const std::string &);
91 ///The graph will be drawn on this \ref GraphDisplayerCanvas
92 GraphDisplayerCanvas * gd_canvas;
94 ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
97 ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
100 ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
103 ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
105 ///Only one of this window can be opened at the same time (\ref mapwinexists),
106 ///because there is no need for more, one per tab is enough.
107 ///There won1t be benefit of more than one, but it would be
108 ///more complicated to synchronize them.
111 ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
113 ///Only one of this window can be opened at the same time (\ref designwinexists),
114 ///because there is no need for more, one per tab is enough.
115 ///There won't be benefit of more than one, but it would be
116 ///more complicated to synchronize them.
117 DesignWin * designwin;
119 ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
121 ///Only one of this window can be opened at the same time (\ref epswinexists),
122 ///because there is no need for more, one per tab is enough.
123 ///There won't be benefit of more than one.
127 ///Callback for 'FileNew' action.
128 virtual void newFile();
129 ///Callback for 'FileOpen' action.
130 virtual void openFile();
131 ///Callback for 'FileSave' action.
132 virtual void saveFile();
133 ///Callback for 'FileSaveAs' action.
134 virtual void saveFileAs();
135 ///Callback for 'Close' action.
136 virtual void close();
138 ///Handles changement of view of graph.
140 ///If the user changes the map to show by a property to a nother in \ref MapWin,
141 ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
142 ///the new map to display by the changed property. After that \ref MapStorage will
143 ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the
144 ///appropriate parts of graph.
145 ///\param itiesedge whether the changed property is edge property or node property
146 ///\param prop id of property, see all_include.h
147 ///\param mapname name of the recently selected map
148 void propertyChange(bool itisedge, int prop, std::string mapname);
150 ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
152 ///This function is called by \ref MapWin.
153 ///\param itisedge whether the new map should be an edgemap or a nodemap.
154 void popupNewMapWin(bool itisedge);
156 ///Returns the actually selected edgemap to visualize by the given property.
158 ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
159 ///\param prop property to inquire.
160 std::string getActiveEdgeMap(int prop);
162 ///Returns the actually selected nodemap to visualize by the given property.
164 ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
165 ///\param prop property to inquire.
166 std::string getActiveNodeMap(int prop);
168 ///Registers recently created edgemap in \ref MapWin.
170 ///After creation of new map \ref MapStorage emits a signal.
171 ///This signal is bound to this callback function, that will call
172 ///a function with the same name and same parameterin \ref MapWin.
173 ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
174 ///\param mapname name of new map
175 void registerNewEdgeMap(std::string mapname);
177 ///Registers recently created nodemap in \ref MapWin.
179 ///After creation of new map \ref MapStorage emits a signal.
180 ///This signal is bound to this callback function, that will call
181 ///a function with the same name and same parameter in \ref MapWin.
182 ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
183 ///\param mapname name of new map
184 void registerNewNodeMap(std::string mapname);
186 ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
190 void createMapWin(std::string);
192 ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
196 void createDesignWin(std::string);
198 ///Pops up a window, that can dump graph to EPS
200 ///Different parameters can be set here.
201 void createExportToEPSWin(std::string);
203 ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
209 ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
213 bool closeDesignWin(GdkEventAny *);
215 ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
221 ///Sets node representation settings
222 void setView(bool, bool, double, double);
224 ///Gets node representation settings
225 void getView(bool &, bool &, double&, double&);
227 ///Let the graph redesign, based on gravity and edge elasticity.
228 void reDesignGraph();
230 ///Lets Mapstorage export the graph to EPS
231 void exportGraphToEPS(std::vector<bool>, std::string);
233 ///\ref MapWin calls this function when it updates the maplist in comboboxes.
234 void active_maps_needed();
237 ///Signal connection from \ref MapStorage to \ref MapWin
239 ///If \ref MapWin is closed this connection has to be disconnected,
240 ///therefore we have to store it.
241 sigc::connection mapst2mapwin;
243 ///Signal connection from \ref MapStorage to \ref DesignWin
245 ///If \ref DesignWin is closed this connection has to be disconnected,
246 ///therefore we have to store it.
247 sigc::connection mapst2designwin;