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

A line between two points. More...

#include <Shapes.h>

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

Public Member Functions

 Line (double x1, double y1, double x2, double y2, Color color, double lineWidth, const LineStyle style=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
 
const std::string & name () const
 
Point center () const
 
Linerotate (double angle, const Point &center)
 
Line rotated (double angle, const Point &center) const
 
Linerotate (double angle)
 
Line rotated (double angle) const
 
Linetranslate (double dx, double dy)
 
Line translated (double dx, double dy) const
 
Linescale (double sx, double sy)
 
Linescale (double s)
 
Line scaled (double sx, double sy) const
 
Line scaled (double s) const
 
void scaleAll (double s)
 
void flushPostscript (std::ostream &stream, const TransformEPS &transform) const
 
void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const
 
void flushSVG (std::ostream &stream, const TransformSVG &transform) const
 
void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const
 
Rect boundingBox () const
 
Lineclone () const
 
- Public Member Functions inherited from LibBoard::Shape
 Shape (Color penColor, 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)
 
ShapemoveCenter (double x, double y)
 
ShapemoveCenter (Point p)
 
Rect bbox () const
 
Shapeoperator-- ()
 
Shapeoperator++ ()
 
int depth () const
 
virtual void depth (int)
 
virtual void shiftDepth (int shift)
 
const ColorpenColor () const
 
const ColorfillColor () const
 

Protected Attributes

double _x1
 
double _y1
 
double _x2
 
double _y2
 
- Protected Attributes inherited from LibBoard::Shape
int _depth
 
Color _penColor
 
Color _fillColor
 
double _lineWidth
 
LineStyle _lineStyle
 
LineCap _lineCap
 
LineJoin _lineJoin
 

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
 
std::string tikzProperties (const TransformTikZ &transform) const
 

Detailed Description

A line between two points.

The line structure.

Examples:
examples/ellipse.cpp, examples/example4.cpp, examples/flag.cpp, examples/koch.cpp, examples/logo.cpp, and examples/ruler.cpp.

Constructor & Destructor Documentation

LibBoard::Line::Line ( double  x1,
double  y1,
double  x2,
double  y2,
Color  color,
double  lineWidth,
const LineStyle  style = SolidStyle,
const LineCap  cap = ButtCap,
const LineJoin  join = MiterJoin,
int  depth = -1 
)
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.
depthThe depth of the line.

Referenced by clone().

Member Function Documentation

Rect LibBoard::Line::boundingBox ( ) const
virtual

Compute the bounding box of the figure.

Returns
The rectangle of the bounding box.

Implements LibBoard::Shape.

References _x1, _x2, _y1, _y2, LibBoard::Rect::height, LibBoard::Rect::left, LibBoard::Rect::top, and LibBoard::Rect::width.

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

Returns the center of the shape.

Returns
The center of the shape, i.e. the center of its bounding box.

Reimplemented from LibBoard::Shape.

References _x1, _x2, _y1, and _y2.

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

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

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References Line().

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

Write the FIG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

References LibBoard::Shape::_depth, LibBoard::Shape::_lineCap, LibBoard::Shape::_lineJoin, LibBoard::Shape::_lineStyle, LibBoard::Shape::_lineWidth, LibBoard::Shape::_penColor, _x1, _x2, _y1, and _y2.

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

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.

Reimplemented in LibBoard::Arrow.

References LibBoard::Shape::_penColor, _x1, _x2, _y1, _y2, and LibBoard::Shape::postscriptProperties().

void LibBoard::Line::flushSVG ( std::ostream &  stream,
const TransformSVG transform 
) const
virtual

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.

Reimplemented in LibBoard::Arrow.

References _x1, _x2, _y1, _y2, and LibBoard::Shape::svgProperties().

void LibBoard::Line::flushTikZ ( std::ostream &  stream,
const TransformTikZ transform 
) const
virtual

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.

Reimplemented in LibBoard::Arrow.

References _x1, _x2, _y1, _y2, and LibBoard::Shape::tikzProperties().

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

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

Returns

Reimplemented from LibBoard::Shape.

Reimplemented in LibBoard::Arrow.

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

Implements LibBoard::Shape.

Examples:
examples/flag.cpp.

References _x1, _x2, _y1, _y2, LibBoard::Point::get(), and LibBoard::Point::rotate().

Referenced by rotate().

Line & LibBoard::Line::rotate ( double  angle)
virtual

Rotate the shape around its center.

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

Implements LibBoard::Shape.

References center(), and rotate().

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 _x1, _x2, _y1, _y2, LibBoard::Point::get(), and LibBoard::Point::rotate().

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 _x1, _x2, _y1, _y2, center(), LibBoard::Point::get(), and LibBoard::Point::rotate().

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

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.

References _x1, _x2, _y1, _y2, center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by scale().

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

Scale the line, given a scaling factor.

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

Implements LibBoard::Shape.

References scale().

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

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

Parameters
sThe scaling factor.

Implements LibBoard::Shape.

References _x1, _x2, _y1, and _y2.

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 _x1, _x2, _y1, _y2, center(), translate(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by scaled().

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

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

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 _x1, _x2, _y1, and _y2.

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

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 _x1, _x2, _y1, and _y2.

Member Data Documentation

double LibBoard::Line::_x1
protected
double LibBoard::Line::_x2
protected
double LibBoard::Line::_y1
protected
double LibBoard::Line::_y2
protected

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