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