Chemical Data Processing Library C++ API - Version 1.1.1
Public Types | Public Member Functions | List of all members
CDPL::Vis::LinePrimitive2D Class Reference

A graphics primitive representing a single line. More...

#include <LinePrimitive2D.hpp>

+ Inheritance diagram for CDPL::Vis::LinePrimitive2D:

Public Types

typedef std::shared_ptr< LinePrimitive2DSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated LinePrimitive2D instances. More...
 
- Public Types inherited from CDPL::Vis::GraphicsPrimitive2D
typedef std::shared_ptr< GraphicsPrimitive2DSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated GraphicsPrimitive2D instances. More...
 

Public Member Functions

 LinePrimitive2D ()
 Constructs a line primitive whose starting and end point is set to (0, 0). More...
 
 LinePrimitive2D (const Math::Vector2D &beg, const Math::Vector2D &end)
 Constructs a line primitive with the starting point set to beg and the end point set to end. More...
 
 LinePrimitive2D (const Line2D &line)
 Constructs a line primitive with the same starting and end point as line. More...
 
void render (Renderer2D &renderer) const
 Visualizes the graphics primitive by means of the Renderer2D instance renderer. More...
 
void setPen (const Pen &pen)
 Sets the pen defining the color, width, line style and cap style of the line. More...
 
const PengetPen () const
 Returns the pen defining the color, width, line style and cap style of the line. More...
 
GraphicsPrimitive2D::SharedPointer clone () const
 Creates a dynamically allocated copy of the graphics primitive. More...
 
void getBounds (Rectangle2D &bounds, FontMetrics *font_metrics=0) const
 Calculates the bounds of the graphics primitive. More...
 
- Public Member Functions inherited from CDPL::Vis::Line2D
 Line2D ()
 Constructs a line whose starting and end point is set to (0, 0). More...
 
 Line2D (const Math::Vector2D &beg, const Math::Vector2D &end)
 Constructs a line with the specified starting and end point. More...
 
 Line2D (double beg_x, double beg_y, double end_x, double end_y)
 Constructs a line with the starting point set to (beg_x, beg_y) and the end point set to (end_x, end_y). More...
 
virtual ~Line2D ()
 Virtual destructor. More...
 
void setBegin (const Math::Vector2D &pt)
 Sets the starting point of the line to pt. More...
 
void setBegin (double x, double y)
 Sets the starting point of the line to (x, y). More...
 
const Math::Vector2DgetBegin () const
 Returns the starting point of the line. More...
 
void setEnd (const Math::Vector2D &pt)
 Sets the end point of the line to pt. More...
 
void setEnd (double x, double y)
 Sets the end point of the line to (x, y). More...
 
const Math::Vector2DgetEnd () const
 Returns the end point of the line. More...
 
void setPoints (double beg_x, double beg_y, double end_x, double end_y)
 Sets the starting point of the line to (beg_x, beg_y) and the end point to (end_x, end_y). More...
 
void setPoints (const Math::Vector2D &beg, const Math::Vector2D &end)
 Sets the starting point of the line to beg and the end point to end. More...
 
void swapPoints ()
 Swaps the starting and end point of the line. More...
 
void getDirection (Math::Vector2D &dir) const
 Calculates the normalized direction vector of the line and stores the result in dir. More...
 
Math::Vector2D getDirection () const
 Calculates the normalized direction vector of the line. More...
 
void getCCWPerpDirection (Math::Vector2D &dir) const
 Calculates the normalized direction vector rotated by 90 degrees in counter-clockwise direction and stores the result in dir. More...
 
Math::Vector2D getCCWPerpDirection () const
 Calculates the normalized direction vector rotated by 90 degrees in counter-clockwise direction. More...
 
void getCWPerpDirection (Math::Vector2D &dir) const
 Calculates the normalized direction vector rotated by 90 degrees in clockwise direction and stores the result in dir. More...
 
Math::Vector2D getCWPerpDirection () const
 Calculates the normalized direction vector rotated by 90 degrees in clockwise direction. More...
 
void getCenter (Math::Vector2D &ctr) const
 Calculates the center point of the line and stores the result in ctr. More...
 
Math::Vector2D getCenter () const
 Calculates the center point of the line. More...
 
double getLength () const
 Returns the length of the line segment. More...
 
void translate (const Math::Vector2D &vec)
 Translates the starting and end point of the line by vec. More...
 
void translateBegin (const Math::Vector2D &vec)
 Translates the starting point of the line by vec. More...
 
void translateEnd (const Math::Vector2D &vec)
 Translates the end of the line point by vec. More...
 
bool containsPoint (const Math::Vector2D &pt) const
 Tests if the point pt is contained within the boundary of the line segment. More...
 
bool getIntersectionPoint (const Line2D &line, Math::Vector2D &pt) const
 Calculates the point of intersection with the specified line and stores the result in pt. More...
 
bool clipBeginAgainstLineSeg (const Line2D &line)
 Sets the starting point of the line to the point of intersection with the specified line segment. More...
 
bool clipEndAgainstLineSeg (const Line2D &line)
 Sets the end point of the line to the point of intersection with the specified line segment. More...
 
bool setBeginToLineSegIntersection (const Line2D &line)
 Sets the starting point of the line to the point of intersection with the specified line segment. More...
 
bool setEndToLineSegIntersection (const Line2D &line)
 Sets the end point of the line to the point of intersection with the specified line segment. More...
 
bool clipBeginAgainstRectangle (const Rectangle2D &rect)
 Sets the starting point of the line to the point of intersection between this line segment and the edges of the rectangle rect. More...
 
bool clipEndAgainstRectangle (const Rectangle2D &rect)
 Sets the end point of the line to the point of intersection between this line segment and the edges of the rectangle rect. More...
 
double getDistance (const Math::Vector2D &pt) const
 Returns the perpendicular distance of the point pt to this line. More...
 
bool operator== (const Line2D &line) const
 Equality comparison operator. More...
 
bool operator!= (const Line2D &line) const
 Inequality comparison operator. More...
 
- Public Member Functions inherited from CDPL::Vis::GraphicsPrimitive2D
virtual ~GraphicsPrimitive2D ()
 Virtual destructor. More...
 

Detailed Description

A graphics primitive representing a single line.

Member Typedef Documentation

◆ SharedPointer

A reference-counted smart pointer [SHPTR] for dynamically allocated LinePrimitive2D instances.

Constructor & Destructor Documentation

◆ LinePrimitive2D() [1/3]

CDPL::Vis::LinePrimitive2D::LinePrimitive2D ( )
inline

Constructs a line primitive whose starting and end point is set to (0, 0).

◆ LinePrimitive2D() [2/3]

CDPL::Vis::LinePrimitive2D::LinePrimitive2D ( const Math::Vector2D beg,
const Math::Vector2D end 
)
inline

Constructs a line primitive with the starting point set to beg and the end point set to end.

Parameters
begThe starting point.
endThe end point.

◆ LinePrimitive2D() [3/3]

CDPL::Vis::LinePrimitive2D::LinePrimitive2D ( const Line2D line)
inlineexplicit

Constructs a line primitive with the same starting and end point as line.

Parameters
lineThe line defining the starting and end point.

Member Function Documentation

◆ render()

void CDPL::Vis::LinePrimitive2D::render ( Renderer2D renderer) const
virtual

Visualizes the graphics primitive by means of the Renderer2D instance renderer.

Parameters
rendererThe renderer that performs the drawing operations.

Implements CDPL::Vis::GraphicsPrimitive2D.

◆ setPen()

void CDPL::Vis::LinePrimitive2D::setPen ( const Pen pen)

Sets the pen defining the color, width, line style and cap style of the line.

Parameters
penThe pen defining the color, width, line style and cap style.

◆ getPen()

const Pen& CDPL::Vis::LinePrimitive2D::getPen ( ) const

Returns the pen defining the color, width, line style and cap style of the line.

Returns
The pen defining the color, width, line style and cap style of the line.

◆ clone()

GraphicsPrimitive2D::SharedPointer CDPL::Vis::LinePrimitive2D::clone ( ) const
virtual

Creates a dynamically allocated copy of the graphics primitive.

Returns
The copy of the graphics primitive.

Implements CDPL::Vis::GraphicsPrimitive2D.

◆ getBounds()

void CDPL::Vis::LinePrimitive2D::getBounds ( Rectangle2D bounds,
FontMetrics font_metrics = 0 
) const
virtual

Calculates the bounds of the graphics primitive.

Parameters
boundsThe object storing the calculated bounding box.
font_metricsThe font metrics object to use for bounds calculation (if required).

Implements CDPL::Vis::GraphicsPrimitive2D.


The documentation for this class was generated from the following file: