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