DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Data Fields
DGtal::Board2D Class Reference

#include <Board2D.h>

Inheritance diagram for DGtal::Board2D:
Inheritance graph
[legend]
Collaboration diagram for DGtal::Board2D:
Collaboration graph
[legend]

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 }
enum  CairoType {
  CairoPDF, CairoPNG, CairoPS, CairoEPS,
  CairoSVG
}
enum  PageSize { BoundingBox, A4, Letter }
enum  Unit { UPoint, UInche, UCentimeter, UMillimeter }
- Public Types inherited from LibBoard::ShapeList
enum  LineCap
enum  LineJoin
enum  LineStyle
- Public Types inherited from LibBoard::Shape

Public Member Functions

 ~Board2D ()
 Board2D (const Color &backgroundColor=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 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, string filename="output.svg") 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
 ShapeList (int depth=-1)
 ShapeList (const ShapeList &other)
 ~ShapeList ()
const std::string & name () const
ShapeListclear ()
Point center () const
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 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)
ShapeListinsert (const Shape &shape, int depth)
ShapeListdup (unsigned int copies=1)
T & last (const unsigned int position=0)
Shapelast (const unsigned int position=0)
Shapetop ()
 Shape (DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join, int depth)
virtual ~Shape ()
bool filled () const
ShaperotateDeg (double angle, const Point &center)
ShaperotateDeg (double angle)
Rect bbox ()
Shapeoperator-- ()
Shapeoperator++ ()
int depth () const
virtual void depth (int)
const DGtal::ColorpenColor () const
const DGtal::ColorfillColor () const
 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 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, string filename="output.svg") 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

Data Fields

DomainDrawMode myDomainDrawMode
bool myDrawObjectAdjacencies
StyleMapping myStyles
ModeMapping myModes
- Data Fields inherited from LibBoard::Board
 CairoPDF
 CairoPNG
 CairoPS
 CairoEPS
 CairoSVG
 BoundingBox
 A4
 Letter
 UPoint
 UInche
 UCentimeter
 UMillimeter
- Data Fields inherited from LibBoard::ShapeList
 ButtCap
 RoundCap
 SquareCap
 MiterJoin
 RoundJoin
 BevelJoin
 SolidStyle
 DashStyle
 DotStyle
 DashDotStyle
 DashDotDotStyle
 DashDotDotDotStyle
- Data Fields inherited from LibBoard::Shape

Additional Inherited Members

- Static Public Attributes inherited from LibBoard::Board
static const double Degree = 3.14159265358979323846 / 180.0
- Protected Member Functions inherited from LibBoard::Board
void addShape (const Shape &shape, double scaleFactor)
void free ()
std::string svgProperties (const TransformSVG &transform) const
std::string postscriptProperties () const
std::string tikzProperties (const TransformTikZ &transform) const
- Protected Attributes inherited from LibBoard::Board
State _state
DGtal::Color _backgroundColor
Path _clippingPath
std::vector< Shape * > _shapes
int _nextDepth
int _depth
DGtal::Color _penColor
DGtal::Color _fillColor
double _lineWidth
LineStyle _lineStyle
LineCap _lineCap
LineJoin _lineJoin
- Protected Attributes inherited from LibBoard::ShapeList
- Protected Attributes inherited from LibBoard::Shape

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, 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, logoDGtal.cpp, topology/ctopo-1.cpp, topology/ctopo-2.cpp, and topology/khalimskySpaceScanner.cpp.

Definition at line 70 of file Board2D.h.


Member Typedef Documentation

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.

Definition at line 86 of file Board2D.h.

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

Definition at line 78 of file Board2D.h.


Constructor & Destructor Documentation

DGtal::Board2D::~Board2D ( )

Destructor.

Definition at line 45 of file Board2D.cpp.

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

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

Parameters:
backgroundColorA color for the drawing's background.

Definition at line 54 of file Board2D.cpp.

References DGtal::false, DGtal::GRID, LibBoard::Board::setUnit(), and LibBoard::Board::UCentimeter.

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

Copy constructor.

Parameters:
otherThe object to be copied.

Definition at line 68 of file Board2D.cpp.


Member Function Documentation

std::string DGtal::Board2D::getMode ( const std::string &  objectName) const
inline
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.
the current mode for the given object name or "" if no specific mode has been set.

Definition at line 50 of file Board2D.ih.

References myModes.

Referenced by DGtal::Display2DFactory::draw(), and DGtal::Display2DFactory::drawAsDigitalPoints().

{
ModeMapping::const_iterator itm = myModes.find( objectName );
return itm == myModes.end() ? "" : itm->second;
}
bool DGtal::Board2D::isValid ( ) const

Checks the validity/consistency of the object.

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

Definition at line 113 of file Board2D.cpp.

{
return true;
}
template<typename TDrawableWithBoard2D >
DGtal::Board2D & DGtal::Board2D::operator<< ( const TDrawableWithBoard2D &  object)
inline

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'.

Draws the drawable [object] in this board. It should satisfy the concept CDrawableWithBoard2D, which requires for instance a method setStyle( LibBoard::Board ).

Parameters:
domainany domain.
Returns:
a reference on 'this'.

Definition at line 67 of file Board2D.ih.

References DGtal::Style2DFactory::draw(), DGtal::Display2DFactory::draw(), DGtal::CountedPtr< T >::get(), DGtal::Trace::info(), and DGtal::trace.

{
CountedPtr<DrawableWithBoard2D> style( defaultStyle(object) );
#ifdef DEBUG_VERBOSE
trace.info() << "[operator<<] " << object.className();
#endif
// Apply default style
if ( style.get() )
{
#ifdef DEBUG_VERBOSE
trace.info() << " [default style]";
#endif
DGtal::Style2DFactory::draw(*this, style.get());
}
// Apply Customized style
StyleMapping::const_iterator it = myStyles.find( object.className() );
if ( it != myStyles.end() )
if ( it->second.get() != 0 )
{
#ifdef DEBUG_VERBOSE
trace.info() << " [specific style]";
#endif
DGtal::Style2DFactory::draw(*this, it->second.get());
}
// Check for specific mode.
ModeMapping::const_iterator itm = myModes.find( object.className() );
if ( itm != myModes.end() )
{
#ifdef DEBUG_VERBOSE
trace.info() << " [mode]";
#endif
// Apply default style for specific mode.
( defaultStyle(object, itm->second) );
if ( style_mode.get() )
{
#ifdef DEBUG_VERBOSE
trace.info() << " [default style for mode]";
#endif
DGtal::Style2DFactory::draw(*this, style_mode.get());
}
// Apply customized style for specific mode.
std::string specific_style = object.className() + "/" + itm->second;
it = myStyles.find( specific_style );
if ( it != myStyles.end() )
if ( it->second.get() != 0 )
{
#ifdef DEBUG_VERBOSE
trace.info() << " [specific style for mode: "
<< specific_style << "]";
#endif
DGtal::Style2DFactory::draw(*this, it->second.get());
}
}
#ifdef DEBUG_VERBOSE
trace.info() << " [draw]";
#endif
#ifdef DEBUG_VERBOSE
std::cerr << std::endl;
#endif
return *this;
}
DGtal::Board2D & DGtal::Board2D::operator= ( const Board2D other)

Assignment.

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

Definition at line 82 of file Board2D.cpp.

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

{
if ( this != &other )
{
myStyles = other.myStyles;
}
return *this;
}
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 103 of file Board2D.cpp.

{
out << "[Board2D]";
}

Field Documentation

DomainDrawMode DGtal::Board2D::myDomainDrawMode
Deprecated:
Since:
2010/11/8
See also:
myModes

Definition at line 160 of file Board2D.h.

Referenced by operator=().

bool DGtal::Board2D::myDrawObjectAdjacencies
Deprecated:
Since:
2010/11/8
See also:
myModes

Definition at line 166 of file Board2D.h.

Referenced by operator=().

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 188 of file Board2D.h.

Referenced by DGtal::Display2DFactory::draw(), and getMode().

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 178 of file Board2D.h.

Referenced by DGtal::Display2DFactory::draw(), and operator=().


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