hegyi@103: // -*- C++ -*- // hegyi@103: hegyi@103: #ifndef ALGOBOX_H hegyi@103: #define ALGOBOX_H hegyi@103: hegyi@103: class AlgoBox; hegyi@103: hegyi@103: #include hegyi@108: #include hegyi@114: #include hegyi@103: #include hegyi@103: #include hegyi@103: hegyi@125: ///Ancestor class of algorithm graphical interface classes. hegyi@125: hegyi@125: ///It also demonstrates, how should an algorithm graphical interface hegyi@125: ///work. Children of this class have the same functions and attributes, hegyi@125: ///therefore with all of them can the holder \ref AlgoWin communicate hegyi@125: ///in the same way. hegyi@125: /// hegyi@125: ///IMPORTANT! In a child class only the following tasks are to do: hegyi@125: /// hegyi@125: ///-call \ref init function with correct parameters from correctly parametrized constructor hegyi@125: /// hegyi@125: ///-implement \ref build_box function hegyi@125: /// hegyi@125: ///-implement \ref run function hegyi@125: /// hegyi@125: ///because all other thing is automatically done in \ref init function! hegyi@125: hegyi@103: class AlgoBox : public Gtk::VBox hegyi@103: { hegyi@125: ///Signal emitted in case of need for list of maps. hegyi@125: hegyi@125: ///If the user has selected different tab to work on hegyi@125: ///new maps are selected as well. These new maps should be hegyi@125: ///provided for \ref AlgoBox. To get these maps, \ref AlgoBox hegyi@125: ///emits this signal. hegyi@125: sigc::signal signal_maplist_need; hegyi@125: hegyi@125: ///Signal emitted in case of need for \ref NewMapWin. hegyi@125: hegyi@125: ///If user wants to create a new for an input, or output hegyi@125: ///it can let \ref NewMapWin popped up from here as well. hegyi@125: ///In that case will be this signal emitted. hegyi@125: sigc::signal signal_newmapwin_need; hegyi@106: hegyi@162: ///Signal emitted when maplists are updated after tab change hegyi@162: sigc::signal signal_maplist_updated; hegyi@162: hegyi@162: hegyi@106: protected: hegyi@125: ///Holder of tabnames. hegyi@114: Gtk::ComboBoxText tabcbt; hegyi@125: hegyi@125: ///Holder of widgets, in which nodemaps can be selected to work on. hegyi@114: std::vector nodemapcbts; hegyi@125: hegyi@125: ///Holder of widgets, in which edgemaps can be selected to work on. hegyi@114: std::vector edgemapcbts; hegyi@108: hegyi@125: ///Maps of selected tabs. hegyi@108: MapStorage * mapstorage; hegyi@108: hegyi@106: public: hegyi@125: ///Empty constructor called by children. hegyi@106: AlgoBox(){}; hegyi@103: hegyi@125: ///Constructor hegyi@125: hegyi@125: ///Calls \ref init function hegyi@125: ///with the provided parameters. \ref init function hegyi@125: ///is needed, because it is virtual, therefore the hegyi@125: ///functions of the proper class will be called when hegyi@125: ///running. hegyi@125: ///\param tablist list of tabs in \ref MainWin hegyi@125: AlgoBox(std::vector tablist); hegyi@125: hegyi@125: ///Initiates \ref AlgoBox. hegyi@125: hegyi@125: ///Creates the graphical interface for the realized algorithm, initiates variables, connects signals. hegyi@125: /// hegyi@125: ///List of tabs in \ref MainWin is required, but no one hegyi@125: ///will be selected automatically. Every other hegyi@125: ///entry field remains empty (unselected), until a \ref NoteBookTab hegyi@125: ///is selected. hegyi@125: /// hegyi@125: ///It also have to bind all the signals to the correct place. hegyi@125: ///This function is virtual, in all type of children of hegyi@125: ///\ref AlgoBox the correct function willbe called. hegyi@125: /// hegyi@125: ///Therefore it is IMPORTANT that only \ref run and \ref build_box hegyi@125: ///has to be implemented in children of \ref AlgoBox, every other hegyi@125: ///thing will automatically work properly by the help of this hegyi@125: ///function that must be called in constructor of child!!! hegyi@108: virtual void init(std::vector); hegyi@103: hegyi@125: ///Signal emitted, when selected tab changes, and new list of maps required. hegyi@125: sigc::signal signal_maplist_needed(); hegyi@125: hegyi@125: ///Emitted if user wants to create a new map for inpuit or output. hegyi@125: sigc::signal signal_newmapwin_needed(){return signal_newmapwin_need;}; hegyi@125: hegyi@162: sigc::signal signal_upon_maplist_updated(){return signal_maplist_updated;}; hegyi@162: hegyi@125: ///Emits signal that requires list of maps for the recently selected \ref NoteBookTab. hegyi@106: void emit_tab_change(); hegyi@103: hegyi@125: ///Interface, through which \ref AlgoBox can be notified about tab addition, deletion in \ref MainWin hegyi@125: hegyi@125: ///\param tl list hegyi@125: ///of new tab state. hegyi@106: void update_tablist( std::vector< std::string > tl ); hegyi@108: hegyi@125: ///Interface, through which \ref AlgoBox can get the maps of the recently selected \ref NoteBookTab hegyi@125: hegyi@125: ///\param ms the maps hegyi@125: ///of the recently selected \ref NoteBookTab hegyi@125: void update_maplist( MapStorage * ms); hegyi@125: hegyi@125: ///Interface, through which \ref AlgoBox can be notified about nodemap addition. hegyi@125: hegyi@125: ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab hegyi@125: ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s hegyi@125: ///in \ref nodemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text) hegyi@108: void nodemaplist_changed(std::string); hegyi@125: hegyi@125: ///Interface, through which \ref AlgoBox can be notified about edgemap addition. hegyi@125: hegyi@125: ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab hegyi@125: ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s hegyi@125: ///in \ref edgemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text) hegyi@108: void edgemaplist_changed(std::string); hegyi@103: hegyi@125: ///Aid function to provide data for a given entry. hegyi@125: hegyi@125: ///At the moment it is only used for updating info hegyi@125: ///in \ref tabcbt. It clears it first, after that hegyi@125: ///inserts the data got from caller, and if there hegyi@125: ///was previously selected item it switches entry hegyi@125: ///to that. hegyi@125: ///\param tl list of entries (at the moment tabs in \ref MainWin) hegyi@125: ///\param cbt the entry to update (at the moment only \ref tabcbt) hegyi@125: void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText & cbt); hegyi@125: hegyi@125: ///Runs the ralized algorithm. hegyi@125: hegyi@125: ///Prepare the data for it hegyi@125: ///and after that postprocess it if necessary. hegyi@125: ///This is only a demo here, but in children it hegyi@125: ///runs the algorithm really. hegyi@106: virtual void run(); hegyi@125: hegyi@125: ///Creates the layout of the \ref AlgoBox hegyi@125: hegyi@125: ///Place all the entries hegyi@125: ///required. Run and close button is not hegyi@125: ///its responsibility! hegyi@106: virtual void build_box(); hegyi@114: hegyi@125: ///Emits \ref signal_newmapwin_need if user wants to create new input or output map. hegyi@116: hegyi@125: ///Called in case of pressing \ref MapSelector::newbut. hegyi@125: ///\param itisedge edge or nodemap is required. hegyi@125: virtual void emit_new_map_signal(bool itisedge); hegyi@125: hegyi@125: ///Aid function to make addition of \ref MapSelector easy in \ref build_box. hegyi@125: hegyi@125: ///\param label label to show in \ref MapSelector hegyi@125: ///\param itisedge whether edge or nodemaps stored in \ref MapSelector hegyi@125: void addMapSelector(std::string label, bool itisedge); hegyi@103: }; hegyi@103: #endif //ALGOBOX_H