COIN-OR::LEMON - Graph Library

source: glemon-0.x/nbtab.h @ 191:af2ed974ab68

Last change on this file since 191:af2ed974ab68 was 191:af2ed974ab68, checked in by Hegyi Péter, 13 years ago

GUI can now export graph to EPS.

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