GTK+ IOStream  Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CairoArrow Class Reference

#include <CairoArrow.H>

Collaboration diagram for CairoArrow:
Collaboration graph
[legend]

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

Definition at line 30 of file CairoArrow.H.

Constructor & Destructor Documentation

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 68 of file CairoArrow.H.

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 87 of file CairoArrow.H.

Here is the call graph for this function:

virtual CairoArrow::~CairoArrow ( )
inlinevirtual

Definition at line 125 of file CairoArrow.H.

Member Function Documentation

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

Definition at line 103 of file CairoArrow.H.

Here is the call graph for this function:

Here is the caller graph for this function:

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 45 of file CairoArrow.H.

Here is the caller graph for this function:

Member Data Documentation

float CairoArrow::vecX
private

Definition at line 33 of file CairoArrow.H.

float CairoArrow::vecY
private

The shaft vector transposed to the origin.

Definition at line 33 of file CairoArrow.H.

float CairoArrow::xSide1
private

Definition at line 31 of file CairoArrow.H.

float CairoArrow::xSide2
private

The arrow head side 1.

Definition at line 31 of file CairoArrow.H.

float CairoArrow::ySide1
private

Definition at line 32 of file CairoArrow.H.

float CairoArrow::ySide2
private

The arrow head side 2.

Definition at line 32 of file CairoArrow.H.


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