Board 0.9.6
Public Types | Public Member Functions | Protected Attributes | List of all members
LibBoard::Ellipse Struct Reference

An ellipse. More...

#include <Ellipse.h>

Inheritance diagram for LibBoard::Ellipse:
LibBoard::ShapeWithStyle LibBoard::Shape

Public Types

enum  SamplingStart { SamplingFromRight , SamplingFromTop , SamplingFromLeft , SamplingFromBottom }
 

Public Member Functions

 Ellipse (double x, double y, double xRadius, double yRadius, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), LineStyle lineStyle=Style::defaultLineStyle())
 
 Ellipse (Point center, double xRadius, double yRadius, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle())
 
 Ellipse (Point center, double xRadius, double yRadius, Style style)
 
const std::string & name () const override
 
Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const override
 
double xRadius () const
 
double yRadius () const
 
double angle () const
 
Ellipserotate (double angle, const Point &center) override
 
Ellipse rotated (double angle, const Point &center) const
 
Ellipserotate (double angle) override
 
Ellipse rotated (double angle) const
 
Ellipsetranslate (double dx, double dy) override
 
Ellipse translated (double dx, double dy) const
 
Ellipsescale (double sx, double sy) override
 
Ellipsescale (double s) override
 
Ellipse scaled (double sx, double sy) const
 
Ellipse scaled (double s) const
 
void scaleAll (double s) override
 
Ellipse resized (double w, double h, LineWidthFlag lineWidthFlag) const
 
void flushPostscript (std::ostream &stream, const TransformEPS &transform) const override
 
void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const override
 
void flushSVG (std::ostream &stream, const TransformSVG &transform) const override
 
void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const override
 
virtual void accept (ShapeVisitor &visitor) override
 Accepts a visitor object.
 
virtual void accept (const ShapeVisitor &visitor) override
 Accepts a visitor object.
 
virtual void accept (ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object.
 
virtual void accept (const ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object.
 
virtual Shapeaccept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform.
 
Rect boundingBox (LineWidthFlag) const override
 
Ellipseclone () const override
 
void setCircleFlag ()
 
double perimeter () const
 
Path sampledPath (int n, SamplingStart start=SamplingFromRight) const
 
 Ellipse (const Ellipse &)=default
 
 Ellipse (Ellipse &&)=default
 
Ellipseoperator= (Ellipse &&)=default
 
Ellipseoperator= (const Ellipse &)=default
 
 ~Ellipse () override=default
 
- Public Member Functions inherited from LibBoard::ShapeWithStyle
 ShapeWithStyle (Color penColor, Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join)
 
 ShapeWithStyle (const Style &style)
 
 ShapeWithStyle (const ShapeWithStyle &other)
 
ShapeWithStyleoperator= (const ShapeWithStyle &other)
 
 ~ShapeWithStyle ()
 
const std::string & name () const
 
Shapeclone () const =0
 
const ColorpenColor () const
 
ShapeWithStylesetPenColor (const Color &)
 
const ColorfillColor () const
 
ShapeWithStylesetFillColor (const Color &)
 
double lineWidth () const
 
ShapeWithStylesetLineWidth (double)
 
LineStyle lineStyle () const
 
ShapeWithStylesetLineStyle (LineStyle)
 
LineCap lineCap () const
 
ShapeWithStylesetLineCap (LineCap)
 
LineJoin lineJoin () const
 
ShapeWithStylesetLineJoin (LineJoin)
 
Style style () const
 
ShapeWithStylesetStyle (const Style &)
 
bool filled () const
 
- Public Member Functions inherited from LibBoard::Shape
 Shape ()
 
virtual ~Shape ()
 
virtual const std::string & name () const
 
virtual Shapeclone () const =0
 
virtual Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const
 
virtual Shaperotate (double angle, const Point &center)=0
 
virtual Shaperotate (double angle)=0
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
virtual Shapetranslate (double dx, double dy)=0
 
ShapemoveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
ShapemoveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
virtual Shapescale (double sx, double sy)=0
 
virtual Shapescale (double s)=0
 
Shaperesize (double width, double height, LineWidthFlag lineWidthFlag)
 
ShapescaleToWidth (double w, LineWidthFlag lineWidthFlag)
 
ShapescaleToHeight (double h, LineWidthFlag lineWidthFlag)
 
virtual Rect boundingBox (LineWidthFlag) const =0
 
Rect bbox (LineWidthFlag) const
 
virtual void scaleAll (double s)=0
 
virtual void flushPostscript (std::ostream &stream, const TransformEPS &transform) const =0
 
virtual void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const =0
 
virtual void flushSVG (std::ostream &stream, const TransformSVG &transform) const =0
 
virtual void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const =0
 
virtual void accept (ShapeVisitor &visitor)
 Accepts a visitor object.
 
virtual void accept (const ShapeVisitor &visitor)
 Accepts a visitor object.
 
virtual void accept (ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object.
 
virtual void accept (const ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object.
 
virtual Shapeaccept (CompositeShapeTransform &transform) const
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const
 Accept a constant composite shape transform.
 
 Shape (const Shape &other)
 

Protected Attributes

Point _center
 
double _xRadius
 
double _yRadius
 
double _angle
 
bool _isCreatedAsCircle
 
- Protected Attributes inherited from LibBoard::ShapeWithStyle
Style _style
 

Additional Inherited Members

- Static Public Member Functions inherited from LibBoard::ShapeWithStyle
static void setLineWidthScaling (bool)
 
- Protected Member Functions inherited from LibBoard::ShapeWithStyle
void updateLineWidth (double s)
 

Detailed Description

An ellipse.

The ellipse structure.

Examples
examples/clipping.cpp, examples/ellipse.cpp, examples/example4.cpp, examples/rough.cpp, examples/scale_ellipse.cpp, examples/tilings.cpp, and examples/traversal.cpp.

Member Enumeration Documentation

◆ SamplingStart

Enumerator
SamplingFromRight 
SamplingFromTop 
SamplingFromLeft 
SamplingFromBottom 

Constructor & Destructor Documentation

◆ Ellipse() [1/5]

LibBoard::Ellipse::Ellipse ( double  x,
double  y,
double  xRadius,
double  yRadius,
Color  penColor = Style::defaultPenColor(),
Color  fillColor = Style::defaultFillColor(),
double  lineWidth = Style::defaultLineWidth(),
LineStyle  lineStyle = Style::defaultLineStyle() 
)
inline

◆ Ellipse() [2/5]

LibBoard::Ellipse::Ellipse ( Point  center,
double  xRadius,
double  yRadius,
Color  penColor = Style::defaultPenColor(),
Color  fillColor = Style::defaultFillColor(),
double  lineWidth = Style::defaultLineWidth(),
const LineStyle  lineStyle = Style::defaultLineStyle() 
)
inline

◆ Ellipse() [3/5]

LibBoard::Ellipse::Ellipse ( Point  center,
double  xRadius,
double  yRadius,
Style  style 
)
inline

◆ Ellipse() [4/5]

LibBoard::Ellipse::Ellipse ( const Ellipse )
default

◆ Ellipse() [5/5]

LibBoard::Ellipse::Ellipse ( Ellipse &&  )
default

◆ ~Ellipse()

LibBoard::Ellipse::~Ellipse ( )
overridedefault

Member Function Documentation

◆ accept() [1/6]

Shape * LibBoard::Ellipse::accept ( CompositeShapeTransform transform) const
overridevirtual

Accept a composite shape transform.

Parameters
transformA composite shape transform object.

Reimplemented from LibBoard::Shape.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [2/6]

Shape * LibBoard::Ellipse::accept ( const CompositeShapeTransform transform) const
overridevirtual

Accept a constant composite shape transform.

Parameters
transformA constant composite shape transform object..

Reimplemented from LibBoard::Shape.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [3/6]

void LibBoard::Ellipse::accept ( const ConstShapeVisitor visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [4/6]

void LibBoard::Ellipse::accept ( const ShapeVisitor visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ShapeVisitor::visit().

◆ accept() [5/6]

void LibBoard::Ellipse::accept ( ConstShapeVisitor visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [6/6]

void LibBoard::Ellipse::accept ( ShapeVisitor visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ShapeVisitor::visit().

◆ angle()

double LibBoard::Ellipse::angle ( ) const
inline

References _angle.

Referenced by LibBoard::hachures(), rotate(), rotate(), rotated(), and rotated().

◆ boundingBox()

Rect LibBoard::Ellipse::boundingBox ( LineWidthFlag  ) const
overridevirtual

Compute the bounding box of the figure.

Returns
The rectangle of the bounding box.

Implements LibBoard::Shape.

References _angle, _center, _xRadius, _yRadius, LibBoard::Rect::grow(), LibBoard::ShapeWithStyle::lineWidth(), M_PI, LibBoard::UseLineWidth, LibBoard::Point::x, and LibBoard::Point::y.

Referenced by LibBoard::hachures().

◆ center()

Point LibBoard::Ellipse::center ( LineWidthFlag  lineWidthFlag = IgnoreLineWidth) const
overridevirtual

Returns the center of the shape.

Parameters
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
The center of the shape, i.e. the center of its bounding box.

Reimplemented from LibBoard::Shape.

References _center.

Referenced by LibBoard::hachures(), rotate(), rotate(), rotated(), and rotated().

◆ clone()

Ellipse * LibBoard::Ellipse::clone ( ) const
overridevirtual

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::ShapeWithStyle.

Referenced by LibBoard::Board::drawCircle(), and LibBoard::Board::fillCircle().

◆ flushFIG()

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

◆ flushPostscript()

void LibBoard::Ellipse::flushPostscript ( std::ostream &  stream,
const TransformEPS transform 
) const
overridevirtual

◆ flushSVG()

void LibBoard::Ellipse::flushSVG ( std::ostream &  stream,
const TransformSVG transform 
) const
overridevirtual

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

References _angle, _center, LibBoard::ShapeWithStyle::_style, _xRadius, _yRadius, M_PI, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), LibBoard::Transform::scale(), LibBoard::Style::svgProperties(), LibBoard::Point::x, and LibBoard::Point::y.

◆ flushTikZ()

void LibBoard::Ellipse::flushTikZ ( std::ostream &  stream,
const TransformTikZ transform 
) const
overridevirtual

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

References _angle, _center, LibBoard::ShapeWithStyle::_style, _xRadius, _yRadius, M_PI, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), LibBoard::Transform::scale(), LibBoard::Style::tikzProperties(), LibBoard::Point::x, and LibBoard::Point::y.

◆ name()

const std::string & LibBoard::Ellipse::name ( ) const
overridevirtual

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

Returns

Reimplemented from LibBoard::Shape.

◆ operator=() [1/2]

Ellipse & LibBoard::Ellipse::operator= ( const Ellipse )
default

◆ operator=() [2/2]

Ellipse & LibBoard::Ellipse::operator= ( Ellipse &&  )
default

◆ perimeter()

double LibBoard::Ellipse::perimeter ( ) const

Estimated perimeter of the ellipse.

Returns
The estimated perimeter.

References _xRadius, _yRadius, and M_PI.

Referenced by LibBoard::RoughVisitor::map(), and sampledPath().

◆ resized()

Ellipse LibBoard::Ellipse::resized ( double  w,
double  h,
LineWidthFlag  lineWidthFlag 
) const

Returns a resized copy of the ellipse.

Parameters
wWidth of the new ellipse.
hHeight of the new ellipse.
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
A resized copy of the ellipse.

References LibBoard::Shape::resize().

◆ rotate() [1/2]

Ellipse & LibBoard::Ellipse::rotate ( double  angle)
overridevirtual

Rotate the shape around its center.

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

Implements LibBoard::Shape.

References angle(), center(), and rotate().

◆ rotate() [2/2]

Ellipse & LibBoard::Ellipse::rotate ( double  angle,
const Point center 
)
overridevirtual

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.

Implements LibBoard::Shape.

References _angle, _center, _xRadius, angle(), center(), rotate(), LibBoard::Point::rotated(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by ell(), LibBoard::hachures(), rotate(), rotate(), rotated(), rotated(), and rough().

◆ rotated() [1/2]

Ellipse LibBoard::Ellipse::rotated ( double  angle) const
Parameters
angle
Returns

References angle(), center(), and rotate().

◆ rotated() [2/2]

Ellipse LibBoard::Ellipse::rotated ( double  angle,
const Point center 
) const
Parameters
angle
center
Returns

References angle(), center(), and rotate().

Referenced by sampledPath().

◆ sampledPath()

Path LibBoard::Ellipse::sampledPath ( int  n,
SamplingStart  start = SamplingFromRight 
) const

Return uniformly sampled points along the ellipse (counterclockwise).

Parameters
nNumber of sample points
startPosition of the first point
Returns
A path of the samples points

References _angle, _center, _xRadius, _yRadius, LibBoard::Path::Closed, M_PI, LibBoard::Path::moveCenter(), perimeter(), LibBoard::Path::pop_back(), LibBoard::Path::push_back(), rotated(), SamplingFromBottom, SamplingFromLeft, SamplingFromRight, and SamplingFromTop.

Referenced by LibBoard::RoughVisitor::map().

◆ scale() [1/2]

Ellipse & LibBoard::Ellipse::scale ( double  s)
overridevirtual

Scale the ellipse, given a scaling factor.

Parameters
sScaling factor.
Returns
A reference to the ellipse itself, once scaled.

Implements LibBoard::Shape.

References scale().

◆ scale() [2/2]

Ellipse & LibBoard::Ellipse::scale ( double  sx,
double  sy 
)
overridevirtual

Scale the polyline, given two scaling factors.

Parameters
sxScaling factor along the x axis.
syScaling factor along the y axis.
Returns
A reference to the polyline itself, once scaled.

Implements LibBoard::Shape.

Examples
examples/example4.cpp.

References _angle, _xRadius, _yRadius, LibBoard::Tools::almostEqual(), M_PI, and LibBoard::ShapeWithStyle::updateLineWidth().

Referenced by main(), scale(), scaled(), and scaled().

◆ scaleAll()

void LibBoard::Ellipse::scaleAll ( double  s)
overridevirtual

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

Parameters
sThe scaling factor.

Implements LibBoard::Shape.

References _center, _xRadius, and _yRadius.

◆ scaled() [1/2]

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

Returns a scaled copy of the ellipse.

Parameters
sThe scaling factor.
Returns
A scaled copy of the ellipse.

References scale().

◆ scaled() [2/2]

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

Returns a scaled copy of the ellipse.

Parameters
sxThe scaling factor along the x axis.
syThe scaling factor along the y axis.
Returns
A scaled copy of the ellipse.

References scale().

◆ setCircleFlag()

void LibBoard::Ellipse::setCircleFlag ( )

Set flag to save the ellipse as a circle as soon as radii are equal.

References _isCreatedAsCircle.

Referenced by LibBoard::circle(), LibBoard::circle(), and LibBoard::circle().

◆ translate()

Ellipse & LibBoard::Ellipse::translate ( double  dx,
double  dy 
)
overridevirtual

Translate the ellipse by a given offset.

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

Implements LibBoard::Shape.

References _center.

Referenced by translated().

◆ translated()

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

Returns a translated copy of the ellipse.

Parameters
dxShift of the first coordinate.
dyShift of the second coordinate.
Returns
A copy of the ellipse, translated.
Examples
examples/graph.cpp.

References translate().

Referenced by main().

◆ xRadius()

double LibBoard::Ellipse::xRadius ( ) const
inline

References _xRadius.

Referenced by LibBoard::hachures().

◆ yRadius()

double LibBoard::Ellipse::yRadius ( ) const
inline

References _yRadius.

Referenced by LibBoard::hachures().

Member Data Documentation

◆ _angle

double LibBoard::Ellipse::_angle
protected

◆ _center

Point LibBoard::Ellipse::_center
protected

◆ _isCreatedAsCircle

bool LibBoard::Ellipse::_isCreatedAsCircle
protected

Referenced by setCircleFlag().

◆ _xRadius

double LibBoard::Ellipse::_xRadius
protected

◆ _yRadius

double LibBoard::Ellipse::_yRadius
protected

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