lemon/graph_to_eps.h
changeset 284 a16cc721259e
parent 253 dbe309b5e855
child 290 f6899946c1ac
equal deleted inserted replaced
14:a18fd910850f 15:af91a112a0b4
   664   ///Like other functions using
   664   ///Like other functions using
   665   ///\ref named-templ-func-param "named template parameters",
   665   ///\ref named-templ-func-param "named template parameters",
   666   ///this function calls the algorithm itself, i.e. in this case
   666   ///this function calls the algorithm itself, i.e. in this case
   667   ///it draws the graph.
   667   ///it draws the graph.
   668   void run() {
   668   void run() {
   669     //\todo better 'epsilon' would be nice here.
       
   670     const double EPSILON=1e-9;
   669     const double EPSILON=1e-9;
   671     if(dontPrint) return;
   670     if(dontPrint) return;
   672 
   671 
   673     _graph_to_eps_bits::_NegY<typename T::CoordsMapType>
   672     _graph_to_eps_bits::_NegY<typename T::CoordsMapType>
   674       mycoords(_coords,_negY);
   673       mycoords(_coords,_negY);
   705 
   704 
   706     if (_autoArcWidthScale) {
   705     if (_autoArcWidthScale) {
   707       double max_w=0;
   706       double max_w=0;
   708       for(ArcIt e(g);e!=INVALID;++e)
   707       for(ArcIt e(g);e!=INVALID;++e)
   709         max_w=std::max(double(_arcWidths[e]),max_w);
   708         max_w=std::max(double(_arcWidths[e]),max_w);
   710       //\todo better 'epsilon' would be nice here.
       
   711       if(max_w>EPSILON) {
   709       if(max_w>EPSILON) {
   712         _arcWidthScale/=max_w;
   710         _arcWidthScale/=max_w;
   713       }
   711       }
   714     }
   712     }
   715 
   713 
   716     if (_autoNodeScale) {
   714     if (_autoNodeScale) {
   717       double max_s=0;
   715       double max_s=0;
   718       for(NodeIt n(g);n!=INVALID;++n)
   716       for(NodeIt n(g);n!=INVALID;++n)
   719         max_s=std::max(double(_nodeSizes[n]),max_s);
   717         max_s=std::max(double(_nodeSizes[n]),max_s);
   720       //\todo better 'epsilon' would be nice here.
       
   721       if(max_s>EPSILON) {
   718       if(max_s>EPSILON) {
   722         _nodeScale/=max_s;
   719         _nodeScale/=max_s;
   723       }
   720       }
   724     }
   721     }
   725 
   722 
   871            << " translate\n"
   868            << " translate\n"
   872            << sc << " dup scale\n"
   869            << sc << " dup scale\n"
   873            << -bb.left() << ' ' << -bb.bottom() << " translate\n";
   870            << -bb.left() << ' ' << -bb.bottom() << " translate\n";
   874       }
   871       }
   875       else {
   872       else {
   876         //\todo Verify centering
       
   877         double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(),
   873         double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(),
   878                   (A4WIDTH-2*A4BORDER)/bb.height());
   874                   (A4WIDTH-2*A4BORDER)/bb.height());
   879         os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' '
   875         os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' '
   880            << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER
   876            << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER
   881            << " translate\n"
   877            << " translate\n"
   904           sw-=_parArcDist;
   900           sw-=_parArcDist;
   905           sw/=-2.0;
   901           sw/=-2.0;
   906           dim2::Point<double>
   902           dim2::Point<double>
   907             dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
   903             dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
   908           double l=std::sqrt(dvec.normSquare());
   904           double l=std::sqrt(dvec.normSquare());
   909           //\todo better 'epsilon' would be nice here.
       
   910           dim2::Point<double> d(dvec/std::max(l,EPSILON));
   905           dim2::Point<double> d(dvec/std::max(l,EPSILON));
   911           dim2::Point<double> m;
   906           dim2::Point<double> m;
   912 //           m=dim2::Point<double>(mycoords[g.target(*i)]+
   907 //           m=dim2::Point<double>(mycoords[g.target(*i)]+
   913 //                                 mycoords[g.source(*i)])/2.0;
   908 //                                 mycoords[g.source(*i)])/2.0;
   914 
   909