Changeset 1673:8919ca9e70f3 in lemon0.x
 Timestamp:
 09/01/05 21:21:35 (19 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2189
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/graph_to_eps.h
r1642 r1673 170 170 } 171 171 172 template<class MT> 173 class _NegY { 174 public: 175 typedef typename MT::Key Key; 176 typedef typename MT::Value Value; 177 const MT ↦ 178 int yscale; 179 _NegY(const MT &m,bool b) : map(m), yscale(1b*2) {} 180 Value operator[](Key n) { return Value(map[n].x,map[n].y*yscale);} 181 }; 182 172 183 ///Default traits class of \ref GraphToEps 173 184 … … 191 202 std::ostream& os; 192 203 193 ConstMap<typename Graph::Node,xy<double> > _coords; 204 typedef ConstMap<typename Graph::Node,xy<double> > CoordsMapType; 205 CoordsMapType _coords; 194 206 ConstMap<typename Graph::Node,double > _nodeSizes; 195 207 ConstMap<typename Graph::Node,int > _nodeShapes; … … 238 250 bool _autoEdgeWidthScale; 239 251 252 bool _negY; 240 253 ///Constructor 241 254 … … 264 277 _nodeTextColorType(SAME_COL), _nodeTextColors(Color(0,0,0)), 265 278 _autoNodeScale(false), 266 _autoEdgeWidthScale(false) 279 _autoEdgeWidthScale(false), 280 _negY(false) 267 281 {} 268 282 }; … … 414 428 415 429 template<class X> struct CoordsTraits : public T { 430 typedef X CoordsMapType; 416 431 const X &_coords; 417 432 CoordsTraits(const T &t,const X &x) : T(t), _coords(x) {} … … 580 595 _autoNodeScale=b;return *this; 581 596 } 597 598 ///Negates the Y coordinates. 599 600 ///Negates the Y coordinates. 601 /// 602 ///\todo More docs. 603 /// 604 GraphToEps<T> &negateY(bool b=true) { 605 _negY=b;return *this; 606 } 607 582 608 ///Sets a global scale factor for edge widths 583 609 … … 744 770 if(dontPrint) return; 745 771 772 _NegY<typename T::CoordsMapType> mycoords(_coords,_negY); 773 746 774 os << "%!PSAdobe2.0 EPSF2.0\n"; 747 775 if(_title.size()>0) os << "%%Title: " << _title << '\n'; … … 784 812 double ns=_nodeSizes[n]*_nodeScale; 785 813 xy<double> p(ns,ns); 786 bb.add(p+ _coords[n]);787 bb.add(p+ _coords[n]);814 bb.add(p+mycoords[n]); 815 bb.add(p+mycoords[n]); 788 816 } 789 817 if (bb.empty()) { … … 889 917 sw=_parEdgeDist; 890 918 sw/=2.0; 891 xy<double> dvec( _coords[g.target(*i)]_coords[g.source(*i)]);919 xy<double> dvec(mycoords[g.target(*i)]mycoords[g.source(*i)]); 892 920 double l=std::sqrt(dvec.normSquare()); 893 921 ///\todo better 'epsilon' would be nice here. 894 922 xy<double> d(dvec/std::max(l,1e9)); 895 923 xy<double> m; 896 // m=xy<double>( _coords[g.target(*i)]+_coords[g.source(*i)])/2.0;897 898 // m=xy<double>( _coords[g.source(*i)])+924 // m=xy<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0; 925 926 // m=xy<double>(mycoords[g.source(*i)])+ 899 927 // dvec*(double(_nodeSizes[g.source(*i)])/ 900 928 // (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)])); 901 929 902 m=xy<double>( _coords[g.source(*i)])+930 m=xy<double>(mycoords[g.source(*i)])+ 903 931 d*(l+_nodeSizes[g.source(*i)]_nodeSizes[g.target(*i)])/2.0; 904 932 … … 908 936 if(_drawArrows) { 909 937 int node_shape; 910 xy<double> s= _coords[g.source(*e)];911 xy<double> t= _coords[g.target(*e)];938 xy<double> s=mycoords[g.source(*e)]; 939 xy<double> t=mycoords[g.target(*e)]; 912 940 double rn=_nodeSizes[g.target(*e)]*_nodeScale; 913 941 node_shape=_nodeShapes[g.target(*e)]; … … 949 977 } 950 978 else { 951 os << _coords[g.source(*e)].x << ' '952 << _coords[g.source(*e)].y << ' '979 os << mycoords[g.source(*e)].x << ' ' 980 << mycoords[g.source(*e)].y << ' ' 953 981 << mm.x << ' ' << mm.y << ' ' 954 << _coords[g.target(*e)].x << ' '955 << _coords[g.target(*e)].y << ' '982 << mycoords[g.target(*e)].x << ' ' 983 << mycoords[g.target(*e)].y << ' ' 956 984 << _edgeColors[*e].red() << ' ' 957 985 << _edgeColors[*e].green() << ' ' … … 966 994 if((!_undirg.source(e)<g.target(e))&&_edgeWidths[e]>0) 967 995 if(_drawArrows) { 968 xy<double> d( _coords[g.target(e)]_coords[g.source(e)]);996 xy<double> d(mycoords[g.target(e)]mycoords[g.source(e)]); 969 997 double rn=_nodeSizes[g.target(e)]*_nodeScale; 970 998 int node_shape=_nodeShapes[g.target(e)]; … … 979 1007 << _edgeWidths[e]*_edgeWidthScale << ' ' 980 1008 << d.x << ' ' << d.y << ' ' 981 << _coords[g.source(e)].x << ' '982 << _coords[g.source(e)].y << ' '1009 << mycoords[g.source(e)].x << ' ' 1010 << mycoords[g.source(e)].y << ' ' 983 1011 << _edgeColors[e].red() << ' ' 984 1012 << _edgeColors[e].green() << ' ' 985 1013 << _edgeColors[e].blue() << " arr\n"; 986 1014 } 987 else os << _coords[g.source(e)].x << ' '988 << _coords[g.source(e)].y << ' '989 << _coords[g.target(e)].x << ' '990 << _coords[g.target(e)].y << ' '1015 else os << mycoords[g.source(e)].x << ' ' 1016 << mycoords[g.source(e)].y << ' ' 1017 << mycoords[g.target(e)].x << ' ' 1018 << mycoords[g.target(e)].y << ' ' 991 1019 << _edgeColors[e].red() << ' ' 992 1020 << _edgeColors[e].green() << ' ' … … 998 1026 os << "%Nodes:\ngsave\n"; 999 1027 for(NodeIt n(g);n!=INVALID;++n) { 1000 os << _coords[n].x << ' ' << _coords[n].y << ' '1028 os << mycoords[n].x << ' ' << mycoords[n].y << ' ' 1001 1029 << _nodeSizes[n]*_nodeScale << ' ' 1002 1030 << _nodeColors[n].red() << ' ' … … 1033 1061 os << "0 0 0 setrgbcolor\n"; 1034 1062 } 1035 os << _coords[n].x << ' ' << _coords[n].y1063 os << mycoords[n].x << ' ' << mycoords[n].y 1036 1064 << " (" << _nodeTexts[n] << ") cshow\n"; 1037 1065 } … … 1041 1069 os << "%Node PS blocks:\ngsave\n"; 1042 1070 for(NodeIt n(g);n!=INVALID;++n) 1043 os << _coords[n].x << ' ' << _coords[n].y1071 os << mycoords[n].x << ' ' << mycoords[n].y 1044 1072 << " moveto\n" << _nodePsTexts[n] << "\n"; 1045 1073 os << "grestore\n";
Note: See TracChangeset
for help on using the changeset viewer.