One more node-shape added.
authoralpar
Wed, 19 Jan 2005 12:17:11 +0000
changeset 1088358526a620f8
parent 1087 d496d1d5a5e7
child 1089 c0f4ebdc0034
One more node-shape added.
src/demo/graph_to_eps_demo.cc
src/lemon/graph_to_eps.h
     1.1 --- a/src/demo/graph_to_eps_demo.cc	Tue Jan 18 12:23:09 2005 +0000
     1.2 +++ b/src/demo/graph_to_eps_demo.cc	Wed Jan 19 12:17:11 2005 +0000
     1.3 @@ -72,10 +72,10 @@
     1.4    ListGraph::EdgeMap<int> widths(g);
     1.5    
     1.6    coords[n1]=Xy(50,50);  sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
     1.7 -  coords[n2]=Xy(50,70);  sizes[n2]=2; colors[n2]=2; shapes[n2]=0;
     1.8 +  coords[n2]=Xy(50,70);  sizes[n2]=2; colors[n2]=2; shapes[n2]=2;
     1.9    coords[n3]=Xy(70,70);  sizes[n3]=1; colors[n3]=3; shapes[n3]=0;
    1.10    coords[n4]=Xy(70,50);  sizes[n4]=2; colors[n4]=4; shapes[n4]=1;
    1.11 -  coords[n5]=Xy(85,60);  sizes[n5]=3; colors[n5]=5; shapes[n5]=0;
    1.12 +  coords[n5]=Xy(85,60);  sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
    1.13    
    1.14    Edge e;
    1.15  
     2.1 --- a/src/lemon/graph_to_eps.h	Tue Jan 18 12:23:09 2005 +0000
     2.2 +++ b/src/lemon/graph_to_eps.h	Wed Jan 19 12:17:11 2005 +0000
     2.3 @@ -157,7 +157,7 @@
     2.4  
     2.5    bool dontPrint;
     2.6  
     2.7 -  enum NodeShapes { CIRCLE=0, SQUARE=1 };
     2.8 +  enum NodeShapes { CIRCLE=0, SQUARE=1, DIAMOND=2 };
     2.9  		   
    2.10    class edgeLess {
    2.11      const Graph &g;
    2.12 @@ -414,6 +414,8 @@
    2.13        return p.normSquare()<=r*r;
    2.14      case SQUARE:
    2.15        return p.x<=r&&p.x>=-r&&p.y<=r&&p.y>=-r;
    2.16 +    case DIAMOND:
    2.17 +      return p.x+p.y<=r && p.x-p.y<=r && -p.x+p.y<=r && -p.x-p.y<=r;
    2.18      }
    2.19      return false;
    2.20    }
    2.21 @@ -449,6 +451,12 @@
    2.22         << "      2 index 1 index sub 2 index 2 index sub lineto\n"
    2.23         << "      2 index 1 index add 2 index 2 index sub lineto\n"
    2.24         << "      closepath pop pop pop} bind def\n";
    2.25 +    //x y r
    2.26 +    os << "/di { newpath 2 index 1 index add 2 index moveto\n"
    2.27 +       << "      2 index             2 index 2 index add lineto\n"
    2.28 +       << "      2 index 1 index sub 2 index             lineto\n"
    2.29 +       << "      2 index             2 index 2 index sub lineto\n"
    2.30 +       << "      closepath pop pop pop} bind def\n";
    2.31      // x y r cr cg cb
    2.32      os << "/nc { setrgbcolor 2 index 2 index 2 index c fill\n"
    2.33         << "     0 0 0 setrgbcolor dup "
    2.34 @@ -460,6 +468,11 @@
    2.35         << _nodeBorderQuotient << " mul setlinewidth "
    2.36         << 1+_nodeBorderQuotient/2 << " div sq stroke\n"
    2.37         << "   } bind def\n";
    2.38 +    os << "/ndi { setrgbcolor 2 index 2 index 2 index di fill\n"
    2.39 +       << "     0 0 0 setrgbcolor dup "
    2.40 +       << _nodeBorderQuotient << " mul setlinewidth "
    2.41 +       << 1+_nodeBorderQuotient/2 << " div di stroke\n"
    2.42 +       << "   } bind def\n";
    2.43      os << "/arrl " << _arrowLength << " def\n";
    2.44      os << "/arrw " << _arrowWidth << " def\n";
    2.45      // l dx_norm dy_norm
    2.46 @@ -619,6 +632,8 @@
    2.47  	  os<< "nc";break;
    2.48  	case SQUARE:
    2.49  	  os<< "nsq";break;
    2.50 +	case DIAMOND:
    2.51 +	  os<< "ndi";break;
    2.52  	}
    2.53  	os<<'\n';
    2.54        }