Changeset 2178:0d7c0f96a5ee in lemon-0.x for lemon/graph_to_eps.h
- Timestamp:
- 08/14/06 17:15:57 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2894
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/graph_to_eps.h
r2174 r2178 39 39 #include<lemon/maps.h> 40 40 #include<lemon/color.h> 41 #include<lemon/b ezier.h>41 #include<lemon/bits/bezier.h> 42 42 43 43 … … 131 131 bool _autoEdgeWidthScale; 132 132 133 bool _absoluteNodeSizes; 134 bool _absoluteEdgeWidths; 135 133 136 bool _negY; 134 137 ///Constructor … … 144 147 bool _pros=false) : 145 148 g(_g), os(_os), 146 _coords(xy<double>(1,1)), _nodeSizes( 1.0), _nodeShapes(0),149 _coords(xy<double>(1,1)), _nodeSizes(.01), _nodeShapes(0), 147 150 _nodeColors(WHITE), _edgeColors(BLACK), 148 _edgeWidths(1 ), _edgeWidthScale(0.3),151 _edgeWidths(1.0), _edgeWidthScale(0.003), 149 152 _nodeScale(1.0), _xBorder(10), _yBorder(10), _scale(1.0), 150 153 _nodeBorderQuotient(.1), … … 159 162 _autoNodeScale(false), 160 163 _autoEdgeWidthScale(false), 164 _absoluteNodeSizes(false), 165 _absoluteEdgeWidths(false), 161 166 _negY(false) 162 167 {} … … 229 234 using T::_autoNodeScale; 230 235 using T::_autoEdgeWidthScale; 236 237 using T::_absoluteNodeSizes; 238 using T::_absoluteEdgeWidths; 239 231 240 232 241 using T::_negY; … … 479 488 /// node sizes will be scaled in such a way that the greatest size will be 480 489 /// equal to \c d. 490 /// \sa nodeSizes() 491 /// \sa autoNodeScale() 481 492 GraphToEps<T> &nodeScale(double d) {_nodeScale=d;return *this;} 482 493 ///Turns on/off the automatic node width scaling. … … 488 499 GraphToEps<T> &autoNodeScale(bool b=true) { 489 500 _autoNodeScale=b;return *this; 501 } 502 503 ///Turns on/off the absolutematic node width scaling. 504 505 ///Turns on/off the absolutematic node width scaling. 506 /// 507 ///\sa nodeScale() 508 /// 509 GraphToEps<T> &absoluteNodeSizes(bool b=true) { 510 _absoluteNodeSizes=b;return *this; 490 511 } 491 512 … … 520 541 GraphToEps<T> &autoEdgeWidthScale(bool b=true) { 521 542 _autoEdgeWidthScale=b;return *this; 543 } 544 ///Turns on/off the absolutematic edge width scaling. 545 546 ///Turns on/off the absolutematic edge width scaling. 547 /// 548 ///\sa edgeWidthScale() 549 /// 550 GraphToEps<T> &absoluteEdgeWidths(bool b=true) { 551 _absoluteEdgeWidths=b;return *this; 522 552 } 523 553 ///Sets a global scale factor for the whole picture … … 665 695 ///it draws the graph. 666 696 void run() { 697 ///\todo better 'epsilon' would be nice here. 698 const double EPSILON=1e-9; 667 699 if(dontPrint) return; 668 700 … … 688 720 max_w=std::max(double(_edgeWidths[e]),max_w); 689 721 ///\todo better 'epsilon' would be nice here. 690 if(max_w> 1e-9) {722 if(max_w>EPSILON) { 691 723 _edgeWidthScale/=max_w; 692 724 } … … 698 730 max_s=std::max(double(_nodeSizes[n]),max_s); 699 731 ///\todo better 'epsilon' would be nice here. 700 if(max_s> 1e-9) {732 if(max_s>EPSILON) { 701 733 _nodeScale/=max_s; 702 734 } 703 735 } 704 736 705 737 double diag_len = 1; 738 if(!(_absoluteNodeSizes&&_absoluteEdgeWidths)) { 739 BoundingBox<double> bb; 740 for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]); 741 if (bb.empty()) { 742 bb = BoundingBox<double>(xy<double>(0,0)); 743 } 744 diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare()); 745 if(diag_len<EPSILON) diag_len = 1; 746 if(!_absoluteNodeSizes) _nodeScale*=diag_len; 747 if(!_absoluteEdgeWidths) _edgeWidthScale*=diag_len; 748 } 749 706 750 BoundingBox<double> bb; 707 ///\bug: Chech whether the graph is empty.708 751 for(NodeIt n(g);n!=INVALID;++n) { 709 752 double ns=_nodeSizes[n]*_nodeScale; … … 865 908 double l=std::sqrt(dvec.normSquare()); 866 909 ///\todo better 'epsilon' would be nice here. 867 xy<double> d(dvec/std::max(l, 1e-9));910 xy<double> d(dvec/std::max(l,EPSILON)); 868 911 xy<double> m; 869 912 // m=xy<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
Note: See TracChangeset
for help on using the changeset viewer.