diff -r c3ff11b0025c -r 75a29ac69c19 lemon/graph_to_eps.h --- a/lemon/graph_to_eps.h Wed Sep 06 11:39:22 2006 +0000 +++ b/lemon/graph_to_eps.h Thu Sep 07 13:27:16 2006 +0000 @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include @@ -81,7 +81,7 @@ std::ostream& os; - typedef ConstMap > CoordsMapType; + typedef ConstMap > CoordsMapType; CoordsMapType _coords; ConstMap _nodeSizes; ConstMap _nodeShapes; @@ -146,7 +146,7 @@ DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout, bool _pros=false) : g(_g), os(_os), - _coords(xy(1,1)), _nodeSizes(.01), _nodeShapes(0), + _coords(dim2::Point(1,1)), _nodeSizes(.01), _nodeShapes(0), _nodeColors(WHITE), _edgeColors(BLACK), _edgeWidths(1.0), _edgeWidthScale(0.003), _nodeScale(1.0), _xBorder(10), _yBorder(10), _scale(1.0), @@ -313,7 +313,7 @@ g.target(e)==g.source(f)); } template - static std::string psOut(const xy &p) + static std::string psOut(const dim2::Point &p) { std::ostringstream os; os << p.x << ' ' << p.y; @@ -337,7 +337,8 @@ ///Sets the map of the node coordinates ///Sets the map of the node coordinates. - ///\param x must be a node map with xy or \ref xy "xy" values. + ///\param x must be a node map with dim2::Point or + ///\ref dim2::Point "dim2::Point" values. template GraphToEps > coords(const X &x) { dontPrint=true; return GraphToEps >(CoordsTraits(*this,x)); @@ -669,7 +670,7 @@ GraphToEps ©right(const std::string &t) {_copyright=t;return *this;} protected: - bool isInsideNode(xy p, double r,int t) + bool isInsideNode(dim2::Point p, double r,int t) { switch(t) { case CIRCLE: @@ -736,10 +737,10 @@ double diag_len = 1; if(!(_absoluteNodeSizes&&_absoluteEdgeWidths)) { - BoundingBox bb; + dim2::BoundingBox bb; for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]); if (bb.empty()) { - bb = BoundingBox(xy(0,0)); + bb = dim2::BoundingBox(dim2::Point(0,0)); } diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare()); if(diag_len bb; + dim2::BoundingBox bb; for(NodeIt n(g);n!=INVALID;++n) { double ns=_nodeSizes[n]*_nodeScale; - xy p(ns,ns); + dim2::Point p(ns,ns); switch(_nodeShapes[n]) { case CIRCLE: case SQUARE: @@ -760,16 +761,16 @@ break; case MALE: bb.add(-p+mycoords[n]); - bb.add(xy(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]); + bb.add(dim2::Point(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]); break; case FEMALE: bb.add(p+mycoords[n]); - bb.add(xy(-ns,-3.01*ns)+mycoords[n]); + bb.add(dim2::Point(-ns,-3.01*ns)+mycoords[n]); break; } } if (bb.empty()) { - bb = BoundingBox(xy(0,0)); + bb = dim2::BoundingBox(dim2::Point(0,0)); } if(_scaleToA4) @@ -870,7 +871,8 @@ double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.height(), (A4WIDTH-2*A4BORDER)/bb.width()); os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' ' - << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER << " translate\n" + << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER + << " translate\n" << sc << " dup scale\n" << -bb.left() << ' ' << -bb.bottom() << " translate\n"; } @@ -879,7 +881,8 @@ double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(), (A4WIDTH-2*A4BORDER)/bb.height()); os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' ' - << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER << " translate\n" + << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER + << " translate\n" << sc << " dup scale\n90 rotate\n" << -bb.left() << ' ' << -bb.top() << " translate\n"; } @@ -904,42 +907,43 @@ sw+=_edgeWidths[*e]*_edgeWidthScale+_parEdgeDist; sw-=_parEdgeDist; sw/=-2.0; - xy dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]); + dim2::Point + dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]); double l=std::sqrt(dvec.normSquare()); ///\todo better 'epsilon' would be nice here. - xy d(dvec/std::max(l,EPSILON)); - xy m; -// m=xy(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0; + dim2::Point d(dvec/std::max(l,EPSILON)); + dim2::Point m; +// m=dim2::Point(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0; -// m=xy(mycoords[g.source(*i)])+ +// m=dim2::Point(mycoords[g.source(*i)])+ // dvec*(double(_nodeSizes[g.source(*i)])/ // (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)])); - m=xy(mycoords[g.source(*i)])+ + m=dim2::Point(mycoords[g.source(*i)])+ d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0; for(typename std::vector::iterator e=i;e!=j;++e) { sw+=_edgeWidths[*e]*_edgeWidthScale/2.0; - xy mm=m+rot90(d)*sw/.75; + dim2::Point mm=m+rot90(d)*sw/.75; if(_drawArrows) { int node_shape; - xy s=mycoords[g.source(*e)]; - xy t=mycoords[g.target(*e)]; + dim2::Point s=mycoords[g.source(*e)]; + dim2::Point t=mycoords[g.target(*e)]; double rn=_nodeSizes[g.target(*e)]*_nodeScale; node_shape=_nodeShapes[g.target(*e)]; - Bezier3 bez(s,mm,mm,t); + dim2::Bezier3 bez(s,mm,mm,t); double t1=0,t2=1; for(int i=0;i apoint=bez((t1+t2)/2); + dim2::Point apoint=bez((t1+t2)/2); rn = _arrowLength+_edgeWidths[*e]*_edgeWidthScale; rn*=rn; t2=(t1+t2)/2;t1=0; for(int i=0;irn) t1=(t1+t2)/2; else t2=(t1+t2)/2; - xy linend=bez((t1+t2)/2); + dim2::Point linend=bez((t1+t2)/2); bez=bez.before((t1+t2)/2); // rn=_nodeSizes[g.source(*e)]*_nodeScale; // node_shape=_nodeShapes[g.source(*e)]; @@ -956,7 +960,7 @@ << bez.p2.x << ' ' << bez.p2.y << ' ' << bez.p3.x << ' ' << bez.p3.y << ' ' << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n"; - xy dd(rot90(linend-apoint)); + dim2::Point dd(rot90(linend-apoint)); dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/ std::sqrt(dd.normSquare()); os << "newpath " << psOut(apoint) << " moveto " @@ -982,7 +986,7 @@ if((!_undirected||g.source(e)0 &&g.source(e)!=g.target(e)) if(_drawArrows) { - xy d(mycoords[g.target(e)]-mycoords[g.source(e)]); + dim2::Point d(mycoords[g.target(e)]-mycoords[g.source(e)]); double rn=_nodeSizes[g.target(e)]*_nodeScale; int node_shape=_nodeShapes[g.target(e)]; double t1=0,t2=1;