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 ALGOWIN_H hegyi@1: #define ALGOWIN_H hegyi@1: hegyi@1: #include hegyi@1: #include hegyi@1: #include hegyi@1: hegyi@1: class AlgoBox; hegyi@1: class MapStorage; hegyi@1: hegyi@1: ///Algorithm identifiers. hegyi@1: enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs; hegyi@1: hegyi@1: ///Window displaying digraphical interface for different algorithms. hegyi@1: hegyi@1: ///This class displays a digraphical interface to set up hegyi@1: ///and run different algorithms. Different algorithms need hegyi@1: ///different inputs, running methods, etc. Therefore hegyi@1: ///class \ref AlgoWin is only a holder of a base class, the so hegyi@1: ///called AlgoBox. \ref AlgoBox is the ancestor of other hegyi@1: ///classes. These child classes realize interfaces of different hegyi@1: ///algorithms, but as their common ancestor is \ref AlgoBox hegyi@1: ///the interface of them is the same. \ref AlgoWin communicates hegyi@1: ///with these classes through this common interface. But it the hegyi@1: ///real object to be placed in \ref AlgoWin depends on the algorithm hegyi@1: ///which the \ref AlgoWin actually has to display. It gets the hegyi@1: ///id of algorithm to display at initialization, and therefore it is hegyi@1: ///able to place in itself the requested child of \ref AlgoBox hegyi@1: /// visualizing the appropriate algorithm. hegyi@1: class AlgoWin : public Gtk::Window hegyi@1: { hegyi@1: private: hegyi@1: ///Algorithm specific part of \ref AlgoWin hegyi@1: AlgoBox * ab; hegyi@1: hegyi@1: ///Run button. hegyi@1: hegyi@1: ///If pressed, algorithm should run. hegyi@1: ///That is why common ancestor of different hegyi@1: ///algorithm realizer classes have to be. In case of hegyi@1: ///pressing run button a common method can be called. hegyi@1: Gtk::Button * runbutton; hegyi@1: hegyi@1: ///Close button. If pressed, \ref AlgoWin should close. hegyi@1: Gtk::Button * closebutton; hegyi@1: hegyi@1: protected: hegyi@1: ///Signal emitted upon close of window hegyi@1: hegyi@1: ///It is necessary, because \ref MainWin have to hegyi@1: ///score the opened \ref AlgoWin s, to be able to communicate hegyi@1: ///with them: let them know about changement in tabs, maps, etc. hegyi@1: ///If \ref AlgoWin is closed, \ref MainWin has to deregistrate it. hegyi@1: ///Therefore signal contains address of emitter \ref AlgoWin. hegyi@1: sigc::signal signal_closed; hegyi@1: hegyi@1: ///Signal indicating that informatino on certain maplist is required. hegyi@1: hegyi@1: ///It is just a forwarded signal from \ref AlgoBox, benefit of common ancestor hegyi@1: ///algorithm class. User can select the digraph (the holder \ref NoteBookTab) on hegyi@1: ///which the algorithm should run. But different digraphs (\ref NoteBookTab) have hegyi@1: ///different maps. If selected tab changes this signal is emitted by \ref AlgoBox, hegyi@1: ///caught and reemitted by \ref AlgoWin. hegyi@1: /// hegyi@1: ///Signal contains the address of \ref AlgoWin to let \ref MainWin know hegyi@1: ///where should the information needed forwarded, and the name of hegyi@1: ///\ref NoteBookTab, of which maps are inquired. hegyi@1: sigc::signal signal_maplist_need; hegyi@1: hegyi@1: ///Signal that indicates that a \ref NewMapWin should be popped up. hegyi@1: hegyi@1: ///This is a forwarded signal. If \ref AlgoBox emits a signal hegyi@1: ///to let a \ref NewMapWin pop up, |ref AlgoWin catch and reemit it. hegyi@1: /// hegyi@1: ///Signal contains the name of \ref NoteBookTab, in which the new map hegyi@1: ///should be created and a boolean that indicates whether an arc or a hegyi@1: ///nodemap should be created. hegyi@1: sigc::signal signal_newmapwin_need; hegyi@1: hegyi@1: public: hegyi@1: ///Close window if escape key is pressed. hegyi@1: bool closeIfEscapeIsPressed(GdkEventKey* e); hegyi@1: hegyi@1: ///Returns \ref signal_closed to be bindable somewhere. hegyi@1: sigc::signal signal_closing(); hegyi@1: hegyi@1: ///Returns \ref signal_maplist_need to be bindable somewhere. hegyi@1: sigc::signal signal_maplist_needed(); hegyi@1: hegyi@1: ///Returns \ref signal_newmapwin_need to be bindable somewhere. hegyi@1: sigc::signal signal_newmapwin_needed(){return signal_newmapwin_need;}; hegyi@1: hegyi@1: ///Forwards signal emitted by \ref AlgoBox, in which it indicates changement in selection of tabs. hegyi@1: void emit_tab_change(std::string); hegyi@1: hegyi@1: ///Forwards signal emitted by \ref AlgoBox, in which it indicates need for \ref NewMapWin. hegyi@1: void emit_new_map_signal(std::string tabname, bool itisarc){signal_newmapwin_need.emit(tabname, itisarc);}; hegyi@1: hegyi@1: ///Constructor hegyi@1: hegyi@1: ///It builds the window according to the information provided hegyi@1: ///by the creator. It needs the identifier of the algorithm hegyi@1: ///to visualize, and a list of name of \ref NoteBookTab s that can hegyi@1: ///be found in \ref MainWin. hegyi@1: ///\param algoid identifier of algorithm to show hegyi@1: ///\param tablist list of tabs in \ref MainWin hegyi@1: AlgoWin(int algoid, std::vector tablist); hegyi@1: hegyi@1: ///Forwards list of \ref NoteBookTabs toward \ref AlgoBox hegyi@1: hegyi@1: ///In case of changement in tabs in \ref MainWin hegyi@1: ///\ref MainWin automatically updates tablist in hegyi@1: ///\ref AlgoWin s. hegyi@1: void update_tablist(std::vector tabnames); hegyi@1: hegyi@1: ///Forwards list of requested maps toward \ref AlgoBox hegyi@1: hegyi@1: ///Upon catching the signal in which \ref AlgoBox requests hegyi@1: ///list of maps \ref MainWin responds hegyi@1: ///through this function. hegyi@1: void update_maplist(MapStorage *); hegyi@1: hegyi@1: ///Called when window is closing. hegyi@1: hegyi@1: ///\ref AlgoWin has to be deregistrated in \ref MainWin hegyi@1: ///thereforeit emits signal \ref signal_closed. hegyi@1: void on_hide(); hegyi@1: }; hegyi@1: #endif //ALGOWIN_H