1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/nbtab.h Mon Jul 07 08:10:39 2008 -0500
1.3 @@ -0,0 +1,256 @@
1.4 +/* -*- C++ -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library
1.7 + *
1.8 + * Copyright (C) 2003-2006
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +#ifndef NBTAB_H
1.23 +#define NBTAB_H
1.24 +
1.25 +class MapStorage;
1.26 +class EpsWin;
1.27 +class MapWin;
1.28 +class DesignWin;
1.29 +class DigraphDisplayerCanvas;
1.30 +
1.31 +#include <libgnomecanvasmm.h>
1.32 +#include <libgnomecanvasmm/polygon.h>
1.33 +#include "map_value.h"
1.34 +
1.35 +///One tab in the Notebook that is placed in the main window (\ref MainWin).
1.36 +
1.37 +///One digraph and all of its accessories like maps are assigned to one tab in the notebook.
1.38 +///\ref NoteBookTab is responsible for the user defined display of the digraph: view can be
1.39 +///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
1.40 +///view of digraph. This is \ref Mapwin window.
1.41 +///
1.42 +///\ref NoteBookTab is also
1.43 +///responsible for modify the digraph if it is
1.44 +///requested. Therefore it is responsible for translating user events to modifications to
1.45 +///do on digraph, like node/arc addition/deletion, map modification, addition and so on.
1.46 +///
1.47 +///To be able to solve these tasks the help of \ref MainWin is also needed, for example to
1.48 +///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab.
1.49 +///
1.50 +///Some information in the other direction is needed as well: for example when new map creation is requested for this tab
1.51 +///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals
1.52 +///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary.
1.53 +class NoteBookTab : public Gtk::VBox
1.54 +{
1.55 +public:
1.56 +
1.57 + ///Constructor of \ref NoteBookTab
1.58 +
1.59 + ///It initiates the \re DigraphDisplayerCanvas, on which the digraph will be drawn
1.60 + ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
1.61 + NoteBookTab();
1.62 +
1.63 + ~NoteBookTab();
1.64 +
1.65 + ///Maps assigned to the digraph displayed in this \ref NoteBookTab of notebook.
1.66 + MapStorage * mapstorage;
1.67 +
1.68 + ///Title changement indicator.
1.69 +
1.70 + ///If digraph is loaded from disk or saved to disk or changed its name somehow
1.71 + ///this signal will be emit to let
1.72 + ///\ref MainWin know that it has to modify the title of the main window.
1.73 + ///It contains the new title.
1.74 + sigc::signal<void, std::string> signal_title;
1.75 +
1.76 + ///Returns \ref signal_title to be the caller able to connect it to a callback function.
1.77 + sigc::signal<void, std::string> signal_title_ch();
1.78 +
1.79 + ///Indicates that new map window should be popped up.
1.80 +
1.81 + ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
1.82 + ///The signal contains whether an arcmap or a nodemap should be popped up. \ref NewMapWin
1.83 + ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
1.84 + ///but for example \ref MainWin and \ref AlgoWin s as well.
1.85 + sigc::signal<void, NoteBookTab *, bool> signal_newmap;
1.86 +
1.87 + ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
1.88 + sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
1.89 +
1.90 + ///Loads the given file.
1.91 +
1.92 + ///The given file will be load in the \ref MapStorage and afeter that
1.93 + ///\ref DigraphDisplayerCanvas will be requested to display the digraph.
1.94 + ///\ref DigraphDisplayer will get datas from the recently set \ref MapStorage.
1.95 + void readFile(const std::string &);
1.96 +
1.97 + ///The digraph will be drawn on this \ref DigraphDisplayerCanvas
1.98 + DigraphDisplayerCanvas * gd_canvas;
1.99 +
1.100 + ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
1.101 + bool mapwinexists;
1.102 +
1.103 + ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
1.104 + bool designwinexists;
1.105 +
1.106 + ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
1.107 + bool epswinexists;
1.108 +
1.109 + ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
1.110 +
1.111 + ///Only one of this window can be opened at the same time (\ref mapwinexists),
1.112 + ///because there is no need for more, one per tab is enough.
1.113 + ///There won1t be benefit of more than one, but it would be
1.114 + ///more complicated to synchronize them.
1.115 + MapWin * mapwin;
1.116 +
1.117 + ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
1.118 +
1.119 + ///Only one of this window can be opened at the same time (\ref designwinexists),
1.120 + ///because there is no need for more, one per tab is enough.
1.121 + ///There won't be benefit of more than one, but it would be
1.122 + ///more complicated to synchronize them.
1.123 + DesignWin * designwin;
1.124 +
1.125 + ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
1.126 +
1.127 + ///Only one of this window can be opened at the same time (\ref epswinexists),
1.128 + ///because there is no need for more, one per tab is enough.
1.129 + ///There won't be benefit of more than one.
1.130 + EpsWin * epswin;
1.131 +
1.132 +public:
1.133 + ///Callback for 'FileNew' action.
1.134 + virtual void newFile();
1.135 + ///Callback for 'FileOpen' action.
1.136 + virtual void openFile();
1.137 + ///Callback for 'FileSave' action.
1.138 + virtual void saveFile();
1.139 + ///Callback for 'FileSaveAs' action.
1.140 + virtual void saveFileAs();
1.141 + ///Callback for 'Close' action.
1.142 + virtual void close();
1.143 +
1.144 + ///Handles changement of view of digraph.
1.145 +
1.146 + ///If the user changes the map to show by a property to a nother in \ref MapWin,
1.147 + ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
1.148 + ///the new map to display by the changed property. After that \ref MapStorage will
1.149 + ///emits a signal that will be forwarded to \ref DigraphDisplayerCanvas to update the
1.150 + ///appropriate parts of digraph.
1.151 + ///\param itiesarc whether the changed property is arc property or node property
1.152 + ///\param prop id of property, see all_include.h
1.153 + ///\param mapname name of the recently selected map
1.154 + void propertyChange(bool itisarc, int prop, std::string mapname);
1.155 +
1.156 + ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
1.157 +
1.158 + ///This function is called by \ref MapWin.
1.159 + ///\param itisarc whether the new map should be an arcmap or a nodemap.
1.160 + void popupNewMapWin(bool itisarc);
1.161 +
1.162 + ///Returns the actually selected arcmap to visualize by the given property.
1.163 +
1.164 + ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
1.165 + ///\param prop property to inquire.
1.166 + std::string getActiveArcMap(int prop);
1.167 +
1.168 + ///Returns the actually selected nodemap to visualize by the given property.
1.169 +
1.170 + ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
1.171 + ///\param prop property to inquire.
1.172 + std::string getActiveNodeMap(int prop);
1.173 +
1.174 + ///Registers recently created arcmap in \ref MapWin.
1.175 +
1.176 + ///After creation of new map \ref MapStorage emits a signal.
1.177 + ///This signal is bound to this callback function, that will call
1.178 + ///a function with the same name and same parameterin \ref MapWin.
1.179 + ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
1.180 + ///\param mapname name of new map
1.181 + void registerNewArcMap(std::string mapname, MapValue::Type type);
1.182 +
1.183 + ///Registers recently created nodemap in \ref MapWin.
1.184 +
1.185 + ///After creation of new map \ref MapStorage emits a signal.
1.186 + ///This signal is bound to this callback function, that will call
1.187 + ///a function with the same name and same parameter in \ref MapWin.
1.188 + ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
1.189 + ///\param mapname name of new map
1.190 + void registerNewNodeMap(std::string mapname, MapValue::Type type);
1.191 +
1.192 + ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
1.193 +
1.194 + ///See also
1.195 + ///\ref mapwin.
1.196 + void createMapWin(std::string);
1.197 +
1.198 + ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
1.199 +
1.200 + ///See also
1.201 + ///\ref mapwin.
1.202 + void createDesignWin(std::string);
1.203 +
1.204 + ///Pops up a window, that can dump digraph to EPS
1.205 +
1.206 + ///Different parameters can be set here.
1.207 + void createExportToEPSWin(std::string);
1.208 +
1.209 + ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
1.210 +
1.211 + ///See also
1.212 + ///\ref mapwin.
1.213 + void closeMapWin();
1.214 +
1.215 + ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
1.216 +
1.217 + ///See also
1.218 + ///\ref designwin.
1.219 + bool closeDesignWin(GdkEventAny *);
1.220 +
1.221 + ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
1.222 +
1.223 + ///See also
1.224 + ///\ref epswin.
1.225 + void closeEpsWin();
1.226 +
1.227 + ///Sets node representation settings
1.228 + void setView(bool, bool, double, double);
1.229 +
1.230 + ///Gets node representation settings
1.231 + void getView(bool &, bool &, double&, double&);
1.232 +
1.233 + ///Let the digraph redesign, based on gravity and arc elasticity.
1.234 + void reDesignDigraph();
1.235 +
1.236 + ///Lets Mapstorage export the digraph to EPS
1.237 + void exportDigraphToEPS(std::vector<bool>, std::string, std::string);
1.238 +
1.239 + ///\ref MapWin calls this function when it updates the maplist in comboboxes.
1.240 + void active_maps_needed();
1.241 +
1.242 +private:
1.243 + ///Called when title of tab has changed
1.244 + void title_changed(std::string);
1.245 +
1.246 + ///Signal connection from \ref MapStorage to \ref MapWin
1.247 +
1.248 + ///If \ref MapWin is closed this connection has to be disconnected,
1.249 + ///therefore we have to store it.
1.250 + sigc::connection mapst2mapwin;
1.251 +
1.252 + ///Signal connection from \ref MapStorage to \ref DesignWin
1.253 +
1.254 + ///If \ref DesignWin is closed this connection has to be disconnected,
1.255 + ///therefore we have to store it.
1.256 + sigc::connection mapst2designwin;
1.257 +};
1.258 +
1.259 +#endif //NBTAB_H