COIN-OR::LEMON - Graph Library

Changeset 1505:7121597da9ba in lemon-0.x


Ignore:
Timestamp:
06/17/05 19:08:45 (19 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1986
Message:

Previous commit was also mine, but I forgot to say, that it was my younger brother's birthyear. From this commit texts of activated maps move together with red arrows.

Location:
gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gui/broken_edge.cc

    r1504 r1505  
    11#include <broken_edge.h>
    2 #include <lemon/xy.h>
    32#include <math.h>
    43
     
    113112      if(gdc.get_actual_tool()!=CREATE_NODE)
    114113        {
     114          gdc.toggle_edge_activity(this, true);
    115115          clicked_x=e->button.x;
    116116          clicked_y=e->button.y;
     
    119119      break;
    120120    case GDK_BUTTON_RELEASE:
    121       isbutton=false;
     121      if(gdc.get_actual_tool()!=CREATE_NODE)
     122        {
     123          gdc.toggle_edge_activity(this, false);
     124          isbutton=false;
     125        }
    122126      break;
    123127    case GDK_MOTION_NOTIFY:
     
    140144
    141145          set_points(points_new);
     146          gdc.text_reposition(xy<double>(my_points[1].get_x(),my_points[1].get_y()));
    142147
    143148          clicked_x=e->motion.x;
     
    150155  return true;
    151156}
     157
     158xy<double> BrokenEdge::get_arrow_pos()
     159{
     160  xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
     161  return ret_val;
     162}
  • gui/broken_edge.h

    r1501 r1505  
    1010#include <libgnomecanvasmm/polygon.h>
    1111#include <graph_displayer_canvas.h>
     12#include <lemon/xy.h>
    1213
    1314class BrokenEdge : public Gnome::Canvas::Line
     
    3132  ~BrokenEdge();
    3233  void set_points(Gnome::Canvas::Points, bool move=false);
     34  xy<double> get_arrow_pos();
    3335};
    3436
  • gui/graph_displayer_canvas.cc

    r1501 r1505  
    3131    //initializing edge-text as well, to empty string
    3232
    33     double x1, x2, y1, y2;
    34     edgesmap[i]->get_bounds(x1, y1, x2, y2);
    35    
    36     edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph,(x1+x2)/2, (y1+y2)/2, "");
     33    xy<double> text_pos=edgesmap[i]->get_arrow_pos();
     34    text_pos+=(xy<double>(10,10));
     35
     36    edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
    3737    edgetextmap[i]->property_fill_color().set_value("black");
    3838  }
     
    174174};
    175175
     176//Deprecated
    176177bool GraphDisplayerCanvas::event_handler(GdkEvent* e, Node n)
    177178{
     
    425426              }
    426427
    427             edgesmap[ei]->get_bounds(x1, y1, x2, y2);
    428 
    429             edgetextmap[ei]->property_x().set_value((x1+x2)/2);
    430             edgetextmap[ei]->property_y().set_value((y1+y2)/2);
     428            xy<double> text_pos=edgesmap[ei]->get_arrow_pos();
     429            text_pos+=(xy<double>(10,10));
     430            edgetextmap[ei]->property_x().set_value(text_pos.x);
     431            edgetextmap[ei]->property_y().set_value(text_pos.y);
    431432        }
    432433
     
    452453              }
    453454
    454             edgesmap[ei]->get_bounds(x1, y1, x2, y2);
    455 
    456             edgetextmap[ei]->property_x().set_value((x1+x2)/2);
    457             edgetextmap[ei]->property_y().set_value((y1+y2)/2);
     455            xy<double> text_pos=edgesmap[ei]->get_arrow_pos();
     456            text_pos+=(xy<double>(10,10));
     457            edgetextmap[ei]->property_x().set_value(text_pos.x);
     458            edgetextmap[ei]->property_y().set_value(text_pos.y);
    458459        }
    459460      }
     
    590591
    591592                  //initializing edge-text as well, to empty string
    592                   edgesmap[active_edge]->get_bounds(x1, y1, x2, y2);
    593                   edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,(x1+x2)/2, (y1+y2)/2, "");
     593                  xy<double> text_pos=edgesmap[active_edge]->get_arrow_pos();
     594                  text_pos+=(xy<double>(10,10));
     595
     596                  edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
    594597                  edgetextmap[active_edge]->property_fill_color().set_value("black");
    595598                }
     
    739742}
    740743
     744void GraphDisplayerCanvas::text_reposition(xy<double> new_place)
     745{
     746  new_place+=(xy<double>(10,10));
     747  edgetextmap[active_edge]->property_x().set_value(new_place.x);
     748  edgetextmap[active_edge]->property_y().set_value(new_place.y);
     749}
     750
     751void GraphDisplayerCanvas::toggle_edge_activity(BrokenEdge* active_bre, bool on)
     752{
     753  if(on)
     754    {
     755      if(active_edge!=INVALID)
     756        {
     757          std::cout << "ERROR!!!! Valid edge found!" << std::endl;
     758        }
     759      else
     760        {
     761          for (EdgeIt i(g); i!=INVALID; ++i)
     762            {
     763              if(edgesmap[i]==active_bre)
     764                {
     765                  active_edge=i;
     766                }
     767            }
     768        }
     769    }
     770  else
     771    {
     772      if(active_edge!=INVALID)
     773        {
     774          active_edge=INVALID;
     775        }
     776      else
     777        {
     778          std::cout << "ERROR!!!! Invalid edge found!" << std::endl;
     779        }
     780    }
     781
     782}
  • gui/graph_displayer_canvas.h

    r1501 r1505  
    5757  ///reaction of any action happened in the territory
    5858  ///of the canvas
     59  ///DEPRECATED!!!!
    5960  bool event_handler(GdkEvent* e, Node n);
    6061
     
    7475  ///event handler for the case when eraser-tool is active
    7576  bool edge_map_edit_event_handler(GdkEvent*);
     77
     78public:
     79  ///Moves the text to new place
     80  void text_reposition(xy<double>);
     81  ///Activates an edge belonging to a BrokenEdge
     82  void toggle_edge_activity(BrokenEdge*, bool);
    7683
    7784public:
Note: See TracChangeset for help on using the changeset viewer.