COIN-OR::LEMON - Graph Library

source: glemon-0.x/nbtab.h @ 165:2cd447b0bd3a

Last change on this file since 165:2cd447b0bd3a was 160:14a76109b561, checked in by Hegyi Péter, 18 years ago

Node antigravity and edge elasticity based graph layout redesigner.

File size: 7.4 KB
Line 
1// -*- C++ -*- //
2
3#ifndef NBTAB_H
4#define NBTAB_H
5
6class NoteBookTab;
7
8#include "mapstorage.h"
9#include "map_win.h"
10#include "design_win.h"
11#include "graph_displayer_canvas.h"
12#include <libgnomecanvasmm.h>
13#include <libgnomecanvasmm/polygon.h>
14
15///One tab in the Notebook that is placed in the main window (\ref MainWin).
16
17///One graph and all of its accessories like maps are assigned to one tab in the notebook.
18///\ref NoteBookTab is responsible for the user defined display of the graph: view can be
19///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
20///view of graph. This is \ref Mapwin window.
21///
22///\ref NoteBookTab is also
23///responsible for modify the graph if it is
24///requested. Therefore it is responsible for translating user events to modifications to
25///do on graph, like node/edge addition/deletion, map modification, addition and so on.
26///
27///To be able to solve these tasks the help of \ref MainWin is also needed, for example to
28///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab.
29///
30///Some information in the other direction is needed as well: for example when new map creation is requested for this tab
31///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals
32///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary.
33class NoteBookTab : public Gtk::VBox
34{
35public:
36 
37  ///Constructor of \ref NoteBookTab
38
39  ///It initiates the \re GraphDisplayerCanvas, on which the graph will be drawn
40  ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
41  NoteBookTab();
42 
43  ///Maps assigned to the graph displayed in this \ref NoteBookTab of notebook.
44  MapStorage mapstorage;
45   
46  ///Title changement indicator.
47
48  ///If graph is loaded from disk or saved to disk or changed its name somehow
49  ///this signal will be emit to let
50  ///\ref MainWin know that it has to modify the title of the main window.
51  ///It contains the new title.
52  sigc::signal<void, std::string> signal_title;
53
54  ///Returns \ref signal_title to be the caller able to connect it to a callback function.
55  sigc::signal<void, std::string> signal_title_ch();
56
57  ///Indicates that new map window should be popped up.
58
59  ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
60  ///The signal contains whether an edgemap or a nodemap should be popped up. \ref NewMapWin
61  ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
62  ///but for example \ref MainWin and \ref AlgoWin s as well.
63  sigc::signal<void, NoteBookTab *, bool> signal_newmap;
64
65  ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
66  sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
67
68  ///Loads the given file.
69
70  ///The given file will be load in the \ref MapStorage and afeter that
71  ///\ref GraphDisplayerCanvas will be requested to display the graph.
72  ///\ref GraphDisplayer will get datas from the recently set \ref MapStorage.
73  void readFile(const std::string &);
74   
75  ///The graph will be drawn on this \ref GraphDisplayerCanvas
76  GraphDisplayerCanvas * gd_canvas;
77
78  ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
79  bool mapwinexists;
80
81  ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
82  bool designwinexists;
83
84  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
85
86  ///Only one of this window can be opened at the same time (\ref mapwinexists),
87  ///because there is no need for more, one per tab is enough.
88  ///There won1t be benefit of more than one, but it would be
89  ///more complicated to synchronize them.
90  MapWin * mapwin;
91   
92  ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
93
94  ///Only one of this window can be opened at the same time (\ref designwinexists),
95  ///because there is no need for more, one per tab is enough.
96  ///There won't be benefit of more than one, but it would be
97  ///more complicated to synchronize them.
98  DesignWin * designwin;
99
100public:
101  ///Callback for 'FileNew' action.
102  virtual void newFile();
103  ///Callback for 'FileOpen' action.
104  virtual void openFile();
105  ///Callback for 'FileSave' action.
106  virtual void saveFile();
107  ///Callback for 'FileSaveAs' action.
108  virtual void saveFileAs();
109  ///Callback for 'Close' action.
110  virtual void close();
111
112  ///Handles changement of view of graph.
113
114  ///If the user changes the map to show by a property to a nother in \ref MapWin,
115  ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
116  ///the new map to display by the changed property. After that \ref MapStorage will
117  ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the
118  ///appropriate parts of graph.
119  ///\param itiesedge whether the changed property is edge property or node property
120  ///\param prop id of property, see all_include.h
121  ///\param mapname name of the recently selected map
122  void propertyChange(bool itisedge, int prop, std::string mapname);
123
124  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
125
126  ///This function is called by \ref MapWin.
127  ///\param itisedge whether the new map should be an edgemap or a nodemap.
128  void popupNewMapWin(bool itisedge);
129
130  ///Returns the actually selected edgemap to visualize by the given property.
131
132  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
133  ///\param prop property to inquire.
134  std::string getActiveEdgeMap(int prop);
135
136  ///Returns the actually selected nodemap to visualize by the given property.
137
138  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
139  ///\param prop property to inquire.
140  std::string getActiveNodeMap(int prop);
141
142  ///Registers recently created edgemap in \ref MapWin.
143
144  ///After creation of new map \ref MapStorage emits a signal.
145  ///This signal is bound to this callback function, that will call
146  ///a function with the same name and same parameterin \ref MapWin.
147  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
148  ///\param mapname name of new map
149  void registerNewEdgeMap(std::string mapname);
150
151  ///Registers recently created nodemap in \ref MapWin.
152
153  ///After creation of new map \ref MapStorage emits a signal.
154  ///This signal is bound to this callback function, that will call
155  ///a function with the same name and same parameter in \ref MapWin.
156  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
157  ///\param mapname name of new map
158  void registerNewNodeMap(std::string mapname);
159
160  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
161 
162  ///See also
163  ///\ref mapwin.
164  void createMapWin(std::string);
165
166  ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
167 
168  ///See also
169  ///\ref mapwin.
170  void createDesignWin(std::string);
171
172  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
173 
174  ///See also
175  ///\ref mapwin.
176  void closeMapWin();
177
178  bool closeDesignWin(GdkEventAny *);
179
180  ///Sets node representation settings
181  void setView(bool, bool, double, double);
182
183  ///Gets node representation settings
184  void getView(bool &, bool &, double&, double&);
185
186  void reDesignGraph();
187
188  void attraction_ch(double);
189
190  void propulsation_ch(double);
191
192  void iteration_ch(int);
193};
194
195#endif //NBTAB_H
Note: See TracBrowser for help on using the repository browser.