COIN-OR::LEMON - Graph Library

Changeset 156:c5cdf6690cdf in glemon-0.x


Ignore:
Timestamp:
09/28/06 16:32:40 (18 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@2961
Message:

Zoom tracking of nodes is implemented and is switchable.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas-node.cc

    r155 r156  
    3737            {
    3838              w=5;
     39            }
     40
     41          if(zoomtrack)
     42            {
     43              double actual_ppu=get_pixels_per_unit();
     44              w=(int)(w/actual_ppu*fixed_zoom_factor);
    3945            }
    4046
     
    96102              w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
    97103            }
     104          if(zoomtrack)
     105            {
     106              double actual_ppu=get_pixels_per_unit();
     107              w=(int)(w/actual_ppu*fixed_zoom_factor);
     108            }
    98109          if(w>=0)
    99110            {
  • graph_displayer_canvas-zoom.cc

    r89 r156  
    66  set_pixels_per_unit(
    77      (1.0 + (double) zoom_step / 100.0) * get_pixels_per_unit());
     8  if(zoomtrack)
     9    {
     10      propertyChange(false, N_RADIUS);
     11    }
    812}
    913
     
    1216  set_pixels_per_unit(
    1317      (1.0 - (double) zoom_step / 100.0) * get_pixels_per_unit());
     18  if(zoomtrack)
     19    {
     20      propertyChange(false, N_RADIUS);
     21    }
    1422}
    1523
     
    3240  double ppu2 = (double) ah / fabs(y2 - y1);
    3341  set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
     42
     43  if(zoomtrack)
     44    {
     45      propertyChange(false, N_RADIUS);
     46    }
    3447}
    3548
     
    3851  updateScrollRegion();
    3952  set_pixels_per_unit(1.0);
     53
     54  if(zoomtrack)
     55    {
     56      propertyChange(false, N_RADIUS);
     57    }
    4058}
    4159
  • graph_displayer_canvas.cc

    r154 r156  
    66  nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
    77  isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
    8   edgemap_to_edit(""), autoscale(true), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw)
     8  edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw)
    99{
    1010  //base event handler is move tool
     
    228228}
    229229
    230 void GraphDisplayerCanvas::setNodeView(bool autoscale_p, double min_p, double max_p, double unit_p)
     230void GraphDisplayerCanvas::setNodeView(bool autoscale_p, bool zoomtrack_p, double min_p, double max_p, double unit_p)
    231231{
    232232  autoscale=autoscale_p;
     
    234234  radius_max=max_p;
    235235  radius_unit=unit_p;
     236
     237  if((!zoomtrack) && zoomtrack_p)
     238    {
     239      fixed_zoom_factor=get_pixels_per_unit();
     240    }
     241
     242  zoomtrack=zoomtrack_p;
     243
    236244  propertyChange(false, N_RADIUS);
    237245}
    238246
    239 void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, double& min_p, double& max_p, double& unit_p)
     247void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, bool & zoomtrack_p, double& min_p, double& max_p, double& unit_p)
    240248{
    241249  autoscale_p=autoscale;
     250  zoomtrack_p=zoomtrack;
    242251  min_p=radius_min;
    243252  max_p=radius_max;
  • graph_displayer_canvas.h

    r154 r156  
    288288
    289289  ///Sets node representation settings
    290   void setNodeView(bool, double, double, double);
     290  void setNodeView(bool, bool, double, double, double);
    291291
    292292  ///Gets node representation settings
    293   void getNodeView(bool &, double&, double&, double&);
     293  void getNodeView(bool &, bool &, double&, double&, double&);
    294294
    295295  ///draws the graph
     
    387387  bool autoscale;
    388388 
     389  ///Should we track zoomfactor changes
     390  bool zoomtrack;
     391
     392  ///to store the zoom factor when it was "fixed"
     393  double fixed_zoom_factor;
     394 
    389395  ///Minimum node radius
    390396  double radius_min;
  • main_win.cc

    r155 r156  
    200200
    201201  }
    202 
    203   auto_scale= new Gtk::CheckButton("Autoscale");
     202 
     203  table2.set_row_spacings(10);
     204  table2.set_col_spacings(5);
     205
     206  auto_scale = new Gtk::CheckButton("Autoscale");
    204207  auto_scale->set_active(false);
    205208  auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    206 
    207   table2.set_row_spacings(10);
    208   table2.set_col_spacings(5);
    209 
    210209  table2.attach(*auto_scale, 0,2,0,1);
    211  
     210
    212211  Gtk::Label * unit_label= new Gtk::Label("Unit:");
    213212//   table2.attach(*unit_label, 2,3,0,1);
     
    236235  radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    237236  table2.attach(*radius_max, 3,4,1,2);
     237
     238  zoom_track = new Gtk::CheckButton("Zoom tracking");
     239  zoom_track->set_active(false);
     240  zoom_track->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
     241  table2.attach(*zoom_track, 2,4,0,1);
     242
    238243
    239244  //vbox.pack_start(hbox, Gtk::PACK_SHRINK);
     
    363368  set_title(tabnames[active_tab]);
    364369  bool autoscale;
     370  bool zoomtrack;
    365371  double min;
    366372  double max;
    367373  double unit;
    368   tabs[active_tab]->getNodeView(autoscale, min, max, unit);
     374  tabs[active_tab]->getNodeView(autoscale, zoomtrack, min, max, unit);
    369375  radius_min->set_value(min);
    370376  radius_max->set_value(max);
    371377  radius_unit->set_value(unit);
     378  zoom_track->set_active(zoomtrack);
    372379  auto_scale->set_active(autoscale);
    373380
     
    540547  double max=radius_max->get_value();
    541548  double unit=radius_unit->get_value();
     549  bool zoomtrack=zoom_track->get_active();
    542550  bool autoscale=auto_scale->get_active();
    543   tabs[active_tab]->setNodeView(autoscale, min, max, unit);
    544 }
     551  tabs[active_tab]->setNodeView(autoscale, zoomtrack, min, max, unit);
     552}
  • main_win.h

    r154 r156  
    3030  ///Should nodes be autoscaled or not?
    3131  Gtk::CheckButton * auto_scale;
     32
     33  ///Should node size track zoom factor?
     34  Gtk::CheckButton * zoom_track;
    3235
    3336  ///Minimum and maximum node radius entry
  • nbtab.cc

    r154 r156  
    219219}
    220220
    221 void NoteBookTab::setNodeView(bool autoscale, double min, double max, double unit)
    222 {
    223   gd_canvas->setNodeView(autoscale, min, max, unit);
    224 }
    225 
    226 void NoteBookTab::getNodeView(bool & autoscale, double& min, double& max, double& unit)
    227 {
    228   gd_canvas->getNodeView(autoscale, min, max, unit);
    229 }
     221void NoteBookTab::setNodeView(bool autoscale, bool zoomtrack, double min, double max, double unit)
     222{
     223  gd_canvas->setNodeView(autoscale, zoomtrack, min, max, unit);
     224}
     225
     226void NoteBookTab::getNodeView(bool & autoscale, bool & zoomtrack, double& min, double& max, double& unit)
     227{
     228  gd_canvas->getNodeView(autoscale, zoomtrack, min, max, unit);
     229}
  • nbtab.h

    r154 r156  
    159159
    160160  ///Sets node representation settings
    161   void setNodeView(bool, double, double, double);
     161  void setNodeView(bool, bool, double, double, double);
    162162
    163163  ///Gets node representation settings
    164   void getNodeView(bool &, double&, double&, double&);
     164  void getNodeView(bool &, bool &, double&, double&, double&);
    165165};
    166166
Note: See TracChangeset for help on using the changeset viewer.