COIN-OR::LEMON - Graph Library

Changeset 157:7e6ad28aeb9e in glemon-0.x


Ignore:
Timestamp:
10/02/06 20:52:00 (18 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@2970
Message:

View settings also for edges.

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas-edge.cc

    r147 r157  
    22#include <cmath>
    33
     4const int minimum_edge_width=2;
    45
    56int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
     
    2526              w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
    2627            }
     28          if(zoomtrack)
     29            {
     30              double actual_ppu=get_pixels_per_unit();
     31              w=(int)(w/actual_ppu*fixed_zoom_factor);
     32            }
    2733          edgesmap[i]->setLineWidth(w);
    2834        }
     
    5561          double v=fabs((*actual_map)[i]);
    5662          int w;
    57           if(min==max)
    58             {
    59               w=(int)(edge_property_defaults[E_WIDTH]);
    60             }
    61           else
    62             {
    63               w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
     63          if(autoscale)
     64            {
     65              if(min==max)
     66                {
     67                  w=(int)(edge_property_defaults[E_WIDTH]);
     68                }
     69              else
     70                {
     71                  w=(int)(minimum_edge_width+(v-min)/(max-min)*(edge_width-minimum_edge_width));
     72                }
     73            }
     74          else
     75            {
     76              w=(int)(v*edge_width);
     77            }
     78          if(w<minimum_edge_width)
     79            {
     80              w=minimum_edge_width;
     81            }
     82          if(zoomtrack)
     83            {
     84              double actual_ppu=get_pixels_per_unit();
     85              w=(int)(w/actual_ppu*fixed_zoom_factor);
    6486            }
    6587          edgesmap[i]->setLineWidth(w);
  • graph_displayer_canvas-node.cc

    r156 r157  
    22#include <cmath>
    33
    4 const int minimum_node_radius=0;
     4const int minimum_node_radius=5;
    55
    66int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
     
    2626              else
    2727                {
    28                   w=(int)(minimum_node_radius+(v-min)/(max-min)*(radius_max-minimum_node_radius));
     28                  w=(int)(minimum_node_radius+(v-min)/(max-min)*(radius_size-minimum_node_radius));
    2929                }
    3030            }
    3131          else
    3232            {
    33               w=(int)(v*radius_max);
    34             }
    35 
    36           if(w<5)
    37             {
    38               w=5;
     33              w=(int)(v*radius_size);
     34            }
     35
     36          if(w<minimum_node_radius)
     37            {
     38              w=minimum_node_radius;
    3939            }
    4040
  • graph_displayer_canvas-zoom.cc

    r156 r157  
    99    {
    1010      propertyChange(false, N_RADIUS);
     11      propertyChange(true, E_WIDTH);
    1112    }
    1213}
     
    1819  if(zoomtrack)
    1920    {
     21      propertyChange(true, E_WIDTH);
    2022      propertyChange(false, N_RADIUS);
    2123    }
     
    4345  if(zoomtrack)
    4446    {
     47      propertyChange(true, E_WIDTH);
    4548      propertyChange(false, N_RADIUS);
    4649    }
     
    5457  if(zoomtrack)
    5558    {
     59      propertyChange(true, E_WIDTH);
    5660      propertyChange(false, N_RADIUS);
    5761    }
  • graph_displayer_canvas.cc

    r156 r157  
    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), zoomtrack(false), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw)
     8  edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10), mytab(mainw)
    99{
    1010  //base event handler is move tool
     
    228228}
    229229
    230 void GraphDisplayerCanvas::setNodeView(bool autoscale_p, bool zoomtrack_p, double min_p, double max_p, double unit_p)
     230void GraphDisplayerCanvas::setView(bool autoscale_p, bool zoomtrack_p, double width_p, double radius_p)
    231231{
    232232  autoscale=autoscale_p;
    233   radius_min=min_p;
    234   radius_max=max_p;
    235   radius_unit=unit_p;
     233  edge_width=width_p;
     234  radius_size=radius_p;
    236235
    237236  if((!zoomtrack) && zoomtrack_p)
     
    243242
    244243  propertyChange(false, N_RADIUS);
    245 }
    246 
    247 void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, bool & zoomtrack_p, double& min_p, double& max_p, double& unit_p)
     244  propertyChange(true, E_WIDTH);
     245}
     246
     247void GraphDisplayerCanvas::getView(bool & autoscale_p, bool & zoomtrack_p, double& width_p, double& radius_p)
    248248{
    249249  autoscale_p=autoscale;
    250250  zoomtrack_p=zoomtrack;
    251   min_p=radius_min;
    252   max_p=radius_max;
    253   unit_p=radius_unit;
    254 }
     251  width_p=edge_width;
     252  radius_p=radius_size;
     253}
  • graph_displayer_canvas.h

    r156 r157  
    288288
    289289  ///Sets node representation settings
    290   void setNodeView(bool, bool, double, double, double);
     290  void setView(bool, bool, double, double);
    291291
    292292  ///Gets node representation settings
    293   void getNodeView(bool &, bool &, double&, double&, double&);
     293  void getView(bool &, bool &, double&, double&);
    294294
    295295  ///draws the graph
     
    393393  double fixed_zoom_factor;
    394394 
    395   ///Minimum node radius
    396   double radius_min;
    397 
    398   ///Maximum node radius
    399   double radius_max;
    400 
    401   ///Node radius unit
    402   double radius_unit;
     395  ///Node radius size
     396  double radius_size;
     397
     398  ///Edge width
     399  double edge_width;
    403400
    404401private:
  • main_win.cc

    r156 r157  
    209209  table2.attach(*auto_scale, 0,2,0,1);
    210210
    211   Gtk::Label * unit_label= new Gtk::Label("Unit:");
    212 //   table2.attach(*unit_label, 2,3,0,1);
     211  Gtk::Label * width_label= new Gtk::Label("Edge Width:");
     212  table2.attach(*width_label, 0,1,1,2);
    213213 
    214   Gtk::Adjustment * adjustment_unit=new Gtk::Adjustment(20, 5, 200, 5, 10);
    215 
    216   radius_unit = new Gtk::SpinButton(*adjustment_unit, 5,0);
    217   radius_unit->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    218 //   table2.attach(*radius_unit, 3,4,0,1);
    219 
    220   Gtk::Label * min_label= new Gtk::Label("Min:");
    221 //   table2.attach(*min_label, 0,1,1,2);
     214  Gtk::Adjustment * adjustment_width=new Gtk::Adjustment(20, 1, 200, 5, 10);
    222215 
    223   Gtk::Adjustment * adjustment_min=new Gtk::Adjustment(20, 5, 200, 5, 10);
    224 
    225   radius_min = new Gtk::SpinButton(*adjustment_min, 5,0);
    226   radius_min->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    227 //   table2.attach(*radius_min, 1,2,1,2);
    228 
    229   Gtk::Label * max_label= new Gtk::Label("Size:");
    230   table2.attach(*max_label, 2,3,1,2);
     216  edge_width = new Gtk::SpinButton(*adjustment_width, 5,0);
     217  edge_width->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
     218  table2.attach(*edge_width, 1,2,1,2);
     219
     220  Gtk::Label * radius_label= new Gtk::Label("Node Radius:");
     221  table2.attach(*radius_label, 2,3,1,2);
    231222 
    232   Gtk::Adjustment * adjustment_max=new Gtk::Adjustment(20, 0, 200, 5, 10);
    233 
    234   radius_max = new Gtk::SpinButton(*adjustment_max, 5,0);
    235   radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
    236   table2.attach(*radius_max, 3,4,1,2);
     223  Gtk::Adjustment * adjustment_radius=new Gtk::Adjustment(20, 0, 500, 5, 10);
     224
     225  radius_size = new Gtk::SpinButton(*adjustment_radius, 5,0);
     226  radius_size->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
     227  table2.attach(*radius_size, 3,4,1,2);
    237228
    238229  zoom_track = new Gtk::CheckButton("Zoom tracking");
     
    242233
    243234
    244   //vbox.pack_start(hbox, Gtk::PACK_SHRINK);
    245235  table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
    246236
     
    253243  active_tool = MOVE;
    254244
    255   //vbox.pack_start(notebook);
    256245  table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL);
    257246 
     
    369358  bool autoscale;
    370359  bool zoomtrack;
    371   double min;
    372   double max;
     360  double width;
     361  double radius;
    373362  double unit;
    374   tabs[active_tab]->getNodeView(autoscale, zoomtrack, min, max, unit);
    375   radius_min->set_value(min);
    376   radius_max->set_value(max);
    377   radius_unit->set_value(unit);
     363  tabs[active_tab]->getView(autoscale, zoomtrack, width, radius);
     364  edge_width->set_value(width);
     365  radius_size->set_value(radius);
    378366  zoom_track->set_active(zoomtrack);
    379367  auto_scale->set_active(autoscale);
     
    544532void MainWin::nodeViewChanged()
    545533{
    546   double min=radius_min->get_value();
    547   double max=radius_max->get_value();
    548   double unit=radius_unit->get_value();
     534  double width=edge_width->get_value();
     535  double radius=radius_size->get_value();
     536  double unit;
    549537  bool zoomtrack=zoom_track->get_active();
    550538  bool autoscale=auto_scale->get_active();
    551   tabs[active_tab]->setNodeView(autoscale, zoomtrack, min, max, unit);
    552 }
     539  tabs[active_tab]->setView(autoscale, zoomtrack, width, radius);
     540}
  • main_win.h

    r156 r157  
    3535
    3636  ///Minimum and maximum node radius entry
    37   Gtk::SpinButton * radius_min, * radius_max, * radius_unit;
     37  Gtk::SpinButton * radius_size, * edge_width;
    3838
    3939  ///The notebook that has tabs (\ref NoteBookTab) with different graphs.
  • nbtab.cc

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

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