748 protected: |
758 protected: |
749 bool isInsideNode(xy<double> p, double r,int t) |
759 bool isInsideNode(xy<double> p, double r,int t) |
750 { |
760 { |
751 switch(t) { |
761 switch(t) { |
752 case CIRCLE: |
762 case CIRCLE: |
|
763 case MALE: |
|
764 case FEMALE: |
753 return p.normSquare()<=r*r; |
765 return p.normSquare()<=r*r; |
754 case SQUARE: |
766 case SQUARE: |
755 return p.x<=r&&p.x>=-r&&p.y<=r&&p.y>=-r; |
767 return p.x<=r&&p.x>=-r&&p.y<=r&&p.y>=-r; |
756 case DIAMOND: |
768 case DIAMOND: |
757 return p.x+p.y<=r && p.x-p.y<=r && -p.x+p.y<=r && -p.x-p.y<=r; |
769 return p.x+p.y<=r && p.x-p.y<=r && -p.x+p.y<=r && -p.x-p.y<=r; |
811 BoundingBox<double> bb; |
823 BoundingBox<double> bb; |
812 ///\bug: Chech whether the graph is empty. |
824 ///\bug: Chech whether the graph is empty. |
813 for(NodeIt n(g);n!=INVALID;++n) { |
825 for(NodeIt n(g);n!=INVALID;++n) { |
814 double ns=_nodeSizes[n]*_nodeScale; |
826 double ns=_nodeSizes[n]*_nodeScale; |
815 xy<double> p(ns,ns); |
827 xy<double> p(ns,ns); |
816 bb.add(p+mycoords[n]); |
828 switch(_nodeShapes[n]) { |
817 bb.add(-p+mycoords[n]); |
829 case CIRCLE: |
|
830 case SQUARE: |
|
831 case DIAMOND: |
|
832 bb.add(p+mycoords[n]); |
|
833 bb.add(-p+mycoords[n]); |
|
834 break; |
|
835 case MALE: |
|
836 bb.add(-p+mycoords[n]); |
|
837 bb.add(xy<double>(1.5*ns,1.5*sqrt(3)*ns)+mycoords[n]); |
|
838 break; |
|
839 case FEMALE: |
|
840 bb.add(p+mycoords[n]); |
|
841 bb.add(xy<double>(-ns,-3.01*ns)+mycoords[n]); |
|
842 break; |
|
843 } |
818 } |
844 } |
819 if (bb.empty()) { |
845 if (bb.empty()) { |
820 bb = BoundingBox<double>(xy<double>(0,0)); |
846 bb = BoundingBox<double>(xy<double>(0,0)); |
821 } |
847 } |
822 |
848 |
856 << " setrgbcolor " << 1+_nodeBorderQuotient << " div sq fill\n" |
882 << " setrgbcolor " << 1+_nodeBorderQuotient << " div sq fill\n" |
857 << " } bind def\n"; |
883 << " } bind def\n"; |
858 os << "/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill\n" |
884 os << "/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill\n" |
859 << " setrgbcolor " << 1+_nodeBorderQuotient << " div di fill\n" |
885 << " setrgbcolor " << 1+_nodeBorderQuotient << " div di fill\n" |
860 << " } bind def\n"; |
886 << " } bind def\n"; |
|
887 os << "/nfemale { 0 0 0 setrgbcolor 3 index " |
|
888 << _nodeBorderQuotient/(1+_nodeBorderQuotient) |
|
889 << " 1.5 mul mul setlinewidth\n" |
|
890 << " newpath 5 index 5 index moveto " |
|
891 << "5 index 5 index 5 index 3.01 mul sub\n" |
|
892 << " lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto\n" |
|
893 << " 5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke\n" |
|
894 << " 5 index 5 index 5 index c fill\n" |
|
895 << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" |
|
896 << " } bind def\n"; |
|
897 os << "/nmale {\n" |
|
898 << " 0 0 0 setrgbcolor 3 index " |
|
899 << _nodeBorderQuotient/(1+_nodeBorderQuotient) |
|
900 <<" 1.5 mul mul setlinewidth\n" |
|
901 << " newpath 5 index 5 index moveto\n" |
|
902 << " 5 index 4 index 1 mul 1.5 mul add\n" |
|
903 << " 5 index 5 index 3 sqrt 1.5 mul mul add\n" |
|
904 << " 1 index 1 index lineto\n" |
|
905 << " 1 index 1 index 7 index sub moveto\n" |
|
906 << " 1 index 1 index lineto\n" |
|
907 << " exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto\n" |
|
908 << " stroke\n" |
|
909 << " 5 index 5 index 5 index c fill\n" |
|
910 << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n" |
|
911 << " } bind def\n"; |
|
912 |
|
913 |
861 os << "/arrl " << _arrowLength << " def\n"; |
914 os << "/arrl " << _arrowLength << " def\n"; |
862 os << "/arrw " << _arrowWidth << " def\n"; |
915 os << "/arrw " << _arrowWidth << " def\n"; |
863 // l dx_norm dy_norm |
916 // l dx_norm dy_norm |
864 os << "/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def\n"; |
917 os << "/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def\n"; |
865 //len w dx_norm dy_norm x1 y1 cr cg cb |
918 //len w dx_norm dy_norm x1 y1 cr cg cb |