1.1 --- a/lemon/graph_to_eps.h Wed Sep 06 11:39:22 2006 +0000
1.2 +++ b/lemon/graph_to_eps.h Thu Sep 07 13:27:16 2006 +0000
1.3 @@ -35,7 +35,7 @@
1.4 #include <cmath>
1.5
1.6 #include<lemon/bits/invalid.h>
1.7 -#include<lemon/xy.h>
1.8 +#include<lemon/dim2.h>
1.9 #include<lemon/maps.h>
1.10 #include<lemon/color.h>
1.11 #include<lemon/bits/bezier.h>
1.12 @@ -81,7 +81,7 @@
1.13
1.14 std::ostream& os;
1.15
1.16 - typedef ConstMap<typename Graph::Node,xy<double> > CoordsMapType;
1.17 + typedef ConstMap<typename Graph::Node,dim2::Point<double> > CoordsMapType;
1.18 CoordsMapType _coords;
1.19 ConstMap<typename Graph::Node,double > _nodeSizes;
1.20 ConstMap<typename Graph::Node,int > _nodeShapes;
1.21 @@ -146,7 +146,7 @@
1.22 DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout,
1.23 bool _pros=false) :
1.24 g(_g), os(_os),
1.25 - _coords(xy<double>(1,1)), _nodeSizes(.01), _nodeShapes(0),
1.26 + _coords(dim2::Point<double>(1,1)), _nodeSizes(.01), _nodeShapes(0),
1.27 _nodeColors(WHITE), _edgeColors(BLACK),
1.28 _edgeWidths(1.0), _edgeWidthScale(0.003),
1.29 _nodeScale(1.0), _xBorder(10), _yBorder(10), _scale(1.0),
1.30 @@ -313,7 +313,7 @@
1.31 g.target(e)==g.source(f));
1.32 }
1.33 template<class TT>
1.34 - static std::string psOut(const xy<TT> &p)
1.35 + static std::string psOut(const dim2::Point<TT> &p)
1.36 {
1.37 std::ostringstream os;
1.38 os << p.x << ' ' << p.y;
1.39 @@ -337,7 +337,8 @@
1.40 ///Sets the map of the node coordinates
1.41
1.42 ///Sets the map of the node coordinates.
1.43 - ///\param x must be a node map with xy<double> or \ref xy "xy<int>" values.
1.44 + ///\param x must be a node map with dim2::Point<double> or
1.45 + ///\ref dim2::Point "dim2::Point<int>" values.
1.46 template<class X> GraphToEps<CoordsTraits<X> > coords(const X &x) {
1.47 dontPrint=true;
1.48 return GraphToEps<CoordsTraits<X> >(CoordsTraits<X>(*this,x));
1.49 @@ -669,7 +670,7 @@
1.50 GraphToEps<T> ©right(const std::string &t) {_copyright=t;return *this;}
1.51
1.52 protected:
1.53 - bool isInsideNode(xy<double> p, double r,int t)
1.54 + bool isInsideNode(dim2::Point<double> p, double r,int t)
1.55 {
1.56 switch(t) {
1.57 case CIRCLE:
1.58 @@ -736,10 +737,10 @@
1.59
1.60 double diag_len = 1;
1.61 if(!(_absoluteNodeSizes&&_absoluteEdgeWidths)) {
1.62 - BoundingBox<double> bb;
1.63 + dim2::BoundingBox<double> bb;
1.64 for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]);
1.65 if (bb.empty()) {
1.66 - bb = BoundingBox<double>(xy<double>(0,0));
1.67 + bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
1.68 }
1.69 diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare());
1.70 if(diag_len<EPSILON) diag_len = 1;
1.71 @@ -747,10 +748,10 @@
1.72 if(!_absoluteEdgeWidths) _edgeWidthScale*=diag_len;
1.73 }
1.74
1.75 - BoundingBox<double> bb;
1.76 + dim2::BoundingBox<double> bb;
1.77 for(NodeIt n(g);n!=INVALID;++n) {
1.78 double ns=_nodeSizes[n]*_nodeScale;
1.79 - xy<double> p(ns,ns);
1.80 + dim2::Point<double> p(ns,ns);
1.81 switch(_nodeShapes[n]) {
1.82 case CIRCLE:
1.83 case SQUARE:
1.84 @@ -760,16 +761,16 @@
1.85 break;
1.86 case MALE:
1.87 bb.add(-p+mycoords[n]);
1.88 - bb.add(xy<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]);
1.89 + bb.add(dim2::Point<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]);
1.90 break;
1.91 case FEMALE:
1.92 bb.add(p+mycoords[n]);
1.93 - bb.add(xy<double>(-ns,-3.01*ns)+mycoords[n]);
1.94 + bb.add(dim2::Point<double>(-ns,-3.01*ns)+mycoords[n]);
1.95 break;
1.96 }
1.97 }
1.98 if (bb.empty()) {
1.99 - bb = BoundingBox<double>(xy<double>(0,0));
1.100 + bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
1.101 }
1.102
1.103 if(_scaleToA4)
1.104 @@ -870,7 +871,8 @@
1.105 double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.height(),
1.106 (A4WIDTH-2*A4BORDER)/bb.width());
1.107 os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' '
1.108 - << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER << " translate\n"
1.109 + << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER
1.110 + << " translate\n"
1.111 << sc << " dup scale\n"
1.112 << -bb.left() << ' ' << -bb.bottom() << " translate\n";
1.113 }
1.114 @@ -879,7 +881,8 @@
1.115 double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(),
1.116 (A4WIDTH-2*A4BORDER)/bb.height());
1.117 os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' '
1.118 - << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER << " translate\n"
1.119 + << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER
1.120 + << " translate\n"
1.121 << sc << " dup scale\n90 rotate\n"
1.122 << -bb.left() << ' ' << -bb.top() << " translate\n";
1.123 }
1.124 @@ -904,42 +907,43 @@
1.125 sw+=_edgeWidths[*e]*_edgeWidthScale+_parEdgeDist;
1.126 sw-=_parEdgeDist;
1.127 sw/=-2.0;
1.128 - xy<double> dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
1.129 + dim2::Point<double>
1.130 + dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
1.131 double l=std::sqrt(dvec.normSquare());
1.132 ///\todo better 'epsilon' would be nice here.
1.133 - xy<double> d(dvec/std::max(l,EPSILON));
1.134 - xy<double> m;
1.135 -// m=xy<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
1.136 + dim2::Point<double> d(dvec/std::max(l,EPSILON));
1.137 + dim2::Point<double> m;
1.138 +// m=dim2::Point<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
1.139
1.140 -// m=xy<double>(mycoords[g.source(*i)])+
1.141 +// m=dim2::Point<double>(mycoords[g.source(*i)])+
1.142 // dvec*(double(_nodeSizes[g.source(*i)])/
1.143 // (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)]));
1.144
1.145 - m=xy<double>(mycoords[g.source(*i)])+
1.146 + m=dim2::Point<double>(mycoords[g.source(*i)])+
1.147 d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0;
1.148
1.149 for(typename std::vector<Edge>::iterator e=i;e!=j;++e) {
1.150 sw+=_edgeWidths[*e]*_edgeWidthScale/2.0;
1.151 - xy<double> mm=m+rot90(d)*sw/.75;
1.152 + dim2::Point<double> mm=m+rot90(d)*sw/.75;
1.153 if(_drawArrows) {
1.154 int node_shape;
1.155 - xy<double> s=mycoords[g.source(*e)];
1.156 - xy<double> t=mycoords[g.target(*e)];
1.157 + dim2::Point<double> s=mycoords[g.source(*e)];
1.158 + dim2::Point<double> t=mycoords[g.target(*e)];
1.159 double rn=_nodeSizes[g.target(*e)]*_nodeScale;
1.160 node_shape=_nodeShapes[g.target(*e)];
1.161 - Bezier3 bez(s,mm,mm,t);
1.162 + dim2::Bezier3 bez(s,mm,mm,t);
1.163 double t1=0,t2=1;
1.164 for(int i=0;i<INTERPOL_PREC;++i)
1.165 if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t2=(t1+t2)/2;
1.166 else t1=(t1+t2)/2;
1.167 - xy<double> apoint=bez((t1+t2)/2);
1.168 + dim2::Point<double> apoint=bez((t1+t2)/2);
1.169 rn = _arrowLength+_edgeWidths[*e]*_edgeWidthScale;
1.170 rn*=rn;
1.171 t2=(t1+t2)/2;t1=0;
1.172 for(int i=0;i<INTERPOL_PREC;++i)
1.173 if((bez((t1+t2)/2)-apoint).normSquare()>rn) t1=(t1+t2)/2;
1.174 else t2=(t1+t2)/2;
1.175 - xy<double> linend=bez((t1+t2)/2);
1.176 + dim2::Point<double> linend=bez((t1+t2)/2);
1.177 bez=bez.before((t1+t2)/2);
1.178 // rn=_nodeSizes[g.source(*e)]*_nodeScale;
1.179 // node_shape=_nodeShapes[g.source(*e)];
1.180 @@ -956,7 +960,7 @@
1.181 << bez.p2.x << ' ' << bez.p2.y << ' '
1.182 << bez.p3.x << ' ' << bez.p3.y << ' '
1.183 << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n";
1.184 - xy<double> dd(rot90(linend-apoint));
1.185 + dim2::Point<double> dd(rot90(linend-apoint));
1.186 dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/
1.187 std::sqrt(dd.normSquare());
1.188 os << "newpath " << psOut(apoint) << " moveto "
1.189 @@ -982,7 +986,7 @@
1.190 if((!_undirected||g.source(e)<g.target(e))&&_edgeWidths[e]>0
1.191 &&g.source(e)!=g.target(e))
1.192 if(_drawArrows) {
1.193 - xy<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);
1.194 + dim2::Point<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);
1.195 double rn=_nodeSizes[g.target(e)]*_nodeScale;
1.196 int node_shape=_nodeShapes[g.target(e)];
1.197 double t1=0,t2=1;