[Lemon-commits] [lemon_svn] hegyi: r2389 - hugo/trunk/gui
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:52:17 CET 2006
Author: hegyi
Date: Tue Nov 29 20:31:58 2005
New Revision: 2389
Modified:
hugo/trunk/gui/graph_displayer_canvas-edge.cc
hugo/trunk/gui/graph_displayer_canvas-event.cc
hugo/trunk/gui/graph_displayer_canvas-node.cc
hugo/trunk/gui/graph_displayer_canvas.cc
hugo/trunk/gui/graph_displayer_canvas.h
hugo/trunk/gui/main_win.cc
hugo/trunk/gui/main_win.h
hugo/trunk/gui/map_win.cc
hugo/trunk/gui/map_win.h
hugo/trunk/gui/mapstorage.cc
hugo/trunk/gui/mapstorage.h
hugo/trunk/gui/mw-mapselector.cc
hugo/trunk/gui/new_map_win.cc
hugo/trunk/gui/new_map_win.h
Log:
Structure of GUI is now more clear-cut than before.
Modified: hugo/trunk/gui/graph_displayer_canvas-edge.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas-edge.cc (original)
+++ hugo/trunk/gui/graph_displayer_canvas-edge.cc Tue Nov 29 20:31:58 2005
@@ -8,11 +8,11 @@
min=edge_property_defaults[E_WIDTH];
max=edge_property_defaults[E_WIDTH];
- Graph::EdgeMap<double> actual_map(mapstorage.graph,edge_property_defaults[E_WIDTH]);
+ Graph::EdgeMap<double> actual_map((mainwin.mapstorage).graph,edge_property_defaults[E_WIDTH]);
if(edge==INVALID)
{
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
double v=fabs(actual_map[i]);
int w;
@@ -44,13 +44,13 @@
Graph::EdgeMap<double> * actual_map;
double min, max;
- min=mapstorage.minOfEdgeMap(mapname);
- max=mapstorage.maxOfEdgeMap(mapname);
- actual_map=(mapstorage.edgemap_storage)[mapname];
+ min=(mainwin.mapstorage).minOfEdgeMap(mapname);
+ max=(mainwin.mapstorage).maxOfEdgeMap(mapname);
+ actual_map=((mainwin.mapstorage).edgemap_storage)[mapname];
if(edge==INVALID)
{
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
double v=fabs((*actual_map)[i]);
int w;
@@ -83,16 +83,16 @@
//the minimum of the nodemap to the range of
//green in RGB
Graph::EdgeMap<double> * actual_map;
- actual_map=(mapstorage.edgemap_storage)[mapname];
+ actual_map=((mainwin.mapstorage).edgemap_storage)[mapname];
double max, min;
- max=mapstorage.maxOfEdgeMap(mapname);
- min=mapstorage.minOfEdgeMap(mapname);
+ max=(mainwin.mapstorage).maxOfEdgeMap(mapname);
+ min=(mainwin.mapstorage).minOfEdgeMap(mapname);
if(edge==INVALID)
{
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
double w=(*actual_map)[i];
@@ -134,7 +134,7 @@
//function maps the range of the maximum and
//the minimum of the nodemap to the range of
//green in RGB
- Graph::EdgeMap<double> actual_map(mapstorage.graph,edge_property_defaults[E_COLOR]);
+ Graph::EdgeMap<double> actual_map((mainwin.mapstorage).graph,edge_property_defaults[E_COLOR]);
double max, min;
@@ -143,7 +143,7 @@
if(edge==INVALID)
{
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
double w=actual_map[i];
@@ -188,10 +188,10 @@
if(edge==INVALID)
{
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
edgemap_to_edit=mapname;
- double number=(*(mapstorage.edgemap_storage)[mapname])[i];
+ double number=(*((mainwin.mapstorage).edgemap_storage)[mapname])[i];
std::ostringstream ostr;
ostr << number;
@@ -202,7 +202,7 @@
}
else
{
- double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
+ double number=(*((mainwin.mapstorage).edgemap_storage)[mapname])[edge];
std::ostringstream ostr;
ostr << number;
@@ -223,7 +223,7 @@
if(edge==INVALID)
{
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
edgemap_to_edit="";
edgetextmap[i]->property_text().set_value("");
Modified: hugo/trunk/gui/graph_displayer_canvas-event.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas-event.cc (original)
+++ hugo/trunk/gui/graph_displayer_canvas-event.cc Tue Nov 29 20:31:58 2005
@@ -94,7 +94,7 @@
active_item=(get_item_at(clicked_x, clicked_y));
active_node=INVALID;
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
if(nodesmap[i]==active_item)
{
@@ -125,7 +125,7 @@
//we only have to do sg. if the mouse button is pressed AND the click was on a node that was found in the set of nodes
if(active_node!=INVALID)
{
- mapstorage.modified = true;
+ (mainwin.mapstorage).modified = true;
//new coordinates will be the old values,
//because the item will be moved to the
@@ -144,52 +144,52 @@
nodetextmap[active_node]->move(dx, dy);
// the new coordinates of the centre of the node
- double coord_x = new_x - (clicked_x - mapstorage.coords[active_node].x);
- double coord_y = new_y - (clicked_y - mapstorage.coords[active_node].y);
+ double coord_x = new_x - (clicked_x - (mainwin.mapstorage).coords[active_node].x);
+ double coord_y = new_y - (clicked_y - (mainwin.mapstorage).coords[active_node].y);
clicked_x=new_x;
clicked_y=new_y;
// write back the new coordinates to the coords map
- mapstorage.coords.set(active_node, xy<double>(coord_x, coord_y));
+ (mainwin.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));
// reposition the coordinates text
std::ostringstream ostr;
ostr << "(" <<
- mapstorage.coords[active_node].x << ", " <<
- mapstorage.coords[active_node].y << ")";
+ (mainwin.mapstorage).coords[active_node].x << ", " <<
+ (mainwin.mapstorage).coords[active_node].y << ")";
double radius =
(nodesmap[active_node]->property_x2().get_value() -
nodesmap[active_node]->property_x1().get_value()) / 2.0;
if (coord_text)
{
coord_text->property_text().set_value(ostr.str());
- coord_text->property_x().set_value(mapstorage.coords[active_node].x +
+ coord_text->property_x().set_value((mainwin.mapstorage).coords[active_node].x +
radius);
- coord_text->property_y().set_value(mapstorage.coords[active_node].y -
+ coord_text->property_y().set_value((mainwin.mapstorage).coords[active_node].y -
radius);
}
else
{
coord_text = new Gnome::Canvas::Text(
displayed_graph,
- mapstorage.coords[active_node].x + radius,
- mapstorage.coords[active_node].y - radius,
+ (mainwin.mapstorage).coords[active_node].x + radius,
+ (mainwin.mapstorage).coords[active_node].y - radius,
ostr.str());
coord_text->property_fill_color().set_value("black");
coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
}
//all the edges connected to the moved point has to be redrawn
- for(OutEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei)
+ for(OutEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
{
Gnome::Canvas::Points coos;
double x1, x2, y1, y2;
- nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);
+ nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
- nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);
+ nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
if(isbutton==3)
@@ -208,15 +208,15 @@
edgetextmap[ei]->property_y().set_value(text_pos.y);
}
- for(InEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei)
+ for(InEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
{
Gnome::Canvas::Points coos;
double x1, x2, y1, y2;
- nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);
+ nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
- nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);
+ nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
if(isbutton==3)
@@ -256,33 +256,33 @@
}
case GDK_BUTTON_RELEASE:
- mapstorage.modified = true;
+ (mainwin.mapstorage).modified = true;
isbutton=1;
- active_node=mapstorage.graph.addNode();
+ active_node=(mainwin.mapstorage).graph.addNode();
//initiating values corresponding to new node in maps
window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
// update coordinates
- mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y));
+ (mainwin.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y));
// update all other maps
for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
- mapstorage.nodemap_storage.begin(); it !=
- mapstorage.nodemap_storage.end(); ++it)
+ (mainwin.mapstorage).nodemap_storage.begin(); it !=
+ (mainwin.mapstorage).nodemap_storage.end(); ++it)
{
if ((it->first != "coordinates_x") &&
(it->first != "coordinates_y"))
{
(*(it->second))[active_node] =
- mapstorage.nodemap_default[it->first];
+ (mainwin.mapstorage).nodemap_default[it->first];
}
}
// increment the id map's default value
- mapstorage.nodemap_default["id"] += 1.0;
+ (mainwin.mapstorage).nodemap_default["id"] += 1.0;
nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
@@ -301,7 +301,8 @@
nodetextmap[active_node]->property_fill_color().set_value("darkblue");
nodetextmap[active_node]->raise_to_top();
- mapwin.updateNode(active_node);
+// mapwin.updateNode(active_node);
+ propertyUpdate(active_node);
isbutton=0;
target_item=NULL;
@@ -331,7 +332,7 @@
active_item=(get_item_at(clicked_x, clicked_y));
active_node=INVALID;
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
if(nodesmap[i]==active_item)
{
@@ -360,7 +361,7 @@
window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
target_item=(get_item_at(clicked_x, clicked_y));
Node target_node=INVALID;
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
if(nodesmap[i]==target_item)
{
@@ -372,26 +373,26 @@
{
if(target_node!=active_node)
{
- mapstorage.modified = true;
+ (mainwin.mapstorage).modified = true;
*(nodesmap[target_node]) <<
Gnome::Canvas::Properties::fill_color("red");
//creating new edge
- active_edge=mapstorage.graph.addEdge(active_node,
+ active_edge=(mainwin.mapstorage).graph.addEdge(active_node,
target_node);
// update maps
for (std::map<std::string,
Graph::EdgeMap<double>*>::const_iterator it =
- mapstorage.edgemap_storage.begin(); it !=
- mapstorage.edgemap_storage.end(); ++it)
+ (mainwin.mapstorage).edgemap_storage.begin(); it !=
+ (mainwin.mapstorage).edgemap_storage.end(); ++it)
{
(*(it->second))[active_edge] =
- mapstorage.edgemap_default[it->first];
+ (mainwin.mapstorage).edgemap_default[it->first];
}
// increment the id map's default value
- mapstorage.edgemap_default["id"] += 1.0;
+ (mainwin.mapstorage).edgemap_default["id"] += 1.0;
//calculating coordinates of new edge
Gnome::Canvas::Points coos;
@@ -423,7 +424,8 @@
edgetextmap[active_edge]->raise_to_top();
//updating its properties
- mapwin.updateEdge(active_edge);
+// mapwin.updateEdge(active_edge);
+ propertyUpdate(active_edge);
}
else
{
@@ -478,7 +480,7 @@
active_node=INVALID;
active_edge=INVALID;
//was it a node?
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
if(nodesmap[i]==active_item)
{
@@ -488,7 +490,7 @@
//or was it an edge?
if(active_node==INVALID)
{
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
if(edgesmap[i]==active_item)
{
@@ -514,16 +516,16 @@
//a node was found
if(active_node!=INVALID)
{
- mapstorage.modified = true;
+ (mainwin.mapstorage).modified = true;
std::set<Graph::Edge> edges_to_delete;
- for(OutEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e)
+ for(OutEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
{
edges_to_delete.insert(e);
}
- for(InEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e)
+ for(InEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
{
edges_to_delete.insert(e);
}
@@ -587,7 +589,7 @@
active_item=(get_item_at(clicked_x, clicked_y));
//find the activated item between texts
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
//at the same time only one can be active
if(edgetextmap[i]==active_item)
@@ -599,7 +601,7 @@
//if it was not between texts, search for it between edges
if(clicked_edge==INVALID)
{
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
//at the same time only one can be active
if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item))
@@ -622,7 +624,7 @@
active_edge=clicked_edge;
//create a dialog
- Gtk::Dialog dialog("Edit value", *parentwin, true);
+ Gtk::Dialog dialog("Edit value", mainwin, true);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
Gtk::VBox* vbox = dialog.get_vbox();
@@ -639,14 +641,15 @@
break;
case Gtk::RESPONSE_ACCEPT:
double new_value = spin.get_value();
- (*mapstorage.edgemap_storage[edgemap_to_edit])[active_edge] =
+ (*(mainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
new_value;
std::ostringstream ostr;
ostr << new_value;
edgetextmap[active_edge]->property_text().set_value(
ostr.str());
//mapwin.updateEdge(active_edge);
- mapwin.updateEdge(Edge(INVALID));
+// mapwin.updateEdge(Edge(INVALID));
+ propertyUpdate(Edge(INVALID));
}
}
}
@@ -674,7 +677,7 @@
active_item=(get_item_at(clicked_x, clicked_y));
//find the activated item between texts
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
//at the same time only one can be active
if(nodetextmap[i]==active_item)
@@ -686,7 +689,7 @@
//if there was not, search for it between nodes
if(clicked_node==INVALID)
{
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
//at the same time only one can be active
if(nodesmap[i]==active_item)
@@ -709,7 +712,7 @@
active_node=clicked_node;
//create a dialog
- Gtk::Dialog dialog("Edit value", *parentwin, true);
+ Gtk::Dialog dialog("Edit value", mainwin, true);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
Gtk::VBox* vbox = dialog.get_vbox();
@@ -726,14 +729,15 @@
break;
case Gtk::RESPONSE_ACCEPT:
double new_value = spin.get_value();
- (*mapstorage.nodemap_storage[nodemap_to_edit])[active_node] =
+ (*(mainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
new_value;
std::ostringstream ostr;
ostr << new_value;
nodetextmap[active_node]->property_text().set_value(
ostr.str());
//mapwin.updateNode(active_node);
- mapwin.updateNode(Node(INVALID));
+// mapwin.updateNode(Node(INVALID));
+ propertyUpdate(Node(INVALID));
}
}
}
@@ -750,14 +754,14 @@
{
delete(nodetextmap[node_to_delete]);
delete(nodesmap[node_to_delete]);
- mapstorage.graph.erase(node_to_delete);
+ (mainwin.mapstorage).graph.erase(node_to_delete);
}
void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete)
{
delete(edgetextmap[edge_to_delete]);
delete(edgesmap[edge_to_delete]);
- mapstorage.graph.erase(edge_to_delete);
+ (mainwin.mapstorage).graph.erase(edge_to_delete);
}
void GraphDisplayerCanvas::textReposition(xy<double> new_place)
@@ -777,7 +781,7 @@
}
else
{
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
if(edgesmap[i]==active_bre)
{
@@ -803,18 +807,18 @@
int GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
{
//create the new map
- Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mapstorage.graph, default_value);
+ Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mainwin.mapstorage).graph, default_value);
//if addition was not successful addEdgeMap returns one.
//cause can be that there is already a map named like the new one
- if(mapstorage.addEdgeMap(mapname,emptr, default_value))
+ if((mainwin.mapstorage).addEdgeMap(mapname,emptr, default_value))
{
return 1;
}
//add it to the list of the displayable maps
- mapwin.registerNewEdgeMap(mapname);
+ mainwin.registerNewEdgeMap(mapname);
//display it
changeEdgeText(mapname);
@@ -825,17 +829,17 @@
int GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
{
//create the new map
- Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mapstorage.graph,default_value);
+ Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mainwin.mapstorage).graph,default_value);
//if addition was not successful addNodeMap returns one.
//cause can be that there is already a map named like the new one
- if(mapstorage.addNodeMap(mapname,emptr, default_value))
+ if((mainwin.mapstorage).addNodeMap(mapname,emptr, default_value))
{
return 1;
}
//add it to the list of the displayable maps
- mapwin.registerNewNodeMap(mapname);
+ mainwin.registerNewNodeMap(mapname);
//display it
changeNodeText(mapname);
Modified: hugo/trunk/gui/graph_displayer_canvas-node.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas-node.cc (original)
+++ hugo/trunk/gui/graph_displayer_canvas-node.cc Tue Nov 29 20:31:58 2005
@@ -6,13 +6,13 @@
{
Graph::NodeMap<double> * actual_map;
double min, max;
- min=mapstorage.minOfNodeMap(mapname);
- max=mapstorage.maxOfNodeMap(mapname);
- actual_map=(mapstorage.nodemap_storage)[mapname];
+ min=(mainwin.mapstorage).minOfNodeMap(mapname);
+ max=(mainwin.mapstorage).maxOfNodeMap(mapname);
+ actual_map=((mainwin.mapstorage).nodemap_storage)[mapname];
if(node==INVALID)
{
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
double v=fabs((*actual_map)[i]);
int w;
@@ -64,11 +64,11 @@
double min, max;
min=node_property_defaults[N_RADIUS];
max=node_property_defaults[N_RADIUS];
- Graph::NodeMap<double> actual_map(mapstorage.graph,node_property_defaults[N_RADIUS]);
+ Graph::NodeMap<double> actual_map((mainwin.mapstorage).graph,node_property_defaults[N_RADIUS]);
if(node==INVALID)
{
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
double v=fabs(actual_map[i]);
int w;
@@ -123,17 +123,17 @@
//green in RGB
Graph::NodeMap<double> * actual_map;
- actual_map=(mapstorage.nodemap_storage)[mapname];
+ actual_map=((mainwin.mapstorage).nodemap_storage)[mapname];
double max, min;
- max=mapstorage.maxOfNodeMap(mapname);
- min=mapstorage.minOfNodeMap(mapname);
+ max=(mainwin.mapstorage).maxOfNodeMap(mapname);
+ min=(mainwin.mapstorage).minOfNodeMap(mapname);
if(node==INVALID)
{
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
Gdk::Color color;
@@ -178,7 +178,7 @@
//the minimum of the nodemap to the range of
//green in RGB
- Graph::NodeMap<double> actual_map(mapstorage.graph,node_property_defaults[N_COLOR]);
+ Graph::NodeMap<double> actual_map((mainwin.mapstorage).graph,node_property_defaults[N_COLOR]);
double max, min;
@@ -188,7 +188,7 @@
if(node==INVALID)
{
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
Gdk::Color color;
@@ -235,11 +235,11 @@
//that is the deleter map
Graph::NodeMap<double> * actual_map=NULL;
- actual_map=(mapstorage.nodemap_storage)[mapname];
+ actual_map=((mainwin.mapstorage).nodemap_storage)[mapname];
if(node==INVALID)
{
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
nodemap_to_edit=mapname;
double number=(*actual_map)[i];
@@ -272,7 +272,7 @@
if(node==INVALID)
{
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
nodemap_to_edit="";
nodetextmap[i]->property_text().set_value("");
Modified: hugo/trunk/gui/graph_displayer_canvas.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.cc (original)
+++ hugo/trunk/gui/graph_displayer_canvas.cc Tue Nov 29 20:31:58 2005
@@ -1,14 +1,12 @@
#include "graph_displayer_canvas.h"
#include <cmath>
-GraphDisplayerCanvas::GraphDisplayerCanvas(MapStorage & ms, MapWin & mw, Gtk::Window * mainwin) :
- nodesmap(ms.graph), edgesmap(ms.graph), edgetextmap(ms.graph),
- nodetextmap(ms.graph), displayed_graph(*(root()), 0, 0), mapstorage(ms),
+GraphDisplayerCanvas::GraphDisplayerCanvas(MainWin & mainw) :
+ nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
+ nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
- edgemap_to_edit(""), mapwin(mw)
+ edgemap_to_edit(""), mainwin(mainw)
{
- parentwin=mainwin;
-
//base event handler is move tool
actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
actual_tool=MOVE;
@@ -20,35 +18,155 @@
GraphDisplayerCanvas::~GraphDisplayerCanvas()
{
- for (NodeIt n(mapstorage.graph); n != INVALID; ++n)
- {
- delete nodesmap[n];
- delete nodetextmap[n];
- }
+ for (NodeIt n((mainwin.mapstorage).graph); n != INVALID; ++n)
+ {
+ delete nodesmap[n];
+ delete nodetextmap[n];
+ }
+
+ for (EdgeIt e((mainwin.mapstorage).graph); e != INVALID; ++e)
+ {
+ delete edgesmap[e];
+ delete edgetextmap[e];
+ }
+}
- for (EdgeIt e(mapstorage.graph); e != INVALID; ++e)
- {
- delete edgesmap[e];
- delete edgetextmap[e];
- }
+void GraphDisplayerCanvas::propertyChange(bool itisedge, int prop)
+{
+ if(itisedge)
+ {
+ propertyUpdate(Edge(INVALID), prop);
+ }
+ else
+ {
+ propertyUpdate(Node(INVALID), prop);
+ }
+}
+
+void GraphDisplayerCanvas::propertyUpdate(Edge edge)
+{
+ for(int i=0;i<EDGE_PROPERTY_NUM;i++)
+ {
+ propertyUpdate(edge, i);
+ }
+}
+
+void GraphDisplayerCanvas::propertyUpdate(Node node)
+{
+ for(int i=0;i<NODE_PROPERTY_NUM;i++)
+ {
+ propertyUpdate(node, i);
+ }
+}
+
+void GraphDisplayerCanvas::propertyUpdate(Node node, int prop, int dummy)
+{
+ dummy=dummy;
+
+ std::string mapname=mainwin.getActiveNodeMap(prop);
+
+ if(mapname!="")
+ {
+ if( ( ((mainwin.mapstorage).nodemap_storage).find(mapname) != ((mainwin.mapstorage).nodemap_storage).end() ) )
+ {
+ switch(prop)
+ {
+ case N_RADIUS:
+ changeNodeRadius(mapname, node);
+ break;
+ case N_COLOR:
+ changeNodeColor(mapname, node);
+ break;
+ case N_TEXT:
+ changeNodeText(mapname, node);
+ break;
+ default:
+ std::cerr<<"Error\n";
+ }
+ }
+ }
+ else //mapname==""
+ {
+ Node node=INVALID;
+ switch(prop)
+ {
+ case N_RADIUS:
+ resetNodeRadius(node);
+ break;
+ case N_COLOR:
+ resetNodeColor(node);
+ break;
+ case N_TEXT:
+ resetNodeText(node);
+ break;
+ default:
+ std::cerr<<"Error\n";
+ }
+ }
+
+}
+
+void GraphDisplayerCanvas::propertyUpdate(Edge edge, int prop, int dummy)
+{
+ dummy=dummy;
+
+ std::string mapname=mainwin.getActiveEdgeMap(prop);
+
+ if(mapname!="")
+ {
+ if( ( ((mainwin.mapstorage).edgemap_storage).find(mapname) != ((mainwin.mapstorage).edgemap_storage).end() ) )
+ {
+ switch(prop)
+ {
+ case E_WIDTH:
+ changeEdgeWidth(mapname, edge);
+ break;
+ case E_COLOR:
+ changeEdgeColor(mapname, edge);
+ break;
+ case E_TEXT:
+ changeEdgeText(mapname, edge);
+ break;
+ default:
+ std::cerr<<"Error\n";
+ }
+ }
+ }
+ else //mapname==""
+ {
+ switch(prop)
+ {
+ case E_WIDTH:
+ resetEdgeWidth(edge);
+ break;
+ case E_COLOR:
+ resetEdgeColor(edge);
+ break;
+ case E_TEXT:
+ resetEdgeText(edge);
+ break;
+ default:
+ std::cerr<<"Error\n";
+ }
+ }
}
void GraphDisplayerCanvas::drawGraph()
{
//first edges are drawn, to hide joining with nodes later
- for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
//drawing green lines, coordinates are from mapstorage.coords
Gnome::Canvas::Points coos;
coos.push_back(Gnome::Art::Point(
- mapstorage.coords[mapstorage.graph.source(i)].x,
- mapstorage.coords[mapstorage.graph.source(i)].y));
+ (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].x,
+ (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].y));
coos.push_back(Gnome::Art::Point(
- mapstorage.coords[mapstorage.graph.target(i)].x,
- mapstorage.coords[mapstorage.graph.target(i)].y));
+ (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].x,
+ (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].y));
edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this);
*(edgesmap[i]) << Gnome::Canvas::Properties::fill_color("green");
@@ -68,16 +186,16 @@
//afterwards nodes come to be drawn
- for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
+ for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
{
//drawing bule nodes, with black line around them
nodesmap[i]=new Gnome::Canvas::Ellipse(
displayed_graph,
- mapstorage.coords[i].x-20,
- mapstorage.coords[i].y-20,
- mapstorage.coords[i].x+20,
- mapstorage.coords[i].y+20);
+ (mainwin.mapstorage).coords[i].x-20,
+ (mainwin.mapstorage).coords[i].y-20,
+ (mainwin.mapstorage).coords[i].x+20,
+ (mainwin.mapstorage).coords[i].y+20);
*(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue");
*(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black");
nodesmap[i]->raise_to_top();
@@ -85,8 +203,8 @@
//initializing edge-text as well, to empty string
xy<double> text_pos(
- (mapstorage.coords[i].x+node_property_defaults[N_RADIUS]+5),
- (mapstorage.coords[i].y+node_property_defaults[N_RADIUS]+5));
+ ((mainwin.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5),
+ ((mainwin.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5));
nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
text_pos.x, text_pos.y, "");
@@ -104,13 +222,13 @@
active_edge=INVALID;
forming_edge=INVALID;
- for (NodeIt n(mapstorage.graph); n != INVALID; ++n)
+ for (NodeIt n((mainwin.mapstorage).graph); n != INVALID; ++n)
{
delete nodesmap[n];
delete nodetextmap[n];
}
- for (EdgeIt e(mapstorage.graph); e != INVALID; ++e)
+ for (EdgeIt e((mainwin.mapstorage).graph); e != INVALID; ++e)
{
delete edgesmap[e];
delete edgetextmap[e];
Modified: hugo/trunk/gui/graph_displayer_canvas.h
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.h (original)
+++ hugo/trunk/gui/graph_displayer_canvas.h Tue Nov 29 20:31:58 2005
@@ -6,8 +6,7 @@
class GraphDisplayerCanvas;
#include "all_include.h"
-#include "mapstorage.h"
-#include "map_win.h"
+#include "main_win.h"
#include <libgnomecanvasmm.h>
#include <libgnomecanvasmm/polygon.h>
#include <lemon/xy.h>
@@ -40,7 +39,7 @@
typedef Gnome::Canvas::CanvasAA Parent;
public:
- GraphDisplayerCanvas(MapStorage &, MapWin &, Gtk::Window *);
+ GraphDisplayerCanvas(MainWin &);
virtual ~GraphDisplayerCanvas();
///Changes the linewidth attribute according to the given map.
@@ -73,6 +72,13 @@
int changeNodeText (std::string mapname, Node new_item=INVALID);
int resetNodeText (Node new_item=INVALID);
+ void propertyChange(bool, int);
+ void propertyUpdate(Edge, int, int dummy=0);
+ void propertyUpdate(Node, int, int dummy=0);
+
+ void propertyUpdate(Edge);
+ void propertyUpdate(Node);
+
///Callback for 'ViewZoomIn' action.
virtual void zoomIn();
///Callback for 'ViewZoomOut' action.
@@ -165,10 +171,6 @@
///Group of graphical elements of displayed_graph
Gnome::Canvas::Group displayed_graph;
-public:
- ///Here we store the maps that can be displayed through properties.
- MapStorage & mapstorage;
-
private:
///Indicates whether the button of mouse is pressed or not
int isbutton;
@@ -193,14 +195,10 @@
static const int zoom_step = 5;
-public:
- ///We need to store mapwin, to be able to ask the appropriate values for properties of new items.
- MapWin & mapwin;
-
private:
- ///pointer to the parent window
- Gtk::Window * parentwin;
+ ///reference to the parent window
+ MainWin & mainwin;
};
Modified: hugo/trunk/gui/main_win.cc
==============================================================================
--- hugo/trunk/gui/main_win.cc (original)
+++ hugo/trunk/gui/main_win.cc Tue Nov 29 20:31:58 2005
@@ -1,14 +1,17 @@
#include "main_win.h"
#include "icons/guipixbufs.h"
-MainWin::MainWin() :
- mapwin("Map Setup", mapstorage, gd_canvas),
- gd_canvas(mapstorage, mapwin, (Gtk::Window *)this)
+MainWin::MainWin()
{
+ mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
+ gd_canvas=new GraphDisplayerCanvas(*this);
+
set_title ("unsaved file - " + prog_name);
set_default_size(WIN_WIDTH,WIN_HEIGHT);
add(vbox);
+ //connecting signals - controller character
+ mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
// custom icons for the toolbar
@@ -92,35 +95,35 @@
ag->add( Gtk::Action::create("ViewMenu", "_View") );
ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
- sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
+ sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomIn));
ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
- sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
+ sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomOut));
ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
- sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
+ sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomFit));
ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
- sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
+ sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoom100));
ag->add( Gtk::Action::create("ShowMenu", "_Show") );
ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
- sigc::mem_fun(this->mapwin, &MapWin::show));
+ sigc::mem_fun(*(this->mapwin), &MapWin::show));
Gtk::RadioAction::Group tool_group;
ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
- sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );
+ sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) );
ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"),
- sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 1) );
+ sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 1) );
ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), "Create edge"),
- sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 2) );
+ sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 2) );
ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), "Delete"),
- sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) );
+ sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 3) );
ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), "Edit edge map"),
- sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );
+ sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 4) );
ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), "Edit node map"),
- sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
+ sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 5) );
ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")),
- sigc::mem_fun (new NewMapWin("NewMapWin", gd_canvas), &NewMapWin::show ) );
+ sigc::mem_fun (new NewMapWin("NewMapWin", *this), &NewMapWin::show ) );
uim=Gtk::UIManager::create();
uim->insert_action_group(ag);
@@ -194,7 +197,7 @@
Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
pScrolledWindow->set_shadow_type(Gtk::SHADOW_IN);
- pScrolledWindow->add(gd_canvas);
+ pScrolledWindow->add(*gd_canvas);
vbox.pack_start(*pScrolledWindow);
tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
@@ -208,8 +211,8 @@
mapstorage.readFromFile(file);
mapstorage.file_name = file;
mapstorage.modified = false;
- gd_canvas.drawGraph();
- mapwin.update();
+ gd_canvas->drawGraph();
+ mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
set_title(Glib::filename_display_basename(file) + " - " + prog_name);
}
@@ -233,9 +236,9 @@
break;
}
}
- gd_canvas.clear();
+ gd_canvas->clear();
mapstorage.clear();
- mapwin.update();
+ mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
set_title("unsaved file - " + prog_name);
}
@@ -264,15 +267,15 @@
fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
{
- gd_canvas.clear();
+ gd_canvas->clear();
mapstorage.clear();
Glib::ustring filename = fcdialog.get_filename();
if (!mapstorage.readFromFile(filename))
{
mapstorage.file_name = filename;
mapstorage.modified = false;
- gd_canvas.drawGraph();
- mapwin.update();
+ gd_canvas->drawGraph();
+ mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
}
}
@@ -327,8 +330,39 @@
break;
}
}
- gd_canvas.clear();
+ gd_canvas->clear();
mapstorage.clear();
- mapwin.update();
+ mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
set_title("unsaved file - " + prog_name);
}
+
+void MainWin::propertyChange(bool itisedge, int prop, std::string mapname)
+{
+ mapstorage.changeActiveMap(itisedge, prop, mapname);
+}
+
+void MainWin::popupNewMapWin(bool itisedge, int prop)
+{
+ prop=prop;
+ (new NewMapWin("NewMapWin", *this, itisedge, false))->run();
+}
+
+std::string MainWin::getActiveEdgeMap(int prop)
+{
+ return mapstorage.getActiveEdgeMap(prop);
+}
+
+std::string MainWin::getActiveNodeMap(int prop)
+{
+ return mapstorage.getActiveNodeMap(prop);
+}
+
+void MainWin::registerNewEdgeMap(std::string mapname)
+{
+ mapwin->registerNewEdgeMap(mapname);
+}
+
+void MainWin::registerNewNodeMap(std::string mapname)
+{
+ mapwin->registerNewNodeMap(mapname);
+}
Modified: hugo/trunk/gui/main_win.h
==============================================================================
--- hugo/trunk/gui/main_win.h (original)
+++ hugo/trunk/gui/main_win.h Tue Nov 29 20:31:58 2005
@@ -3,6 +3,8 @@
#ifndef MAIN_WIN_H
#define MAIN_WIN_H
+class MainWin;
+
#include "all_include.h"
#include "mapstorage.h"
#include "map_win.h"
@@ -26,10 +28,10 @@
protected:
///Window of map-showing setup. Its type is \ref MapWin
- MapWin mapwin;
+ MapWin * mapwin;
///The graph will be drawn on this \ref GraphDisplayerCanvas
- GraphDisplayerCanvas gd_canvas;
+ GraphDisplayerCanvas * gd_canvas;
///ActionGroup for menu
Glib::RefPtr<Gtk::ActionGroup> ag;
@@ -53,6 +55,17 @@
virtual void saveFileAs();
///Callback for 'Close' action.
virtual void close();
+
+public:
+ void propertyChange(bool, int, std::string);
+ void popupNewMapWin(bool, int);
+
+ std::string getActiveEdgeMap(int);
+ std::string getActiveNodeMap(int);
+
+ void registerNewEdgeMap(std::string);
+ void registerNewNodeMap(std::string);
+
};
#endif //MAIN_WIN_H
Modified: hugo/trunk/gui/map_win.cc
==============================================================================
--- hugo/trunk/gui/map_win.cc (original)
+++ hugo/trunk/gui/map_win.cc Tue Nov 29 20:31:58 2005
@@ -10,7 +10,7 @@
return true;
}
-MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
+MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, MainWin & mw):mainwin(mw)
{
set_title(title);
set_default_size(200, 50);
@@ -23,9 +23,12 @@
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
{
- e_combo_array[i]=new MapSelector(gdc, ms, i, true);
+ e_combo_array[i]=new MapSelector(eml, i, true);
(*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
+
+ e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i));
+ e_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
}
vbox.pack_start(*(new Gtk::Label("Edge properties")));
@@ -40,9 +43,12 @@
for(int i=0;i<NODE_PROPERTY_NUM;i++)
{
- n_combo_array[i]=new MapSelector(gdc, ms, i, false);
+ n_combo_array[i]=new MapSelector(nml, i, false);
(*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
+
+ n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
+ n_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
}
add(vbox);
@@ -55,34 +61,32 @@
}
-void MapWin::update()
+void MapWin::nodeMapChanged(std::string mapname, int prop)
{
- for(int i=0;i<EDGE_PROPERTY_NUM;i++)
- {
- e_combo_array[i]->update_list();
- }
-
- for(int i=0;i<NODE_PROPERTY_NUM;i++)
- {
- n_combo_array[i]->update_list();
- }
+ mainwin.propertyChange(false, prop, mapname);
}
+void MapWin::edgeMapChanged(std::string mapname, int prop)
+{
+ mainwin.propertyChange(true, prop, mapname);
+}
-void MapWin::updateNode(Node node)
+void MapWin::newMapWinNeeded(bool itisedge, int prop)
{
- for(int i=0;i<NODE_PROPERTY_NUM;i++)
- {
- n_combo_array[i]->update(node);
- }
+ mainwin.popupNewMapWin(itisedge, prop);
}
-void MapWin::updateEdge(Edge edge)
+void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
{
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
- {
- e_combo_array[i]->update(edge);
- }
+ {
+ e_combo_array[i]->update_list(eml);
+ }
+
+ for(int i=0;i<NODE_PROPERTY_NUM;i++)
+ {
+ n_combo_array[i]->update_list(nml);
+ }
}
void MapWin::registerNewEdgeMap(std::string newmapname)
Modified: hugo/trunk/gui/map_win.h
==============================================================================
--- hugo/trunk/gui/map_win.h (original)
+++ hugo/trunk/gui/map_win.h Tue Nov 29 20:31:58 2005
@@ -5,10 +5,8 @@
class MapWin;
-#include "all_include.h"
-#include "graph_displayer_canvas.h"
-#include "mapstorage.h"
-#include "new_map_win.h"
+#include <all_include.h>
+#include <main_win.h>
#include <libgnomecanvasmm.h>
#include <libgnomecanvasmm/polygon.h>
@@ -21,9 +19,8 @@
class MapSelector : public Gtk::HBox
{
protected:
- GraphDisplayerCanvas & gdc;
- ///The \ref MapStorage in which the visualizable maps are stored
- MapStorage & ms;
+ sigc::signal<void, std::string> signal_cbt;
+ sigc::signal<void, bool> signal_newmapwin;
int id;
@@ -41,15 +38,14 @@
Gtk::Label * label;
- Node node_to_update;
- Edge edge_to_update;
-
-
public:
- MapSelector(GraphDisplayerCanvas &, MapStorage &, int, bool);
+ MapSelector(std::vector<std::string>, int, bool);
+
+ sigc::signal<void, std::string> signal_cbt_ch();
+ sigc::signal<void, bool> signal_newmapwin_needed();
- void update_list();
+ void update_list( std::vector<std::string> );
///If a radiobutton is clicked, this function determines
///which button was that and after that calls the
@@ -61,9 +57,6 @@
virtual void reset();
- virtual void update(Node node);
- virtual void update(Edge edge);
-
Glib::ustring get_active_text();
void set_active_text(Glib::ustring);
void append_text(Glib::ustring);
@@ -72,14 +65,7 @@
protected:
- ///The \ref GraphDisplayerCanvas on which the graph will be drawn.
- ///It has to be known for this class, because
- ///when a map assigned to a certain attribute
- ///a function of the \ref GraphDisplayerCanvas will be called.
- GraphDisplayerCanvas & gdc;
-
- ///The \ref MapStorage in which the visualizable maps are stored
- MapStorage & ms;
+ MainWin & mainwin;
Gtk::Table * table;
@@ -91,13 +77,13 @@
public:
///Constructor of MapWin creates the widgets shown in MapWin.
- MapWin(const std::string& title, MapStorage &, GraphDisplayerCanvas &);
+ MapWin(const std::string& title, std::vector<std::string>, std::vector<std::string>, MainWin & mw);
+
+ void nodeMapChanged(std::string, int);
- ///This function is created to set the appropriate maps on the newly created node
- void updateNode(Graph::Node);
+ void edgeMapChanged(std::string, int);
- ///This function is created to set the appropriate maps on the newly created edge
- void updateEdge(Graph::Edge);
+ void newMapWinNeeded(bool, int);
///This function inserts name of the new edgemap in the list in the combo box
void registerNewEdgeMap(std::string);
@@ -107,7 +93,7 @@
virtual bool closeIfEscapeIsPressed(GdkEventKey*);
- void update();
+ void update(std::vector<std::string>, std::vector<std::string>);
};
#endif //MAP_WIN_H
Modified: hugo/trunk/gui/mapstorage.cc
==============================================================================
--- hugo/trunk/gui/mapstorage.cc (original)
+++ hugo/trunk/gui/mapstorage.cc Tue Nov 29 20:31:58 2005
@@ -16,6 +16,18 @@
nodemap_default["id"] = 1.0;
edgemap_default["id"] = 1.0;
+
+ active_nodemaps.resize(NODE_PROPERTY_NUM);
+ for(int i=0;i<NODE_PROPERTY_NUM;i++)
+ {
+ active_nodemaps[i]="";
+ }
+
+ active_edgemaps.resize(EDGE_PROPERTY_NUM);
+ for(int i=0;i<EDGE_PROPERTY_NUM;i++)
+ {
+ active_edgemaps[i]="";
+ }
}
MapStorage::~MapStorage()
@@ -44,6 +56,62 @@
return 1;
}
+void MapStorage::changeActiveMap(bool itisedge, int prop, std::string mapname)
+{
+ if(itisedge)
+ {
+ active_edgemaps[prop]=mapname;
+ }
+ else
+ {
+ active_nodemaps[prop]=mapname;
+ }
+ signal_prop.emit(itisedge, prop);
+}
+
+std::string MapStorage::getActiveEdgeMap(int prop)
+{
+ return active_edgemaps[prop];
+}
+
+std::string MapStorage::getActiveNodeMap(int prop)
+{
+ return active_nodemaps[prop];
+}
+
+std::vector<std::string> MapStorage::getEdgeMapList()
+{
+ std::vector<std::string> eml;
+ eml.resize(edgemap_storage.size());
+ int i=0;
+ std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=beginOfEdgeMaps();
+ for(;emsi!=endOfEdgeMaps();emsi++)
+ {
+ eml[i]=(emsi->first);
+ i++;
+ }
+ return eml;
+}
+
+std::vector<std::string> MapStorage::getNodeMapList()
+{
+ std::vector<std::string> nml;
+ nml.resize(nodemap_storage.size());
+ int i=0;
+ std::map< std::string,Graph::NodeMap<double> * >::iterator nmsi=beginOfNodeMaps();
+ for(;nmsi!=endOfNodeMaps();nmsi++)
+ {
+ nml[i]=(nmsi->first);
+ i++;
+ }
+ return nml;
+}
+
+MapStorage::Signal_Prop MapStorage::signal_prop_ch()
+{
+ return signal_prop;
+}
+
int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap, double default_value = 0.0)
{
if( edgemap_storage.find(name) == edgemap_storage.end() )
Modified: hugo/trunk/gui/mapstorage.h
==============================================================================
--- hugo/trunk/gui/mapstorage.h (original)
+++ hugo/trunk/gui/mapstorage.h Tue Nov 29 20:31:58 2005
@@ -3,8 +3,11 @@
#ifndef MAPSTORAGE_H
#define MAPSTORAGE_H
+class Mapstorage;
+
#include "all_include.h"
#include "xymap.h"
+#include <libgnomecanvasmm.h>
///Class MapStorage is responsible for storing
///NodeMaps and EdgeMaps that can be shown later
@@ -37,12 +40,22 @@
//Stores the default values for the different visualization edge attributes
std::vector<Graph::EdgeMap<double> > default_edgemaps;
+ //Stores the active maps for the different visualization node attributes
+ std::vector< std::string > active_nodemaps;
+
+ //Stores the active maps for the different visualization edge attributes
+ std::vector< std::string > active_edgemaps;
+
// Default values for the maps
std::map< std::string, double > nodemap_default;
// Default values for the maps
std::map< std::string, double > edgemap_default;
+protected:
+ typedef sigc::signal<void, bool, int> Signal_Prop;
+ Signal_Prop signal_prop;
+
public:
///Constructor of MapStorage. Expects the Graph of
///which maps will be stored in it.
@@ -54,6 +67,16 @@
~MapStorage();
+ void changeActiveMap(bool, int, std::string);
+
+ std::string getActiveEdgeMap(int);
+ std::string getActiveNodeMap(int);
+
+ std::vector<std::string> getEdgeMapList();
+ std::vector<std::string> getNodeMapList();
+
+ Signal_Prop signal_prop_ch();
+
///Adds given map to storage. A name and the map itself has to be provided.
///\param name is the name of map
///\nodemap is the pointer of the given nodemap
Modified: hugo/trunk/gui/mw-mapselector.cc
==============================================================================
--- hugo/trunk/gui/mw-mapselector.cc (original)
+++ hugo/trunk/gui/mw-mapselector.cc Tue Nov 29 20:31:58 2005
@@ -1,8 +1,8 @@
#include "map_win.h"
-MapWin::MapSelector::MapSelector(GraphDisplayerCanvas & grdispc, MapStorage & mapst, int identifier, bool edge):gdc(grdispc),ms(mapst),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID)
+MapWin::MapSelector::MapSelector(std::vector<std::string> ml, int identifier, bool edge):id(identifier),itisedge(edge),default_state(true),set_new_map(false)
{
- update_list();
+ update_list(ml);
cbt.set_active(0);
@@ -50,27 +50,16 @@
void MapWin::MapSelector::new_but_pressed()
{
set_new_map=true;
- (new NewMapWin("NewMapWin", gdc, itisedge, false))->run();
+ signal_newmapwin.emit(itisedge);
}
-void MapWin::MapSelector::update_list()
+void MapWin::MapSelector::update_list( std::vector< std::string > ml )
{
cbt.clear();
- if(itisedge)
+ std::vector< std::string >::iterator emsi=ml.begin();
+ for(;emsi!=ml.end();emsi++)
{
- std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
- for(;emsi!=ms.endOfEdgeMaps();emsi++)
- {
- cbt.append_text(emsi->first);
- }
- }
- else
- {
- std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
- for(;emsi!=ms.endOfNodeMaps();emsi++)
- {
- cbt.append_text(emsi->first);
- }
+ cbt.append_text(*emsi);
}
cbt.prepend_text("Default values");
}
@@ -83,52 +72,12 @@
Glib::ustring mapname = cbt.get_active_text();
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
{
- if(itisedge)
- {
- if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) )
- {
- Edge edge=edge_to_update;
- switch(id)
- {
- case E_WIDTH:
- gdc.changeEdgeWidth(mapname, edge);
- break;
- case E_COLOR:
- gdc.changeEdgeColor(mapname, edge);
- break;
- case E_TEXT:
- gdc.changeEdgeText(mapname, edge);
- break;
- default:
- std::cerr<<"Error\n";
- }
- }
- }
- else
- {
- if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) )
- {
- Node node=node_to_update;
- switch(id)
- {
- case N_RADIUS:
- gdc.changeNodeRadius(mapname, node);
- break;
- case N_COLOR:
- gdc.changeNodeColor(mapname, node);
- break;
- case N_TEXT:
- gdc.changeNodeText(mapname, node);
- break;
- default:
- std::cerr<<"Error\n";
- }
- }
- }
+ signal_cbt.emit(mapname);
}
}
else if((!default_state)&&(cbt.get_active_row_number()==0))
{
+ signal_cbt.emit("");
reset();
}
}
@@ -138,71 +87,9 @@
default_state=true;
cbt.set_active(0);
- if(itisedge)
- {
- Edge edge=edge_to_update;
- switch(id)
- {
- case E_WIDTH:
- gdc.resetEdgeWidth(edge);
- break;
- case E_COLOR:
- gdc.resetEdgeColor(edge);
- break;
- case E_TEXT:
- gdc.resetEdgeText(edge);
- break;
- default:
- std::cerr<<"Error\n";
- }
- }
- else
- {
- Node node=node_to_update;
- switch(id)
- {
- case N_RADIUS:
- gdc.resetNodeRadius(node);
- break;
- case N_COLOR:
- gdc.resetNodeColor(node);
- break;
- case N_TEXT:
- gdc.resetNodeText(node);
- break;
- default:
- std::cerr<<"Error\n";
- }
- }
+ signal_cbt.emit("");
}
-void MapWin::MapSelector::update(Node node)
-{
- node_to_update=node;
- if(default_state)
- {
- reset();
- }
- else
- {
- comboChanged();
- }
- node_to_update=INVALID;
-}
-
-void MapWin::MapSelector::update(Edge edge)
-{
- edge_to_update=edge;
- if(default_state)
- {
- reset();
- }
- else
- {
- comboChanged();
- }
- edge_to_update=INVALID;
-}
Glib::ustring MapWin::MapSelector::get_active_text()
{
@@ -223,3 +110,13 @@
set_new_map=false;
}
}
+
+sigc::signal<void, std::string> MapWin::MapSelector::signal_cbt_ch()
+{
+ return signal_cbt;
+}
+
+sigc::signal<void, bool> MapWin::MapSelector::signal_newmapwin_needed()
+{
+ return signal_newmapwin;
+}
Modified: hugo/trunk/gui/new_map_win.cc
==============================================================================
--- hugo/trunk/gui/new_map_win.cc (original)
+++ hugo/trunk/gui/new_map_win.cc Tue Nov 29 20:31:58 2005
@@ -9,7 +9,7 @@
return true;
}
-NewMapWin::NewMapWin(const std::string& title, GraphDisplayerCanvas & grdispc, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),gdc(grdispc),node("Create NodeMap"),edge("Create EdgeMap")
+NewMapWin::NewMapWin(const std::string& title, MainWin & mw, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),mainwin(mw),node("Create NodeMap"),edge("Create EdgeMap")
{
set_default_size(200, 50);
@@ -83,11 +83,11 @@
if(edge.get_active())
{
//create the new map
- Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (gdc.mapstorage.graph);
+ Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mainwin.mapstorage.graph);
std::stack<double> polishstack;
- for(EdgeIt k(gdc.mapstorage.graph); k!=INVALID; ++k)
+ for(EdgeIt k(mainwin.mapstorage.graph); k!=INVALID; ++k)
{
for(int i=0;i<(int)polishform.size();i++)
{
@@ -106,11 +106,11 @@
break;
default:
//substitute variable
- std::map< std::string,Graph::EdgeMap<double> * > ems=gdc.mapstorage.edgemap_storage;
+ std::map< std::string,Graph::EdgeMap<double> * > ems=mainwin.mapstorage.edgemap_storage;
bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end());
if(itisvar)
{
- polishstack.push( (*(gdc.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);
+ polishstack.push( (*(mainwin.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);
}
else
{
@@ -153,25 +153,25 @@
//if addition was not successful addEdgeMap returns one.
//cause can be that there is already a map named like the new one
- if(gdc.mapstorage.addEdgeMap(mapname, emptr, def_val))
+ if(mainwin.mapstorage.addEdgeMap(mapname, emptr, def_val))
{
abortion=1;
}
//add it to the list of the displayable maps
- gdc.mapwin.registerNewEdgeMap(mapname);
+ mainwin.registerNewEdgeMap(mapname);
//display it
- gdc.changeEdgeText(mapname);
+ //gdc.changeEdgeText(mapname);
}
else //!edge.get_active()
{
//create the new map
- Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (gdc.mapstorage.graph);
+ Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mainwin.mapstorage.graph);
std::stack<double> polishstack;
- for(NodeIt k(gdc.mapstorage.graph); k!=INVALID; ++k)
+ for(NodeIt k(mainwin.mapstorage.graph); k!=INVALID; ++k)
{
for(int i=0;i<(int)polishform.size();i++)
{
@@ -189,11 +189,11 @@
polishstack.pop();
break;
default:
- std::map< std::string,Graph::NodeMap<double> * > nms=gdc.mapstorage.nodemap_storage;
+ std::map< std::string,Graph::NodeMap<double> * > nms=mainwin.mapstorage.nodemap_storage;
bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end());
if(itisvar)
{
- polishstack.push( (*(gdc.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);
+ polishstack.push( (*(mainwin.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);
}
else
{
@@ -236,13 +236,13 @@
//if addition was not successful addNodeMap returns one.
//cause can be that there is already a map named like the new one
- if(gdc.mapstorage.addNodeMap(mapname,emptr, def_val))
+ if(mainwin.mapstorage.addNodeMap(mapname,emptr, def_val))
{
abortion=1;
}
//add it to the list of the displayable maps
- gdc.mapwin.registerNewNodeMap(mapname);
+ mainwin.registerNewNodeMap(mapname);
//display it
//gdc.changeNodeText(mapname);
@@ -431,11 +431,11 @@
//is it mapname?
if(itisedge)
{
- cancel=(gdc.mapstorage.edgemap_storage.find(variable)==gdc.mapstorage.edgemap_storage.end());
+ cancel=(mainwin.mapstorage.edgemap_storage.find(variable)==mainwin.mapstorage.edgemap_storage.end());
}
else
{
- cancel=(gdc.mapstorage.nodemap_storage.find(variable)==gdc.mapstorage.nodemap_storage.end());
+ cancel=(mainwin.mapstorage.nodemap_storage.find(variable)==mainwin.mapstorage.nodemap_storage.end());
}
//maybe it is number
int point_num=0;
Modified: hugo/trunk/gui/new_map_win.h
==============================================================================
--- hugo/trunk/gui/new_map_win.h (original)
+++ hugo/trunk/gui/new_map_win.h Tue Nov 29 20:31:58 2005
@@ -6,7 +6,7 @@
class NewMapWin;
#include <all_include.h>
-#include <graph_displayer_canvas.h>
+#include <main_win.h>
#include <libgnomecanvasmm.h>
#include <libgnomecanvasmm/polygon.h>
#include <stack>
@@ -16,11 +16,7 @@
class NewMapWin : public Gtk::Dialog
{
- ///The \ref GraphDisplayerCanvas on which the graph will be drawn.
- ///It has to be known for this class, because
- ///when a map is created
- ///a function of the \ref GraphDisplayerCanvas will be called.
- GraphDisplayerCanvas & gdc;
+ MainWin & mainwin;
public:
struct tree_node
@@ -31,7 +27,7 @@
};
///Constructor of NewMapWin creates the widgets shown in NewMapWin.
- NewMapWin(const std::string& title, GraphDisplayerCanvas &, bool itisedge=true, bool edgenode=true);
+ NewMapWin(const std::string& title, MainWin &, bool itisedge=true, bool edgenode=true);
///Signal on button is connected to this function,
///Therefore this function determines whether to
More information about the Lemon-commits
mailing list