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

Specifies how to draw lines and outlines of shapes. More...

#include <Pen.hpp>

Public Types

enum  LineStyle {
  NO_LINE,
  SOLID_LINE,
  DASH_LINE,
  DOT_LINE,
  DASH_DOT_LINE,
  DASH_DOT_DOT_LINE
}
 Defines constants for supported line styles. More...
 
enum  CapStyle {
  FLAT_CAP,
  SQUARE_CAP,
  ROUND_CAP
}
 Defines constants for supported line cap styles. More...
 
enum  JoinStyle {
  MITER_JOIN,
  BEVEL_JOIN,
  ROUND_JOIN
}
 Defines constants for supported line join styles. More...
 

Public Member Functions

 Pen ()
 Constructs a pen with line style Pen::SOLID_LINE, line width 1.0, cap style Pen::ROUND_CAP, join style Pen::ROUND_JOIN and color Color::BLACK. More...
 
 Pen (LineStyle line_style)
 Constructs a pen with the specified line style, line width 1.0, cap style Pen::ROUND_CAP, join style Pen::ROUND_JOIN and color Color::BLACK. More...
 
 Pen (const Color &color, double width=1.0, LineStyle line_style=SOLID_LINE, CapStyle cap_style=ROUND_CAP, JoinStyle join_style=ROUND_JOIN)
 Constructs a pen with the specified color, line width, line style, cap style and join style. More...
 
void setLineStyle (LineStyle line_style)
 Sets the line style to line_style. More...
 
LineStyle getLineStyle () const
 Returns the line style. More...
 
void setWidth (double width)
 Sets the line width to the specified value. More...
 
double getWidth () const
 Returns the line width. More...
 
void setColor (const Color &color)
 Sets the pen's color to the specified value. More...
 
const ColorgetColor () const
 Returns the color of the pen. More...
 
void setCapStyle (CapStyle cap_style)
 Sets the line cap style to cap_style. More...
 
CapStyle getCapStyle () const
 Returns the line cap style. More...
 
void setJoinStyle (JoinStyle join_style)
 Sets the line join style to join_style. More...
 
JoinStyle getJoinStyle () const
 Returns the line join style. More...
 
bool operator== (const Pen &pen) const
 Equality comparison operator. More...
 
bool operator!= (const Pen &pen) const
 Inequality comparison operator. More...
 

Detailed Description

Specifies how to draw lines and outlines of shapes.

A pen has a line style, width, color, cap style and join style attribute. The line style specifies how a line will look like (solid, dashed, ...). The default line style is Pen::SOLID_LINE. Setting the line style to Pen::NO_LINE tells the renderer not to draw lines or outlines. The pen color defines the color of lines and text. The default line color is Color::BLACK. The cap style specifies how the end points of lines are drawn and the join style defines how the joins between two or more connected have to be drawn. The default cap style is Pen::ROUND_CAP and the default join style is Pen::ROUND_JOIN.

Member Enumeration Documentation

◆ LineStyle

Defines constants for supported line styles.

Enumerator
NO_LINE 

Tells the renderer not to draw lines or shape outlines.

SOLID_LINE 

Specifies a solid line without gaps.

DASH_LINE 

Specifies a dashed line.

DOT_LINE 

Specifies a dotted line.

DASH_DOT_LINE 

Specifies a line with alternating dots and dashes.

DASH_DOT_DOT_LINE 

Specifies a line with dashes that are followed by two dots.

◆ CapStyle

Defines constants for supported line cap styles.

Enumerator
FLAT_CAP 

Specifies a squared line end that does not cover the end point of the line.

SQUARE_CAP 

Specifies a squared line end that covers the end point and extends beyond it with half the line width.

ROUND_CAP 

Specifies a rounded line end.

◆ JoinStyle

Defines constants for supported line join styles.

Enumerator
MITER_JOIN 

Specifies a join style where the outer edges of the lines are extended to meet at an angle, and this area is filled.

BEVEL_JOIN 

Specifies a join style where the triangular notch between the two lines is filled.

ROUND_JOIN 

Specifies a join style where the circular arc between the two lines is filled.

Constructor & Destructor Documentation

◆ Pen() [1/3]

CDPL::Vis::Pen::Pen ( )

Constructs a pen with line style Pen::SOLID_LINE, line width 1.0, cap style Pen::ROUND_CAP, join style Pen::ROUND_JOIN and color Color::BLACK.

◆ Pen() [2/3]

CDPL::Vis::Pen::Pen ( LineStyle  line_style)

Constructs a pen with the specified line style, line width 1.0, cap style Pen::ROUND_CAP, join style Pen::ROUND_JOIN and color Color::BLACK.

Parameters
line_styleThe line style.

◆ Pen() [3/3]

CDPL::Vis::Pen::Pen ( const Color color,
double  width = 1.0,
LineStyle  line_style = SOLID_LINE,
CapStyle  cap_style = ROUND_CAP,
JoinStyle  join_style = ROUND_JOIN 
)

Constructs a pen with the specified color, line width, line style, cap style and join style.

If width is negative, the line width is set to zero.

Parameters
colorThe pen color.
widthThe line width.
line_styleThe line style.
cap_styleThe line cap style.
join_styleThe line join style.

Member Function Documentation

◆ setLineStyle()

void CDPL::Vis::Pen::setLineStyle ( LineStyle  line_style)

Sets the line style to line_style.

Parameters
line_styleThe line style.

◆ getLineStyle()

LineStyle CDPL::Vis::Pen::getLineStyle ( ) const

Returns the line style.

Returns
The line style.

◆ setWidth()

void CDPL::Vis::Pen::setWidth ( double  width)

Sets the line width to the specified value.

If width is negative, the line width is set to zero.

Parameters
widthThe line width.

◆ getWidth()

double CDPL::Vis::Pen::getWidth ( ) const

Returns the line width.

Returns
The line width.

◆ setColor()

void CDPL::Vis::Pen::setColor ( const Color color)

Sets the pen's color to the specified value.

Parameters
colorThe color of the pen.

◆ getColor()

const Color& CDPL::Vis::Pen::getColor ( ) const

Returns the color of the pen.

Returns
The color of the pen.

◆ setCapStyle()

void CDPL::Vis::Pen::setCapStyle ( CapStyle  cap_style)

Sets the line cap style to cap_style.

Parameters
cap_styleThe line cap style.

◆ getCapStyle()

CapStyle CDPL::Vis::Pen::getCapStyle ( ) const

Returns the line cap style.

Returns
The line cap style.

◆ setJoinStyle()

void CDPL::Vis::Pen::setJoinStyle ( JoinStyle  join_style)

Sets the line join style to join_style.

Parameters
join_styleThe line join style.

◆ getJoinStyle()

JoinStyle CDPL::Vis::Pen::getJoinStyle ( ) const

Returns the line join style.

Returns
The line join style.

◆ operator==()

bool CDPL::Vis::Pen::operator== ( const Pen pen) const

Equality comparison operator.

Parameters
penThe other Pen object to be compared with.
Returns
true if all pen attributes compare equal, and false otherwise.

◆ operator!=()

bool CDPL::Vis::Pen::operator!= ( const Pen pen) const

Inequality comparison operator.

The result is equivalent to !(*this == pen).

Parameters
penThe other Pen object to be compared with.
Returns
true if the pen attributes compare non-equal, and false otherwise.

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