Rel.07 NEWS - 3. round
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
26 #include<lemon/color.h>
27 #include<lemon/dim2.h>
31 ///\brief Simple tool to create \c .eps files
33 ///\author Alpar Juttner
38 ///\brief A simple tool to create \c .eps files
40 ///A simple tool to create \c .eps files
41 ///\author Alpar Juttner
45 void init(int x1,int y1,int x2,int y2);
46 void init(double x1,double y1,double x2,double y2);
56 ///\image html nodeshape_0.png
57 ///\image latex nodeshape_0.eps "CIRCLE shape (0)" width=2cm
60 ///\image html nodeshape_1.png
61 ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm
65 ///\image html nodeshape_2.png
66 ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm
70 ///\image html nodeshape_3.png
71 ///\image latex nodeshape_2.eps "MALE shape (4)" width=2cm
73 ///\warning Not implemented
76 ///\image html nodeshape_4.png
77 ///\image latex nodeshape_2.eps "FEMALE shape (4)" width=2cm
79 ///\warning Not implemented
84 ///The generated file is put to \c os.
86 /// \c x and \c y determine the upper
87 ///right corner of the bounding box. The lower left corner is (0,0).
88 EpsDrawer(std::ostream &os,int x,int y);
91 ///The generated file is put to \c os.
93 ///(x1,y1) and (x2,y2)
94 /// determine the lower left and the upper right corners of
95 ///the bounding box, respectively.
96 EpsDrawer(std::ostream &os,int x1,int y1,int x2,int y2);
99 ///The generated file is put to \c os.
101 ///\c s determines the upper
102 ///right corner of the bounding box. The lower left corner is (0,0).
103 EpsDrawer(std::ostream &os,dim2::Point<double> s);
106 ///The generated file is put to \c os.
109 /// determine the lower left and the upper right corners of
110 ///the bounding box, respectively.
111 EpsDrawer(std::ostream &os,dim2::Point<double> a, dim2::Point<double> b);
114 ///The generated picture is put to the file \c name.
116 ///\c x and \c y determine the upper
117 ///right corner of the bounding box. The lower left corner is (0,0).
118 EpsDrawer(const std::string &name,int x,int y);
121 ///The generated picture is put to the file \c name.
123 ///(x1,y1) and (x2,y2)
124 /// determine the lower left and the upper right corners of
125 ///the bounding box, respectively.
126 EpsDrawer(const std::string &name,int x1,int y1,int x2,int y2);
129 ///The generated picture is put to the file \c name.
131 ///\c s determines the upper
132 ///right corner of the bounding box. The lower left corner is (0,0).
133 EpsDrawer(const std::string &name,dim2::Point<double> s);
136 ///The generated picture is put to the file \c name.
139 /// determine the lower left and the upper right corners of
140 ///the bounding box, respectively.
141 EpsDrawer(const std::string &name,dim2::Point<double> a, dim2::Point<double> b);
143 // template<class T> EpsDrawer(std::ostream &os,BoundingBox<T> b)
144 // template<class T> EpsDrawer(std::ostream &os,BoundingBox<T> b);
148 ///Save the current graphic state.
150 ///This function saves the current coordinate system, and the parameters
151 ///set by \ref color(), \ref lineWidth() etc.
152 ///The can be \ref restore "restore()"d later.
154 ///The \ref save() - \ref restore() pairs can be nested.
157 ///Restore the saves graphic state.
159 EpsDrawer &restore();
162 EpsDrawer &line(double x1,double y1,double x2,double y2);
163 ///Draw a line from the current point
164 EpsDrawer &lineTo(double x1,double y1);
165 ///Move the current point
166 EpsDrawer &moveTo(double x1,double y1);
168 EpsDrawer &circle(double x,double y, double r);
171 template<class T> EpsDrawer &line(dim2::Point<T> p1,dim2::Point<T> p2)
173 return line(p1.x,p1.y,p2.x,p2.y);
175 ///Draw a line from the current point
176 template<class T> EpsDrawer &lineTo(dim2::Point<T> p)
178 return lineTo(p.x,p.y);
180 ///Move the current point
181 template<class T> EpsDrawer &moveTo(dim2::Point<T> p)
183 return moveTo(p.x,p.y);
186 template<class T> EpsDrawer &circle(dim2::Point<T> p, double r)
188 return circle(p.x,p.y,r);
192 EpsDrawer &fontSize(double si);
194 EpsDrawer &font(std::string );
195 ///Sets whether text output is centerized of not
197 ///Sets whether text output is centerized of not.
199 ///\warning \ref save() doesn't save this setting.
201 EpsDrawer ¢erMode(bool m);
202 ///Turn to collect mode.
204 ///If you call this function, then the drawing operations like \ref line(),
205 ///\ref lineTo(), \ref moveTo() will not take place immediately, but istead
207 ///are collected. These operations form a \e path.
208 ///Then you can \ref stroke(), \ref fill(), \ref eoFill(), \ref clip() or
210 ///When drawing, you can also use \ref closePath() to - surprise - close the
213 ///This example draws a red filled diamond.
215 /// EpsDraw ed("diamond.eps",-1,-1,1,1);
216 /// ed.color(1,0,0,).collect().line(0,-1,1,0).lineTo(0,1)
217 /// .lineTo(-1,0).closePath().fill();
219 EpsDrawer &collect();
220 ///Close the current drawing path
221 EpsDrawer &closePath();
222 ///Stroke (draw) a path
224 ///Stroke (draw) a path.
234 ///Even-odd fill a path
236 ///Even-odd fill a path.
240 ///Set a clipping area.
242 ///This function sets a clipping area. After that, the drawing operations
243 ///will affect only this area.
247 ///Set a clipping area using even-odd rule.
249 ///This function sets a clipping area using even-odd rule.
250 ///After that, the drawing operations
251 ///will affect only this area.
256 ///Set the line width.
257 EpsDrawer &lineWidth(double w);
258 ///Set the style of the line ends
260 ///\param i It can be 0, 1 or 2
262 EpsDrawer &lineCap(int i);
263 ///Set the style of the line joins
265 ///\param i It can be 0, 1 or 2
267 EpsDrawer &lineJoin(int i);
268 ///Set the cut length of near parallel joining lines.
269 EpsDrawer &miterLimit(double w);
271 ///Set the drawing color
272 EpsDrawer &color(double r, double g, double b);
273 ///Set the drawing color
274 EpsDrawer &color(Color c)
276 return color(c.red(),c.green(),c.blue());
281 ///Draw a node shape.
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 r The size (radius) of the node
287 ///\param col Color of the node. The default color is white
288 ///\param brd Color of the node border. The default color is black
289 EpsDrawer &node(NodeShapes t, double x, double y, double r,
290 Color col=WHITE, Color brd=BLACK);
293 ///Draw a node shape.
295 ///\param t The shape of the drawn object
296 ///\param pos Position of the node
297 ///\param r The size (radius) of the node
298 ///\param col Color of the node. The default color is white
299 ///\param brd Color of the node border. The default color is black
301 EpsDrawer &node(NodeShapes t, dim2::Point<T> pos, double r,
302 Color col=WHITE, Color brd=BLACK)
304 return node(t,pos.x,pos.y,r,col,brd);
307 ///Translate the coordinate system
308 EpsDrawer &translate(double x,double y);
309 ///Translate the coordinate system
310 template<class T> EpsDrawer &translate(dim2::Point<T> p)
312 return translate(p.x,p.y);
314 ///Rotate the coordinate system
315 EpsDrawer &rotate(double r);
316 ///Scale the coordinate system
317 EpsDrawer &scale(double sx, double sy);
318 ///Scale the coordinate system
319 EpsDrawer &scale(double s) { return scale(s,s); }
320 ///Scale the coordinate system
321 template<class T> EpsDrawer &scale(dim2::Point<T> p)
323 return scale(p.x,p.y);
331 ///Print a text at the current point
332 EpsDrawer &operator<<(const std::string &s);
333 ///Print a text at the current point
334 EpsDrawer &operator<<(const char *s);
335 ///Print a number at the current point
336 EpsDrawer &operator<<(int i);
337 ///Print a number at the current point
338 EpsDrawer &operator<<(double d);
339 ///Print a coordinate at the current point
341 EpsDrawer &operator<<(dim2::Point<T> p)
343 out << "((" << p.x << ',' << p.y <<")) show\n";