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