[Lemon-commits] [lemon_svn] alpar: r2623 - in hugo/trunk: demo lemon

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:53:59 CET 2006


Author: alpar
Date: Wed Mar 15 10:45:59 2006
New Revision: 2623

Modified:
   hugo/trunk/demo/eps_demo.cc
   hugo/trunk/lemon/eps.cc
   hugo/trunk/lemon/eps.h

Log:
"Node shapes" added

Modified: hugo/trunk/demo/eps_demo.cc
==============================================================================
--- hugo/trunk/demo/eps_demo.cc	(original)
+++ hugo/trunk/demo/eps_demo.cc	Wed Mar 15 10:45:59 2006
@@ -106,5 +106,10 @@
   
   fonts(ed.color(.7,.7,.7));
   ed.color(0,1,0);
+
+  ed.node(ed.CIRCLE,128,333,25);
+  ed.node(ed.SQUARE,256,333,25);
+  ed.node(ed.DIAMOND,128+256,333,25);
+
   kosar(ed);
 }

Modified: hugo/trunk/lemon/eps.cc
==============================================================================
--- hugo/trunk/lemon/eps.cc	(original)
+++ hugo/trunk/lemon/eps.cc	Wed Mar 15 10:45:59 2006
@@ -298,4 +298,66 @@
     return *this;
   }
 
+  EpsDrawer &EpsDrawer::node(NodeShapes t, double x, double y, double r,
+			     Color col, Color brd)
+  {
+    out << "gsave\n"
+	<< brd.red() << ' ' << brd.green() << ' ' << brd.blue() 
+	<< " setrgbcolor\n";
+    switch(t) {
+    case CIRCLE:
+      out << "newpath " << x << ' ' << y << ' ' << r 
+	  << " dup 3 index add 2 index moveto 0 360 arc fill\n";
+      break;
+    case SQUARE:
+      out << "newpath\n"
+	  << x-r << ' ' << y-r << " moveto\n"
+	  << x-r << ' ' << y+r << " lineto\n"
+	  << x+r << ' ' << y+r << " lineto\n"
+	  << x+r << ' ' << y-r << " lineto closepath fill\n";
+      break;
+    case DIAMOND:
+      out << "newpath\n"
+	  << x-r << ' ' << y   << " moveto\n"
+	  << x   << ' ' << y+r << " lineto\n"
+	  << x+r << ' ' << y   << " lineto\n"
+	  << x   << ' ' << y-r << " lineto closepath fill\n";
+      break;
+    case MALE:
+      break;
+    case FEMALE:
+      break;
+    }
+    r/=1.1;
+    out << col.red() << ' ' << col.green() << ' ' << col.blue() 
+	<< " setrgbcolor\n";
+    switch(t) {
+    case CIRCLE:
+      out << "newpath " << x << ' ' << y << ' ' << r 
+	  << " dup 3 index add 2 index moveto 0 360 arc fill\n";
+      break;
+    case SQUARE:
+      out << "newpath\n"
+	  << x-r << ' ' << y-r << " moveto\n"
+	  << x-r << ' ' << y+r << " lineto\n"
+	  << x+r << ' ' << y+r << " lineto\n"
+	  << x+r << ' ' << y-r << " lineto closepath fill\n";
+      break;
+    case DIAMOND:
+      out << "newpath\n"
+	  << x-r << ' ' << y   << " moveto\n"
+	  << x   << ' ' << y+r << " lineto\n"
+	  << x+r << ' ' << y   << " lineto\n"
+	  << x   << ' ' << y-r << " lineto closepath fill\n";
+      break;
+    case MALE:
+      break;
+    case FEMALE:
+      break;
+    }
+
+    out << "grestore\n";
+    return *this;
+  }
+  
 }

Modified: hugo/trunk/lemon/eps.h
==============================================================================
--- hugo/trunk/lemon/eps.h	(original)
+++ hugo/trunk/lemon/eps.h	Wed Mar 15 10:45:59 2006
@@ -49,6 +49,36 @@
     
     std::ostream &out;
     
+    ///Node shapes
+    ///
+    enum NodeShapes { 
+      /// = 0
+      ///\image html nodeshape_0.png
+      ///\image latex nodeshape_0.eps "CIRCLE shape (0)" width=2cm
+      CIRCLE=0, 
+      /// = 1
+      ///\image html nodeshape_1.png
+      ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm
+      ///
+      SQUARE=1, 
+      /// = 2
+      ///\image html nodeshape_2.png
+      ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm
+      ///
+      DIAMOND=2,
+      /// = 3
+      ///\image html nodeshape_3.png
+      ///\image latex nodeshape_2.eps "MALE shape (4)" width=2cm
+      ///
+      ///\warning Not implemented
+      MALE=3,
+      /// = 4
+      ///\image html nodeshape_4.png
+      ///\image latex nodeshape_2.eps "FEMALE shape (4)" width=2cm
+      ///
+      ///\warning Not implemented
+      FEMALE=4
+    };
     ///\e 
 
     ///The generated file is put to \c os.
@@ -246,6 +276,32 @@
       return color(c.red(),c.green(),c.blue());
     }
     
+    ///Draw a node shape
+
+    ///Draw a node shape.
+    ///
+    ///\param t The shape of the drawn object
+    ///\param x The \c x coordinate of the node
+    ///\param y The \c y coordinate of the node
+    ///\param col Color of the node. The default color is white
+    ///\param brd Color of the node border. The default color is black
+    EpsDrawer &node(NodeShapes t, double x, double y, double r,
+		    Color col=Color(1,1,1), Color brd=Color(0,0,0));
+    ///Draw a node shape
+    
+    ///Draw a node shape.
+    ///
+    ///\param t The shape of the drawn object
+    ///\param pos Position of the node
+    ///\param col Color of the node. The default color is white
+    ///\param brd Color of the node border. The default color is black
+    template<class T>
+    EpsDrawer &node(NodeShapes t, xy<T> pos, double r,
+		    Color col=Color(1,1,1), Color brd=Color(0,0,0))
+    {
+      return node(t,pos.x,pos.y,r,col,brd);
+    }
+
     ///Translate the coordinate system
     EpsDrawer &translate(double x,double y);
     ///Translate the coordinate system



More information about the Lemon-commits mailing list