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