0
2
0
19
26
| ... | ... |
@@ -110,16 +110,16 @@ |
| 110 | 110 |
public: |
| 111 | 111 |
///Constructor |
| 112 | 112 |
|
| 113 | 113 |
///Constructor |
| 114 |
///\param have_white indicates whether white is amongst the |
|
| 115 |
///provided initial colors (\c true) or not (\c false). If it is true, |
|
| 116 |
///white will be assigned to \c 0. |
|
| 114 | 117 |
///\param num the number of the allocated colors. If it is \c -1, |
| 115 |
///the default color configuration is set up (26 color plus the |
|
| 118 |
///the default color configuration is set up (26 color plus optionaly the |
|
| 116 | 119 |
///white). If \c num is less then 26/27 then the default color |
| 117 | 120 |
///list is cut. Otherwise the color list is filled repeatedly with |
| 118 | 121 |
///the default color list. (The colors can be changed later on.) |
| 119 |
///\param have_white indicates whether white is amongst the |
|
| 120 |
///provided color (\c true) or not (\c false). If it is true, |
|
| 121 |
///white will be assigned to \c 0. |
|
| 122 | 122 |
Palette(bool have_white=false,int num=-1) |
| 123 | 123 |
{
|
| 124 | 124 |
if (num==0) return; |
| 125 | 125 |
do {
|
| ... | ... |
@@ -172,9 +172,9 @@ |
| 172 | 172 |
void set(int i,const Color &c) |
| 173 | 173 |
{
|
| 174 | 174 |
colors[i%colors.size()]=c; |
| 175 | 175 |
} |
| 176 |
/// |
|
| 176 |
///Add a new color to the end of the color list. |
|
| 177 | 177 |
void add(const Color &c) |
| 178 | 178 |
{
|
| 179 | 179 |
colors.push_back(c); |
| 180 | 180 |
} |
| ... | ... |
@@ -184,9 +184,9 @@ |
| 184 | 184 |
///Returns the number of the existing colors. |
| 185 | 185 |
int size() const { return int(colors.size());}
|
| 186 | 186 |
}; |
| 187 | 187 |
|
| 188 |
///Returns a |
|
| 188 |
///Returns a visibly distinct \ref Color |
|
| 189 | 189 |
|
| 190 | 190 |
///Returns a \ref Color which is as different from the given parameter |
| 191 | 191 |
///as it is possible. |
| 192 | 192 |
inline Color distantColor(const Color &c) |
| ... | ... |
@@ -42,11 +42,9 @@ |
| 42 | 42 |
|
| 43 | 43 |
|
| 44 | 44 |
///\ingroup eps_io |
| 45 | 45 |
///\file |
| 46 |
///\brief Simple graph drawer |
|
| 47 |
/// |
|
| 48 |
///\ |
|
| 46 |
///\brief A well configurable tool for visualizing graphs |
|
| 49 | 47 |
|
| 50 | 48 |
namespace lemon {
|
| 51 | 49 |
|
| 52 | 50 |
namespace _graph_to_eps_bits {
|
| ... | ... |
@@ -171,18 +169,11 @@ |
| 171 | 169 |
_preScale(true) |
| 172 | 170 |
{}
|
| 173 | 171 |
}; |
| 174 | 172 |
|
| 175 |
/// |
|
| 173 |
///Auxiliary class to implement the named parameters of \ref graphToEps() |
|
| 176 | 174 |
|
| 177 |
///Helper class to implement the named parameters of \ref graphToEps() |
|
| 178 |
///\todo Is 'helper class' a good name for this? |
|
| 179 |
/// |
|
| 180 |
///\todo Follow PostScript's DSC. |
|
| 181 |
/// Use own dictionary. |
|
| 182 |
///\todo Useful new features. |
|
| 183 |
/// - Linestyles: dotted, dashed etc. |
|
| 184 |
/// - A second color and percent value for the lines. |
|
| 175 |
///Auxiliary class to implement the named parameters of \ref graphToEps() |
|
| 185 | 176 |
template<class T> class GraphToEps : public T |
| 186 | 177 |
{
|
| 187 | 178 |
// Can't believe it is required by the C++ standard |
| 188 | 179 |
using T::g; |
| ... | ... |
@@ -368,9 +359,9 @@ |
| 368 | 359 |
}; |
| 369 | 360 |
///Sets the map of the node shapes |
| 370 | 361 |
|
| 371 | 362 |
///Sets the map of the node shapes. |
| 372 |
///The |
|
| 363 |
///The available shape values |
|
| 373 | 364 |
///can be found in \ref NodeShapes "enum NodeShapes". |
| 374 | 365 |
///\param x must be a node map with \c int (or convertible) values. |
| 375 | 366 |
///\sa NodeShapes |
| 376 | 367 |
template<class X> GraphToEps<NodeShapesTraits<X> > nodeShapes(const X &x) |
| ... | ... |
@@ -410,10 +401,8 @@ |
| 410 | 401 |
///\param x must be a node map with type that can be pushed to a standard |
| 411 | 402 |
///ostream. |
| 412 | 403 |
/// |
| 413 | 404 |
///\sa nodePsTextsPreamble() |
| 414 |
///\todo Offer the choise not to move to the centre but pass the coordinates |
|
| 415 |
///to the Postscript block inserted. |
|
| 416 | 405 |
template<class X> GraphToEps<NodePsTextsTraits<X> > nodePsTexts(const X &x) |
| 417 | 406 |
{
|
| 418 | 407 |
dontPrint=true; |
| 419 | 408 |
_showNodePsText=true; |
| ... | ... |
@@ -520,15 +509,13 @@ |
| 520 | 509 |
///Negates the Y coordinates. |
| 521 | 510 |
|
| 522 | 511 |
///Negates the Y coordinates. |
| 523 | 512 |
/// |
| 524 |
///\todo More docs. |
|
| 525 |
/// |
|
| 526 | 513 |
GraphToEps<T> &negateY(bool b=true) {
|
| 527 | 514 |
_negY=b;return *this; |
| 528 | 515 |
} |
| 529 | 516 |
|
| 530 |
///Turn on/off |
|
| 517 |
///Turn on/off pre-scaling |
|
| 531 | 518 |
|
| 532 | 519 |
///By default graphToEps() rescales the whole image in order to avoid |
| 533 | 520 |
///very big or very small bounding boxes. |
| 534 | 521 |
/// |
| ... | ... |
@@ -577,9 +564,9 @@ |
| 577 | 564 |
///Sets the width of the border around the picture |
| 578 | 565 |
|
| 579 | 566 |
///Sets the width of the border around the picture |
| 580 | 567 |
/// |
| 581 |
GraphToEps<T> &border(double b) {_xBorder=_yBorder=b;return *this;}
|
|
| 568 |
GraphToEps<T> &border(double b=10) {_xBorder=_yBorder=b;return *this;}
|
|
| 582 | 569 |
///Sets the width of the border around the picture |
| 583 | 570 |
|
| 584 | 571 |
///Sets the width of the border around the picture |
| 585 | 572 |
/// |
| ... | ... |
@@ -594,14 +581,14 @@ |
| 594 | 581 |
///Sets the length of the arrowheads |
| 595 | 582 |
|
| 596 | 583 |
///Sets the length of the arrowheads |
| 597 | 584 |
/// |
| 598 |
GraphToEps<T> &arrowLength(double d) {_arrowLength*=d;return *this;}
|
|
| 585 |
GraphToEps<T> &arrowLength(double d=1.0) {_arrowLength*=d;return *this;}
|
|
| 599 | 586 |
///Sets the width of the arrowheads |
| 600 | 587 |
|
| 601 | 588 |
///Sets the width of the arrowheads |
| 602 | 589 |
/// |
| 603 |
GraphToEps<T> &arrowWidth(double d) {_arrowWidth*=d;return *this;}
|
|
| 590 |
GraphToEps<T> &arrowWidth(double d=.3) {_arrowWidth*=d;return *this;}
|
|
| 604 | 591 |
|
| 605 | 592 |
///Scales the drawing to fit to A4 page |
| 606 | 593 |
|
| 607 | 594 |
///Scales the drawing to fit to A4 page |
| ... | ... |
@@ -661,16 +648,23 @@ |
| 661 | 648 |
_nodePsTextsPreamble=str ;return *this; |
| 662 | 649 |
} |
| 663 | 650 |
///Sets whether the the graph is undirected |
| 664 | 651 |
|
| 665 |
///Sets whether the the graph is undirected |
|
| 652 |
///Sets whether the the graph is undirected. |
|
| 666 | 653 |
/// |
| 654 |
///This setting is the default for undirected graphs. |
|
| 655 |
/// |
|
| 656 |
///\sa directed() |
|
| 667 | 657 |
GraphToEps<T> &undirected(bool b=true) {_undirected=b;return *this;}
|
| 668 | 658 |
|
| 669 | 659 |
///Sets whether the the graph is directed |
| 670 | 660 |
|
| 671 | 661 |
///Sets whether the the graph is directed. |
| 672 | 662 |
///Use it to show the edges as a pair of directed ones. |
| 663 |
/// |
|
| 664 |
///This setting is the default for digraphs. |
|
| 665 |
/// |
|
| 666 |
///\sa undirected() |
|
| 673 | 667 |
GraphToEps<T> &directed(bool b=true) {_undirected=!b;return *this;}
|
| 674 | 668 |
|
| 675 | 669 |
///Sets the title. |
| 676 | 670 |
|
| ... | ... |
@@ -682,9 +676,8 @@ |
| 682 | 676 |
|
| 683 | 677 |
///Sets the copyright statement of the generated image, |
| 684 | 678 |
///namely it inserts a <tt>%%Copyright:</tt> DSC field to the header of |
| 685 | 679 |
///the EPS file. |
| 686 |
///\todo Multiline copyright notice could be supported. |
|
| 687 | 680 |
GraphToEps<T> ©right(const std::string &t) {_copyright=t;return *this;}
|
| 688 | 681 |
|
| 689 | 682 |
protected: |
| 690 | 683 |
bool isInsideNode(dim2::Point<double> p, double r,int t) |
| ... | ... |
@@ -708,12 +701,12 @@ |
| 708 | 701 |
///Draws the graph. |
| 709 | 702 |
|
| 710 | 703 |
///Like other functions using |
| 711 | 704 |
///\ref named-templ-func-param "named template parameters", |
| 712 |
///this function |
|
| 705 |
///this function calls the algorithm itself, i.e. in this case |
|
| 713 | 706 |
///it draws the graph. |
| 714 | 707 |
void run() {
|
| 715 |
|
|
| 708 |
//\todo better 'epsilon' would be nice here. |
|
| 716 | 709 |
const double EPSILON=1e-9; |
| 717 | 710 |
if(dontPrint) return; |
| 718 | 711 |
|
| 719 | 712 |
_graph_to_eps_bits::_NegY<typename T::CoordsMapType> |
| ... | ... |
@@ -929,9 +922,9 @@ |
| 929 | 922 |
sw/=-2.0; |
| 930 | 923 |
dim2::Point<double> |
| 931 | 924 |
dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]); |
| 932 | 925 |
double l=std::sqrt(dvec.normSquare()); |
| 933 |
|
|
| 926 |
//\todo better 'epsilon' would be nice here. |
|
| 934 | 927 |
dim2::Point<double> d(dvec/std::max(l,EPSILON)); |
| 935 | 928 |
dim2::Point<double> m; |
| 936 | 929 |
// m=dim2::Point<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0; |
| 937 | 930 |
|
0 comments (0 inline)