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

A line between two points. More...

#include <Line.h>

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

Public Member Functions

 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
 
Linerotate (double angle, const Point &center) override
 
Line rotated (double angle, const Point &center) const
 
Linerotate (double angle) override
 
Line rotated (double angle) const
 
Linetranslate (double dx, double dy) override
 
Line translated (double dx, double dy) const
 
Linescale (double sx, double sy) override
 
Linescale (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
 
Lineclone () 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 Shapeaccept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform.
 
const Pointa () const
 
const Pointb () const
 
 Line (const Line &other)
 
 Line (Line &&)=default
 
Lineoperator= (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)
 
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 _a
 
Point _b
 
- 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

A line between two points.

The line structure.

Examples
examples/Julia.cpp, examples/board_font_text.cpp, examples/ellipse.cpp, examples/example4.cpp, examples/flag.cpp, examples/holes.cpp, examples/interpolate.cpp, examples/logo.cpp, examples/rough.cpp, examples/ruler.cpp, examples/stroke_path.cpp, examples/tilings.cpp, examples/traversal.cpp, and examples/xkcd.cpp.

Constructor & Destructor Documentation

◆ Line() [1/6]

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

Constructs a line.

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.
colorThe color of the line.
lineWidthThe line thickness.
lineStyleThe line style.
capThe line cap.
joinThe line join.

◆ Line() [2/6]

LibBoard::Line::Line ( double  x1,
double  y1,
double  x2,
double  y2,
const Style style 
)
inline

Constructs a line.

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.
styleThe shape style.

◆ Line() [3/6]

LibBoard::Line::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() 
)
inline

Constructs a line.

Parameters
aFirst extremity.
bSecond extremity.
colorThe color of the line.
lineWidthThe line thickness.
lineStyleThe line style.
capThe line cap.
joinThe line join.

◆ Line() [4/6]

LibBoard::Line::Line ( Point  a,
Point  b,
const Style style 
)
inline

Constructs a line.

Parameters
aFirst extremity.
bSecond extremity.
styleThe shape style.

◆ Line() [5/6]

LibBoard::Line::Line ( const Line other)

◆ Line() [6/6]

LibBoard::Line::Line ( Line &&  )
default

◆ ~Line()

LibBoard::Line::~Line ( )
overridedefault

Member Function Documentation

◆ a()

const Point & LibBoard::Line::a ( ) const
inline

The first extremity of the line.

Returns
The first extremity of the line.

References _a.

Referenced by LibBoard::Arrow::flushFIG(), flushFIG(), flushPostscript(), flushSVG(), LibBoard::Arrow::flushTikZ(), flushTikZ(), LibBoard::RoughVisitor::map(), and LibBoard::RoughVisitor::map().

◆ accept() [1/6]

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

Accept a composite shape transform.

Parameters
transformA composite shape transform object.

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [2/6]

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

Accept a constant composite shape transform.

Parameters
transformA constant composite shape transform object..

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [3/6]

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

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [4/6]

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

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References LibBoard::ShapeVisitor::visit().

◆ accept() [5/6]

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

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [6/6]

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

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

Examples
examples/rough.cpp.

References LibBoard::ShapeVisitor::visit().

Referenced by slide().

◆ b()

const Point & LibBoard::Line::b ( ) const
inline

The second extremity of the line.

Returns
The second extremity of the line.

References _b.

Referenced by LibBoard::Arrow::flushFIG(), flushFIG(), flushPostscript(), flushSVG(), LibBoard::Arrow::flushTikZ(), flushTikZ(), LibBoard::RoughVisitor::map(), and LibBoard::RoughVisitor::map().

◆ boundingBox()

Rect LibBoard::Line::boundingBox ( LineWidthFlag  lineWidthFlag) const
overridevirtual

◆ clone()

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

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::ShapeWithStyle.

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

◆ flushFIG()

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

◆ flushPostscript()

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

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

References _a, _b, LibBoard::ShapeWithStyle::_style, a(), b(), LibBoard::Transform::map(), LibBoard::ShapeWithStyle::penColor(), LibBoard::Color::postscript(), LibBoard::Style::postscriptProperties(), LibBoard::Point::x, and LibBoard::Point::y.

◆ flushSVG()

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

Referenced by LibBoard::Arrow::flushSVG().

◆ flushTikZ()

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

◆ name()

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

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

Returns

Reimplemented from LibBoard::Shape.

◆ operator=()

Line & LibBoard::Line::operator= ( const Line line)

References _a, and _b.

◆ resized()

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

Returns a resized copy of the line.

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

References LibBoard::Shape::resize().

◆ rotate() [1/2]

Line & LibBoard::Line::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 LibBoard::Shape::center(), and rotate().

◆ rotate() [2/2]

Line & LibBoard::Line::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.

Examples
examples/flag.cpp.

References _a, _b, LibBoard::Shape::center(), and LibBoard::Point::rotated().

Referenced by main(), rotate(), LibBoard::Arrow::rotated(), and LibBoard::Arrow::rotated().

◆ rotated() [1/2]

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

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

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

References _a, _b, LibBoard::Shape::center(), and LibBoard::Point::rotated().

◆ rotated() [2/2]

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

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

Parameters
angleThe rotation angle.
centerThe center of rotation.
Returns
The rotated copy of the line.
Examples
examples/logo.cpp.

References _a, _b, LibBoard::Shape::center(), and LibBoard::Point::rotated().

Referenced by main().

◆ scale() [1/2]

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

Scale the line, given a scaling factor.

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

Implements LibBoard::Shape.

References scale().

◆ scale() [2/2]

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

Scale the line, given two scaling factors.

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

Implements LibBoard::Shape.

Examples
examples/stroke_path.cpp.

References _a, _b, LibBoard::Shape::center(), translate(), LibBoard::ShapeWithStyle::updateLineWidth(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by scale(), LibBoard::Arrow::scaled(), scaled(), and strikeOut().

◆ scaleAll()

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

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

Parameters
sThe scaling factor.

Implements LibBoard::Shape.

References _a, _b, LibBoard::Point::x, and LibBoard::Point::y.

◆ scaled() [1/2]

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

Returns a scaled copy of the line.

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

References scaled().

◆ scaled() [2/2]

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

Returns a scaled copy of the line.

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

References scale().

Referenced by scaled().

◆ translate()

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

Translate the line by a given offset.

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

Implements LibBoard::Shape.

Examples
examples/ruler.cpp.

References _a, _b, and LibBoard::Point::translate().

Referenced by LibBoard::grid(), main(), scale(), and LibBoard::Arrow::translated().

◆ translated()

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

Returns a translated copy of the line.

Parameters
dxThe shift along the x axis.
dyThe shift along the y axis.
Returns
A translated copy of the line.

References _a, _b, and LibBoard::Point::translate().

Member Data Documentation

◆ _a

Point LibBoard::Line::_a
protected

◆ _b

Point LibBoard::Line::_b
protected

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