# HG changeset patch # User hegyi # Date 1119636972 0 # Node ID e543923954800e71fe2a3393f6c0e9c188b1efda # Parent d6b95a59da265b0e1fe5bce0f1384afa1edd3904 NodeMap values are now visualizable. Todo: default map-values diff -r d6b95a59da26 -r e54392395480 gui/Makefile.am --- a/gui/Makefile.am Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/Makefile.am Fri Jun 24 18:16:12 2005 +0000 @@ -7,6 +7,7 @@ all_include.h \ graph_displayer_canvas.cc \ graph_displayer_canvas-edge.cc \ + graph_displayer_canvas-node.cc \ graph_displayer_canvas-event.cc \ graph_displayer_canvas-zoom.cc \ graph_displayer_canvas.h \ diff -r d6b95a59da26 -r e54392395480 gui/all_include.h --- a/gui/all_include.h Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/all_include.h Fri Jun 24 18:16:12 2005 +0000 @@ -16,7 +16,8 @@ #include #include -enum {WIDTH, COLOR, TEXT, PROPERTY_NUM}; // edge properties; +enum {E_WIDTH, E_COLOR, E_TEXT, EDGE_PROPERTY_NUM}; // edge properties; +enum {N_RADIUS, N_COLOR, N_TEXT, NODE_PROPERTY_NUM}; // node properties; enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, TOOL_NUM}; // tools; #define RANGE 3 #define WIN_WIDTH 900 @@ -24,8 +25,10 @@ #ifndef MAIN_PART -extern std::vector property_strings; -extern std::vector property_defaults; +extern std::vector edge_property_strings; +extern std::vector edge_property_defaults; +extern std::vector node_property_strings; +extern std::vector node_property_defaults; #endif //MAIN_PART using namespace lemon; diff -r d6b95a59da26 -r e54392395480 gui/graph-displayer.cc --- a/gui/graph-displayer.cc Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/graph-displayer.cc Fri Jun 24 18:16:12 2005 +0000 @@ -6,8 +6,10 @@ #define MAIN_PART -std::vector property_strings; -std::vector property_defaults; +std::vector edge_property_strings; +std::vector edge_property_defaults; +std::vector node_property_strings; +std::vector node_property_defaults; int main(int argc, char *argv[]) @@ -15,15 +17,25 @@ //initializing - property_strings.resize(PROPERTY_NUM); - property_strings[WIDTH]="Width"; - property_strings[COLOR]="Color"; - property_strings[TEXT]="Text"; + edge_property_strings.resize(EDGE_PROPERTY_NUM); + edge_property_strings[E_WIDTH]="Edge Width"; + edge_property_strings[E_COLOR]="Edge Color"; + edge_property_strings[E_TEXT]="Edge Text"; - property_defaults.resize(PROPERTY_NUM); - property_defaults[WIDTH]=10.0; - property_defaults[COLOR]=100; - property_defaults[TEXT]=0; + edge_property_defaults.resize(EDGE_PROPERTY_NUM); + edge_property_defaults[E_WIDTH]=10.0; + edge_property_defaults[E_COLOR]=100; + edge_property_defaults[E_TEXT]=0; + + node_property_strings.resize(NODE_PROPERTY_NUM); + node_property_strings[N_RADIUS]="Node Radius"; + node_property_strings[N_COLOR]="Node Color"; + node_property_strings[N_TEXT]="Node Text"; + + node_property_defaults.resize(NODE_PROPERTY_NUM); + node_property_defaults[N_RADIUS]=20.0; + node_property_defaults[N_COLOR]=100; + node_property_defaults[N_TEXT]=0; if(argc<2) { diff -r d6b95a59da26 -r e54392395480 gui/graph_displayer_canvas-edge.cc --- a/gui/graph_displayer_canvas-edge.cc Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/graph_displayer_canvas-edge.cc Fri Jun 24 18:16:12 2005 +0000 @@ -3,49 +3,82 @@ #include -int GraphDisplayerCanvas::changeLineWidth (std::string mapname) +int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Graph::Edge edge) { - for (EdgeIt i(g); i!=INVALID; ++i) + if(edge==INVALID) { - int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; + for (EdgeIt i(g); i!=INVALID; ++i) + { + int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; + if(w>=0) + { + edgesmap[i]->property_width_pixels().set_value(w); + } + } + } + else + { + int w=(int)(*(mapstorage.edgemap_storage)[mapname])[edge]; if(w>=0) { - edgesmap[i]->property_width_pixels().set_value(w); + edgesmap[edge]->property_width_pixels().set_value(w); } } return 0; }; -int GraphDisplayerCanvas::changeColor (std::string mapname) +int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Graph::Edge edge) { //function maps the range of the maximum and //the minimum of the nodemap to the range of //green in RGB + if(edge==INVALID) + { - for (EdgeIt i(g); i!=INVALID; ++i) - { - double w=(*(mapstorage.edgemap_storage)[mapname])[i]; - double max=mapstorage.maxOfEdgeMap(mapname); - double min=mapstorage.minOfEdgeMap(mapname); + for (EdgeIt i(g); i!=INVALID; ++i) + { + double w=(*(mapstorage.edgemap_storage)[mapname])[i]; + double max=mapstorage.maxOfEdgeMap(mapname); + double min=mapstorage.minOfEdgeMap(mapname); - //std::cout<property_fill_color_gdk().set_value(color); + } + } + else { - color.set_rgb_p (0, 100*(w-min)/(max-min), 0); + double w=(*(mapstorage.edgemap_storage)[mapname])[edge]; + double max=mapstorage.maxOfEdgeMap(mapname); + double min=mapstorage.minOfEdgeMap(mapname); + + //std::cout<property_fill_color_gdk().set_value(color); } - else - { - color.set_rgb_p (0, 100, 0); - } - - edgesmap[i]->property_fill_color_gdk().set_value(color); - } return 0; }; -int GraphDisplayerCanvas::changeText (std::string mapname) +int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Graph::Edge edge) { //the number in the map will be written on the edge @@ -54,11 +87,50 @@ //that is the deleter map //\todo isn't it a bit woodcutter? - for (EdgeIt i(g); i!=INVALID; ++i) + if(edge==INVALID) { - if(mapname!="Text") + for (EdgeIt i(g); i!=INVALID; ++i) { - double number=(*(mapstorage.edgemap_storage)[mapname])[i]; + if(mapname!=edge_property_strings[E_TEXT]) + { + double number=(*(mapstorage.edgemap_storage)[mapname])[i]; + int length=1; + //if number is smaller than one, length would be negative, or invalid + if(number>=1) + { + length=(int)(floor(log(number)/log(10)))+1; + } + int maxpos=(int)(pow(10,length-1)); + int strl=length+1+RANGE; + char * str=new char[strl]; + str[length]='.'; + str[strl]='\0'; + + for(int j=0;jproperty_text().set_value(str); + } + else + { + edgetextmap[i]->property_text().set_value(""); + } + } + + } + else + { + if(mapname!=edge_property_strings[E_TEXT]) + { + double number=(*(mapstorage.edgemap_storage)[mapname])[edge]; int length=1; //if number is smaller than one, length would be negative, or invalid if(number>=1) @@ -82,12 +154,15 @@ } } - edgetextmap[i]->property_text().set_value(str); + edgetextmap[edge]->property_text().set_value(str); } else { - edgetextmap[i]->property_text().set_value(""); + edgetextmap[edge]->property_text().set_value(""); } + } + return 0; + }; diff -r d6b95a59da26 -r e54392395480 gui/graph_displayer_canvas-event.cc --- a/gui/graph_displayer_canvas-event.cc Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/graph_displayer_canvas-event.cc Fri Jun 24 18:16:12 2005 +0000 @@ -99,7 +99,9 @@ double dx=e->motion.x-clicked_x; double dy=e->motion.y-clicked_y; + //repositioning node and its text active_item->move(dx, dy); + nodetextmap[active_node]->move(dx, dy); clicked_x=e->motion.x; clicked_y=e->motion.y; @@ -129,6 +131,7 @@ edgesmap[ei]->set_points(coos,true); } + //reposition of edgetext xy text_pos=edgesmap[ei]->get_arrow_pos(); text_pos+=(xy(10,10)); edgetextmap[ei]->property_x().set_value(text_pos.x); @@ -189,6 +192,12 @@ *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red"); *(nodesmap[active_node]) << Gnome::Canvas::Properties::outline_color("black"); (nodesmap[active_node])->show(); + + nodetextmap[active_node]=new Gnome::Canvas::Text(displayed_graph, clicked_x+node_property_defaults[N_RADIUS]+5, clicked_y+node_property_defaults[N_RADIUS]+5, ""); + nodetextmap[active_node]->property_fill_color().set_value("darkblue"); + + mapwin->update_node(active_node); + break; //move the new node @@ -272,39 +281,50 @@ //the clicked item is a node, the edge can be drawn if(target_node!=INVALID) { - *(nodesmap[target_node]) << Gnome::Canvas::Properties::fill_color("red"); + if(target_node!=active_node) + { + *(nodesmap[target_node]) << Gnome::Canvas::Properties::fill_color("red"); - //creating new edge - active_edge=EdgeIt(g,g.addEdge(active_node, target_node)); + //creating new edge + active_edge=EdgeIt(g,g.addEdge(active_node, target_node)); - //initiating values corresponding to new edge in maps - mapstorage.init_maps_for_edge(active_edge); + //initiating values corresponding to new edge in maps + mapstorage.init_maps_for_edge(active_edge); - //calculating coordinates of new edge - Gnome::Canvas::Points coos; - double x1, x2, y1, y2; + //calculating coordinates of new edge + Gnome::Canvas::Points coos; + double x1, x2, y1, y2; - active_item->get_bounds(x1, y1, x2, y2); - coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); + active_item->get_bounds(x1, y1, x2, y2); + coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); - target_item->get_bounds(x1, y1, x2, y2); - coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); + target_item->get_bounds(x1, y1, x2, y2); + coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); - //drawing new edge - edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this); - *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green"); - edgesmap[active_edge]->property_width_pixels().set_value(10); + //drawing new edge + edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this); + *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green"); + edgesmap[active_edge]->property_width_pixels().set_value(10); - //redraw nodes to blank terminations of the new edge - target_item->raise_to_top(); - active_item->raise_to_top(); + //redraw nodes to blank terminations of the new edge + target_item->raise_to_top(); + active_item->raise_to_top(); - //initializing edge-text as well, to empty string - xy text_pos=edgesmap[active_edge]->get_arrow_pos(); - text_pos+=(xy(10,10)); + //initializing edge-text as well, to empty string + xy text_pos=edgesmap[active_edge]->get_arrow_pos(); + text_pos+=(xy(10,10)); - edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); - edgetextmap[active_edge]->property_fill_color().set_value("black"); + edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); + edgetextmap[active_edge]->property_fill_color().set_value("darkgreen"); + + //updating its properties + mapwin->update_edge(active_edge); + } + else + { + target_node=INVALID; + std::cout << "Loop edge is not yet implemented!" << std::endl; + } } //clicked item was not a node. it could be an e.g. edge. we do not deal with it furthermore. else @@ -435,18 +455,21 @@ void GraphDisplayerCanvas::delete_item(NodeIt node_to_delete) { + delete(nodetextmap[node_to_delete]); delete(nodesmap[node_to_delete]); g.erase(node_to_delete); } void GraphDisplayerCanvas::delete_item(EdgeIt edge_to_delete) { + delete(edgetextmap[edge_to_delete]); delete(edgesmap[edge_to_delete]); g.erase(edge_to_delete); } void GraphDisplayerCanvas::delete_item(Graph::Edge edge_to_delete) { + delete(edgetextmap[edge_to_delete]); delete(edgesmap[edge_to_delete]); g.erase(edge_to_delete); } diff -r d6b95a59da26 -r e54392395480 gui/graph_displayer_canvas-node.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/graph_displayer_canvas-node.cc Fri Jun 24 18:16:12 2005 +0000 @@ -0,0 +1,175 @@ +#include +#include +#include + + +int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Graph::Node node) +{ + if(node==INVALID) + { + for (NodeIt i(g); i!=INVALID; ++i) + { + int w=(int)(*(mapstorage.nodemap_storage)[mapname])[i]; + if(w>=0) + { + double x1, y1, x2, y2; + nodesmap[i]->get_bounds(x1, y1, x2, y2); + nodesmap[i]->property_x1().set_value((x1+x2)/2-w); + nodesmap[i]->property_x2().set_value((x1+x2)/2+w); + nodesmap[i]->property_y1().set_value((y1+y2)/2-w); + nodesmap[i]->property_y2().set_value((y1+y2)/2+w); + } + } + } + else + { + int w=(int)(*(mapstorage.nodemap_storage)[mapname])[node]; + if(w>=0) + { + double x1, y1, x2, y2; + nodesmap[node]->get_bounds(x1, y1, x2, y2); + nodesmap[node]->property_x1().set_value((x1+x2)/2-w); + nodesmap[node]->property_x2().set_value((x1+x2)/2+w); + nodesmap[node]->property_y1().set_value((y1+y2)/2-w); + nodesmap[node]->property_y2().set_value((y1+y2)/2+w); + } + } + return 0; +}; + +int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Graph::Node node) +{ + + //function maps the range of the maximum and + //the minimum of the nodemap to the range of + //green in RGB + + if(node==INVALID) + { + + for (NodeIt i(g); i!=INVALID; ++i) + { + double w=(*(mapstorage.nodemap_storage)[mapname])[i]; + double max=mapstorage.maxOfNodeMap(mapname); + double min=mapstorage.minOfNodeMap(mapname); + + //std::cout<property_fill_color_gdk().set_value(color); + } + } + else + { + double w=(*(mapstorage.nodemap_storage)[mapname])[node]; + double max=mapstorage.maxOfNodeMap(mapname); + double min=mapstorage.minOfNodeMap(mapname); + + //std::cout<property_fill_color_gdk().set_value(color); + } + return 0; +}; + +int GraphDisplayerCanvas::changeNodeText (std::string mapname, Graph::Node node) +{ + + //the number in the map will be written on the node + //EXCEPT when the name of the map is Text, because + //in that case empty string will be written, because + //that is the deleter map + //\todo isn't it a bit woodcutter? + + if(node==INVALID) + { + for (NodeIt i(g); i!=INVALID; ++i) + { + if(mapname!=node_property_strings[N_TEXT]) + { + double number=(*(mapstorage.nodemap_storage)[mapname])[i]; + int length=1; + //if number is smaller than one, length would be negative, or invalid + if(number>=1) + { + length=(int)(floor(log(number)/log(10)))+1; + } + int maxpos=(int)(pow(10,length-1)); + int strl=length+1+RANGE; + char * str=new char[strl]; + str[length]='.'; + str[strl]='\0'; + + for(int j=0;jproperty_text().set_value(str); + } + else + { + nodetextmap[i]->property_text().set_value(""); + } + } + } + else + { + if(mapname!=node_property_strings[N_TEXT]) + { + double number=(*(mapstorage.nodemap_storage)[mapname])[node]; + int length=1; + //if number is smaller than one, length would be negative, or invalid + if(number>=1) + { + length=(int)(floor(log(number)/log(10)))+1; + } + int maxpos=(int)(pow(10,length-1)); + int strl=length+1+RANGE; + char * str=new char[strl]; + str[length]='.'; + str[strl]='\0'; + + for(int j=0;jproperty_text().set_value(str); + } + else + { + nodetextmap[node]->property_text().set_value(""); + } + } + return 0; +}; diff -r d6b95a59da26 -r e54392395480 gui/graph_displayer_canvas.cc --- a/gui/graph_displayer_canvas.cc Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/graph_displayer_canvas.cc Fri Jun 24 18:16:12 2005 +0000 @@ -2,7 +2,7 @@ #include #include -GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL) +GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms, MapWin * mw):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),nodetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL),mapwin(mw) { actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_node_event_handler), false); @@ -34,7 +34,7 @@ text_pos+=(xy(10,10)); edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); - edgetextmap[i]->property_fill_color().set_value("black"); + edgetextmap[i]->property_fill_color().set_value("darkgreen"); } //afterwards nodes come to be drawn @@ -56,7 +56,13 @@ nodesmap[i]=new Gnome::Canvas::Ellipse(displayed_graph, cm[i].x-20, cm[i].y-20, cm[i].x+20, cm[i].y+20); *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue"); *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black"); - //!!!!!!! (nodesmap[i])->signal_event().connect(sigc::bind(sigc::mem_fun(*this, &GraphDisplayerCanvas::event_handler),i)); + + //initializing edge-text as well, to empty string + + xy text_pos((cm[i].x+node_property_defaults[N_RADIUS]+5),(cm[i].y+node_property_defaults[N_RADIUS]+5)); + + nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); + nodetextmap[i]->property_fill_color().set_value("darkblue"); } updateScrollRegion(); diff -r d6b95a59da26 -r e54392395480 gui/graph_displayer_canvas.h --- a/gui/graph_displayer_canvas.h Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/graph_displayer_canvas.h Fri Jun 24 18:16:12 2005 +0000 @@ -6,6 +6,7 @@ class GraphDisplayerCanvas; #include +#include #include #include #include @@ -17,20 +18,32 @@ typedef Gnome::Canvas::CanvasAA Parent; public: - GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &); + GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &, MapWin *); virtual ~GraphDisplayerCanvas(); ///Changes the linewidth attribute according to the given map. ///\param mapname is the name of the map which contains the new values - int changeLineWidth (std::string mapname); + int changeEdgeWidth (std::string mapname, Graph::Edge new_item=INVALID); ///Changes the linecolor attribute according to the given map. ///\param mapname is the name of the map which contains the new values - int changeColor (std::string mapname); + int changeEdgeColor (std::string mapname, Graph::Edge new_item=INVALID); ///Changes the text of line attribute according to the given map. ///\param mapname is the name of the map which contains the new values - int changeText (std::string mapname); + int changeEdgeText (std::string mapname, Graph::Edge new_item=INVALID); + + ///Changes the linewidth attribute according to the given map. + ///\param mapname is the name of the map which contains the new values + int changeNodeRadius (std::string mapname, Graph::Node new_item=INVALID); + + ///Changes the linecolor attribute according to the given map. + ///\param mapname is the name of the map which contains the new values + int changeNodeColor (std::string mapname, Graph::Node new_item=INVALID); + + ///Changes the text of line attribute according to the given map. + ///\param mapname is the name of the map which contains the new values + int changeNodeText (std::string mapname, Graph::Node new_item=INVALID); ///Callback for 'ViewZoomIn' action. virtual void zoomIn(); @@ -107,6 +120,9 @@ ///Map of texts to write on edges Graph::EdgeMap edgetextmap; + ///Map of texts to write on nodes + Graph::NodeMap nodetextmap; + ///Group of graphical elements of displayed_graph Gnome::Canvas::Group displayed_graph; @@ -133,6 +149,9 @@ static const int zoom_step = 5; + ///We need to store mapwin, to be able to ask the appropriate values for properties of new items. + MapWin * mapwin; + }; #endif //GRAPH_DISPLAYER_CANVAS_H diff -r d6b95a59da26 -r e54392395480 gui/main_win.cc --- a/gui/main_win.cc Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/main_win.cc Fri Jun 24 18:16:12 2005 +0000 @@ -1,7 +1,7 @@ #include MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm, - MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),gd_canvas(graph, cm, ms) + MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),gd_canvas(graph, cm, ms, &mapwin) { set_title (title); set_default_size(WIN_WIDTH,WIN_HEIGHT); diff -r d6b95a59da26 -r e54392395480 gui/map_win.cc --- a/gui/map_win.cc Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/map_win.cc Fri Jun 24 18:16:12 2005 +0000 @@ -10,16 +10,18 @@ return true; } -MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst),table(PROPERTY_NUM, 2, false) +MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst) { set_title(title); set_default_size(200, 50); signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed)); - combo_array=new Gtk::Combo [PROPERTY_NUM]; + e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM]; - for(int i=0;i * >::iterator emsi=ms.beginOfEdgeMaps(); @@ -35,8 +37,8 @@ { actprop=j; } - //this is the other maps to show for this property - for(int k=0;ksecond==&(ms.default_edgemaps[k])) { @@ -46,8 +48,6 @@ emsi++; } - //combo_array[i].set_group(group); - //filling in combo box with choices std::list listStrings; @@ -64,17 +64,17 @@ emsi++; } - combo_array[i].set_popdown_strings(listStrings); + e_combo_array[i].set_popdown_strings(listStrings); //Restrict it to these choices only: - combo_array[i].set_value_in_list(); + e_combo_array[i].set_value_in_list(); - //binding signal to thew actual entry - combo_array[i].get_entry()->signal_changed().connect + //binding signal to the actual entry + e_combo_array[i].get_entry()->signal_changed().connect ( sigc::bind ( - sigc::mem_fun(*this, &MapWin::combo_changed), + sigc::mem_fun(*this, &MapWin::e_combo_changed), i ) ); @@ -82,44 +82,106 @@ //placing actual entry in the right place label=new Gtk::Label; - label->set_text(property_strings[i]); + label->set_text(edge_property_strings[i]); + + (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); + (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); - // labelpluscombo=new Gtk::HBox; - // labelpluscombo->pack_start(*label); - // labelpluscombo->pack_start(combo_array[i]); - - table.attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); - table.attach(combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); - - /* - if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2) - { - vbox_r1.pack_start(*labelpluscombo); - } - else - { - vbox_r2.pack_start(*labelpluscombo); - } - actpos++; - //*/ } - combos.pack_start(vbox_r1); - combos.pack_start(vbox_r2); + vbox.pack_start(*(new Gtk::Label("Edge properties"))); - //add(combos); - add(table); + vbox.pack_start(*table); + + vbox.pack_start(*(new Gtk::HSeparator)); + + n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM]; + + table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false); + + for(int i=0;i * >::iterator emsi=ms.beginOfNodeMaps(); + std::set props; + + int actprop; + + //here we find out, which map is the default in MapStorage for this property, which are not + for(int j=0;jsecond==&(ms.default_nodemaps[i])) + { + actprop=j; + } + //this is the other maps to show for this property + for(int k=0;ksecond==&(ms.default_nodemaps[k])) + { + props.insert(j); + } + } + emsi++; + } + + //filling in combo box with choices + std::list listStrings; + + listStrings.push_back("Default"); + + emsi=ms.beginOfNodeMaps(); + + for(int j=0;jfirst); + } + emsi++; + } + + n_combo_array[i].set_popdown_strings(listStrings); + + //Restrict it to these choices only: + n_combo_array[i].set_value_in_list(); + + //binding signal to thew actual entry + n_combo_array[i].get_entry()->signal_changed().connect + ( + sigc::bind + ( + sigc::mem_fun(*this, &MapWin::n_combo_changed), + i + ) + ); + + //placing actual entry in the right place + + label=new Gtk::Label; + label->set_text(node_property_strings[i]); + + (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); + (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); + + + } + + add(vbox); + + vbox.pack_start(*(new Gtk::Label("Node properties"))); + + vbox.pack_start(*table); show_all_children(); } -void MapWin::combo_changed(int prop) +void MapWin::e_combo_changed(int prop) { - - //most nem kommentezem fel, mert ugyis valtozik - Gtk::Entry* entry = combo_array[prop].get_entry(); + Gtk::Entry* entry = e_combo_array[prop].get_entry(); if(entry) { @@ -128,21 +190,21 @@ { if(mapname=="Default") { - mapname=property_strings[prop]; + mapname=edge_property_strings[prop]; } if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) { switch(prop) { - case WIDTH: - gdc.changeLineWidth(mapname); + case E_WIDTH: + gdc.changeEdgeWidth(mapname); break; - case COLOR: - gdc.changeColor(mapname); + case E_COLOR: + gdc.changeEdgeColor(mapname); break; - case TEXT: - gdc.changeText(mapname); + case E_TEXT: + gdc.changeEdgeText(mapname); break; default: std::cout<<"Error\n"; @@ -151,3 +213,118 @@ } } }; + +void MapWin::n_combo_changed(int prop) +{ + + Gtk::Entry* entry = n_combo_array[prop].get_entry(); + + if(entry) + { + Glib::ustring mapname = entry->get_text(); + if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. + { + if(mapname=="Default") + { + mapname=node_property_strings[prop]; + } + + if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) + { + switch(prop) + { + case N_RADIUS: + gdc.changeNodeRadius(mapname); + break; + case N_COLOR: + gdc.changeNodeColor(mapname); + break; + case N_TEXT: + gdc.changeNodeText(mapname); + break; + default: + std::cout<<"Error\n"; + } + } + } + } +}; + +void MapWin::update_node(Graph::Node node) +{ + for(int i=0;iget_text(); + if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. + { + if(mapname=="Default") + { + mapname=node_property_strings[i]; + } + + if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) + { + switch(i) + { + case N_RADIUS: + //gdc.changeNodeRadius(mapname, node); + std::cout << "If default map-value problem is solved, uncomment line in MapWin::node_update!" << std::endl; + break; + case N_COLOR: + gdc.changeNodeColor(mapname, node); + break; + case N_TEXT: + gdc.changeNodeText(mapname, node); + break; + default: + std::cout<<"Error\n"; + } + } + } + } + } +} + +void MapWin::update_edge(Graph::Edge edge) +{ + for(int i=0;iget_text(); + if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. + { + if(mapname=="Default") + { + mapname=edge_property_strings[i]; + } + + if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) + { + switch(i) + { + case E_WIDTH: + //gdc.changeEdgeWidth(mapname, edge); + std::cout << "If default map-value problem is solved, uncomment line in MapWin::edge_update!" << std::endl; + break; + case E_COLOR: + gdc.changeEdgeColor(mapname, edge); + break; + case E_TEXT: + gdc.changeEdgeText(mapname, edge); + break; + default: + std::cout<<"Error\n"; + } + } + } + } + } +} diff -r d6b95a59da26 -r e54392395480 gui/map_win.h --- a/gui/map_win.h Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/map_win.h Fri Jun 24 18:16:12 2005 +0000 @@ -3,6 +3,8 @@ #ifndef MAP_WIN_H #define MAP_WIN_H +class MapWin; + #include #include #include @@ -24,15 +26,14 @@ ///The \ref MapStorage in which the visualizable maps are stored MapStorage & ms; - Gtk::Table table; + Gtk::Table * table; - Gtk::HBox combos, * labelpluscombo; - Gtk::Combo * combo_array; - - Gtk::VBox vbox_b, vbox_r1, vbox_r2; + Gtk::Combo * e_combo_array, * n_combo_array; Gtk::Label * label; + Gtk::VBox vbox; + public: ///Constructor of MapWin creates the widgets shown in MapWin. MapWin(const std::string& title, MapStorage &, GraphDisplayerCanvas &); @@ -41,7 +42,19 @@ ///which button was that and after that calls the ///appropriate function of the \ref GraphDisplayerCanvas ///to change the visible values of that attribute. - virtual void combo_changed(int); + virtual void e_combo_changed(int); + ///If a radiobutton is clicked, this function determines + ///which button was that and after that calls the + ///appropriate function of the \ref GraphDisplayerCanvas + ///to change the visible values of that attribute. + virtual void n_combo_changed(int); + + ///This function is created to set the appropriate maps on the newly created node + void update_node(Graph::Node); + + ///This function is created to set the appropriate maps on the newly created edge + void update_edge(Graph::Edge); + virtual bool close_if_escape_is_pressed(GdkEventKey*); }; diff -r d6b95a59da26 -r e54392395480 gui/mapstorage.cc --- a/gui/mapstorage.cc Fri Jun 24 08:44:54 2005 +0000 +++ b/gui/mapstorage.cc Fri Jun 24 18:16:12 2005 +0000 @@ -2,20 +2,34 @@ MapStorage::MapStorage(Graph & graph):g(graph) { - for(int i=0;i emd(g); + Graph::EdgeMap emd(g,edge_property_defaults[i]); default_edgemaps.push_back(emd); - Graph::NodeMap nmd(g); + } + + for(int i=0;i nmd(g,node_property_defaults[i]); default_nodemaps.push_back(nmd); } - for(int i=0;i