DGtal  1.0.0
Public Member Functions | Protected Attributes | Static Private Attributes
LibBoard::Dot Struct Reference

A line between two points. More...

#include <Board/Shapes.h>

Inheritance diagram for LibBoard::Dot:
[legend]
Collaboration diagram for LibBoard::Dot:
[legend]

Public Member Functions

 Dot (double x, double y, DGtal::Color color, double lineWidth, int depth=-1)
 
const std::string & name () const
 
Point center () const
 
Dotrotate (double angle, const Point &center)
 
Dot rotated (double angle, const Point &center) const
 
Dotrotate (double angle)
 
Dot rotated (double angle) const
 
Dottranslate (double dx, double dy)
 
Dot translated (double dx, double dy) const
 
Shapescale (double sx, double sy)
 
Shapescale (double s)
 
Dot scaled (double sx, double sy) const
 
Dot scaled (double s) 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 flushCairo (cairo_t *cr, const TransformCairo &transform) const
 
void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const
 
Rect boundingBox () const
 
Dotclone () const
 
- 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
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
Rect bbox ()
 
Shapeoperator-- ()
 
Shapeoperator++ ()
 
int depth () const
 
virtual void depth (int)
 
virtual void shiftDepth (int shift)
 
const DGtal::ColorpenColor () const
 
const DGtal::ColorfillColor () const
 

Protected Attributes

double _x
 
double _y
 
- Protected Attributes inherited from LibBoard::Shape
int _depth
 
DGtal::Color _penColor
 
DGtal::Color _fillColor
 
double _lineWidth
 
LineStyle _lineStyle
 
LineCap _lineCap
 
LineJoin _lineJoin
 

Static Private Attributes

static const std::string _name
 

Additional Inherited Members

- 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
}
 
- 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
 

Detailed Description

A line between two points.

The dot structure. This primitive ha been reported as "missing" by Manuel Peinado from Spain. Manuel also suggested that rendering a dot consists in drawing a line from a point to the same point with a roundcap style.

Definition at line 398 of file Board/Shapes.h.

Constructor & Destructor Documentation

◆ Dot()

LibBoard::Dot::Dot ( double  x,
double  y,
DGtal::Color  color,
double  lineWidth,
int  depth = -1 
)
inline

Referenced by clone(), rotated(), and translated().

Member Function Documentation

◆ boundingBox()

Rect LibBoard::Dot::boundingBox ( ) const
virtual

Returns the bounding box of the figure.

Returns
The rectangle of the bounding box.

Implements LibBoard::Shape.

Definition at line 379 of file Shapes.cpp.

380 {
381  return Rect( _x, _y, 0.0, 0.0 );
382 }

References _x, and _y.

◆ center()

Point LibBoard::Dot::center ( ) const
virtual

Returns the gravity center of the shape.

Returns
The center of the shape.

Implements LibBoard::Shape.

Definition at line 218 of file Shapes.cpp.

218  {
219  return Point( _x, _y );
220 }
MyPointD Point
Definition: testClone2.cpp:383

References _x, and _y.

◆ clone()

Dot * LibBoard::Dot::clone ( ) const
virtual

Return a copy of the shape.

Returns
copye of the shape.

Implements LibBoard::Shape.

Definition at line 385 of file Shapes.cpp.

385  {
386  return new Dot(*this);
387 }
Dot(double x, double y, DGtal::Color color, double lineWidth, int depth=-1)

References Dot().

◆ flushCairo()

void LibBoard::Dot::flushCairo ( cairo_t *  cr,
const TransformCairo transform 
) const
virtual

Writes the cairo code of the shape in a cairo drawing context according to a transform.

Parameters
crThe cairo drawing context.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Definition at line 348 of file Shapes.cpp.

350 {
351  cairo_save (cr);
352 
353  cairo_set_source_rgba (cr, _penColor.red()/255.0, _penColor.green()/255.0, _penColor.blue()/255.0, 1.);
354 
355  cairo_move_to (cr, transform.mapX( _x ), transform.mapY( _y ));
356  cairo_line_to (cr, transform.mapX( _x ), transform.mapY( _y ));
357 
358  cairo_set_line_width (cr, _lineWidth);
359  cairo_set_line_cap (cr, cairoLineCap[_lineCap]);
360  cairo_set_line_join (cr, cairoLineJoin[_lineJoin]);
362 
363  cairo_stroke (cr);
364 
365  cairo_restore (cr);
366 }
void setCairoDashStyle(cairo_t *cr, LineStyle type) const
Definition: Shapes.cpp:153
LineJoin _lineJoin
Definition: Board/Shapes.h:301
void green(const unsigned char aGreenValue)
DGtal::Color _penColor
Definition: Board/Shapes.h:296
void red(const unsigned char aRedValue)
LineStyle _lineStyle
Definition: Board/Shapes.h:299
void blue(const unsigned char aBlueValue)

References LibBoard::Shape::_lineCap, LibBoard::Shape::_lineJoin, LibBoard::Shape::_lineStyle, LibBoard::Shape::_lineWidth, LibBoard::Shape::_penColor, _x, _y, DGtal::Color::blue(), DGtal::Color::green(), DGtal::Color::red(), and LibBoard::Shape::setCairoDashStyle().

◆ flushFIG()

void LibBoard::Dot::flushFIG ( std::ostream &  stream,
const TransformFIG transform,
std::map< DGtal::Color, int > &  colormap 
) const
virtual

Writes the FIG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.
colormapA colormap.

Implements LibBoard::Shape.

Definition at line 308 of file Shapes.cpp.

311 {
312  stream << "2 1 0 ";
313  // Thickness
314  stream << ( _penColor.valid()?transform.mapWidth( _lineWidth ):0 ) << " ";
315  // Pen color
316  stream << colormap[ _penColor ] << " ";
317  // Fill color
318  stream << "0 ";
319  // Depth
320  stream << transform.mapDepth( _depth ) << " ";
321  // Pen style
322  stream << "-1 ";
323  // Area fill, style val, join style, cap style, radius, f_arrow, b_arrow
324  stream << "-1 0.000 " << _lineJoin << " " << _lineCap << " -1 0 0 ";
325  // Number of points
326  stream << "2\n";
327  stream << " ";
328  stream << static_cast<int>( transform.mapX( _x ) ) << " "
329  << static_cast<int>( transform.mapY( _y ) ) << " "
330  << static_cast<int>( transform.mapX( _x ) ) << " "
331  << static_cast<int>( transform.mapY( _y ) ) << std::endl;
332 }
LineJoin _lineJoin
Definition: Board/Shapes.h:301
bool valid() const
DGtal::Color _penColor
Definition: Board/Shapes.h:296

References LibBoard::Shape::_depth, LibBoard::Shape::_lineCap, LibBoard::Shape::_lineJoin, LibBoard::Shape::_lineWidth, LibBoard::Shape::_penColor, _x, _y, and DGtal::Color::valid().

◆ flushPostscript()

void LibBoard::Dot::flushPostscript ( std::ostream &  stream,
const TransformEPS transform 
) const
virtual

Writes the EPS code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Definition at line 293 of file Shapes.cpp.

295 {
296  stream << "\n% Dot\n";
297  stream << postscriptProperties() << " "
298  << "n "
299  << transform.mapX( _x ) << " "
300  << transform.mapY( _y ) << " "
301  << "m "
302  << transform.mapX( _x ) << " "
303  << transform.mapY( _y ) << " "
304  << "l " << _penColor.postscript() << " srgb stroke" << std::endl;
305 }
std::string postscript() const
Definition: Color.cpp:132
DGtal::Color _penColor
Definition: Board/Shapes.h:296
std::string postscriptProperties() const
Definition: Shapes.cpp:140

References LibBoard::Shape::_penColor, _x, _y, DGtal::Color::postscript(), and LibBoard::Shape::postscriptProperties().

◆ flushSVG()

void LibBoard::Dot::flushSVG ( std::ostream &  stream,
const TransformSVG transform 
) const
virtual

Writes the SVG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Definition at line 335 of file Shapes.cpp.

337 {
338  stream << "<line x1=\"" << transform.mapX( _x ) << "\""
339  << " y1=\"" << transform.mapY( _y ) << "\""
340  << " x2=\"" << transform.mapX( _x ) << "\""
341  << " y2=\"" << transform.mapY( _y ) << "\""
342  << svgProperties( transform )
343  << " />" << std::endl;
344 }
std::string svgProperties(const TransformSVG &transform) const
Definition: Shapes.cpp:109

References _x, _y, and LibBoard::Shape::svgProperties().

◆ flushTikZ()

void LibBoard::Dot::flushTikZ ( std::ostream &  stream,
const TransformTikZ transform 
) const
virtual

Writes the TikZ code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Definition at line 370 of file Shapes.cpp.

373 {
374  // FIXME: unimplemented
375  stream << "% FIXME: Dot::flushTikZ unimplemented" << std::endl;
376 }

◆ name()

const std::string & LibBoard::Dot::name ( ) const
virtual

Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)

Returns
object name

Reimplemented from LibBoard::Shape.

Definition at line 212 of file Shapes.cpp.

213 {
214  return _name;
215 }
static const std::string _name
Definition: Board/Shapes.h:521

References _name.

◆ rotate() [1/2]

Dot & LibBoard::Dot::rotate ( double  angle,
const Point center 
)
virtual

Rotates the dot around a given center of rotation.

Parameters
angleThe rotation angle.
centerThe center of rotation.
Returns
A reference to the Dot itself.

Implements LibBoard::Shape.

Definition at line 223 of file Shapes.cpp.

224 {
225  Point( _x, _y ).rotate( angle, rotCenter ).get( _x, _y );
226  return *this;
227 }
MyPointD Point
Definition: testClone2.cpp:383

References _x, and _y.

◆ rotate() [2/2]

Dot & LibBoard::Dot::rotate ( double  angle)
virtual

Rotates the dot around its center (actually does nothing!).

Parameters
angleThe rotation angle.
Returns
A reference to the Dot itself.

Implements LibBoard::Shape.

Definition at line 236 of file Shapes.cpp.

237 {
238  return *this;
239 }

◆ rotated() [1/2]

Dot LibBoard::Dot::rotated ( double  angle,
const Point center 
) const

Returns a rotated copy of the dot around a given rotation center.

Parameters
angleTh rotation angle.
centerThe center of rotation.
Returns
A rotated copy of the Dot.

Definition at line 230 of file Shapes.cpp.

231 {
232  return Dot(*this).rotate( angle, rotCenter );
233 }
Dot(double x, double y, DGtal::Color color, double lineWidth, int depth=-1)

References Dot().

◆ rotated() [2/2]

Dot LibBoard::Dot::rotated ( double  angle) const

Returns a copy of the dot rotated around its center (i.e. left unchanged!)

Parameters
angleThe rotation angle.
Returns
A copy of the dot.

Definition at line 242 of file Shapes.cpp.

243 {
244  return *this;
245 }

◆ scale() [1/2]

Shape & LibBoard::Dot::scale ( double  sx,
double  sy 
)
virtual

Scale the shape along the x an y axis.

Parameters
sxThe scale factor along the x axis.
syThe scale factor along the y axis.
Returns
The shape itself.

Implements LibBoard::Shape.

Definition at line 262 of file Shapes.cpp.

263 {
264  return *this;
265 }

◆ scale() [2/2]

Shape & LibBoard::Dot::scale ( double  s)
virtual

Scale the shape along both axis.

Parameters
sThe scale factor along both axis.
Returns
The shape itself.

Implements LibBoard::Shape.

Definition at line 268 of file Shapes.cpp.

269 {
270  return *this;
271 }

◆ scaleAll()

void LibBoard::Dot::scaleAll ( double  s)
virtual

Scales all the values (positions, dimensions, etc.) associated with the shape.

Parameters
sThe scaling factor.

Implements LibBoard::Shape.

Definition at line 286 of file Shapes.cpp.

287 {
288  _x *= s;
289  _y *= s;
290 }

References _x, and _y.

◆ scaled() [1/2]

Dot LibBoard::Dot::scaled ( double  sx,
double  sy 
) const

Returns a scaled copy of the dot, i.e. the dot itself. (Dots are not actually scaled since their diameters is given by the line width.)

Parameters
sxThe scale factor around the x axis.
syThe scale factor around the y axis.
Returns
A scaled copy of the Dot, i.e. the Dot itself.

Definition at line 274 of file Shapes.cpp.

275 {
276  return *this;
277 }

◆ scaled() [2/2]

Dot LibBoard::Dot::scaled ( double  s) const

Definition at line 280 of file Shapes.cpp.

281 {
282  return *this;
283 }

◆ translate()

Dot & LibBoard::Dot::translate ( double  dx,
double  dy 
)
virtual
Parameters
dxdx
dydy
Returns
a Dot

Implements LibBoard::Shape.

Definition at line 248 of file Shapes.cpp.

249 {
250  _x += dx;
251  _y += dy;
252  return *this;
253 }

References _x, and _y.

◆ translated()

Dot LibBoard::Dot::translated ( double  dx,
double  dy 
) const

Returns a translated copy of the dot.

Parameters
dxShift of the first coordinate.
dyShift of the second coordinate.
Returns
A copy of the Dot, translated.

Definition at line 256 of file Shapes.cpp.

257 {
258  return Dot(*this).translate( dx, dy );
259 }
Dot(double x, double y, DGtal::Color color, double lineWidth, int depth=-1)

References Dot().

Field Documentation

◆ _name

const std::string LibBoard::Dot::_name
staticprivate

The generic name of the shape.

Definition at line 521 of file Board/Shapes.h.

Referenced by name().

◆ _x

double LibBoard::Dot::_x
protected

First coordinate of the dot.

Definition at line 524 of file Board/Shapes.h.

Referenced by boundingBox(), center(), flushCairo(), flushFIG(), flushPostscript(), flushSVG(), rotate(), scaleAll(), and translate().

◆ _y

double LibBoard::Dot::_y
protected

Second coordinate of the dot.

Definition at line 525 of file Board/Shapes.h.

Referenced by boundingBox(), center(), flushCairo(), flushFIG(), flushPostscript(), flushSVG(), rotate(), scaleAll(), and translate().


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