lemon/eps.h
changeset 2207 75a29ac69c19
parent 2174 f9e43b5cc617
child 2214 a886e48e0d91
equal deleted inserted replaced
3:a6793bfc7dd2 4:ba73720b8a66
    22 #include<string>
    22 #include<string>
    23 #include<iostream>
    23 #include<iostream>
    24 #include<fstream>
    24 #include<fstream>
    25 #include<sstream>
    25 #include<sstream>
    26 #include<lemon/color.h>
    26 #include<lemon/color.h>
    27 #include<lemon/xy.h>
    27 #include<lemon/dim2.h>
    28 
    28 
    29   ///\ingroup eps_io
    29   ///\ingroup eps_io
    30   ///\file
    30   ///\file
    31   ///\brief Simple tool to create \c .eps files
    31   ///\brief Simple tool to create \c .eps files
    32   ///
    32   ///
    98 
    98 
    99     ///The generated file is put to \c os.
    99     ///The generated file is put to \c os.
   100     ///
   100     ///
   101     ///\c s determines the upper
   101     ///\c s determines the upper
   102     ///right corner of the bounding box. The lower left corner is (0,0).
   102     ///right corner of the bounding box. The lower left corner is (0,0).
   103     EpsDrawer(std::ostream &os,xy<double> s);
   103     EpsDrawer(std::ostream &os,dim2::Point<double> s);
   104     ///\e
   104     ///\e
   105 
   105 
   106     ///The generated file is put to \c os.
   106     ///The generated file is put to \c os.
   107     ///
   107     ///
   108     ///\c a and \c b
   108     ///\c a and \c b
   109     /// determine the lower left and the upper right corners of
   109     /// determine the lower left and the upper right corners of
   110     ///the bounding box, respectively.
   110     ///the bounding box, respectively.
   111     EpsDrawer(std::ostream &os,xy<double> a, xy<double> b);
   111     EpsDrawer(std::ostream &os,dim2::Point<double> a, dim2::Point<double> b);
   112     ///\e
   112     ///\e
   113 
   113 
   114     ///The generated picture is put to the file \c name.
   114     ///The generated picture is put to the file \c name.
   115     ///
   115     ///
   116     ///\c x and \c y determine the upper
   116     ///\c x and \c y determine the upper
   128 
   128 
   129     ///The generated picture is put to the file \c name.
   129     ///The generated picture is put to the file \c name.
   130     ///
   130     ///
   131     ///\c s determines the upper
   131     ///\c s determines the upper
   132     ///right corner of the bounding box. The lower left corner is (0,0).
   132     ///right corner of the bounding box. The lower left corner is (0,0).
   133     EpsDrawer(const std::string &name,xy<double> s);
   133     EpsDrawer(const std::string &name,dim2::Point<double> s);
   134     ///\e
   134     ///\e
   135 
   135 
   136     ///The generated picture is put to the file \c name.
   136     ///The generated picture is put to the file \c name.
   137     ///
   137     ///
   138     ///\c a and \c b
   138     ///\c a and \c b
   139     /// determine the lower left and the upper right corners of
   139     /// determine the lower left and the upper right corners of
   140     ///the bounding box, respectively.
   140     ///the bounding box, respectively.
   141     EpsDrawer(const std::string &name,xy<double> a, xy<double> b);
   141     EpsDrawer(const std::string &name,dim2::Point<double> a, dim2::Point<double> b);
   142 
   142 
   143 //     template<class T> EpsDrawer(std::ostream &os,BoundingBox<T> b) 
   143 //     template<class T> EpsDrawer(std::ostream &os,BoundingBox<T> b) 
   144 //     template<class T> EpsDrawer(std::ostream &os,BoundingBox<T> b);
   144 //     template<class T> EpsDrawer(std::ostream &os,BoundingBox<T> b);
   145     
   145     
   146     ~EpsDrawer();
   146     ~EpsDrawer();
   166     EpsDrawer &moveTo(double x1,double y1);
   166     EpsDrawer &moveTo(double x1,double y1);
   167     ///Draw a circle
   167     ///Draw a circle
   168     EpsDrawer &circle(double x,double y, double r);
   168     EpsDrawer &circle(double x,double y, double r);
   169     
   169     
   170     ///Draw a line
   170     ///Draw a line
   171     template<class T> EpsDrawer &line(xy<T> p1,xy<T> p2) 
   171     template<class T> EpsDrawer &line(dim2::Point<T> p1,dim2::Point<T> p2) 
   172     {
   172     {
   173       return line(p1.x,p1.y,p2.x,p2.y);
   173       return line(p1.x,p1.y,p2.x,p2.y);
   174     }
   174     }
   175     ///Draw a line from the current point
   175     ///Draw a line from the current point
   176     template<class T> EpsDrawer &lineTo(xy<T> p)
   176     template<class T> EpsDrawer &lineTo(dim2::Point<T> p)
   177     {
   177     {
   178       return lineTo(p.x,p.y);
   178       return lineTo(p.x,p.y);
   179     }
   179     }
   180     ///Move the current point
   180     ///Move the current point
   181     template<class T> EpsDrawer &moveTo(xy<T> p)
   181     template<class T> EpsDrawer &moveTo(dim2::Point<T> p)
   182     {
   182     {
   183       return moveTo(p.x,p.y);
   183       return moveTo(p.x,p.y);
   184     }
   184     }
   185     ///Draw a circle
   185     ///Draw a circle
   186     template<class T> EpsDrawer &circle(xy<T> p, double r)
   186     template<class T> EpsDrawer &circle(dim2::Point<T> p, double r)
   187     {
   187     {
   188       return circle(p.x,p.y,r);
   188       return circle(p.x,p.y,r);
   189     }
   189     }
   190     
   190     
   191     ///Set the font size
   191     ///Set the font size
   294     ///\param t The shape of the drawn object
   294     ///\param t The shape of the drawn object
   295     ///\param pos Position of the node
   295     ///\param pos Position of the node
   296     ///\param col Color of the node. The default color is white
   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
   297     ///\param brd Color of the node border. The default color is black
   298     template<class T>
   298     template<class T>
   299     EpsDrawer &node(NodeShapes t, xy<T> pos, double r,
   299     EpsDrawer &node(NodeShapes t, dim2::Point<T> pos, double r,
   300 		    Color col=WHITE, Color brd=BLACK)
   300 		    Color col=WHITE, Color brd=BLACK)
   301     {
   301     {
   302       return node(t,pos.x,pos.y,r,col,brd);
   302       return node(t,pos.x,pos.y,r,col,brd);
   303     }
   303     }
   304 
   304 
   305     ///Translate the coordinate system
   305     ///Translate the coordinate system
   306     EpsDrawer &translate(double x,double y);
   306     EpsDrawer &translate(double x,double y);
   307     ///Translate the coordinate system
   307     ///Translate the coordinate system
   308     template<class T> EpsDrawer &translate(xy<T> p)
   308     template<class T> EpsDrawer &translate(dim2::Point<T> p)
   309     {
   309     {
   310       return translate(p.x,p.y);
   310       return translate(p.x,p.y);
   311     }
   311     }
   312     ///Rotate the coordinate system
   312     ///Rotate the coordinate system
   313     EpsDrawer &rotate(double r);
   313     EpsDrawer &rotate(double r);
   314     ///Scale the coordinate system
   314     ///Scale the coordinate system
   315     EpsDrawer &scale(double sx, double sy);
   315     EpsDrawer &scale(double sx, double sy);
   316     ///Scale the coordinate system
   316     ///Scale the coordinate system
   317     EpsDrawer &scale(double s) { return scale(s,s); }
   317     EpsDrawer &scale(double s) { return scale(s,s); }
   318     ///Scale the coordinate system
   318     ///Scale the coordinate system
   319     template<class T> EpsDrawer &scale(xy<T> p)
   319     template<class T> EpsDrawer &scale(dim2::Point<T> p)
   320     {
   320     {
   321       return scale(p.x,p.y);
   321       return scale(p.x,p.y);
   322     }
   322     }
   323     
   323     
   324     ///\e
   324     ///\e
   334     EpsDrawer &operator<<(int i);
   334     EpsDrawer &operator<<(int i);
   335     ///Print a number at the current point
   335     ///Print a number at the current point
   336     EpsDrawer &operator<<(double d);
   336     EpsDrawer &operator<<(double d);
   337     ///Print a coordinate at the current point
   337     ///Print a coordinate at the current point
   338     template<class T>
   338     template<class T>
   339     EpsDrawer &operator<<(xy<T> p) 
   339     EpsDrawer &operator<<(dim2::Point<T> p) 
   340     {
   340     {
   341       out << "((" << p.x << ',' << p.y <<")) show\n";
   341       out << "((" << p.x << ',' << p.y <<")) show\n";
   342       return *this;
   342       return *this;
   343     }
   343     }
   344     
   344