hegyi@1: /* -*- C++ -*- hegyi@1: * hegyi@1: * This file is a part of LEMON, a generic C++ optimization library hegyi@1: * hegyi@1: * Copyright (C) 2003-2006 hegyi@1: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport hegyi@1: * (Egervary Research Group on Combinatorial Optimization, EGRES). hegyi@1: * hegyi@1: * Permission to use, modify and distribute this software is granted hegyi@1: * provided that this copyright notice appears in all copies. For hegyi@1: * precise terms see the accompanying LICENSE file. hegyi@1: * hegyi@1: * This software is provided "AS IS" with no warranty of any kind, hegyi@1: * express or implied, and with no claim as to its suitability for any hegyi@1: * purpose. hegyi@1: * hegyi@1: */ hegyi@1: hegyi@1: #ifndef ALGOBOX_H hegyi@1: #define ALGOBOX_H hegyi@1: hegyi@1: class MapStorage; hegyi@1: class MapSelector; hegyi@1: hegyi@1: #include hegyi@1: #include hegyi@1: #include hegyi@1: #include "map_value.h" hegyi@1: hegyi@1: ///Ancestor class of algorithm digraphical interface classes. hegyi@1: hegyi@1: ///It also demonstrates, how should an algorithm digraphical interface hegyi@1: ///work. Children of this class have the same functions and attributes, hegyi@1: ///therefore with all of them can the holder \ref AlgoWin communicate hegyi@1: ///in the same way. hegyi@1: /// hegyi@1: ///IMPORTANT! In a child class only the following tasks are to do: hegyi@1: /// hegyi@1: ///-call \ref init function with correct parameters from correctly parametrized constructor hegyi@1: /// hegyi@1: ///-implement \ref build_box function hegyi@1: /// hegyi@1: ///-implement \ref run function hegyi@1: /// hegyi@1: ///because all other thing is automatically done in \ref init function! hegyi@1: hegyi@1: class AlgoBox : public Gtk::VBox hegyi@1: { hegyi@1: ///Signal emitted in case of need for list of maps. hegyi@1: hegyi@1: ///If the user has selected different tab to work on hegyi@1: ///new maps are selected as well. These new maps should be hegyi@1: ///provided for \ref AlgoBox. To get these maps, \ref AlgoBox hegyi@1: ///emits this signal. hegyi@1: sigc::signal signal_maplist_need; hegyi@1: hegyi@1: ///Signal emitted in case of need for \ref NewMapWin. hegyi@1: hegyi@1: ///If user wants to create a new for an input, or output hegyi@1: ///it can let \ref NewMapWin popped up from here as well. hegyi@1: ///In that case will be this signal emitted. hegyi@1: sigc::signal signal_newmapwin_need; hegyi@1: hegyi@1: ///Signal emitted when maplists are updated after tab change hegyi@1: sigc::signal signal_maplist_updated; hegyi@1: hegyi@1: hegyi@1: protected: hegyi@1: ///Holder of tabnames. hegyi@1: Gtk::ComboBoxText tabcbt; hegyi@1: hegyi@1: ///Holder of widgets, in which nodemaps can be selected to work on. hegyi@1: std::vector nodemapcbts; hegyi@1: hegyi@1: ///Holder of widgets, in which arcmaps can be selected to work on. hegyi@1: std::vector arcmapcbts; hegyi@1: hegyi@1: ///Maps of selected tabs. hegyi@1: MapStorage * mapstorage; hegyi@1: hegyi@1: public: hegyi@1: ///Empty constructor called by children. hegyi@1: AlgoBox(){}; hegyi@1: hegyi@1: ///Constructor hegyi@1: hegyi@1: ///Calls \ref init function hegyi@1: ///with the provided parameters. \ref init function hegyi@1: ///is needed, because it is virtual, therefore the hegyi@1: ///functions of the proper class will be called when hegyi@1: ///running. hegyi@1: ///\param tablist list of tabs in \ref MainWin hegyi@1: AlgoBox(std::vector tablist); hegyi@1: hegyi@1: ///Initiates \ref AlgoBox. hegyi@1: hegyi@1: ///Creates the digraphical interface for the realized algorithm, initiates variables, connects signals. hegyi@1: /// hegyi@1: ///List of tabs in \ref MainWin is required, but no one hegyi@1: ///will be selected automatically. Every other hegyi@1: ///entry field remains empty (unselected), until a \ref NoteBookTab hegyi@1: ///is selected. hegyi@1: /// hegyi@1: ///It also have to bind all the signals to the correct place. hegyi@1: ///This function is virtual, in all type of children of hegyi@1: ///\ref AlgoBox the correct function willbe called. hegyi@1: /// hegyi@1: ///Therefore it is IMPORTANT that only \ref run and \ref build_box hegyi@1: ///has to be implemented in children of \ref AlgoBox, every other hegyi@1: ///thing will automatically work properly by the help of this hegyi@1: ///function that must be called in constructor of child!!! hegyi@1: virtual void init(std::vector); hegyi@1: hegyi@1: ///Signal emitted, when selected tab changes, and new list of maps required. hegyi@1: sigc::signal signal_maplist_needed(); hegyi@1: hegyi@1: ///Emitted if user wants to create a new map for inpuit or output. hegyi@1: sigc::signal signal_newmapwin_needed(){return signal_newmapwin_need;}; hegyi@1: hegyi@1: sigc::signal signal_upon_maplist_updated(){return signal_maplist_updated;}; hegyi@1: hegyi@1: ///Emits signal that requires list of maps for the recently selected \ref NoteBookTab. hegyi@1: void emit_tab_change(); hegyi@1: hegyi@1: ///Interface, through which \ref AlgoBox can be notified about tab addition, deletion in \ref MainWin hegyi@1: hegyi@1: ///\param tl list hegyi@1: ///of new tab state. hegyi@1: void update_tablist( std::vector< std::string > tl ); hegyi@1: hegyi@1: ///Interface, through which \ref AlgoBox can get the maps of the recently selected \ref NoteBookTab hegyi@1: hegyi@1: ///\param ms the maps hegyi@1: ///of the recently selected \ref NoteBookTab hegyi@1: void update_maplist( MapStorage * ms); hegyi@1: hegyi@1: ///Interface, through which \ref AlgoBox can be notified about nodemap addition. hegyi@1: hegyi@1: ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab hegyi@1: ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s hegyi@1: ///in \ref nodemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text) hegyi@1: void nodemaplist_changed(std::string, MapValue::Type); hegyi@1: hegyi@1: ///Interface, through which \ref AlgoBox can be notified about arcmap addition. hegyi@1: hegyi@1: ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab hegyi@1: ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s hegyi@1: ///in \ref arcmapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text) hegyi@1: void arcmaplist_changed(std::string, MapValue::Type); hegyi@1: hegyi@1: ///Aid function to provide data for a given entry. hegyi@1: hegyi@1: ///At the moment it is only used for updating info hegyi@1: ///in \ref tabcbt. It clears it first, after that hegyi@1: ///inserts the data got from caller, and if there hegyi@1: ///was previously selected item it switches entry hegyi@1: ///to that. hegyi@1: ///\param tl list of entries (at the moment tabs in \ref MainWin) hegyi@1: ///\param cbt the entry to update (at the moment only \ref tabcbt) hegyi@1: void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText & cbt); hegyi@1: hegyi@1: ///Runs the ralized algorithm. hegyi@1: hegyi@1: ///Prepare the data for it hegyi@1: ///and after that postprocess it if necessary. hegyi@1: ///This is only a demo here, but in children it hegyi@1: ///runs the algorithm really. hegyi@1: virtual void run(); hegyi@1: hegyi@1: ///Creates the layout of the \ref AlgoBox hegyi@1: hegyi@1: ///Place all the entries hegyi@1: ///required. Run and close button is not hegyi@1: ///its responsibility! hegyi@1: virtual void build_box(); hegyi@1: hegyi@1: ///Emits \ref signal_newmapwin_need if user wants to create new input or output map. hegyi@1: hegyi@1: ///Called in case of pressing \ref MapSelector::newbut. hegyi@1: ///\param itisarc arc or nodemap is required. hegyi@1: virtual void emit_new_map_signal(bool itisarc); hegyi@1: hegyi@1: ///Aid function to make addition of \ref MapSelector easy in \ref build_box. hegyi@1: hegyi@1: ///\param label label to show in \ref MapSelector hegyi@1: ///\param itisarc whether arc or nodemaps stored in \ref MapSelector hegyi@1: void addMapSelector(std::string label, bool itisarc, MapType type = ALL); hegyi@1: }; hegyi@1: #endif //ALGOBOX_H