COIN-OR::LEMON - Graph Library

Changeset 177:40f3006fba2e in glemon-0.x


Ignore:
Timestamp:
10/30/06 15:57:48 (18 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@3032
Message:

Redesign parameters can now be saved and loaded.

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • design_win.cc

    r174 r177  
    9090  Gtk::Window::set_title("Design Setup - "+tabname);
    9191}
     92
     93void DesignWin::set_data(double attr, double propuls, int it)
     94{
     95  attraction->set_value(attr);
     96  propulsation->set_value(propuls);
     97  iteration->set_value(it);
     98}
  • design_win.h

    r174 r177  
    6464
    6565  void set_title(std::string);
     66
     67  void set_data(double, double, int);
    6668};
    6769#endif //DESWIN_H
  • graph_displayer_canvas.cc

    r174 r177  
    2626  isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
    2727  edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
    28   iterations(20), attraction(0.05), propulsation(40000), was_redesigned(false), is_drawn(false), mytab(mainw)
     28  was_redesigned(false), is_drawn(false), mytab(mainw)
    2929{
    3030  //base event handler is move tool
     
    305305      was_redesigned=true;
    306306    }
    307  
     307
     308  double attraction;
     309  double propulsation;
     310  int iterations;
     311
     312  (mytab.mapstorage).get_design_data(attraction, propulsation, iterations);
    308313
    309314  //iteration counter
     
    394399}
    395400
    396 void GraphDisplayerCanvas::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p)
    397 {
    398   attraction_p=attraction;
    399   propulsation_p=propulsation;
    400   iterations_p=iterations;
    401 }
    402 
    403 void GraphDisplayerCanvas::set_attraction(double attraction_p)
    404 {
    405   attraction=attraction_p;
    406 }
    407 
    408 void GraphDisplayerCanvas::set_propulsation(double propulsation_p)
    409 {
    410   propulsation=propulsation_p;
    411 }
    412 
    413 void GraphDisplayerCanvas::set_iteration(int iterations_p)
    414 {
    415   iterations=iterations_p;
    416 }
    417 
  • graph_displayer_canvas.h

    r174 r177  
    337337  void reDesignGraph();
    338338
    339   void get_design_data(double &, double &, int &);
    340   void set_attraction(double);
    341   void set_propulsation(double);
    342   void set_iteration(int);
    343 
    344339  ///Show whether the graph is already drawn.
    345340  bool is_drawn;
     
    429424  double edge_width;
    430425
    431   ///Iteration number during graph design
    432   int iterations;
    433 
    434   ///Attraction factor during graph design
    435   double attraction;
    436 
    437   ///Propulsation factor during graph design
    438   double propulsation;
    439 
    440426  ///Was redesign run on this graph already?
    441427  ///
  • gui_reader.cc

    r176 r177  
    6161      mapstorage->changeActiveMap(true, i, em[i]);
    6262    }
     63
     64  double attraction;
     65  double propulsation;
     66  int iteration;
     67
     68  x("redesign-attraction", attraction);
     69  x("redesign-propulsation", propulsation);
     70  x("redesign-iteration", iteration);
     71
     72  mapstorage->set_attraction(attraction);
     73  mapstorage->set_propulsation(propulsation);
     74  mapstorage->set_iteration(iteration);
     75
     76  mapstorage->redesign_data_changed();
    6377}
    6478
  • gui_writer.cc

    r174 r177  
    5252    }
    5353  x("active_edgemaps", em);
     54
     55  double attraction;
     56  double propulsation;
     57  int iteration;
     58
     59  mapstorage->get_design_data(attraction, propulsation, iteration);
     60
     61  x("redesign-attraction", attraction);
     62  x("redesign-propulsation", propulsation);
     63  x("redesign-iteration", iteration);
    5464}
    5565
  • mapstorage.cc

    r174 r177  
    2424#include <gtkmm.h>
    2525
    26 MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false)
     26const double i_d=20;
     27const double a_d=0.05;
     28const double p_d=40000;
     29
     30MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false), iterations(i_d), attraction(a_d), propulsation(p_d)
    2731{
    2832  nodemap_storage["coordinates_x"] = new Graph::NodeMap<double>(graph);
     
    149153}
    150154
    151 MapStorage::Signal_Prop MapStorage::signal_prop_ch()
     155sigc::signal<void, bool, int> MapStorage::signal_prop_ch()
    152156{
    153157  return signal_prop;
     
    486490      signal_map_win.emit(true, i, "");
    487491    }
     492
     493  attraction=a_d;
     494  propulsation=p_d;
     495  iterations=i_d;
     496
     497  signal_design_win.emit(attraction, propulsation, iterations);
    488498}
    489499
     
    516526    }
    517527}
     528
     529void MapStorage::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p)
     530{
     531  attraction_p=attraction;
     532  propulsation_p=propulsation;
     533  iterations_p=iterations;
     534}
     535
     536void MapStorage::set_attraction(double attraction_p)
     537{
     538  attraction=attraction_p;
     539}
     540
     541void MapStorage::set_propulsation(double propulsation_p)
     542{
     543  propulsation=propulsation_p;
     544}
     545
     546void MapStorage::set_iteration(int iterations_p)
     547{
     548  iterations=iterations_p;
     549}
     550
     551void MapStorage::redesign_data_changed()
     552{
     553  signal_design_win.emit(attraction, propulsation, iterations);
     554}
  • mapstorage.h

    r174 r177  
    8383
    8484protected:
    85   /// type of the signal emitted if the visualization of the maps might have to be updated.
    86 
     85
     86  /// Signal emitted on any change made on map values
     87
     88  /// Signal emitted if the visualization of the maps might have to be updated.
    8789  /// bool shows us whether the changed map is edge or nodemap.
    8890  /// int tells us the refreshed property
    89   typedef sigc::signal<void, bool, int> Signal_Prop;
    90 
    91   /// Signal emitted on any change made on map values
    92   Signal_Prop signal_prop;
     91  sigc::signal<void, bool, int> signal_prop;
    9392
    9493  /// Signal emitted in the case of nodemap addition
     
    106105  /// Signal emitted, when entry in \ref MapWin should be changed.
    107106  sigc::signal<void, bool, int, std::string> signal_map_win;
     107
     108  /// Signal emitted, when entry in \ref DesignWin should be changed.
     109  sigc::signal<void, double, double, int> signal_design_win;
     110
     111  ///Iteration number during graph design
     112  int iterations;
     113
     114  ///Attraction factor during graph design
     115  double attraction;
     116
     117  ///Propulsation factor during graph design
     118  double propulsation;
    108119
    109120public:
     
    153164
    154165  ///returns \ref signal_prop to be able to connect functions to it
    155   Signal_Prop signal_prop_ch();
     166  sigc::signal<void, bool, int> signal_prop_ch();
    156167
    157168  ///returns \ref signal_node_map to be able to connect functions to it
     
    163174  ///returns \ref signal_map_win to be able to connect functions to it
    164175  sigc::signal<void, bool, int, std::string> signal_map_win_ch(){return signal_map_win;};
     176
     177  ///returns \ref signal_design_win to be able to connect functions to it
     178  sigc::signal<void, double, double, int> signal_design_win_ch(){return signal_design_win;};
    165179
    166180  ///Adds given map to storage.
     
    262276
    263277  void ArrowPosReadOK();
     278
     279  void get_design_data(double &, double &, int &);
     280  void set_attraction(double);
     281  void set_propulsation(double);
     282  void set_iteration(int);
     283
     284  void redesign_data_changed();
    264285};
    265286
  • nbtab.cc

    r174 r177  
    236236      double attraction, propulsation;
    237237      int iterations;
    238       gd_canvas->get_design_data(attraction, propulsation, iterations);
     238      mapstorage.get_design_data(attraction, propulsation, iterations);
    239239      designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations, *this);
    240240
    241       designwin->signal_attraction().connect(sigc::mem_fun(*this, &NoteBookTab::attraction_ch));
    242       designwin->signal_propulsation().connect(sigc::mem_fun(*this, &NoteBookTab::propulsation_ch));
    243       designwin->signal_iteration().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::set_iteration));
     241      designwin->signal_attraction().connect(sigc::mem_fun(mapstorage, &MapStorage::set_attraction));
     242      designwin->signal_propulsation().connect(sigc::mem_fun(mapstorage, &MapStorage::set_propulsation));
     243      designwin->signal_iteration().connect(sigc::mem_fun(mapstorage, &MapStorage::set_iteration));
    244244      designwin->close_run().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::reDesignGraph));
    245245
    246246      designwin->signal_delete_event().connect(sigc::mem_fun(*this, &NoteBookTab::closeDesignWin));
     247
     248      mapst2designwin=mapstorage.signal_design_win_ch().connect(sigc::mem_fun(*designwin, &DesignWin::set_data));
    247249
    248250      designwin->show();
     
    263265    {
    264266      designwinexists=false;
     267      mapst2designwin.disconnect();
    265268      delete designwin;
    266269    }
     
    287290}
    288291
    289 void NoteBookTab::attraction_ch(double v)
    290 {
    291   gd_canvas->set_attraction(v);
    292 }
    293 
    294 void NoteBookTab::propulsation_ch(double v)
    295 {
    296   gd_canvas->set_propulsation(v);
    297 }
    298 
    299 void NoteBookTab::iteration_ch(int v)
    300 {
    301   gd_canvas->set_iteration(v);
    302 }
    303 
    304292void NoteBookTab::active_maps_needed()
    305293{
  • nbtab.h

    r174 r177  
    203203  void reDesignGraph();
    204204
    205   ///Indicates that attraction factor is changed
    206   void attraction_ch(double);
    207 
    208   ///Indicates that propulsation factor is changed
    209   void propulsation_ch(double);
    210 
    211   ///Indicates that iteration number of redesign is changed
    212   void iteration_ch(int);
    213 
    214205  ///\ref MapWin calls this function when it updates the maplist in comboboxes.
    215206  void active_maps_needed();
     
    221212  ///therefore we have to store it.
    222213  sigc::connection mapst2mapwin;
     214
     215  ///Signal connection from \ref MapStorage to \ref DesignWin
     216
     217  ///If \ref DesignWin is closed this connection has to be disconnected,
     218  ///therefore we have to store it.
     219  sigc::connection mapst2designwin;
    223220};
    224221
Note: See TracChangeset for help on using the changeset viewer.