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 DigraphDisplayerCanvas;
28 #include <libgnomecanvasmm.h>
29 #include <libgnomecanvasmm/polygon.h>
30 #include "map_value.h"
32 ///One tab in the Notebook that is placed in the main window (\ref MainWin).
34 ///One digraph and all of its accessories like maps are assigned to one tab in the notebook.
35 ///\ref NoteBookTab is responsible for the user defined display of the digraph: view can be
36 ///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
37 ///view of digraph. This is \ref Mapwin window.
39 ///\ref NoteBookTab is also
40 ///responsible for modify the digraph if it is
41 ///requested. Therefore it is responsible for translating user events to modifications to
42 ///do on digraph, like node/arc addition/deletion, map modification, addition and so on.
44 ///To be able to solve these tasks the help of \ref MainWin is also needed, for example to
45 ///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab.
47 ///Some information in the other direction is needed as well: for example when new map creation is requested for this tab
48 ///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals
49 ///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary.
50 class NoteBookTab : public Gtk::VBox
54 ///Constructor of \ref NoteBookTab
56 ///It initiates the \re DigraphDisplayerCanvas, on which the digraph will be drawn
57 ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
62 ///Maps assigned to the digraph displayed in this \ref NoteBookTab of notebook.
63 MapStorage * mapstorage;
65 ///Title changement indicator.
67 ///If digraph is loaded from disk or saved to disk or changed its name somehow
68 ///this signal will be emit to let
69 ///\ref MainWin know that it has to modify the title of the main window.
70 ///It contains the new title.
71 sigc::signal<void, std::string> signal_title;
73 ///Returns \ref signal_title to be the caller able to connect it to a callback function.
74 sigc::signal<void, std::string> signal_title_ch();
76 ///Indicates that new map window should be popped up.
78 ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
79 ///The signal contains whether an arcmap or a nodemap should be popped up. \ref NewMapWin
80 ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
81 ///but for example \ref MainWin and \ref AlgoWin s as well.
82 sigc::signal<void, NoteBookTab *, bool> signal_newmap;
84 ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
85 sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
87 ///Loads the given file.
89 ///The given file will be load in the \ref MapStorage and afeter that
90 ///\ref DigraphDisplayerCanvas will be requested to display the digraph.
91 ///\ref DigraphDisplayer will get datas from the recently set \ref MapStorage.
92 void readFile(const std::string &);
94 ///The digraph will be drawn on this \ref DigraphDisplayerCanvas
95 DigraphDisplayerCanvas * gd_canvas;
97 ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
100 ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
101 bool designwinexists;
103 ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
106 ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
108 ///Only one of this window can be opened at the same time (\ref mapwinexists),
109 ///because there is no need for more, one per tab is enough.
110 ///There won1t be benefit of more than one, but it would be
111 ///more complicated to synchronize them.
114 ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
116 ///Only one of this window can be opened at the same time (\ref designwinexists),
117 ///because there is no need for more, one per tab is enough.
118 ///There won't be benefit of more than one, but it would be
119 ///more complicated to synchronize them.
120 DesignWin * designwin;
122 ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
124 ///Only one of this window can be opened at the same time (\ref epswinexists),
125 ///because there is no need for more, one per tab is enough.
126 ///There won't be benefit of more than one.
130 ///Callback for 'FileNew' action.
131 virtual void newFile();
132 ///Callback for 'FileOpen' action.
133 virtual void openFile();
134 ///Callback for 'FileSave' action.
135 virtual void saveFile();
136 ///Callback for 'FileSaveAs' action.
137 virtual void saveFileAs();
138 ///Callback for 'Close' action.
139 virtual void close();
141 ///Handles changement of view of digraph.
143 ///If the user changes the map to show by a property to a nother in \ref MapWin,
144 ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
145 ///the new map to display by the changed property. After that \ref MapStorage will
146 ///emits a signal that will be forwarded to \ref DigraphDisplayerCanvas to update the
147 ///appropriate parts of digraph.
148 ///\param itiesarc whether the changed property is arc property or node property
149 ///\param prop id of property, see all_include.h
150 ///\param mapname name of the recently selected map
151 void propertyChange(bool itisarc, int prop, std::string mapname);
153 ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
155 ///This function is called by \ref MapWin.
156 ///\param itisarc whether the new map should be an arcmap or a nodemap.
157 void popupNewMapWin(bool itisarc);
159 ///Returns the actually selected arcmap to visualize by the given property.
161 ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
162 ///\param prop property to inquire.
163 std::string getActiveArcMap(int prop);
165 ///Returns the actually selected nodemap to visualize by the given property.
167 ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
168 ///\param prop property to inquire.
169 std::string getActiveNodeMap(int prop);
171 ///Registers recently created arcmap in \ref MapWin.
173 ///After creation of new map \ref MapStorage emits a signal.
174 ///This signal is bound to this callback function, that will call
175 ///a function with the same name and same parameterin \ref MapWin.
176 ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
177 ///\param mapname name of new map
178 void registerNewArcMap(std::string mapname, MapValue::Type type);
180 ///Registers recently created nodemap in \ref MapWin.
182 ///After creation of new map \ref MapStorage emits a signal.
183 ///This signal is bound to this callback function, that will call
184 ///a function with the same name and same parameter in \ref MapWin.
185 ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
186 ///\param mapname name of new map
187 void registerNewNodeMap(std::string mapname, MapValue::Type type);
189 ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
193 void createMapWin(std::string);
195 ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
199 void createDesignWin(std::string);
201 ///Pops up a window, that can dump digraph to EPS
203 ///Different parameters can be set here.
204 void createExportToEPSWin(std::string);
206 ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
212 ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
216 bool closeDesignWin(GdkEventAny *);
218 ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
224 ///Sets node representation settings
225 void setView(bool, bool, double, double);
227 ///Gets node representation settings
228 void getView(bool &, bool &, double&, double&);
230 ///Let the digraph redesign, based on gravity and arc elasticity.
231 void reDesignDigraph();
233 ///Lets Mapstorage export the digraph to EPS
234 void exportDigraphToEPS(std::vector<bool>, std::string, std::string);
236 ///\ref MapWin calls this function when it updates the maplist in comboboxes.
237 void active_maps_needed();
240 ///Called when title of tab has changed
241 void title_changed(std::string);
243 ///Signal connection from \ref MapStorage to \ref MapWin
245 ///If \ref MapWin is closed this connection has to be disconnected,
246 ///therefore we have to store it.
247 sigc::connection mapst2mapwin;
249 ///Signal connection from \ref MapStorage to \ref DesignWin
251 ///If \ref DesignWin is closed this connection has to be disconnected,
252 ///therefore we have to store it.
253 sigc::connection mapst2designwin;