COIN-OR::LEMON - Graph Library

source: glemon-0.x/nbtab.h @ 197:c1084e2bff10

Last change on this file since 197:c1084e2bff10 was 196:c220f9de6545, checked in by Hegyi Péter, 17 years ago

EpsWin? and DesignWin? does not need to know NoteBookTab?.

File size: 9.3 KB
Line 
1/* -*- C++ -*-
2 *
3 * This file is a part of LEMON, a generic C++ optimization library
4 *
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 *
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.
12 *
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
15 * purpose.
16 *
17 */
18
19#ifndef NBTAB_H
20#define NBTAB_H
21
22class MapStorage;
23class EpsWin;
24class MapWin;
25class DesignWin;
26class GraphDisplayerCanvas;
27
28#include <libgnomecanvasmm.h>
29#include <libgnomecanvasmm/polygon.h>
30
31///One tab in the Notebook that is placed in the main window (\ref MainWin).
32
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.
37///
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.
42///
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.
45///
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.
49class NoteBookTab : public Gtk::VBox
50{
51public:
52 
53  ///Constructor of \ref NoteBookTab
54
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.
57  NoteBookTab();
58 
59  ///Maps assigned to the graph displayed in this \ref NoteBookTab of notebook.
60  MapStorage * mapstorage;
61   
62  ///Title changement indicator.
63
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;
69
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();
72
73  ///Indicates that new map window should be popped up.
74
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;
80
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();
83
84  ///Loads the given file.
85
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 &);
90   
91  ///The graph will be drawn on this \ref GraphDisplayerCanvas
92  GraphDisplayerCanvas * gd_canvas;
93
94  ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
95  bool mapwinexists;
96
97  ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
98  bool designwinexists;
99
100  ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
101  bool epswinexists;
102
103  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
104
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.
109  MapWin * mapwin;
110   
111  ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
112
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;
118
119  ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
120
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.
124  EpsWin * epswin;
125
126public:
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();
137
138  ///Handles changement of view of graph.
139
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);
149
150  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
151
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);
155
156  ///Returns the actually selected edgemap to visualize by the given property.
157
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);
161
162  ///Returns the actually selected nodemap to visualize by the given property.
163
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);
167
168  ///Registers recently created edgemap in \ref MapWin.
169
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);
176
177  ///Registers recently created nodemap in \ref MapWin.
178
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);
185
186  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
187 
188  ///See also
189  ///\ref mapwin.
190  void createMapWin(std::string);
191
192  ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
193 
194  ///See also
195  ///\ref mapwin.
196  void createDesignWin(std::string);
197
198  ///Pops up a window, that can dump graph to EPS
199
200  ///Different parameters can be set here.
201  void createExportToEPSWin(std::string);
202
203  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
204 
205  ///See also
206  ///\ref mapwin.
207  void closeMapWin();
208
209  ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
210 
211  ///See also
212  ///\ref designwin.
213  bool closeDesignWin(GdkEventAny *);
214
215  ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
216 
217  ///See also
218  ///\ref epswin.
219  void closeEpsWin();
220
221  ///Sets node representation settings
222  void setView(bool, bool, double, double);
223
224  ///Gets node representation settings
225  void getView(bool &, bool &, double&, double&);
226
227  ///Let the graph redesign, based on gravity and edge elasticity.
228  void reDesignGraph();
229
230  ///Lets Mapstorage export the graph to EPS
231  void exportGraphToEPS(std::vector<bool>, std::string);
232
233  ///\ref MapWin calls this function when it updates the maplist in comboboxes.
234  void active_maps_needed();
235
236private:
237  ///Called when title of tab has changed
238  void title_changed(std::string);
239
240  ///Signal connection from \ref MapStorage to \ref MapWin
241
242  ///If \ref MapWin is closed this connection has to be disconnected,
243  ///therefore we have to store it.
244  sigc::connection mapst2mapwin;
245
246  ///Signal connection from \ref MapStorage to \ref DesignWin
247
248  ///If \ref DesignWin is closed this connection has to be disconnected,
249  ///therefore we have to store it.
250  sigc::connection mapst2designwin;
251};
252
253#endif //NBTAB_H
Note: See TracBrowser for help on using the repository browser.