COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
09/25/06 09:54:00 (18 years ago)
Author:
Akos Ladanyi
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@2953
Message:

LoopEdge? improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas-event.cc

    r150 r151  
    410410          if(target_node!=INVALID)
    411411          {
     412            (mytab.mapstorage).modified = true;
     413
     414            *(nodesmap[target_node]) <<
     415              Gnome::Canvas::Properties::fill_color("red");
     416
     417            //creating new edge
     418            active_edge=(mytab.mapstorage).graph.addEdge(active_node,
     419                target_node);
     420
     421            // update maps
     422            for (std::map<std::string,
     423                Graph::EdgeMap<double>*>::const_iterator it =
     424                (mytab.mapstorage).edgemap_storage.begin(); it !=
     425                (mytab.mapstorage).edgemap_storage.end(); ++it)
     426            {
     427              (*(it->second))[active_edge] =
     428                (mytab.mapstorage).edgemap_default[it->first];
     429            }
     430            // increment the id map's default value
     431            (mytab.mapstorage).edgemap_default["label"] += 1.0;
     432
    412433            if(target_node!=active_node)               
    413434            {
    414               (mytab.mapstorage).modified = true;
    415 
    416               *(nodesmap[target_node]) <<
    417                 Gnome::Canvas::Properties::fill_color("red");
    418 
    419               //creating new edge
    420               active_edge=(mytab.mapstorage).graph.addEdge(active_node,
    421                   target_node);
    422 
    423               // update maps
    424               for (std::map<std::string,
    425                   Graph::EdgeMap<double>*>::const_iterator it =
    426                   (mytab.mapstorage).edgemap_storage.begin(); it !=
    427                   (mytab.mapstorage).edgemap_storage.end(); ++it)
    428               {
    429                 (*(it->second))[active_edge] =
    430                   (mytab.mapstorage).edgemap_default[it->first];
    431               }
    432               // increment the id map's default value
    433               (mytab.mapstorage).edgemap_default["label"] += 1.0;
    434 
    435               //calculating coordinates of new edge
    436               Gnome::Canvas::Points coos;
    437               double x1, x2, y1, y2;
    438 
    439               active_item->get_bounds(x1, y1, x2, y2);
    440               coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    441 
    442               target_item->get_bounds(x1, y1, x2, y2);
    443               coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    444 
    445435              // set the coordinates of the arrow on the new edge
    446436              MapStorage& ms = mytab.mapstorage;
     
    452442              edgesmap[active_edge]=new BrokenEdge(displayed_graph, active_edge,
    453443                  *this);
    454 
    455               //initializing edge-text as well, to empty string
    456               XY text_pos=mytab.mapstorage.arrow_pos[active_edge];
    457               text_pos+=(XY(10,10));
    458 
    459               edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,
    460                   text_pos.x, text_pos.y, "");
    461               edgetextmap[active_edge]->property_fill_color().set_value(
    462                   "darkgreen");
    463               edgetextmap[active_edge]->raise_to_top();
    464 
    465               //updating its properties
    466 //               mapwin.updateEdge(active_edge);
    467               propertyUpdate(active_edge);
    468444            }
    469445            else
    470446            {
    471               target_node=INVALID;
    472               std::cerr << "Loop edge is not yet implemented!" << std::endl;
     447              // set the coordinates of the arrow on the new edge
     448              MapStorage& ms = mytab.mapstorage;
     449              ms.arrow_pos.set(active_edge,
     450                  (ms.coords[ms.graph.source(active_edge)] +
     451                   XY(0.0, 80.0)));
     452
     453              //drawing new edge
     454              edgesmap[active_edge]=new LoopEdge(displayed_graph, active_edge,
     455                  *this);
    473456            }
     457
     458            //initializing edge-text as well, to empty string
     459            XY text_pos=mytab.mapstorage.arrow_pos[active_edge];
     460            text_pos+=(XY(10,10));
     461
     462            edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,
     463                text_pos.x, text_pos.y, "");
     464            edgetextmap[active_edge]->property_fill_color().set_value(
     465                "darkgreen");
     466            edgetextmap[active_edge]->raise_to_top();
     467
     468            propertyUpdate(active_edge);
    474469          }
    475470          //clicked item was not a node. it could be an e.g. edge. we do not
Note: See TracChangeset for help on using the changeset viewer.