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