COIN-OR::LEMON - Graph Library

Changeset 191:af2ed974ab68 in glemon-0.x for mapstorage.cc


Ignore:
Timestamp:
02/27/07 18:18:19 (17 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@3202
Message:

GUI can now export graph to EPS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mapstorage.cc

    r184 r191  
    2424#include <cmath>
    2525#include <gtkmm.h>
    26 
    27 const double i_d=20;
     26#include<lemon/graph_to_eps.h>
     27
     28const int i_d=20;
    2829const double a_d=0.05;
    2930const double p_d=40000;
     
    590591  background_scaling = scaling;
    591592}
     593
     594void MapStorage::exportGraphToEPS(std::vector<bool> options, std::string filename)
     595{
     596  Graph::NodeMap<int> _nodeColors(graph, 0);
     597  Graph::EdgeMap<int> _edgeColors(graph, 0);
     598  Graph::NodeMap<double> _nodeSizes(graph, 6.0);
     599  Graph::EdgeMap<double> _edgeWidths(graph, 1.0);
     600  bool _drawArrows=options[ARROWS];
     601  bool _enableParallel=options[PAR];
     602
     603  std::string emptyString="";
     604  Graph::NodeMap<std::string> _nodeTextMap(graph,emptyString);
     605
     606  //_nodeTextMap=(Graph::NodeMap<void> *)&emptyStringMap;
     607
     608  if(options[N_MAPS])
     609    {
     610      if(active_nodemaps[N_RADIUS]!="")
     611        {
     612          _nodeSizes=*(nodemap_storage[active_nodemaps[N_RADIUS]]);
     613        }
     614      if(active_nodemaps[N_COLOR]!="")
     615        {
     616          for(NodeIt ni(graph);ni!=INVALID;++ni)
     617            {
     618              _nodeColors[ni]=(int)((*(nodemap_storage[active_nodemaps[N_COLOR]]))[ni]);
     619            }
     620        }
     621      if(active_nodemaps[N_TEXT]!="")
     622        {
     623          for(NodeIt ni(graph);ni!=INVALID;++ni)
     624            {
     625              std::ostringstream o;
     626              o << ((*(nodemap_storage[active_nodemaps[N_TEXT]]))[ni]);
     627              _nodeTextMap[ni]=o.str();       
     628            }
     629        }
     630    }
     631  if(options[E_MAPS])
     632    {
     633      if(active_edgemaps[E_WIDTH]!="")
     634        {
     635          _edgeWidths=*(edgemap_storage[active_edgemaps[E_WIDTH]]);
     636        }
     637      if(active_edgemaps[E_COLOR]!="")
     638        {
     639          for(EdgeIt ei(graph);ei!=INVALID;++ei)
     640            {
     641              _edgeColors[ei]=(int)((*(edgemap_storage[active_edgemaps[E_COLOR]]))[ei]);
     642            }
     643        }
     644    }
     645
     646  Palette palette;
     647  Palette paletteW(true);
     648
     649  graphToEps(graph,filename).
     650    title("Sample .eps figure (fits to A4)").
     651    copyright("(C) 2006 LEMON Project").
     652    absoluteNodeSizes().absoluteEdgeWidths().
     653    nodeScale(2).nodeSizes(_nodeSizes).
     654    coords(coords).
     655    nodeColors(composeMap(paletteW,_nodeColors)).
     656    edgeColors(composeMap(palette,_edgeColors)).
     657    edgeWidthScale(0.3).edgeWidths(_edgeWidths).
     658    nodeTexts(_nodeTextMap).nodeTextSize(7).
     659    enableParallel(_enableParallel).parEdgeDist(4).
     660    drawArrows(_drawArrows).arrowWidth(7).arrowLength(7).
     661    run();
     662
     663}
Note: See TracChangeset for help on using the changeset viewer.