COIN-OR::LEMON - Graph Library

Changeset 1860:27a9a75b957b in lemon-0.x for gui/mapstorage.cc


Ignore:
Timestamp:
12/17/05 21:55:41 (18 years ago)
Author:
Akos Ladanyi
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2432
Message:

Save and load the coordinates of the arrows on the edges.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gui/mapstorage.cc

    r1837 r1860  
    11#include "mapstorage.h"
     2#include "gui_writer.h"
     3#include "gui_reader.h"
    24#include <gtkmm.h>
    35#include <cmath>
     
    57#include <cmath>
    68
    7 MapStorage::MapStorage() : modified(false), file_name("")
     9MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false)
    810{
    911  nodemap_storage["coordinates_x"] = new Graph::NodeMap<double>(graph);
     
    1113  nodemap_storage["coordinates_y"] = new Graph::NodeMap<double>(graph);
    1214  coords.setYMap(*nodemap_storage["coordinates_y"]);
     15
     16  edgemap_storage["arrow_pos_x"] = new Graph::EdgeMap<double>(graph);
     17  arrow_pos.setXMap(*edgemap_storage["arrow_pos_x"]);
     18  edgemap_storage["arrow_pos_y"] = new Graph::EdgeMap<double>(graph);
     19  arrow_pos.setYMap(*edgemap_storage["arrow_pos_y"]);
    1320
    1421  nodemap_storage["id"] = new Graph::NodeMap<double>(graph);
     
    248255      greader.readEdgeMap(*it, *edgemap_storage[*it]);
    249256    }
     257    GuiReader gui_reader(greader, this);
    250258    greader.run();
    251259  } catch (DataFormatError& error) {
     
    284292  }
    285293
     294  if (!arrow_pos_read_ok)
     295  {
     296    arrow_pos_read_ok = false;
     297    for (EdgeIt e(graph); e != INVALID; ++e)
     298    {
     299      arrow_pos.set(e, (coords[graph.source(e)] + coords[graph.target(e)]) / 2.0);
     300    }
     301  }
     302
    286303  // fill in the default values for the maps
    287304  for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
     
    339356  {
    340357    gwriter.writeNodeMap(it->first, *(it->second));
    341     //std::cout << "wrote " << it->first << " nodemap" << std::endl;
    342358  }
    343359  for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
    344360      edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
    345361  {
    346     gwriter.writeEdgeMap(it->first, *(it->second));
    347     //std::cout << "wrote " << it->first << " edgemap" << std::endl;
    348   }
     362    if ((it->first != "arrow_pos_x") &&
     363        (it->first != "arrow_pos_y"))
     364    {
     365      gwriter.writeEdgeMap(it->first, *(it->second));
     366    }
     367  }
     368
     369  GuiWriter gui_writer(gwriter, this);
     370
    349371  gwriter.run();
    350372}
     
    366388      edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
    367389  {
    368     if (it->first != "id")
     390    if ((it->first != "id") &&
     391        (it->first != "arrow_pos_x") &&
     392        (it->first != "arrow_pos_y"))
    369393    {
    370394      delete it->second;
     
    388412  modified = false;
    389413}
     414
     415void MapStorage::ArrowPosReadOK()
     416{
     417  arrow_pos_read_ok = true;
     418}
Note: See TracChangeset for help on using the changeset viewer.