Changeset 148:5adf29662354 in glemon0.x
 Timestamp:
 09/18/06 18:02:20 (13 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/glemon/trunk@2949
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

graph_displayer_canvasevent.cc
r147 r148 102 102 } 103 103 } 104 switch(e>button.button) 105 { 106 case 3: 107 isbutton=3; 108 break; 109 default: 110 isbutton=1; 111 break; 112 } 104 isbutton=e>button.button; 113 105 break; 114 106 case GDK_BUTTON_RELEASE: … … 192 184 193 185 XY arrow_pos; 194 if(isbutton==3) 195 arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, false); 196 else 197 arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, true); 186 arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton); 198 187 199 188 mytab.mapstorage.arrow_pos.set(ei, arrow_pos); … … 217 206 218 207 XY arrow_pos; 219 if(isbutton==3) 220 arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, false); 221 else 222 arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, true); 208 arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton); 223 209 224 210 mytab.mapstorage.arrow_pos.set(ei, arrow_pos); … … 238 224 } 239 225 240 XY GraphDisplayerCanvas::calcArrowPos(XY moved_node_1, XY moved_node_2, XY fix_node, XY old_arrow_pos, bool move) 241 { 242 if(!move) 243 { 244 return XY((moved_node_2.x + fix_node.x) / 2.0, (moved_node_2.y + fix_node.y) / 2.0); 245 } 246 else 247 { 248 ////////////////////////////////////////////////////////////////////////////////////////////////////// 249 /////////// keeps shapewith scalar multiplication  version 2. 250 ////////////////////////////////////////////////////////////////////////////////////////////////////// 251 252 //old vector from one to the other node  a 253 xy<double> a_v(moved_node_1.xfix_node.x,moved_node_1.yfix_node.y); 254 //new vector from one to the other node  b 255 xy<double> b_v(moved_node_2.xfix_node.x,moved_node_2.yfix_node.y); 256 257 double absa=sqrt(a_v.normSquare()); 258 double absb=sqrt(b_v.normSquare()); 259 260 if ((absa == 0.0)  (absb == 0.0)) 226 XY GraphDisplayerCanvas::calcArrowPos(XY moved_node_1, XY moved_node_2, XY fix_node, XY old_arrow_pos, int move_code) 227 { 228 switch(move_code) 261 229 { 230 case 1: 231 return XY((moved_node_2.x + fix_node.x) / 2.0, (moved_node_2.y + fix_node.y) / 2.0); 232 break; 233 case 2: 262 234 return old_arrow_pos; 235 break; 236 case 3: 237 { 238 ////////////////////////////////////////////////////////////////////////////////////////////////////// 239 /////////// keeps shapewith scalar multiplication  version 2. 240 ////////////////////////////////////////////////////////////////////////////////////////////////////// 241 242 //old vector from one to the other node  a 243 xy<double> a_v(moved_node_1.xfix_node.x,moved_node_1.yfix_node.y); 244 //new vector from one to the other node  b 245 xy<double> b_v(moved_node_2.xfix_node.x,moved_node_2.yfix_node.y); 246 247 double absa=sqrt(a_v.normSquare()); 248 double absb=sqrt(b_v.normSquare()); 249 250 if ((absa == 0.0)  (absb == 0.0)) 251 { 252 return old_arrow_pos; 253 } 254 else 255 { 256 //old vector from one node to the breakpoint  c 257 xy<double> c_v(old_arrow_pos.xfix_node.x,old_arrow_pos.yfix_node.y); 258 259 //unit vector with the same direction to a_v 260 xy<double> a_v_u(a_v.x/absa,a_v.y/absa); 261 262 //normal vector of unit vector with the same direction to a_v 263 xy<double> a_v_u_n(((1)*a_v_u.y),a_v_u.x); 264 265 //unit vector with the same direction to b_v 266 xy<double> b_v_u(b_v.x/absb,b_v.y/absb); 267 268 //normal vector of unit vector with the same direction to b_v 269 xy<double> b_v_u_n(((1)*b_v_u.y),b_v_u.x); 270 271 //vector c in a_v_u and a_v_u_n coordinate system 272 xy<double> c_a(c_v*a_v_u,c_v*a_v_u_n); 273 274 //new vector from one node to the breakpoint  d  we have to calculate this one 275 xy<double> d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n); 276 277 return XY(d_v.x+fix_node.x,d_v.y+fix_node.y); 278 } 279 break; 280 } 281 default: 282 break; 263 283 } 264 else 265 { 266 //old vector from one node to the breakpoint  c 267 xy<double> c_v(old_arrow_pos.xfix_node.x,old_arrow_pos.yfix_node.y); 268 269 //unit vector with the same direction to a_v 270 xy<double> a_v_u(a_v.x/absa,a_v.y/absa); 271 272 //normal vector of unit vector with the same direction to a_v 273 xy<double> a_v_u_n(((1)*a_v_u.y),a_v_u.x); 274 275 //unit vector with the same direction to b_v 276 xy<double> b_v_u(b_v.x/absb,b_v.y/absb); 277 278 //normal vector of unit vector with the same direction to b_v 279 xy<double> b_v_u_n(((1)*b_v_u.y),b_v_u.x); 280 281 //vector c in a_v_u and a_v_u_n coordinate system 282 xy<double> c_a(c_v*a_v_u,c_v*a_v_u_n); 283 284 //new vector from one node to the breakpoint  d  we have to calculate this one 285 xy<double> d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n); 286 287 return XY(d_v.x+fix_node.x,d_v.y+fix_node.y); 288 } 289 } 290 } 284 } 285 291 286 292 287 bool GraphDisplayerCanvas::createNodeEventHandler(GdkEvent* e) 
graph_displayer_canvas.h
r147 r148 379 379 NoteBookTab & mytab; 380 380 381 XY calcArrowPos(XY, XY, XY, XY, bool);381 XY calcArrowPos(XY, XY, XY, XY, int); 382 382 }; 383 383
Note: See TracChangeset
for help on using the changeset viewer.