Changeset 1896:92ef660710f1 in lemon-0.x
- Timestamp:
- 01/14/06 14:42:37 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2471
- Location:
- gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/algobox.h
r1886 r1896 12 12 #include <libgnomecanvasmm/polygon.h> 13 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 14 31 class AlgoBox : public Gtk::VBox 15 32 { 16 sigc::signal<void, std::string> signal_maplist_need; 17 sigc::signal<void, std::string, bool> signal_newmapwin_need; 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; 18 47 19 48 protected: 49 ///Holder of tabnames. 20 50 Gtk::ComboBoxText tabcbt; 51 52 ///Holder of widgets, in which nodemaps can be selected to work on. 21 53 std::vector<MapSelector *> nodemapcbts; 54 55 ///Holder of widgets, in which edgemaps can be selected to work on. 22 56 std::vector<MapSelector *> edgemapcbts; 23 57 58 ///Maps of selected tabs. 24 59 MapStorage * mapstorage; 25 60 26 61 public: 62 ///Empty constructor called by children. 27 63 AlgoBox(){}; 28 AlgoBox(std::vector<std::string>);29 64 65 ///Constructor 66 67 ///Calls \ref init function 68 ///with the provided parameters. \ref init function 69 ///is needed, because it is virtual, therefore the 70 ///functions of the proper class will be called when 71 ///running. 72 ///\param tablist list of tabs in \ref MainWin 73 AlgoBox(std::vector<std::string> tablist); 74 75 ///Initiates \ref AlgoBox. 76 77 ///Creates the graphical interface for the realized algorithm, initiates variables, connects signals. 78 /// 79 ///List of tabs in \ref MainWin is required, but no one 80 ///will be selected automatically. Every other 81 ///entry field remains empty (unselected), until a \ref NoteBookTab 82 ///is selected. 83 /// 84 ///It also have to bind all the signals to the correct place. 85 ///This function is virtual, in all type of children of 86 ///\ref AlgoBox the correct function willbe called. 87 /// 88 ///Therefore it is IMPORTANT that only \ref run and \ref build_box 89 ///has to be implemented in children of \ref AlgoBox, every other 90 ///thing will automatically work properly by the help of this 91 ///function that must be called in constructor of child!!! 30 92 virtual void init(std::vector<std::string>); 31 93 32 sigc::signal<void, std::string> signal_maplist_needed(); 33 sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;}; 94 ///Signal emitted, when selected tab changes, and new list of maps required. 95 sigc::signal<void, std::string> signal_maplist_needed(); 96 97 ///Emitted if user wants to create a new map for inpuit or output. 98 sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;}; 99 100 ///Emits signal that requires list of maps for the recently selected \ref NoteBookTab. 34 101 void emit_tab_change(); 35 102 103 ///Interface, through which \ref AlgoBox can be notified about tab addition, deletion in \ref MainWin 104 105 ///\param tl list 106 ///of new tab state. 36 107 void update_tablist( std::vector< std::string > tl ); 37 void update_maplist( MapStorage * );38 108 109 ///Interface, through which \ref AlgoBox can get the maps of the recently selected \ref NoteBookTab 110 111 ///\param ms the maps 112 ///of the recently selected \ref NoteBookTab 113 void update_maplist( MapStorage * ms); 114 115 ///Interface, through which \ref AlgoBox can be notified about nodemap addition. 116 117 ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab 118 ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s 119 ///in \ref nodemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text) 39 120 void nodemaplist_changed(std::string); 121 122 ///Interface, through which \ref AlgoBox can be notified about edgemap addition. 123 124 ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab 125 ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s 126 ///in \ref edgemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text) 40 127 void edgemaplist_changed(std::string); 41 128 42 void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText &); 43 129 ///Aid function to provide data for a given entry. 130 131 ///At the moment it is only used for updating info 132 ///in \ref tabcbt. It clears it first, after that 133 ///inserts the data got from caller, and if there 134 ///was previously selected item it switches entry 135 ///to that. 136 ///\param tl list of entries (at the moment tabs in \ref MainWin) 137 ///\param cbt the entry to update (at the moment only \ref tabcbt) 138 void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText & cbt); 139 140 ///Runs the ralized algorithm. 141 142 ///Prepare the data for it 143 ///and after that postprocess it if necessary. 144 ///This is only a demo here, but in children it 145 ///runs the algorithm really. 44 146 virtual void run(); 45 147 148 ///Creates the layout of the \ref AlgoBox 149 150 ///Place all the entries 151 ///required. Run and close button is not 152 ///its responsibility! 46 153 virtual void build_box(); 47 154 48 virtual void emit_new_map_signal(bool);155 ///Emits \ref signal_newmapwin_need if user wants to create new input or output map. 49 156 50 void addMapSelector(std::string, bool); 157 ///Called in case of pressing \ref MapSelector::newbut. 158 ///\param itisedge edge or nodemap is required. 159 virtual void emit_new_map_signal(bool itisedge); 160 161 ///Aid function to make addition of \ref MapSelector easy in \ref build_box. 162 163 ///\param label label to show in \ref MapSelector 164 ///\param itisedge whether edge or nodemaps stored in \ref MapSelector 165 void addMapSelector(std::string label, bool itisedge); 51 166 }; 52 167 #endif //ALGOBOX_H -
gui/algowin.h
r1884 r1896 14 14 class MapStorage; 15 15 16 ///Algorithm identifiers. 16 17 enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs; 17 18 19 ///Window displaying graphical interface for different algorithms. 20 21 ///This class displays a graphical interface to set up 22 ///and run different algorithms. Different algorithms need 23 ///different inputs, running methods, etc. Therefore 24 ///class \ref AlgoWin is only a holder of a base class, the so 25 ///called AlgoBox. \ref AlgoBox is the ancestor of other 26 ///classes. These child classes realize interfaces of different 27 ///algorithms, but as their common ancestor is \ref AlgoBox 28 ///the interface of them is the same. \ref AlgoWin communicates 29 ///with these classes through this common interface. But it the 30 ///real object to be placed in \ref AlgoWin depends on the algorithm 31 ///which the \ref AlgoWin actually has to display. It gets the 32 ///id of algorithm to display at initialization, and therefore it is 33 ///able to place in itself the requested child of \ref AlgoBox 34 /// visualizing the appropriate algorithm. 18 35 class AlgoWin : public Gtk::Window 19 36 { 20 37 private: 38 ///Algorithm specific part of \ref AlgoWin 21 39 AlgoBox * ab; 40 41 ///Run button. 42 43 ///If pressed, algorithm should run. 44 ///That is why common ancestor of different 45 ///algorithm realizer classes have to be. In case of 46 ///pressing run button a common method can be called. 22 47 Gtk::Button * runbutton; 48 49 ///Close button. If pressed, \ref AlgoWin should close. 23 50 Gtk::Button * closebutton; 24 51 25 52 protected: 26 sigc::signal<void, AlgoWin *> signal_closed; 27 sigc::signal<void, AlgoWin *, std::string> signal_maplist_need; 28 sigc::signal<void, std::string, bool> signal_newmapwin_need; 53 ///Signal emitted upon close of window 54 55 ///It is necessary, because \ref MainWin have to 56 ///score the opened \ref AlgoWin s, to be able to communicate 57 ///with them: let them know about changement in tabs, maps, etc. 58 ///If \ref AlgoWin is closed, \ref MainWin has to deregistrate it. 59 ///Therefore signal contains address of emitter \ref AlgoWin. 60 sigc::signal<void, AlgoWin *> signal_closed; 61 62 ///Signal indicating that informatino on certain maplist is required. 63 64 ///It is just a forwarded signal from \ref AlgoBox, benefit of common ancestor 65 ///algorithm class. User can select the graph (the holder \ref NoteBookTab) on 66 ///which the algorithm should run. But different graphs (\ref NoteBookTab) have 67 ///different maps. If selected tab changes this signal is emitted by \ref AlgoBox, 68 ///caught and reemitted by \ref AlgoWin. 69 /// 70 ///Signal contains the address of \ref AlgoWin to let \ref MainWin know 71 ///where should the information needed forwarded, and the name of 72 ///\ref NoteBookTab, of which maps are inquired. 73 sigc::signal<void, AlgoWin *, std::string> signal_maplist_need; 74 75 ///Signal that indicates that a \ref NewMapWin should be popped up. 76 77 ///This is a forwarded signal. If \ref AlgoBox emits a signal 78 ///to let a \ref NewMapWin pop up, |ref AlgoWin catch and reemit it. 79 /// 80 ///Signal contains the name of \ref NoteBookTab, in which the new map 81 ///should be created and a boolean that indicates whether an edge or a 82 ///nodemap should be created. 83 sigc::signal<void, std::string, bool> signal_newmapwin_need; 29 84 30 85 public: 86 ///Close window if escape key is pressed. 31 87 bool closeIfEscapeIsPressed(GdkEventKey* e); 32 88 89 ///Returns \ref signal_closed to be bindable somewhere. 33 90 sigc::signal<void, AlgoWin *> signal_closing(); 91 92 ///Returns \ref signal_maplist_need to be bindable somewhere. 34 93 sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed(); 35 sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};36 94 95 ///Returns \ref signal_newmapwin_need to be bindable somewhere. 96 sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;}; 97 98 ///Forwards signal emitted by \ref AlgoBox, in which it indicates changement in selection of tabs. 37 99 void emit_tab_change(std::string); 100 101 ///Forwards signal emitted by \ref AlgoBox, in which it indicates need for \ref NewMapWin. 38 102 void emit_new_map_signal(std::string tabname, bool itisedge){signal_newmapwin_need.emit(tabname, itisedge);}; 39 103 40 AlgoWin(int, std::vector<std::string>);104 ///Constructor 41 105 106 ///It builds the window according to the information provided 107 ///by the creator. It needs the identifier of the algorithm 108 ///to visualize, and a list of name of \ref NoteBookTab s that can 109 ///be found in \ref MainWin. 110 ///\param algoid identifier of algorithm to show 111 ///\param tablist list of tabs in \ref MainWin 112 AlgoWin(int algoid, std::vector<std::string> tablist); 113 114 ///Forwards list of \ref NoteBookTabs toward \ref AlgoBox 115 116 ///In case of changement in tabs in \ref MainWin 117 ///\ref MainWin automatically updates tablist in 118 ///\ref AlgoWin s. 42 119 void update_tablist(std::vector<std::string> tabnames); 120 121 ///Forwards list of requested maps toward \ref AlgoBox 122 123 ///Upon catching the signal in which \ref AlgoBox requests 124 ///list of maps \ref MainWin responds 125 ///through this function. 43 126 void update_maplist(MapStorage *); 44 127 128 ///Called when window is closing. 129 130 ///\ref AlgoWin has to be deregistrated in \ref MainWin 131 ///thereforeit emits signal \ref signal_closed. 45 132 void on_hide(); 46 133 }; -
gui/kruskalbox.h
r1879 r1896 12 12 #include <libgnomecanvasmm/polygon.h> 13 13 14 ///Graphical interface to run Kruskal algorithm. 15 16 ///Child of \ref AlgoBox, 17 ///therefore the only task to do at implementation was to 18 /// 19 ///-call init function with correct parameters from correctly parametrized constructor 20 /// 21 ///-implement \ref build_box function 22 /// 23 ///-implement \ref run function 14 24 class KruskalBox : public AlgoBox 15 25 { 26 ///Shows result of Kruskal algorithm 16 27 Gtk::Label resultlabel; 17 28 18 29 public: 30 ///Calls \ref AlgoBox::init function to initialize class properly, automatically. 19 31 KruskalBox(std::vector<std::string> t); 20 32 33 ///Prepare, run and postprocess Kruskal algorithm. 34 35 ///\ref glemon works only with maps filled with double values 36 ///at the moment. While Kruskal nedds a bool map as output. 37 ///As postprocess this bool map should be transformed to 38 ///double map. 21 39 void run(); 22 40 41 ///Builds the graphical design of the interface. 23 42 void build_box(); 24 43 };
Note: See TracChangeset
for help on using the changeset viewer.