alpar@174: /* -*- C++ -*- alpar@174: * alpar@174: * This file is a part of LEMON, a generic C++ optimization library alpar@174: * alpar@174: * Copyright (C) 2003-2006 alpar@174: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@174: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@174: * alpar@174: * Permission to use, modify and distribute this software is granted alpar@174: * provided that this copyright notice appears in all copies. For alpar@174: * precise terms see the accompanying LICENSE file. alpar@174: * alpar@174: * This software is provided "AS IS" with no warranty of any kind, alpar@174: * express or implied, and with no claim as to its suitability for any alpar@174: * purpose. alpar@174: * alpar@174: */ hegyi@103: hegyi@103: #ifndef ALGOWIN_H hegyi@103: #define ALGOWIN_H hegyi@103: hegyi@103: #include hegyi@103: #include hegyi@103: #include hegyi@103: hegyi@194: class AlgoBox; hegyi@109: class MapStorage; hegyi@109: hegyi@125: ///Algorithm identifiers. hegyi@106: enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs; hegyi@103: hegyi@125: ///Window displaying graphical interface for different algorithms. hegyi@125: hegyi@125: ///This class displays a graphical interface to set up hegyi@125: ///and run different algorithms. Different algorithms need hegyi@125: ///different inputs, running methods, etc. Therefore hegyi@125: ///class \ref AlgoWin is only a holder of a base class, the so hegyi@125: ///called AlgoBox. \ref AlgoBox is the ancestor of other hegyi@125: ///classes. These child classes realize interfaces of different hegyi@125: ///algorithms, but as their common ancestor is \ref AlgoBox hegyi@125: ///the interface of them is the same. \ref AlgoWin communicates hegyi@125: ///with these classes through this common interface. But it the hegyi@125: ///real object to be placed in \ref AlgoWin depends on the algorithm hegyi@125: ///which the \ref AlgoWin actually has to display. It gets the hegyi@125: ///id of algorithm to display at initialization, and therefore it is hegyi@125: ///able to place in itself the requested child of \ref AlgoBox hegyi@125: /// visualizing the appropriate algorithm. hegyi@106: class AlgoWin : public Gtk::Window hegyi@103: { hegyi@103: private: hegyi@125: ///Algorithm specific part of \ref AlgoWin hegyi@103: AlgoBox * ab; hegyi@125: hegyi@125: ///Run button. hegyi@125: hegyi@125: ///If pressed, algorithm should run. hegyi@125: ///That is why common ancestor of different hegyi@125: ///algorithm realizer classes have to be. In case of hegyi@125: ///pressing run button a common method can be called. hegyi@106: Gtk::Button * runbutton; hegyi@125: hegyi@125: ///Close button. If pressed, \ref AlgoWin should close. hegyi@106: Gtk::Button * closebutton; hegyi@103: hegyi@103: protected: hegyi@125: ///Signal emitted upon close of window hegyi@125: hegyi@125: ///It is necessary, because \ref MainWin have to hegyi@125: ///score the opened \ref AlgoWin s, to be able to communicate hegyi@125: ///with them: let them know about changement in tabs, maps, etc. hegyi@125: ///If \ref AlgoWin is closed, \ref MainWin has to deregistrate it. hegyi@125: ///Therefore signal contains address of emitter \ref AlgoWin. hegyi@125: sigc::signal signal_closed; hegyi@125: hegyi@125: ///Signal indicating that informatino on certain maplist is required. hegyi@125: hegyi@125: ///It is just a forwarded signal from \ref AlgoBox, benefit of common ancestor hegyi@125: ///algorithm class. User can select the graph (the holder \ref NoteBookTab) on hegyi@125: ///which the algorithm should run. But different graphs (\ref NoteBookTab) have hegyi@125: ///different maps. If selected tab changes this signal is emitted by \ref AlgoBox, hegyi@125: ///caught and reemitted by \ref AlgoWin. hegyi@125: /// hegyi@125: ///Signal contains the address of \ref AlgoWin to let \ref MainWin know hegyi@125: ///where should the information needed forwarded, and the name of hegyi@125: ///\ref NoteBookTab, of which maps are inquired. hegyi@125: sigc::signal signal_maplist_need; hegyi@125: hegyi@125: ///Signal that indicates that a \ref NewMapWin should be popped up. hegyi@125: hegyi@125: ///This is a forwarded signal. If \ref AlgoBox emits a signal hegyi@125: ///to let a \ref NewMapWin pop up, |ref AlgoWin catch and reemit it. hegyi@125: /// hegyi@125: ///Signal contains the name of \ref NoteBookTab, in which the new map hegyi@125: ///should be created and a boolean that indicates whether an edge or a hegyi@125: ///nodemap should be created. hegyi@125: sigc::signal signal_newmapwin_need; hegyi@103: hegyi@103: public: hegyi@125: ///Close window if escape key is pressed. hegyi@106: bool closeIfEscapeIsPressed(GdkEventKey* e); hegyi@103: hegyi@125: ///Returns \ref signal_closed to be bindable somewhere. hegyi@106: sigc::signal signal_closing(); hegyi@125: hegyi@125: ///Returns \ref signal_maplist_need to be bindable somewhere. hegyi@106: sigc::signal signal_maplist_needed(); hegyi@103: hegyi@125: ///Returns \ref signal_newmapwin_need to be bindable somewhere. hegyi@125: sigc::signal signal_newmapwin_needed(){return signal_newmapwin_need;}; hegyi@125: hegyi@125: ///Forwards signal emitted by \ref AlgoBox, in which it indicates changement in selection of tabs. hegyi@106: void emit_tab_change(std::string); hegyi@125: hegyi@125: ///Forwards signal emitted by \ref AlgoBox, in which it indicates need for \ref NewMapWin. hegyi@114: void emit_new_map_signal(std::string tabname, bool itisedge){signal_newmapwin_need.emit(tabname, itisedge);}; hegyi@103: hegyi@125: ///Constructor hegyi@106: hegyi@125: ///It builds the window according to the information provided hegyi@125: ///by the creator. It needs the identifier of the algorithm hegyi@125: ///to visualize, and a list of name of \ref NoteBookTab s that can hegyi@125: ///be found in \ref MainWin. hegyi@125: ///\param algoid identifier of algorithm to show hegyi@125: ///\param tablist list of tabs in \ref MainWin hegyi@125: AlgoWin(int algoid, std::vector tablist); hegyi@125: hegyi@125: ///Forwards list of \ref NoteBookTabs toward \ref AlgoBox hegyi@125: hegyi@125: ///In case of changement in tabs in \ref MainWin hegyi@125: ///\ref MainWin automatically updates tablist in hegyi@125: ///\ref AlgoWin s. hegyi@106: void update_tablist(std::vector tabnames); hegyi@125: hegyi@125: ///Forwards list of requested maps toward \ref AlgoBox hegyi@125: hegyi@125: ///Upon catching the signal in which \ref AlgoBox requests hegyi@125: ///list of maps \ref MainWin responds hegyi@125: ///through this function. hegyi@109: void update_maplist(MapStorage *); hegyi@106: hegyi@125: ///Called when window is closing. hegyi@125: hegyi@125: ///\ref AlgoWin has to be deregistrated in \ref MainWin hegyi@125: ///thereforeit emits signal \ref signal_closed. hegyi@106: void on_hide(); hegyi@103: }; hegyi@103: #endif //ALGOWIN_H