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