[Lemon-commits] [lemon_svn] hegyi: r1981 - hugo/trunk/gui
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:49:15 CET 2006
Author: hegyi
Date: Thu Jun 16 20:58:15 2005
New Revision: 1981
Modified:
hugo/trunk/gui/broken_edge.cc
hugo/trunk/gui/broken_edge.h
hugo/trunk/gui/graph_displayer_canvas.cc
hugo/trunk/gui/graph_displayer_canvas.h
Log:
First of all: revision 1981 is mine, what is important me because I was born in 1981. But what is new in my revision? If you drag nodes with left button, edge-breakpoints do not change location. If you drag nodes by right button, they do, they take up their base situation at the halfpoint of the edge.
Modified: hugo/trunk/gui/broken_edge.cc
==============================================================================
--- hugo/trunk/gui/broken_edge.cc (original)
+++ hugo/trunk/gui/broken_edge.cc Thu Jun 16 20:58:15 2005
@@ -17,25 +17,42 @@
if(arrow)delete(arrow);
}
-void BrokenEdge::set_points(Gnome::Canvas::Points p)
+void BrokenEdge::set_points(Gnome::Canvas::Points p, bool move)
{
bool set_arrow=false;
- if(p.size()==2)
+ if(!move)
{
- set_arrow=true;
- Gnome::Canvas::Points points_with_center;
- points_with_center.push_back(my_points[0]=p[0]);
- points_with_center.push_back(my_points[1]=Gnome::Art::Point( (p[0].get_x()+p[1].get_x())/2+0 , (p[0].get_y()+p[1].get_y())/2 )+0 );
- points_with_center.push_back(my_points[2]=p[1]);
- property_points().set_value(points_with_center);
- }
- if(p.size()==3)
+ if(p.size()==2)
+ {
+ set_arrow=true;
+ Gnome::Canvas::Points points_with_center;
+ points_with_center.push_back(my_points[0]=p[0]);
+ points_with_center.push_back(my_points[1]=Gnome::Art::Point( (p[0].get_x()+p[1].get_x())/2+0 , (p[0].get_y()+p[1].get_y())/2 )+0 );
+ points_with_center.push_back(my_points[2]=p[1]);
+ property_points().set_value(points_with_center);
+ }
+ if(p.size()==3)
+ {
+ set_arrow=true;
+ property_points().set_value(p);
+ for(int i=0;i<3;i++)
+ {
+ my_points[i]=p[i];
+ }
+ }
+ }
+ else
{
- set_arrow=true;
- property_points().set_value(p);
- for(int i=0;i<3;i++)
+ if(p.size()==2)
{
- my_points[i]=p[i];
+ Gnome::Canvas::Points points;
+ my_points[0]=p[0];
+ my_points[2]=p[1];
+ for(int i=0;i<3;i++)
+ {
+ points.push_back(my_points[i]);
+ }
+ property_points().set_value(points);
}
}
Modified: hugo/trunk/gui/broken_edge.h
==============================================================================
--- hugo/trunk/gui/broken_edge.h (original)
+++ hugo/trunk/gui/broken_edge.h Thu Jun 16 20:58:15 2005
@@ -24,7 +24,7 @@
public:
BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points);
~BrokenEdge();
- void set_points(Gnome::Canvas::Points);
+ void set_points(Gnome::Canvas::Points, bool move=false);
};
Modified: hugo/trunk/gui/graph_displayer_canvas.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.cc (original)
+++ hugo/trunk/gui/graph_displayer_canvas.cc Thu Jun 16 20:58:15 2005
@@ -2,7 +2,7 @@
#include <broken_edge.h>
#include <math.h>
-GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(false),active_item(NULL),target_item(NULL)
+GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL)
{
actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false);
@@ -181,10 +181,10 @@
clicked_x=e->button.x;
clicked_y=e->button.y;
active_item=(get_item_at(e->button.x, e->button.y));
- isbutton=true;
+ isbutton=1;
break;
case GDK_BUTTON_RELEASE:
- isbutton=false;
+ isbutton=0;
active_item=NULL;
updateScrollRegion();
break;
@@ -350,10 +350,18 @@
active_node=i;
}
}
- isbutton=true;
+ switch(e->button.button)
+ {
+ case 3:
+ isbutton=3;
+ break;
+ default:
+ isbutton=1;
+ break;
+ }
break;
case GDK_BUTTON_RELEASE:
- isbutton=false;
+ isbutton=0;
active_item=NULL;
active_node=INVALID;
updateScrollRegion();
@@ -376,47 +384,61 @@
clicked_y=e->motion.y;
//all the edges connected to the moved point has to be redrawn
- EdgeIt e;
+ EdgeIt ei;
- g.firstOut(e,active_node);
+ g.firstOut(ei,active_node);
- for(;e!=INVALID;g.nextOut(e))
+ for(;ei!=INVALID;g.nextOut(ei))
{
Gnome::Canvas::Points coos;
double x1, x2, y1, y2;
- nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2);
+ nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2);
coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
- nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2);
+ nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2);
coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
- edgesmap[e]->set_points(coos);
+ if(isbutton==3)
+ {
+ edgesmap[ei]->set_points(coos);
+ }
+ else
+ {
+ edgesmap[ei]->set_points(coos,true);
+ }
- edgesmap[e]->get_bounds(x1, y1, x2, y2);
+ edgesmap[ei]->get_bounds(x1, y1, x2, y2);
- edgetextmap[e]->property_x().set_value((x1+x2)/2);
- edgetextmap[e]->property_y().set_value((y1+y2)/2);
+ edgetextmap[ei]->property_x().set_value((x1+x2)/2);
+ edgetextmap[ei]->property_y().set_value((y1+y2)/2);
}
- g.firstIn(e,active_node);
- for(;e!=INVALID;g.nextIn(e))
+ g.firstIn(ei,active_node);
+ for(;ei!=INVALID;g.nextIn(ei))
{
Gnome::Canvas::Points coos;
double x1, x2, y1, y2;
- nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2);
+ nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2);
coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
- nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2);
+ nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2);
coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
- edgesmap[e]->set_points(coos);
+ if(isbutton==3)
+ {
+ edgesmap[ei]->set_points(coos);
+ }
+ else
+ {
+ edgesmap[ei]->set_points(coos,true);
+ }
- edgesmap[e]->get_bounds(x1, y1, x2, y2);
+ edgesmap[ei]->get_bounds(x1, y1, x2, y2);
- edgetextmap[e]->property_x().set_value((x1+x2)/2);
- edgetextmap[e]->property_y().set_value((y1+y2)/2);
+ edgetextmap[ei]->property_x().set_value((x1+x2)/2);
+ edgetextmap[ei]->property_y().set_value((y1+y2)/2);
}
}
default: break;
@@ -432,7 +454,7 @@
//draw the new node in red at the clicked place
case GDK_BUTTON_PRESS:
- isbutton=true;
+ isbutton=1;
active_node=NodeIt(g,g.addNode());
@@ -460,7 +482,7 @@
//finalize the new node
case GDK_BUTTON_RELEASE:
- isbutton=false;
+ isbutton=0;
*active_item << Gnome::Canvas::Properties::fill_color("blue");
active_item=NULL;
active_node=INVALID;
@@ -499,7 +521,7 @@
if(active_node!=INVALID)
{
*(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red");
- isbutton=true;
+ isbutton=1;
}
//clicked item was not a node. It could be e.g. edge.
else
@@ -564,7 +586,7 @@
}
break;
case GDK_BUTTON_RELEASE:
- isbutton=false;
+ isbutton=0;
//we clear settings in two cases
//1: the edge is ready (target_item has valid value)
//2: the edge creation is cancelled with right button
Modified: hugo/trunk/gui/graph_displayer_canvas.h
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.h (original)
+++ hugo/trunk/gui/graph_displayer_canvas.h Thu Jun 16 20:58:15 2005
@@ -96,7 +96,7 @@
MapStorage mapstorage;
///Indicates whether the button of mouse is pressed or not
- bool isbutton;
+ int isbutton;
///At this location was the mousebutton pressed.
///It helps to calculate the distance of dragging.
More information about the Lemon-commits
mailing list