[Lemon-commits] ladanyi: r3373 - glemon/branches/akos
Lemon SVN
svn at lemon.cs.elte.hu
Thu Nov 8 18:51:17 CET 2007
Author: ladanyi
Date: Thu Nov 8 18:51:17 2007
New Revision: 3373
Modified:
glemon/branches/akos/graph_displayer_canvas.cc
glemon/branches/akos/main_win.cc
glemon/branches/akos/main_win.h
Log:
Ported r3194 from trunk.
Modified: glemon/branches/akos/graph_displayer_canvas.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas.cc (original)
+++ glemon/branches/akos/graph_displayer_canvas.cc Thu Nov 8 18:51:17 2007
@@ -345,108 +345,113 @@
void GraphDisplayerCanvas::reDesignGraph()
{
- double max_coord=50000;
- double min_dist=20;
- double init_vector_length=25;
-
- if(!was_redesigned)
+ NodeIt firstnode((mytab.mapstorage).graph);
+ //is it not an empty graph?
+ if(firstnode!=INVALID)
{
- NodeIt i((mytab.mapstorage).graph);
+ double max_coord=50000;
+ double min_dist=20;
+ double init_vector_length=25;
- dim2::Point<double> init(init_vector_length*rnd(),
- init_vector_length*rnd());
- moveNode(init.x, init.y, nodesmap[i], i);
- was_redesigned=true;
- }
+ if(!was_redesigned)
+ {
+ NodeIt i((mytab.mapstorage).graph);
- double attraction;
- double propulsation;
- int iterations;
+ dim2::Point<double> init(init_vector_length*rnd(),
+ init_vector_length*rnd());
+ moveNode(init.x, init.y, nodesmap[i], i);
+ was_redesigned=true;
+ }
- (mytab.mapstorage).get_design_data(attraction, propulsation, iterations);
+ double attraction;
+ double propulsation;
+ int iterations;
- //iteration counter
- for(int l=0;l<iterations;l++)
- {
- Graph::NodeMap<double> x(mytab.mapstorage.graph);
- Graph::NodeMap<double> y(mytab.mapstorage.graph);
- XYMap<Graph::NodeMap<double> > actual_forces;
- actual_forces.setXMap(x);
- actual_forces.setYMap(y);
+ (mytab.mapstorage).get_design_data(attraction, propulsation, iterations);
- //count actual force for each nodes
- for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
+ //iteration counter
+ for(int l=0;l<iterations;l++)
{
- //propulsation of nodes
- for (NodeIt j((mytab.mapstorage).graph); j!=INVALID; ++j)
+ Graph::NodeMap<double> x(mytab.mapstorage.graph);
+ Graph::NodeMap<double> y(mytab.mapstorage.graph);
+ XYMap<Graph::NodeMap<double> > actual_forces;
+ actual_forces.setXMap(x);
+ actual_forces.setYMap(y);
+
+ //count actual force for each nodes
+ for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
{
- if(i!=j)
+ //propulsation of nodes
+ for (NodeIt j((mytab.mapstorage).graph); j!=INVALID; ++j)
{
- lemon::dim2::Point<double> delta =
- (mytab.mapstorage.getNodeCoords(i)-
- mytab.mapstorage.getNodeCoords(j));
-
- const double length_sqr=std::max(delta.normSquare(),min_dist);
-
- //normalize vector
- delta/=sqrt(length_sqr);
-
- //calculating propulsation strength
- //greater distance menas smaller propulsation strength
- delta*=propulsation/length_sqr;
+ if(i!=j)
+ {
+ lemon::dim2::Point<double> delta =
+ (mytab.mapstorage.getNodeCoords(i)-
+ mytab.mapstorage.getNodeCoords(j));
+
+ const double length_sqr=std::max(delta.normSquare(),min_dist);
+
+ //normalize vector
+ delta/=sqrt(length_sqr);
+
+ //calculating propulsation strength
+ //greater distance menas smaller propulsation strength
+ delta*=propulsation/length_sqr;
- actual_forces.set(i,(actual_forces[i]+delta));
+ actual_forces.set(i,(actual_forces[i]+delta));
+ }
}
- }
- //attraction of nodes, to which actual node is bound
- for(OutEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei)
- {
- lemon::dim2::Point<double> delta =
- (mytab.mapstorage.getNodeCoords(i)-
- mytab.mapstorage.getNodeCoords(mytab.mapstorage.graph.target(ei)));
-
- //calculating attraction strength
- //greater distance means greater strength
- delta*=attraction;
-
- actual_forces.set(i,actual_forces[i]-delta);
- }
- for(InEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei)
- {
- lemon::dim2::Point<double> delta =
- (mytab.mapstorage.getNodeCoords(i)-
- mytab.mapstorage.getNodeCoords(mytab.mapstorage.graph.source(ei)));
-
- //calculating attraction strength
- //greater distance means greater strength
- delta*=attraction;
+ //attraction of nodes, to which actual node is bound
+ for(OutEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei)
+ {
+ lemon::dim2::Point<double> delta =
+ (mytab.mapstorage.getNodeCoords(i)-
+ mytab.mapstorage.getNodeCoords(mytab.mapstorage.graph.target(ei)));
+
+ //calculating attraction strength
+ //greater distance means greater strength
+ delta*=attraction;
+
+ actual_forces.set(i,actual_forces[i]-delta);
+ }
+ for(InEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei)
+ {
+ lemon::dim2::Point<double> delta =
+ (mytab.mapstorage.getNodeCoords(i)-
+ mytab.mapstorage.getNodeCoords(mytab.mapstorage.graph.source(ei)));
+
+ //calculating attraction strength
+ //greater distance means greater strength
+ delta*=attraction;
- actual_forces.set(i,actual_forces[i]-delta);
- }
- }
- for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
- {
- if((mytab.mapstorage.getNodeCoords(i).x)+actual_forces[i].x>max_coord)
- {
- actual_forces[i].x=max_coord-(mytab.mapstorage.getNodeCoords(i).x);
- std::cout << "Correction! " << ((mytab.mapstorage.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
- }
- else if((mytab.mapstorage.getNodeCoords(i).x)+actual_forces[i].x<(0-max_coord))
- {
- actual_forces[i].x=0-max_coord-(mytab.mapstorage.getNodeCoords(i).x);
- std::cout << "Correction! " << ((mytab.mapstorage.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
+ actual_forces.set(i,actual_forces[i]-delta);
+ }
}
- if((mytab.mapstorage.getNodeCoords(i).y)+actual_forces[i].y>max_coord)
+ for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
{
- actual_forces[i].y=max_coord-((mytab.mapstorage).getNodeCoords(i).y);
- std::cout << "Correction! " << (((mytab.mapstorage).getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
- }
- else if((mytab.mapstorage.getNodeCoords(i).y)+actual_forces[i].y<(0-max_coord))
- {
- actual_forces[i].y=0-max_coord-((mytab.mapstorage).getNodeCoords(i).y);
- std::cout << "Correction! " << (((mytab.mapstorage).getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
+ if(((mytab.mapstorage).getNodeCoords(i).x)+actual_forces[i].x>max_coord)
+ {
+ actual_forces[i].x=max_coord-((mytab.mapstorage).getNodeCoords(i).x);
+ std::cout << "Correction! " << (((mytab.mapstorage).getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
+ }
+ else if(((mytab.mapstorage).getNodeCoords(i).x)+actual_forces[i].x<(0-max_coord))
+ {
+ actual_forces[i].x=0-max_coord-((mytab.mapstorage).getNodeCoords(i).x);
+ std::cout << "Correction! " << (((mytab.mapstorage).getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
+ }
+ if(((mytab.mapstorage).getNodeCoords(i).y)+actual_forces[i].y>max_coord)
+ {
+ actual_forces[i].y=max_coord-((mytab.mapstorage).getNodeCoords(i).y);
+ std::cout << "Correction! " << (((mytab.mapstorage).getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
+ }
+ else if(((mytab.mapstorage).getNodeCoords(i).y)+actual_forces[i].y<(0-max_coord))
+ {
+ actual_forces[i].y=0-max_coord-((mytab.mapstorage).getNodeCoords(i).y);
+ std::cout << "Correction! " << (((mytab.mapstorage).getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
+ }
+ moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
}
- moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
}
}
}
Modified: glemon/branches/akos/main_win.cc
==============================================================================
--- glemon/branches/akos/main_win.cc (original)
+++ glemon/branches/akos/main_win.cc Thu Nov 8 18:51:17 2007
@@ -233,6 +233,7 @@
if (toolbar)
{
static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
+ static_cast<Gtk::Toolbar*>(toolbar)->set_tooltips(true);
//hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET);
table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
@@ -273,8 +274,32 @@
table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
- tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
- tooltips.enable();
+ tooltips=Gtk::manage(new Gtk::Tooltips());
+ if(tooltips)
+ {
+ tooltips->set_tip(*zoom_track, "If on, edge widths and node radiuses are constant, independent from zooming");
+ tooltips->set_tip(*auto_scale, "If on, glemon automatically determines the size of edges and nodes");
+ tooltips->set_tip(*radius_size, "Sets maximum node radius, if auto-scale is off");
+ tooltips->set_tip(*edge_width, "Sets maximum edge width, if auto-scale is off");
+
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/FileNew"))->set_tooltip(*tooltips, "Inserts new tab");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/FileOpen"))->set_tooltip(*tooltips, "Lets you open a file");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/FileSave"))->set_tooltip(*tooltips, "Saves the graph on the active tab");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/Close"))->set_tooltip(*tooltips, "Closes the active tab");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomIn"))->set_tooltip(*tooltips, "Zoom in the graph");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomOut"))->set_tooltip(*tooltips, "Zoom out the graph");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoom100"))->set_tooltip(*tooltips, "Shows actual size of graph");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomFit"))->set_tooltip(*tooltips, "Fits graph into window");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/MoveItem"))->set_tooltip(*tooltips, "Moves the clicked item (edge/node)");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/CreateNode"))->set_tooltip(*tooltips, "Adds new node");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/CreateEdge"))->set_tooltip(*tooltips, "Lets you create new edge");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/EraseItem"))->set_tooltip(*tooltips, "Erases the clicked item (edge/node)");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/EditEdgeMap"))->set_tooltip(*tooltips, "Lets you edit the values written on the items");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/AddMap"))->set_tooltip(*tooltips, "Adds edge/nodemap");
+ static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/DesignGraph"))->set_tooltip(*tooltips, "Redesigns your graph, supposing elastic edges and propulsation of nodes.");
+
+ tooltips->enable();
+ }
active_tab=-1;
notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab));
Modified: glemon/branches/akos/main_win.h
==============================================================================
--- glemon/branches/akos/main_win.h (original)
+++ glemon/branches/akos/main_win.h Thu Nov 8 18:51:17 2007
@@ -117,7 +117,7 @@
void readFile(const std::string &);
///Tooltips
- Gtk::Tooltips tooltips;
+ Gtk::Tooltips * tooltips;
//Call-backs of buttons
More information about the Lemon-commits
mailing list