COIN-OR::LEMON - Graph Library

source: glemon-0.x/nbtab.h @ 201:879e47e5b731

Last change on this file since 201:879e47e5b731 was 201:879e47e5b731, checked in by Akos Ladanyi, 16 years ago

Merge branches/akos to trunk.

File size: 9.4 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#include "map_value.h"
31
32///One tab in the Notebook that is placed in the main window (\ref MainWin).
33
34///One graph 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 graph: view can be
36///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
37///view of graph. This is \ref Mapwin window.
38///
39///\ref NoteBookTab is also
40///responsible for modify the graph if it is
41///requested. Therefore it is responsible for translating user events to modifications to
42///do on graph, like node/edge addition/deletion, map modification, addition and so on.
43///
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.
46///
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.
50class NoteBookTab : public Gtk::VBox
51{
52public:
53 
54  ///Constructor of \ref NoteBookTab
55
56  ///It initiates the \re GraphDisplayerCanvas, on which the graph will be drawn
57  ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
58  NoteBookTab();
59 
60  ///Maps assigned to the graph displayed in this \ref NoteBookTab of notebook.
61  MapStorage * mapstorage;
62   
63  ///Title changement indicator.
64
65  ///If graph is loaded from disk or saved to disk or changed its name somehow
66  ///this signal will be emit to let
67  ///\ref MainWin know that it has to modify the title of the main window.
68  ///It contains the new title.
69  sigc::signal<void, std::string> signal_title;
70
71  ///Returns \ref signal_title to be the caller able to connect it to a callback function.
72  sigc::signal<void, std::string> signal_title_ch();
73
74  ///Indicates that new map window should be popped up.
75
76  ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
77  ///The signal contains whether an edgemap or a nodemap should be popped up. \ref NewMapWin
78  ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
79  ///but for example \ref MainWin and \ref AlgoWin s as well.
80  sigc::signal<void, NoteBookTab *, bool> signal_newmap;
81
82  ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
83  sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
84
85  ///Loads the given file.
86
87  ///The given file will be load in the \ref MapStorage and afeter that
88  ///\ref GraphDisplayerCanvas will be requested to display the graph.
89  ///\ref GraphDisplayer will get datas from the recently set \ref MapStorage.
90  void readFile(const std::string &);
91   
92  ///The graph will be drawn on this \ref GraphDisplayerCanvas
93  GraphDisplayerCanvas * gd_canvas;
94
95  ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
96  bool mapwinexists;
97
98  ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
99  bool designwinexists;
100
101  ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
102  bool epswinexists;
103
104  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
105
106  ///Only one of this window can be opened at the same time (\ref mapwinexists),
107  ///because there is no need for more, one per tab is enough.
108  ///There won1t be benefit of more than one, but it would be
109  ///more complicated to synchronize them.
110  MapWin * mapwin;
111   
112  ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
113
114  ///Only one of this window can be opened at the same time (\ref designwinexists),
115  ///because there is no need for more, one per tab is enough.
116  ///There won't be benefit of more than one, but it would be
117  ///more complicated to synchronize them.
118  DesignWin * designwin;
119
120  ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
121
122  ///Only one of this window can be opened at the same time (\ref epswinexists),
123  ///because there is no need for more, one per tab is enough.
124  ///There won't be benefit of more than one.
125  EpsWin * epswin;
126
127public:
128  ///Callback for 'FileNew' action.
129  virtual void newFile();
130  ///Callback for 'FileOpen' action.
131  virtual void openFile();
132  ///Callback for 'FileSave' action.
133  virtual void saveFile();
134  ///Callback for 'FileSaveAs' action.
135  virtual void saveFileAs();
136  ///Callback for 'Close' action.
137  virtual void close();
138
139  ///Handles changement of view of graph.
140
141  ///If the user changes the map to show by a property to a nother in \ref MapWin,
142  ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
143  ///the new map to display by the changed property. After that \ref MapStorage will
144  ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the
145  ///appropriate parts of graph.
146  ///\param itiesedge whether the changed property is edge property or node property
147  ///\param prop id of property, see all_include.h
148  ///\param mapname name of the recently selected map
149  void propertyChange(bool itisedge, int prop, std::string mapname);
150
151  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
152
153  ///This function is called by \ref MapWin.
154  ///\param itisedge whether the new map should be an edgemap or a nodemap.
155  void popupNewMapWin(bool itisedge);
156
157  ///Returns the actually selected edgemap to visualize by the given property.
158
159  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
160  ///\param prop property to inquire.
161  std::string getActiveEdgeMap(int prop);
162
163  ///Returns the actually selected nodemap to visualize by the given property.
164
165  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
166  ///\param prop property to inquire.
167  std::string getActiveNodeMap(int prop);
168
169  ///Registers recently created edgemap in \ref MapWin.
170
171  ///After creation of new map \ref MapStorage emits a signal.
172  ///This signal is bound to this callback function, that will call
173  ///a function with the same name and same parameterin \ref MapWin.
174  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
175  ///\param mapname name of new map
176  void registerNewEdgeMap(std::string mapname, MapValue::Type type);
177
178  ///Registers recently created nodemap in \ref MapWin.
179
180  ///After creation of new map \ref MapStorage emits a signal.
181  ///This signal is bound to this callback function, that will call
182  ///a function with the same name and same parameter in \ref MapWin.
183  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
184  ///\param mapname name of new map
185  void registerNewNodeMap(std::string mapname, MapValue::Type type);
186
187  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
188 
189  ///See also
190  ///\ref mapwin.
191  void createMapWin(std::string);
192
193  ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
194 
195  ///See also
196  ///\ref mapwin.
197  void createDesignWin(std::string);
198
199  ///Pops up a window, that can dump graph to EPS
200
201  ///Different parameters can be set here.
202  void createExportToEPSWin(std::string);
203
204  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
205 
206  ///See also
207  ///\ref mapwin.
208  void closeMapWin();
209
210  ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
211 
212  ///See also
213  ///\ref designwin.
214  bool closeDesignWin(GdkEventAny *);
215
216  ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
217 
218  ///See also
219  ///\ref epswin.
220  void closeEpsWin();
221
222  ///Sets node representation settings
223  void setView(bool, bool, double, double);
224
225  ///Gets node representation settings
226  void getView(bool &, bool &, double&, double&);
227
228  ///Let the graph redesign, based on gravity and edge elasticity.
229  void reDesignGraph();
230
231  ///Lets Mapstorage export the graph to EPS
232  void exportGraphToEPS(std::vector<bool>, std::string, std::string);
233
234  ///\ref MapWin calls this function when it updates the maplist in comboboxes.
235  void active_maps_needed();
236
237private:
238  ///Called when title of tab has changed
239  void title_changed(std::string);
240
241  ///Signal connection from \ref MapStorage to \ref MapWin
242
243  ///If \ref MapWin is closed this connection has to be disconnected,
244  ///therefore we have to store it.
245  sigc::connection mapst2mapwin;
246
247  ///Signal connection from \ref MapStorage to \ref DesignWin
248
249  ///If \ref DesignWin is closed this connection has to be disconnected,
250  ///therefore we have to store it.
251  sigc::connection mapst2designwin;
252};
253
254#endif //NBTAB_H
Note: See TracBrowser for help on using the repository browser.