gui/algowin.h
author deba
Thu, 30 Mar 2006 09:36:33 +0000
changeset 2021 11455e986b95
parent 1884 9c061834b33b
permissions -rw-r--r--
IncEdgeIt goes through on loop edges twice.
hegyi@1871
     1
// -*- C++ -*- //
hegyi@1871
     2
hegyi@1871
     3
#ifndef ALGOWIN_H
hegyi@1871
     4
#define ALGOWIN_H
hegyi@1871
     5
hegyi@1871
     6
class AlgoWin;
hegyi@1871
     7
hegyi@1871
     8
#include <all_include.h>
hegyi@1879
     9
//#include <mapstorage.h>
hegyi@1871
    10
#include <algobox.h>
hegyi@1871
    11
#include <libgnomecanvasmm.h>
hegyi@1871
    12
#include <libgnomecanvasmm/polygon.h>
hegyi@1871
    13
hegyi@1879
    14
class MapStorage;
hegyi@1879
    15
hegyi@1896
    16
///Algorithm identifiers.
hegyi@1876
    17
enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs;
hegyi@1871
    18
hegyi@1896
    19
///Window displaying graphical interface for different algorithms.
hegyi@1896
    20
hegyi@1896
    21
///This class displays a graphical interface to set up
hegyi@1896
    22
///and run different algorithms. Different algorithms need
hegyi@1896
    23
///different inputs, running methods, etc. Therefore
hegyi@1896
    24
///class \ref AlgoWin is only a holder of a base class, the so
hegyi@1896
    25
///called AlgoBox. \ref AlgoBox is the ancestor of other
hegyi@1896
    26
///classes. These child classes realize interfaces of different
hegyi@1896
    27
///algorithms, but as their common ancestor is \ref AlgoBox
hegyi@1896
    28
///the interface of them is the same. \ref AlgoWin communicates
hegyi@1896
    29
///with these classes through this common interface. But it the
hegyi@1896
    30
///real object to be placed in \ref AlgoWin depends on the algorithm
hegyi@1896
    31
///which the \ref AlgoWin actually has to display. It gets the
hegyi@1896
    32
///id of algorithm to display at initialization, and therefore it is
hegyi@1896
    33
///able to place in itself the requested child of \ref AlgoBox
hegyi@1896
    34
/// visualizing the appropriate algorithm.
hegyi@1876
    35
class AlgoWin : public Gtk::Window
hegyi@1871
    36
{
hegyi@1871
    37
private:
hegyi@1896
    38
  ///Algorithm specific part of \ref AlgoWin
hegyi@1871
    39
  AlgoBox * ab;
hegyi@1896
    40
hegyi@1896
    41
  ///Run button.
hegyi@1896
    42
hegyi@1896
    43
  ///If pressed, algorithm should run.
hegyi@1896
    44
  ///That is why common ancestor of different
hegyi@1896
    45
  ///algorithm realizer classes have to be. In case of
hegyi@1896
    46
  ///pressing run button a common method can be called.
hegyi@1876
    47
  Gtk::Button * runbutton;
hegyi@1896
    48
hegyi@1896
    49
  ///Close button. If pressed, \ref AlgoWin should close.
hegyi@1876
    50
  Gtk::Button * closebutton;
hegyi@1871
    51
hegyi@1871
    52
protected:
hegyi@1896
    53
  ///Signal emitted upon close of window
hegyi@1896
    54
hegyi@1896
    55
  ///It is necessary, because \ref MainWin have to
hegyi@1896
    56
  ///score the opened \ref AlgoWin s, to be able to communicate
hegyi@1896
    57
  ///with them: let them know about changement in tabs, maps, etc.
hegyi@1896
    58
  ///If \ref AlgoWin is closed, \ref MainWin has to deregistrate it.
hegyi@1896
    59
  ///Therefore signal contains address of emitter \ref AlgoWin.
hegyi@1896
    60
  sigc::signal<void, AlgoWin *> signal_closed;
hegyi@1896
    61
hegyi@1896
    62
  ///Signal indicating that informatino on certain maplist is required.
hegyi@1896
    63
hegyi@1896
    64
  ///It is just a forwarded signal from \ref AlgoBox, benefit of common ancestor
hegyi@1896
    65
  ///algorithm class. User can select the graph (the holder \ref NoteBookTab) on
hegyi@1896
    66
  ///which the algorithm should run. But different graphs (\ref NoteBookTab) have
hegyi@1896
    67
  ///different maps. If selected tab changes this signal is emitted by \ref AlgoBox,
hegyi@1896
    68
  ///caught and reemitted by \ref AlgoWin.
hegyi@1896
    69
  ///
hegyi@1896
    70
  ///Signal contains the address of \ref AlgoWin to let \ref MainWin know
hegyi@1896
    71
  ///where should the information needed forwarded, and the name of
hegyi@1896
    72
  ///\ref NoteBookTab, of which maps are inquired.
hegyi@1896
    73
  sigc::signal<void, AlgoWin *, std::string> signal_maplist_need;
hegyi@1896
    74
hegyi@1896
    75
  ///Signal that indicates that a \ref NewMapWin should be popped up.
hegyi@1896
    76
hegyi@1896
    77
  ///This is a forwarded signal. If \ref AlgoBox emits a signal
hegyi@1896
    78
  ///to let a \ref NewMapWin pop up, |ref AlgoWin catch and reemit it.
hegyi@1896
    79
  ///
hegyi@1896
    80
  ///Signal contains the name of \ref NoteBookTab, in which the new map
hegyi@1896
    81
  ///should be created and a boolean that indicates whether an edge or a
hegyi@1896
    82
  ///nodemap should be created.
hegyi@1896
    83
  sigc::signal<void, std::string, bool> signal_newmapwin_need;
hegyi@1871
    84
hegyi@1871
    85
public:
hegyi@1896
    86
  ///Close window if escape key is pressed.
hegyi@1876
    87
  bool closeIfEscapeIsPressed(GdkEventKey* e);
hegyi@1871
    88
hegyi@1896
    89
  ///Returns \ref signal_closed to be bindable somewhere.
hegyi@1876
    90
  sigc::signal<void, AlgoWin *> signal_closing();
hegyi@1896
    91
hegyi@1896
    92
  ///Returns \ref signal_maplist_need to be bindable somewhere.
hegyi@1876
    93
  sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed();
hegyi@1871
    94
hegyi@1896
    95
  ///Returns \ref signal_newmapwin_need to be bindable somewhere.
hegyi@1896
    96
  sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
hegyi@1896
    97
hegyi@1896
    98
  ///Forwards signal emitted by \ref AlgoBox, in which it indicates changement in selection of tabs.
hegyi@1876
    99
  void emit_tab_change(std::string);
hegyi@1896
   100
hegyi@1896
   101
  ///Forwards signal emitted by \ref AlgoBox, in which it indicates need for \ref NewMapWin.
hegyi@1884
   102
  void emit_new_map_signal(std::string tabname, bool itisedge){signal_newmapwin_need.emit(tabname, itisedge);};
hegyi@1871
   103
hegyi@1896
   104
  ///Constructor
hegyi@1876
   105
hegyi@1896
   106
  ///It builds the window according to the information provided
hegyi@1896
   107
  ///by the creator. It needs the identifier of the algorithm
hegyi@1896
   108
  ///to visualize, and a list of name of \ref NoteBookTab s that can
hegyi@1896
   109
  ///be found in \ref MainWin.
hegyi@1896
   110
  ///\param algoid identifier of algorithm to show
hegyi@1896
   111
  ///\param tablist list of tabs in \ref MainWin
hegyi@1896
   112
  AlgoWin(int algoid, std::vector<std::string> tablist);
hegyi@1896
   113
hegyi@1896
   114
  ///Forwards list of \ref NoteBookTabs toward \ref AlgoBox
hegyi@1896
   115
hegyi@1896
   116
  ///In case of changement in tabs in \ref MainWin
hegyi@1896
   117
  ///\ref MainWin automatically updates tablist in
hegyi@1896
   118
  ///\ref AlgoWin s.
hegyi@1876
   119
  void update_tablist(std::vector<std::string> tabnames);
hegyi@1896
   120
hegyi@1896
   121
  ///Forwards list of requested maps toward \ref AlgoBox
hegyi@1896
   122
hegyi@1896
   123
  ///Upon catching the signal in which \ref AlgoBox requests
hegyi@1896
   124
  ///list of maps \ref MainWin responds
hegyi@1896
   125
  ///through this function.
hegyi@1879
   126
  void update_maplist(MapStorage *);
hegyi@1876
   127
hegyi@1896
   128
  ///Called when window is closing.
hegyi@1896
   129
hegyi@1896
   130
  ///\ref AlgoWin has to be deregistrated in \ref MainWin
hegyi@1896
   131
  ///thereforeit emits signal \ref signal_closed.
hegyi@1876
   132
  void on_hide();
hegyi@1871
   133
};
hegyi@1871
   134
#endif //ALGOWIN_H