Tooltip should be turn up on CreateNode tool. gui
authorhegyi
Thu, 28 Jul 2005 17:01:40 +0000
branchgui
changeset 50eedecee61922
parent 49 e112465192dc
child 51 25405e400292
Tooltip should be turn up on CreateNode tool.
broken_edge.cc
main_win.cc
main_win.h
     1.1 --- a/broken_edge.cc	Thu Jul 28 15:54:53 2005 +0000
     1.2 +++ b/broken_edge.cc	Thu Jul 28 17:01:40 2005 +0000
     1.3 @@ -19,6 +19,7 @@
     1.4  void BrokenEdge::setPoints(Gnome::Canvas::Points p, bool move)
     1.5  {
     1.6    bool set_arrow=false;
     1.7 +  //red arrow losts its position-right button
     1.8    if(!move)
     1.9      {
    1.10        if(p.size()==2)
    1.11 @@ -42,11 +43,189 @@
    1.12      }
    1.13    else
    1.14      {
    1.15 +      //arrow keeps its position-left button
    1.16 +
    1.17 +      //       if(p.size()==2)
    1.18 +      // 	{
    1.19 +      // 	  Gnome::Canvas::Points points;
    1.20 +      // 	  my_points[0]=p[0];
    1.21 +      // 	  my_points[2]=p[1];
    1.22 +      // 	  for(int i=0;i<3;i++)
    1.23 +      // 	    {
    1.24 +      // 	      points.push_back(my_points[i]);
    1.25 +      // 	    }
    1.26 +      // 	  property_points().set_value(points);
    1.27 +      // 	}
    1.28 +
    1.29 +      //////////////////////////////////////////////////////////////////////////////////////////////////////
    1.30 +      /////////// kepps shape-with angles
    1.31 +      //////////////////////////////////////////////////////////////////////////////////////////////////////
    1.32 +
    1.33 +
    1.34 +//       //old vector from one to the other node
    1.35 +//       xy<double> o_p2p(my_points[2].get_x()-my_points[0].get_x(),my_points[2].get_y()-my_points[0].get_y());
    1.36 +//       //projection of the old vector to positive x axis
    1.37 +//       xy<double> o_x_p2p(fabs(o_p2p.x),0);
    1.38 +//       //length of p2p vector
    1.39 +//       double o_l_p2p=sqrt( o_p2p.normSquare() );
    1.40 +//       if(o_p2p.x<0)
    1.41 +// 	{
    1.42 +// 	  o_l_p2p*=-1;
    1.43 +// 	}
    1.44 +//       //length of projection of p2p vector
    1.45 +//       double o_l_x_p2p=sqrt( o_x_p2p.normSquare() );
    1.46 +//       //old angle of p2p vector to the x axis
    1.47 +//       double o_a_p2p=acos(o_l_x_p2p/o_l_p2p);
    1.48 +//       if(o_p2p.y>0)
    1.49 +// 	{
    1.50 +// 	  o_a_p2p=2*M_PI-o_a_p2p;
    1.51 +// 	}
    1.52 +
    1.53 +//       //old vector from first node to the breakpoint
    1.54 +//       xy<double> o_1b((my_points[1].get_x()-my_points[0].get_x()),(my_points[1].get_y()-my_points[0].get_y()));
    1.55 +//       //projection of the old node-breakpoint vector to positive x axis
    1.56 +//       xy<double> o_x_1b(fabs(o_1b.x),0);
    1.57 +//       //length of 1b vector
    1.58 +//       double o_l_1b=sqrt( o_1b.normSquare() );
    1.59 +//       if(o_1b.x<0)
    1.60 +// 	{
    1.61 +// 	  o_l_1b*=-1;
    1.62 +// 	}
    1.63 +//       //length of projection of 1b vector
    1.64 +//       double o_l_x_1b=sqrt( o_x_1b.normSquare() );
    1.65 +//       //old angle of 1b vector to the x axis
    1.66 +//       double o_a_1b=acos(o_l_x_1b/o_l_1b);
    1.67 +//       if(o_1b.y>0)
    1.68 +// 	{
    1.69 +// 	  o_a_1b=2*M_PI-o_a_1b;
    1.70 +// 	}
    1.71 +
    1.72 +//       if(p.size()==2)
    1.73 +//       	{
    1.74 +// 	  set_arrow=true;
    1.75 +
    1.76 +//       	  my_points[0]=p[0];
    1.77 +//       	  my_points[2]=p[1];
    1.78 +
    1.79 +// 	  //new vector from one to the other node
    1.80 +// 	  xy<double> n_p2p(my_points[2].get_x()-my_points[0].get_x(),my_points[2].get_y()-my_points[0].get_y());
    1.81 +// 	  //projection of the new vector to positive x axis
    1.82 +// 	  xy<double> n_x_p2p(fabs(n_p2p.x),0);
    1.83 +// 	  //length of p2p vector
    1.84 +// 	  double n_l_p2p=sqrt( n_p2p.normSquare() );
    1.85 +// 	  if(n_p2p.x<0)
    1.86 +// 	    {
    1.87 +// 	      n_l_p2p*=-1;
    1.88 +// 	    }
    1.89 +// 	  //length of projection of p2p vector
    1.90 +// 	  double n_l_x_p2p=sqrt( n_x_p2p.normSquare() );
    1.91 +// 	  //new angle of p2p vector to the x axis
    1.92 +// 	  double n_a_p2p=acos(n_l_x_p2p/n_l_p2p);
    1.93 +// 	  if(n_p2p.y>0)
    1.94 +// 	    {
    1.95 +// 	      n_a_p2p=2*M_PI-n_a_p2p;
    1.96 +// 	    }
    1.97 +
    1.98 +// 	  //new angle of 1b vector to the x axis
    1.99 +// 	  double n_a_1b=o_a_1b+n_a_p2p-o_a_p2p;
   1.100 +
   1.101 +// 	  std::cout << " p2p regi: " << o_a_p2p/M_PI*180 << " uj: " << n_a_p2p/M_PI*180-(int)n_a_p2p/M_PI*180 << std::endl;
   1.102 +// 	  std::cout << " 1b regi: " << o_a_1b/M_PI*180 << " uj: " << n_a_1b/M_PI*180-(int)n_a_1b/M_PI*180 << std::endl;
   1.103 +
   1.104 +// // 	  std::cout << o_p2p << " " << n_p2p << std::endl;
   1.105 +
   1.106 +// 	  if((n_a_1b>M_PI*3/2)||(n_a_1b<M_PI/2))
   1.107 +// 	    {
   1.108 +// 	      std::cout << "jobb terfel" << std::endl;
   1.109 +// 	      my_points[1]=Gnome::Art::Point(p[0].get_x()+cos(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p,p[0].get_y()-sin(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p);
   1.110 +// 	    }
   1.111 +// 	  else if((n_a_1b<M_PI*3/2)&&(n_a_1b>M_PI/2))
   1.112 +// 	    {
   1.113 +// 	      std::cout << "bal terfel" << std::endl;
   1.114 +// 	      my_points[1]=Gnome::Art::Point(p[0].get_x()-cos(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p,p[0].get_y()+sin(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p);
   1.115 +// 	    }
   1.116 +// 	  else
   1.117 +// 	    {
   1.118 +// 	      std::cout << "y tengely" << std::endl;
   1.119 +// 	      double new_y=my_points[1].get_y();
   1.120 +// 	      my_points[1]=Gnome::Art::Point(p[0].get_x()-cos(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p,new_y);
   1.121 +// 	    }
   1.122 +
   1.123 +// 	  std::cout << "alap: " << p[0] << " eredeti hossz: " << o_l_1b << " nagy uj: " << n_l_p2p << " nagy regi: " << o_l_p2p << " a*b/c " << o_l_1b*n_l_p2p/o_l_p2p << " eredmeny: " << my_points[1] << std::endl;
   1.124 +
   1.125 +
   1.126 +// // 	  if(o_1b.x*o_1b.y>0)
   1.127 +// // 	    {
   1.128 +// // 	      if(n_p2p.x>0)
   1.129 +// // 		{
   1.130 +// // 		  my_points[1]=Gnome::Art::Point(p[0].get_x()+cos(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p,p[0].get_y()+sin(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p);
   1.131 +// // 		}
   1.132 +// // 	      else
   1.133 +// // 		{
   1.134 +// // 		  my_points[1]=Gnome::Art::Point(p[0].get_x()-cos(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p,p[0].get_y()-sin(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p);
   1.135 +// // 		}
   1.136 +// // 	    }
   1.137 +// // 	  else if(o_1b.x*o_1b.y<0)
   1.138 +// // 	    {
   1.139 +// // 	      if(n_p2p.x>0)
   1.140 +// // 		{
   1.141 +// // 		  my_points[1]=Gnome::Art::Point(p[0].get_x()+cos(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p,p[0].get_y()-sin(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p);
   1.142 +// // 		}
   1.143 +// // 	      else
   1.144 +// // 		{
   1.145 +// // 		  my_points[1]=Gnome::Art::Point(p[0].get_x()-cos(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p,p[0].get_y()+sin(n_a_1b)*o_l_1b*n_l_p2p/o_l_p2p);
   1.146 +// // 		}
   1.147 +// // 	    }
   1.148 +// // 	  else
   1.149 +// // 	    {
   1.150 +// // 	    }
   1.151 +
   1.152 +      //////////////////////////////////////////////////////////////////////////////////////////////////////
   1.153 +      /////////// kepps shape-with scalar multiplication
   1.154 +      //////////////////////////////////////////////////////////////////////////////////////////////////////
   1.155 +
   1.156        if(p.size()==2)
   1.157 -	{
   1.158 +      	{
   1.159 +	  //old vector from one to the other node - a
   1.160 +	  xy<double> a_v(my_points[2].get_x()-my_points[0].get_x(),my_points[2].get_y()-my_points[0].get_y());
   1.161 +	  //new vector from one to the other node - b
   1.162 +	  xy<double> b_v(p[1].get_x()-p[0].get_x(),p[1].get_y()-p[0].get_y());
   1.163 +
   1.164 +	  //old vector from one node to the breakpoint - c
   1.165 +	  xy<double> c_v(my_points[1].get_x()-my_points[0].get_x(),my_points[1].get_y()-my_points[0].get_y());
   1.166 +
   1.167 +	  //new vector from one node to the breakpoint - d - we have to calculate this one
   1.168 +	  xy<double> d_v;
   1.169 +
   1.170 +	  //scalar product of a and b (old and new vector from first point to the other)
   1.171 +	  double sab=a_v*b_v;
   1.172 +	  //scalar product of c and d (old and new vector from first point to breakpoint)
   1.173 +	  double scd=sab*c_v.normSquare()/a_v.normSquare();
   1.174 +
   1.175 +	  std::cout<<" a " << a_v<<" b " <<b_v<<" c " <<c_v<<" sab " <<sab<<" scd "<<scd<<std::endl;
   1.176 +
   1.177 +	  double a=c_v.normSquare();
   1.178 +	  double b=2*scd*c_v.y;
   1.179 +	  double c=scd*scd-b_v.normSquare()/a_v.normSquare()*c_v.normSquare()*c_v.x*c_v.x;
   1.180 +
   1.181 +	  std::cout<<" a " << a<<" b " <<b<<" c " <<c<<std::endl;
   1.182 +
   1.183 +	  d_v.y=(-b-sqrt(b*b-4*a*c))/2/a;
   1.184 +
   1.185 +	  if(c_v.x!=0)
   1.186 +	    {
   1.187 +	      d_v.x=(scd-c_v.y*d_v.y)/c_v.x;
   1.188 +	    }
   1.189 +	  else
   1.190 +	    {
   1.191 +	      d_v.x=my_points[1].get_x();
   1.192 +	    }
   1.193 +
   1.194 +	  std::cout<<" d " << d_v<<std::endl;
   1.195 +
   1.196 +	  my_points[1]=Gnome::Art::Point(d_v.x+p[0].get_x(),d_v.y+p[0].get_y());
   1.197 +
   1.198  	  Gnome::Canvas::Points points;
   1.199 -	  my_points[0]=p[0];
   1.200 -	  my_points[2]=p[1];
   1.201  	  for(int i=0;i<3;i++)
   1.202  	    {
   1.203  	      points.push_back(my_points[i]);
   1.204 @@ -54,7 +233,6 @@
   1.205  	  property_points().set_value(points);
   1.206  	}
   1.207      }
   1.208 -
   1.209    if(set_arrow)
   1.210      {
   1.211        //calculating coordinates of the direction indicator arrow
     2.1 --- a/main_win.cc	Thu Jul 28 15:54:53 2005 +0000
     2.2 +++ b/main_win.cc	Thu Jul 28 17:01:40 2005 +0000
     2.3 @@ -121,7 +121,9 @@
     2.4    Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
     2.5    pScrolledWindow->add(gd_canvas);
     2.6    vbox.pack_start(*pScrolledWindow);
     2.7 -  //vbox.pack_start(gd_canvas);
     2.8 +
     2.9 +  tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
    2.10 +  tooltips.enable();
    2.11  
    2.12    show_all_children();
    2.13  }
     3.1 --- a/main_win.h	Thu Jul 28 15:54:53 2005 +0000
     3.2 +++ b/main_win.h	Thu Jul 28 17:01:40 2005 +0000
     3.3 @@ -41,6 +41,9 @@
     3.4    ///Container
     3.5    Gtk::VBox vbox;
     3.6  
     3.7 +  ///Tooltips
     3.8 +  Gtk::Tooltips tooltips;
     3.9 +
    3.10    ///Callback for 'FileNew' action.
    3.11    virtual void newFile();
    3.12    ///Callback for 'FileOpen' action.