Zoom is now available with mouse-wheel.
1.1 --- a/graph_displayer_canvas-event.cc Wed Jan 10 14:56:16 2007 +0000
1.2 +++ b/graph_displayer_canvas-event.cc Fri Feb 02 10:13:33 2007 +0000
1.3 @@ -95,6 +95,45 @@
1.4 return actual_tool;
1.5 }
1.6
1.7 +bool GraphDisplayerCanvas::scrollEventHandler(GdkEvent* e)
1.8 +{
1.9 + bool handled=false;
1.10 + if(e->type==GDK_SCROLL)
1.11 + {
1.12 +
1.13 + //pointer shows this win point before zoom
1.14 + XY win_coord(((GdkEventScroll*)e)->x, ((GdkEventScroll*)e)->y);
1.15 +
1.16 + //the original scroll settings
1.17 + int scroll_offset_x, scroll_offset_y;
1.18 + get_scroll_offsets(scroll_offset_x, scroll_offset_y);
1.19 +
1.20 + //pointer shows this canvas point before zoom
1.21 + XY canvas_coord;
1.22 + window_to_world(win_coord.x, win_coord.y, canvas_coord.x, canvas_coord.y);
1.23 +
1.24 + if(((GdkEventScroll*)e)->direction) //IN
1.25 + {
1.26 + zoomIn();
1.27 + }
1.28 + else
1.29 + {
1.30 + zoomOut();
1.31 + }
1.32 +
1.33 + //pointer shows this window point after zoom
1.34 + XY post_win_coord;
1.35 + world_to_window(canvas_coord.x, canvas_coord.y, post_win_coord.x, post_win_coord.y);
1.36 +
1.37 + //we have to add the difference between new and old window point to original scroll offset
1.38 + scroll_to(scroll_offset_x+(int)(post_win_coord.x-win_coord.x),scroll_offset_y+(int)(post_win_coord.y-win_coord.y));
1.39 +
1.40 + //no other eventhandler is needed
1.41 + handled=true;
1.42 + }
1.43 + return handled;
1.44 +}
1.45 +
1.46 bool GraphDisplayerCanvas::moveEventHandler(GdkEvent* e)
1.47 {
1.48 static Gnome::Canvas::Text *coord_text = 0;
2.1 --- a/graph_displayer_canvas.cc Wed Jan 10 14:56:16 2007 +0000
2.2 +++ b/graph_displayer_canvas.cc Fri Feb 02 10:13:33 2007 +0000
2.3 @@ -28,10 +28,14 @@
2.4 was_redesigned(false), is_drawn(false), mytab(mainw),
2.5 background_set(false)
2.6 {
2.7 + //add mouse scroll event handler - it won't be changed, it handles zoom
2.8 + signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::scrollEventHandler), false);
2.9 +
2.10 //base event handler is move tool
2.11 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
2.12 actual_tool=MOVE;
2.13
2.14 +
2.15 active_node=INVALID;
2.16 active_edge=INVALID;
2.17 forming_edge=INVALID;
2.18 @@ -319,6 +323,7 @@
2.19
2.20 void GraphDisplayerCanvas::reDesignGraph()
2.21 {
2.22 + double max_coord=50000;
2.23 double min_dist=20;
2.24 double init_vector_length=25;
2.25
2.26 @@ -401,6 +406,26 @@
2.27 }
2.28 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
2.29 {
2.30 + if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x>max_coord)
2.31 + {
2.32 + actual_forces[i].x=max_coord-((mytab.mapstorage).coords[i].x);
2.33 + std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl;
2.34 + }
2.35 + else if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x<(0-max_coord))
2.36 + {
2.37 + actual_forces[i].x=0-max_coord-((mytab.mapstorage).coords[i].x);
2.38 + std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl;
2.39 + }
2.40 + if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y>max_coord)
2.41 + {
2.42 + actual_forces[i].y=max_coord-((mytab.mapstorage).coords[i].y);
2.43 + std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl;
2.44 + }
2.45 + else if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y<(0-max_coord))
2.46 + {
2.47 + actual_forces[i].y=0-max_coord-((mytab.mapstorage).coords[i].y);
2.48 + std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl;
2.49 + }
2.50 moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
2.51 }
2.52 }
3.1 --- a/graph_displayer_canvas.h Wed Jan 10 14:56:16 2007 +0000
3.2 +++ b/graph_displayer_canvas.h Fri Feb 02 10:13:33 2007 +0000
3.3 @@ -288,6 +288,8 @@
3.4 bool eraserEventHandler(GdkEvent*);
3.5 ///event handler for the case when map editor tool is active
3.6 bool mapEditEventHandler(GdkEvent*);
3.7 + ///event handler for the case when user scrolls the mouse
3.8 + bool scrollEventHandler(GdkEvent*);
3.9
3.10 private:
3.11 ///moves node according to the given parameters