cheshirekow
v0.1.0
|
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 |
wrapper for cairo context which adds methods allowing for eigen vector typed points
Definition at line 38 of file EigenCairo.h.
mpblocks::gtk::EigenCairo::EigenCairo | ( | const Cairo::RefPtr< Cairo::Context > & | ctx | ) |
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:
xc | X position of the center of the arc |
yc | Y position of the center of the arc |
radius | the radius of the arc |
angle1 | the start angle, in radians |
angle2 | the end angle, in radians |
Definition at line 77 of file EigenCairo.hpp.
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.
xc | X position of the center of the arc |
yc | Y position of the center of the arc |
radius | the radius of the arc |
angle1 | the start angle, in radians |
angle2 | the end angle, in radians |
Definition at line 83 of file EigenCairo.hpp.
|
inline |
Definition at line 115 of file EigenCairo.hpp.
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).
x1 | the X coordinate of the first control point |
y1 | the Y coordinate of the first control point |
x2 | the X coordinate of the second control point |
y2 | the Y coordinate of the second control point |
x3 | the X coordinate of the end of the curve |
y3 | the Y coordinate of the end of the curve |
Definition at line 68 of file EigenCairo.hpp.
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).
x | the X coordinate of the end of the new line |
y | the Y coordinate of the end of the new line |
Definition at line 62 of file EigenCairo.hpp.
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).
x | the X coordinate of the new position |
y | the Y coordinate of the new position |
Definition at line 56 of file EigenCairo.hpp.
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:
x | the X coordinate of the top left corner of the rectangle |
y | the Y coordinate to the top left corner of the rectangle |
width | the width of the rectangle |
height | the height of the rectangle |
Definition at line 108 of file EigenCairo.hpp.
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),
is logically equivalent to
dx1 | the X offset to the first control point |
dy1 | the Y offset to the first control point |
dx2 | the X offset to the second control point |
dy2 | the Y offset to the second control point |
dx3 | the X offset to the end of the curve |
dy3 | the 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.
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),
is logically equivalent to
dx | the X offset to the end of the new line |
dy | the 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.
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),
is logically equivalent to
dx | the X offset |
dy | the 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.
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.
sx | scale factor for the X dimension |
sy | scale 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.
source | a Pattern to be used as the source for subsequent drawing operations. |
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.
red | red component of color |
green | green component of color |
blue | blue component of color |
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.
red | red component of color |
green | green component of color |
blue | blue component of color |
alpha | alpha component of color |
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.
tx | amount to translate in the X direction |
ty | amount to translate in the Y direction |
Definition at line 35 of file EigenCairo.hpp.
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).
x | X value of coordinate (in/out parameter) |
y | Y 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 |
|
private |
Definition at line 40 of file EigenCairo.h.