algobox.h
changeset 1 67188bd752db
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/algobox.h	Mon Jul 07 08:10:39 2008 -0500
     1.3 @@ -0,0 +1,189 @@
     1.4 +/* -*- C++ -*-
     1.5 + *
     1.6 + * This file is a part of LEMON, a generic C++ optimization library
     1.7 + *
     1.8 + * Copyright (C) 2003-2006
     1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11 + *
    1.12 + * Permission to use, modify and distribute this software is granted
    1.13 + * provided that this copyright notice appears in all copies. For
    1.14 + * precise terms see the accompanying LICENSE file.
    1.15 + *
    1.16 + * This software is provided "AS IS" with no warranty of any kind,
    1.17 + * express or implied, and with no claim as to its suitability for any
    1.18 + * purpose.
    1.19 + *
    1.20 + */
    1.21 +
    1.22 +#ifndef ALGOBOX_H
    1.23 +#define ALGOBOX_H
    1.24 +
    1.25 +class MapStorage;
    1.26 +class MapSelector;
    1.27 +
    1.28 +#include <all_include.h>
    1.29 +#include <libgnomecanvasmm.h>
    1.30 +#include <libgnomecanvasmm/polygon.h>
    1.31 +#include "map_value.h"
    1.32 +
    1.33 +///Ancestor class of algorithm digraphical interface classes.
    1.34 +
    1.35 +///It also demonstrates, how should an algorithm digraphical interface
    1.36 +///work. Children of this class have the same functions and attributes,
    1.37 +///therefore with all of them can the holder \ref AlgoWin communicate
    1.38 +///in the same way.
    1.39 +///
    1.40 +///IMPORTANT! In a child class only the following tasks are to do:
    1.41 +///
    1.42 +///-call \ref init function with correct parameters from correctly parametrized constructor
    1.43 +///
    1.44 +///-implement \ref build_box function
    1.45 +///
    1.46 +///-implement \ref run function
    1.47 +///
    1.48 +///because all other thing is automatically done in \ref init function!
    1.49 +
    1.50 +class AlgoBox : public Gtk::VBox
    1.51 +{
    1.52 +  ///Signal emitted in case of need for list of maps.
    1.53 +
    1.54 +  ///If the user has selected different tab to work on
    1.55 +  ///new maps are selected as well. These new maps should be
    1.56 +  ///provided for \ref AlgoBox. To get these maps, \ref AlgoBox
    1.57 +  ///emits this signal.
    1.58 +  sigc::signal<void, std::string> signal_maplist_need;
    1.59 +
    1.60 +  ///Signal emitted in case of need for \ref NewMapWin.
    1.61 +
    1.62 +  ///If user wants to create a new for an input, or output
    1.63 +  ///it can let \ref NewMapWin popped up from here as well.
    1.64 +  ///In that case will be this signal emitted.
    1.65 +  sigc::signal<void, std::string, bool> signal_newmapwin_need;
    1.66 +
    1.67 +  ///Signal emitted when maplists are updated after tab change
    1.68 +  sigc::signal<void> signal_maplist_updated;
    1.69 +
    1.70 +
    1.71 +protected:
    1.72 +  ///Holder of tabnames.
    1.73 +  Gtk::ComboBoxText tabcbt;
    1.74 +
    1.75 +  ///Holder of widgets, in which nodemaps can be selected to work on.
    1.76 +  std::vector<MapSelector *> nodemapcbts;
    1.77 +
    1.78 +  ///Holder of widgets, in which arcmaps can be selected to work on.
    1.79 +  std::vector<MapSelector *> arcmapcbts;
    1.80 +
    1.81 +  ///Maps of selected tabs.
    1.82 +  MapStorage * mapstorage;
    1.83 +
    1.84 +public:
    1.85 +  ///Empty constructor called by children.
    1.86 +  AlgoBox(){};
    1.87 +
    1.88 +  ///Constructor
    1.89 +
    1.90 +  ///Calls \ref init function
    1.91 +  ///with the provided parameters. \ref init function
    1.92 +  ///is needed, because it is virtual, therefore the
    1.93 +  ///functions of the proper class will be called when
    1.94 +  ///running.
    1.95 +  ///\param tablist list of tabs in \ref MainWin
    1.96 +  AlgoBox(std::vector<std::string> tablist);
    1.97 +
    1.98 +  ///Initiates \ref AlgoBox.
    1.99 +
   1.100 +  ///Creates the digraphical interface for the realized algorithm, initiates variables, connects signals.
   1.101 +  ///
   1.102 +  ///List of tabs in \ref MainWin is required, but no one
   1.103 +  ///will be selected automatically. Every other
   1.104 +  ///entry field remains empty (unselected), until a \ref NoteBookTab
   1.105 +  ///is selected.
   1.106 +  ///
   1.107 +  ///It also have to bind all the signals to the correct place.
   1.108 +  ///This function is virtual, in all type of children of
   1.109 +  ///\ref AlgoBox the correct function willbe called.
   1.110 +  ///
   1.111 +  ///Therefore it is IMPORTANT that only \ref run and \ref build_box
   1.112 +  ///has to be implemented in children of \ref AlgoBox, every other
   1.113 +  ///thing will automatically work properly by the help of this
   1.114 +  ///function that must be called in constructor of child!!!
   1.115 +  virtual void init(std::vector<std::string>);
   1.116 +
   1.117 +  ///Signal emitted, when selected tab changes, and new list of maps required.
   1.118 +  sigc::signal<void, std::string> signal_maplist_needed();
   1.119 +
   1.120 +  ///Emitted if user wants to create a new map for inpuit or output.
   1.121 +  sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
   1.122 +
   1.123 +  sigc::signal<void> signal_upon_maplist_updated(){return signal_maplist_updated;};
   1.124 +
   1.125 +  ///Emits signal that requires list of maps for the recently selected \ref NoteBookTab.
   1.126 +  void emit_tab_change();
   1.127 +
   1.128 +  ///Interface, through which \ref AlgoBox can be notified about tab addition, deletion in \ref MainWin
   1.129 +
   1.130 +  ///\param tl list
   1.131 +  ///of new tab state.
   1.132 +  void update_tablist( std::vector< std::string > tl );
   1.133 +
   1.134 +  ///Interface, through which \ref AlgoBox can get the maps of the recently selected \ref NoteBookTab
   1.135 +
   1.136 +  ///\param ms the maps
   1.137 +  ///of the recently selected \ref NoteBookTab
   1.138 +  void update_maplist( MapStorage * ms);
   1.139 +
   1.140 +  ///Interface, through which \ref AlgoBox can be notified about nodemap addition.
   1.141 +
   1.142 +  ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
   1.143 +  ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
   1.144 +  ///in \ref nodemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
   1.145 +  void nodemaplist_changed(std::string, MapValue::Type);
   1.146 +
   1.147 +  ///Interface, through which \ref AlgoBox can be notified about arcmap addition.
   1.148 +
   1.149 +  ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
   1.150 +  ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
   1.151 +  ///in \ref arcmapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
   1.152 +  void arcmaplist_changed(std::string, MapValue::Type);
   1.153 +
   1.154 +  ///Aid function to provide data for a given entry.
   1.155 +
   1.156 +  ///At the moment it is only used for updating info
   1.157 +  ///in \ref tabcbt. It clears it first, after that
   1.158 +  ///inserts the data got from caller, and if there
   1.159 +  ///was previously selected item it switches entry
   1.160 +  ///to that.
   1.161 +  ///\param tl list of entries (at the moment tabs in \ref MainWin)
   1.162 +  ///\param cbt the entry to update (at the moment only \ref tabcbt)
   1.163 +  void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText & cbt);
   1.164 +
   1.165 +  ///Runs the ralized algorithm.
   1.166 +
   1.167 +  ///Prepare the data for it
   1.168 +  ///and after that postprocess it if necessary.
   1.169 +  ///This is only a demo here, but in children it
   1.170 +  ///runs the algorithm really.
   1.171 +  virtual void run();
   1.172 +
   1.173 +  ///Creates the layout of the \ref AlgoBox
   1.174 +
   1.175 +  ///Place all the entries
   1.176 +  ///required. Run and close button is not
   1.177 +  ///its responsibility!
   1.178 +  virtual void build_box();
   1.179 +
   1.180 +  ///Emits \ref signal_newmapwin_need if user wants to create new input or output map.
   1.181 +
   1.182 +  ///Called in case of pressing \ref MapSelector::newbut.
   1.183 +  ///\param itisarc arc or nodemap is required.
   1.184 +  virtual void emit_new_map_signal(bool itisarc);
   1.185 +
   1.186 +  ///Aid function to make addition of \ref MapSelector easy in \ref build_box.
   1.187 +
   1.188 +  ///\param label label to show in \ref MapSelector
   1.189 +  ///\param itisarc whether arc or nodemaps stored in \ref MapSelector
   1.190 +  void addMapSelector(std::string label, bool itisarc, MapType type = ALL);
   1.191 +};
   1.192 +#endif //ALGOBOX_H