COIN-OR::LEMON - Graph Library

source: glemon-0.x/nbtab.h

Last change on this file was 177:40f3006fba2e, checked in by Hegyi Péter, 13 years ago

Redesign parameters can now be saved and loaded.

File size: 8.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 NoteBookTab;
23
24#include "mapstorage.h"
25#include "map_win.h"
26#include "design_win.h"
27#include "graph_displayer_canvas.h"
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  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
101
102  ///Only one of this window can be opened at the same time (\ref mapwinexists),
103  ///because there is no need for more, one per tab is enough.
104  ///There won1t be benefit of more than one, but it would be
105  ///more complicated to synchronize them.
106  MapWin * mapwin;
107   
108  ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
109
110  ///Only one of this window can be opened at the same time (\ref designwinexists),
111  ///because there is no need for more, one per tab is enough.
112  ///There won't be benefit of more than one, but it would be
113  ///more complicated to synchronize them.
114  DesignWin * designwin;
115
116public:
117  ///Callback for 'FileNew' action.
118  virtual void newFile();
119  ///Callback for 'FileOpen' action.
120  virtual void openFile();
121  ///Callback for 'FileSave' action.
122  virtual void saveFile();
123  ///Callback for 'FileSaveAs' action.
124  virtual void saveFileAs();
125  ///Callback for 'Close' action.
126  virtual void close();
127
128  ///Handles changement of view of graph.
129
130  ///If the user changes the map to show by a property to a nother in \ref MapWin,
131  ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
132  ///the new map to display by the changed property. After that \ref MapStorage will
133  ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the
134  ///appropriate parts of graph.
135  ///\param itiesedge whether the changed property is edge property or node property
136  ///\param prop id of property, see all_include.h
137  ///\param mapname name of the recently selected map
138  void propertyChange(bool itisedge, int prop, std::string mapname);
139
140  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
141
142  ///This function is called by \ref MapWin.
143  ///\param itisedge whether the new map should be an edgemap or a nodemap.
144  void popupNewMapWin(bool itisedge);
145
146  ///Returns the actually selected edgemap to visualize by the given property.
147
148  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
149  ///\param prop property to inquire.
150  std::string getActiveEdgeMap(int prop);
151
152  ///Returns the actually selected nodemap to visualize by the given property.
153
154  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
155  ///\param prop property to inquire.
156  std::string getActiveNodeMap(int prop);
157
158  ///Registers recently created edgemap in \ref MapWin.
159
160  ///After creation of new map \ref MapStorage emits a signal.
161  ///This signal is bound to this callback function, that will call
162  ///a function with the same name and same parameterin \ref MapWin.
163  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
164  ///\param mapname name of new map
165  void registerNewEdgeMap(std::string mapname);
166
167  ///Registers recently created nodemap in \ref MapWin.
168
169  ///After creation of new map \ref MapStorage emits a signal.
170  ///This signal is bound to this callback function, that will call
171  ///a function with the same name and same parameter in \ref MapWin.
172  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
173  ///\param mapname name of new map
174  void registerNewNodeMap(std::string mapname);
175
176  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
177 
178  ///See also
179  ///\ref mapwin.
180  void createMapWin(std::string);
181
182  ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
183 
184  ///See also
185  ///\ref mapwin.
186  void createDesignWin(std::string);
187
188  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
189 
190  ///See also
191  ///\ref mapwin.
192  void closeMapWin();
193
194  bool closeDesignWin(GdkEventAny *);
195
196  ///Sets node representation settings
197  void setView(bool, bool, double, double);
198
199  ///Gets node representation settings
200  void getView(bool &, bool &, double&, double&);
201
202  ///Let the graph redesign, based on gravity and edge elasticity.
203  void reDesignGraph();
204
205  ///\ref MapWin calls this function when it updates the maplist in comboboxes.
206  void active_maps_needed();
207
208private:
209  ///Signal connection from \ref MapStorage to \ref MapWin
210
211  ///If \ref MapWin is closed this connection has to be disconnected,
212  ///therefore we have to store it.
213  sigc::connection mapst2mapwin;
214
215  ///Signal connection from \ref MapStorage to \ref DesignWin
216
217  ///If \ref DesignWin is closed this connection has to be disconnected,
218  ///therefore we have to store it.
219  sigc::connection mapst2designwin;
220};
221
222#endif //NBTAB_H
Note: See TracBrowser for help on using the repository browser.