equal
deleted
inserted
replaced
140 ///Constructor |
140 ///Constructor |
141 |
141 |
142 ///Constructor |
142 ///Constructor |
143 ///\param _g Reference to the graph to be printed. |
143 ///\param _g Reference to the graph to be printed. |
144 ///\param _os Reference to the output stream. |
144 ///\param _os Reference to the output stream. |
145 ///\param _os Reference to the output stream. By default it is <tt>std::cout</tt>. |
145 ///\param _os Reference to the output stream. |
|
146 ///By default it is <tt>std::cout</tt>. |
146 ///\param _pros If it is \c true, then the \c ostream referenced by \c _os |
147 ///\param _pros If it is \c true, then the \c ostream referenced by \c _os |
147 ///will be explicitly deallocated by the destructor. |
148 ///will be explicitly deallocated by the destructor. |
148 DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout, |
149 DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout, |
149 bool _pros=false) : |
150 bool _pros=false) : |
150 g(_g), os(_os), |
151 g(_g), os(_os), |
779 os << "%%EndComments\n"; |
780 os << "%%EndComments\n"; |
780 |
781 |
781 //x1 y1 x2 y2 x3 y3 cr cg cb w |
782 //x1 y1 x2 y2 x3 y3 cr cg cb w |
782 os << "/lb { setlinewidth setrgbcolor newpath moveto\n" |
783 os << "/lb { setlinewidth setrgbcolor newpath moveto\n" |
783 << " 4 2 roll 1 index 1 index curveto stroke } bind def\n"; |
784 << " 4 2 roll 1 index 1 index curveto stroke } bind def\n"; |
784 os << "/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def\n"; |
785 os << "/l { setlinewidth setrgbcolor newpath moveto lineto stroke }" |
|
786 << " bind def\n"; |
785 //x y r |
787 //x y r |
786 os << "/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def\n"; |
788 os << "/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath }" |
|
789 << " bind def\n"; |
787 //x y r |
790 //x y r |
788 os << "/sq { newpath 2 index 1 index add 2 index 2 index add moveto\n" |
791 os << "/sq { newpath 2 index 1 index add 2 index 2 index add moveto\n" |
789 << " 2 index 1 index sub 2 index 2 index add lineto\n" |
792 << " 2 index 1 index sub 2 index 2 index add lineto\n" |
790 << " 2 index 1 index sub 2 index 2 index sub lineto\n" |
793 << " 2 index 1 index sub 2 index 2 index sub lineto\n" |
791 << " 2 index 1 index add 2 index 2 index sub lineto\n" |
794 << " 2 index 1 index add 2 index 2 index sub lineto\n" |
809 os << "/nfemale { 0 0 0 setrgbcolor 3 index " |
812 os << "/nfemale { 0 0 0 setrgbcolor 3 index " |
810 << _nodeBorderQuotient/(1+_nodeBorderQuotient) |
813 << _nodeBorderQuotient/(1+_nodeBorderQuotient) |
811 << " 1.5 mul mul setlinewidth\n" |
814 << " 1.5 mul mul setlinewidth\n" |
812 << " newpath 5 index 5 index moveto " |
815 << " newpath 5 index 5 index moveto " |
813 << "5 index 5 index 5 index 3.01 mul sub\n" |
816 << "5 index 5 index 5 index 3.01 mul sub\n" |
814 << " lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto\n" |
817 << " lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub" |
815 << " 5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke\n" |
818 << " moveto\n" |
|
819 << " 5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto " |
|
820 << "stroke\n" |
816 << " 5 index 5 index 5 index c fill\n" |
821 << " 5 index 5 index 5 index c fill\n" |
817 << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" |
822 << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" |
818 << " } bind def\n"; |
823 << " } bind def\n"; |
819 os << "/nmale {\n" |
824 os << "/nmale {\n" |
820 << " 0 0 0 setrgbcolor 3 index " |
825 << " 0 0 0 setrgbcolor 3 index " |
824 << " 5 index 4 index 1 mul 1.5 mul add\n" |
829 << " 5 index 4 index 1 mul 1.5 mul add\n" |
825 << " 5 index 5 index 3 sqrt 1.5 mul mul add\n" |
830 << " 5 index 5 index 3 sqrt 1.5 mul mul add\n" |
826 << " 1 index 1 index lineto\n" |
831 << " 1 index 1 index lineto\n" |
827 << " 1 index 1 index 7 index sub moveto\n" |
832 << " 1 index 1 index 7 index sub moveto\n" |
828 << " 1 index 1 index lineto\n" |
833 << " 1 index 1 index lineto\n" |
829 << " exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto\n" |
834 << " exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub" |
|
835 << " lineto\n" |
830 << " stroke\n" |
836 << " stroke\n" |
831 << " 5 index 5 index 5 index c fill\n" |
837 << " 5 index 5 index 5 index c fill\n" |
832 << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" |
838 << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" |
833 << " } bind def\n"; |
839 << " } bind def\n"; |
834 |
840 |
836 os << "/arrl " << _arrowLength << " def\n"; |
842 os << "/arrl " << _arrowLength << " def\n"; |
837 os << "/arrw " << _arrowWidth << " def\n"; |
843 os << "/arrw " << _arrowWidth << " def\n"; |
838 // l dx_norm dy_norm |
844 // l dx_norm dy_norm |
839 os << "/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def\n"; |
845 os << "/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def\n"; |
840 //len w dx_norm dy_norm x1 y1 cr cg cb |
846 //len w dx_norm dy_norm x1 y1 cr cg cb |
841 os << "/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def\n" |
847 os << "/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx " |
|
848 << "exch def\n" |
842 << " /w exch def /len exch def\n" |
849 << " /w exch def /len exch def\n" |
843 // << " 0.1 setlinewidth x1 y1 moveto dx len mul dy len mul rlineto stroke" |
850 //<< "0.1 setlinewidth x1 y1 moveto dx len mul dy len mul rlineto stroke" |
844 << " newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto\n" |
851 << " newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto\n" |
845 << " len w sub arrl sub dx dy lrl\n" |
852 << " len w sub arrl sub dx dy lrl\n" |
846 << " arrw dy dx neg lrl\n" |
853 << " arrw dy dx neg lrl\n" |
847 << " dx arrl w add mul dy w 2 div arrw add mul sub\n" |
854 << " dx arrl w add mul dy w 2 div arrw add mul sub\n" |
848 << " dy arrl w add mul dx w 2 div arrw add mul add rlineto\n" |
855 << " dy arrl w add mul dx w 2 div arrw add mul add rlineto\n" |
900 dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]); |
907 dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]); |
901 double l=std::sqrt(dvec.normSquare()); |
908 double l=std::sqrt(dvec.normSquare()); |
902 //\todo better 'epsilon' would be nice here. |
909 //\todo better 'epsilon' would be nice here. |
903 dim2::Point<double> d(dvec/std::max(l,EPSILON)); |
910 dim2::Point<double> d(dvec/std::max(l,EPSILON)); |
904 dim2::Point<double> m; |
911 dim2::Point<double> m; |
905 // m=dim2::Point<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0; |
912 // m=dim2::Point<double>(mycoords[g.target(*i)]+ |
|
913 // mycoords[g.source(*i)])/2.0; |
906 |
914 |
907 // m=dim2::Point<double>(mycoords[g.source(*i)])+ |
915 // m=dim2::Point<double>(mycoords[g.source(*i)])+ |
908 // dvec*(double(_nodeSizes[g.source(*i)])/ |
916 // dvec*(double(_nodeSizes[g.source(*i)])/ |
909 // (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)])); |
917 // (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)])); |
910 |
918 |
936 bez=bez.before((t1+t2)/2); |
944 bez=bez.before((t1+t2)/2); |
937 // rn=_nodeSizes[g.source(*e)]*_nodeScale; |
945 // rn=_nodeSizes[g.source(*e)]*_nodeScale; |
938 // node_shape=_nodeShapes[g.source(*e)]; |
946 // node_shape=_nodeShapes[g.source(*e)]; |
939 // t1=0;t2=1; |
947 // t1=0;t2=1; |
940 // for(int i=0;i<INTERPOL_PREC;++i) |
948 // for(int i=0;i<INTERPOL_PREC;++i) |
941 // if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t1=(t1+t2)/2; |
949 // if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) |
|
950 // t1=(t1+t2)/2; |
942 // else t2=(t1+t2)/2; |
951 // else t2=(t1+t2)/2; |
943 // bez=bez.after((t1+t2)/2); |
952 // bez=bez.after((t1+t2)/2); |
944 os << _arcWidths[*e]*_arcWidthScale << " setlinewidth " |
953 os << _arcWidths[*e]*_arcWidthScale << " setlinewidth " |
945 << _arcColors[*e].red() << ' ' |
954 << _arcColors[*e].red() << ' ' |
946 << _arcColors[*e].green() << ' ' |
955 << _arcColors[*e].green() << ' ' |