gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
CairoArrow Class Reference

#include <CairoArrow.H>

Public Member Functions

 CairoArrow (void)
 
 CairoArrow (cairo_t *cr, float xBase, float yBase, float xPoint, float yPoint, float headToLengthRatio, float width, bool closed, bool filled)
 
void draw (cairo_t *cr, float xBase, float yBase, float xPoint, float yPoint, float headToLengthRatio, float width, bool closed, bool filled)
 
virtual ~CairoArrow ()
 

Private Member Functions

void findArrowHeadPoints (float xBase, float yBase, float xPoint, float yPoint, float headToLengthRatio, float width)
 

Private Attributes

float xSide1
 
float xSide2
 The arrow head side 1. More...
 
float ySide1
 
float ySide2
 The arrow head side 2. More...
 
float vecX
 
float vecY
 The shaft vector transposed to the origin. More...
 

Detailed Description

Given a Cairo context, draw an arrow. Arrows can be of three types, line arrows, closed head arrows and filled head arrows. The arrows are specified by a base (x,y) and point (x,y). The arrow head is specified by a fraction of the shaft size. The arrow head width is specified in pixels.

CairoArrowTest.jpg
Examples:
CairoArrowTest.C.

Definition at line 32 of file CairoArrow.H.

Constructor & Destructor Documentation

◆ CairoArrow() [1/2]

CairoArrow::CairoArrow ( void  )
inline

This constructor does nothing. Allows instantiation and usage like so :

ca.draw(cr, 200, 200, 250, 350, .2, 20, 0, 0);
ca.draw(cr, 400, 400, 300, 200, .2, 20, 1, 0);

Definition at line 70 of file CairoArrow.H.

◆ CairoArrow() [2/2]

CairoArrow::CairoArrow ( cairo_t *  cr,
float  xBase,
float  yBase,
float  xPoint,
float  yPoint,
float  headToLengthRatio,
float  width,
bool  closed,
bool  filled 
)
inline

Construct an arrow by calculating the head points and then use cairo to stroke or fill. The Cairo context which is passed in should already be configured for line width and colour. This medthod is good if you want to draw one arrow :

CairoArrow ca(cr, 200, 200, 250, 350, .2, 20, 0, 0);
Parameters
crThe cairo context to draw in
xBaseThe x arrow shaft base ordinate
yBaseThe y arrow shaft base co-ordinate
xPointThe x arrow shaft point ordinate
yPointThe y arrow shaft point co-ordinate
headToLengthRatioThe fraction of the shaft length to be taken up by the arrow head
widthThe width of the arrow
closedClose the arrow head (draw a triangle)
filledFill the arrow head

Definition at line 89 of file CairoArrow.H.

Here is the call graph for this function:

◆ ~CairoArrow()

virtual CairoArrow::~CairoArrow ( )
inlinevirtual

Definition at line 127 of file CairoArrow.H.

Member Function Documentation

◆ draw()

void CairoArrow::draw ( cairo_t *  cr,
float  xBase,
float  yBase,
float  xPoint,
float  yPoint,
float  headToLengthRatio,
float  width,
bool  closed,
bool  filled 
)
inline

Construct an arrow by calculating the head points and then use cairo to stroke or fill The Cairo context which is passed in should already be configured for line width and colour

Parameters
crThe cairo context to draw in
xBaseThe x arrow shaft base ordinate
yBaseThe y arrow shaft base co-ordinate
xPointThe x arrow shaft point ordinate
yPointThe y arrow shaft point co-ordinate
headToLengthRatioThe fraction of the shaft length to be taken up by the arrow head
widthThe width of the arrow
closedClose the arrow head (draw a triangle)
filledFill the arrow head
Examples:
CairoArrowTest.C.

Definition at line 105 of file CairoArrow.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findArrowHeadPoints()

void CairoArrow::findArrowHeadPoints ( float  xBase,
float  yBase,
float  xPoint,
float  yPoint,
float  headToLengthRatio,
float  width 
)
inlineprivate

Given an arrow shaft, the width and ratio of the head, find the arrow head points. The ratio is how much as a fraction of the shaft size should be consumed by the arrow head. The arrow head side points are derived using the orthogonal unit vector to the shaft vector.

Parameters
xBaseThe x arrow shaft base ordinate
yBaseThe y arrow shaft base co-ordinate
xPointThe x arrow shaft point ordinate
yPointThe y arrow shaft point co-ordinate
headToLengthRatioThe fraction of the shaft length to be taken up by the arrow head
widthThe width of the arrow

Definition at line 47 of file CairoArrow.H.

Here is the caller graph for this function:

Member Data Documentation

◆ vecX

float CairoArrow::vecX
private

Definition at line 35 of file CairoArrow.H.

◆ vecY

float CairoArrow::vecY
private

The shaft vector transposed to the origin.

Definition at line 35 of file CairoArrow.H.

◆ xSide1

float CairoArrow::xSide1
private

Definition at line 33 of file CairoArrow.H.

◆ xSide2

float CairoArrow::xSide2
private

The arrow head side 1.

Definition at line 33 of file CairoArrow.H.

◆ ySide1

float CairoArrow::ySide1
private

Definition at line 34 of file CairoArrow.H.

◆ ySide2

float CairoArrow::ySide2
private

The arrow head side 2.

Definition at line 34 of file CairoArrow.H.


The documentation for this class was generated from the following file:
gtkIOStream: CairoArrow Class Reference
GTK+ IOStream  Beta