COIN-OR::LEMON - Graph Library

source: glemon/nbtab.h @ 2:fdb8a163000f

Last change on this file since 2:fdb8a163000f was 1:67188bd752db, checked in by Peter Hegyi <hegyi@…>, 16 years ago

SVN revision 3500 made compilable with Lemon 1.0.

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 DigraphDisplayerCanvas;
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 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.
38///
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.
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 DigraphDisplayerCanvas, on which the digraph will be drawn
57  ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
58  NoteBookTab();
59 
60  ~NoteBookTab();
61 
62  ///Maps assigned to the digraph displayed in this \ref NoteBookTab of notebook.
63  MapStorage * mapstorage;
64   
65  ///Title changement indicator.
66
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;
72
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();
75
76  ///Indicates that new map window should be popped up.
77
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;
83
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();
86
87  ///Loads the given file.
88
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 &);
93   
94  ///The digraph will be drawn on this \ref DigraphDisplayerCanvas
95  DigraphDisplayerCanvas * gd_canvas;
96
97  ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
98  bool mapwinexists;
99
100  ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
101  bool designwinexists;
102
103  ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
104  bool epswinexists;
105
106  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
107
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.
112  MapWin * mapwin;
113   
114  ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
115
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;
121
122  ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
123
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.
127  EpsWin * epswin;
128
129public:
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();
140
141  ///Handles changement of view of digraph.
142
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);
152
153  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
154
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);
158
159  ///Returns the actually selected arcmap to visualize by the given property.
160
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);
164
165  ///Returns the actually selected nodemap to visualize by the given property.
166
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);
170
171  ///Registers recently created arcmap in \ref MapWin.
172
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);
179
180  ///Registers recently created nodemap in \ref MapWin.
181
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);
188
189  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
190 
191  ///See also
192  ///\ref mapwin.
193  void createMapWin(std::string);
194
195  ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
196 
197  ///See also
198  ///\ref mapwin.
199  void createDesignWin(std::string);
200
201  ///Pops up a window, that can dump digraph to EPS
202
203  ///Different parameters can be set here.
204  void createExportToEPSWin(std::string);
205
206  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
207 
208  ///See also
209  ///\ref mapwin.
210  void closeMapWin();
211
212  ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
213 
214  ///See also
215  ///\ref designwin.
216  bool closeDesignWin(GdkEventAny *);
217
218  ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
219 
220  ///See also
221  ///\ref epswin.
222  void closeEpsWin();
223
224  ///Sets node representation settings
225  void setView(bool, bool, double, double);
226
227  ///Gets node representation settings
228  void getView(bool &, bool &, double&, double&);
229
230  ///Let the digraph redesign, based on gravity and arc elasticity.
231  void reDesignDigraph();
232
233  ///Lets Mapstorage export the digraph to EPS
234  void exportDigraphToEPS(std::vector<bool>, std::string, std::string);
235
236  ///\ref MapWin calls this function when it updates the maplist in comboboxes.
237  void active_maps_needed();
238
239private:
240  ///Called when title of tab has changed
241  void title_changed(std::string);
242
243  ///Signal connection from \ref MapStorage to \ref MapWin
244
245  ///If \ref MapWin is closed this connection has to be disconnected,
246  ///therefore we have to store it.
247  sigc::connection mapst2mapwin;
248
249  ///Signal connection from \ref MapStorage to \ref DesignWin
250
251  ///If \ref DesignWin is closed this connection has to be disconnected,
252  ///therefore we have to store it.
253  sigc::connection mapst2designwin;
254};
255
256#endif //NBTAB_H
Note: See TracBrowser for help on using the repository browser.