nbtab.h
author alpar
Mon, 30 Oct 2006 12:20:54 +0000
changeset 175 1e0a66d6b45a
parent 172 fc1e478697d3
child 177 40f3006fba2e
permissions -rw-r--r--
Add autopackage specfile (not yet working).
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@160
    26
#include "design_win.h"
hegyi@96
    27
#include "graph_displayer_canvas.h"
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@96
    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@121
   100
  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
hegyi@121
   101
hegyi@121
   102
  ///Only one of this window can be opened at the same time (\ref mapwinexists), 
hegyi@121
   103
  ///because there is no need for more, one per tab is enough.
hegyi@121
   104
  ///There won1t be benefit of more than one, but it would be
hegyi@121
   105
  ///more complicated to synchronize them.
hegyi@96
   106
  MapWin * mapwin;
hegyi@96
   107
    
hegyi@160
   108
  ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
hegyi@160
   109
hegyi@160
   110
  ///Only one of this window can be opened at the same time (\ref designwinexists), 
hegyi@160
   111
  ///because there is no need for more, one per tab is enough.
hegyi@160
   112
  ///There won't be benefit of more than one, but it would be
hegyi@160
   113
  ///more complicated to synchronize them.
hegyi@160
   114
  DesignWin * designwin;
hegyi@160
   115
hegyi@96
   116
public:
hegyi@96
   117
  ///Callback for 'FileNew' action.
hegyi@96
   118
  virtual void newFile();
hegyi@96
   119
  ///Callback for 'FileOpen' action.
hegyi@96
   120
  virtual void openFile();
hegyi@96
   121
  ///Callback for 'FileSave' action.
hegyi@96
   122
  virtual void saveFile();
hegyi@96
   123
  ///Callback for 'FileSaveAs' action.
hegyi@96
   124
  virtual void saveFileAs();
hegyi@96
   125
  ///Callback for 'Close' action.
hegyi@96
   126
  virtual void close();
hegyi@96
   127
hegyi@121
   128
  ///Handles changement of view of graph.
hegyi@96
   129
hegyi@121
   130
  ///If the user changes the map to show by a property to a nother in \ref MapWin,
hegyi@121
   131
  ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
hegyi@121
   132
  ///the new map to display by the changed property. After that \ref MapStorage will
hegyi@121
   133
  ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the
hegyi@121
   134
  ///appropriate parts of graph.
hegyi@121
   135
  ///\param itiesedge whether the changed property is edge property or node property
hegyi@121
   136
  ///\param prop id of property, see all_include.h
hegyi@121
   137
  ///\param mapname name of the recently selected map
hegyi@121
   138
  void propertyChange(bool itisedge, int prop, std::string mapname);
hegyi@96
   139
hegyi@121
   140
  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
hegyi@96
   141
hegyi@121
   142
  ///This function is called by \ref MapWin.
hegyi@121
   143
  ///\param itisedge whether the new map should be an edgemap or a nodemap.
hegyi@121
   144
  void popupNewMapWin(bool itisedge);
hegyi@121
   145
hegyi@121
   146
  ///Returns the actually selected edgemap to visualize by the given property.
hegyi@121
   147
hegyi@121
   148
  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
hegyi@121
   149
  ///\param prop property to inquire.
hegyi@121
   150
  std::string getActiveEdgeMap(int prop);
hegyi@121
   151
hegyi@121
   152
  ///Returns the actually selected nodemap to visualize by the given property.
hegyi@121
   153
hegyi@121
   154
  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
hegyi@121
   155
  ///\param prop property to inquire.
hegyi@121
   156
  std::string getActiveNodeMap(int prop);
hegyi@121
   157
hegyi@121
   158
  ///Registers recently created edgemap in \ref MapWin.
hegyi@121
   159
hegyi@121
   160
  ///After creation of new map \ref MapStorage emits a signal.
hegyi@121
   161
  ///This signal is bound to this callback function, that will call
hegyi@121
   162
  ///a function with the same name and same parameterin \ref MapWin.
hegyi@121
   163
  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
hegyi@121
   164
  ///\param mapname name of new map
hegyi@121
   165
  void registerNewEdgeMap(std::string mapname);
hegyi@121
   166
hegyi@121
   167
  ///Registers recently created nodemap in \ref MapWin.
hegyi@121
   168
hegyi@121
   169
  ///After creation of new map \ref MapStorage emits a signal.
hegyi@121
   170
  ///This signal is bound to this callback function, that will call
hegyi@121
   171
  ///a function with the same name and same parameter in \ref MapWin.
hegyi@121
   172
  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
hegyi@121
   173
  ///\param mapname name of new map
hegyi@121
   174
  void registerNewNodeMap(std::string mapname);
hegyi@121
   175
hegyi@121
   176
  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
hegyi@121
   177
  
hegyi@121
   178
  ///See also
hegyi@121
   179
  ///\ref mapwin.
hegyi@96
   180
  void createMapWin(std::string);
hegyi@121
   181
hegyi@160
   182
  ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
hegyi@160
   183
  
hegyi@160
   184
  ///See also
hegyi@160
   185
  ///\ref mapwin.
hegyi@160
   186
  void createDesignWin(std::string);
hegyi@160
   187
hegyi@121
   188
  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
hegyi@121
   189
  
hegyi@121
   190
  ///See also
hegyi@121
   191
  ///\ref mapwin.
hegyi@96
   192
  void closeMapWin();
hegyi@154
   193
hegyi@160
   194
  bool closeDesignWin(GdkEventAny *);
hegyi@160
   195
hegyi@154
   196
  ///Sets node representation settings
hegyi@157
   197
  void setView(bool, bool, double, double);
hegyi@154
   198
hegyi@154
   199
  ///Gets node representation settings
hegyi@157
   200
  void getView(bool &, bool &, double&, double&);
hegyi@160
   201
hegyi@172
   202
  ///Let the graph redesign, based on gravity and edge elasticity.
hegyi@160
   203
  void reDesignGraph();
hegyi@160
   204
hegyi@172
   205
  ///Indicates that attraction factor is changed
hegyi@160
   206
  void attraction_ch(double);
hegyi@160
   207
hegyi@172
   208
  ///Indicates that propulsation factor is changed
hegyi@160
   209
  void propulsation_ch(double);
hegyi@160
   210
hegyi@172
   211
  ///Indicates that iteration number of redesign is changed
hegyi@160
   212
  void iteration_ch(int);
hegyi@172
   213
hegyi@172
   214
  ///\ref MapWin calls this function when it updates the maplist in comboboxes.
hegyi@172
   215
  void active_maps_needed();
hegyi@172
   216
hegyi@172
   217
private:
hegyi@172
   218
  ///Signal connection from \ref MapStorage to \ref MapWin
hegyi@172
   219
hegyi@172
   220
  ///If \ref MapWin is closed this connection has to be disconnected,
hegyi@172
   221
  ///therefore we have to store it.
hegyi@172
   222
  sigc::connection mapst2mapwin;
hegyi@96
   223
};
hegyi@96
   224
hegyi@96
   225
#endif //NBTAB_H