DGtal  1.5.beta
LibBoard::Circle Struct Reference

A circle. More...

#include <Board/Shapes.h>

Inheritance 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

◆ Circle()

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.

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)

References LibBoard::Ellipse::_circle.

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

Member Function Documentation

◆ center()

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

1328  {
1329  return _center;
1330 }

References LibBoard::Ellipse::_center.

◆ clone()

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

Return a copy of the shape.

Returns
copye of the shape.

Reimplemented from LibBoard::Ellipse.

Definition at line 1410 of file Shapes.cpp.

1410  {
1411  return new Circle(*this);
1412 }
Circle(double x, double y, double radius, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, int depthValue=-1)

References Circle().

◆ flushCairo()

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

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

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(), DGtal::Color::None, DGtal::Color::red(), LibBoard::Shape::setCairoDashStyle(), LibBoard::Point::x, and LibBoard::Point::y.

◆ flushSVG()

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

1417 {
1418  if ( ! _circle )
1419  Ellipse::flushSVG( stream, transform );
1420  else {
1421  stream << "<circle cx=\"" << transform.mapX( _center.x ) << '"'
1422  << " cy=\"" << transform.mapY( _center.y ) << '"'
1423  << " r=\"" << transform.scale( _xRadius ) << '"'
1424  << svgProperties( transform )
1425  << " />" << std::endl;
1426  }
1427 }
void flushSVG(std::ostream &stream, const TransformSVG &transform) const
Definition: Shapes.cpp:1213
std::string svgProperties(const TransformSVG &transform) const
Definition: Shapes.cpp:109

References LibBoard::Ellipse::_center, LibBoard::Ellipse::_circle, LibBoard::Ellipse::_xRadius, LibBoard::Ellipse::flushSVG(), LibBoard::Shape::svgProperties(), LibBoard::Point::x, and LibBoard::Point::y.

◆ flushTikZ()

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

1474 {
1475  if ( ! _circle )
1476  Ellipse::flushTikZ( stream, transform );
1477  else {
1478  stream << "\\path[" << tikzProperties(transform) << "] ("
1479  << transform.mapX( _center.x ) << ','
1480  << transform.mapY( _center.y ) << ')'
1481  << " circle (" << transform.scale( _xRadius ) << ");"
1482  << std::endl;
1483  }
1484 }
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const
Definition: Shapes.cpp:1275
std::string tikzProperties(const TransformTikZ &transform) const
Definition: Shapes.cpp:177

References LibBoard::Ellipse::_center, LibBoard::Ellipse::_circle, LibBoard::Ellipse::_xRadius, LibBoard::Ellipse::flushTikZ(), LibBoard::Shape::tikzProperties(), LibBoard::Point::x, and LibBoard::Point::y.

◆ name()

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

1323 {
1324  return _name;
1325 }
static const std::string _name

References _name.

◆ rotate() [1/2]

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

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

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

◆ rotate() [2/2]

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

1334 {
1335  if ( _circle ) {
1336  if ( rotCenter == _center ) return *this;
1337  _center.rotate( angle, rotCenter );
1338  return *this;
1339  }
1340  Ellipse::rotate( angle, rotCenter );
1341  return *this;
1342 }
Point & rotate(double angle)
Definition: Point.h:190

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

◆ rotated() [1/2]

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

Definition at line 1359 of file Shapes.cpp.

1360 {
1361  return Circle(*this).rotate( angle );
1362 }

References Circle().

◆ rotated() [2/2]

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

Definition at line 1345 of file Shapes.cpp.

1346 {
1347  return Circle(*this).rotate( angle, rotCenter );
1348 }

References Circle().

◆ scale() [1/2]

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

1385 {
1386  return Ellipse::scale( s );
1387 }
Shape & scale(double sx, double sy)
Definition: Shapes.cpp:1075

References LibBoard::Ellipse::scale().

◆ scale() [2/2]

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

1379 {
1380  return Ellipse::scale( sx, sy );
1381 }

References LibBoard::Ellipse::scale().

◆ scaleAll()

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

1403 {
1404  _center *= s;
1405  _xRadius *= s;
1406  _yRadius *= s;
1407 }

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

◆ scaled() [1/2]

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

Definition at line 1396 of file Shapes.cpp.

1397 {
1398  return static_cast<Circle &>( Circle(*this).scale( s, s ) );
1399 }

References Circle().

◆ scaled() [2/2]

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

Definition at line 1390 of file Shapes.cpp.

1391 {
1392  return static_cast<Circle &>( Circle(*this).scale( sx, sy ) );
1393 }

References Circle().

◆ translate()

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

1366 {
1367  _center += Point( dx, dy );
1368  return *this;
1369 }
MyPointD Point
Definition: testClone2.cpp:383

References LibBoard::Ellipse::_center.

◆ translated()

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

Definition at line 1372 of file Shapes.cpp.

1373 {
1374  return Circle(*this).translate( dx, dy );
1375 }

References Circle().

Field Documentation

◆ _name

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: