View settings also for edges.
authorhegyi
Mon, 02 Oct 2006 18:52:00 +0000
changeset 1577e6ad28aeb9e
parent 156 c5cdf6690cdf
child 158 aa50a64b3a6e
View settings also for edges.
graph_displayer_canvas-edge.cc
graph_displayer_canvas-node.cc
graph_displayer_canvas-zoom.cc
graph_displayer_canvas.cc
graph_displayer_canvas.h
main_win.cc
main_win.h
nbtab.cc
nbtab.h
     1.1 --- a/graph_displayer_canvas-edge.cc	Thu Sep 28 14:32:40 2006 +0000
     1.2 +++ b/graph_displayer_canvas-edge.cc	Mon Oct 02 18:52:00 2006 +0000
     1.3 @@ -1,6 +1,7 @@
     1.4  #include "graph_displayer_canvas.h"
     1.5  #include <cmath>
     1.6  
     1.7 +const int minimum_edge_width=2;
     1.8  
     1.9  int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
    1.10  {
    1.11 @@ -24,6 +25,11 @@
    1.12  	    {
    1.13  	      w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
    1.14  	    }
    1.15 +	  if(zoomtrack)
    1.16 +	    {
    1.17 +	      double actual_ppu=get_pixels_per_unit();
    1.18 +	      w=(int)(w/actual_ppu*fixed_zoom_factor);
    1.19 +	    }
    1.20  	  edgesmap[i]->setLineWidth(w);
    1.21  	}
    1.22      }
    1.23 @@ -54,13 +60,29 @@
    1.24  	{
    1.25  	  double v=fabs((*actual_map)[i]);
    1.26  	  int w;
    1.27 -	  if(min==max)
    1.28 +	  if(autoscale)
    1.29  	    {
    1.30 -	      w=(int)(edge_property_defaults[E_WIDTH]);
    1.31 +	      if(min==max)
    1.32 +		{
    1.33 +		  w=(int)(edge_property_defaults[E_WIDTH]);
    1.34 +		}
    1.35 +	      else
    1.36 +		{
    1.37 +		  w=(int)(minimum_edge_width+(v-min)/(max-min)*(edge_width-minimum_edge_width));
    1.38 +		}
    1.39  	    }
    1.40  	  else
    1.41  	    {
    1.42 -	      w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
    1.43 +	      w=(int)(v*edge_width);
    1.44 +	    }
    1.45 +	  if(w<minimum_edge_width)
    1.46 +	    {
    1.47 +	      w=minimum_edge_width;
    1.48 +	    }
    1.49 +	  if(zoomtrack)
    1.50 +	    {
    1.51 +	      double actual_ppu=get_pixels_per_unit();
    1.52 +	      w=(int)(w/actual_ppu*fixed_zoom_factor);
    1.53  	    }
    1.54  	  edgesmap[i]->setLineWidth(w);
    1.55  	}
     2.1 --- a/graph_displayer_canvas-node.cc	Thu Sep 28 14:32:40 2006 +0000
     2.2 +++ b/graph_displayer_canvas-node.cc	Mon Oct 02 18:52:00 2006 +0000
     2.3 @@ -1,7 +1,7 @@
     2.4  #include "graph_displayer_canvas.h"
     2.5  #include <cmath>
     2.6  
     2.7 -const int minimum_node_radius=0;
     2.8 +const int minimum_node_radius=5;
     2.9  
    2.10  int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
    2.11  {
    2.12 @@ -25,17 +25,17 @@
    2.13  		}
    2.14  	      else
    2.15  		{
    2.16 -		  w=(int)(minimum_node_radius+(v-min)/(max-min)*(radius_max-minimum_node_radius));
    2.17 +		  w=(int)(minimum_node_radius+(v-min)/(max-min)*(radius_size-minimum_node_radius));
    2.18  		}
    2.19  	    }
    2.20  	  else
    2.21  	    {
    2.22 -	      w=(int)(v*radius_max);
    2.23 +	      w=(int)(v*radius_size);
    2.24  	    }
    2.25  
    2.26 -	  if(w<5)
    2.27 +	  if(w<minimum_node_radius)
    2.28  	    {
    2.29 -	      w=5;
    2.30 +	      w=minimum_node_radius;
    2.31  	    }
    2.32  
    2.33  	  if(zoomtrack)
     3.1 --- a/graph_displayer_canvas-zoom.cc	Thu Sep 28 14:32:40 2006 +0000
     3.2 +++ b/graph_displayer_canvas-zoom.cc	Mon Oct 02 18:52:00 2006 +0000
     3.3 @@ -8,6 +8,7 @@
     3.4    if(zoomtrack)
     3.5      {
     3.6        propertyChange(false, N_RADIUS);
     3.7 +      propertyChange(true, E_WIDTH);
     3.8      }
     3.9  }
    3.10  
    3.11 @@ -17,6 +18,7 @@
    3.12        (1.0 - (double) zoom_step / 100.0) * get_pixels_per_unit());
    3.13    if(zoomtrack)
    3.14      {
    3.15 +      propertyChange(true, E_WIDTH);
    3.16        propertyChange(false, N_RADIUS);
    3.17      }
    3.18  }
    3.19 @@ -42,6 +44,7 @@
    3.20  
    3.21    if(zoomtrack)
    3.22      {
    3.23 +      propertyChange(true, E_WIDTH);
    3.24        propertyChange(false, N_RADIUS);
    3.25      }
    3.26  }
    3.27 @@ -53,6 +56,7 @@
    3.28  
    3.29    if(zoomtrack)
    3.30      {
    3.31 +      propertyChange(true, E_WIDTH);
    3.32        propertyChange(false, N_RADIUS);
    3.33      }
    3.34  }
     4.1 --- a/graph_displayer_canvas.cc	Thu Sep 28 14:32:40 2006 +0000
     4.2 +++ b/graph_displayer_canvas.cc	Mon Oct 02 18:52:00 2006 +0000
     4.3 @@ -5,7 +5,7 @@
     4.4    nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
     4.5    nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
     4.6    isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
     4.7 -  edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw)
     4.8 +  edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10), mytab(mainw)
     4.9  {
    4.10    //base event handler is move tool
    4.11    actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    4.12 @@ -227,12 +227,11 @@
    4.13    }
    4.14  }
    4.15  
    4.16 -void GraphDisplayerCanvas::setNodeView(bool autoscale_p, bool zoomtrack_p, double min_p, double max_p, double unit_p)
    4.17 +void GraphDisplayerCanvas::setView(bool autoscale_p, bool zoomtrack_p, double width_p, double radius_p)
    4.18  {
    4.19    autoscale=autoscale_p;
    4.20 -  radius_min=min_p;
    4.21 -  radius_max=max_p;
    4.22 -  radius_unit=unit_p;
    4.23 +  edge_width=width_p;
    4.24 +  radius_size=radius_p;
    4.25  
    4.26    if((!zoomtrack) && zoomtrack_p)
    4.27      {
    4.28 @@ -242,13 +241,13 @@
    4.29    zoomtrack=zoomtrack_p;
    4.30  
    4.31    propertyChange(false, N_RADIUS);
    4.32 +  propertyChange(true, E_WIDTH);
    4.33  }
    4.34  
    4.35 -void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, bool & zoomtrack_p, double& min_p, double& max_p, double& unit_p)
    4.36 +void GraphDisplayerCanvas::getView(bool & autoscale_p, bool & zoomtrack_p, double& width_p, double& radius_p)
    4.37  {
    4.38    autoscale_p=autoscale;
    4.39    zoomtrack_p=zoomtrack;
    4.40 -  min_p=radius_min;
    4.41 -  max_p=radius_max;
    4.42 -  unit_p=radius_unit;
    4.43 +  width_p=edge_width;
    4.44 +  radius_p=radius_size;
    4.45  }
     5.1 --- a/graph_displayer_canvas.h	Thu Sep 28 14:32:40 2006 +0000
     5.2 +++ b/graph_displayer_canvas.h	Mon Oct 02 18:52:00 2006 +0000
     5.3 @@ -287,10 +287,10 @@
     5.4    int getActualTool();
     5.5  
     5.6    ///Sets node representation settings
     5.7 -  void setNodeView(bool, bool, double, double, double);
     5.8 +  void setView(bool, bool, double, double);
     5.9  
    5.10    ///Gets node representation settings
    5.11 -  void getNodeView(bool &, bool &, double&, double&, double&);
    5.12 +  void getView(bool &, bool &, double&, double&);
    5.13  
    5.14    ///draws the graph
    5.15  
    5.16 @@ -392,14 +392,11 @@
    5.17    ///to store the zoom factor when it was "fixed"
    5.18    double fixed_zoom_factor;
    5.19    
    5.20 -  ///Minimum node radius
    5.21 -  double radius_min;
    5.22 +  ///Node radius size
    5.23 +  double radius_size;
    5.24  
    5.25 -  ///Maximum node radius
    5.26 -  double radius_max;
    5.27 -
    5.28 -  ///Node radius unit
    5.29 -  double radius_unit;
    5.30 +  ///Edge width
    5.31 +  double edge_width;
    5.32  
    5.33  private:
    5.34  
     6.1 --- a/main_win.cc	Thu Sep 28 14:32:40 2006 +0000
     6.2 +++ b/main_win.cc	Mon Oct 02 18:52:00 2006 +0000
     6.3 @@ -208,32 +208,23 @@
     6.4    auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
     6.5    table2.attach(*auto_scale, 0,2,0,1);
     6.6  
     6.7 -  Gtk::Label * unit_label= new Gtk::Label("Unit:");
     6.8 -//   table2.attach(*unit_label, 2,3,0,1);
     6.9 +  Gtk::Label * width_label= new Gtk::Label("Edge Width:");
    6.10 +  table2.attach(*width_label, 0,1,1,2);
    6.11    
    6.12 -  Gtk::Adjustment * adjustment_unit=new Gtk::Adjustment(20, 5, 200, 5, 10);
    6.13 +  Gtk::Adjustment * adjustment_width=new Gtk::Adjustment(20, 1, 200, 5, 10);
    6.14 +  
    6.15 +  edge_width = new Gtk::SpinButton(*adjustment_width, 5,0);
    6.16 +  edge_width->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    6.17 +  table2.attach(*edge_width, 1,2,1,2);
    6.18  
    6.19 -  radius_unit = new Gtk::SpinButton(*adjustment_unit, 5,0);
    6.20 -  radius_unit->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    6.21 -//   table2.attach(*radius_unit, 3,4,0,1);
    6.22 +  Gtk::Label * radius_label= new Gtk::Label("Node Radius:");
    6.23 +  table2.attach(*radius_label, 2,3,1,2);
    6.24 +  
    6.25 +  Gtk::Adjustment * adjustment_radius=new Gtk::Adjustment(20, 0, 500, 5, 10);
    6.26  
    6.27 -  Gtk::Label * min_label= new Gtk::Label("Min:");
    6.28 -//   table2.attach(*min_label, 0,1,1,2);
    6.29 -  
    6.30 -  Gtk::Adjustment * adjustment_min=new Gtk::Adjustment(20, 5, 200, 5, 10);
    6.31 -
    6.32 -  radius_min = new Gtk::SpinButton(*adjustment_min, 5,0);
    6.33 -  radius_min->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    6.34 -//   table2.attach(*radius_min, 1,2,1,2);
    6.35 -
    6.36 -  Gtk::Label * max_label= new Gtk::Label("Size:");
    6.37 -  table2.attach(*max_label, 2,3,1,2);
    6.38 -  
    6.39 -  Gtk::Adjustment * adjustment_max=new Gtk::Adjustment(20, 0, 200, 5, 10);
    6.40 -
    6.41 -  radius_max = new Gtk::SpinButton(*adjustment_max, 5,0);
    6.42 -  radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    6.43 -  table2.attach(*radius_max, 3,4,1,2);
    6.44 +  radius_size = new Gtk::SpinButton(*adjustment_radius, 5,0);
    6.45 +  radius_size->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    6.46 +  table2.attach(*radius_size, 3,4,1,2);
    6.47  
    6.48    zoom_track = new Gtk::CheckButton("Zoom tracking");
    6.49    zoom_track->set_active(false);
    6.50 @@ -241,7 +232,6 @@
    6.51    table2.attach(*zoom_track, 2,4,0,1);
    6.52  
    6.53  
    6.54 -  //vbox.pack_start(hbox, Gtk::PACK_SHRINK);
    6.55    table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
    6.56  
    6.57    tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
    6.58 @@ -252,7 +242,6 @@
    6.59  
    6.60    active_tool = MOVE;
    6.61  
    6.62 -  //vbox.pack_start(notebook);
    6.63    table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL);
    6.64    
    6.65    show_all_children();
    6.66 @@ -368,13 +357,12 @@
    6.67    set_title(tabnames[active_tab]);
    6.68    bool autoscale;
    6.69    bool zoomtrack;
    6.70 -  double min;
    6.71 -  double max;
    6.72 +  double width;
    6.73 +  double radius;
    6.74    double unit;
    6.75 -  tabs[active_tab]->getNodeView(autoscale, zoomtrack, min, max, unit);
    6.76 -  radius_min->set_value(min);
    6.77 -  radius_max->set_value(max);
    6.78 -  radius_unit->set_value(unit);
    6.79 +  tabs[active_tab]->getView(autoscale, zoomtrack, width, radius);
    6.80 +  edge_width->set_value(width);
    6.81 +  radius_size->set_value(radius);
    6.82    zoom_track->set_active(zoomtrack);
    6.83    auto_scale->set_active(autoscale);
    6.84  
    6.85 @@ -543,10 +531,10 @@
    6.86  
    6.87  void MainWin::nodeViewChanged()
    6.88  {
    6.89 -  double min=radius_min->get_value();
    6.90 -  double max=radius_max->get_value();
    6.91 -  double unit=radius_unit->get_value();
    6.92 +  double width=edge_width->get_value();
    6.93 +  double radius=radius_size->get_value();
    6.94 +  double unit;
    6.95    bool zoomtrack=zoom_track->get_active();
    6.96    bool autoscale=auto_scale->get_active();
    6.97 -  tabs[active_tab]->setNodeView(autoscale, zoomtrack, min, max, unit);
    6.98 +  tabs[active_tab]->setView(autoscale, zoomtrack, width, radius);
    6.99  }
     7.1 --- a/main_win.h	Thu Sep 28 14:32:40 2006 +0000
     7.2 +++ b/main_win.h	Mon Oct 02 18:52:00 2006 +0000
     7.3 @@ -34,7 +34,7 @@
     7.4    Gtk::CheckButton * zoom_track;
     7.5  
     7.6    ///Minimum and maximum node radius entry
     7.7 -  Gtk::SpinButton * radius_min, * radius_max, * radius_unit;
     7.8 +  Gtk::SpinButton * radius_size, * edge_width;
     7.9  
    7.10    ///The notebook that has tabs (\ref NoteBookTab) with different graphs.
    7.11    Gtk::Notebook notebook;
     8.1 --- a/nbtab.cc	Thu Sep 28 14:32:40 2006 +0000
     8.2 +++ b/nbtab.cc	Mon Oct 02 18:52:00 2006 +0000
     8.3 @@ -218,12 +218,12 @@
     8.4    return signal_title;
     8.5  }
     8.6  
     8.7 -void NoteBookTab::setNodeView(bool autoscale, bool zoomtrack, double min, double max, double unit)
     8.8 +void NoteBookTab::setView(bool autoscale, bool zoomtrack, double width, double radius)
     8.9  {
    8.10 -  gd_canvas->setNodeView(autoscale, zoomtrack, min, max, unit);
    8.11 +  gd_canvas->setView(autoscale, zoomtrack, width, radius);
    8.12  }
    8.13  
    8.14 -void NoteBookTab::getNodeView(bool & autoscale, bool & zoomtrack, double& min, double& max, double& unit)
    8.15 +void NoteBookTab::getView(bool & autoscale, bool & zoomtrack, double& width, double& radius)
    8.16  {
    8.17 -  gd_canvas->getNodeView(autoscale, zoomtrack, min, max, unit);
    8.18 +  gd_canvas->getView(autoscale, zoomtrack, width, radius);
    8.19  }
     9.1 --- a/nbtab.h	Thu Sep 28 14:32:40 2006 +0000
     9.2 +++ b/nbtab.h	Mon Oct 02 18:52:00 2006 +0000
     9.3 @@ -158,10 +158,10 @@
     9.4    void closeMapWin();
     9.5  
     9.6    ///Sets node representation settings
     9.7 -  void setNodeView(bool, bool, double, double, double);
     9.8 +  void setView(bool, bool, double, double);
     9.9  
    9.10    ///Gets node representation settings
    9.11 -  void getNodeView(bool &, bool &, double&, double&, double&);
    9.12 +  void getView(bool &, bool &, double&, double&);
    9.13  };
    9.14  
    9.15  #endif //NBTAB_H