# HG changeset patch # User hegyi # Date 1120074270 0 # Node ID 66e85f44a66fa7fb4fd89e01676ac4806a943331 # Parent f70bbee5350a8fb4bb568a81cffee04eba0726ba Uh, long comment arrives... Zoom update does not happen after editorial steps. Nodes initial color is light blue, if there is any item under them. Strange node-text relations disappeared. Initial values of new items are given now in a more common way. The wood-cutter way of handling default values of properties is now changed. diff -r f70bbee5350a -r 66e85f44a66f graph_displayer_canvas-edge.cc --- a/graph_displayer_canvas-edge.cc Wed Jun 29 15:41:33 2005 +0000 +++ b/graph_displayer_canvas-edge.cc Wed Jun 29 19:44:30 2005 +0000 @@ -5,11 +5,21 @@ int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Graph::Edge edge) { + Graph::EdgeMap * actual_map; + if(mapname=="Default") + { + actual_map=new Graph::EdgeMap(g,edge_property_defaults[E_WIDTH]); + } + else + { + actual_map=(mapstorage.edgemap_storage)[mapname]; + } + if(edge==INVALID) { for (EdgeIt i(g); i!=INVALID; ++i) { - int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; + int w=(int)(*actual_map)[i]; if(w>=0) { edgesmap[i]->property_width_pixels().set_value(w); @@ -18,7 +28,7 @@ } else { - int w=(int)(*(mapstorage.edgemap_storage)[mapname])[edge]; + int w=(int)(*actual_map)[edge]; if(w>=0) { edgesmap[edge]->property_width_pixels().set_value(w); @@ -33,16 +43,35 @@ //function maps the range of the maximum and //the minimum of the nodemap to the range of //green in RGB + Graph::EdgeMap * actual_map; + if(mapname=="Default") + { + actual_map=new Graph::EdgeMap(g,edge_property_defaults[E_COLOR]); + } + else + { + actual_map=(mapstorage.edgemap_storage)[mapname]; + } + + double max, min; + + if(mapname!="Default") + { + max=mapstorage.maxOfEdgeMap(mapname); + min=mapstorage.minOfEdgeMap(mapname); + } + else + { + max=edge_property_defaults[E_COLOR]; + min=edge_property_defaults[E_COLOR]; + } + 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); - - //std::cout<property_fill_color_gdk().set_value(color); } } else { - double w=(*(mapstorage.edgemap_storage)[mapname])[edge]; - double max=mapstorage.maxOfEdgeMap(mapname); - double min=mapstorage.minOfEdgeMap(mapname); - - //std::cout<button.x; - clicked_y=e->button.y; - active_item=(get_item_at(e->button.x, e->button.y)); + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); + + active_item=(get_item_at(clicked_x, clicked_y)); active_node=INVALID; for (NodeIt i(g); i!=INVALID; ++i) { @@ -85,7 +84,6 @@ isbutton=0; active_item=NULL; active_node=INVALID; - updateScrollRegion(); break; case GDK_MOTION_NOTIFY: //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 @@ -96,15 +94,19 @@ //new coordinate therefore the new movement //has to be calculated from here - double dx=e->motion.x-clicked_x; - double dy=e->motion.y-clicked_y; + double new_x, new_y; + + window_to_world (e->motion.x, e->motion.y, new_x, new_y); + + double dx=new_x-clicked_x; + double dy=new_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; + clicked_x=new_x; + clicked_y=new_y; //all the edges connected to the moved point has to be redrawn EdgeIt ei; @@ -168,7 +170,7 @@ default: break; } - return true; + return false; } bool GraphDisplayerCanvas::createNodeEventHandler(GdkEvent* e) @@ -177,16 +179,21 @@ { //draw the new node in red at the clicked place + case GDK_2BUTTON_PRESS: + std::cout << "double click" << std::endl; + break; case GDK_BUTTON_PRESS: isbutton=1; active_node=NodeIt(g,g.addNode()); //initiating values corresponding to new node in maps - window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); + target_item=NULL; + target_item=get_item_at(clicked_x, clicked_y); + nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20); active_item=(Gnome::Canvas::Item *)(nodesmap[active_node]); *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red"); @@ -205,9 +212,8 @@ { double world_motion_x, world_motion_y; GdkEvent * generated=new GdkEvent(); - window_to_world (e->motion.x, e->motion.y, world_motion_x, world_motion_y); - generated->motion.x=world_motion_x; - generated->motion.y=world_motion_y; + generated->motion.x=e->motion.x; + generated->motion.y=e->motion.y; generated->type=GDK_MOTION_NOTIFY; moveEventHandler(generated); break; @@ -216,10 +222,19 @@ //finalize the new node case GDK_BUTTON_RELEASE: isbutton=0; - *active_item << Gnome::Canvas::Properties::fill_color("blue"); + if(!target_item) + { + //Its appropriate color is given by update. + //*active_item << Gnome::Canvas::Properties::fill_color("blue"); + } + else + { + //In this case the given color has to be overwritten, because the noe covers an other item. + *active_item << Gnome::Canvas::Properties::fill_color("lightblue"); + } + target_item=NULL; active_item=NULL; active_node=INVALID; - updateScrollRegion(); break; default: break; @@ -239,9 +254,10 @@ if(active_node==INVALID) { //we mark the location of the event to be able to calculate parameters of dragging - clicked_x=e->button.x; - clicked_y=e->button.y; - active_item=(get_item_at(e->button.x, e->button.y)); + + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); + + active_item=(get_item_at(clicked_x, clicked_y)); active_node=INVALID; for (NodeIt i(g); i!=INVALID; ++i) { @@ -269,7 +285,8 @@ //node else { - target_item=(get_item_at(e->button.x, e->button.y)); + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); + target_item=(get_item_at(clicked_x, clicked_y)); Graph::NodeIt target_node=INVALID; for (NodeIt i(g); i!=INVALID; ++i) { @@ -366,7 +383,8 @@ switch(e->type) { case GDK_BUTTON_PRESS: - active_item=(get_item_at(e->button.x, e->button.y)); + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); + active_item=(get_item_at(clicked_x, clicked_y)); active_node=INVALID; active_edge=INVALID; for (NodeIt i(g); i!=INVALID; ++i) @@ -386,56 +404,61 @@ } } } - *active_item << Gnome::Canvas::Properties::fill_color("red"); + if(active_item) + { + *active_item << Gnome::Canvas::Properties::fill_color("red"); + } break; case GDK_BUTTON_RELEASE: - if(active_item==(get_item_at(e->button.x, e->button.y))) + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); + if(active_item) { - if(active_node!=INVALID) + if( active_item == ( get_item_at (clicked_x, clicked_y) ) ) { + if(active_node!=INVALID) + { - //collecting edges to delete - EdgeIt e; - std::set edges_to_delete; + //collecting edges to delete + EdgeIt e; + std::set edges_to_delete; - g.firstOut(e,active_node); - for(;e!=INVALID;g.nextOut(e)) + g.firstOut(e,active_node); + for(;e!=INVALID;g.nextOut(e)) + { + edges_to_delete.insert(e); + } + + g.firstIn(e,active_node); + for(;e!=INVALID;g.nextIn(e)) + { + edges_to_delete.insert(e); + } + + //deleting collected edges + for(std::set::iterator edge_set_it=edges_to_delete.begin();edge_set_it!=edges_to_delete.end();edge_set_it++) + { + deleteItem(*edge_set_it); + } + deleteItem(active_node); + } + //a simple edge was chosen + else { - edges_to_delete.insert(e); + deleteItem(active_edge); } - - g.firstIn(e,active_node); - for(;e!=INVALID;g.nextIn(e)) - { - edges_to_delete.insert(e); - } - - //deleting collected edges - for(std::set::iterator edge_set_it=edges_to_delete.begin();edge_set_it!=edges_to_delete.end();edge_set_it++) - { - deleteItem(*edge_set_it); - } - deleteItem(active_node); } - //a simple edge was chosen + //pointer was moved, deletion is cancelled else { - deleteItem(active_edge); - } - - - } - //pointer was moved, deletion is cancelled - else - { - if(active_node!=INVALID) - { - *active_item << Gnome::Canvas::Properties::fill_color("blue"); - } - else - { - *active_item << Gnome::Canvas::Properties::fill_color("green"); + if(active_node!=INVALID) + { + *active_item << Gnome::Canvas::Properties::fill_color("blue"); + } + else + { + *active_item << Gnome::Canvas::Properties::fill_color("green"); + } } } //reseting datas @@ -450,7 +473,7 @@ default: break; } - return true; + return false; } void GraphDisplayerCanvas::deleteItem(NodeIt node_to_delete) diff -r f70bbee5350a -r 66e85f44a66f graph_displayer_canvas-node.cc --- a/graph_displayer_canvas-node.cc Wed Jun 29 15:41:33 2005 +0000 +++ b/graph_displayer_canvas-node.cc Wed Jun 29 19:44:30 2005 +0000 @@ -5,15 +5,28 @@ int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Graph::Node node) { + Graph::NodeMap * actual_map; + if(mapname=="Default") + { + actual_map=new Graph::NodeMap(g,node_property_defaults[N_RADIUS]); + } + else + { + actual_map=(mapstorage.nodemap_storage)[mapname]; + } + if(node==INVALID) { for (NodeIt i(g); i!=INVALID; ++i) { - int w=(int)(*(mapstorage.nodemap_storage)[mapname])[i]; + int w=(int)(*actual_map)[i]; if(w>=0) { double x1, y1, x2, y2; - nodesmap[i]->get_bounds(x1, y1, x2, y2); + x1=nodesmap[i]->property_x1().get_value(); + x2=nodesmap[i]->property_x2().get_value(); + y1=nodesmap[i]->property_y1().get_value(); + y2=nodesmap[i]->property_y2().get_value(); 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); @@ -23,11 +36,16 @@ } else { - int w=(int)(*(mapstorage.nodemap_storage)[mapname])[node]; + //I think only new nodes use this case +// int w=(int)(*actual_map)[node]; + int w=(int)(node_property_defaults[N_RADIUS]); if(w>=0) { double x1, y1, x2, y2; - nodesmap[node]->get_bounds(x1, y1, x2, y2); + x1=nodesmap[node]->property_x1().get_value(); + x2=nodesmap[node]->property_x2().get_value(); + y1=nodesmap[node]->property_y1().get_value(); + y2=nodesmap[node]->property_y2().get_value(); 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); @@ -44,17 +62,39 @@ //the minimum of the nodemap to the range of //green in RGB + Graph::NodeMap * actual_map; + if(mapname=="Default") + { + actual_map=new Graph::NodeMap(g,node_property_defaults[N_COLOR]); + } + else + { + actual_map=(mapstorage.nodemap_storage)[mapname]; + } + + double max, min; + + if(mapname!="Default") + { + max=mapstorage.maxOfNodeMap(mapname); + min=mapstorage.minOfNodeMap(mapname); + } + else + { + max=node_property_defaults[N_COLOR]; + min=node_property_defaults[N_COLOR]; + } + + 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< * actual_map; + if(mapname=="Default") + { + actual_map=new Graph::NodeMap(g,node_property_defaults[N_COLOR]); + } + else + { + actual_map=(mapstorage.nodemap_storage)[mapname]; + } if(node==INVALID) { for (NodeIt i(g); i!=INVALID; ++i) { - if(mapname!=node_property_strings[N_TEXT]) + if(mapname!="Default") { - double number=(*(mapstorage.nodemap_storage)[mapname])[i]; + double number=(*actual_map)[i]; int length=1; //if number is smaller than one, length would be negative, or invalid if(number>=1) @@ -138,9 +185,9 @@ } else { - if(mapname!=node_property_strings[N_TEXT]) + if(mapname!="Default") { - double number=(*(mapstorage.nodemap_storage)[mapname])[node]; + double number=(*actual_map)[node]; int length=1; //if number is smaller than one, length would be negative, or invalid if(number>=1) diff -r f70bbee5350a -r 66e85f44a66f graph_displayer_canvas.cc --- a/graph_displayer_canvas.cc Wed Jun 29 15:41:33 2005 +0000 +++ b/graph_displayer_canvas.cc Wed Jun 29 19:44:30 2005 +0000 @@ -5,7 +5,7 @@ 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::createNodeEventHandler), false); + actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false); actual_tool=CREATE_NODE; active_node=INVALID; diff -r f70bbee5350a -r 66e85f44a66f map_win.cc --- a/map_win.cc Wed Jun 29 15:41:33 2005 +0000 +++ b/map_win.cc Wed Jun 29 19:44:30 2005 +0000 @@ -23,45 +23,15 @@ for(int i=0;i * >::iterator emsi=ms.beginOfEdgeMaps(); - 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_edgemaps[i])) - { - actprop=j; - } - //these are the maps NOT to show for this property - for(int k=0;ksecond==&(ms.default_edgemaps[k])) - { - props.insert(j); - } - } - emsi++; - } - //filling in combo box with choices std::list listStrings; listStrings.push_back("Default"); - emsi=ms.beginOfEdgeMaps(); - - for(int j=0;j * >::iterator emsi=ms.beginOfEdgeMaps(); + for(;emsi!=ms.endOfEdgeMaps();emsi++) { - if( ( props.find(j) )==( props.end() ) ) - { listStrings.push_back(emsi->first); - } - emsi++; } e_combo_array[i].set_popdown_strings(listStrings); @@ -102,45 +72,16 @@ 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(); + std::map< std::string,Graph::NodeMap * >::iterator emsi=ms.beginOfNodeMaps(); - for(int j=0;jfirst); - } - emsi++; + listStrings.push_back(emsi->first); } n_combo_array[i].set_popdown_strings(listStrings); @@ -188,12 +129,7 @@ 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=edge_property_strings[prop]; - } - - if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) + if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") ) { switch(prop) { @@ -224,12 +160,7 @@ 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() ) + if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") ) { switch(prop) { @@ -261,18 +192,12 @@ 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[i]; - } - - if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) + if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") ) { 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; + gdc.changeNodeRadius(mapname, node); break; case N_COLOR: gdc.changeNodeColor(mapname, node); @@ -301,18 +226,13 @@ 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=edge_property_strings[i]; - } - if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) + if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") ) { 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; + gdc.changeEdgeWidth(mapname, edge); break; case E_COLOR: gdc.changeEdgeColor(mapname, edge); diff -r f70bbee5350a -r 66e85f44a66f mapstorage.cc --- a/mapstorage.cc Wed Jun 29 15:41:33 2005 +0000 +++ b/mapstorage.cc Wed Jun 29 19:44:30 2005 +0000 @@ -2,36 +2,6 @@ MapStorage::MapStorage(Graph & graph):g(graph) { - for(int i=0;i emd(g,edge_property_defaults[i]); - default_edgemaps.push_back(emd); - } - - for(int i=0;i nmd(g,node_property_defaults[i]); - default_nodemaps.push_back(nmd); - } - - for(int i=0;i *nodemap) @@ -102,19 +72,9 @@ void MapStorage::initMapsForEdge(Graph::Edge e) { - e=e; -// beragad, aztan csovez -// std::map< std::string,Graph::EdgeMap * >::iterator ems_it; -// for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++) -// { -// std::cout << "szevasz\n"; -// (*((*ems_it).second))[e]=0; -// } -// std::cout << std::endl; - -// g_closure_invoke... -// for(int i=0;i * >::iterator ems_it; + for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++) + { + (*((*ems_it).second))[e]=5; + } } diff -r f70bbee5350a -r 66e85f44a66f mapstorage.h --- a/mapstorage.h Wed Jun 29 15:41:33 2005 +0000 +++ b/mapstorage.h Wed Jun 29 19:44:30 2005 +0000 @@ -81,6 +81,12 @@ ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage. std::map< std::string,Graph::EdgeMap * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();}; + ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage. + std::map< std::string,Graph::NodeMap * >::iterator endOfNodeMaps(){return nodemap_storage.end();}; + + ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage. + std::map< std::string,Graph::EdgeMap * >::iterator endOfEdgeMaps(){return edgemap_storage.end();}; + ///This function sets a default base value for the newly created node void initMapsForNode(NodeIt);