cheshirekow  v0.1.0
mpblocks::gtk::EigenCairo Class Reference

wrapper for cairo context which adds methods allowing for eigen vector typed points More...

#include <mpblocks/gtk/EigenCairo.h>

Classes

struct  SolidPattern
 

Public Member Functions

template<typename Derived >
void arc (const Eigen::MatrixBase< Derived > &c, double radius, double angle1, double angle2)
 
template<typename Derived >
void arc_negative (const Eigen::MatrixBase< Derived > &c, double radius, double angle1, double angle2)
 
template<typename Derived >
void circle (const Eigen::MatrixBase< Derived > &c, double r)
 
template<typename Derived1 , typename Derived2 , typename Derived3 >
void curve_to (const Eigen::MatrixBase< Derived1 > &x, const Eigen::MatrixBase< Derived2 > &c1, const Eigen::MatrixBase< Derived3 > &c2)
 
 EigenCairo (const Cairo::RefPtr< Cairo::Context > &ctx)
 
template<typename Derived >
void line_to (const Eigen::MatrixBase< Derived > &v) const
 
template<typename Derived >
void move_to (const Eigen::MatrixBase< Derived > &v) const
 
template<typename Derived1 , typename Derived2 >
void rectangle (const Eigen::MatrixBase< Derived1 > &x, const Eigen::MatrixBase< Derived2 > &s)
 
template<typename Derived1 , typename Derived2 , typename Derived3 >
void rel_curve_to (const Eigen::MatrixBase< Derived1 > &dx, const Eigen::MatrixBase< Derived2 > &dc1, const Eigen::MatrixBase< Derived3 > &dc2)
 
template<typename Derived >
void rel_line_to (const Eigen::MatrixBase< Derived > &v)
 
template<typename Derived >
void rel_move_to (const Eigen::MatrixBase< Derived > &v)
 
template<typename Derived >
void scale (const Eigen::MatrixBase< Derived > &v)
 
void set_source (const Gdk::RGBA &rgba)
 
void set_source_rgb (const char *str)
 
void set_source_rgba (const char *str)
 
template<typename Derived >
void translate (const Eigen::MatrixBase< Derived > &v)
 
template<typename Derived >
void user_to_device (Eigen::MatrixBase< Derived > &v) const
 
void user_to_device (Eigen::Matrix< double, 2, 1 > &v) const
 

Private Attributes

Cairo::RefPtr< Cairo::Context > m_ctx
 

Detailed Description

wrapper for cairo context which adds methods allowing for eigen vector typed points

Definition at line 38 of file EigenCairo.h.

Constructor & Destructor Documentation

mpblocks::gtk::EigenCairo::EigenCairo ( const Cairo::RefPtr< Cairo::Context > &  ctx)

Member Function Documentation

template<typename Derived >
void mpblocks::gtk::EigenCairo::arc ( const Eigen::MatrixBase< Derived > &  c,
double  radius,
double  angle1,
double  angle2 
)

Adds a circular arc of the given radius to the current path. The arc is centered at (xc, yc), begins at angle1 and proceeds in the direction of increasing angles to end at angle2. If angle2 is less than angle1 it will be progressively increased by 2*M_PI until it is greater than angle1.

If there is a current point, an initial line segment will be added to the path to connect the current point to the beginning of the arc. If this initial line is undesired, it can be avoided by calling begin_new_sub_path() before calling arc().

Angles are measured in radians. An angle of 0 is in the direction of the positive X axis (in user-space). An angle of M_PI/2.0 radians (90 degrees) is in the direction of the positive Y axis (in user-space). Angles increase in the direction from the positive X axis toward the positive Y axis. So with the default transformation matrix, angles increase in a clockwise direction.

( To convert from degrees to radians, use degrees * (M_PI / 180.0). )

This function gives the arc in the direction of increasing angles; see arc_negative() to get the arc in the direction of decreasing angles.

The arc is circular in user-space. To achieve an elliptical arc, you can scale the current transformation matrix by different amounts in the X and Y directions. For example, to draw an ellipse in the box given by x, y, width, height:

context->save();
context->translate(x, y);
context->scale(width / 2.0, height / 2.0);
context->arc(0.0, 0.0, 1.0, 0.0, 2 * M_PI);
context->restore();
Parameters
xcX position of the center of the arc
ycY position of the center of the arc
radiusthe radius of the arc
angle1the start angle, in radians
angle2the end angle, in radians

Definition at line 77 of file EigenCairo.hpp.

template<typename Derived >
void mpblocks::gtk::EigenCairo::arc_negative ( const Eigen::MatrixBase< Derived > &  c,
double  radius,
double  angle1,
double  angle2 
)

Adds a circular arc of the given radius to the current path. The arc is centered at (xc, yc), begins at angle1 and proceeds in the direction of decreasing angles to end at angle2. If angle2 is greater than angle1 it will be progressively decreased by 2*M_PI until it is greater than angle1.

See arc() for more details. This function differs only in the direction of the arc between the two angles.

Parameters
xcX position of the center of the arc
ycY position of the center of the arc
radiusthe radius of the arc
angle1the start angle, in radians
angle2the end angle, in radians

Definition at line 83 of file EigenCairo.hpp.

template<typename Derived >
void mpblocks::gtk::EigenCairo::circle ( const Eigen::MatrixBase< Derived > &  c,
double  r 
)
inline

Definition at line 115 of file EigenCairo.hpp.

template<typename Derived1 , typename Derived2 , typename Derived3 >
void mpblocks::gtk::EigenCairo::curve_to ( const Eigen::MatrixBase< Derived1 > &  x,
const Eigen::MatrixBase< Derived2 > &  c1,
const Eigen::MatrixBase< Derived3 > &  c2 
)

Adds a cubic Bezier spline to the path from the current point to position (x3, y3) in user-space coordinates, using (x1, y1) and (x2, y2) as the control points. After this call the current point will be (x3, y3).

Parameters
x1the X coordinate of the first control point
y1the Y coordinate of the first control point
x2the X coordinate of the second control point
y2the Y coordinate of the second control point
x3the X coordinate of the end of the curve
y3the Y coordinate of the end of the curve

Definition at line 68 of file EigenCairo.hpp.

template<typename Derived >
void mpblocks::gtk::EigenCairo::line_to ( const Eigen::MatrixBase< Derived > &  v) const

Adds a line to the path from the current point to position (x, y) in user-space coordinates. After this call the current point will be (x, y).

Parameters
xthe X coordinate of the end of the new line
ythe Y coordinate of the end of the new line

Definition at line 62 of file EigenCairo.hpp.

template<typename Derived >
void mpblocks::gtk::EigenCairo::move_to ( const Eigen::MatrixBase< Derived > &  v) const

If the current subpath is not empty, begin a new subpath. After this call the current point will be (x, y).

Parameters
xthe X coordinate of the new position
ythe Y coordinate of the new position

Definition at line 56 of file EigenCairo.hpp.

template<typename Derived1 , typename Derived2 >
void mpblocks::gtk::EigenCairo::rectangle ( const Eigen::MatrixBase< Derived1 > &  x,
const Eigen::MatrixBase< Derived2 > &  s 
)

Adds a closed-subpath rectangle of the given size to the current path at position (x, y) in user-space coordinates.

This function is logically equivalent to:

context->move_to(x, y);
context->rel_line_to(width, 0);
context->rel_line_to(0, height);
context->rel_line_to(-width, 0);
context->close_path();
Parameters
xthe X coordinate of the top left corner of the rectangle
ythe Y coordinate to the top left corner of the rectangle
widththe width of the rectangle
heightthe height of the rectangle

Definition at line 108 of file EigenCairo.hpp.

template<typename Derived1 , typename Derived2 , typename Derived3 >
void mpblocks::gtk::EigenCairo::rel_curve_to ( const Eigen::MatrixBase< Derived1 > &  dx,
const Eigen::MatrixBase< Derived2 > &  dc1,
const Eigen::MatrixBase< Derived3 > &  dc2 
)

Relative-coordinate version of curve_to(). All offsets are relative to the current point. Adds a cubic Bezier spline to the path from the current point to a point offset from the current point by (dx3, dy3), using points offset by (dx1, dy1) and (dx2, dy2) as the control points. After this call the current point will be offset by (dx3, dy3).

Given a current point of (x, y),

rel_curve_to(dx1, dy1, dx2, dy2, dx3, dy3)

is logically equivalent to

curve_to(x + dx1, y + dy1, x + dx2, y + dy2, x + dx3, y + dy3).
Parameters
dx1the X offset to the first control point
dy1the Y offset to the first control point
dx2the X offset to the second control point
dy2the Y offset to the second control point
dx3the X offset to the end of the curve
dy3the Y offset to the end of the curve

It is an error to call this function with no current point. Doing so will cause this to shutdown with a status of CAIRO_STATUS_NO_CURRENT_POINT. Cairomm will then throw an exception.

Definition at line 99 of file EigenCairo.hpp.

template<typename Derived >
void mpblocks::gtk::EigenCairo::rel_line_to ( const Eigen::MatrixBase< Derived > &  v)

Relative-coordinate version of line_to(). Adds a line to the path from the current point to a point that is offset from the current point by (dx, dy) in user space. After this call the current point will be offset by (dx, dy).

Given a current point of (x, y),

rel_line_to(dx, dy)

is logically equivalent to

line_to(x + dx, y + dy).
Parameters
dxthe X offset to the end of the new line
dythe Y offset to the end of the new line

It is an error to call this function with no current point. Doing so will cause this to shutdown with a status of CAIRO_STATUS_NO_CURRENT_POINT. Cairomm will then throw an exception.

Definition at line 94 of file EigenCairo.hpp.

template<typename Derived >
void mpblocks::gtk::EigenCairo::rel_move_to ( const Eigen::MatrixBase< Derived > &  v)

If the current subpath is not empty, begin a new subpath. After this call the current point will offset by (x, y).

Given a current point of (x, y),

rel_move_to(dx, dy)

is logically equivalent to

move_to(x + dx, y + dy)
Parameters
dxthe X offset
dythe Y offset

It is an error to call this function with no current point. Doing so will cause this to shutdown with a status of CAIRO_STATUS_NO_CURRENT_POINT. Cairomm will then throw an exception.

Definition at line 89 of file EigenCairo.hpp.

template<typename Derived >
void mpblocks::gtk::EigenCairo::scale ( const Eigen::MatrixBase< Derived > &  v)

Modifies the current transformation matrix (CTM) by scaling the X and Y user-space axes by sx and sy respectively. The scaling of the axes takes place after any existing transformation of user space.

Parameters
sxscale factor for the X dimension
syscale factor for the Y dimension

Definition at line 41 of file EigenCairo.hpp.

void mpblocks::gtk::EigenCairo::set_source ( const Gdk::RGBA &  rgba)

Sets the source pattern within the Context to source. This Pattern will then be used for any subsequent drawing operation until a new source pattern is set.

Note: The Pattern's transformation matrix will be locked to the user space in effect at the time of set_source(). This means that further modifications of the current transformation matrix will not affect the source pattern.

Parameters
sourcea Pattern to be used as the source for subsequent drawing operations.
See Also
Pattern::set_matrix()
set_source_rgb()
set_source_rgba()
set_source(const RefPtr<Surface>& surface, double x, double y)
void mpblocks::gtk::EigenCairo::set_source_rgb ( const char *  str)

Sets the source pattern within the Context to an opaque color. This opaque color will then be used for any subsequent drawing operation until a new source pattern is set.

The color components are floating point numbers in the range 0 to 1. If the values passed in are outside that range, they will be clamped.

Parameters
redred component of color
greengreen component of color
blueblue component of color
See Also
set_source_rgba()
set_source()
void mpblocks::gtk::EigenCairo::set_source_rgba ( const char *  str)

Sets the source pattern within the Context to a translucent color. This color will then be used for any subsequent drawing operation until a new source pattern is set.

The color and alpha components are floating point numbers in the range 0 to 1. If the values passed in are outside that range, they will be clamped.

Parameters
redred component of color
greengreen component of color
blueblue component of color
alphaalpha component of color
See Also
set_source_rgb()
set_source()
template<typename Derived >
void mpblocks::gtk::EigenCairo::translate ( const Eigen::MatrixBase< Derived > &  v)

Modifies the current transformation matrix (CTM) by translating the user-space origin by (tx, ty). This offset is interpreted as a user-space coordinate according to the CTM in place before the new call to cairo_translate. In other words, the translation of the user-space origin takes place after any existing transformation.

Parameters
txamount to translate in the X direction
tyamount to translate in the Y direction

Definition at line 35 of file EigenCairo.hpp.

template<typename Derived >
void mpblocks::gtk::EigenCairo::user_to_device ( Eigen::MatrixBase< Derived > &  v) const

Transform a coordinate from user space to device space by multiplying the given point by the current transformation matrix (CTM).

Parameters
xX value of coordinate (in/out parameter)
yY value of coordinate (in/out parameter)

Definition at line 47 of file EigenCairo.hpp.

void mpblocks::gtk::EigenCairo::user_to_device ( Eigen::Matrix< double, 2, 1 > &  v) const

Member Data Documentation

Cairo::RefPtr<Cairo::Context> mpblocks::gtk::EigenCairo::m_ctx
private

Definition at line 40 of file EigenCairo.h.


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