COIN-OR::LEMON - Graph Library

Changeset 154:65c1b103443d in glemon-0.x


Ignore:
Timestamp:
09/25/06 17:30:04 (18 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@2958
Message:

Node view

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas-node.cc

    r96 r154  
    1717          double v=fabs((*actual_map)[i]);
    1818          int w;
    19           if(min==max)
    20             {
    21               w=(int)(node_property_defaults[N_RADIUS]);
    22             }
    23           else
    24             {
    25               w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
     19          if(autoscale)
     20            {
     21              if(min==max)
     22                {
     23                  w=(int)(node_property_defaults[N_RADIUS]);
     24                }
     25              else
     26                {
     27                  w=(int)(radius_min+(v-min)/(max-min)*(radius_max-radius_min));
     28                }
     29            }
     30          else
     31            {
     32              w=5+(int)(v/radius_unit);
    2633            }
    2734          if(w>=0)
     
    4249    {
    4350      //I think only new nodes use this case
    44 //       int w=(int)(*actual_map)[node];
     51      //that has no own value, only the default one
     52      //int w=(int)(*actual_map)[node];
    4553      int w=(int)(node_property_defaults[N_RADIUS]);
    4654      if(w>=0)
  • graph_displayer_canvas.cc

    r151 r154  
    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(""), mytab(mainw)
     8  edgemap_to_edit(""), autoscale(true), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw)
    99{
    1010  //base event handler is move tool
     
    227227  }
    228228}
     229
     230void GraphDisplayerCanvas::setNodeView(bool autoscale_p, double min_p, double max_p, double unit_p)
     231{
     232  autoscale=autoscale_p;
     233  radius_min=min_p;
     234  radius_max=max_p;
     235  radius_unit=unit_p;
     236  propertyChange(false, N_RADIUS);
     237}
     238
     239void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, double& min_p, double& max_p, double& unit_p)
     240{
     241  autoscale_p=autoscale;
     242  min_p=radius_min;
     243  max_p=radius_max;
     244  unit_p=radius_unit;
     245}
  • graph_displayer_canvas.h

    r151 r154  
    287287  int getActualTool();
    288288
     289  ///Sets node representation settings
     290  void setNodeView(bool, double, double, double);
     291
     292  ///Gets node representation settings
     293  void getNodeView(bool &, double&, double&, double&);
     294
    289295  ///draws the graph
    290296
     
    378384  static const int zoom_step = 5;
    379385
     386  ///Is node radius autoscaled
     387  bool autoscale;
     388 
     389  ///Minimum node radius
     390  double radius_min;
     391
     392  ///Maximum node radius
     393  double radius_max;
     394
     395  ///Node radius unit
     396  double radius_unit;
     397
    380398private:
    381399
  • main_win.cc

    r149 r154  
    1212  set_title ("no file");
    1313  set_default_size(WIN_WIDTH,WIN_HEIGHT);
    14   add(vbox);
     14  //add(vbox);
     15  add(table);
    1516
    1617  // custom icons for the toolbar
     
    186187  Gtk::Widget* menubar = uim->get_widget("/MenuBar");
    187188  if (menubar){
    188     vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
     189    //vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
     190    table.attach(*menubar, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
    189191  }
    190192
     
    193195  {
    194196    static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
    195     vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
     197    //hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET);
     198
     199    table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
     200
    196201  }
     202
     203  auto_scale= new Gtk::CheckButton("Autoscale");
     204  auto_scale->set_active(false);
     205  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
     210  table2.attach(*auto_scale, 0,2,0,1);
     211 
     212  Gtk::Label * unit_label= new Gtk::Label("Unit:");
     213  table2.attach(*unit_label, 2,3,0,1);
     214 
     215  Gtk::Adjustment * adjustment_unit=new Gtk::Adjustment(20, 5, 200, 5, 10);
     216
     217  radius_unit = new Gtk::SpinButton(*adjustment_unit, 5,0);
     218  radius_unit->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
     219  table2.attach(*radius_unit, 3,4,0,1);
     220
     221  Gtk::Label * min_label= new Gtk::Label("Min:");
     222  table2.attach(*min_label, 0,1,1,2);
     223 
     224  Gtk::Adjustment * adjustment_min=new Gtk::Adjustment(20, 5, 200, 5, 10);
     225
     226  radius_min = new Gtk::SpinButton(*adjustment_min, 5,0);
     227  radius_min->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
     228  table2.attach(*radius_min, 1,2,1,2);
     229
     230  Gtk::Label * max_label= new Gtk::Label("Max:");
     231  table2.attach(*max_label, 2,3,1,2);
     232 
     233  Gtk::Adjustment * adjustment_max=new Gtk::Adjustment(20, 5, 200, 5, 10);
     234
     235  radius_max = new Gtk::SpinButton(*adjustment_max, 5,0);
     236  radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
     237  table2.attach(*radius_max, 3,4,1,2);
     238
     239  //vbox.pack_start(hbox, Gtk::PACK_SHRINK);
     240  table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
    197241
    198242  tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
     
    204248  active_tool = MOVE;
    205249
    206   vbox.pack_start(notebook);
     250  //vbox.pack_start(notebook);
     251  table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL);
    207252 
    208253  show_all_children();
     
    317362  tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
    318363  set_title(tabnames[active_tab]);
     364  bool autoscale;
     365  double min;
     366  double max;
     367  double unit;
     368  tabs[active_tab]->getNodeView(autoscale, min, max, unit);
     369  radius_min->set_value(min);
     370  radius_max->set_value(max);
     371  radius_unit->set_value(unit);
     372  auto_scale->set_active(autoscale);
     373
    319374}
    320375
     
    478533  nmw->run();
    479534}
     535
     536
     537void MainWin::nodeViewChanged()
     538{
     539  double min=radius_min->get_value();
     540  double max=radius_max->get_value();
     541  double unit=radius_unit->get_value();
     542  bool autoscale=auto_scale->get_active();
     543  tabs[active_tab]->setNodeView(autoscale, min, max, unit);
     544}
  • main_win.h

    r119 r154  
    2121{
    2222  ///Container in which the menus and the notebook is.
    23   Gtk::VBox vbox;
     23  //Gtk::VBox vbox;
     24  Gtk::Table table;
     25  Gtk::Table table2;
     26
     27  ///Container in which the toolbar and the node parametrizer is.
     28  Gtk::HBox hbox;
     29
     30  ///Should nodes be autoscaled or not?
     31  Gtk::CheckButton * auto_scale;
     32
     33  ///Minimum and maximum node radius entry
     34  Gtk::SpinButton * radius_min, * radius_max, * radius_unit;
    2435
    2536  ///The notebook that has tabs (\ref NoteBookTab) with different graphs.
     
    222233  ///updates the title of window to the actually selected \ref NoteBookTab.
    223234  virtual void onChangeTab(GtkNotebookPage*, guint);
     235
     236  virtual void nodeViewChanged();
    224237};
    225238
  • nbtab.cc

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

    r121 r154  
    157157  ///\ref mapwin.
    158158  void closeMapWin();
     159
     160  ///Sets node representation settings
     161  void setNodeView(bool, double, double, double);
     162
     163  ///Gets node representation settings
     164  void getNodeView(bool &, double&, double&, double&);
    159165};
    160166
Note: See TracChangeset for help on using the changeset viewer.