Changeset 190:2cac5b936a2b in glemon-0.x
- Timestamp:
- 02/20/07 18:45:44 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@3194
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
graph_displayer_canvas.cc
r187 r190 324 324 void GraphDisplayerCanvas::reDesignGraph() 325 325 { 326 double max_coord=50000; 327 double min_dist=20; 328 double init_vector_length=25; 329 330 if(!was_redesigned) 331 { 332 NodeIt i((mytab.mapstorage).graph); 333 334 dim2::Point<double> init(init_vector_length*rnd(), 335 init_vector_length*rnd()); 336 moveNode(init.x, init.y, nodesmap[i], i); 337 was_redesigned=true; 338 } 339 340 double attraction; 341 double propulsation; 342 int iterations; 343 344 (mytab.mapstorage).get_design_data(attraction, propulsation, iterations); 345 346 //iteration counter 347 for(int l=0;l<iterations;l++) 348 { 349 Graph::NodeMap<double> x(mytab.mapstorage.graph); 350 Graph::NodeMap<double> y(mytab.mapstorage.graph); 351 XYMap<Graph::NodeMap<double> > actual_forces; 352 actual_forces.setXMap(x); 353 actual_forces.setYMap(y); 354 355 //count actual force for each nodes 356 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 357 { 358 //propulsation of nodes 359 for (NodeIt j((mytab.mapstorage).graph); j!=INVALID; ++j) 360 { 361 if(i!=j) 326 NodeIt firstnode((mytab.mapstorage).graph); 327 //is it not an empty graph? 328 if(firstnode!=INVALID) 329 { 330 double max_coord=50000; 331 double min_dist=20; 332 double init_vector_length=25; 333 334 if(!was_redesigned) 335 { 336 NodeIt i((mytab.mapstorage).graph); 337 338 dim2::Point<double> init(init_vector_length*rnd(), 339 init_vector_length*rnd()); 340 moveNode(init.x, init.y, nodesmap[i], i); 341 was_redesigned=true; 342 } 343 344 double attraction; 345 double propulsation; 346 int iterations; 347 348 (mytab.mapstorage).get_design_data(attraction, propulsation, iterations); 349 350 //iteration counter 351 for(int l=0;l<iterations;l++) 352 { 353 Graph::NodeMap<double> x(mytab.mapstorage.graph); 354 Graph::NodeMap<double> y(mytab.mapstorage.graph); 355 XYMap<Graph::NodeMap<double> > actual_forces; 356 actual_forces.setXMap(x); 357 actual_forces.setYMap(y); 358 359 //count actual force for each nodes 360 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 361 { 362 //propulsation of nodes 363 for (NodeIt j((mytab.mapstorage).graph); j!=INVALID; ++j) 364 { 365 if(i!=j) 366 { 367 lemon::dim2::Point<double> delta = 368 ((mytab.mapstorage).coords[i]- 369 (mytab.mapstorage).coords[j]); 370 371 const double length_sqr=std::max(delta.normSquare(),min_dist); 372 373 //normalize vector 374 delta/=sqrt(length_sqr); 375 376 //calculating propulsation strength 377 //greater distance menas smaller propulsation strength 378 delta*=propulsation/length_sqr; 379 380 actual_forces.set(i,(actual_forces[i]+delta)); 381 } 382 } 383 //attraction of nodes, to which actual node is bound 384 for(OutEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei) 362 385 { 363 386 lemon::dim2::Point<double> delta = 364 387 ((mytab.mapstorage).coords[i]- 365 (mytab.mapstorage).coords[j]); 366 367 const double length_sqr=std::max(delta.normSquare(),min_dist); 368 369 //normalize vector 370 delta/=sqrt(length_sqr); 371 372 //calculating propulsation strength 373 //greater distance menas smaller propulsation strength 374 delta*=propulsation/length_sqr; 375 376 actual_forces.set(i,(actual_forces[i]+delta)); 377 } 378 } 379 //attraction of nodes, to which actual node is bound 380 for(OutEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei) 381 { 382 lemon::dim2::Point<double> delta = 383 ((mytab.mapstorage).coords[i]- 384 (mytab.mapstorage).coords[mytab.mapstorage. 385 graph.target(ei)]); 388 (mytab.mapstorage).coords[mytab.mapstorage. 389 graph.target(ei)]); 386 390 387 //calculating attraction strength388 //greater distance means greater strength389 delta*=attraction;391 //calculating attraction strength 392 //greater distance means greater strength 393 delta*=attraction; 390 394 391 actual_forces.set(i,actual_forces[i]-delta);392 393 for(InEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei)394 395 396 ((mytab.mapstorage).coords[i]-397 (mytab.mapstorage).coords[mytab.mapstorage.398 graph.source(ei)]);395 actual_forces.set(i,actual_forces[i]-delta); 396 } 397 for(InEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei) 398 { 399 lemon::dim2::Point<double> delta = 400 ((mytab.mapstorage).coords[i]- 401 (mytab.mapstorage).coords[mytab.mapstorage. 402 graph.source(ei)]); 399 403 400 //calculating attraction strength401 //greater distance means greater strength402 delta*=attraction;404 //calculating attraction strength 405 //greater distance means greater strength 406 delta*=attraction; 403 407 404 actual_forces.set(i,actual_forces[i]-delta); 405 } 406 } 407 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 408 { 409 if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x>max_coord) 410 { 411 actual_forces[i].x=max_coord-((mytab.mapstorage).coords[i].x); 412 std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl; 413 } 414 else if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x<(0-max_coord)) 415 { 416 actual_forces[i].x=0-max_coord-((mytab.mapstorage).coords[i].x); 417 std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl; 418 } 419 if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y>max_coord) 420 { 421 actual_forces[i].y=max_coord-((mytab.mapstorage).coords[i].y); 422 std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl; 423 } 424 else if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y<(0-max_coord)) 425 { 426 actual_forces[i].y=0-max_coord-((mytab.mapstorage).coords[i].y); 427 std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl; 428 } 429 moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i); 430 } 431 } 432 } 433 408 actual_forces.set(i,actual_forces[i]-delta); 409 } 410 } 411 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 412 { 413 if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x>max_coord) 414 { 415 actual_forces[i].x=max_coord-((mytab.mapstorage).coords[i].x); 416 std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl; 417 } 418 else if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x<(0-max_coord)) 419 { 420 actual_forces[i].x=0-max_coord-((mytab.mapstorage).coords[i].x); 421 std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl; 422 } 423 if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y>max_coord) 424 { 425 actual_forces[i].y=max_coord-((mytab.mapstorage).coords[i].y); 426 std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl; 427 } 428 else if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y<(0-max_coord)) 429 { 430 actual_forces[i].y=0-max_coord-((mytab.mapstorage).coords[i].y); 431 std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl; 432 } 433 moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i); 434 } 435 } 436 } 437 } 438 -
main_win.cc
r184 r190 230 230 { 231 231 static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS); 232 static_cast<Gtk::Toolbar*>(toolbar)->set_tooltips(true); 232 233 //hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET); 233 234 … … 270 271 table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK); 271 272 272 tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node"); 273 tooltips.enable(); 273 tooltips=Gtk::manage(new Gtk::Tooltips()); 274 if(tooltips) 275 { 276 tooltips->set_tip(*zoom_track, "If on, edge widths and node radiuses are constant, independent from zooming"); 277 tooltips->set_tip(*auto_scale, "If on, glemon automatically determines the size of edges and nodes"); 278 tooltips->set_tip(*radius_size, "Sets maximum node radius, if auto-scale is off"); 279 tooltips->set_tip(*edge_width, "Sets maximum edge width, if auto-scale is off"); 280 281 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/FileNew"))->set_tooltip(*tooltips, "Inserts new tab"); 282 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/FileOpen"))->set_tooltip(*tooltips, "Lets you open a file"); 283 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/FileSave"))->set_tooltip(*tooltips, "Saves the graph on the active tab"); 284 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/Close"))->set_tooltip(*tooltips, "Closes the active tab"); 285 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomIn"))->set_tooltip(*tooltips, "Zoom in the graph"); 286 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomOut"))->set_tooltip(*tooltips, "Zoom out the graph"); 287 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoom100"))->set_tooltip(*tooltips, "Shows actual size of graph"); 288 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomFit"))->set_tooltip(*tooltips, "Fits graph into window"); 289 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/MoveItem"))->set_tooltip(*tooltips, "Moves the clicked item (edge/node)"); 290 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/CreateNode"))->set_tooltip(*tooltips, "Adds new node"); 291 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/CreateEdge"))->set_tooltip(*tooltips, "Lets you create new edge"); 292 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/EraseItem"))->set_tooltip(*tooltips, "Erases the clicked item (edge/node)"); 293 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/EditEdgeMap"))->set_tooltip(*tooltips, "Lets you edit the values written on the items"); 294 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/AddMap"))->set_tooltip(*tooltips, "Adds edge/nodemap"); 295 static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/DesignGraph"))->set_tooltip(*tooltips, "Redesigns your graph, supposing elastic edges and propulsation of nodes."); 296 297 tooltips->enable(); 298 } 274 299 275 300 active_tab=-1; -
main_win.h
r184 r190 118 118 119 119 ///Tooltips 120 Gtk::Tooltips tooltips;120 Gtk::Tooltips * tooltips; 121 121 122 122 //Call-backs of buttons
Note: See TracChangeset
for help on using the changeset viewer.