[Lemon-commits] ladanyi: r3371 - glemon/branches/akos
Lemon SVN
svn at lemon.cs.elte.hu
Thu Nov 8 18:19:05 CET 2007
Author: ladanyi
Date: Thu Nov 8 18:19:04 2007
New Revision: 3371
Modified:
glemon/branches/akos/graph_displayer_canvas-event.cc
glemon/branches/akos/graph_displayer_canvas.cc
glemon/branches/akos/graph_displayer_canvas.h
Log:
Ported r3150 from trunk.
Modified: glemon/branches/akos/graph_displayer_canvas-event.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas-event.cc (original)
+++ glemon/branches/akos/graph_displayer_canvas-event.cc Thu Nov 8 18:19:04 2007
@@ -95,6 +95,45 @@
return actual_tool;
}
+bool GraphDisplayerCanvas::scrollEventHandler(GdkEvent* e)
+{
+ bool handled=false;
+ if(e->type==GDK_SCROLL)
+ {
+
+ //pointer shows this win point before zoom
+ XY win_coord(((GdkEventScroll*)e)->x, ((GdkEventScroll*)e)->y);
+
+ //the original scroll settings
+ int scroll_offset_x, scroll_offset_y;
+ get_scroll_offsets(scroll_offset_x, scroll_offset_y);
+
+ //pointer shows this canvas point before zoom
+ XY canvas_coord;
+ window_to_world(win_coord.x, win_coord.y, canvas_coord.x, canvas_coord.y);
+
+ if(((GdkEventScroll*)e)->direction) //IN
+ {
+ zoomIn();
+ }
+ else
+ {
+ zoomOut();
+ }
+
+ //pointer shows this window point after zoom
+ XY post_win_coord;
+ world_to_window(canvas_coord.x, canvas_coord.y, post_win_coord.x, post_win_coord.y);
+
+ //we have to add the difference between new and old window point to original scroll offset
+ scroll_to(scroll_offset_x+(int)(post_win_coord.x-win_coord.x),scroll_offset_y+(int)(post_win_coord.y-win_coord.y));
+
+ //no other eventhandler is needed
+ handled=true;
+ }
+ return handled;
+}
+
bool GraphDisplayerCanvas::moveEventHandler(GdkEvent* e)
{
static Gnome::Canvas::Text *coord_text = 0;
Modified: glemon/branches/akos/graph_displayer_canvas.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas.cc (original)
+++ glemon/branches/akos/graph_displayer_canvas.cc Thu Nov 8 18:19:04 2007
@@ -28,10 +28,14 @@
was_redesigned(false), is_drawn(false), mytab(mainw),
background_set(false)
{
+ //add mouse scroll event handler - it won't be changed, it handles zoom
+ signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::scrollEventHandler), false);
+
//base event handler is move tool
actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
actual_tool=MOVE;
+
active_node=INVALID;
active_edge=INVALID;
forming_edge=INVALID;
@@ -341,6 +345,7 @@
void GraphDisplayerCanvas::reDesignGraph()
{
+ double max_coord=50000;
double min_dist=20;
double init_vector_length=25;
@@ -421,6 +426,26 @@
}
for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
{
+ if((mytab.mapstorage.getNodeCoords(i).x)+actual_forces[i].x>max_coord)
+ {
+ actual_forces[i].x=max_coord-(mytab.mapstorage.getNodeCoords(i).x);
+ std::cout << "Correction! " << ((mytab.mapstorage.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
+ }
+ else if((mytab.mapstorage.getNodeCoords(i).x)+actual_forces[i].x<(0-max_coord))
+ {
+ actual_forces[i].x=0-max_coord-(mytab.mapstorage.getNodeCoords(i).x);
+ std::cout << "Correction! " << ((mytab.mapstorage.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
+ }
+ if((mytab.mapstorage.getNodeCoords(i).y)+actual_forces[i].y>max_coord)
+ {
+ actual_forces[i].y=max_coord-((mytab.mapstorage).getNodeCoords(i).y);
+ std::cout << "Correction! " << (((mytab.mapstorage).getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
+ }
+ else if((mytab.mapstorage.getNodeCoords(i).y)+actual_forces[i].y<(0-max_coord))
+ {
+ actual_forces[i].y=0-max_coord-((mytab.mapstorage).getNodeCoords(i).y);
+ std::cout << "Correction! " << (((mytab.mapstorage).getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
+ }
moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
}
}
Modified: glemon/branches/akos/graph_displayer_canvas.h
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas.h (original)
+++ glemon/branches/akos/graph_displayer_canvas.h Thu Nov 8 18:19:04 2007
@@ -288,6 +288,8 @@
bool eraserEventHandler(GdkEvent*);
///event handler for the case when map editor tool is active
bool mapEditEventHandler(GdkEvent*);
+ ///event handler for the case when user scrolls the mouse
+ bool scrollEventHandler(GdkEvent*);
private:
///moves node according to the given parameters
More information about the Lemon-commits
mailing list