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