COIN-OR::LEMON - Graph Library

source: glemon-0.x/algobox.h @ 170:bff6d1c63cff

Last change on this file since 170:bff6d1c63cff was 162:aaa517c9dc23, checked in by Hegyi Péter, 17 years ago

Dijkstra in GUI.

File size: 6.2 KB
Line 
1// -*- C++ -*- //
2
3#ifndef ALGOBOX_H
4#define ALGOBOX_H
5
6class AlgoBox;
7
8#include <all_include.h>
9#include <mapstorage.h>
10#include <mapselector.h>
11#include <libgnomecanvasmm.h>
12#include <libgnomecanvasmm/polygon.h>
13
14///Ancestor class of algorithm graphical interface classes.
15
16///It also demonstrates, how should an algorithm graphical interface
17///work. Children of this class have the same functions and attributes,
18///therefore with all of them can the holder \ref AlgoWin communicate
19///in the same way.
20///
21///IMPORTANT! In a child class only the following tasks are to do:
22///
23///-call \ref init function with correct parameters from correctly parametrized constructor
24///
25///-implement \ref build_box function
26///
27///-implement \ref run function
28///
29///because all other thing is automatically done in \ref init function!
30
31class AlgoBox : public Gtk::VBox
32{
33  ///Signal emitted in case of need for list of maps.
34
35  ///If the user has selected different tab to work on
36  ///new maps are selected as well. These new maps should be
37  ///provided for \ref AlgoBox. To get these maps, \ref AlgoBox
38  ///emits this signal.
39  sigc::signal<void, std::string> signal_maplist_need;
40
41  ///Signal emitted in case of need for \ref NewMapWin.
42
43  ///If user wants to create a new for an input, or output
44  ///it can let \ref NewMapWin popped up from here as well.
45  ///In that case will be this signal emitted.
46  sigc::signal<void, std::string, bool> signal_newmapwin_need;
47
48  ///Signal emitted when maplists are updated after tab change
49  sigc::signal<void> signal_maplist_updated;
50
51
52protected:
53  ///Holder of tabnames.
54  Gtk::ComboBoxText tabcbt;
55
56  ///Holder of widgets, in which nodemaps can be selected to work on.
57  std::vector<MapSelector *> nodemapcbts;
58
59  ///Holder of widgets, in which edgemaps can be selected to work on.
60  std::vector<MapSelector *> edgemapcbts;
61
62  ///Maps of selected tabs.
63  MapStorage * mapstorage;
64
65public:
66  ///Empty constructor called by children.
67  AlgoBox(){};
68
69  ///Constructor
70
71  ///Calls \ref init function
72  ///with the provided parameters. \ref init function
73  ///is needed, because it is virtual, therefore the
74  ///functions of the proper class will be called when
75  ///running.
76  ///\param tablist list of tabs in \ref MainWin
77  AlgoBox(std::vector<std::string> tablist);
78
79  ///Initiates \ref AlgoBox.
80
81  ///Creates the graphical interface for the realized algorithm, initiates variables, connects signals.
82  ///
83  ///List of tabs in \ref MainWin is required, but no one
84  ///will be selected automatically. Every other
85  ///entry field remains empty (unselected), until a \ref NoteBookTab
86  ///is selected.
87  ///
88  ///It also have to bind all the signals to the correct place.
89  ///This function is virtual, in all type of children of
90  ///\ref AlgoBox the correct function willbe called.
91  ///
92  ///Therefore it is IMPORTANT that only \ref run and \ref build_box
93  ///has to be implemented in children of \ref AlgoBox, every other
94  ///thing will automatically work properly by the help of this
95  ///function that must be called in constructor of child!!!
96  virtual void init(std::vector<std::string>);
97
98  ///Signal emitted, when selected tab changes, and new list of maps required.
99  sigc::signal<void, std::string> signal_maplist_needed();
100
101  ///Emitted if user wants to create a new map for inpuit or output.
102  sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
103
104  sigc::signal<void> signal_upon_maplist_updated(){return signal_maplist_updated;};
105
106  ///Emits signal that requires list of maps for the recently selected \ref NoteBookTab.
107  void emit_tab_change();
108
109  ///Interface, through which \ref AlgoBox can be notified about tab addition, deletion in \ref MainWin
110
111  ///\param tl list
112  ///of new tab state.
113  void update_tablist( std::vector< std::string > tl );
114
115  ///Interface, through which \ref AlgoBox can get the maps of the recently selected \ref NoteBookTab
116
117  ///\param ms the maps
118  ///of the recently selected \ref NoteBookTab
119  void update_maplist( MapStorage * ms);
120
121  ///Interface, through which \ref AlgoBox can be notified about nodemap addition.
122
123  ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
124  ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
125  ///in \ref nodemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
126  void nodemaplist_changed(std::string);
127
128  ///Interface, through which \ref AlgoBox can be notified about edgemap addition.
129
130  ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
131  ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
132  ///in \ref edgemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
133  void edgemaplist_changed(std::string);
134
135  ///Aid function to provide data for a given entry.
136
137  ///At the moment it is only used for updating info
138  ///in \ref tabcbt. It clears it first, after that
139  ///inserts the data got from caller, and if there
140  ///was previously selected item it switches entry
141  ///to that.
142  ///\param tl list of entries (at the moment tabs in \ref MainWin)
143  ///\param cbt the entry to update (at the moment only \ref tabcbt)
144  void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText & cbt);
145
146  ///Runs the ralized algorithm.
147
148  ///Prepare the data for it
149  ///and after that postprocess it if necessary.
150  ///This is only a demo here, but in children it
151  ///runs the algorithm really.
152  virtual void run();
153
154  ///Creates the layout of the \ref AlgoBox
155
156  ///Place all the entries
157  ///required. Run and close button is not
158  ///its responsibility!
159  virtual void build_box();
160
161  ///Emits \ref signal_newmapwin_need if user wants to create new input or output map.
162
163  ///Called in case of pressing \ref MapSelector::newbut.
164  ///\param itisedge edge or nodemap is required.
165  virtual void emit_new_map_signal(bool itisedge);
166
167  ///Aid function to make addition of \ref MapSelector easy in \ref build_box.
168
169  ///\param label label to show in \ref MapSelector
170  ///\param itisedge whether edge or nodemaps stored in \ref MapSelector
171  void addMapSelector(std::string label, bool itisedge);
172};
173#endif //ALGOBOX_H
Note: See TracBrowser for help on using the repository browser.