algobox.h
author hegyi
Fri, 13 Oct 2006 13:53:44 +0000
changeset 163 443bc769b344
parent 125 e8bf8bbcf75a
child 174 95872af46fc4
permissions -rw-r--r--
Dijkstra in GUI - and the body...
hegyi@103
     1
// -*- C++ -*- //
hegyi@103
     2
hegyi@103
     3
#ifndef ALGOBOX_H
hegyi@103
     4
#define ALGOBOX_H
hegyi@103
     5
hegyi@103
     6
class AlgoBox;
hegyi@103
     7
hegyi@103
     8
#include <all_include.h>
hegyi@108
     9
#include <mapstorage.h>
hegyi@114
    10
#include <mapselector.h>
hegyi@103
    11
#include <libgnomecanvasmm.h>
hegyi@103
    12
#include <libgnomecanvasmm/polygon.h>
hegyi@103
    13
hegyi@125
    14
///Ancestor class of algorithm graphical interface classes.
hegyi@125
    15
hegyi@125
    16
///It also demonstrates, how should an algorithm graphical interface
hegyi@125
    17
///work. Children of this class have the same functions and attributes,
hegyi@125
    18
///therefore with all of them can the holder \ref AlgoWin communicate
hegyi@125
    19
///in the same way.
hegyi@125
    20
///
hegyi@125
    21
///IMPORTANT! In a child class only the following tasks are to do:
hegyi@125
    22
///
hegyi@125
    23
///-call \ref init function with correct parameters from correctly parametrized constructor
hegyi@125
    24
///
hegyi@125
    25
///-implement \ref build_box function
hegyi@125
    26
///
hegyi@125
    27
///-implement \ref run function
hegyi@125
    28
///
hegyi@125
    29
///because all other thing is automatically done in \ref init function!
hegyi@125
    30
hegyi@103
    31
class AlgoBox : public Gtk::VBox
hegyi@103
    32
{
hegyi@125
    33
  ///Signal emitted in case of need for list of maps.
hegyi@125
    34
hegyi@125
    35
  ///If the user has selected different tab to work on
hegyi@125
    36
  ///new maps are selected as well. These new maps should be
hegyi@125
    37
  ///provided for \ref AlgoBox. To get these maps, \ref AlgoBox
hegyi@125
    38
  ///emits this signal.
hegyi@125
    39
  sigc::signal<void, std::string> signal_maplist_need;
hegyi@125
    40
hegyi@125
    41
  ///Signal emitted in case of need for \ref NewMapWin.
hegyi@125
    42
hegyi@125
    43
  ///If user wants to create a new for an input, or output
hegyi@125
    44
  ///it can let \ref NewMapWin popped up from here as well.
hegyi@125
    45
  ///In that case will be this signal emitted.
hegyi@125
    46
  sigc::signal<void, std::string, bool> signal_newmapwin_need;
hegyi@106
    47
hegyi@162
    48
  ///Signal emitted when maplists are updated after tab change
hegyi@162
    49
  sigc::signal<void> signal_maplist_updated;
hegyi@162
    50
hegyi@162
    51
hegyi@106
    52
protected:
hegyi@125
    53
  ///Holder of tabnames.
hegyi@114
    54
  Gtk::ComboBoxText tabcbt;
hegyi@125
    55
hegyi@125
    56
  ///Holder of widgets, in which nodemaps can be selected to work on.
hegyi@114
    57
  std::vector<MapSelector *> nodemapcbts;
hegyi@125
    58
hegyi@125
    59
  ///Holder of widgets, in which edgemaps can be selected to work on.
hegyi@114
    60
  std::vector<MapSelector *> edgemapcbts;
hegyi@108
    61
hegyi@125
    62
  ///Maps of selected tabs.
hegyi@108
    63
  MapStorage * mapstorage;
hegyi@108
    64
hegyi@106
    65
public:
hegyi@125
    66
  ///Empty constructor called by children.
hegyi@106
    67
  AlgoBox(){};
hegyi@103
    68
hegyi@125
    69
  ///Constructor
hegyi@125
    70
hegyi@125
    71
  ///Calls \ref init function
hegyi@125
    72
  ///with the provided parameters. \ref init function
hegyi@125
    73
  ///is needed, because it is virtual, therefore the
hegyi@125
    74
  ///functions of the proper class will be called when
hegyi@125
    75
  ///running.
hegyi@125
    76
  ///\param tablist list of tabs in \ref MainWin
hegyi@125
    77
  AlgoBox(std::vector<std::string> tablist);
hegyi@125
    78
hegyi@125
    79
  ///Initiates \ref AlgoBox.
hegyi@125
    80
hegyi@125
    81
  ///Creates the graphical interface for the realized algorithm, initiates variables, connects signals.
hegyi@125
    82
  ///
hegyi@125
    83
  ///List of tabs in \ref MainWin is required, but no one
hegyi@125
    84
  ///will be selected automatically. Every other
hegyi@125
    85
  ///entry field remains empty (unselected), until a \ref NoteBookTab
hegyi@125
    86
  ///is selected.
hegyi@125
    87
  ///
hegyi@125
    88
  ///It also have to bind all the signals to the correct place.
hegyi@125
    89
  ///This function is virtual, in all type of children of
hegyi@125
    90
  ///\ref AlgoBox the correct function willbe called.
hegyi@125
    91
  ///
hegyi@125
    92
  ///Therefore it is IMPORTANT that only \ref run and \ref build_box
hegyi@125
    93
  ///has to be implemented in children of \ref AlgoBox, every other
hegyi@125
    94
  ///thing will automatically work properly by the help of this
hegyi@125
    95
  ///function that must be called in constructor of child!!!
hegyi@108
    96
  virtual void init(std::vector<std::string>);
hegyi@103
    97
hegyi@125
    98
  ///Signal emitted, when selected tab changes, and new list of maps required.
hegyi@125
    99
  sigc::signal<void, std::string> signal_maplist_needed();
hegyi@125
   100
hegyi@125
   101
  ///Emitted if user wants to create a new map for inpuit or output.
hegyi@125
   102
  sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
hegyi@125
   103
hegyi@162
   104
  sigc::signal<void> signal_upon_maplist_updated(){return signal_maplist_updated;};
hegyi@162
   105
hegyi@125
   106
  ///Emits signal that requires list of maps for the recently selected \ref NoteBookTab.
hegyi@106
   107
  void emit_tab_change();
hegyi@103
   108
hegyi@125
   109
  ///Interface, through which \ref AlgoBox can be notified about tab addition, deletion in \ref MainWin
hegyi@125
   110
hegyi@125
   111
  ///\param tl list
hegyi@125
   112
  ///of new tab state.
hegyi@106
   113
  void update_tablist( std::vector< std::string > tl );
hegyi@108
   114
hegyi@125
   115
  ///Interface, through which \ref AlgoBox can get the maps of the recently selected \ref NoteBookTab
hegyi@125
   116
hegyi@125
   117
  ///\param ms the maps
hegyi@125
   118
  ///of the recently selected \ref NoteBookTab
hegyi@125
   119
  void update_maplist( MapStorage * ms);
hegyi@125
   120
hegyi@125
   121
  ///Interface, through which \ref AlgoBox can be notified about nodemap addition.
hegyi@125
   122
hegyi@125
   123
  ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
hegyi@125
   124
  ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
hegyi@125
   125
  ///in \ref nodemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
hegyi@108
   126
  void nodemaplist_changed(std::string);
hegyi@125
   127
hegyi@125
   128
  ///Interface, through which \ref AlgoBox can be notified about edgemap addition.
hegyi@125
   129
hegyi@125
   130
  ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
hegyi@125
   131
  ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
hegyi@125
   132
  ///in \ref edgemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
hegyi@108
   133
  void edgemaplist_changed(std::string);
hegyi@103
   134
hegyi@125
   135
  ///Aid function to provide data for a given entry.
hegyi@125
   136
hegyi@125
   137
  ///At the moment it is only used for updating info
hegyi@125
   138
  ///in \ref tabcbt. It clears it first, after that
hegyi@125
   139
  ///inserts the data got from caller, and if there
hegyi@125
   140
  ///was previously selected item it switches entry
hegyi@125
   141
  ///to that.
hegyi@125
   142
  ///\param tl list of entries (at the moment tabs in \ref MainWin)
hegyi@125
   143
  ///\param cbt the entry to update (at the moment only \ref tabcbt)
hegyi@125
   144
  void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText & cbt);
hegyi@125
   145
hegyi@125
   146
  ///Runs the ralized algorithm.
hegyi@125
   147
hegyi@125
   148
  ///Prepare the data for it
hegyi@125
   149
  ///and after that postprocess it if necessary.
hegyi@125
   150
  ///This is only a demo here, but in children it
hegyi@125
   151
  ///runs the algorithm really.
hegyi@106
   152
  virtual void run();
hegyi@125
   153
hegyi@125
   154
  ///Creates the layout of the \ref AlgoBox
hegyi@125
   155
hegyi@125
   156
  ///Place all the entries
hegyi@125
   157
  ///required. Run and close button is not
hegyi@125
   158
  ///its responsibility!
hegyi@106
   159
  virtual void build_box();
hegyi@114
   160
hegyi@125
   161
  ///Emits \ref signal_newmapwin_need if user wants to create new input or output map.
hegyi@116
   162
hegyi@125
   163
  ///Called in case of pressing \ref MapSelector::newbut.
hegyi@125
   164
  ///\param itisedge edge or nodemap is required.
hegyi@125
   165
  virtual void emit_new_map_signal(bool itisedge);
hegyi@125
   166
hegyi@125
   167
  ///Aid function to make addition of \ref MapSelector easy in \ref build_box.
hegyi@125
   168
hegyi@125
   169
  ///\param label label to show in \ref MapSelector
hegyi@125
   170
  ///\param itisedge whether edge or nodemaps stored in \ref MapSelector
hegyi@125
   171
  void addMapSelector(std::string label, bool itisedge);
hegyi@103
   172
};
hegyi@103
   173
#endif //ALGOBOX_H