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