nbtab.h
author alpar
Fri, 13 Oct 2006 15:14:18 +0000
changeset 164 70e3c3646283
parent 157 7e6ad28aeb9e
child 172 fc1e478697d3
permissions -rw-r--r--
- Add missing repository files (AUTHORS COPYING NEWS README). They need to
be filled with info.
- RPM support
hegyi@96
     1
// -*- C++ -*- //
hegyi@96
     2
hegyi@96
     3
#ifndef NBTAB_H
hegyi@96
     4
#define NBTAB_H
hegyi@96
     5
hegyi@96
     6
class NoteBookTab;
hegyi@96
     7
hegyi@96
     8
#include "mapstorage.h"
hegyi@96
     9
#include "map_win.h"
hegyi@160
    10
#include "design_win.h"
hegyi@96
    11
#include "graph_displayer_canvas.h"
hegyi@96
    12
#include <libgnomecanvasmm.h>
hegyi@96
    13
#include <libgnomecanvasmm/polygon.h>
hegyi@96
    14
hegyi@121
    15
///One tab in the Notebook that is placed in the main window (\ref MainWin).
hegyi@121
    16
hegyi@121
    17
///One graph and all of its accessories like maps are assigned to one tab in the notebook.
hegyi@121
    18
///\ref NoteBookTab is responsible for the user defined display of the graph: view can be
hegyi@121
    19
///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
hegyi@121
    20
///view of graph. This is \ref Mapwin window.
hegyi@121
    21
///
hegyi@121
    22
///\ref NoteBookTab is also
hegyi@121
    23
///responsible for modify the graph if it is
hegyi@121
    24
///requested. Therefore it is responsible for translating user events to modifications to
hegyi@121
    25
///do on graph, like node/edge addition/deletion, map modification, addition and so on.
hegyi@121
    26
///
hegyi@121
    27
///To be able to solve these tasks the help of \ref MainWin is also needed, for example to
hegyi@121
    28
///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab.
hegyi@121
    29
///
hegyi@121
    30
///Some information in the other direction is needed as well: for example when new map creation is requested for this tab
hegyi@121
    31
///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals
hegyi@121
    32
///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary.
hegyi@96
    33
class NoteBookTab : public Gtk::VBox
hegyi@96
    34
{
hegyi@96
    35
public:
hegyi@121
    36
  
hegyi@121
    37
  ///Constructor of \ref NoteBookTab
hegyi@121
    38
hegyi@121
    39
  ///It initiates the \re GraphDisplayerCanvas, on which the graph will be drawn
hegyi@121
    40
  ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
hegyi@96
    41
  NoteBookTab();
hegyi@96
    42
  
hegyi@121
    43
  ///Maps assigned to the graph displayed in this \ref NoteBookTab of notebook.
hegyi@96
    44
  MapStorage mapstorage;
hegyi@96
    45
    
hegyi@121
    46
  ///Title changement indicator.
hegyi@121
    47
hegyi@121
    48
  ///If graph is loaded from disk or saved to disk or changed its name somehow
hegyi@121
    49
  ///this signal will be emit to let
hegyi@121
    50
  ///\ref MainWin know that it has to modify the title of the main window.
hegyi@121
    51
  ///It contains the new title.
hegyi@96
    52
  sigc::signal<void, std::string> signal_title;
hegyi@96
    53
hegyi@121
    54
  ///Returns \ref signal_title to be the caller able to connect it to a callback function.
hegyi@96
    55
  sigc::signal<void, std::string> signal_title_ch();
hegyi@96
    56
hegyi@121
    57
  ///Indicates that new map window should be popped up.
hegyi@121
    58
hegyi@121
    59
  ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
hegyi@121
    60
  ///The signal contains whether an edgemap or a nodemap should be popped up. \ref NewMapWin
hegyi@121
    61
  ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
hegyi@121
    62
  ///but for example \ref MainWin and \ref AlgoWin s as well.
hegyi@96
    63
  sigc::signal<void, NoteBookTab *, bool> signal_newmap;
hegyi@96
    64
hegyi@121
    65
  ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
hegyi@96
    66
  sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
hegyi@96
    67
hegyi@121
    68
  ///Loads the given file.
hegyi@121
    69
hegyi@121
    70
  ///The given file will be load in the \ref MapStorage and afeter that
hegyi@121
    71
  ///\ref GraphDisplayerCanvas will be requested to display the graph.
hegyi@121
    72
  ///\ref GraphDisplayer will get datas from the recently set \ref MapStorage.
hegyi@96
    73
  void readFile(const std::string &);
hegyi@96
    74
    
hegyi@96
    75
  ///The graph will be drawn on this \ref GraphDisplayerCanvas
hegyi@96
    76
  GraphDisplayerCanvas * gd_canvas;
hegyi@96
    77
hegyi@121
    78
  ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
hegyi@96
    79
  bool mapwinexists;
hegyi@96
    80
hegyi@160
    81
  ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
hegyi@160
    82
  bool designwinexists;
hegyi@160
    83
hegyi@121
    84
  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
hegyi@121
    85
hegyi@121
    86
  ///Only one of this window can be opened at the same time (\ref mapwinexists), 
hegyi@121
    87
  ///because there is no need for more, one per tab is enough.
hegyi@121
    88
  ///There won1t be benefit of more than one, but it would be
hegyi@121
    89
  ///more complicated to synchronize them.
hegyi@96
    90
  MapWin * mapwin;
hegyi@96
    91
    
hegyi@160
    92
  ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
hegyi@160
    93
hegyi@160
    94
  ///Only one of this window can be opened at the same time (\ref designwinexists), 
hegyi@160
    95
  ///because there is no need for more, one per tab is enough.
hegyi@160
    96
  ///There won't be benefit of more than one, but it would be
hegyi@160
    97
  ///more complicated to synchronize them.
hegyi@160
    98
  DesignWin * designwin;
hegyi@160
    99
hegyi@96
   100
public:
hegyi@96
   101
  ///Callback for 'FileNew' action.
hegyi@96
   102
  virtual void newFile();
hegyi@96
   103
  ///Callback for 'FileOpen' action.
hegyi@96
   104
  virtual void openFile();
hegyi@96
   105
  ///Callback for 'FileSave' action.
hegyi@96
   106
  virtual void saveFile();
hegyi@96
   107
  ///Callback for 'FileSaveAs' action.
hegyi@96
   108
  virtual void saveFileAs();
hegyi@96
   109
  ///Callback for 'Close' action.
hegyi@96
   110
  virtual void close();
hegyi@96
   111
hegyi@121
   112
  ///Handles changement of view of graph.
hegyi@96
   113
hegyi@121
   114
  ///If the user changes the map to show by a property to a nother in \ref MapWin,
hegyi@121
   115
  ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
hegyi@121
   116
  ///the new map to display by the changed property. After that \ref MapStorage will
hegyi@121
   117
  ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the
hegyi@121
   118
  ///appropriate parts of graph.
hegyi@121
   119
  ///\param itiesedge whether the changed property is edge property or node property
hegyi@121
   120
  ///\param prop id of property, see all_include.h
hegyi@121
   121
  ///\param mapname name of the recently selected map
hegyi@121
   122
  void propertyChange(bool itisedge, int prop, std::string mapname);
hegyi@96
   123
hegyi@121
   124
  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
hegyi@96
   125
hegyi@121
   126
  ///This function is called by \ref MapWin.
hegyi@121
   127
  ///\param itisedge whether the new map should be an edgemap or a nodemap.
hegyi@121
   128
  void popupNewMapWin(bool itisedge);
hegyi@121
   129
hegyi@121
   130
  ///Returns the actually selected edgemap to visualize by the given property.
hegyi@121
   131
hegyi@121
   132
  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
hegyi@121
   133
  ///\param prop property to inquire.
hegyi@121
   134
  std::string getActiveEdgeMap(int prop);
hegyi@121
   135
hegyi@121
   136
  ///Returns the actually selected nodemap to visualize by the given property.
hegyi@121
   137
hegyi@121
   138
  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
hegyi@121
   139
  ///\param prop property to inquire.
hegyi@121
   140
  std::string getActiveNodeMap(int prop);
hegyi@121
   141
hegyi@121
   142
  ///Registers recently created edgemap in \ref MapWin.
hegyi@121
   143
hegyi@121
   144
  ///After creation of new map \ref MapStorage emits a signal.
hegyi@121
   145
  ///This signal is bound to this callback function, that will call
hegyi@121
   146
  ///a function with the same name and same parameterin \ref MapWin.
hegyi@121
   147
  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
hegyi@121
   148
  ///\param mapname name of new map
hegyi@121
   149
  void registerNewEdgeMap(std::string mapname);
hegyi@121
   150
hegyi@121
   151
  ///Registers recently created nodemap in \ref MapWin.
hegyi@121
   152
hegyi@121
   153
  ///After creation of new map \ref MapStorage emits a signal.
hegyi@121
   154
  ///This signal is bound to this callback function, that will call
hegyi@121
   155
  ///a function with the same name and same parameter in \ref MapWin.
hegyi@121
   156
  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
hegyi@121
   157
  ///\param mapname name of new map
hegyi@121
   158
  void registerNewNodeMap(std::string mapname);
hegyi@121
   159
hegyi@121
   160
  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
hegyi@121
   161
  
hegyi@121
   162
  ///See also
hegyi@121
   163
  ///\ref mapwin.
hegyi@96
   164
  void createMapWin(std::string);
hegyi@121
   165
hegyi@160
   166
  ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
hegyi@160
   167
  
hegyi@160
   168
  ///See also
hegyi@160
   169
  ///\ref mapwin.
hegyi@160
   170
  void createDesignWin(std::string);
hegyi@160
   171
hegyi@121
   172
  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
hegyi@121
   173
  
hegyi@121
   174
  ///See also
hegyi@121
   175
  ///\ref mapwin.
hegyi@96
   176
  void closeMapWin();
hegyi@154
   177
hegyi@160
   178
  bool closeDesignWin(GdkEventAny *);
hegyi@160
   179
hegyi@154
   180
  ///Sets node representation settings
hegyi@157
   181
  void setView(bool, bool, double, double);
hegyi@154
   182
hegyi@154
   183
  ///Gets node representation settings
hegyi@157
   184
  void getView(bool &, bool &, double&, double&);
hegyi@160
   185
hegyi@160
   186
  void reDesignGraph();
hegyi@160
   187
hegyi@160
   188
  void attraction_ch(double);
hegyi@160
   189
hegyi@160
   190
  void propulsation_ch(double);
hegyi@160
   191
hegyi@160
   192
  void iteration_ch(int);
hegyi@96
   193
};
hegyi@96
   194
hegyi@96
   195
#endif //NBTAB_H