DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields
DGtal::Board2D Class Reference

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>

Inheritance diagram for DGtal::Board2D:
LibBoard::Board LibBoard::ShapeList LibBoard::Shape

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)
 
Board2Doperator= (const Board2D &other)
 
std::string getMode (const std::string &objectName) const
 
template<typename TDrawableWithBoard2D >
Board2Doperator<< (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 ()
 
Boardoperator= (const Board &other)
 
Boardoperator<< (const Shape &shape)
 
Boardoperator<< (Unit unit)
 
void clear (const DGtal::Color &color=DGtal::Color::None)
 
void clear (unsigned char red, unsigned char green, unsigned char blue)
 
Shaperotate (double angle, const Point &center)
 
Shaperotate (double angle)
 
Shapetranslate (double dx, double dy)
 
Shapescale (double sx, double sy)
 
Shapescale (double s)
 
Board rotated (double angle, const Point &center)
 
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)
 
BoardsetFont (const Fonts::Font font, double fontSize)
 
BoardsetFontSize (double fontSize)
 
BoardsetPenColorRGBi (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
 
BoardsetPenColorRGBf (float red, float green, float blue, float alpha=1.0f)
 
BoardsetPenColor (const DGtal::Color &color)
 
BoardsetFillColorRGBi (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
 
BoardsetFillColorRGBf (float red, float green, float blue, float alpha=1.0f)
 
BoardsetFillColor (const DGtal::Color &color)
 
BoardsetLineWidth (double width)
 
BoardsetLineStyle (Shape::LineStyle style)
 
BoardsetLineCap (Shape::LineCap cap)
 
BoardsetLineJoin (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
 
ShapeListclear ()
 
Point center () const
 
Shaperotate (double angle, const Point &center)
 
ShapeList rotated (double angle, const Point &center)
 
Shaperotate (double angle)
 
ShapeList rotated (double angle)
 
Shapetranslate (double dx, double dy)
 
ShapeList translated (double dx, double dy)
 
Shapescale (double sx, double sy)
 
Shapescale (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)
 
Shapeclone () const
 
ShapeListoperator= (const ShapeList &other)
 
ShapeListoperator<< (const Shape &shape)
 
ShapeListoperator+= (const Shape &shape)
 
ShapeListinsert (const Shape &shape, int depth)
 
ShapeListdup (unsigned int copies=1)
 
template<typename T >
T & last (const unsigned int position=0)
 
Shapelast (const unsigned int position=0)
 
Shapetop ()
 
- 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 ()
 
virtual const std::string & name () const
 
virtual Shapeclone () const =0
 
bool filled () const
 
virtual Point center () const =0
 
virtual Shaperotate (double angle, const Point &center)=0
 
virtual Shaperotate (double angle)=0
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
virtual Shapetranslate (double dx, double dy)=0
 
virtual Shapescale (double sx, double sy)=0
 
virtual Shapescale (double s)=0
 
virtual Rect boundingBox () const =0
 
Rect bbox ()
 
Shapeoperator-- ()
 
Shapeoperator++ ()
 
virtual void scaleAll (double s)=0
 
virtual void flushPostscript (std::ostream &stream, const TransformEPS &transform) const =0
 
virtual void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const =0
 
virtual void flushSVG (std::ostream &stream, const TransformSVG &transform) const =0
 
virtual void flushCairo (cairo_t *cr, const TransformCairo &transform) const =0
 
virtual void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const =0
 
int depth () const
 
virtual void depth (int)
 
virtual void shiftDepth (int shift)
 
const DGtal::ColorpenColor () const
 
const DGtal::ColorfillColor () 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
 

Detailed Description

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'

Examples
arithmetic/lower-integer-convex-hull.cpp, dec/exampleDiscreteExteriorCalculusChladni.cpp, dec/exampleDiscreteExteriorCalculusSolve.cpp, dec/exampleDiscreteExteriorCalculusUsage.cpp, dec/examplePropagation.cpp, doc-examples/demo-kernel-1.cpp, doc-examples/kernelDomain.cpp, geometry/curves/convex-and-concave-parts.cpp, geometry/curves/exampleAlphaThickSegment.cpp, geometry/curves/exampleAlphaThickSegmentNoisy.cpp, geometry/curves/exampleAlphaThickSegmentTgtCover.cpp, geometry/curves/exampleArithmeticalDSL.cpp, geometry/curves/exampleArithmeticalDSS.cpp, geometry/curves/exampleDigitalConvexity.cpp, geometry/curves/exampleFrechetShortcut.cpp, geometry/curves/exampleGridCurve2d.cpp, geometry/curves/exampleRationalConvexity.cpp, geometry/curves/greedy-dss-decomposition.cpp, geometry/curves/greedyAlphaThickDecomposition.cpp, geometry/surfaces/dvcm-2d-curvature.cpp, geometry/tools/exampleAlphaShape.cpp, geometry/tools/exampleConvexHull2D.cpp, geometry/tools/examplePreimage.cpp, geometry/volumes/distance/distancetransform2D.cpp, geometry/volumes/distance/exampleFMM2D.cpp, geometry/volumes/distance/toricdomainvolumetric.cpp, geometry/volumes/distance/voronoimap2D.cpp, geometry/volumes/dvcm-2d.cpp, geometry/volumes/fullConvexityCollapsiblePoints2D.cpp, geometry/volumes/fullConvexityLUT2D.cpp, graph/graphTraversal.cpp, images/exampleConstImageAdapter.cpp, images/exampleTiledImage.cpp, io/boards/dgtalBoard2D-1-points.cpp, io/boards/dgtalBoard2D-2-sets.cpp, io/boards/dgtalBoard2D-3-custom-classes.cpp, io/boards/dgtalBoard2D-3-custom-points.cpp, io/boards/dgtalBoard2D-4-colormaps.cpp, io/boards/exampleBezierCurve.cpp, io/boards/logoDGtal.cpp, shapes/exampleEuclideanShapesDecorator.cpp, topology/ctopo-1.cpp, topology/ctopo-2.cpp, topology/ctopo-fillContours.cpp, topology/cubical-complex-illustrations.cpp, topology/digitalSetToCubicalComplexes2D.cpp, topology/generateSimplicityTables2D.cpp, topology/khalimskySpaceScanner.cpp, and tutorial-examples/freemanChainFromImage.cpp.

Definition at line 70 of file Board2D.h.

Member Typedef Documentation

◆ ModeMapping

typedef std::map< std::string, std::string > DGtal::Board2D::ModeMapping

The associated map type for storing possible modes used for displaying for digital objects.

Definition at line 84 of file Board2D.h.

◆ Shape

Definition at line 86 of file Board2D.h.

◆ StyleMapping

The associated map type for storing the default styles of digital objects.

Definition at line 78 of file Board2D.h.

Constructor & Destructor Documentation

◆ ~Board2D()

DGtal::Board2D::~Board2D ( )

Destructor.

Definition at line 45 of file Board2D.cpp.

46{
47}

◆ Board2D() [1/2]

DGtal::Board2D::Board2D ( const Color aBackgroundColor = Color::None)

Constructs a new board and sets the background color, if any.

Parameters
aBackgroundColorA color for the drawing's background.

Definition at line 54 of file Board2D.cpp.

55 : LibBoard::Board( aBackgroundColor ),
56 myStyles()
57{
59}
StyleMapping myStyles
Definition: Board2D.h:165
Class for EPS, FIG or SVG drawings.
Definition: Board.h:35
void setUnit(Unit unit)
Definition: Board.cpp:240

References LibBoard::Board::setUnit(), and LibBoard::Board::UCentimeter.

◆ Board2D() [2/2]

DGtal::Board2D::Board2D ( const Board2D other)

Copy constructor.

Parameters
otherThe object to be copied.

Definition at line 66 of file Board2D.cpp.

67 : LibBoard::Board( other ),
68 myStyles( other.myStyles )
69{
70}

Member Function Documentation

◆ getMode()

std::string DGtal::Board2D::getMode ( const std::string &  objectName) const
Parameters
objectNamethe name of the object (generally obtained with a 'object.className()').
Returns
the current mode for the given object name or "" if no specific mode has been set.

◆ isValid()

bool DGtal::Board2D::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 107 of file Board2D.cpp.

108{
109 return true;
110}

◆ operator<<()

template<typename TDrawableWithBoard2D >
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 & ).

Parameters
objectany drawable object.
Returns
a reference on 'this'.

◆ operator=()

DGtal::Board2D & DGtal::Board2D::operator= ( const Board2D other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

Definition at line 78 of file Board2D.cpp.

79{
80 if ( this != &other )
81 {
83 myStyles = other.myStyles;
84 }
85 return *this;
86}
Board & operator=(const Board &other)
Definition: Board.cpp:117

References myStyles, and LibBoard::Board::operator=().

◆ selfDisplay()

void DGtal::Board2D::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Definition at line 97 of file Board2D.cpp.

98{
99 out << "[Board2D]";
100}

Field Documentation

◆ myModes

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.

Definition at line 175 of file Board2D.h.

◆ myStyles

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=().


The documentation for this class was generated from the following files: