/* -*- C++ -*- * * This file is a part of LEMON, a generic C++ optimization library * * Copyright (C) 2003-2006 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * * Permission to use, modify and distribute this software is granted * provided that this copyright notice appears in all copies. For * precise terms see the accompanying LICENSE file. * * This software is provided "AS IS" with no warranty of any kind, * express or implied, and with no claim as to its suitability for any * purpose. * */ #ifndef NBTAB_H #define NBTAB_H class NoteBookTab; #include "mapstorage.h" #include "map_win.h" #include "design_win.h" #include "graph_displayer_canvas.h" #include #include ///One tab in the Notebook that is placed in the main window (\ref MainWin). ///One graph and all of its accessories like maps are assigned to one tab in the notebook. ///\ref NoteBookTab is responsible for the user defined display of the graph: view can be ///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the ///view of graph. This is \ref Mapwin window. /// ///\ref NoteBookTab is also ///responsible for modify the graph if it is ///requested. Therefore it is responsible for translating user events to modifications to ///do on graph, like node/edge addition/deletion, map modification, addition and so on. /// ///To be able to solve these tasks the help of \ref MainWin is also needed, for example to ///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab. /// ///Some information in the other direction is needed as well: for example when new map creation is requested for this tab ///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals ///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary. class NoteBookTab : public Gtk::VBox { public: ///Constructor of \ref NoteBookTab ///It initiates the \re GraphDisplayerCanvas, on which the graph will be drawn ///Signals of \ref MapStorage will be bound to the appropriate callback functions here. NoteBookTab(); ///Maps assigned to the graph displayed in this \ref NoteBookTab of notebook. MapStorage mapstorage; ///Title changement indicator. ///If graph is loaded from disk or saved to disk or changed its name somehow ///this signal will be emit to let ///\ref MainWin know that it has to modify the title of the main window. ///It contains the new title. sigc::signal signal_title; ///Returns \ref signal_title to be the caller able to connect it to a callback function. sigc::signal signal_title_ch(); ///Indicates that new map window should be popped up. ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal. ///The signal contains whether an edgemap or a nodemap should be popped up. \ref NewMapWin ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin, ///but for example \ref MainWin and \ref AlgoWin s as well. sigc::signal signal_newmap; ///Returns \ref signal_newmap to be the caller able to connect it to a callback function. sigc::signal signal_newmap_needed(); ///Loads the given file. ///The given file will be load in the \ref MapStorage and afeter that ///\ref GraphDisplayerCanvas will be requested to display the graph. ///\ref GraphDisplayer will get datas from the recently set \ref MapStorage. void readFile(const std::string &); ///The graph will be drawn on this \ref GraphDisplayerCanvas GraphDisplayerCanvas * gd_canvas; ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin. bool mapwinexists; ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin. bool designwinexists; ///Address of the only \ref MapWin that the \ref NoteBookTab can open. ///Only one of this window can be opened at the same time (\ref mapwinexists), ///because there is no need for more, one per tab is enough. ///There won1t be benefit of more than one, but it would be ///more complicated to synchronize them. MapWin * mapwin; ///Address of the only \ref DesignWin that the \ref NoteBookTab can open. ///Only one of this window can be opened at the same time (\ref designwinexists), ///because there is no need for more, one per tab is enough. ///There won't be benefit of more than one, but it would be ///more complicated to synchronize them. DesignWin * designwin; public: ///Callback for 'FileNew' action. virtual void newFile(); ///Callback for 'FileOpen' action. virtual void openFile(); ///Callback for 'FileSave' action. virtual void saveFile(); ///Callback for 'FileSaveAs' action. virtual void saveFileAs(); ///Callback for 'Close' action. virtual void close(); ///Handles changement of view of graph. ///If the user changes the map to show by a property to a nother in \ref MapWin, ///\ref MapWin will call this function. This function will registrate in \ref MapStorage ///the new map to display by the changed property. After that \ref MapStorage will ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the ///appropriate parts of graph. ///\param itiesedge whether the changed property is edge property or node property ///\param prop id of property, see all_include.h ///\param mapname name of the recently selected map void propertyChange(bool itisedge, int prop, std::string mapname); ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin ///This function is called by \ref MapWin. ///\param itisedge whether the new map should be an edgemap or a nodemap. void popupNewMapWin(bool itisedge); ///Returns the actually selected edgemap to visualize by the given property. ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage. ///\param prop property to inquire. std::string getActiveEdgeMap(int prop); ///Returns the actually selected nodemap to visualize by the given property. ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage. ///\param prop property to inquire. std::string getActiveNodeMap(int prop); ///Registers recently created edgemap in \ref MapWin. ///After creation of new map \ref MapStorage emits a signal. ///This signal is bound to this callback function, that will call ///a function with the same name and same parameterin \ref MapWin. ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin ///\param mapname name of new map void registerNewEdgeMap(std::string mapname); ///Registers recently created nodemap in \ref MapWin. ///After creation of new map \ref MapStorage emits a signal. ///This signal is bound to this callback function, that will call ///a function with the same name and same parameter in \ref MapWin. ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin ///\param mapname name of new map void registerNewNodeMap(std::string mapname); ///Pops up and registrates the \ref MapWin of \ref NoteBookTab. ///See also ///\ref mapwin. void createMapWin(std::string); ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab. ///See also ///\ref mapwin. void createDesignWin(std::string); ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab. ///See also ///\ref mapwin. void closeMapWin(); bool closeDesignWin(GdkEventAny *); ///Sets node representation settings void setView(bool, bool, double, double); ///Gets node representation settings void getView(bool &, bool &, double&, double&); ///Let the graph redesign, based on gravity and edge elasticity. void reDesignGraph(); ///Indicates that attraction factor is changed void attraction_ch(double); ///Indicates that propulsation factor is changed void propulsation_ch(double); ///Indicates that iteration number of redesign is changed void iteration_ch(int); ///\ref MapWin calls this function when it updates the maplist in comboboxes. void active_maps_needed(); private: ///Signal connection from \ref MapStorage to \ref MapWin ///If \ref MapWin is closed this connection has to be disconnected, ///therefore we have to store it. sigc::connection mapst2mapwin; }; #endif //NBTAB_H