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 NBTAB_H hegyi@1: #define NBTAB_H hegyi@1: hegyi@1: class MapStorage; hegyi@1: class EpsWin; hegyi@1: class MapWin; hegyi@1: class DesignWin; hegyi@1: class DigraphDisplayerCanvas; hegyi@1: hegyi@1: #include hegyi@1: #include hegyi@1: #include "map_value.h" hegyi@1: hegyi@1: ///One tab in the Notebook that is placed in the main window (\ref MainWin). hegyi@1: hegyi@1: ///One digraph and all of its accessories like maps are assigned to one tab in the notebook. hegyi@1: ///\ref NoteBookTab is responsible for the user defined display of the digraph: view can be hegyi@1: ///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the hegyi@1: ///view of digraph. This is \ref Mapwin window. hegyi@1: /// hegyi@1: ///\ref NoteBookTab is also hegyi@1: ///responsible for modify the digraph if it is hegyi@1: ///requested. Therefore it is responsible for translating user events to modifications to hegyi@1: ///do on digraph, like node/arc addition/deletion, map modification, addition and so on. hegyi@1: /// hegyi@1: ///To be able to solve these tasks the help of \ref MainWin is also needed, for example to hegyi@1: ///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab. hegyi@1: /// hegyi@1: ///Some information in the other direction is needed as well: for example when new map creation is requested for this tab hegyi@1: ///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals hegyi@1: ///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary. hegyi@1: class NoteBookTab : public Gtk::VBox hegyi@1: { hegyi@1: public: hegyi@1: hegyi@1: ///Constructor of \ref NoteBookTab hegyi@1: hegyi@1: ///It initiates the \re DigraphDisplayerCanvas, on which the digraph will be drawn hegyi@1: ///Signals of \ref MapStorage will be bound to the appropriate callback functions here. hegyi@1: NoteBookTab(); hegyi@1: hegyi@1: ~NoteBookTab(); hegyi@1: hegyi@1: ///Maps assigned to the digraph displayed in this \ref NoteBookTab of notebook. hegyi@1: MapStorage * mapstorage; hegyi@1: hegyi@1: ///Title changement indicator. hegyi@1: hegyi@1: ///If digraph is loaded from disk or saved to disk or changed its name somehow hegyi@1: ///this signal will be emit to let hegyi@1: ///\ref MainWin know that it has to modify the title of the main window. hegyi@1: ///It contains the new title. hegyi@1: sigc::signal signal_title; hegyi@1: hegyi@1: ///Returns \ref signal_title to be the caller able to connect it to a callback function. hegyi@1: sigc::signal signal_title_ch(); hegyi@1: hegyi@1: ///Indicates that new map window should be popped up. hegyi@1: hegyi@1: ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal. hegyi@1: ///The signal contains whether an arcmap or a nodemap should be popped up. \ref NewMapWin hegyi@1: ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin, hegyi@1: ///but for example \ref MainWin and \ref AlgoWin s as well. hegyi@1: sigc::signal signal_newmap; hegyi@1: hegyi@1: ///Returns \ref signal_newmap to be the caller able to connect it to a callback function. hegyi@1: sigc::signal signal_newmap_needed(); hegyi@1: hegyi@1: ///Loads the given file. hegyi@1: hegyi@1: ///The given file will be load in the \ref MapStorage and afeter that hegyi@1: ///\ref DigraphDisplayerCanvas will be requested to display the digraph. hegyi@1: ///\ref DigraphDisplayer will get datas from the recently set \ref MapStorage. hegyi@1: void readFile(const std::string &); hegyi@1: hegyi@1: ///The digraph will be drawn on this \ref DigraphDisplayerCanvas hegyi@1: DigraphDisplayerCanvas * gd_canvas; hegyi@1: hegyi@1: ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin. hegyi@1: bool mapwinexists; hegyi@1: hegyi@1: ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin. hegyi@1: bool designwinexists; hegyi@1: hegyi@1: ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin. hegyi@1: bool epswinexists; hegyi@1: hegyi@1: ///Address of the only \ref MapWin that the \ref NoteBookTab can open. hegyi@1: hegyi@1: ///Only one of this window can be opened at the same time (\ref mapwinexists), hegyi@1: ///because there is no need for more, one per tab is enough. hegyi@1: ///There won1t be benefit of more than one, but it would be hegyi@1: ///more complicated to synchronize them. hegyi@1: MapWin * mapwin; hegyi@1: hegyi@1: ///Address of the only \ref DesignWin that the \ref NoteBookTab can open. hegyi@1: hegyi@1: ///Only one of this window can be opened at the same time (\ref designwinexists), hegyi@1: ///because there is no need for more, one per tab is enough. hegyi@1: ///There won't be benefit of more than one, but it would be hegyi@1: ///more complicated to synchronize them. hegyi@1: DesignWin * designwin; hegyi@1: hegyi@1: ///Address of the only \ref EpsWin that the \ref NoteBookTab can open. hegyi@1: hegyi@1: ///Only one of this window can be opened at the same time (\ref epswinexists), hegyi@1: ///because there is no need for more, one per tab is enough. hegyi@1: ///There won't be benefit of more than one. hegyi@1: EpsWin * epswin; hegyi@1: hegyi@1: public: hegyi@1: ///Callback for 'FileNew' action. hegyi@1: virtual void newFile(); hegyi@1: ///Callback for 'FileOpen' action. hegyi@1: virtual void openFile(); hegyi@1: ///Callback for 'FileSave' action. hegyi@1: virtual void saveFile(); hegyi@1: ///Callback for 'FileSaveAs' action. hegyi@1: virtual void saveFileAs(); hegyi@1: ///Callback for 'Close' action. hegyi@1: virtual void close(); hegyi@1: hegyi@1: ///Handles changement of view of digraph. hegyi@1: hegyi@1: ///If the user changes the map to show by a property to a nother in \ref MapWin, hegyi@1: ///\ref MapWin will call this function. This function will registrate in \ref MapStorage hegyi@1: ///the new map to display by the changed property. After that \ref MapStorage will hegyi@1: ///emits a signal that will be forwarded to \ref DigraphDisplayerCanvas to update the hegyi@1: ///appropriate parts of digraph. hegyi@1: ///\param itiesarc whether the changed property is arc property or node property hegyi@1: ///\param prop id of property, see all_include.h hegyi@1: ///\param mapname name of the recently selected map hegyi@1: void propertyChange(bool itisarc, int prop, std::string mapname); hegyi@1: hegyi@1: ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin hegyi@1: hegyi@1: ///This function is called by \ref MapWin. hegyi@1: ///\param itisarc whether the new map should be an arcmap or a nodemap. hegyi@1: void popupNewMapWin(bool itisarc); hegyi@1: hegyi@1: ///Returns the actually selected arcmap to visualize by the given property. hegyi@1: hegyi@1: ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage. hegyi@1: ///\param prop property to inquire. hegyi@1: std::string getActiveArcMap(int prop); hegyi@1: hegyi@1: ///Returns the actually selected nodemap to visualize by the given property. hegyi@1: hegyi@1: ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage. hegyi@1: ///\param prop property to inquire. hegyi@1: std::string getActiveNodeMap(int prop); hegyi@1: hegyi@1: ///Registers recently created arcmap in \ref MapWin. hegyi@1: hegyi@1: ///After creation of new map \ref MapStorage emits a signal. hegyi@1: ///This signal is bound to this callback function, that will call hegyi@1: ///a function with the same name and same parameterin \ref MapWin. hegyi@1: ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin hegyi@1: ///\param mapname name of new map hegyi@1: void registerNewArcMap(std::string mapname, MapValue::Type type); hegyi@1: hegyi@1: ///Registers recently created nodemap in \ref MapWin. hegyi@1: hegyi@1: ///After creation of new map \ref MapStorage emits a signal. hegyi@1: ///This signal is bound to this callback function, that will call hegyi@1: ///a function with the same name and same parameter in \ref MapWin. hegyi@1: ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin hegyi@1: ///\param mapname name of new map hegyi@1: void registerNewNodeMap(std::string mapname, MapValue::Type type); hegyi@1: hegyi@1: ///Pops up and registrates the \ref MapWin of \ref NoteBookTab. hegyi@1: hegyi@1: ///See also hegyi@1: ///\ref mapwin. hegyi@1: void createMapWin(std::string); hegyi@1: hegyi@1: ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab. hegyi@1: hegyi@1: ///See also hegyi@1: ///\ref mapwin. hegyi@1: void createDesignWin(std::string); hegyi@1: hegyi@1: ///Pops up a window, that can dump digraph to EPS hegyi@1: hegyi@1: ///Different parameters can be set here. hegyi@1: void createExportToEPSWin(std::string); hegyi@1: hegyi@1: ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab. hegyi@1: hegyi@1: ///See also hegyi@1: ///\ref mapwin. hegyi@1: void closeMapWin(); hegyi@1: hegyi@1: ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab. hegyi@1: hegyi@1: ///See also hegyi@1: ///\ref designwin. hegyi@1: bool closeDesignWin(GdkEventAny *); hegyi@1: hegyi@1: ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab. hegyi@1: hegyi@1: ///See also hegyi@1: ///\ref epswin. hegyi@1: void closeEpsWin(); hegyi@1: hegyi@1: ///Sets node representation settings hegyi@1: void setView(bool, bool, double, double); hegyi@1: hegyi@1: ///Gets node representation settings hegyi@1: void getView(bool &, bool &, double&, double&); hegyi@1: hegyi@1: ///Let the digraph redesign, based on gravity and arc elasticity. hegyi@1: void reDesignDigraph(); hegyi@1: hegyi@1: ///Lets Mapstorage export the digraph to EPS hegyi@1: void exportDigraphToEPS(std::vector, std::string, std::string); hegyi@1: hegyi@1: ///\ref MapWin calls this function when it updates the maplist in comboboxes. hegyi@1: void active_maps_needed(); hegyi@1: hegyi@1: private: hegyi@1: ///Called when title of tab has changed hegyi@1: void title_changed(std::string); hegyi@1: hegyi@1: ///Signal connection from \ref MapStorage to \ref MapWin hegyi@1: hegyi@1: ///If \ref MapWin is closed this connection has to be disconnected, hegyi@1: ///therefore we have to store it. hegyi@1: sigc::connection mapst2mapwin; hegyi@1: hegyi@1: ///Signal connection from \ref MapStorage to \ref DesignWin hegyi@1: hegyi@1: ///If \ref DesignWin is closed this connection has to be disconnected, hegyi@1: ///therefore we have to store it. hegyi@1: sigc::connection mapst2designwin; hegyi@1: }; hegyi@1: hegyi@1: #endif //NBTAB_H