Reorganizing.
1.1 --- a/Makefile.am Thu Nov 17 15:34:18 2005 +0000
1.2 +++ b/Makefile.am Mon Nov 21 12:07:05 2005 +0000
1.3 @@ -15,20 +15,18 @@
1.4 graph_displayer_canvas-zoom.cc \
1.5 graph_displayer_canvas.h \
1.6 graph-displayer.cc \
1.7 + gdc-broken_edge.cc \
1.8 main_win.cc \
1.9 main_win.h \
1.10 mapstorage.cc \
1.11 mapstorage.h \
1.12 map_win.cc \
1.13 map_win.h \
1.14 - broken_edge.cc \
1.15 - broken_edge.h \
1.16 + mw-mapselector.cc \
1.17 new_map_win.cc \
1.18 new_map_win.h \
1.19 xymap.h \
1.20 - icons/guipixbufs.h\
1.21 - mapselector.h\
1.22 - mapselector.cc
1.23 + icons/guipixbufs.h
1.24
1.25
1.26 glemon_CXXFLAGS = $(GTK_CFLAGS)
2.1 --- a/broken_edge.cc Thu Nov 17 15:34:18 2005 +0000
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,214 +0,0 @@
2.4 -#include "broken_edge.h"
2.5 -#include <cmath>
2.6 -
2.7 -BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
2.8 -{
2.9 - my_points=new Gnome::Art::Point[3];
2.10 -
2.11 - arrow=new Gnome::Canvas::Polygon(g);
2.12 - *arrow << Gnome::Canvas::Properties::fill_color("red");
2.13 - arrow->signal_event().connect(sigc::mem_fun(*this, &BrokenEdge::edgeFormerEventHandler));
2.14 - arrow->lower_to_bottom();
2.15 - setPoints(p);
2.16 -}
2.17 -
2.18 -BrokenEdge::~BrokenEdge()
2.19 -{
2.20 - if(arrow)delete(arrow);
2.21 -}
2.22 -
2.23 -void BrokenEdge::setPoints(Gnome::Canvas::Points p, bool move)
2.24 -{
2.25 - bool set_arrow=false;
2.26 - //red arrow losts its position-right button
2.27 - if(!move)
2.28 - {
2.29 - if(p.size()==2)
2.30 - {
2.31 - set_arrow=true;
2.32 - Gnome::Canvas::Points points_with_center;
2.33 - points_with_center.push_back(my_points[0]=p[0]);
2.34 - 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 );
2.35 - points_with_center.push_back(my_points[2]=p[1]);
2.36 - property_points().set_value(points_with_center);
2.37 - }
2.38 - if(p.size()==3)
2.39 - {
2.40 - set_arrow=true;
2.41 - property_points().set_value(p);
2.42 - for(int i=0;i<3;i++)
2.43 - {
2.44 - my_points[i]=p[i];
2.45 - }
2.46 - }
2.47 - }
2.48 - else
2.49 - {
2.50 - //arrow keeps its position-left button
2.51 -
2.52 -// if(p.size()==2)
2.53 -// {
2.54 -// Gnome::Canvas::Points points;
2.55 -// my_points[0]=p[0];
2.56 -// my_points[2]=p[1];
2.57 -// for(int i=0;i<3;i++)
2.58 -// {
2.59 -// points.push_back(my_points[i]);
2.60 -// }
2.61 -// property_points().set_value(points);
2.62 -// }
2.63 - set_arrow=true;
2.64 -
2.65 - //////////////////////////////////////////////////////////////////////////////////////////////////////
2.66 - /////////// keeps shape-with scalar multiplication - version 2.
2.67 - //////////////////////////////////////////////////////////////////////////////////////////////////////
2.68 -
2.69 - if(p.size()==2)
2.70 - {
2.71 - //old vector from one to the other node - a
2.72 - xy<double> a_v(my_points[2].get_x()-my_points[0].get_x(),my_points[2].get_y()-my_points[0].get_y());
2.73 - //new vector from one to the other node - b
2.74 - xy<double> b_v(p[1].get_x()-p[0].get_x(),p[1].get_y()-p[0].get_y());
2.75 -
2.76 - double absa=sqrt(a_v.normSquare());
2.77 - double absb=sqrt(b_v.normSquare());
2.78 -
2.79 - //old vector from one node to the breakpoint - c
2.80 - xy<double> c_v(my_points[1].get_x()-my_points[0].get_x(),my_points[1].get_y()-my_points[0].get_y());
2.81 -
2.82 - //unit vector with the same direction to a_v
2.83 - xy<double> a_v_u(a_v.x/absa,a_v.y/absa);
2.84 -
2.85 - //normal vector of unit vector with the same direction to a_v
2.86 - xy<double> a_v_u_n(((-1)*a_v_u.y),a_v_u.x);
2.87 -
2.88 - //unit vector with the same direction to b_v
2.89 - xy<double> b_v_u(b_v.x/absb,b_v.y/absb);
2.90 -
2.91 - //normal vector of unit vector with the same direction to b_v
2.92 - xy<double> b_v_u_n(((-1)*b_v_u.y),b_v_u.x);
2.93 -
2.94 - //vector c in a_v_u and a_v_u_n co-ordinate system
2.95 - xy<double> c_a(c_v*a_v_u,c_v*a_v_u_n);
2.96 -
2.97 - //new vector from one node to the breakpoint - d - we have to calculate this one
2.98 - xy<double> d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n);
2.99 -
2.100 - my_points[1]=Gnome::Art::Point(d_v.x+p[0].get_x(),d_v.y+p[0].get_y());
2.101 -
2.102 - my_points[0]=p[0];
2.103 - my_points[2]=p[1];
2.104 -
2.105 - Gnome::Canvas::Points points;
2.106 - for(int i=0;i<3;i++)
2.107 - {
2.108 - points.push_back(my_points[i]);
2.109 - }
2.110 - property_points().set_value(points);
2.111 - }
2.112 - }
2.113 - if(set_arrow)
2.114 - {
2.115 - //calculating coordinates of the direction indicator arrow
2.116 -
2.117 - xy<gdouble> target( my_points[2].get_x(), my_points[2].get_y() );
2.118 - xy<gdouble> center( my_points[1].get_x(), my_points[1].get_y() );
2.119 -
2.120 - xy<gdouble> unit_vector_in_dir(target-center);
2.121 - // std::cout << target << " - " << center << " = " << unit_vector_in_dir << " / " <<unit_vector_in_dir.normSquare() ;
2.122 - unit_vector_in_dir/=sqrt( unit_vector_in_dir.normSquare() );
2.123 - // std::cout << " = " << unit_vector_in_dir << std::endl;
2.124 -
2.125 - xy<gdouble> unit_norm_vector(0-unit_vector_in_dir.y, unit_vector_in_dir.x);
2.126 - // std::cout << unit_norm_vector << std::endl;
2.127 -
2.128 - {
2.129 - // /\ // top
2.130 - // / \ //
2.131 - // - - // c(enter)l(eft), ccl, ccr, cr
2.132 - // || //
2.133 - // || // b(ottom)l, br
2.134 - }
2.135 -
2.136 - double size=3;
2.137 -
2.138 - xy<gdouble> bl (center - unit_vector_in_dir * 3 * size + unit_norm_vector * size );
2.139 - xy<gdouble> br (center - unit_vector_in_dir * 3 * size - unit_norm_vector * size );
2.140 - xy<gdouble> ccl(center + unit_vector_in_dir * size + unit_norm_vector * size );
2.141 - xy<gdouble> ccr(center + unit_vector_in_dir * size - unit_norm_vector * size );
2.142 - xy<gdouble> cl (center + unit_vector_in_dir * size + unit_norm_vector * 2 * size );
2.143 - xy<gdouble> cr (center + unit_vector_in_dir * size - unit_norm_vector * 2 * size );
2.144 - xy<gdouble> top(center + unit_vector_in_dir * 3 * size);
2.145 -
2.146 - // std::cout << bl << " " << br << " " << ccl << " " << ccr << " " << cl << " " << cr << " " << top << std::endl;
2.147 -
2.148 - Gnome::Canvas::Points arrow_points;
2.149 - arrow_points.push_back(Gnome::Art::Point( bl.x , bl.y ) );
2.150 - arrow_points.push_back(Gnome::Art::Point( br.x , br.y ) );
2.151 - arrow_points.push_back(Gnome::Art::Point( ccr.x, ccr.y ) );
2.152 - arrow_points.push_back(Gnome::Art::Point( cr.x , cr.y ) );
2.153 - arrow_points.push_back(Gnome::Art::Point( top.x, top.y ) );
2.154 - arrow_points.push_back(Gnome::Art::Point( cl.x , cl.y ) );
2.155 - arrow_points.push_back(Gnome::Art::Point( ccl.x, ccl.y ) );
2.156 -
2.157 - arrow->property_points().set_value(arrow_points);
2.158 - }
2.159 -}
2.160 -
2.161 -bool BrokenEdge::edgeFormerEventHandler(GdkEvent* e)
2.162 -{
2.163 - switch(e->type)
2.164 - {
2.165 - case GDK_BUTTON_PRESS:
2.166 - //we mark the location of the event to be able to calculate parameters of dragging
2.167 - if(gdc.getActualTool()!=CREATE_NODE)
2.168 - {
2.169 - gdc.toggleEdgeActivity(this, true);
2.170 - clicked_x=e->button.x;
2.171 - clicked_y=e->button.y;
2.172 - isbutton=true;
2.173 - }
2.174 - break;
2.175 - case GDK_BUTTON_RELEASE:
2.176 - if(gdc.getActualTool()!=CREATE_NODE)
2.177 - {
2.178 - gdc.toggleEdgeActivity(this, false);
2.179 - isbutton=false;
2.180 - }
2.181 - break;
2.182 - case GDK_MOTION_NOTIFY:
2.183 - //we only have to do sg. if the mouse button is pressed
2.184 - if(isbutton)
2.185 - {
2.186 - //new coordinates will be the old values,
2.187 - //because the item will be moved to the
2.188 - //new coordinate therefore the new movement
2.189 - //has to be calculated from here
2.190 -
2.191 - double dx=e->motion.x-clicked_x;
2.192 - double dy=e->motion.y-clicked_y;
2.193 -
2.194 - Gnome::Canvas::Points points_new;
2.195 -
2.196 - points_new.push_back(my_points[0]);
2.197 - points_new.push_back(my_points[1]=Gnome::Art::Point(my_points[1].get_x()+dx,my_points[1].get_y()+dy));
2.198 - points_new.push_back(my_points[2]);
2.199 -
2.200 - setPoints(points_new);
2.201 - gdc.textReposition(xy<double>(my_points[1].get_x(),my_points[1].get_y()));
2.202 -
2.203 - clicked_x=e->motion.x;
2.204 - clicked_y=e->motion.y;
2.205 -
2.206 - }
2.207 - default: break;
2.208 - }
2.209 -
2.210 - return true;
2.211 -}
2.212 -
2.213 -xy<double> BrokenEdge::getArrowPos()
2.214 -{
2.215 - xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
2.216 - return ret_val;
2.217 -}
3.1 --- a/broken_edge.h Thu Nov 17 15:34:18 2005 +0000
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,39 +0,0 @@
3.4 -// -*- C++ -*- //
3.5 -
3.6 -#ifndef BROKEN_EDGE_H
3.7 -#define BROKEN_EDGE_H
3.8 -
3.9 -class BrokenEdge;
3.10 -
3.11 -#include "all_include.h"
3.12 -#include <libgnomecanvasmm.h>
3.13 -#include <libgnomecanvasmm/polygon.h>
3.14 -#include "graph_displayer_canvas.h"
3.15 -#include <lemon/xy.h>
3.16 -
3.17 -class BrokenEdge : public Gnome::Canvas::Line
3.18 -{
3.19 - GraphDisplayerCanvas & gdc;
3.20 - Gnome::Canvas::Polygon * arrow;
3.21 - Gnome::Art::Point * my_points;
3.22 -
3.23 -
3.24 - ///Indicates whether the button of mouse is pressed or not
3.25 - bool isbutton;
3.26 -
3.27 - ///At this location was the mousebutton pressed.
3.28 - ///It helps to calculate the distance of dragging.
3.29 - double clicked_x, clicked_y;
3.30 -
3.31 - ///event handler for forming edges
3.32 - bool edgeFormerEventHandler(GdkEvent*);
3.33 - public:
3.34 - BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points, GraphDisplayerCanvas &);
3.35 - ~BrokenEdge();
3.36 - void setPoints(Gnome::Canvas::Points, bool move=false);
3.37 - xy<double> getArrowPos();
3.38 -};
3.39 -
3.40 -
3.41 -#endif //BROKEN_EDGE_H
3.42 -
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/gdc-broken_edge.cc Mon Nov 21 12:07:05 2005 +0000
4.3 @@ -0,0 +1,214 @@
4.4 +#include "graph_displayer_canvas.h"
4.5 +#include <cmath>
4.6 +
4.7 +GraphDisplayerCanvas::BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
4.8 +{
4.9 + my_points=new Gnome::Art::Point[3];
4.10 +
4.11 + arrow=new Gnome::Canvas::Polygon(g);
4.12 + *arrow << Gnome::Canvas::Properties::fill_color("red");
4.13 + arrow->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::BrokenEdge::edgeFormerEventHandler));
4.14 + arrow->lower_to_bottom();
4.15 + setPoints(p);
4.16 +}
4.17 +
4.18 +GraphDisplayerCanvas::BrokenEdge::~BrokenEdge()
4.19 +{
4.20 + if(arrow)delete(arrow);
4.21 +}
4.22 +
4.23 +void GraphDisplayerCanvas::BrokenEdge::setPoints(Gnome::Canvas::Points p, bool move)
4.24 +{
4.25 + bool set_arrow=false;
4.26 + //red arrow losts its position-right button
4.27 + if(!move)
4.28 + {
4.29 + if(p.size()==2)
4.30 + {
4.31 + set_arrow=true;
4.32 + Gnome::Canvas::Points points_with_center;
4.33 + points_with_center.push_back(my_points[0]=p[0]);
4.34 + 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 );
4.35 + points_with_center.push_back(my_points[2]=p[1]);
4.36 + property_points().set_value(points_with_center);
4.37 + }
4.38 + if(p.size()==3)
4.39 + {
4.40 + set_arrow=true;
4.41 + property_points().set_value(p);
4.42 + for(int i=0;i<3;i++)
4.43 + {
4.44 + my_points[i]=p[i];
4.45 + }
4.46 + }
4.47 + }
4.48 + else
4.49 + {
4.50 + //arrow keeps its position-left button
4.51 +
4.52 +// if(p.size()==2)
4.53 +// {
4.54 +// Gnome::Canvas::Points points;
4.55 +// my_points[0]=p[0];
4.56 +// my_points[2]=p[1];
4.57 +// for(int i=0;i<3;i++)
4.58 +// {
4.59 +// points.push_back(my_points[i]);
4.60 +// }
4.61 +// property_points().set_value(points);
4.62 +// }
4.63 + set_arrow=true;
4.64 +
4.65 + //////////////////////////////////////////////////////////////////////////////////////////////////////
4.66 + /////////// keeps shape-with scalar multiplication - version 2.
4.67 + //////////////////////////////////////////////////////////////////////////////////////////////////////
4.68 +
4.69 + if(p.size()==2)
4.70 + {
4.71 + //old vector from one to the other node - a
4.72 + xy<double> a_v(my_points[2].get_x()-my_points[0].get_x(),my_points[2].get_y()-my_points[0].get_y());
4.73 + //new vector from one to the other node - b
4.74 + xy<double> b_v(p[1].get_x()-p[0].get_x(),p[1].get_y()-p[0].get_y());
4.75 +
4.76 + double absa=sqrt(a_v.normSquare());
4.77 + double absb=sqrt(b_v.normSquare());
4.78 +
4.79 + //old vector from one node to the breakpoint - c
4.80 + xy<double> c_v(my_points[1].get_x()-my_points[0].get_x(),my_points[1].get_y()-my_points[0].get_y());
4.81 +
4.82 + //unit vector with the same direction to a_v
4.83 + xy<double> a_v_u(a_v.x/absa,a_v.y/absa);
4.84 +
4.85 + //normal vector of unit vector with the same direction to a_v
4.86 + xy<double> a_v_u_n(((-1)*a_v_u.y),a_v_u.x);
4.87 +
4.88 + //unit vector with the same direction to b_v
4.89 + xy<double> b_v_u(b_v.x/absb,b_v.y/absb);
4.90 +
4.91 + //normal vector of unit vector with the same direction to b_v
4.92 + xy<double> b_v_u_n(((-1)*b_v_u.y),b_v_u.x);
4.93 +
4.94 + //vector c in a_v_u and a_v_u_n co-ordinate system
4.95 + xy<double> c_a(c_v*a_v_u,c_v*a_v_u_n);
4.96 +
4.97 + //new vector from one node to the breakpoint - d - we have to calculate this one
4.98 + xy<double> d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n);
4.99 +
4.100 + my_points[1]=Gnome::Art::Point(d_v.x+p[0].get_x(),d_v.y+p[0].get_y());
4.101 +
4.102 + my_points[0]=p[0];
4.103 + my_points[2]=p[1];
4.104 +
4.105 + Gnome::Canvas::Points points;
4.106 + for(int i=0;i<3;i++)
4.107 + {
4.108 + points.push_back(my_points[i]);
4.109 + }
4.110 + property_points().set_value(points);
4.111 + }
4.112 + }
4.113 + if(set_arrow)
4.114 + {
4.115 + //calculating coordinates of the direction indicator arrow
4.116 +
4.117 + xy<gdouble> target( my_points[2].get_x(), my_points[2].get_y() );
4.118 + xy<gdouble> center( my_points[1].get_x(), my_points[1].get_y() );
4.119 +
4.120 + xy<gdouble> unit_vector_in_dir(target-center);
4.121 + // std::cout << target << " - " << center << " = " << unit_vector_in_dir << " / " <<unit_vector_in_dir.normSquare() ;
4.122 + unit_vector_in_dir/=sqrt( unit_vector_in_dir.normSquare() );
4.123 + // std::cout << " = " << unit_vector_in_dir << std::endl;
4.124 +
4.125 + xy<gdouble> unit_norm_vector(0-unit_vector_in_dir.y, unit_vector_in_dir.x);
4.126 + // std::cout << unit_norm_vector << std::endl;
4.127 +
4.128 + {
4.129 + // /\ // top
4.130 + // / \ //
4.131 + // - - // c(enter)l(eft), ccl, ccr, cr
4.132 + // || //
4.133 + // || // b(ottom)l, br
4.134 + }
4.135 +
4.136 + double size=3;
4.137 +
4.138 + xy<gdouble> bl (center - unit_vector_in_dir * 3 * size + unit_norm_vector * size );
4.139 + xy<gdouble> br (center - unit_vector_in_dir * 3 * size - unit_norm_vector * size );
4.140 + xy<gdouble> ccl(center + unit_vector_in_dir * size + unit_norm_vector * size );
4.141 + xy<gdouble> ccr(center + unit_vector_in_dir * size - unit_norm_vector * size );
4.142 + xy<gdouble> cl (center + unit_vector_in_dir * size + unit_norm_vector * 2 * size );
4.143 + xy<gdouble> cr (center + unit_vector_in_dir * size - unit_norm_vector * 2 * size );
4.144 + xy<gdouble> top(center + unit_vector_in_dir * 3 * size);
4.145 +
4.146 + // std::cout << bl << " " << br << " " << ccl << " " << ccr << " " << cl << " " << cr << " " << top << std::endl;
4.147 +
4.148 + Gnome::Canvas::Points arrow_points;
4.149 + arrow_points.push_back(Gnome::Art::Point( bl.x , bl.y ) );
4.150 + arrow_points.push_back(Gnome::Art::Point( br.x , br.y ) );
4.151 + arrow_points.push_back(Gnome::Art::Point( ccr.x, ccr.y ) );
4.152 + arrow_points.push_back(Gnome::Art::Point( cr.x , cr.y ) );
4.153 + arrow_points.push_back(Gnome::Art::Point( top.x, top.y ) );
4.154 + arrow_points.push_back(Gnome::Art::Point( cl.x , cl.y ) );
4.155 + arrow_points.push_back(Gnome::Art::Point( ccl.x, ccl.y ) );
4.156 +
4.157 + arrow->property_points().set_value(arrow_points);
4.158 + }
4.159 +}
4.160 +
4.161 +bool GraphDisplayerCanvas::BrokenEdge::edgeFormerEventHandler(GdkEvent* e)
4.162 +{
4.163 + switch(e->type)
4.164 + {
4.165 + case GDK_BUTTON_PRESS:
4.166 + //we mark the location of the event to be able to calculate parameters of dragging
4.167 + if(gdc.getActualTool()!=CREATE_NODE)
4.168 + {
4.169 + gdc.toggleEdgeActivity(this, true);
4.170 + clicked_x=e->button.x;
4.171 + clicked_y=e->button.y;
4.172 + isbutton=true;
4.173 + }
4.174 + break;
4.175 + case GDK_BUTTON_RELEASE:
4.176 + if(gdc.getActualTool()!=CREATE_NODE)
4.177 + {
4.178 + gdc.toggleEdgeActivity(this, false);
4.179 + isbutton=false;
4.180 + }
4.181 + break;
4.182 + case GDK_MOTION_NOTIFY:
4.183 + //we only have to do sg. if the mouse button is pressed
4.184 + if(isbutton)
4.185 + {
4.186 + //new coordinates will be the old values,
4.187 + //because the item will be moved to the
4.188 + //new coordinate therefore the new movement
4.189 + //has to be calculated from here
4.190 +
4.191 + double dx=e->motion.x-clicked_x;
4.192 + double dy=e->motion.y-clicked_y;
4.193 +
4.194 + Gnome::Canvas::Points points_new;
4.195 +
4.196 + points_new.push_back(my_points[0]);
4.197 + points_new.push_back(my_points[1]=Gnome::Art::Point(my_points[1].get_x()+dx,my_points[1].get_y()+dy));
4.198 + points_new.push_back(my_points[2]);
4.199 +
4.200 + setPoints(points_new);
4.201 + gdc.textReposition(xy<double>(my_points[1].get_x(),my_points[1].get_y()));
4.202 +
4.203 + clicked_x=e->motion.x;
4.204 + clicked_y=e->motion.y;
4.205 +
4.206 + }
4.207 + default: break;
4.208 + }
4.209 +
4.210 + return true;
4.211 +}
4.212 +
4.213 +xy<double> GraphDisplayerCanvas::BrokenEdge::getArrowPos()
4.214 +{
4.215 + xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
4.216 + return ret_val;
4.217 +}
5.1 --- a/graph_displayer_canvas-edge.cc Thu Nov 17 15:34:18 2005 +0000
5.2 +++ b/graph_displayer_canvas-edge.cc Mon Nov 21 12:07:05 2005 +0000
5.3 @@ -1,5 +1,4 @@
5.4 #include "graph_displayer_canvas.h"
5.5 -#include "broken_edge.h"
5.6 #include <cmath>
5.7
5.8
6.1 --- a/graph_displayer_canvas-event.cc Thu Nov 17 15:34:18 2005 +0000
6.2 +++ b/graph_displayer_canvas-event.cc Mon Nov 21 12:07:05 2005 +0000
6.3 @@ -1,5 +1,4 @@
6.4 #include "graph_displayer_canvas.h"
6.5 -#include "broken_edge.h"
6.6 #include <cmath>
6.7
6.8
7.1 --- a/graph_displayer_canvas-node.cc Thu Nov 17 15:34:18 2005 +0000
7.2 +++ b/graph_displayer_canvas-node.cc Mon Nov 21 12:07:05 2005 +0000
7.3 @@ -1,5 +1,4 @@
7.4 #include "graph_displayer_canvas.h"
7.5 -#include "broken_edge.h"
7.6 #include <cmath>
7.7
7.8
8.1 --- a/graph_displayer_canvas-zoom.cc Thu Nov 17 15:34:18 2005 +0000
8.2 +++ b/graph_displayer_canvas-zoom.cc Mon Nov 21 12:07:05 2005 +0000
8.3 @@ -1,5 +1,4 @@
8.4 #include "graph_displayer_canvas.h"
8.5 -#include "broken_edge.h"
8.6 #include <cmath>
8.7
8.8 void GraphDisplayerCanvas::zoomIn()
9.1 --- a/graph_displayer_canvas.cc Thu Nov 17 15:34:18 2005 +0000
9.2 +++ b/graph_displayer_canvas.cc Mon Nov 21 12:07:05 2005 +0000
9.3 @@ -1,5 +1,4 @@
9.4 #include "graph_displayer_canvas.h"
9.5 -#include "broken_edge.h"
9.6 #include <cmath>
9.7
9.8 GraphDisplayerCanvas::GraphDisplayerCanvas(MapStorage & ms, MapWin & mw, Gtk::Window * mainwin) :
10.1 --- a/graph_displayer_canvas.h Thu Nov 17 15:34:18 2005 +0000
10.2 +++ b/graph_displayer_canvas.h Mon Nov 21 12:07:05 2005 +0000
10.3 @@ -7,14 +7,36 @@
10.4
10.5 #include "all_include.h"
10.6 #include "mapstorage.h"
10.7 -#include "broken_edge.h"
10.8 #include "map_win.h"
10.9 #include <libgnomecanvasmm.h>
10.10 #include <libgnomecanvasmm/polygon.h>
10.11 +#include <lemon/xy.h>
10.12
10.13 ///This class is the canvas, on which the graph can be drawn.
10.14 class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
10.15 {
10.16 + class BrokenEdge : public Gnome::Canvas::Line
10.17 + {
10.18 + GraphDisplayerCanvas & gdc;
10.19 + Gnome::Canvas::Polygon * arrow;
10.20 + Gnome::Art::Point * my_points;
10.21 +
10.22 +
10.23 + ///Indicates whether the button of mouse is pressed or not
10.24 + bool isbutton;
10.25 +
10.26 + ///At this location was the mousebutton pressed.
10.27 + ///It helps to calculate the distance of dragging.
10.28 + double clicked_x, clicked_y;
10.29 +
10.30 + ///event handler for forming edges
10.31 + bool edgeFormerEventHandler(GdkEvent*);
10.32 + public:
10.33 + BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points, GraphDisplayerCanvas &);
10.34 + ~BrokenEdge();
10.35 + void setPoints(Gnome::Canvas::Points, bool move=false);
10.36 + xy<double> getArrowPos();
10.37 + };
10.38 typedef Gnome::Canvas::CanvasAA Parent;
10.39
10.40 public:
11.1 --- a/map_win.h Thu Nov 17 15:34:18 2005 +0000
11.2 +++ b/map_win.h Mon Nov 21 12:07:05 2005 +0000
11.3 @@ -9,7 +9,6 @@
11.4 #include "graph_displayer_canvas.h"
11.5 #include "mapstorage.h"
11.6 #include "new_map_win.h"
11.7 -#include "mapselector.h"
11.8 #include <libgnomecanvasmm.h>
11.9 #include <libgnomecanvasmm/polygon.h>
11.10
11.11 @@ -18,6 +17,61 @@
11.12 ///assigned to maps.
11.13 class MapWin : public Gtk::Window
11.14 {
11.15 +
11.16 + class MapSelector : public Gtk::HBox
11.17 + {
11.18 + protected:
11.19 + GraphDisplayerCanvas & gdc;
11.20 + ///The \ref MapStorage in which the visualizable maps are stored
11.21 + MapStorage & ms;
11.22 + NewMapWin & nmw;
11.23 +
11.24 + int id;
11.25 +
11.26 + bool itisedge;
11.27 +
11.28 + bool default_state;
11.29 +
11.30 + bool set_new_map;
11.31 +
11.32 + Gtk::ComboBoxText cbt;
11.33 +
11.34 + Gtk::Button * newbut, * defbut;
11.35 +
11.36 + Gtk::HBox hbox;
11.37 +
11.38 + Gtk::Label * label;
11.39 +
11.40 + Node node_to_update;
11.41 + Edge edge_to_update;
11.42 +
11.43 +
11.44 + public:
11.45 +
11.46 + MapSelector(GraphDisplayerCanvas &, MapStorage &, NewMapWin &, int, bool);
11.47 +
11.48 + void update_list();
11.49 +
11.50 + ///If a radiobutton is clicked, this function determines
11.51 + ///which button was that and after that calls the
11.52 + ///appropriate function of the \ref GraphDisplayerCanvas
11.53 + ///to change the visible values of that attribute.
11.54 + virtual void comboChanged();
11.55 +
11.56 + virtual void new_but_pressed();
11.57 +
11.58 + virtual void reset();
11.59 +
11.60 + virtual void update(Node node);
11.61 + virtual void update(Edge edge);
11.62 +
11.63 + Glib::ustring get_active_text();
11.64 + void set_active_text(Glib::ustring);
11.65 + void append_text(Glib::ustring);
11.66 + };
11.67 +
11.68 +
11.69 +
11.70 protected:
11.71 ///The \ref GraphDisplayerCanvas on which the graph will be drawn.
11.72 ///It has to be known for this class, because
12.1 --- a/mapselector.cc Thu Nov 17 15:34:18 2005 +0000
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,225 +0,0 @@
12.4 -#include "mapselector.h"
12.5 -
12.6 -MapSelector::MapSelector(GraphDisplayerCanvas & grdispc, MapStorage & mapst, NewMapWin & newmapw, int identifier, bool edge):gdc(grdispc),ms(mapst),nmw(newmapw),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID)
12.7 -{
12.8 - update_list();
12.9 -
12.10 - cbt.set_active(0);
12.11 -
12.12 - //binding signal to the actual entry
12.13 - cbt.signal_changed().connect
12.14 - (
12.15 - sigc::mem_fun((*this), &MapSelector::comboChanged),
12.16 - false
12.17 - );
12.18 -
12.19 - if(itisedge)
12.20 - {
12.21 - label=new Gtk::Label(edge_property_strings[id]);
12.22 - }
12.23 - else
12.24 - {
12.25 - label=new Gtk::Label(node_property_strings[id]);
12.26 - }
12.27 -
12.28 - label->set_width_chars(longest_property_string_length);
12.29 -
12.30 - defbut=new Gtk::Button();
12.31 - defbut->set_label("Reset");
12.32 -
12.33 - defbut->signal_pressed().connect
12.34 - (
12.35 - sigc::mem_fun(*this, &MapSelector::reset)
12.36 - );
12.37 -
12.38 - newbut=new Gtk::Button(Gtk::Stock::NEW);
12.39 -
12.40 - newbut->signal_pressed().connect
12.41 - (
12.42 - sigc::mem_fun(*this, &MapSelector::new_but_pressed)
12.43 - );
12.44 -
12.45 - add(*label);
12.46 -
12.47 - add(cbt);
12.48 -
12.49 - add(*defbut);
12.50 - add(*newbut);
12.51 -}
12.52 -
12.53 -void MapSelector::new_but_pressed()
12.54 -{
12.55 - set_new_map=true;
12.56 - nmw.showByPreChoose(itisedge);
12.57 -}
12.58 -
12.59 -void MapSelector::update_list()
12.60 -{
12.61 - cbt.clear();
12.62 - if(itisedge)
12.63 - {
12.64 - std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
12.65 - for(;emsi!=ms.endOfEdgeMaps();emsi++)
12.66 - {
12.67 - cbt.append_text(emsi->first);
12.68 - }
12.69 - }
12.70 - else
12.71 - {
12.72 - std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
12.73 - for(;emsi!=ms.endOfNodeMaps();emsi++)
12.74 - {
12.75 - cbt.append_text(emsi->first);
12.76 - }
12.77 - }
12.78 - cbt.prepend_text("Default values");
12.79 -}
12.80 -
12.81 -void MapSelector::comboChanged()
12.82 -{
12.83 - if(cbt.get_active_row_number()!=0)
12.84 - {
12.85 - default_state=false;
12.86 - Glib::ustring mapname = cbt.get_active_text();
12.87 - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
12.88 - {
12.89 - if(itisedge)
12.90 - {
12.91 - if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) )
12.92 - {
12.93 - Edge edge=edge_to_update;
12.94 - switch(id)
12.95 - {
12.96 - case E_WIDTH:
12.97 - gdc.changeEdgeWidth(mapname, edge);
12.98 - break;
12.99 - case E_COLOR:
12.100 - gdc.changeEdgeColor(mapname, edge);
12.101 - break;
12.102 - case E_TEXT:
12.103 - gdc.changeEdgeText(mapname, edge);
12.104 - break;
12.105 - default:
12.106 - std::cerr<<"Error\n";
12.107 - }
12.108 - }
12.109 - }
12.110 - else
12.111 - {
12.112 - if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) )
12.113 - {
12.114 - Node node=node_to_update;
12.115 - switch(id)
12.116 - {
12.117 - case N_RADIUS:
12.118 - gdc.changeNodeRadius(mapname, node);
12.119 - break;
12.120 - case N_COLOR:
12.121 - gdc.changeNodeColor(mapname, node);
12.122 - break;
12.123 - case N_TEXT:
12.124 - gdc.changeNodeText(mapname, node);
12.125 - break;
12.126 - default:
12.127 - std::cerr<<"Error\n";
12.128 - }
12.129 - }
12.130 - }
12.131 - }
12.132 - }
12.133 - else if((!default_state)&&(cbt.get_active_row_number()==0))
12.134 - {
12.135 - reset();
12.136 - }
12.137 -}
12.138 -
12.139 -void MapSelector::reset()
12.140 -{
12.141 - default_state=true;
12.142 - cbt.set_active(0);
12.143 -
12.144 - if(itisedge)
12.145 - {
12.146 - Edge edge=edge_to_update;
12.147 - switch(id)
12.148 - {
12.149 - case E_WIDTH:
12.150 - gdc.resetEdgeWidth(edge);
12.151 - break;
12.152 - case E_COLOR:
12.153 - gdc.resetEdgeColor(edge);
12.154 - break;
12.155 - case E_TEXT:
12.156 - gdc.resetEdgeText(edge);
12.157 - break;
12.158 - default:
12.159 - std::cerr<<"Error\n";
12.160 - }
12.161 - }
12.162 - else
12.163 - {
12.164 - Node node=node_to_update;
12.165 - switch(id)
12.166 - {
12.167 - case N_RADIUS:
12.168 - gdc.resetNodeRadius(node);
12.169 - break;
12.170 - case N_COLOR:
12.171 - gdc.resetNodeColor(node);
12.172 - break;
12.173 - case N_TEXT:
12.174 - gdc.resetNodeText(node);
12.175 - break;
12.176 - default:
12.177 - std::cerr<<"Error\n";
12.178 - }
12.179 - }
12.180 -}
12.181 -
12.182 -void MapSelector::update(Node node)
12.183 -{
12.184 - node_to_update=node;
12.185 - if(default_state)
12.186 - {
12.187 - reset();
12.188 - }
12.189 - else
12.190 - {
12.191 - comboChanged();
12.192 - }
12.193 - node_to_update=INVALID;
12.194 -}
12.195 -
12.196 -void MapSelector::update(Edge edge)
12.197 -{
12.198 - edge_to_update=edge;
12.199 - if(default_state)
12.200 - {
12.201 - reset();
12.202 - }
12.203 - else
12.204 - {
12.205 - comboChanged();
12.206 - }
12.207 - edge_to_update=INVALID;
12.208 -}
12.209 -
12.210 -Glib::ustring MapSelector::get_active_text()
12.211 -{
12.212 - return cbt.get_active_text();
12.213 -}
12.214 -
12.215 -void MapSelector::set_active_text(Glib::ustring text)
12.216 -{
12.217 - cbt.set_active_text(text);
12.218 -}
12.219 -
12.220 -void MapSelector::append_text(Glib::ustring text)
12.221 -{
12.222 - cbt.append_text(text);
12.223 - if(set_new_map)
12.224 - {
12.225 - set_active_text(text);
12.226 - set_new_map=false;
12.227 - }
12.228 -}
13.1 --- a/mapselector.h Thu Nov 17 15:34:18 2005 +0000
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,67 +0,0 @@
13.4 -// -*- C++ -*- //
13.5 -
13.6 -#ifndef MAP_SELECTOR_H
13.7 -#define MAP_SELECTOR_H
13.8 -
13.9 -class MapSelector;
13.10 -
13.11 -#include "all_include.h"
13.12 -#include "mapstorage.h"
13.13 -#include "new_map_win.h"
13.14 -#include "graph_displayer_canvas.h"
13.15 -#include <libgnomecanvasmm.h>
13.16 -#include <libgnomecanvasmm/polygon.h>
13.17 -
13.18 -class MapSelector : public Gtk::HBox
13.19 -{
13.20 -protected:
13.21 - GraphDisplayerCanvas & gdc;
13.22 - ///The \ref MapStorage in which the visualizable maps are stored
13.23 - MapStorage & ms;
13.24 - NewMapWin & nmw;
13.25 -
13.26 - int id;
13.27 -
13.28 - bool itisedge;
13.29 -
13.30 - bool default_state;
13.31 -
13.32 - bool set_new_map;
13.33 -
13.34 - Gtk::ComboBoxText cbt;
13.35 -
13.36 - Gtk::Button * newbut, * defbut;
13.37 -
13.38 - Gtk::HBox hbox;
13.39 -
13.40 - Gtk::Label * label;
13.41 -
13.42 - Node node_to_update;
13.43 - Edge edge_to_update;
13.44 -
13.45 -
13.46 -public:
13.47 -
13.48 - MapSelector(GraphDisplayerCanvas &, MapStorage &, NewMapWin &, int, bool);
13.49 -
13.50 - void update_list();
13.51 -
13.52 - ///If a radiobutton is clicked, this function determines
13.53 - ///which button was that and after that calls the
13.54 - ///appropriate function of the \ref GraphDisplayerCanvas
13.55 - ///to change the visible values of that attribute.
13.56 - virtual void comboChanged();
13.57 -
13.58 - virtual void new_but_pressed();
13.59 -
13.60 - virtual void reset();
13.61 -
13.62 - virtual void update(Node node);
13.63 - virtual void update(Edge edge);
13.64 -
13.65 - Glib::ustring get_active_text();
13.66 - void set_active_text(Glib::ustring);
13.67 - void append_text(Glib::ustring);
13.68 -};
13.69 -
13.70 -#endif
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/mw-mapselector.cc Mon Nov 21 12:07:05 2005 +0000
14.3 @@ -0,0 +1,225 @@
14.4 +#include "map_win.h"
14.5 +
14.6 +MapWin::MapSelector::MapSelector(GraphDisplayerCanvas & grdispc, MapStorage & mapst, NewMapWin & newmapw, int identifier, bool edge):gdc(grdispc),ms(mapst),nmw(newmapw),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID)
14.7 +{
14.8 + update_list();
14.9 +
14.10 + cbt.set_active(0);
14.11 +
14.12 + //binding signal to the actual entry
14.13 + cbt.signal_changed().connect
14.14 + (
14.15 + sigc::mem_fun((*this), &MapWin::MapSelector::comboChanged),
14.16 + false
14.17 + );
14.18 +
14.19 + if(itisedge)
14.20 + {
14.21 + label=new Gtk::Label(edge_property_strings[id]);
14.22 + }
14.23 + else
14.24 + {
14.25 + label=new Gtk::Label(node_property_strings[id]);
14.26 + }
14.27 +
14.28 + label->set_width_chars(longest_property_string_length);
14.29 +
14.30 + defbut=new Gtk::Button();
14.31 + defbut->set_label("Reset");
14.32 +
14.33 + defbut->signal_pressed().connect
14.34 + (
14.35 + sigc::mem_fun(*this, &MapWin::MapSelector::reset)
14.36 + );
14.37 +
14.38 + newbut=new Gtk::Button(Gtk::Stock::NEW);
14.39 +
14.40 + newbut->signal_pressed().connect
14.41 + (
14.42 + sigc::mem_fun(*this, &MapWin::MapSelector::new_but_pressed)
14.43 + );
14.44 +
14.45 + add(*label);
14.46 +
14.47 + add(cbt);
14.48 +
14.49 + add(*defbut);
14.50 + add(*newbut);
14.51 +}
14.52 +
14.53 +void MapWin::MapSelector::new_but_pressed()
14.54 +{
14.55 + set_new_map=true;
14.56 + nmw.showByPreChoose(itisedge);
14.57 +}
14.58 +
14.59 +void MapWin::MapSelector::update_list()
14.60 +{
14.61 + cbt.clear();
14.62 + if(itisedge)
14.63 + {
14.64 + std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
14.65 + for(;emsi!=ms.endOfEdgeMaps();emsi++)
14.66 + {
14.67 + cbt.append_text(emsi->first);
14.68 + }
14.69 + }
14.70 + else
14.71 + {
14.72 + std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
14.73 + for(;emsi!=ms.endOfNodeMaps();emsi++)
14.74 + {
14.75 + cbt.append_text(emsi->first);
14.76 + }
14.77 + }
14.78 + cbt.prepend_text("Default values");
14.79 +}
14.80 +
14.81 +void MapWin::MapSelector::comboChanged()
14.82 +{
14.83 + if(cbt.get_active_row_number()!=0)
14.84 + {
14.85 + default_state=false;
14.86 + Glib::ustring mapname = cbt.get_active_text();
14.87 + if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
14.88 + {
14.89 + if(itisedge)
14.90 + {
14.91 + if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) )
14.92 + {
14.93 + Edge edge=edge_to_update;
14.94 + switch(id)
14.95 + {
14.96 + case E_WIDTH:
14.97 + gdc.changeEdgeWidth(mapname, edge);
14.98 + break;
14.99 + case E_COLOR:
14.100 + gdc.changeEdgeColor(mapname, edge);
14.101 + break;
14.102 + case E_TEXT:
14.103 + gdc.changeEdgeText(mapname, edge);
14.104 + break;
14.105 + default:
14.106 + std::cerr<<"Error\n";
14.107 + }
14.108 + }
14.109 + }
14.110 + else
14.111 + {
14.112 + if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) )
14.113 + {
14.114 + Node node=node_to_update;
14.115 + switch(id)
14.116 + {
14.117 + case N_RADIUS:
14.118 + gdc.changeNodeRadius(mapname, node);
14.119 + break;
14.120 + case N_COLOR:
14.121 + gdc.changeNodeColor(mapname, node);
14.122 + break;
14.123 + case N_TEXT:
14.124 + gdc.changeNodeText(mapname, node);
14.125 + break;
14.126 + default:
14.127 + std::cerr<<"Error\n";
14.128 + }
14.129 + }
14.130 + }
14.131 + }
14.132 + }
14.133 + else if((!default_state)&&(cbt.get_active_row_number()==0))
14.134 + {
14.135 + reset();
14.136 + }
14.137 +}
14.138 +
14.139 +void MapWin::MapSelector::reset()
14.140 +{
14.141 + default_state=true;
14.142 + cbt.set_active(0);
14.143 +
14.144 + if(itisedge)
14.145 + {
14.146 + Edge edge=edge_to_update;
14.147 + switch(id)
14.148 + {
14.149 + case E_WIDTH:
14.150 + gdc.resetEdgeWidth(edge);
14.151 + break;
14.152 + case E_COLOR:
14.153 + gdc.resetEdgeColor(edge);
14.154 + break;
14.155 + case E_TEXT:
14.156 + gdc.resetEdgeText(edge);
14.157 + break;
14.158 + default:
14.159 + std::cerr<<"Error\n";
14.160 + }
14.161 + }
14.162 + else
14.163 + {
14.164 + Node node=node_to_update;
14.165 + switch(id)
14.166 + {
14.167 + case N_RADIUS:
14.168 + gdc.resetNodeRadius(node);
14.169 + break;
14.170 + case N_COLOR:
14.171 + gdc.resetNodeColor(node);
14.172 + break;
14.173 + case N_TEXT:
14.174 + gdc.resetNodeText(node);
14.175 + break;
14.176 + default:
14.177 + std::cerr<<"Error\n";
14.178 + }
14.179 + }
14.180 +}
14.181 +
14.182 +void MapWin::MapSelector::update(Node node)
14.183 +{
14.184 + node_to_update=node;
14.185 + if(default_state)
14.186 + {
14.187 + reset();
14.188 + }
14.189 + else
14.190 + {
14.191 + comboChanged();
14.192 + }
14.193 + node_to_update=INVALID;
14.194 +}
14.195 +
14.196 +void MapWin::MapSelector::update(Edge edge)
14.197 +{
14.198 + edge_to_update=edge;
14.199 + if(default_state)
14.200 + {
14.201 + reset();
14.202 + }
14.203 + else
14.204 + {
14.205 + comboChanged();
14.206 + }
14.207 + edge_to_update=INVALID;
14.208 +}
14.209 +
14.210 +Glib::ustring MapWin::MapSelector::get_active_text()
14.211 +{
14.212 + return cbt.get_active_text();
14.213 +}
14.214 +
14.215 +void MapWin::MapSelector::set_active_text(Glib::ustring text)
14.216 +{
14.217 + cbt.set_active_text(text);
14.218 +}
14.219 +
14.220 +void MapWin::MapSelector::append_text(Glib::ustring text)
14.221 +{
14.222 + cbt.append_text(text);
14.223 + if(set_new_map)
14.224 + {
14.225 + set_active_text(text);
14.226 + set_new_map=false;
14.227 + }
14.228 +}
15.1 --- a/new_map_win.cc Thu Nov 17 15:34:18 2005 +0000
15.2 +++ b/new_map_win.cc Mon Nov 21 12:07:05 2005 +0000
15.3 @@ -318,8 +318,8 @@
15.4 {
15.5 unsigned int pr=10000;
15.6 bool prevmult=false;
15.7 - unsigned int prev_change;
15.8 - unsigned int prev_br=10000;
15.9 + unsigned int prev_change=pr;
15.10 + unsigned int prev_br=pr;
15.11 int counter=0;
15.12 std::string comm_nobr="";
15.13 std::vector<unsigned int> p;
15.14 @@ -392,7 +392,7 @@
15.15
15.16 NewMapWin::tree_node * NewMapWin::weightedString2Tree(std::string to_tree, std::vector<unsigned int> & p, int offset)
15.17 {
15.18 - int min=p[offset];
15.19 + unsigned int min=p[offset];
15.20 int minplace=0;
15.21 for(int i=0;i<(int)to_tree.size();i++)
15.22 {