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