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