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

#include <Board/Shapes.h>

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

Public Member Functions

 Circle (double x, double y, double radius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, int depthValue=-1)
 
const std::string & name () const
 
Point center () const
 
Circlerotate (double angle, const Point &center)
 
Circle rotated (double angle, const Point &center) const
 
Circlerotate (double angle)
 
Circle rotated (double angle) const
 
Circletranslate (double dx, double dy)
 
Circle translated (double dx, double dy) const
 
Shapescale (double sx, double sy)
 
Shapescale (double s)
 
Circle scaled (double sx, double sy) const
 
Circle scaled (double s) const
 
void scaleAll (double s)
 
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
 
Circleclone () const
 
- Public Member Functions inherited from LibBoard::Ellipse
 Ellipse (double x, double y, double xRadius, double yRadius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle lineStyle=SolidStyle, int depthValue=-1)
 
Ellipse rotated (double angle, const Point &center) const
 
Ellipse rotated (double angle) const
 
Ellipse translated (double dx, double dy) const
 
Ellipse scaled (double sx, double sy) const
 
Ellipse scaled (double s) const
 
void flushPostscript (std::ostream &stream, const TransformEPS &transform) const
 
void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const
 
Rect boundingBox () 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
 

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
 
- Protected Attributes inherited from LibBoard::Ellipse
Point _center
 
double _xRadius
 
double _yRadius
 
double _angle
 
bool _circle
 
- Protected Attributes inherited from LibBoard::Shape
int _depth
 
DGtal::Color _penColor
 
DGtal::Color _fillColor
 
double _lineWidth
 
LineStyle _lineStyle
 
LineCap _lineCap
 
LineJoin _lineJoin
 

Detailed Description

A circle.

The circle structure.

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

Constructor & Destructor Documentation

LibBoard::Circle::Circle ( double  x,
double  y,
double  radius,
DGtal::Color  pen,
DGtal::Color  fill,
double  lineWidth,
const LineStyle  style = SolidStyle,
int  depthValue = -1 
)
inline

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

References LibBoard::Ellipse::_circle.

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

1467  : Ellipse( x, y, radius, radius, pen, fill, lineWidth, style, depthValue )
1468  { _circle = true; }
Ellipse(double x, double y, double xRadius, double yRadius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle lineStyle=SolidStyle, int depthValue=-1)

Member Function Documentation

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

Returns the gravity center of the shape.

Returns
The center of the shape.

Reimplemented from LibBoard::Ellipse.

Definition at line 1329 of file Shapes.cpp.

References LibBoard::Ellipse::_center.

1329  {
1330  return _center;
1331 }
Circle * LibBoard::Circle::clone ( ) const
virtual

Return a copy of the shape.

Returns
copye of the shape.

Reimplemented from LibBoard::Ellipse.

Definition at line 1411 of file Shapes.cpp.

References Circle().

1411  {
1412  return new Circle(*this);
1413 }
Circle(double x, double y, double radius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, int depthValue=-1)
void LibBoard::Circle::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.

Reimplemented from LibBoard::Ellipse.

Reimplemented in LibBoard::Arc.

Definition at line 1432 of file Shapes.cpp.

References LibBoard::Ellipse::_center, LibBoard::Ellipse::_circle, LibBoard::Shape::_fillColor, LibBoard::Shape::_lineCap, LibBoard::Shape::_lineJoin, LibBoard::Shape::_lineStyle, LibBoard::Shape::_lineWidth, LibBoard::Shape::_penColor, LibBoard::Ellipse::_xRadius, DGtal::Color::blue(), LibBoard::Shape::filled(), LibBoard::Ellipse::flushCairo(), DGtal::Color::green(), LibBoard::Transform::mapX(), LibBoard::TransformCairo::mapY(), DGtal::Color::None, DGtal::Color::red(), LibBoard::Transform::scale(), LibBoard::Shape::setCairoDashStyle(), LibBoard::Point::x, and LibBoard::Point::y.

1434 {
1435  if ( ! _circle )
1436  Ellipse::flushCairo( cr, transform );
1437  else
1438  {
1439  cairo_save (cr);
1440 
1441  cairo_set_source_rgba (cr, _fillColor.red()/255.0, _fillColor.green()/255.0, _fillColor.blue()/255.0, 1.);
1442 
1443  cairo_arc (cr, transform.mapX( _center.x ), transform.mapY( _center.y ), transform.scale( _xRadius ), 0, 2*M_PI);
1444 
1445  if ( filled() )
1446  {
1447  if ( _penColor != DGtal::Color::None )
1448  cairo_fill_preserve (cr);
1449  else
1450  cairo_fill (cr);
1451  }
1452 
1453  //
1454 
1455  if ( _penColor != DGtal::Color::None )
1456  {
1457  cairo_set_source_rgba (cr, _penColor.red()/255.0, _penColor.green()/255.0, _penColor.blue()/255.0, 1.);
1458 
1459  cairo_set_line_width (cr, _lineWidth);
1460  cairo_set_line_cap (cr, cairoLineCap[_lineCap]);
1461  cairo_set_line_join (cr, cairoLineJoin[_lineJoin]);
1463 
1464  cairo_stroke (cr);
1465  }
1466 
1467  cairo_restore (cr);
1468  }
1469 }
static const Color None
Definition: Color.h:387
double x
Definition: Point.h:29
LineJoin _lineJoin
Definition: Board/Shapes.h:301
bool filled() const
Definition: Board/Shapes.h:111
void flushCairo(cairo_t *cr, const TransformCairo &transform) const
Definition: Shapes.cpp:1233
void green(const unsigned char aGreenValue)
double y
Definition: Point.h:30
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
DGtal::Color _fillColor
Definition: Board/Shapes.h:297
void blue(const unsigned char aBlueValue)
void LibBoard::Circle::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.

Reimplemented from LibBoard::Ellipse.

Reimplemented in LibBoard::Arc.

Definition at line 1416 of file Shapes.cpp.

References LibBoard::Ellipse::_center, LibBoard::Ellipse::_circle, LibBoard::Ellipse::_xRadius, LibBoard::Ellipse::flushSVG(), LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), LibBoard::Transform::scale(), LibBoard::Shape::svgProperties(), LibBoard::Point::x, and LibBoard::Point::y.

1418 {
1419  if ( ! _circle )
1420  Ellipse::flushSVG( stream, transform );
1421  else {
1422  stream << "<circle cx=\"" << transform.mapX( _center.x ) << '"'
1423  << " cy=\"" << transform.mapY( _center.y ) << '"'
1424  << " r=\"" << transform.scale( _xRadius ) << '"'
1425  << svgProperties( transform )
1426  << " />" << std::endl;
1427  }
1428 }
void flushSVG(std::ostream &stream, const TransformSVG &transform) const
Definition: Shapes.cpp:1214
double x
Definition: Point.h:29
std::string svgProperties(const TransformSVG &transform) const
Definition: Shapes.cpp:110
double y
Definition: Point.h:30
void LibBoard::Circle::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.

Reimplemented from LibBoard::Ellipse.

Reimplemented in LibBoard::Arc.

Definition at line 1473 of file Shapes.cpp.

References LibBoard::Ellipse::_center, LibBoard::Ellipse::_circle, LibBoard::Ellipse::_xRadius, LibBoard::Ellipse::flushTikZ(), LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), LibBoard::Transform::scale(), LibBoard::Shape::tikzProperties(), LibBoard::Point::x, and LibBoard::Point::y.

1475 {
1476  if ( ! _circle )
1477  Ellipse::flushTikZ( stream, transform );
1478  else {
1479  stream << "\\path[" << tikzProperties(transform) << "] ("
1480  << transform.mapX( _center.x ) << ','
1481  << transform.mapY( _center.y ) << ')'
1482  << " circle (" << transform.scale( _xRadius ) << ");"
1483  << std::endl;
1484  }
1485 }
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const
Definition: Shapes.cpp:1276
std::string tikzProperties(const TransformTikZ &transform) const
Definition: Shapes.cpp:178
double x
Definition: Point.h:29
double y
Definition: Point.h:30
const std::string & LibBoard::Circle::name ( ) const
virtual

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

Returns
generic name as a string

Reimplemented from LibBoard::Ellipse.

Reimplemented in LibBoard::Arc.

Definition at line 1323 of file Shapes.cpp.

References _name.

1324 {
1325  return _name;
1326 }
static const std::string _name
Circle & LibBoard::Circle::rotate ( double  angle,
const Point center 
)
virtual

Rotate the shape around a given center of rotation.

Parameters
angleThe rotation angle in radian.
centerThe center of rotation.
Returns
A reference to the shape itself.

Reimplemented from LibBoard::Ellipse.

Definition at line 1334 of file Shapes.cpp.

References LibBoard::Ellipse::_center, LibBoard::Ellipse::_circle, LibBoard::Point::rotate(), and LibBoard::Ellipse::rotate().

1335 {
1336  if ( _circle ) {
1337  if ( rotCenter == _center ) return *this;
1338  _center.rotate( angle, rotCenter );
1339  return *this;
1340  }
1341  Ellipse::rotate( angle, rotCenter );
1342  return *this;
1343 }
Point & rotate(double angle)
Definition: Point.h:183
Ellipse & rotate(double angle, const Point &center)
Definition: Shapes.cpp:1032
Circle & LibBoard::Circle::rotate ( double  angle)
virtual

Rotate the shape around its center.

Parameters
angleThe rotation angle in radian.
Returns
A reference to the shape itself.

Reimplemented from LibBoard::Ellipse.

Definition at line 1352 of file Shapes.cpp.

References LibBoard::Ellipse::_circle, and LibBoard::Ellipse::rotate().

1353 {
1354  if ( !_circle )
1355  Ellipse::rotate( angle );
1356  return *this;
1357 }
Ellipse & rotate(double angle, const Point &center)
Definition: Shapes.cpp:1032
Circle LibBoard::Circle::rotated ( double  angle,
const Point center 
) const

Definition at line 1346 of file Shapes.cpp.

References Circle().

1347 {
1348  return Circle(*this).rotate( angle, rotCenter );
1349 }
Circle(double x, double y, double radius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, int depthValue=-1)
Circle LibBoard::Circle::rotated ( double  angle) const

Definition at line 1360 of file Shapes.cpp.

References Circle().

1361 {
1362  return Circle(*this).rotate( angle );
1363 }
Circle(double x, double y, double radius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, int depthValue=-1)
Shape & LibBoard::Circle::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.

Reimplemented from LibBoard::Ellipse.

Definition at line 1379 of file Shapes.cpp.

References LibBoard::Ellipse::scale().

1380 {
1381  return Ellipse::scale( sx, sy );
1382 }
Shape & scale(double sx, double sy)
Definition: Shapes.cpp:1076
Shape & LibBoard::Circle::scale ( double  s)
virtual

Scale the shape along both axis.

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

Reimplemented from LibBoard::Ellipse.

Definition at line 1385 of file Shapes.cpp.

References LibBoard::Ellipse::scale().

1386 {
1387  return Ellipse::scale( s );
1388 }
Shape & scale(double sx, double sy)
Definition: Shapes.cpp:1076
void LibBoard::Circle::scaleAll ( double  s)
virtual

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

Parameters
sThe scaling factor.

Reimplemented from LibBoard::Ellipse.

Definition at line 1403 of file Shapes.cpp.

References LibBoard::Ellipse::_center, LibBoard::Ellipse::_xRadius, and LibBoard::Ellipse::_yRadius.

1404 {
1405  _center *= s;
1406  _xRadius *= s;
1407  _yRadius *= s;
1408 }
Circle LibBoard::Circle::scaled ( double  sx,
double  sy 
) const

Definition at line 1391 of file Shapes.cpp.

References Circle().

1392 {
1393  return static_cast<Circle &>( Circle(*this).scale( sx, sy ) );
1394 }
Circle(double x, double y, double radius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, int depthValue=-1)
Circle LibBoard::Circle::scaled ( double  s) const

Definition at line 1397 of file Shapes.cpp.

References Circle().

1398 {
1399  return static_cast<Circle &>( Circle(*this).scale( s, s ) );
1400 }
Circle(double x, double y, double radius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, int depthValue=-1)
Circle & LibBoard::Circle::translate ( double  dx,
double  dy 
)
virtual

Translate the shape by a given offset.

Parameters
dxThe x offset.
dyThe y offset.
Returns
A reference to the shape itself.

Reimplemented from LibBoard::Ellipse.

Definition at line 1366 of file Shapes.cpp.

References LibBoard::Ellipse::_center.

1367 {
1368  _center += Point( dx, dy );
1369  return *this;
1370 }
Circle LibBoard::Circle::translated ( double  dx,
double  dy 
) const

Definition at line 1373 of file Shapes.cpp.

References Circle().

1374 {
1375  return Circle(*this).translate( dx, dy );
1376 }
Circle(double x, double y, double radius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, int depthValue=-1)

Field Documentation

const std::string LibBoard::Circle::_name
staticprivate

The generic name of the shape.

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

Referenced by name().


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