nbtab.h
author hegyi
Thu, 01 Mar 2007 16:28:13 +0000
changeset 198 d6cc0579b94b
parent 196 c220f9de6545
child 201 879e47e5b731
permissions -rw-r--r--
Shape feature of EPS can be used.
alpar@174
     1
/* -*- C++ -*-
alpar@174
     2
 *
alpar@174
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@174
     4
 *
alpar@174
     5
 * Copyright (C) 2003-2006
alpar@174
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@174
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@174
     8
 *
alpar@174
     9
 * Permission to use, modify and distribute this software is granted
alpar@174
    10
 * provided that this copyright notice appears in all copies. For
alpar@174
    11
 * precise terms see the accompanying LICENSE file.
alpar@174
    12
 *
alpar@174
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@174
    14
 * express or implied, and with no claim as to its suitability for any
alpar@174
    15
 * purpose.
alpar@174
    16
 *
alpar@174
    17
 */
hegyi@96
    18
hegyi@96
    19
#ifndef NBTAB_H
hegyi@96
    20
#define NBTAB_H
hegyi@96
    21
hegyi@194
    22
class MapStorage;
hegyi@194
    23
class EpsWin;
hegyi@194
    24
class MapWin;
hegyi@194
    25
class DesignWin;
hegyi@194
    26
class GraphDisplayerCanvas;
hegyi@96
    27
hegyi@96
    28
#include <libgnomecanvasmm.h>
hegyi@96
    29
#include <libgnomecanvasmm/polygon.h>
hegyi@96
    30
hegyi@121
    31
///One tab in the Notebook that is placed in the main window (\ref MainWin).
hegyi@121
    32
hegyi@121
    33
///One graph and all of its accessories like maps are assigned to one tab in the notebook.
hegyi@121
    34
///\ref NoteBookTab is responsible for the user defined display of the graph: view can be
hegyi@121
    35
///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
hegyi@121
    36
///view of graph. This is \ref Mapwin window.
hegyi@121
    37
///
hegyi@121
    38
///\ref NoteBookTab is also
hegyi@121
    39
///responsible for modify the graph if it is
hegyi@121
    40
///requested. Therefore it is responsible for translating user events to modifications to
hegyi@121
    41
///do on graph, like node/edge addition/deletion, map modification, addition and so on.
hegyi@121
    42
///
hegyi@121
    43
///To be able to solve these tasks the help of \ref MainWin is also needed, for example to
hegyi@121
    44
///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab.
hegyi@121
    45
///
hegyi@121
    46
///Some information in the other direction is needed as well: for example when new map creation is requested for this tab
hegyi@121
    47
///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals
hegyi@121
    48
///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary.
hegyi@96
    49
class NoteBookTab : public Gtk::VBox
hegyi@96
    50
{
hegyi@96
    51
public:
hegyi@121
    52
  
hegyi@121
    53
  ///Constructor of \ref NoteBookTab
hegyi@121
    54
hegyi@121
    55
  ///It initiates the \re GraphDisplayerCanvas, on which the graph will be drawn
hegyi@121
    56
  ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
hegyi@96
    57
  NoteBookTab();
hegyi@96
    58
  
hegyi@121
    59
  ///Maps assigned to the graph displayed in this \ref NoteBookTab of notebook.
hegyi@194
    60
  MapStorage * mapstorage;
hegyi@96
    61
    
hegyi@121
    62
  ///Title changement indicator.
hegyi@121
    63
hegyi@121
    64
  ///If graph is loaded from disk or saved to disk or changed its name somehow
hegyi@121
    65
  ///this signal will be emit to let
hegyi@121
    66
  ///\ref MainWin know that it has to modify the title of the main window.
hegyi@121
    67
  ///It contains the new title.
hegyi@96
    68
  sigc::signal<void, std::string> signal_title;
hegyi@96
    69
hegyi@121
    70
  ///Returns \ref signal_title to be the caller able to connect it to a callback function.
hegyi@96
    71
  sigc::signal<void, std::string> signal_title_ch();
hegyi@96
    72
hegyi@121
    73
  ///Indicates that new map window should be popped up.
hegyi@121
    74
hegyi@121
    75
  ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
hegyi@121
    76
  ///The signal contains whether an edgemap or a nodemap should be popped up. \ref NewMapWin
hegyi@121
    77
  ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
hegyi@121
    78
  ///but for example \ref MainWin and \ref AlgoWin s as well.
hegyi@96
    79
  sigc::signal<void, NoteBookTab *, bool> signal_newmap;
hegyi@96
    80
hegyi@121
    81
  ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
hegyi@96
    82
  sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
hegyi@96
    83
hegyi@121
    84
  ///Loads the given file.
hegyi@121
    85
hegyi@121
    86
  ///The given file will be load in the \ref MapStorage and afeter that
hegyi@121
    87
  ///\ref GraphDisplayerCanvas will be requested to display the graph.
hegyi@121
    88
  ///\ref GraphDisplayer will get datas from the recently set \ref MapStorage.
hegyi@96
    89
  void readFile(const std::string &);
hegyi@96
    90
    
hegyi@96
    91
  ///The graph will be drawn on this \ref GraphDisplayerCanvas
hegyi@96
    92
  GraphDisplayerCanvas * gd_canvas;
hegyi@96
    93
hegyi@121
    94
  ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
hegyi@96
    95
  bool mapwinexists;
hegyi@96
    96
hegyi@160
    97
  ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
hegyi@160
    98
  bool designwinexists;
hegyi@160
    99
hegyi@191
   100
  ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
hegyi@191
   101
  bool epswinexists;
hegyi@191
   102
hegyi@121
   103
  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
hegyi@121
   104
hegyi@121
   105
  ///Only one of this window can be opened at the same time (\ref mapwinexists), 
hegyi@121
   106
  ///because there is no need for more, one per tab is enough.
hegyi@121
   107
  ///There won1t be benefit of more than one, but it would be
hegyi@121
   108
  ///more complicated to synchronize them.
hegyi@96
   109
  MapWin * mapwin;
hegyi@96
   110
    
hegyi@160
   111
  ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
hegyi@160
   112
hegyi@160
   113
  ///Only one of this window can be opened at the same time (\ref designwinexists), 
hegyi@160
   114
  ///because there is no need for more, one per tab is enough.
hegyi@160
   115
  ///There won't be benefit of more than one, but it would be
hegyi@160
   116
  ///more complicated to synchronize them.
hegyi@160
   117
  DesignWin * designwin;
hegyi@160
   118
hegyi@191
   119
  ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
hegyi@191
   120
hegyi@191
   121
  ///Only one of this window can be opened at the same time (\ref epswinexists), 
hegyi@191
   122
  ///because there is no need for more, one per tab is enough.
hegyi@191
   123
  ///There won't be benefit of more than one.
hegyi@191
   124
  EpsWin * epswin;
hegyi@191
   125
hegyi@96
   126
public:
hegyi@96
   127
  ///Callback for 'FileNew' action.
hegyi@96
   128
  virtual void newFile();
hegyi@96
   129
  ///Callback for 'FileOpen' action.
hegyi@96
   130
  virtual void openFile();
hegyi@96
   131
  ///Callback for 'FileSave' action.
hegyi@96
   132
  virtual void saveFile();
hegyi@96
   133
  ///Callback for 'FileSaveAs' action.
hegyi@96
   134
  virtual void saveFileAs();
hegyi@96
   135
  ///Callback for 'Close' action.
hegyi@96
   136
  virtual void close();
hegyi@96
   137
hegyi@121
   138
  ///Handles changement of view of graph.
hegyi@96
   139
hegyi@121
   140
  ///If the user changes the map to show by a property to a nother in \ref MapWin,
hegyi@121
   141
  ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
hegyi@121
   142
  ///the new map to display by the changed property. After that \ref MapStorage will
hegyi@121
   143
  ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the
hegyi@121
   144
  ///appropriate parts of graph.
hegyi@121
   145
  ///\param itiesedge whether the changed property is edge property or node property
hegyi@121
   146
  ///\param prop id of property, see all_include.h
hegyi@121
   147
  ///\param mapname name of the recently selected map
hegyi@121
   148
  void propertyChange(bool itisedge, int prop, std::string mapname);
hegyi@96
   149
hegyi@121
   150
  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
hegyi@96
   151
hegyi@121
   152
  ///This function is called by \ref MapWin.
hegyi@121
   153
  ///\param itisedge whether the new map should be an edgemap or a nodemap.
hegyi@121
   154
  void popupNewMapWin(bool itisedge);
hegyi@121
   155
hegyi@121
   156
  ///Returns the actually selected edgemap to visualize by the given property.
hegyi@121
   157
hegyi@121
   158
  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
hegyi@121
   159
  ///\param prop property to inquire.
hegyi@121
   160
  std::string getActiveEdgeMap(int prop);
hegyi@121
   161
hegyi@121
   162
  ///Returns the actually selected nodemap to visualize by the given property.
hegyi@121
   163
hegyi@121
   164
  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
hegyi@121
   165
  ///\param prop property to inquire.
hegyi@121
   166
  std::string getActiveNodeMap(int prop);
hegyi@121
   167
hegyi@121
   168
  ///Registers recently created edgemap in \ref MapWin.
hegyi@121
   169
hegyi@121
   170
  ///After creation of new map \ref MapStorage emits a signal.
hegyi@121
   171
  ///This signal is bound to this callback function, that will call
hegyi@121
   172
  ///a function with the same name and same parameterin \ref MapWin.
hegyi@121
   173
  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
hegyi@121
   174
  ///\param mapname name of new map
hegyi@121
   175
  void registerNewEdgeMap(std::string mapname);
hegyi@121
   176
hegyi@121
   177
  ///Registers recently created nodemap in \ref MapWin.
hegyi@121
   178
hegyi@121
   179
  ///After creation of new map \ref MapStorage emits a signal.
hegyi@121
   180
  ///This signal is bound to this callback function, that will call
hegyi@121
   181
  ///a function with the same name and same parameter in \ref MapWin.
hegyi@121
   182
  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
hegyi@121
   183
  ///\param mapname name of new map
hegyi@121
   184
  void registerNewNodeMap(std::string mapname);
hegyi@121
   185
hegyi@121
   186
  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
hegyi@121
   187
  
hegyi@121
   188
  ///See also
hegyi@121
   189
  ///\ref mapwin.
hegyi@96
   190
  void createMapWin(std::string);
hegyi@121
   191
hegyi@160
   192
  ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
hegyi@160
   193
  
hegyi@160
   194
  ///See also
hegyi@160
   195
  ///\ref mapwin.
hegyi@160
   196
  void createDesignWin(std::string);
hegyi@160
   197
hegyi@191
   198
  ///Pops up a window, that can dump graph to EPS
hegyi@191
   199
hegyi@191
   200
  ///Different parameters can be set here.
hegyi@191
   201
  void createExportToEPSWin(std::string);
hegyi@191
   202
hegyi@121
   203
  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
hegyi@121
   204
  
hegyi@121
   205
  ///See also
hegyi@121
   206
  ///\ref mapwin.
hegyi@96
   207
  void closeMapWin();
hegyi@154
   208
hegyi@191
   209
  ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
hegyi@191
   210
  
hegyi@191
   211
  ///See also
hegyi@191
   212
  ///\ref designwin.
hegyi@160
   213
  bool closeDesignWin(GdkEventAny *);
hegyi@160
   214
hegyi@191
   215
  ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
hegyi@191
   216
  
hegyi@191
   217
  ///See also
hegyi@191
   218
  ///\ref epswin.
hegyi@191
   219
  void closeEpsWin();
hegyi@191
   220
hegyi@154
   221
  ///Sets node representation settings
hegyi@157
   222
  void setView(bool, bool, double, double);
hegyi@154
   223
hegyi@154
   224
  ///Gets node representation settings
hegyi@157
   225
  void getView(bool &, bool &, double&, double&);
hegyi@160
   226
hegyi@172
   227
  ///Let the graph redesign, based on gravity and edge elasticity.
hegyi@160
   228
  void reDesignGraph();
hegyi@160
   229
hegyi@191
   230
  ///Lets Mapstorage export the graph to EPS
hegyi@198
   231
  void exportGraphToEPS(std::vector<bool>, std::string, std::string);
hegyi@191
   232
hegyi@172
   233
  ///\ref MapWin calls this function when it updates the maplist in comboboxes.
hegyi@172
   234
  void active_maps_needed();
hegyi@172
   235
hegyi@172
   236
private:
hegyi@196
   237
  ///Called when title of tab has changed
hegyi@196
   238
  void title_changed(std::string);
hegyi@196
   239
hegyi@172
   240
  ///Signal connection from \ref MapStorage to \ref MapWin
hegyi@172
   241
hegyi@172
   242
  ///If \ref MapWin is closed this connection has to be disconnected,
hegyi@172
   243
  ///therefore we have to store it.
hegyi@172
   244
  sigc::connection mapst2mapwin;
hegyi@177
   245
hegyi@177
   246
  ///Signal connection from \ref MapStorage to \ref DesignWin
hegyi@177
   247
hegyi@177
   248
  ///If \ref DesignWin is closed this connection has to be disconnected,
hegyi@177
   249
  ///therefore we have to store it.
hegyi@177
   250
  sigc::connection mapst2designwin;
hegyi@96
   251
};
hegyi@96
   252
hegyi@96
   253
#endif //NBTAB_H