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

#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

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

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 380 of file Shapes.cpp.

References _x, and _y.

381 {
382  return Rect( _x, _y, 0.0, 0.0 );
383 }
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 219 of file Shapes.cpp.

References _x, and _y.

219  {
220  return Point( _x, _y );
221 }
Dot * LibBoard::Dot::clone ( ) const
virtual

Return a copy of the shape.

Returns
copye of the shape.

Implements LibBoard::Shape.

Definition at line 386 of file Shapes.cpp.

References Dot().

386  {
387  return new Dot(*this);
388 }
Dot(double x, double y, DGtal::Color color, double lineWidth, int depth=-1)
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 349 of file Shapes.cpp.

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

351 {
352  cairo_save (cr);
353 
354  cairo_set_source_rgba (cr, _penColor.red()/255.0, _penColor.green()/255.0, _penColor.blue()/255.0, 1.);
355 
356  cairo_move_to (cr, transform.mapX( _x ), transform.mapY( _y ));
357  cairo_line_to (cr, transform.mapX( _x ), transform.mapY( _y ));
358 
359  cairo_set_line_width (cr, _lineWidth);
360  cairo_set_line_cap (cr, cairoLineCap[_lineCap]);
361  cairo_set_line_join (cr, cairoLineJoin[_lineJoin]);
363 
364  cairo_stroke (cr);
365 
366  cairo_restore (cr);
367 }
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)
void setCairoDashStyle(cairo_t *cr, LineStyle type) const
Definition: Shapes.cpp:154
LineStyle _lineStyle
Definition: Board/Shapes.h:299
void blue(const unsigned char aBlueValue)
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 309 of file Shapes.cpp.

References LibBoard::Shape::_depth, LibBoard::Shape::_lineCap, LibBoard::Shape::_lineJoin, LibBoard::Shape::_lineWidth, LibBoard::Shape::_penColor, _x, _y, LibBoard::TransformFIG::mapDepth(), LibBoard::TransformFIG::mapWidth(), LibBoard::Transform::mapX(), LibBoard::TransformFIG::mapY(), and DGtal::Color::valid().

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

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

296 {
297  stream << "\n% Dot\n";
298  stream << postscriptProperties() << " "
299  << "n "
300  << transform.mapX( _x ) << " "
301  << transform.mapY( _y ) << " "
302  << "m "
303  << transform.mapX( _x ) << " "
304  << transform.mapY( _y ) << " "
305  << "l " << _penColor.postscript() << " srgb stroke" << std::endl;
306 }
std::string postscriptProperties() const
Definition: Shapes.cpp:141
std::string postscript() const
Definition: Color.cpp:132
DGtal::Color _penColor
Definition: Board/Shapes.h:296
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 336 of file Shapes.cpp.

References _x, _y, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), and LibBoard::Shape::svgProperties().

338 {
339  stream << "<line x1=\"" << transform.mapX( _x ) << "\""
340  << " y1=\"" << transform.mapY( _y ) << "\""
341  << " x2=\"" << transform.mapX( _x ) << "\""
342  << " y2=\"" << transform.mapY( _y ) << "\""
343  << svgProperties( transform )
344  << " />" << std::endl;
345 }
std::string svgProperties(const TransformSVG &transform) const
Definition: Shapes.cpp:110
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 371 of file Shapes.cpp.

374 {
375  // FIXME: unimplemented
376  stream << "% FIXME: Dot::flushTikZ unimplemented" << std::endl;
377 }
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 213 of file Shapes.cpp.

References _name.

214 {
215  return _name;
216 }
static const std::string _name
Definition: Board/Shapes.h:521
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 224 of file Shapes.cpp.

References _x, _y, LibBoard::Point::get(), and LibBoard::Point::rotate().

225 {
226  Point( _x, _y ).rotate( angle, rotCenter ).get( _x, _y );
227  return *this;
228 }
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 237 of file Shapes.cpp.

238 {
239  return *this;
240 }
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 231 of file Shapes.cpp.

References Dot().

232 {
233  return Dot(*this).rotate( angle, rotCenter );
234 }
Dot(double x, double y, DGtal::Color color, double lineWidth, int depth=-1)
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 243 of file Shapes.cpp.

244 {
245  return *this;
246 }
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 263 of file Shapes.cpp.

264 {
265  return *this;
266 }
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 269 of file Shapes.cpp.

270 {
271  return *this;
272 }
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 287 of file Shapes.cpp.

References _x, and _y.

288 {
289  _x *= s;
290  _y *= s;
291 }
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 275 of file Shapes.cpp.

276 {
277  return *this;
278 }
Dot LibBoard::Dot::scaled ( double  s) const

Definition at line 281 of file Shapes.cpp.

282 {
283  return *this;
284 }
Dot & LibBoard::Dot::translate ( double  dx,
double  dy 
)
virtual
Parameters
dxdx
dydy
Returns
a Dot

Implements LibBoard::Shape.

Definition at line 249 of file Shapes.cpp.

References _x, and _y.

250 {
251  _x += dx;
252  _y += dy;
253  return *this;
254 }
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 257 of file Shapes.cpp.

References Dot().

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

Field Documentation

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

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

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: