Board 0.9.6
Public Types | Public Member Functions | List of all members
LibBoard::Arrow Struct Reference

A line between two points with an arrow at one extremity. More...

#include <Arrow.h>

Inheritance diagram for LibBoard::Arrow:
LibBoard::Line LibBoard::ShapeWithStyle LibBoard::Shape

Public Types

enum class  ExtremityType { Stick , Closed , Plain }
 The ExtremityType enum. More...
 

Public Member Functions

 Arrow (double x1, double y1, double x2, double y2, ExtremityType type=ExtremityType::Plain, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle(), const LineCap cap=Style::defaultLineCap(), const LineJoin join=Style::defaultLineJoin())
 
 Arrow (double x1, double y1, double x2, double y2, ExtremityType type, const Style &style)
 
 Arrow (Point p1, Point p2, ExtremityType type=ExtremityType::Plain, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle(), const LineCap cap=Style::defaultLineCap(), const LineJoin join=Style::defaultLineJoin())
 
 Arrow (Point p1, Point p2, ExtremityType type, const Style &style)
 
const std::string & name () const override
 
Arrow rotated (double angle, const Point &center) const
 
Arrow rotated (double angle) const
 
Arrow translated (double dx, double dy) const
 
Arrow scaled (double sx, double sy) const
 
Arrow scaled (double s) const
 
Arrow resized (double w, double h, LineWidthFlag lineWidthFlag) const
 
Rect boundingBox (LineWidthFlag) const override
 
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 Shape * accept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform.
 
virtual Shape * accept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform.
 
Arrow * clone () const override
 
Path extremity () const
 
 Arrow (const Arrow &)=default
 
 Arrow (Arrow &&)=default
 
Arrow & operator= (Arrow &&)=default
 
Arrow & operator= (const Arrow &)=default
 
 ~Arrow () override=default
 
ExtremityType type () const
 The extremity type of the arrow.
 
- Public Member Functions inherited from LibBoard::Line
 Line (double x1, double y1, double x2, double y2, Color color, double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle(), const LineCap cap=Style::defaultLineCap(), const LineJoin join=Style::defaultLineJoin())
 
 Line (double x1, double y1, double x2, double y2, const Style &style)
 
 Line (Point a, Point b, Color color, double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle(), const LineCap cap=Style::defaultLineCap(), const LineJoin join=Style::defaultLineJoin())
 
 Line (Point a, Point b, const Style &style)
 
const std::string & name () const override
 
Line & rotate (double angle, const Point &center) override
 
Line rotated (double angle, const Point &center) const
 
Line & rotate (double angle) override
 
Line rotated (double angle) const
 
Line & translate (double dx, double dy) override
 
Line translated (double dx, double dy) const
 
Line & scale (double sx, double sy) override
 
Line & scale (double s) override
 
Line scaled (double sx, double sy) const
 
Line scaled (double s) const
 
void scaleAll (double s) override
 
Line resized (double w, double h, LineWidthFlag lineWidthFlag) const
 
Rect boundingBox (LineWidthFlag) const override
 
Line * clone () const override
 
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 Shape * accept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform.
 
virtual Shape * accept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform.
 
const Point & a () const
 
const Point & b () const
 
 Line (const Line &other)
 
 Line (Line &&)=default
 
Line & operator= (const Line &line)
 
 ~Line () 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)
 
ShapeWithStyle & operator= (const ShapeWithStyle &other)
 
 ~ShapeWithStyle ()
 
const std::string & name () const
 
Shape * clone () const =0
 
const Color & penColor () const
 
ShapeWithStyle & setPenColor (const Color &)
 
const Color & fillColor () const
 
ShapeWithStyle & setFillColor (const Color &)
 
double lineWidth () const
 
ShapeWithStyle & setLineWidth (double)
 
LineStyle lineStyle () const
 
ShapeWithStyle & setLineStyle (LineStyle)
 
LineCap lineCap () const
 
ShapeWithStyle & setLineCap (LineCap)
 
LineJoin lineJoin () const
 
ShapeWithStyle & setLineJoin (LineJoin)
 
Style style () const
 
ShapeWithStyle & setStyle (const Style &)
 
bool filled () const
 
- Public Member Functions inherited from LibBoard::Shape
 Shape ()
 
virtual ~Shape ()
 
virtual const std::string & name () const
 
virtual Shape * clone () const =0
 
virtual Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const
 
virtual Shape & rotate (double angle, const Point &center)=0
 
virtual Shape & rotate (double angle)=0
 
Shape & rotateDeg (double angle, const Point &center)
 
Shape & rotateDeg (double angle)
 
virtual Shape & translate (double dx, double dy)=0
 
Shape & moveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
Shape & moveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
virtual Shape & scale (double sx, double sy)=0
 
virtual Shape & scale (double s)=0
 
Shape & resize (double width, double height, LineWidthFlag lineWidthFlag)
 
Shape & scaleToWidth (double w, LineWidthFlag lineWidthFlag)
 
Shape & scaleToHeight (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 Shape * accept (CompositeShapeTransform &transform) const
 Accept a composite shape transform.
 
virtual Shape * accept (const CompositeShapeTransform &transform) const
 Accept a constant composite shape transform.
 
 Shape (const Shape &other)
 

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)
 
- Protected Attributes inherited from LibBoard::Line
Point _a
 
Point _b
 
- Protected Attributes inherited from LibBoard::ShapeWithStyle
Style _style
 

Detailed Description

A line between two points with an arrow at one extremity.

The arrow structure.

Examples
examples/graph.cpp, examples/rough.cpp, examples/test_arrow.cpp, and examples/xkcd.cpp.

Member Enumeration Documentation

◆ ExtremityType

enum class LibBoard::Arrow::ExtremityType
strong

The ExtremityType enum.

Enumerator
Stick 

Two lines

Closed 

Closed triangle (pen color, white filled)

Plain 

Plain triangle (with pen color)

Constructor & Destructor Documentation

◆ Arrow() [1/6]

LibBoard::Arrow::Arrow ( double  x1,
double  y1,
double  x2,
double  y2,
ExtremityType  type = ExtremityType::Plain,
Color  penColor = Style::defaultPenColor(),
Color  fillColor = Style::defaultFillColor(),
double  lineWidth = Style::defaultLineWidth(),
const LineStyle  lineStyle = Style::defaultLineStyle(),
const LineCap  cap = Style::defaultLineCap(),
const LineJoin  join = Style::defaultLineJoin() 
)
inline

Constructs an arrow.

Parameters
x1First coordinate of the start point.
y1Second coordinate of the start point.
x2First coordinate of the end point.
y2Second coordinate of the end point.
typeArrow type.
penColorThe color of the line.
fillColorThe fill color of the sharp end.
lineWidthThe line thickness.
lineStyleThe line style.
capThe line cap.
joinThe line join.

References LibBoard::ShapeWithStyle::_style, LibBoard::ShapeWithStyle::fillColor(), LibBoard::Style::fillColor, LibBoard::Color::Null, and LibBoard::ShapeWithStyle::penColor().

◆ Arrow() [2/6]

LibBoard::Arrow::Arrow ( double  x1,
double  y1,
double  x2,
double  y2,
ExtremityType  type,
const Style &  style 
)
inline

Constructs an arrow.

Parameters
x1First coordinate of the start point.
y1Second coordinate of the start point.
x2First coordinate of the end point.
y2Second coordinate of the end point.
typeArrow type.
styleThe shape style.

References LibBoard::ShapeWithStyle::_style, LibBoard::Style::fillColor, LibBoard::Color::Null, LibBoard::Style::penColor, and LibBoard::ShapeWithStyle::style().

◆ Arrow() [3/6]

LibBoard::Arrow::Arrow ( Point  p1,
Point  p2,
ExtremityType  type = ExtremityType::Plain,
Color  penColor = Style::defaultPenColor(),
Color  fillColor = Style::defaultFillColor(),
double  lineWidth = Style::defaultLineWidth(),
const LineStyle  lineStyle = Style::defaultLineStyle(),
const LineCap  cap = Style::defaultLineCap(),
const LineJoin  join = Style::defaultLineJoin() 
)
inline

Constructs an arrow.

Parameters
p1Start point.
p2End point.
typeArrow type.
penColorThe color of the line.
fillColorThe fill color of the sharp end.
lineWidthThe line thickness.
lineStyleThe line style.
capThe line cap.
joinThe line join.

References LibBoard::ShapeWithStyle::_style, LibBoard::ShapeWithStyle::fillColor(), LibBoard::Style::fillColor, LibBoard::Color::Null, and LibBoard::ShapeWithStyle::penColor().

◆ Arrow() [4/6]

LibBoard::Arrow::Arrow ( Point  p1,
Point  p2,
ExtremityType  type,
const Style &  style 
)
inline

Constructs an arrow.

Parameters
p1Start point.
p2End point.
typeArrow type.
styleThe shape style.

References LibBoard::ShapeWithStyle::_style, LibBoard::Style::fillColor, LibBoard::Color::Null, LibBoard::Style::penColor, and LibBoard::ShapeWithStyle::style().

◆ Arrow() [5/6]

LibBoard::Arrow::Arrow ( const Arrow &  )
default

◆ Arrow() [6/6]

LibBoard::Arrow::Arrow ( Arrow &&  )
default

◆ ~Arrow()

LibBoard::Arrow::~Arrow ( )
overridedefault

Member Function Documentation

◆ accept() [1/6]

Shape * LibBoard::Arrow::accept ( CompositeShapeTransform &  transform) const
overridevirtual

Accept a composite shape transform.

Parameters
transformA composite shape transform object.

Reimplemented from LibBoard::Line.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [2/6]

Shape * LibBoard::Arrow::accept ( const CompositeShapeTransform &  transform) const
overridevirtual

Accept a constant composite shape transform.

Parameters
transformA constant composite shape transform object..

Reimplemented from LibBoard::Line.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [3/6]

void LibBoard::Arrow::accept ( const ConstShapeVisitor &  visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Line.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [4/6]

void LibBoard::Arrow::accept ( const ShapeVisitor &  visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Line.

References LibBoard::ShapeVisitor::visit().

◆ accept() [5/6]

void LibBoard::Arrow::accept ( ConstShapeVisitor &  visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Line.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [6/6]

void LibBoard::Arrow::accept ( ShapeVisitor &  visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Line.

References LibBoard::ShapeVisitor::visit().

◆ boundingBox()

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

◆ clone()

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

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::ShapeWithStyle.

◆ extremity()

Path LibBoard::Arrow::extremity ( ) const

◆ flushFIG()

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

◆ flushPostscript()

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

◆ flushSVG()

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

◆ flushTikZ()

void LibBoard::Arrow::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 LibBoard::Line::_a, LibBoard::Line::_b, LibBoard::ShapeWithStyle::_style, LibBoard::Line::a(), LibBoard::Line::b(), LibBoard::Transform::map(), LibBoard::Style::tikzProperties(), LibBoard::Point::x, and LibBoard::Point::y.

◆ name()

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

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

Returns

Reimplemented from LibBoard::Shape.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ resized()

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

Returns a resized copy of the arrow.

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

References LibBoard::Shape::resize().

◆ rotated() [1/2]

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

Returns a copy of the arrow, rotated around its center.

Parameters
angleThe angle of rotation.
Returns
A copy of the lines, rotated around its center by the given angle.

References LibBoard::Line::rotate().

◆ rotated() [2/2]

Arrow LibBoard::Arrow::rotated ( double  angle,
const Point &  center 
) const

Returns a copy of the arrow, rotated around a given rotation center.

Parameters
angleThe rotation angle.
centerThe center of rotation.
Returns
The rotated copy of the line.

References LibBoard::Shape::center(), and LibBoard::Line::rotate().

◆ scaled() [1/2]

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

Returns a scaled copy of the arrow.

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

References scaled().

◆ scaled() [2/2]

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

Returns a scaled copy of the arrow.

Parameters
sxScaling factor along the x axis.
syscaling factor along the y axis.
Returns
A scaled copy of the arrow.

References LibBoard::Line::scale().

Referenced by scaled().

◆ translated()

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

Returns a translated copy of the arrow.

Parameters
dxThe shift along the x axis.
dyThe shift along the y axis.
Returns
A translated copy of the line.
Examples
examples/test_arrow.cpp.

References LibBoard::Line::translate().

Referenced by main().

◆ type()

Arrow::ExtremityType LibBoard::Arrow::type ( ) const
inline

The extremity type of the arrow.

Returns
The extremity type of the arrow

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


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