gui/gdc-broken_edge.cc
changeset 1829 183b4cbf9733
parent 1714 66c89fe52d4e
child 1831 75ab76fc4bf2
equal deleted inserted replaced
12:c1ea19ef1021 0:3a2d772af6b6
     1 #include "broken_edge.h"
     1 #include "graph_displayer_canvas.h"
     2 #include <cmath>
     2 #include <cmath>
     3 
     3 
     4 BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
     4 GraphDisplayerCanvas::BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
     5 {
     5 {
     6   my_points=new Gnome::Art::Point[3];
     6   my_points=new Gnome::Art::Point[3];
     7 
     7 
     8   arrow=new Gnome::Canvas::Polygon(g);
     8   arrow=new Gnome::Canvas::Polygon(g);
     9   *arrow << Gnome::Canvas::Properties::fill_color("red");
     9   *arrow << Gnome::Canvas::Properties::fill_color("red");
    10   arrow->signal_event().connect(sigc::mem_fun(*this, &BrokenEdge::edgeFormerEventHandler));
    10   arrow->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::BrokenEdge::edgeFormerEventHandler));
    11   arrow->lower_to_bottom();
    11   arrow->lower_to_bottom();
    12   setPoints(p);
    12   setPoints(p);
    13 }
    13 }
    14 
    14 
    15 BrokenEdge::~BrokenEdge()
    15 GraphDisplayerCanvas::BrokenEdge::~BrokenEdge()
    16 {
    16 {
    17   if(arrow)delete(arrow);
    17   if(arrow)delete(arrow);
    18 }
    18 }
    19 
    19 
    20 void BrokenEdge::setPoints(Gnome::Canvas::Points p, bool move)
    20 void GraphDisplayerCanvas::BrokenEdge::setPoints(Gnome::Canvas::Points p, bool move)
    21 {
    21 {
    22   bool set_arrow=false;
    22   bool set_arrow=false;
    23   //red arrow losts its position-right button
    23   //red arrow losts its position-right button
    24   if(!move)
    24   if(!move)
    25     {
    25     {
   153 
   153 
   154       arrow->property_points().set_value(arrow_points);
   154       arrow->property_points().set_value(arrow_points);
   155     }
   155     }
   156 }
   156 }
   157 
   157 
   158 bool BrokenEdge::edgeFormerEventHandler(GdkEvent* e)
   158 bool GraphDisplayerCanvas::BrokenEdge::edgeFormerEventHandler(GdkEvent* e)
   159 {
   159 {
   160   switch(e->type)
   160   switch(e->type)
   161     {
   161     {
   162     case GDK_BUTTON_PRESS:
   162     case GDK_BUTTON_PRESS:
   163       //we mark the location of the event to be able to calculate parameters of dragging
   163       //we mark the location of the event to be able to calculate parameters of dragging
   205     }
   205     }
   206 
   206 
   207   return true;
   207   return true;
   208 }
   208 }
   209 
   209 
   210 xy<double> BrokenEdge::getArrowPos()
   210 xy<double> GraphDisplayerCanvas::BrokenEdge::getArrowPos()
   211 {
   211 {
   212   xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
   212   xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
   213   return ret_val;
   213   return ret_val;
   214 }
   214 }