Changeset 2207:75a29ac69c19 in lemon-0.x for lemon/graph_to_eps.h
- Timestamp:
- 09/07/06 15:27:16 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2933
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/graph_to_eps.h
r2178 r2207 36 36 37 37 #include<lemon/bits/invalid.h> 38 #include<lemon/ xy.h>38 #include<lemon/dim2.h> 39 39 #include<lemon/maps.h> 40 40 #include<lemon/color.h> … … 82 82 std::ostream& os; 83 83 84 typedef ConstMap<typename Graph::Node, xy<double> > CoordsMapType;84 typedef ConstMap<typename Graph::Node,dim2::Point<double> > CoordsMapType; 85 85 CoordsMapType _coords; 86 86 ConstMap<typename Graph::Node,double > _nodeSizes; … … 147 147 bool _pros=false) : 148 148 g(_g), os(_os), 149 _coords( xy<double>(1,1)), _nodeSizes(.01), _nodeShapes(0),149 _coords(dim2::Point<double>(1,1)), _nodeSizes(.01), _nodeShapes(0), 150 150 _nodeColors(WHITE), _edgeColors(BLACK), 151 151 _edgeWidths(1.0), _edgeWidthScale(0.003), … … 314 314 } 315 315 template<class TT> 316 static std::string psOut(const xy<TT> &p)316 static std::string psOut(const dim2::Point<TT> &p) 317 317 { 318 318 std::ostringstream os; … … 338 338 339 339 ///Sets the map of the node coordinates. 340 ///\param x must be a node map with xy<double> or \ref xy "xy<int>" values. 340 ///\param x must be a node map with dim2::Point<double> or 341 ///\ref dim2::Point "dim2::Point<int>" values. 341 342 template<class X> GraphToEps<CoordsTraits<X> > coords(const X &x) { 342 343 dontPrint=true; … … 670 671 671 672 protected: 672 bool isInsideNode( xy<double> p, double r,int t)673 bool isInsideNode(dim2::Point<double> p, double r,int t) 673 674 { 674 675 switch(t) { … … 737 738 double diag_len = 1; 738 739 if(!(_absoluteNodeSizes&&_absoluteEdgeWidths)) { 739 BoundingBox<double> bb;740 dim2::BoundingBox<double> bb; 740 741 for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]); 741 742 if (bb.empty()) { 742 bb = BoundingBox<double>(xy<double>(0,0));743 bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0)); 743 744 } 744 745 diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare()); … … 748 749 } 749 750 750 BoundingBox<double> bb;751 dim2::BoundingBox<double> bb; 751 752 for(NodeIt n(g);n!=INVALID;++n) { 752 753 double ns=_nodeSizes[n]*_nodeScale; 753 xy<double> p(ns,ns);754 dim2::Point<double> p(ns,ns); 754 755 switch(_nodeShapes[n]) { 755 756 case CIRCLE: … … 761 762 case MALE: 762 763 bb.add(-p+mycoords[n]); 763 bb.add( xy<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]);764 bb.add(dim2::Point<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]); 764 765 break; 765 766 case FEMALE: 766 767 bb.add(p+mycoords[n]); 767 bb.add( xy<double>(-ns,-3.01*ns)+mycoords[n]);768 bb.add(dim2::Point<double>(-ns,-3.01*ns)+mycoords[n]); 768 769 break; 769 770 } 770 771 } 771 772 if (bb.empty()) { 772 bb = BoundingBox<double>(xy<double>(0,0));773 bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0)); 773 774 } 774 775 … … 871 872 (A4WIDTH-2*A4BORDER)/bb.width()); 872 873 os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' ' 873 << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER << " translate\n" 874 << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER 875 << " translate\n" 874 876 << sc << " dup scale\n" 875 877 << -bb.left() << ' ' << -bb.bottom() << " translate\n"; … … 880 882 (A4WIDTH-2*A4BORDER)/bb.height()); 881 883 os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' ' 882 << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER << " translate\n" 884 << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER 885 << " translate\n" 883 886 << sc << " dup scale\n90 rotate\n" 884 887 << -bb.left() << ' ' << -bb.top() << " translate\n"; … … 905 908 sw-=_parEdgeDist; 906 909 sw/=-2.0; 907 xy<double> dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]); 910 dim2::Point<double> 911 dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]); 908 912 double l=std::sqrt(dvec.normSquare()); 909 913 ///\todo better 'epsilon' would be nice here. 910 xy<double> d(dvec/std::max(l,EPSILON));911 xy<double> m;912 // m= xy<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;913 914 // m= xy<double>(mycoords[g.source(*i)])+914 dim2::Point<double> d(dvec/std::max(l,EPSILON)); 915 dim2::Point<double> m; 916 // m=dim2::Point<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0; 917 918 // m=dim2::Point<double>(mycoords[g.source(*i)])+ 915 919 // dvec*(double(_nodeSizes[g.source(*i)])/ 916 920 // (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)])); 917 921 918 m= xy<double>(mycoords[g.source(*i)])+922 m=dim2::Point<double>(mycoords[g.source(*i)])+ 919 923 d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0; 920 924 921 925 for(typename std::vector<Edge>::iterator e=i;e!=j;++e) { 922 926 sw+=_edgeWidths[*e]*_edgeWidthScale/2.0; 923 xy<double> mm=m+rot90(d)*sw/.75;927 dim2::Point<double> mm=m+rot90(d)*sw/.75; 924 928 if(_drawArrows) { 925 929 int node_shape; 926 xy<double> s=mycoords[g.source(*e)];927 xy<double> t=mycoords[g.target(*e)];930 dim2::Point<double> s=mycoords[g.source(*e)]; 931 dim2::Point<double> t=mycoords[g.target(*e)]; 928 932 double rn=_nodeSizes[g.target(*e)]*_nodeScale; 929 933 node_shape=_nodeShapes[g.target(*e)]; 930 Bezier3 bez(s,mm,mm,t);934 dim2::Bezier3 bez(s,mm,mm,t); 931 935 double t1=0,t2=1; 932 936 for(int i=0;i<INTERPOL_PREC;++i) 933 937 if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t2=(t1+t2)/2; 934 938 else t1=(t1+t2)/2; 935 xy<double> apoint=bez((t1+t2)/2);939 dim2::Point<double> apoint=bez((t1+t2)/2); 936 940 rn = _arrowLength+_edgeWidths[*e]*_edgeWidthScale; 937 941 rn*=rn; … … 940 944 if((bez((t1+t2)/2)-apoint).normSquare()>rn) t1=(t1+t2)/2; 941 945 else t2=(t1+t2)/2; 942 xy<double> linend=bez((t1+t2)/2);946 dim2::Point<double> linend=bez((t1+t2)/2); 943 947 bez=bez.before((t1+t2)/2); 944 948 // rn=_nodeSizes[g.source(*e)]*_nodeScale; … … 957 961 << bez.p3.x << ' ' << bez.p3.y << ' ' 958 962 << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n"; 959 xy<double> dd(rot90(linend-apoint));963 dim2::Point<double> dd(rot90(linend-apoint)); 960 964 dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/ 961 965 std::sqrt(dd.normSquare()); … … 983 987 &&g.source(e)!=g.target(e)) 984 988 if(_drawArrows) { 985 xy<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);989 dim2::Point<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]); 986 990 double rn=_nodeSizes[g.target(e)]*_nodeScale; 987 991 int node_shape=_nodeShapes[g.target(e)];
Note: See TracChangeset
for help on using the changeset viewer.