DGtal 1.4.0
|
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<). The user has simply to declare a Board2D object and uses stream operators to display most digital objects. Furthermore, one can use this class to modify the current style for drawing. More...
#include <DGtal/io/boards/Board2D.h>
Public Types | |
typedef std::map< std::string, CountedPtr< DrawableWithBoard2D > > | StyleMapping |
typedef std::map< std::string, std::string > | ModeMapping |
typedef LibBoard::Shape | Shape |
Public Types inherited from LibBoard::Board | |
enum | CairoType { CairoPDF , CairoPNG , CairoPS , CairoEPS , CairoSVG } |
enum | PageSize { BoundingBox , A4 , Letter } |
enum | Unit { UPoint , UInche , UCentimeter , UMillimeter } |
Public Types inherited from LibBoard::Shape | |
enum | LineCap { ButtCap = 0 , RoundCap , SquareCap } |
enum | LineJoin { MiterJoin = 0 , RoundJoin , BevelJoin } |
enum | LineStyle { SolidStyle = 0 , DashStyle , DotStyle , DashDotStyle , DashDotDotStyle , DashDotDotDotStyle } |
Public Member Functions | |
~Board2D () | |
Board2D (const Color &aBackgroundColor=Color::None) | |
Board2D (const Board2D &other) | |
Board2D & | operator= (const Board2D &other) |
std::string | getMode (const std::string &objectName) const |
template<typename TDrawableWithBoard2D > | |
Board2D & | operator<< (const TDrawableWithBoard2D &object) |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Public Member Functions inherited from LibBoard::Board | |
Board (const DGtal::Color &backgroundColor=DGtal::Color::None) | |
Board (const Board &other) | |
~Board () | |
Board & | operator= (const Board &other) |
Board & | operator<< (const Shape &shape) |
Board & | operator<< (Unit unit) |
void | clear (const DGtal::Color &color=DGtal::Color::None) |
void | clear (unsigned char red, unsigned char green, unsigned char blue) |
Shape & | rotate (double angle, const Point ¢er) |
Shape & | rotate (double angle) |
Shape & | translate (double dx, double dy) |
Shape & | scale (double sx, double sy) |
Shape & | scale (double s) |
Board | rotated (double angle, const Point ¢er) |
Board | rotated (double angle) |
Board | translated (double dx, double dy) |
Board | scaled (double sx, double sy) |
Board | scaled (double s) |
void | setUnit (Unit unit) |
void | setUnit (double factor, Unit unit) |
void | drawDot (double x, double y, int depthValue=-1) |
void | drawLine (double x1, double y1, double x2, double y2, int depthValue=-1) |
void | drawQuadraticBezierCurve (double x1, double y1, double x2, double y2, double x3, double y3, int depthValue=-1) |
void | drawArrow (double x1, double y1, double x2, double y2, bool filled=true, int depthValue=-1) |
void | drawTriangle (double x1, double y1, double x2, double y2, double x3, double y3, int depthValue=-1) |
void | drawTriangle (const Point &p1, const Point &p2, const Point &p3, int depthValue=-1) |
void | drawArc (double x, double y, double radius, double angle1, double angle2, bool neg, int depthValue=-1) |
void | fillTriangle (double x1, double y1, double x2, double y2, double x3, double y3, int depthValue=-1) |
void | fillGouraudTriangle (const Point &p1, const DGtal::Color &color1, const Point &p2, const DGtal::Color &color2, const Point &p3, const DGtal::Color &color3, unsigned char divisions=3, int depthValue=-1) |
void | fillGouraudTriangle (const double x1, const double y1, const DGtal::Color &color1, const double x2, const double y2, const DGtal::Color &color2, const double x3, const double y3, const DGtal::Color &color3, unsigned char divisions=3, int depthValue=-1) |
void | fillGouraudTriangle (const Point &p1, const float brightness1, const Point &p2, const float brightness2, const Point &p3, const float brightness3, unsigned char divisions=3, int depthValue=-1) |
void | fillGouraudTriangle (const double x1, const double y1, const float brightness1, const double x2, const double y2, const float brightness2, const double x3, const double y3, const float brightness3, unsigned char divisions=3, int depthValue=-1) |
void | fillTriangle (const Point &p1, const Point &p2, const Point &p3, int depthValue=-1) |
void | drawRectangle (double x, double y, double width, double height, int depthValue=-1) |
void | drawImage (std::string filename, double x, double y, double width, double height, int depthValue=-1, double alpha=1.0) |
void | fillRectangle (double x, double y, double width, double height, int depthValue=-1) |
void | drawCircle (double x, double y, double radius, int depthValue=-1) |
void | fillCircle (double x, double y, double radius, int depthValue=-1) |
void | drawEllipse (double x, double y, double xRadius, double yRadius, int depthValue=-1) |
void | fillEllipse (double x, double y, double xRadius, double yRadius, int depthValue=-1) |
void | drawPolyline (const std::vector< Point > &points, int depthValue=-1) |
void | drawClosedPolyline (const std::vector< Point > &points, int depthValue=-1) |
void | fillPolyline (const std::vector< Point > &points, int depthValue=-1) |
void | drawText (double x, double y, const char *text, int depthValue=-1) |
void | drawText (double x, double y, const std::string &str, int depthValue=-1) |
Board & | setFont (const Fonts::Font font, double fontSize) |
Board & | setFontSize (double fontSize) |
Board & | setPenColorRGBi (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255) |
Board & | setPenColorRGBf (float red, float green, float blue, float alpha=1.0f) |
Board & | setPenColor (const DGtal::Color &color) |
Board & | setFillColorRGBi (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255) |
Board & | setFillColorRGBf (float red, float green, float blue, float alpha=1.0f) |
Board & | setFillColor (const DGtal::Color &color) |
Board & | setLineWidth (double width) |
Board & | setLineStyle (Shape::LineStyle style) |
Board & | setLineCap (Shape::LineCap cap) |
Board & | setLineJoin (Shape::LineJoin join) |
void | backgroundColor (const DGtal::Color &color) |
void | drawBoundingBox (int depthValue=-1) |
void | setClippingRectangle (double x, double y, double width, double height) |
void | setClippingPath (const std::vector< Point > &points) |
void | setClippingPath (const Path &path) |
void | addDuplicates (const Shape &shape, unsigned int times, double dx, double dy, double scale=1.0) |
void | addDuplicates (const Shape &shape, unsigned int times, double dx, double dy, double scaleX, double scaleY, double angle=0.0) |
void | save (const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const |
void | save (const char *filename, double pageWidth, double pageHeight, double margin=10.0) const |
void | saveEPS (const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const |
void | saveEPS (std::ostream &out, PageSize size=Board::BoundingBox, double margin=10.0) const |
void | saveEPS (const char *filename, double pageWidth, double pageHeight, double margin=10.0) const |
void | saveEPS (std::ostream &out, double pageWidth, double pageHeight, double margin=10.0) const |
void | saveFIG (const char *filename, PageSize size=Board::BoundingBox, double margin=10.0, bool includeFIGHeader=true) const |
void | saveFIG (std::ostream &out, PageSize size=Board::BoundingBox, double margin=10.0, bool includeFIGHeader=true) const |
void | saveFIG (const char *filename, double pageWidth, double pageHeight, double margin=10.0, bool includeFIGHeader=true) const |
void | saveFIG (std::ostream &out, double pageWidth, double pageHeight, double margin=10.0, bool includeFIGHeader=true) const |
void | saveSVG (const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const |
void | saveSVG (std::ostream &out, PageSize size=Board::BoundingBox, double margin=10.0) const |
void | saveSVG (const char *filename, double pageWidth, double pageHeight, double margin=10.0) const |
void | saveSVG (std::ostream &out, double pageWidth, double pageHeight, double margin=10.0, std::string filename="output.svg") const |
void | saveCairo (const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const |
void | saveCairo (const char *filename, CairoType type, double pageWidth, double pageHeight, double margin=10.0) const |
void | saveTikZ (const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const |
void | saveTikZ (std::ostream &out, PageSize size=Board::BoundingBox, double margin=10.0) const |
void | saveTikZ (const char *filename, double pageWidth, double pageHeight, double margin=10.0) const |
void | saveTikZ (std::ostream &out, double pageWidth, double pageHeight, double margin=10.0) const |
Public Member Functions inherited from LibBoard::ShapeList | |
ShapeList (int depth=-1) | |
ShapeList (const ShapeList &other) | |
~ShapeList () | |
const std::string & | name () const |
ShapeList & | clear () |
Point | center () const |
Shape & | rotate (double angle, const Point ¢er) |
ShapeList | rotated (double angle, const Point ¢er) |
Shape & | rotate (double angle) |
ShapeList | rotated (double angle) |
Shape & | translate (double dx, double dy) |
ShapeList | translated (double dx, double dy) |
Shape & | scale (double sx, double sy) |
Shape & | scale (double s) |
ShapeList | scaled (double sx, double sy) |
ShapeList | scaled (double s) |
void | scaleAll (double s) |
void | flushPostscript (std::ostream &stream, const TransformEPS &transform) const |
void | flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const |
void | flushSVG (std::ostream &stream, const TransformSVG &transform) const |
void | flushCairo (cairo_t *cr, const TransformCairo &transform) const |
void | flushTikZ (std::ostream &stream, const TransformTikZ &transform) const |
Rect | boundingBox () const |
virtual int | minDepth () const |
virtual int | maxDepth () const |
void | shiftDepth (int shift) |
Shape * | clone () const |
ShapeList & | operator= (const ShapeList &other) |
ShapeList & | operator<< (const Shape &shape) |
ShapeList & | operator+= (const Shape &shape) |
ShapeList & | insert (const Shape &shape, int depth) |
ShapeList & | dup (unsigned int copies=1) |
template<typename T > | |
T & | last (const unsigned int position=0) |
Shape & | last (const unsigned int position=0) |
Shape & | top () |
Public Member Functions inherited from LibBoard::Shape | |
Shape (DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join, int depth) | |
virtual | ~Shape () |
bool | filled () const |
Shape & | rotateDeg (double angle, const Point ¢er) |
Shape & | rotateDeg (double angle) |
Rect | bbox () |
Shape & | operator-- () |
Shape & | operator++ () |
int | depth () const |
virtual void | depth (int) |
const DGtal::Color & | penColor () const |
const DGtal::Color & | fillColor () const |
Data Fields | |
StyleMapping | myStyles |
ModeMapping | myModes |
Additional Inherited Members | |
Static Public Attributes inherited from LibBoard::Board | |
static const double | Degree = 3.14159265358979323846 / 180.0 |
Protected Member Functions inherited from LibBoard::ShapeList | |
void | addShape (const Shape &shape, double scaleFactor) |
void | free () |
Protected Member Functions inherited from LibBoard::Shape | |
std::string | svgProperties (const TransformSVG &transform) const |
std::string | postscriptProperties () const |
void | setCairoDashStyle (cairo_t *cr, LineStyle type) const |
std::string | tikzProperties (const TransformTikZ &transform) const |
Protected Attributes inherited from LibBoard::Board | |
State | _state |
DGtal::Color | _backgroundColor |
Path | _clippingPath |
Protected Attributes inherited from LibBoard::ShapeList | |
std::vector< Shape * > | _shapes |
int | _nextDepth |
Protected Attributes inherited from LibBoard::Shape | |
int | _depth |
DGtal::Color | _penColor |
DGtal::Color | _fillColor |
double | _lineWidth |
LineStyle | _lineStyle |
LineCap | _lineCap |
LineJoin | _lineJoin |
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<). The user has simply to declare a Board2D object and uses stream operators to display most digital objects. Furthermore, one can use this class to modify the current style for drawing.
Description of class 'Board2D'
typedef std::map< std::string, std::string > DGtal::Board2D::ModeMapping |
typedef LibBoard::Shape DGtal::Board2D::Shape |
typedef std::map< std::string,CountedPtr<DrawableWithBoard2D> > DGtal::Board2D::StyleMapping |
DGtal::Board2D::~Board2D | ( | ) |
DGtal::Board2D::Board2D | ( | const Color & | aBackgroundColor = Color::None | ) |
Constructs a new board and sets the background color, if any.
aBackgroundColor | A color for the drawing's background. |
Definition at line 54 of file Board2D.cpp.
References LibBoard::Board::setUnit(), and LibBoard::Board::UCentimeter.
DGtal::Board2D::Board2D | ( | const Board2D & | other | ) |
Copy constructor.
other | The object to be copied. |
Definition at line 66 of file Board2D.cpp.
std::string DGtal::Board2D::getMode | ( | const std::string & | objectName | ) | const |
objectName | the name of the object (generally obtained with a 'object.className()'). |
bool DGtal::Board2D::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Definition at line 107 of file Board2D.cpp.
Board2D & DGtal::Board2D::operator<< | ( | const TDrawableWithBoard2D & | object | ) |
Draws the drawable [object] in this board. It should satisfy the concept CDrawableWithBoard2D, which requires for instance a method setStyle( Board2D & ).
object | any drawable object. |
DGtal::Board2D & DGtal::Board2D::operator= | ( | const Board2D & | other | ) |
Assignment.
other | the object to copy. |
Definition at line 78 of file Board2D.cpp.
References myStyles, and LibBoard::Board::operator=().
void DGtal::Board2D::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Definition at line 97 of file Board2D.cpp.
ModeMapping DGtal::Board2D::myModes |
May associate a current mode for a given class. myModes[ "HyperRectDomain" ] = "Paving".
Next display of a HyperRectDomain object will used the mode "Paving". Modes may only be used in objects implementing the concept CDrawableWithBoard2D.
StyleMapping DGtal::Board2D::myStyles |
For instance, may associate a new style object T1 to the class "HyperRectDomain": myStyles[ "HyperRectDomain" ] = T1.
One can also store a new style T2 for a specific mode used for drawing a class: myStyles[ "HyperRectDomain/Paving" ] = T2.
Modes may only be used in objects implementing the concept CDrawableWithBoard2D.
Definition at line 165 of file Board2D.h.
Referenced by operator=().