mapstorage.cc
changeset 191 af2ed974ab68
parent 184 4e8704aae278
child 194 6b2b718420eb
     1.1 --- a/mapstorage.cc	Tue Feb 20 17:45:44 2007 +0000
     1.2 +++ b/mapstorage.cc	Tue Feb 27 17:18:19 2007 +0000
     1.3 @@ -23,8 +23,9 @@
     1.4  #include <limits>
     1.5  #include <cmath>
     1.6  #include <gtkmm.h>
     1.7 +#include<lemon/graph_to_eps.h>
     1.8  
     1.9 -const double i_d=20;
    1.10 +const int i_d=20;
    1.11  const double a_d=0.05;
    1.12  const double p_d=40000;
    1.13  
    1.14 @@ -589,3 +590,74 @@
    1.15  {
    1.16    background_scaling = scaling;
    1.17  }
    1.18 +
    1.19 +void MapStorage::exportGraphToEPS(std::vector<bool> options, std::string filename)
    1.20 +{
    1.21 +  Graph::NodeMap<int> _nodeColors(graph, 0);
    1.22 +  Graph::EdgeMap<int> _edgeColors(graph, 0);
    1.23 +  Graph::NodeMap<double> _nodeSizes(graph, 6.0);
    1.24 +  Graph::EdgeMap<double> _edgeWidths(graph, 1.0);
    1.25 +  bool _drawArrows=options[ARROWS];
    1.26 +  bool _enableParallel=options[PAR];
    1.27 +
    1.28 +  std::string emptyString="";
    1.29 +  Graph::NodeMap<std::string> _nodeTextMap(graph,emptyString);
    1.30 +
    1.31 +  //_nodeTextMap=(Graph::NodeMap<void> *)&emptyStringMap;
    1.32 +
    1.33 +  if(options[N_MAPS])
    1.34 +    {
    1.35 +      if(active_nodemaps[N_RADIUS]!="")
    1.36 +	{
    1.37 +	  _nodeSizes=*(nodemap_storage[active_nodemaps[N_RADIUS]]);
    1.38 +	}
    1.39 +      if(active_nodemaps[N_COLOR]!="")
    1.40 +	{
    1.41 +	  for(NodeIt ni(graph);ni!=INVALID;++ni)
    1.42 +	    {
    1.43 +	      _nodeColors[ni]=(int)((*(nodemap_storage[active_nodemaps[N_COLOR]]))[ni]);
    1.44 +	    }
    1.45 +	}
    1.46 +      if(active_nodemaps[N_TEXT]!="")
    1.47 +	{
    1.48 +	  for(NodeIt ni(graph);ni!=INVALID;++ni)
    1.49 +	    {
    1.50 +	      std::ostringstream o;
    1.51 +	      o << ((*(nodemap_storage[active_nodemaps[N_TEXT]]))[ni]);
    1.52 +	      _nodeTextMap[ni]=o.str();	      
    1.53 +	    }
    1.54 +	}
    1.55 +    }
    1.56 +  if(options[E_MAPS])
    1.57 +    {
    1.58 +      if(active_edgemaps[E_WIDTH]!="")
    1.59 +	{
    1.60 +	  _edgeWidths=*(edgemap_storage[active_edgemaps[E_WIDTH]]);
    1.61 +	}
    1.62 +      if(active_edgemaps[E_COLOR]!="")
    1.63 +	{
    1.64 +	  for(EdgeIt ei(graph);ei!=INVALID;++ei)
    1.65 +	    {
    1.66 +	      _edgeColors[ei]=(int)((*(edgemap_storage[active_edgemaps[E_COLOR]]))[ei]);
    1.67 +	    }
    1.68 +	}
    1.69 +    }
    1.70 +
    1.71 +  Palette palette;
    1.72 +  Palette paletteW(true);
    1.73 +
    1.74 +  graphToEps(graph,filename).
    1.75 +    title("Sample .eps figure (fits to A4)").
    1.76 +    copyright("(C) 2006 LEMON Project").
    1.77 +    absoluteNodeSizes().absoluteEdgeWidths().
    1.78 +    nodeScale(2).nodeSizes(_nodeSizes).
    1.79 +    coords(coords).
    1.80 +    nodeColors(composeMap(paletteW,_nodeColors)).
    1.81 +    edgeColors(composeMap(palette,_edgeColors)).
    1.82 +    edgeWidthScale(0.3).edgeWidths(_edgeWidths).
    1.83 +    nodeTexts(_nodeTextMap).nodeTextSize(7).
    1.84 +    enableParallel(_enableParallel).parEdgeDist(4).
    1.85 +    drawArrows(_drawArrows).arrowWidth(7).arrowLength(7).
    1.86 +    run();
    1.87 +
    1.88 +}