COIN-OR::LEMON - Graph Library

Changeset 96:e664d8aa3f72 in glemon-0.x for graph_displayer_canvas-event.cc


Ignore:
Timestamp:
12/06/05 11:53:38 (18 years ago)
Author:
Hegyi Péter
Branch:
gui
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2414
Message:

Notebook style is provided. Without opportunity to close tabs. :-) But with all other necessary things (I think).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas-event.cc

    r94 r96  
    9595      active_item=(get_item_at(clicked_x, clicked_y));
    9696      active_node=INVALID;
    97       for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     97      for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    9898        {
    9999          if(nodesmap[i]==active_item)
     
    126126      if(active_node!=INVALID)
    127127      {
    128         (mainwin.mapstorage).modified = true;
     128        (mytab.mapstorage).modified = true;
    129129
    130130        //new coordinates will be the old values,
     
    145145
    146146        // the new coordinates of the centre of the node
    147         double coord_x = new_x - (clicked_x - (mainwin.mapstorage).coords[active_node].x);
    148         double coord_y = new_y - (clicked_y - (mainwin.mapstorage).coords[active_node].y);
     147        double coord_x = new_x - (clicked_x - (mytab.mapstorage).coords[active_node].x);
     148        double coord_y = new_y - (clicked_y - (mytab.mapstorage).coords[active_node].y);
    149149
    150150        clicked_x=new_x;
     
    152152
    153153        // write back the new coordinates to the coords map
    154         (mainwin.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));
     154        (mytab.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));
    155155
    156156        // reposition the coordinates text
    157157        std::ostringstream ostr;
    158158        ostr << "(" <<
    159           (mainwin.mapstorage).coords[active_node].x << ", " <<
    160           (mainwin.mapstorage).coords[active_node].y << ")";
     159          (mytab.mapstorage).coords[active_node].x << ", " <<
     160          (mytab.mapstorage).coords[active_node].y << ")";
    161161        double radius =
    162162          (nodesmap[active_node]->property_x2().get_value() -
     
    165165        {
    166166          coord_text->property_text().set_value(ostr.str());
    167           coord_text->property_x().set_value((mainwin.mapstorage).coords[active_node].x +
     167          coord_text->property_x().set_value((mytab.mapstorage).coords[active_node].x +
    168168              radius);
    169           coord_text->property_y().set_value((mainwin.mapstorage).coords[active_node].y -
     169          coord_text->property_y().set_value((mytab.mapstorage).coords[active_node].y -
    170170              radius);
    171171        }
     
    174174          coord_text = new Gnome::Canvas::Text(
    175175              displayed_graph,
    176               (mainwin.mapstorage).coords[active_node].x + radius,
    177               (mainwin.mapstorage).coords[active_node].y - radius,
     176              (mytab.mapstorage).coords[active_node].x + radius,
     177              (mytab.mapstorage).coords[active_node].y - radius,
    178178              ostr.str());
    179179          coord_text->property_fill_color().set_value("black");
     
    182182
    183183        //all the edges connected to the moved point has to be redrawn
    184         for(OutEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
     184        for(OutEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
    185185        {
    186186            Gnome::Canvas::Points coos;
    187187            double x1, x2, y1, y2;
    188188
    189             nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
     189            nodesmap[(mytab.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
    190190            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    191191
    192             nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
     192            nodesmap[(mytab.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
    193193            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    194194
     
    209209        }
    210210
    211         for(InEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
     211        for(InEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
    212212        {
    213213            Gnome::Canvas::Points coos;
    214214            double x1, x2, y1, y2;
    215215
    216             nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
     216            nodesmap[(mytab.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
    217217            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    218218
    219             nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
     219            nodesmap[(mytab.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
    220220            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    221221
     
    257257
    258258    case GDK_BUTTON_RELEASE:
    259       (mainwin.mapstorage).modified = true;
     259      (mytab.mapstorage).modified = true;
    260260
    261261      isbutton=1;
    262262
    263       active_node=(mainwin.mapstorage).graph.addNode();
     263      active_node=(mytab.mapstorage).graph.addNode();
    264264
    265265      //initiating values corresponding to new node in maps
     
    268268
    269269      // update coordinates
    270       (mainwin.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y));
     270      (mytab.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y));
    271271
    272272      // update all other maps
    273273      for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
    274           (mainwin.mapstorage).nodemap_storage.begin(); it !=
    275           (mainwin.mapstorage).nodemap_storage.end(); ++it)
     274          (mytab.mapstorage).nodemap_storage.begin(); it !=
     275          (mytab.mapstorage).nodemap_storage.end(); ++it)
    276276      {
    277277        if ((it->first != "coordinates_x") &&
     
    279279        {
    280280          (*(it->second))[active_node] =
    281             (mainwin.mapstorage).nodemap_default[it->first];
     281            (mytab.mapstorage).nodemap_default[it->first];
    282282        }
    283283      }
    284284      // increment the id map's default value
    285       (mainwin.mapstorage).nodemap_default["id"] += 1.0;
     285      (mytab.mapstorage).nodemap_default["id"] += 1.0;
    286286
    287287      nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
     
    333333          active_item=(get_item_at(clicked_x, clicked_y));
    334334          active_node=INVALID;
    335           for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     335          for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    336336          {
    337337            if(nodesmap[i]==active_item)
     
    362362          target_item=(get_item_at(clicked_x, clicked_y));
    363363          Node target_node=INVALID;
    364           for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     364          for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    365365          {
    366366            if(nodesmap[i]==target_item)
     
    374374            if(target_node!=active_node)               
    375375            {
    376               (mainwin.mapstorage).modified = true;
     376              (mytab.mapstorage).modified = true;
    377377
    378378              *(nodesmap[target_node]) <<
     
    380380
    381381              //creating new edge
    382               active_edge=(mainwin.mapstorage).graph.addEdge(active_node,
     382              active_edge=(mytab.mapstorage).graph.addEdge(active_node,
    383383                  target_node);
    384384
     
    386386              for (std::map<std::string,
    387387                  Graph::EdgeMap<double>*>::const_iterator it =
    388                   (mainwin.mapstorage).edgemap_storage.begin(); it !=
    389                   (mainwin.mapstorage).edgemap_storage.end(); ++it)
     388                  (mytab.mapstorage).edgemap_storage.begin(); it !=
     389                  (mytab.mapstorage).edgemap_storage.end(); ++it)
    390390              {
    391391                (*(it->second))[active_edge] =
    392                   (mainwin.mapstorage).edgemap_default[it->first];
     392                  (mytab.mapstorage).edgemap_default[it->first];
    393393              }
    394394              // increment the id map's default value
    395               (mainwin.mapstorage).edgemap_default["id"] += 1.0;
     395              (mytab.mapstorage).edgemap_default["id"] += 1.0;
    396396
    397397              //calculating coordinates of new edge
     
    481481      active_edge=INVALID;
    482482      //was it a node?
    483       for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     483      for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    484484        {
    485485          if(nodesmap[i]==active_item)
     
    491491      if(active_node==INVALID)
    492492        {
    493           for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     493          for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    494494            {
    495495              if(edgesmap[i]==active_item)
     
    517517              if(active_node!=INVALID)
    518518                {
    519                   (mainwin.mapstorage).modified = true;
     519                  (mytab.mapstorage).modified = true;
    520520
    521521                  std::set<Graph::Edge> edges_to_delete;
    522522
    523                   for(OutEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
     523                  for(OutEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e)
    524524                    {
    525525                      edges_to_delete.insert(e);
    526526                    }
    527527                 
    528                   for(InEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
     528                  for(InEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e)
    529529                    {
    530530                      edges_to_delete.insert(e);
     
    590590
    591591          //find the activated item between texts
    592           for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     592          for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    593593          {
    594594            //at the same time only one can be active
     
    602602          if(clicked_edge==INVALID)
    603603          {
    604             for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     604            for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    605605            {
    606606              //at the same time only one can be active
     
    625625
    626626              //create a dialog
    627               Gtk::Dialog dialog("Edit value", mainwin, true);
     627              Gtk::Dialog dialog("Edit value", true);
    628628              dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    629629              dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
     
    642642                case Gtk::RESPONSE_ACCEPT:
    643643                  double new_value = spin.get_value();
    644                   (*(mainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
     644                  (*(mytab.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
    645645                    new_value;
    646646                  std::ostringstream ostr;
     
    678678
    679679          //find the activated item between texts
    680           for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     680          for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    681681          {
    682682            //at the same time only one can be active
     
    690690          if(clicked_node==INVALID)
    691691          {
    692             for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     692            for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    693693            {
    694694              //at the same time only one can be active
     
    713713
    714714              //create a dialog
    715               Gtk::Dialog dialog("Edit value", mainwin, true);
     715              Gtk::Dialog dialog("Edit value", true);
    716716              dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    717717              dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
     
    730730                case Gtk::RESPONSE_ACCEPT:
    731731                  double new_value = spin.get_value();
    732                   (*(mainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
     732                  (*(mytab.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
    733733                    new_value;
    734734                  std::ostringstream ostr;
     
    755755  delete(nodetextmap[node_to_delete]);
    756756  delete(nodesmap[node_to_delete]);
    757   (mainwin.mapstorage).graph.erase(node_to_delete);
     757  (mytab.mapstorage).graph.erase(node_to_delete);
    758758}
    759759
     
    762762  delete(edgetextmap[edge_to_delete]);
    763763  delete(edgesmap[edge_to_delete]);
    764   (mainwin.mapstorage).graph.erase(edge_to_delete);
     764  (mytab.mapstorage).graph.erase(edge_to_delete);
    765765}
    766766
     
    782782      else
    783783        {
    784           for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     784          for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    785785            {
    786786              if(edgesmap[i]==active_bre)
     
    808808{
    809809  //create the new map
    810   Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mainwin.mapstorage).graph, default_value);
     810  Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mytab.mapstorage).graph, default_value);
    811811
    812812  //if addition was not successful addEdgeMap returns one.
    813813  //cause can be that there is already a map named like the new one
    814   if((mainwin.mapstorage).addEdgeMap(mapname,emptr, default_value))
     814  if((mytab.mapstorage).addEdgeMap(mapname,emptr, default_value))
    815815    {
    816816      return 1;
     
    819819
    820820  //add it to the list of the displayable maps
    821   mainwin.registerNewEdgeMap(mapname);
     821  mytab.registerNewEdgeMap(mapname);
    822822
    823823  //display it
     
    830830{
    831831  //create the new map
    832   Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mainwin.mapstorage).graph,default_value);
     832  Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mytab.mapstorage).graph,default_value);
    833833
    834834  //if addition was not successful addNodeMap returns one.
    835835  //cause can be that there is already a map named like the new one
    836   if((mainwin.mapstorage).addNodeMap(mapname,emptr, default_value))
     836  if((mytab.mapstorage).addNodeMap(mapname,emptr, default_value))
    837837    {
    838838      return 1;
     
    840840
    841841  //add it to the list of the displayable maps
    842   mainwin.registerNewNodeMap(mapname);
     842  mytab.registerNewNodeMap(mapname);
    843843
    844844  //display it
Note: See TracChangeset for help on using the changeset viewer.