COIN-OR::LEMON - Graph Library

Changeset 2008:0820d8168cbb in lemon-0.x for lemon


Ignore:
Timestamp:
03/15/06 10:45:59 (14 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2623
Message:

"Node shapes" added

Location:
lemon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/eps.cc

    r1971 r2008  
    299299  }
    300300
     301  EpsDrawer &EpsDrawer::node(NodeShapes t, double x, double y, double r,
     302                             Color col, Color brd)
     303  {
     304    out << "gsave\n"
     305        << brd.red() << ' ' << brd.green() << ' ' << brd.blue()
     306        << " setrgbcolor\n";
     307    switch(t) {
     308    case CIRCLE:
     309      out << "newpath " << x << ' ' << y << ' ' << r
     310          << " dup 3 index add 2 index moveto 0 360 arc fill\n";
     311      break;
     312    case SQUARE:
     313      out << "newpath\n"
     314          << x-r << ' ' << y-r << " moveto\n"
     315          << x-r << ' ' << y+r << " lineto\n"
     316          << x+r << ' ' << y+r << " lineto\n"
     317          << x+r << ' ' << y-r << " lineto closepath fill\n";
     318      break;
     319    case DIAMOND:
     320      out << "newpath\n"
     321          << x-r << ' ' << y   << " moveto\n"
     322          << x   << ' ' << y+r << " lineto\n"
     323          << x+r << ' ' << y   << " lineto\n"
     324          << x   << ' ' << y-r << " lineto closepath fill\n";
     325      break;
     326    case MALE:
     327      break;
     328    case FEMALE:
     329      break;
     330    }
     331    r/=1.1;
     332    out << col.red() << ' ' << col.green() << ' ' << col.blue()
     333        << " setrgbcolor\n";
     334    switch(t) {
     335    case CIRCLE:
     336      out << "newpath " << x << ' ' << y << ' ' << r
     337          << " dup 3 index add 2 index moveto 0 360 arc fill\n";
     338      break;
     339    case SQUARE:
     340      out << "newpath\n"
     341          << x-r << ' ' << y-r << " moveto\n"
     342          << x-r << ' ' << y+r << " lineto\n"
     343          << x+r << ' ' << y+r << " lineto\n"
     344          << x+r << ' ' << y-r << " lineto closepath fill\n";
     345      break;
     346    case DIAMOND:
     347      out << "newpath\n"
     348          << x-r << ' ' << y   << " moveto\n"
     349          << x   << ' ' << y+r << " lineto\n"
     350          << x+r << ' ' << y   << " lineto\n"
     351          << x   << ' ' << y-r << " lineto closepath fill\n";
     352      break;
     353    case MALE:
     354      break;
     355    case FEMALE:
     356      break;
     357    }
     358
     359    out << "grestore\n";
     360    return *this;
     361  }
     362 
    301363}
  • lemon/eps.h

    r1971 r2008  
    5050    std::ostream &out;
    5151   
     52    ///Node shapes
     53    ///
     54    enum NodeShapes {
     55      /// = 0
     56      ///\image html nodeshape_0.png
     57      ///\image latex nodeshape_0.eps "CIRCLE shape (0)" width=2cm
     58      CIRCLE=0,
     59      /// = 1
     60      ///\image html nodeshape_1.png
     61      ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm
     62      ///
     63      SQUARE=1,
     64      /// = 2
     65      ///\image html nodeshape_2.png
     66      ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm
     67      ///
     68      DIAMOND=2,
     69      /// = 3
     70      ///\image html nodeshape_3.png
     71      ///\image latex nodeshape_2.eps "MALE shape (4)" width=2cm
     72      ///
     73      ///\warning Not implemented
     74      MALE=3,
     75      /// = 4
     76      ///\image html nodeshape_4.png
     77      ///\image latex nodeshape_2.eps "FEMALE shape (4)" width=2cm
     78      ///
     79      ///\warning Not implemented
     80      FEMALE=4
     81    };
    5282    ///\e
    5383
     
    247277    }
    248278   
     279    ///Draw a node shape
     280
     281    ///Draw a node shape.
     282    ///
     283    ///\param t The shape of the drawn object
     284    ///\param x The \c x coordinate of the node
     285    ///\param y The \c y coordinate of the node
     286    ///\param col Color of the node. The default color is white
     287    ///\param brd Color of the node border. The default color is black
     288    EpsDrawer &node(NodeShapes t, double x, double y, double r,
     289                    Color col=Color(1,1,1), Color brd=Color(0,0,0));
     290    ///Draw a node shape
     291   
     292    ///Draw a node shape.
     293    ///
     294    ///\param t The shape of the drawn object
     295    ///\param pos Position of the node
     296    ///\param col Color of the node. The default color is white
     297    ///\param brd Color of the node border. The default color is black
     298    template<class T>
     299    EpsDrawer &node(NodeShapes t, xy<T> pos, double r,
     300                    Color col=Color(1,1,1), Color brd=Color(0,0,0))
     301    {
     302      return node(t,pos.x,pos.y,r,col,brd);
     303    }
     304
    249305    ///Translate the coordinate system
    250306    EpsDrawer &translate(double x,double y);
Note: See TracChangeset for help on using the changeset viewer.