| ... | ... |
@@ -499,397 +499,409 @@ |
| 499 | 499 |
GraphToEps<T> &autoNodeScale(bool b=true) {
|
| 500 | 500 |
_autoNodeScale=b;return *this; |
| 501 | 501 |
} |
| 502 | 502 |
|
| 503 | 503 |
///Turns on/off the absolutematic node size scaling. |
| 504 | 504 |
|
| 505 | 505 |
///Turns on/off the absolutematic node size scaling. |
| 506 | 506 |
/// |
| 507 | 507 |
///\sa nodeScale() |
| 508 | 508 |
/// |
| 509 | 509 |
GraphToEps<T> &absoluteNodeSizes(bool b=true) {
|
| 510 | 510 |
_absoluteNodeSizes=b;return *this; |
| 511 | 511 |
} |
| 512 | 512 |
|
| 513 | 513 |
///Negates the Y coordinates. |
| 514 | 514 |
GraphToEps<T> &negateY(bool b=true) {
|
| 515 | 515 |
_negY=b;return *this; |
| 516 | 516 |
} |
| 517 | 517 |
|
| 518 | 518 |
///Turn on/off pre-scaling |
| 519 | 519 |
|
| 520 | 520 |
///By default graphToEps() rescales the whole image in order to avoid |
| 521 | 521 |
///very big or very small bounding boxes. |
| 522 | 522 |
/// |
| 523 | 523 |
///This (p)rescaling can be turned off with this function. |
| 524 | 524 |
/// |
| 525 | 525 |
GraphToEps<T> &preScale(bool b=true) {
|
| 526 | 526 |
_preScale=b;return *this; |
| 527 | 527 |
} |
| 528 | 528 |
|
| 529 | 529 |
///Sets a global scale factor for arc widths |
| 530 | 530 |
|
| 531 | 531 |
/// Sets a global scale factor for arc widths. |
| 532 | 532 |
/// |
| 533 | 533 |
/// If arcWidths() is not given, this function simply sets the arc |
| 534 | 534 |
/// widths to \c d. If arcWidths() is given, but |
| 535 | 535 |
/// autoArcWidthScale() is not, then the arc withs given by |
| 536 | 536 |
/// arcWidths() will be multiplied by the value \c d. |
| 537 | 537 |
/// If both arcWidths() and autoArcWidthScale() are used, then the |
| 538 | 538 |
/// arc withs will be scaled in such a way that the greatest width will be |
| 539 | 539 |
/// equal to \c d. |
| 540 | 540 |
GraphToEps<T> &arcWidthScale(double d=.003) {_arcWidthScale=d;return *this;}
|
| 541 | 541 |
///Turns on/off the automatic arc width scaling. |
| 542 | 542 |
|
| 543 | 543 |
///Turns on/off the automatic arc width scaling. |
| 544 | 544 |
/// |
| 545 | 545 |
///\sa arcWidthScale() |
| 546 | 546 |
/// |
| 547 | 547 |
GraphToEps<T> &autoArcWidthScale(bool b=true) {
|
| 548 | 548 |
_autoArcWidthScale=b;return *this; |
| 549 | 549 |
} |
| 550 | 550 |
///Turns on/off the absolutematic arc width scaling. |
| 551 | 551 |
|
| 552 | 552 |
///Turns on/off the absolutematic arc width scaling. |
| 553 | 553 |
/// |
| 554 | 554 |
///\sa arcWidthScale() |
| 555 | 555 |
/// |
| 556 | 556 |
GraphToEps<T> &absoluteArcWidths(bool b=true) {
|
| 557 | 557 |
_absoluteArcWidths=b;return *this; |
| 558 | 558 |
} |
| 559 | 559 |
///Sets a global scale factor for the whole picture |
| 560 | 560 |
GraphToEps<T> &scale(double d) {_scale=d;return *this;}
|
| 561 | 561 |
///Sets the width of the border around the picture |
| 562 | 562 |
GraphToEps<T> &border(double b=10) {_xBorder=_yBorder=b;return *this;}
|
| 563 | 563 |
///Sets the width of the border around the picture |
| 564 | 564 |
GraphToEps<T> &border(double x, double y) {
|
| 565 | 565 |
_xBorder=x;_yBorder=y;return *this; |
| 566 | 566 |
} |
| 567 | 567 |
///Sets whether to draw arrows |
| 568 | 568 |
GraphToEps<T> &drawArrows(bool b=true) {_drawArrows=b;return *this;}
|
| 569 | 569 |
///Sets the length of the arrowheads |
| 570 | 570 |
GraphToEps<T> &arrowLength(double d=1.0) {_arrowLength*=d;return *this;}
|
| 571 | 571 |
///Sets the width of the arrowheads |
| 572 | 572 |
GraphToEps<T> &arrowWidth(double d=.3) {_arrowWidth*=d;return *this;}
|
| 573 | 573 |
|
| 574 | 574 |
///Scales the drawing to fit to A4 page |
| 575 | 575 |
GraphToEps<T> &scaleToA4() {_scaleToA4=true;return *this;}
|
| 576 | 576 |
|
| 577 | 577 |
///Enables parallel arcs |
| 578 | 578 |
GraphToEps<T> &enableParallel(bool b=true) {_enableParallel=b;return *this;}
|
| 579 | 579 |
|
| 580 | 580 |
///Sets the distance between parallel arcs |
| 581 | 581 |
GraphToEps<T> &parArcDist(double d) {_parArcDist*=d;return *this;}
|
| 582 | 582 |
|
| 583 | 583 |
///Hides the arcs |
| 584 | 584 |
GraphToEps<T> &hideArcs(bool b=true) {_showArcs=!b;return *this;}
|
| 585 | 585 |
///Hides the nodes |
| 586 | 586 |
GraphToEps<T> &hideNodes(bool b=true) {_showNodes=!b;return *this;}
|
| 587 | 587 |
|
| 588 | 588 |
///Sets the size of the node texts |
| 589 | 589 |
GraphToEps<T> &nodeTextSize(double d) {_nodeTextSize=d;return *this;}
|
| 590 | 590 |
|
| 591 | 591 |
///Sets the color of the node texts to be different from the node color |
| 592 | 592 |
|
| 593 | 593 |
///Sets the color of the node texts to be as different from the node color |
| 594 | 594 |
///as it is possible. |
| 595 | 595 |
GraphToEps<T> &distantColorNodeTexts() |
| 596 | 596 |
{_nodeTextColorType=DIST_COL;return *this;}
|
| 597 | 597 |
///Sets the color of the node texts to be black or white and always visible. |
| 598 | 598 |
|
| 599 | 599 |
///Sets the color of the node texts to be black or white according to |
| 600 | 600 |
///which is more different from the node color. |
| 601 | 601 |
GraphToEps<T> &distantBWNodeTexts() |
| 602 | 602 |
{_nodeTextColorType=DIST_BW;return *this;}
|
| 603 | 603 |
|
| 604 | 604 |
///Gives a preamble block for node Postscript block. |
| 605 | 605 |
|
| 606 | 606 |
///Gives a preamble block for node Postscript block. |
| 607 | 607 |
/// |
| 608 | 608 |
///\sa nodePsTexts() |
| 609 | 609 |
GraphToEps<T> & nodePsTextsPreamble(const char *str) {
|
| 610 | 610 |
_nodePsTextsPreamble=str ;return *this; |
| 611 | 611 |
} |
| 612 | 612 |
///Sets whether the graph is undirected |
| 613 | 613 |
|
| 614 | 614 |
///Sets whether the graph is undirected. |
| 615 | 615 |
/// |
| 616 | 616 |
///This setting is the default for undirected graphs. |
| 617 | 617 |
/// |
| 618 | 618 |
///\sa directed() |
| 619 | 619 |
GraphToEps<T> &undirected(bool b=true) {_undirected=b;return *this;}
|
| 620 | 620 |
|
| 621 | 621 |
///Sets whether the graph is directed |
| 622 | 622 |
|
| 623 | 623 |
///Sets whether the graph is directed. |
| 624 | 624 |
///Use it to show the edges as a pair of directed ones. |
| 625 | 625 |
/// |
| 626 | 626 |
///This setting is the default for digraphs. |
| 627 | 627 |
/// |
| 628 | 628 |
///\sa undirected() |
| 629 | 629 |
GraphToEps<T> &directed(bool b=true) {_undirected=!b;return *this;}
|
| 630 | 630 |
|
| 631 | 631 |
///Sets the title. |
| 632 | 632 |
|
| 633 | 633 |
///Sets the title of the generated image, |
| 634 | 634 |
///namely it inserts a <tt>%%Title:</tt> DSC field to the header of |
| 635 | 635 |
///the EPS file. |
| 636 | 636 |
GraphToEps<T> &title(const std::string &t) {_title=t;return *this;}
|
| 637 | 637 |
///Sets the copyright statement. |
| 638 | 638 |
|
| 639 | 639 |
///Sets the copyright statement of the generated image, |
| 640 | 640 |
///namely it inserts a <tt>%%Copyright:</tt> DSC field to the header of |
| 641 | 641 |
///the EPS file. |
| 642 | 642 |
GraphToEps<T> ©right(const std::string &t) {_copyright=t;return *this;}
|
| 643 | 643 |
|
| 644 | 644 |
protected: |
| 645 | 645 |
bool isInsideNode(dim2::Point<double> p, double r,int t) |
| 646 | 646 |
{
|
| 647 | 647 |
switch(t) {
|
| 648 | 648 |
case CIRCLE: |
| 649 | 649 |
case MALE: |
| 650 | 650 |
case FEMALE: |
| 651 | 651 |
return p.normSquare()<=r*r; |
| 652 | 652 |
case SQUARE: |
| 653 | 653 |
return p.x<=r&&p.x>=-r&&p.y<=r&&p.y>=-r; |
| 654 | 654 |
case DIAMOND: |
| 655 | 655 |
return p.x+p.y<=r && p.x-p.y<=r && -p.x+p.y<=r && -p.x-p.y<=r; |
| 656 | 656 |
} |
| 657 | 657 |
return false; |
| 658 | 658 |
} |
| 659 | 659 |
|
| 660 | 660 |
public: |
| 661 | 661 |
~GraphToEps() { }
|
| 662 | 662 |
|
| 663 | 663 |
///Draws the graph. |
| 664 | 664 |
|
| 665 | 665 |
///Like other functions using |
| 666 | 666 |
///\ref named-templ-func-param "named template parameters", |
| 667 | 667 |
///this function calls the algorithm itself, i.e. in this case |
| 668 | 668 |
///it draws the graph. |
| 669 | 669 |
void run() {
|
| 670 | 670 |
const double EPSILON=1e-9; |
| 671 | 671 |
if(dontPrint) return; |
| 672 | 672 |
|
| 673 | 673 |
_graph_to_eps_bits::_NegY<typename T::CoordsMapType> |
| 674 | 674 |
mycoords(_coords,_negY); |
| 675 | 675 |
|
| 676 | 676 |
os << "%!PS-Adobe-2.0 EPSF-2.0\n"; |
| 677 | 677 |
if(_title.size()>0) os << "%%Title: " << _title << '\n'; |
| 678 | 678 |
if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n'; |
| 679 | 679 |
os << "%%Creator: LEMON, graphToEps()\n"; |
| 680 | 680 |
|
| 681 | 681 |
{
|
| 682 | 682 |
#ifndef WIN32 |
| 683 | 683 |
timeval tv; |
| 684 | 684 |
gettimeofday(&tv, 0); |
| 685 | 685 |
|
| 686 | 686 |
char cbuf[26]; |
| 687 | 687 |
ctime_r(&tv.tv_sec,cbuf); |
| 688 | 688 |
os << "%%CreationDate: " << cbuf; |
| 689 | 689 |
#else |
| 690 | 690 |
SYSTEMTIME time; |
| 691 |
GetSystemTime(&time); |
|
| 692 |
#if defined(_MSC_VER) && (_MSC_VER < 1500) |
|
| 693 |
LPWSTR buf1, buf2, buf3; |
|
| 694 |
if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time, |
|
| 695 |
L"ddd MMM dd", buf1, 11) && |
|
| 696 |
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time, |
|
| 697 |
L"HH':'mm':'ss", buf2, 9) && |
|
| 698 |
GetDateFormat(LOCALE_USER_DEFAULT, 0, &time, |
|
| 699 |
L"yyyy", buf3, 5)) {
|
|
| 700 |
os << "%%CreationDate: " << buf1 << ' ' |
|
| 701 |
<< buf2 << ' ' << buf3 << std::endl; |
|
| 702 |
} |
|
| 703 |
#else |
|
| 691 | 704 |
char buf1[11], buf2[9], buf3[5]; |
| 692 |
|
|
| 693 |
GetSystemTime(&time); |
|
| 694 | 705 |
if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time, |
| 695 | 706 |
"ddd MMM dd", buf1, 11) && |
| 696 | 707 |
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time, |
| 697 | 708 |
"HH':'mm':'ss", buf2, 9) && |
| 698 | 709 |
GetDateFormat(LOCALE_USER_DEFAULT, 0, &time, |
| 699 | 710 |
"yyyy", buf3, 5)) {
|
| 700 | 711 |
os << "%%CreationDate: " << buf1 << ' ' |
| 701 | 712 |
<< buf2 << ' ' << buf3 << std::endl; |
| 702 | 713 |
} |
| 703 | 714 |
#endif |
| 715 |
#endif |
|
| 704 | 716 |
} |
| 705 | 717 |
|
| 706 | 718 |
if (_autoArcWidthScale) {
|
| 707 | 719 |
double max_w=0; |
| 708 | 720 |
for(ArcIt e(g);e!=INVALID;++e) |
| 709 | 721 |
max_w=std::max(double(_arcWidths[e]),max_w); |
| 710 | 722 |
if(max_w>EPSILON) {
|
| 711 | 723 |
_arcWidthScale/=max_w; |
| 712 | 724 |
} |
| 713 | 725 |
} |
| 714 | 726 |
|
| 715 | 727 |
if (_autoNodeScale) {
|
| 716 | 728 |
double max_s=0; |
| 717 | 729 |
for(NodeIt n(g);n!=INVALID;++n) |
| 718 | 730 |
max_s=std::max(double(_nodeSizes[n]),max_s); |
| 719 | 731 |
if(max_s>EPSILON) {
|
| 720 | 732 |
_nodeScale/=max_s; |
| 721 | 733 |
} |
| 722 | 734 |
} |
| 723 | 735 |
|
| 724 | 736 |
double diag_len = 1; |
| 725 | 737 |
if(!(_absoluteNodeSizes&&_absoluteArcWidths)) {
|
| 726 | 738 |
dim2::Box<double> bb; |
| 727 | 739 |
for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]); |
| 728 | 740 |
if (bb.empty()) {
|
| 729 | 741 |
bb = dim2::Box<double>(dim2::Point<double>(0,0)); |
| 730 | 742 |
} |
| 731 | 743 |
diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare()); |
| 732 | 744 |
if(diag_len<EPSILON) diag_len = 1; |
| 733 | 745 |
if(!_absoluteNodeSizes) _nodeScale*=diag_len; |
| 734 | 746 |
if(!_absoluteArcWidths) _arcWidthScale*=diag_len; |
| 735 | 747 |
} |
| 736 | 748 |
|
| 737 | 749 |
dim2::Box<double> bb; |
| 738 | 750 |
for(NodeIt n(g);n!=INVALID;++n) {
|
| 739 | 751 |
double ns=_nodeSizes[n]*_nodeScale; |
| 740 | 752 |
dim2::Point<double> p(ns,ns); |
| 741 | 753 |
switch(_nodeShapes[n]) {
|
| 742 | 754 |
case CIRCLE: |
| 743 | 755 |
case SQUARE: |
| 744 | 756 |
case DIAMOND: |
| 745 | 757 |
bb.add(p+mycoords[n]); |
| 746 | 758 |
bb.add(-p+mycoords[n]); |
| 747 | 759 |
break; |
| 748 | 760 |
case MALE: |
| 749 | 761 |
bb.add(-p+mycoords[n]); |
| 750 | 762 |
bb.add(dim2::Point<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]); |
| 751 | 763 |
break; |
| 752 | 764 |
case FEMALE: |
| 753 | 765 |
bb.add(p+mycoords[n]); |
| 754 | 766 |
bb.add(dim2::Point<double>(-ns,-3.01*ns)+mycoords[n]); |
| 755 | 767 |
break; |
| 756 | 768 |
} |
| 757 | 769 |
} |
| 758 | 770 |
if (bb.empty()) {
|
| 759 | 771 |
bb = dim2::Box<double>(dim2::Point<double>(0,0)); |
| 760 | 772 |
} |
| 761 | 773 |
|
| 762 | 774 |
if(_scaleToA4) |
| 763 | 775 |
os <<"%%BoundingBox: 0 0 596 842\n%%DocumentPaperSizes: a4\n"; |
| 764 | 776 |
else {
|
| 765 | 777 |
if(_preScale) {
|
| 766 | 778 |
//Rescale so that BoundingBox won't be neither to big nor too small. |
| 767 | 779 |
while(bb.height()*_scale>1000||bb.width()*_scale>1000) _scale/=10; |
| 768 | 780 |
while(bb.height()*_scale<100||bb.width()*_scale<100) _scale*=10; |
| 769 | 781 |
} |
| 770 | 782 |
|
| 771 | 783 |
os << "%%BoundingBox: " |
| 772 | 784 |
<< int(floor(bb.left() * _scale - _xBorder)) << ' ' |
| 773 | 785 |
<< int(floor(bb.bottom() * _scale - _yBorder)) << ' ' |
| 774 | 786 |
<< int(ceil(bb.right() * _scale + _xBorder)) << ' ' |
| 775 | 787 |
<< int(ceil(bb.top() * _scale + _yBorder)) << '\n'; |
| 776 | 788 |
} |
| 777 | 789 |
|
| 778 | 790 |
os << "%%EndComments\n"; |
| 779 | 791 |
|
| 780 | 792 |
//x1 y1 x2 y2 x3 y3 cr cg cb w |
| 781 | 793 |
os << "/lb { setlinewidth setrgbcolor newpath moveto\n"
|
| 782 | 794 |
<< " 4 2 roll 1 index 1 index curveto stroke } bind def\n"; |
| 783 | 795 |
os << "/l { setlinewidth setrgbcolor newpath moveto lineto stroke }"
|
| 784 | 796 |
<< " bind def\n"; |
| 785 | 797 |
//x y r |
| 786 | 798 |
os << "/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath }"
|
| 787 | 799 |
<< " bind def\n"; |
| 788 | 800 |
//x y r |
| 789 | 801 |
os << "/sq { newpath 2 index 1 index add 2 index 2 index add moveto\n"
|
| 790 | 802 |
<< " 2 index 1 index sub 2 index 2 index add lineto\n" |
| 791 | 803 |
<< " 2 index 1 index sub 2 index 2 index sub lineto\n" |
| 792 | 804 |
<< " 2 index 1 index add 2 index 2 index sub lineto\n" |
| 793 | 805 |
<< " closepath pop pop pop} bind def\n"; |
| 794 | 806 |
//x y r |
| 795 | 807 |
os << "/di { newpath 2 index 1 index add 2 index moveto\n"
|
| 796 | 808 |
<< " 2 index 2 index 2 index add lineto\n" |
| 797 | 809 |
<< " 2 index 1 index sub 2 index lineto\n" |
| 798 | 810 |
<< " 2 index 2 index 2 index sub lineto\n" |
| 799 | 811 |
<< " closepath pop pop pop} bind def\n"; |
| 800 | 812 |
// x y r cr cg cb |
| 801 | 813 |
os << "/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill\n"
|
| 802 | 814 |
<< " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" |
| 803 | 815 |
<< " } bind def\n"; |
| 804 | 816 |
os << "/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill\n"
|
| 805 | 817 |
<< " setrgbcolor " << 1+_nodeBorderQuotient << " div sq fill\n" |
| 806 | 818 |
<< " } bind def\n"; |
| 807 | 819 |
os << "/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill\n"
|
| 808 | 820 |
<< " setrgbcolor " << 1+_nodeBorderQuotient << " div di fill\n" |
| 809 | 821 |
<< " } bind def\n"; |
| 810 | 822 |
os << "/nfemale { 0 0 0 setrgbcolor 3 index "
|
| 811 | 823 |
<< _nodeBorderQuotient/(1+_nodeBorderQuotient) |
| 812 | 824 |
<< " 1.5 mul mul setlinewidth\n" |
| 813 | 825 |
<< " newpath 5 index 5 index moveto " |
| 814 | 826 |
<< "5 index 5 index 5 index 3.01 mul sub\n" |
| 815 | 827 |
<< " lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub" |
| 816 | 828 |
<< " moveto\n" |
| 817 | 829 |
<< " 5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto " |
| 818 | 830 |
<< "stroke\n" |
| 819 | 831 |
<< " 5 index 5 index 5 index c fill\n" |
| 820 | 832 |
<< " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" |
| 821 | 833 |
<< " } bind def\n"; |
| 822 | 834 |
os << "/nmale {\n"
|
| 823 | 835 |
<< " 0 0 0 setrgbcolor 3 index " |
| 824 | 836 |
<< _nodeBorderQuotient/(1+_nodeBorderQuotient) |
| 825 | 837 |
<<" 1.5 mul mul setlinewidth\n" |
| 826 | 838 |
<< " newpath 5 index 5 index moveto\n" |
| 827 | 839 |
<< " 5 index 4 index 1 mul 1.5 mul add\n" |
| 828 | 840 |
<< " 5 index 5 index 3 sqrt 1.5 mul mul add\n" |
| 829 | 841 |
<< " 1 index 1 index lineto\n" |
| 830 | 842 |
<< " 1 index 1 index 7 index sub moveto\n" |
| 831 | 843 |
<< " 1 index 1 index lineto\n" |
| 832 | 844 |
<< " exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub" |
| 833 | 845 |
<< " lineto\n" |
| 834 | 846 |
<< " stroke\n" |
| 835 | 847 |
<< " 5 index 5 index 5 index c fill\n" |
| 836 | 848 |
<< " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" |
| 837 | 849 |
<< " } bind def\n"; |
| 838 | 850 |
|
| 839 | 851 |
|
| 840 | 852 |
os << "/arrl " << _arrowLength << " def\n"; |
| 841 | 853 |
os << "/arrw " << _arrowWidth << " def\n"; |
| 842 | 854 |
// l dx_norm dy_norm |
| 843 | 855 |
os << "/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def\n";
|
| 844 | 856 |
//len w dx_norm dy_norm x1 y1 cr cg cb |
| 845 | 857 |
os << "/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx "
|
| 846 | 858 |
<< "exch def\n" |
| 847 | 859 |
<< " /w exch def /len exch def\n" |
| 848 | 860 |
//<< "0.1 setlinewidth x1 y1 moveto dx len mul dy len mul rlineto stroke" |
| 849 | 861 |
<< " newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto\n" |
| 850 | 862 |
<< " len w sub arrl sub dx dy lrl\n" |
| 851 | 863 |
<< " arrw dy dx neg lrl\n" |
| 852 | 864 |
<< " dx arrl w add mul dy w 2 div arrw add mul sub\n" |
| 853 | 865 |
<< " dy arrl w add mul dx w 2 div arrw add mul add rlineto\n" |
| 854 | 866 |
<< " dx arrl w add mul neg dy w 2 div arrw add mul sub\n" |
| 855 | 867 |
<< " dy arrl w add mul neg dx w 2 div arrw add mul add rlineto\n" |
| 856 | 868 |
<< " arrw dy dx neg lrl\n" |
| 857 | 869 |
<< " len w sub arrl sub neg dx dy lrl\n" |
| 858 | 870 |
<< " closepath fill } bind def\n"; |
| 859 | 871 |
os << "/cshow { 2 index 2 index moveto dup stringwidth pop\n"
|
| 860 | 872 |
<< " neg 2 div fosi .35 mul neg rmoveto show pop pop} def\n"; |
| 861 | 873 |
|
| 862 | 874 |
os << "\ngsave\n"; |
| 863 | 875 |
if(_scaleToA4) |
| 864 | 876 |
if(bb.height()>bb.width()) {
|
| 865 | 877 |
double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.height(), |
| 866 | 878 |
(A4WIDTH-2*A4BORDER)/bb.width()); |
| 867 | 879 |
os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' ' |
| 868 | 880 |
<< ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER |
| 869 | 881 |
<< " translate\n" |
| 870 | 882 |
<< sc << " dup scale\n" |
| 871 | 883 |
<< -bb.left() << ' ' << -bb.bottom() << " translate\n"; |
| 872 | 884 |
} |
| 873 | 885 |
else {
|
| 874 | 886 |
double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(), |
| 875 | 887 |
(A4WIDTH-2*A4BORDER)/bb.height()); |
| 876 | 888 |
os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' ' |
| 877 | 889 |
<< ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER |
| 878 | 890 |
<< " translate\n" |
| 879 | 891 |
<< sc << " dup scale\n90 rotate\n" |
| 880 | 892 |
<< -bb.left() << ' ' << -bb.top() << " translate\n"; |
| 881 | 893 |
} |
| 882 | 894 |
else if(_scale!=1.0) os << _scale << " dup scale\n"; |
| 883 | 895 |
|
| 884 | 896 |
if(_showArcs) {
|
| 885 | 897 |
os << "%Arcs:\ngsave\n"; |
| 886 | 898 |
if(_enableParallel) {
|
| 887 | 899 |
std::vector<Arc> el; |
| 888 | 900 |
for(ArcIt e(g);e!=INVALID;++e) |
| 889 | 901 |
if((!_undirected||g.source(e)<g.target(e))&&_arcWidths[e]>0 |
| 890 | 902 |
&&g.source(e)!=g.target(e)) |
| 891 | 903 |
el.push_back(e); |
| 892 | 904 |
std::sort(el.begin(),el.end(),arcLess(g)); |
| 893 | 905 |
|
| 894 | 906 |
typename std::vector<Arc>::iterator j; |
| 895 | 907 |
for(typename std::vector<Arc>::iterator i=el.begin();i!=el.end();i=j) {
|
0 comments (0 inline)