[Lemon-commits] [lemon_svn] hegyi: r1982 - hugo/trunk/gui
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:49:15 CET 2006
Author: hegyi
Date: Fri Jun 17 14:25:53 2005
New Revision: 1982
Modified:
hugo/trunk/gui/all_include.h
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:
Very small bug is corrected: if node creator tool is active, the small red arrows won't move, if you click on them and if you drag the newly created node... 'was hard to notice it :-)
Modified: hugo/trunk/gui/all_include.h
==============================================================================
--- hugo/trunk/gui/all_include.h (original)
+++ hugo/trunk/gui/all_include.h Fri Jun 17 14:25:53 2005
@@ -17,7 +17,7 @@
#include <lemon/xy.h>
enum {WIDTH, COLOR, TEXT, PROPERTY_NUM}; // edge properties;
-enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, TOOL_NUM}; // tools;
+enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, TOOL_NUM}; // tools;
#define RANGE 3
#define WIN_WIDTH 900
#define WIN_HEIGHT 600
Modified: hugo/trunk/gui/broken_edge.cc
==============================================================================
--- hugo/trunk/gui/broken_edge.cc (original)
+++ hugo/trunk/gui/broken_edge.cc Fri Jun 17 14:25:53 2005
@@ -2,7 +2,7 @@
#include <lemon/xy.h>
#include <math.h>
-BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p) : Line(g), isbutton(false)
+BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
{
my_points=new Gnome::Art::Point[3];
@@ -110,9 +110,12 @@
{
case GDK_BUTTON_PRESS:
//we mark the location of the event to be able to calculate parameters of dragging
- clicked_x=e->button.x;
- clicked_y=e->button.y;
- isbutton=true;
+ if(gdc.get_actual_tool()!=CREATE_NODE)
+ {
+ clicked_x=e->button.x;
+ clicked_y=e->button.y;
+ isbutton=true;
+ }
break;
case GDK_BUTTON_RELEASE:
isbutton=false;
Modified: hugo/trunk/gui/broken_edge.h
==============================================================================
--- hugo/trunk/gui/broken_edge.h (original)
+++ hugo/trunk/gui/broken_edge.h Fri Jun 17 14:25:53 2005
@@ -3,15 +3,20 @@
#ifndef BROKEN_EDGE_H
#define BROKEN_EDGE_H
+class BrokenEdge;
+
#include <all_include.h>
#include <libgnomecanvasmm.h>
#include <libgnomecanvasmm/polygon.h>
+#include <graph_displayer_canvas.h>
class BrokenEdge : public Gnome::Canvas::Line
{
+ GraphDisplayerCanvas & gdc;
Gnome::Canvas::Polygon * arrow;
Gnome::Art::Point * my_points;
+
///Indicates whether the button of mouse is pressed or not
bool isbutton;
@@ -22,7 +27,7 @@
///event handler for forming edges
bool edge_former_event_handler(GdkEvent*);
public:
- BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points);
+ BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points, GraphDisplayerCanvas &);
~BrokenEdge();
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 Fri Jun 17 14:25:53 2005
@@ -5,7 +5,8 @@
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);
+ actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_node_event_handler), false);
+ actual_tool=CREATE_NODE;
active_node=INVALID;
active_edge=INVALID;
@@ -23,7 +24,7 @@
coos.push_back(Gnome::Art::Point(cm[g.source(i)].x,cm[g.source(i)].y));
coos.push_back(Gnome::Art::Point(cm[g.target(i)].x,cm[g.target(i)].y));
- edgesmap[i]=new BrokenEdge(displayed_graph, coos);
+ edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this);
*(edgesmap[i]) << Gnome::Canvas::Properties::fill_color("green");
edgesmap[i]->property_width_pixels().set_value(10);
@@ -309,6 +310,16 @@
{
actual_handler.disconnect();
+ if(actual_tool==CREATE_EDGE)
+ {
+ GdkEvent * generated=new GdkEvent();
+ generated->type=GDK_BUTTON_RELEASE;
+ generated->button.button=3;
+ create_edge_event_handler(generated);
+ }
+
+ actual_tool=newtool;
+
switch(newtool)
{
case MOVE:
@@ -333,6 +344,11 @@
}
}
+int GraphDisplayerCanvas::get_actual_tool()
+{
+ return actual_tool;
+}
+
bool GraphDisplayerCanvas::move_event_handler(GdkEvent* e)
{
switch(e->type)
@@ -564,7 +580,7 @@
coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
//drawing new edge
- edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos);
+ edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this);
*(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green");
edgesmap[active_edge]->property_width_pixels().set_value(10);
Modified: hugo/trunk/gui/graph_displayer_canvas.h
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.h (original)
+++ hugo/trunk/gui/graph_displayer_canvas.h Fri Jun 17 14:25:53 2005
@@ -3,6 +3,8 @@
#ifndef GRAPH_DISPLAYER_CANVAS_H
#define GRAPH_DISPLAYER_CANVAS_H
+class GraphDisplayerCanvas;
+
#include <all_include.h>
#include <mapstorage.h>
#include <broken_edge.h>
@@ -69,7 +71,14 @@
bool create_edge_event_handler(GdkEvent*);
///event handler for the case when eraser-tool is active
bool eraser_event_handler(GdkEvent*);
+ ///event handler for the case when eraser-tool is active
+ bool edge_map_edit_event_handler(GdkEvent*);
+
+public:
+ ///\return the actual tool in hand
+ int get_actual_tool();
+private:
///Deletes the given element.
void delete_item(NodeIt);
///Deletes the given element.
@@ -77,6 +86,8 @@
///Deletes the given element.
void delete_item(Graph::Edge);
+private:
+
///The graph, on which we work
Graph g;
@@ -98,6 +109,9 @@
///Indicates whether the button of mouse is pressed or not
int isbutton;
+ ///Stores the actual tool in hand
+ int actual_tool;
+
///At this location was the mousebutton pressed.
///It helps to calculate the distance of dragging.
double clicked_x, clicked_y;
More information about the Lemon-commits
mailing list