Imagine++
Draw.h
1// ===========================================================================
2// Imagine++ Libraries
3// Copyright (C) Imagine
4// For detailed information: http://imagine.enpc.fr/software
5// ===========================================================================
6
7#ifndef IMAGINE_GRAPHICS_DRAW2D_H
8#define IMAGINE_GRAPHICS_DRAW2D_H
9
10#include "Types.h"
11
12namespace Imagine {
13 class Mesh;
16
17 // Drawing commands
26 void drawPoint(int x, int y, const Color& col, bool xorMode = false);
35 inline void drawPoint(const IntPoint2& p, const Color& col, bool xorMode = false)
36 { drawPoint(p.x(), p.y(), col, xorMode); }
47 void drawCircle(int xc, int yc, int r, const Color& col, int penWidth = 1, bool xorMode = false);
58 inline void drawCircle(const IntPoint2& c, int r, const Color &col, int penWidth = 1, bool xorMode = false)
59 { drawCircle(c.x(), c.y(), r, col, penWidth, xorMode); }
70 void drawEllipse(int x, int y, int w, int h, const Color &col, int penWidth = 1, bool xorMode = false);
81 inline void drawEllipse(const IntPoint2& p, int w, int h, const Color &col, int penWidth = 1, bool xorMode = false)
82 { drawEllipse(p.x(), p.y(), w, h, col, penWidth, xorMode); }
93 void drawLine(int x1, int y1, int x2, int y2, const Color &col, int penWidth = 1, bool xorMode = false);
104 inline void drawLine(const IntPoint2& p1, const IntPoint2& p2, const Color &col, int penWidth = 1, bool xorMode = false)
105 { drawLine(p1.x(), p1.y(), p2.x(), p2.y(), col, penWidth, xorMode); }
116 void drawRect(int x, int y, int w, int h, const Color &col, int penWidth = 1, bool xorMode = false);
127 inline void drawRect(const IntPoint2& p, int w, int h, const Color &col, int penWidth = 1, bool xorMode = false)
128 { drawRect(p.x(), p.y(), w, h, col, penWidth, xorMode); }
129
141 void drawPoly(const int x[], const int y[], int n, const Color& col, int width = 1, bool xorMode = false);
153 void drawPoly(const IntPoint2* p, int n, const Color& col,int width = 1, bool xorMode = false);
165 inline void drawPoly(const int xy[], int n, const Color &col, int width = 1, bool xorMode = false)
166 { drawPoly((const IntPoint2*)xy,n,col,width, xorMode); }
180 void drawString(int x, int y, const std::string &s, const AlphaColor &col, int fontSize = 12,
181 double alpha = 0, bool italic = false, bool bold = false, bool underlined = false, bool xorMode = false);
195 inline void drawString(const IntPoint2& p, const std::string &s, const AlphaColor& col, int fontSize = 12,
196 double alpha = 0, bool italic = false, bool bold = false, bool underlined = false, bool xorMode = false)
197 { drawString(p.x(), p.y(), s, col, fontSize, alpha, italic, bold, underlined, xorMode); }
210 void drawArrow(int x1, int y1, int x2, int y2, const AlphaColor &col, int arrowWidth = 8, int arrowHeight = 5,
211 int style = 0, int width = 1, bool xorMode = false);
224 inline void drawArrow(const IntPoint2& p1, const IntPoint2& p2, const AlphaColor& col, int arrowWidth = 8, int arrowHeight = 5,
225 int style = 0, int width = 1, bool xorMode = false)
226 { drawArrow(p1.x(), p1.y(), p2.x(), p2.y(), col, arrowWidth, arrowHeight,
227 style, width, xorMode); }
240 inline void drawArrow(int x1, int y1, int x2, int y2, const AlphaColor& col, double ta, double tl, int style = 0, int width = 1, bool xorMode = false)
241 { drawArrow(x1, y1, x2, y2, col,
242 int(tl*cos(ta*3.14/180)), int(2*tl*sin(ta*3.14/180)),
243 style, width, xorMode); }
256 inline void drawArrow(const IntPoint2& p1, const IntPoint2& p2, const AlphaColor& col, double ta, double tl, int style = 0, int width = 1, bool xorMode = false)
257 { drawArrow(p1.x(), p1.y(), p2.x(), p2.y(), col, ta, tl, style, width, xorMode); }
267 void fillEllipse(int x, int y, int w, int h, const AlphaColor &col, bool xorMode = false);
277 inline void fillEllipse(const IntPoint2& p, int w, int h, const AlphaColor& col, bool xorMode = false)
278 { fillEllipse(p.x(), p.y(), w, h, col, xorMode); }
288 void fillRect(int x, int y, int w, int h, const AlphaColor &col, bool xorMode = false);
298 inline void fillRect(const IntPoint2& p, int w, int h, const AlphaColor& col, bool xorMode = false)
299 { fillRect(p.x(), p.y(), w, h, col, xorMode); }
309 void fillCircle(int xc, int yc, int r, const AlphaColor &col, bool xorMode = false);
319 inline void fillCircle(const IntPoint2& c, int r, const AlphaColor& col, bool xorMode = false)
320 { fillCircle(c.x(), c.y(), r, col, xorMode); }
321
332 void fillPoly(const int x[], const int y[], int n, const AlphaColor &col, bool xorMode = false);
343 void fillPoly(const IntPoint2* p, int n, const AlphaColor &col, bool xorMode = false);
354 void fillPoly(const int xy[], int n, const AlphaColor &col, bool xorMode = false);
355
356// 3D Functions
361 void setCamera(const DoublePoint3& pos,
362 const DoublePoint3& dir,
363 const DoubleVector3& up);
366 void setLight(bool b);
373 void setLight(const FloatVector3& dir, float ambient=0.2f);
375 void setLight(float dirx, float diry, float dirz, float ambient=0.2f);
376
377 // No refresh functions
378#ifndef DOXYGEN_SHOULD_SKIP_THIS
379 int noRefreshStack(int i); // Private : do not use.
380#endif
381
405 inline void noRefreshPush()
406 { if(noRefreshStack(1) == 1) noRefreshBegin(); }
413 inline void noRefreshPop()
414 { if(noRefreshStack(-1) == 0) noRefreshEnd(); }
415
417} /* namespace Imagine */
418
419#endif // IMAGINE_GRAPHICS_DRAW2D_H
Vector of fixed size.
Definition: FVector.h:17
const T & y() const
Read alias.
Definition: FVector.h:118
const T & x() const
Read alias.
Definition: FVector.h:104
RED GREEN BLUE Alpha color.
Definition: Color.h:138
RED GREEN BLUE color.
Definition: Color.h:26
void setLight(bool b)
Set/unset lighting in 3D rendering.
void drawPoint(int x, int y, const Color &col, bool xorMode=false)
Point.
void drawPoly(const int x[], const int y[], int n, const Color &col, int width=1, bool xorMode=false)
Draw a polygon.
void drawEllipse(int x, int y, int w, int h, const Color &col, int penWidth=1, bool xorMode=false)
Ellipse.
void fillCircle(int xc, int yc, int r, const AlphaColor &col, bool xorMode=false)
Filled Circle.
void drawString(int x, int y, const std::string &s, const AlphaColor &col, int fontSize=12, double alpha=0, bool italic=false, bool bold=false, bool underlined=false, bool xorMode=false)
String.
void drawCircle(int xc, int yc, int r, const Color &col, int penWidth=1, bool xorMode=false)
Circle.
void noRefreshPop()
Norefresh pop.
Definition: Draw.h:413
void noRefreshEnd()
Norefresh end.
void drawRect(int x, int y, int w, int h, const Color &col, int penWidth=1, bool xorMode=false)
Rectangle.
void fillRect(int x, int y, int w, int h, const AlphaColor &col, bool xorMode=false)
Filled rectangle.
void fillEllipse(int x, int y, int w, int h, const AlphaColor &col, bool xorMode=false)
Filled Ellipse.
void noRefreshPush()
Norefresh push.
Definition: Draw.h:405
void fillPoly(const int x[], const int y[], int n, const AlphaColor &col, bool xorMode=false)
Filled Polygon.
void setCamera(const DoublePoint3 &pos, const DoublePoint3 &dir, const DoubleVector3 &up)
Sets the camera pose.
void noRefreshBegin()
Norefresh begin.
void drawArrow(int x1, int y1, int x2, int y2, const AlphaColor &col, int arrowWidth=8, int arrowHeight=5, int style=0, int width=1, bool xorMode=false)
Arrow.
void drawLine(int x1, int y1, int x2, int y2, const Color &col, int penWidth=1, bool xorMode=false)
Line.
Imagine++ namespace.