papyrus logo

Papyrus::Drawable Class Reference

Drawable is the base class for objects capable of being drawn into a cairo context that also have spatial properties; i.e. More...

#include <drawable.h>

Inheritance diagram for Papyrus::Drawable:
Inheritance graph
[legend]

List of all members.

Classes

struct  CountedConnection
 Internal structure exposed for the unit test framework. More...

Public Types

typedef std::list
< Matrix::pointer
MatrixList
typedef std::map< int, MatrixListMatrixMap
typedef std::map
< Matrix::pointer,
CountedConnection
MatrixConnMap
 Internals exposed for the unit test framework.

Public Member Functions

 PAPYRUS_RENDERABLE (Drawable)
virtual ~Drawable ()
virtual void set (const AttributeValueMap &avmap)
bool is_visible () const
void show ()
void hide ()
double alpha () const
void set_alpha (double a)
double x () const
 X position.
void set_x (double x)
 Absolute move of the x position.
double y () const
 Y position.
void set_y (double y)
 Absolute move of the y position.
void get_xy (double &x, double &y)
 (X,Y) position
void set_xy (double x, double y)
 Absolute move to (x,y).
void translate (double tx, double ty)
 Relative translation of the current position by (tx, ty).
void get_scale (double &sx, double &sy)
 convenience method to get scaling in x and y dimensions with a single function call
double get_scale_x () const
 The current x dimension scaling value.
double get_scale_y () const
 The current y dimension scaling value.
void set_scale_x (double sx)
 Absolute set of the x dimension scaling value.
void set_scale_y (double sy)
 Absolute set of the y dimension scaling value.
void set_scale (double scale_x, double scale_y)
 Absolute set of the x and y dimension scalings using independent values for each.
void set_scale (double s)
 Absolute set of the x and y dimension scalings using a uniform scaling value.
void scale (double s)
 Uniformly scales the current x and y scaling values by s.
void scale (double scale_x, double scale_y)
 Independently scales the current x and y scaling values.
double get_rotation (DegRad unit=RADIANS) const
 Get rotation r in the specified units.
void set_rotation (double r, DegRad unit=RADIANS)
 Absolute set of the current rotation value to r using the specified units.
void rotate (double r, DegRad unit=RADIANS)
 Relative rotation of the current value by r.
void get_skew (double &skewx, double &skewy, DegRad unit=RADIANS)
 Get the x and y skewing angles.
double get_skew_x (DegRad unit=RADIANS) const
 Gets the current x-axis skew angle.
double get_skew_y (DegRad unit=RADIANS) const
 Gets the current y-axis skew angle.
void set_skew_x (double skewx, DegRad unit=RADIANS)
 Absolute set of the x-axis skewing angle.
void set_skew_y (double skewy, DegRad unit=RADIANS)
 Absolute set of the y-axis skewing angle.
void set_skew (double skewx, double skewy, DegRad unit=RADIANS)
 Absolute set of the x-axis and y-axis skewing angles using separate values for each axis.
void set_skew (double s, DegRad unit=RADIANS)
 Absolute set of the x-axis and y-axis skewing angles using the same value for each axis.
void skew (double x, double y, DegRad unit=RADIANS)
 Relative skewing of the x-axis and y-axis angles using separate values for each axis.
void skew (double s, DegRad unit=RADIANS)
 Relative skewing of the x-axis and y-axis angles by the same value for each axis.
double centroid_x () const
 Get centroid x position about which the Drawable is rotated.
void set_centroid_x (double centroid_x)
 Set the x value of the centroid about which the Drawable will be rotated.
double centroid_y () const
 Get centroid y position about which the Drawable is rotated.
void set_centroid_y (double centroid_y)
 Set the y value of the centroid about which the Drawable will be rotated.
void get_centroid (double &centroid_x, double &centroid_y)
 Get the (x,y) centroid about which the Drawable will be rotated.
void set_centroid (double centroid_x, double centroid_y)
 Set the (x,y) centroid about which the Drawable will be rotated.
const Matrixmatrix () const
 Returns the matrix used for this object's drawing.
const Matrixcomposed_matrix () const
 Return the composed matrix of this drawable.
void add_matrix (const Matrix::pointer m, int level=0)
 Add an transformation matrix at the specified level.
void remove_matrix (const Matrix::pointer m)
 Remove matrix m from all matrix levels.
void remove_matrix (const Matrix::pointer m, int level)
 Remove matrix m from the specified level.
const MatrixMapmatrices ()
 Get the map of external matrices for this object.
const MatrixConnMapmatrix_connection_map ()
 Internals exposed for the unit test framework.
virtual Matrix global_matrix () const
 Returns the global matrix that will be applied to this drawable.
void global_to_local (double &x, double &y) const
 Transform a global point to the drawable's local coordinates.
void local_to_global (double &x, double &y) const
 Transform a local point to global coordinates.
void distance_global_to_local (double &x, double &y) const
 Transform a global distance to the drawable's local coordinates.
void distance_local_to_global (double &x, double &y) const
 Transform a local distance to global coordinates.
virtual void render (Context &cairo) const
 Reimplemented render method from renderable.
virtual void render (Context &cairo, double x, double y, double w, double h) const
 Reimplemented render method from renderable.
virtual void draw (Context &cairo) const =0
 Pure virtual draw method to be reimplemented by children.
virtual void freeze ()
 Freeze the drawable, preventing any changes until it is thawed.
virtual void thaw (bool force_redraw=false)
 Thaw the drawable, causing any changes to be updated.
bool is_frozen ()
 True if the drawable is frozen.
int composite_operator ()
 Returns the Cairomm composite operator enumerated value, or -1 if the composite operator is not set.
void set_composite_operator (Cairo::Operator op)
 Sets the composite operator of this drawable.
void clear_composite_operator ()
 Removes the composite operator.
virtual Region extents (const Matrix &m=Matrix::Identity, ExtentsPerformance ep=EXTENTS_QUICK) const
 Returns the extents of this drawable.
virtual Region pre_viewbox_extents (const Matrix &m=Matrix::Identity, ExtentsPerformance ep=EXTENTS_QUICK) const
 Raw extents with only the composition matrix applied.
virtual Region raw_extents () const
 These are the extents of the drawable without any matrices applied.
virtual Region global_extents () const
 Returns the global extents of this drawable.
bool exclude_from_extents ()
 Calculate a drawable's extents, applying matrix m.
void set_exclude_from_extents (bool b=true)
 Exclude this drawable from all extents calculations of its parent.
virtual Region calculate_extents (const Matrix &m=Matrix::Identity, ExtentsPerformance ep=EXTENTS_QUICK) const
 Calculate the extents of this drawable when the specified matrix is applied.
void apply_external_matrices (Matrix &m) const
 Applies external matrices to m and returns the result.
virtual bool inside (double x, double y)
 True if the point (x,y) is inside this Drawable's drawing area.
void set_selectable (bool selectable=true)
 Set to true if this Drawable will respond to the select method.
bool is_selectable ()
 True if this Drawable will respond to the select method, or false if it will not include itself in the select method.
virtual bool is_group ()
 True if this Drawable contains other drawables.
Viewbox::pointer viewbox ()
 Returns the viewbox associated with this Drawable.
void set_viewbox (Viewbox::pointer viewbox=Viewbox::pointer())
 Sets this Drawable's viewbox to the provided viewbox.
void set_viewbox (double x, double y, double w, double h, Viewbox::ALIGN align=Viewbox::ALIGN_XMAX_YMAX, Viewbox::MEET_OR_SLICE meet_or_slice=Viewbox::MEET)
void set_viewbox (const Region &region, Viewbox::ALIGN align=Viewbox::ALIGN_XMAX_YMAX, Viewbox::MEET_OR_SLICE meet_or_slice=Viewbox::MEET)
void set_viewbox (const Viewbox &viewbox)
 Sets this Drawable's viewbox to the provided viewbox.
sigc::signal< void, double,
double, double, double > & 
signal_redraw ()
 Signal emitted with x,y,w,h values when this Drawable needs to be redrawn.
sigc::signal< void > & signal_selectable ()
 Signal emitted when the selectable value is changed.
sigc::signal< void > & signal_destroyed ()
 Signal emitted when this drawable is destroyed.
sigc::signal< void,
FrozenThawed > & 
signal_frozen ()
 Signal emitted when the frozen/thawed state is changed.
sigc::signal< void > & signal_composed_matrix_invalidated ()
 Signal emitted when the composed matrix is invalidated.
sigc::signal< void > & signal_extents_changed ()
 Signal emitted when the extents are changed.
void reset_position ()
 Reset position to default values of xy = (0,0), scale = (1,1), rotation = 0, and shear xy = (0,0).
void redraw_proxy ()
 This is a proxy for the virtual redraw() method.
virtual pointer clone () const =0
 operator pointer ()
pointer self ()
virtual Groupparent ()

Protected Member Functions

 Drawable (const Glib::ustring &id=Glib::ustring(), double tx=0.0, double ty=0.0, double sx=1.0, double sy=1.0, double r=0.0)
 Constructor that sets initial transforms.
void on_matrix_changed ()
virtual Matrix calculate_composed_matrix () const
 Recalculates m_matrix if m_regenerate_matrix is true and sets m_regenerate_matrix to false; does nothing if m_regenerate_matrix is false.
void on_viewbox_changed ()
virtual void redraw ()
 Convenience method that children can call and will take care of emitting the need redraw signal with the proper parameters.
Glib::ustring svg_transform ()
void invalidate_matrix ()
void invalidate_composed_matrix ()
void invalidate_extents ()

Protected Attributes

weak_pointer m_self
Groupm_parent
MatrixMap m_matrices
MatrixConnMap m_matrix_connections
int m_composite_operator
bool m_visible
double m_alpha
bool m_frozen
 If true the drawable is frozen.
bool m_frozen_by_parent
 If true the drawable is frozen by parent.
bool m_need_redraw
 If true a redraw will occur when thawed or when parent is unthawed.
bool m_selectable
 whether the drawable is selectable
Viewbox::pointer m_viewbox
 Pointer to a viewbox, which may be null if this Drawable doesn't have a viewbox.
sigc::connection m_viewbox_connection
sigc::signal< void, double,
double, double, double > 
m_signal_redraw
 Signal emitted when this object has changed and needs to be redrawn.
sigc::signal< void > m_signal_selectable
 Signal emitted when the selectable value is changed.
sigc::signal< void > m_signal_destroyed
 Signal emitted when this drawable is destroyed.
sigc::signal< void, FrozenThawedm_signal_frozen
 Signal emitted when the drawable is frozen / thawed.
sigc::signal< void > m_signal_composed_matrix_invalidated
 Signal emitted when the composed matrix is invalidated.
sigc::signal< void > m_signal_extents_changed
 Signal emitted when the extents change.
bool m_exclude_from_extents
 If true, this object will be excluded from a parent's extents calculation.

Static Protected Attributes

static Cairo::RefPtr
< Cairo::ImageSurface > 
m_sidebuffer_image
static Context m_sidebuffer_cairo

Private Attributes

double m_x
 x position
double m_y
 y position
double m_sx
 x scaling value
double m_sy
 y scaling value
double m_r
 rotation value in radians
double m_skewx
 skew x angle in radians
double m_skewy
 skew y angle in radians
double m_centroid_x
 x centroid value
double m_centroid_y
 y centroid value
Matrix m_composed_matrix
 The drawable's local matrix.
bool m_composed_matrix_invalid
 When true, this drawable's transformation matrix is invalid and needs to be calculated.
Matrix m_matrix
 This is the final matrix applied when drawing occurs and is the composed matrix multiplied by the viewbox matrix.
bool m_matrix_invalid
Region m_extents
 These are the final extents of the drawable.
bool m_extents_invalid
Region m_redraw_extents
 Redraw extents containing areas that need redraws including the current extents plus any old ones.
Region m_pre_viewbox_extents
 These are the extents of the drawable without the transformation matrix applied.
bool m_pre_viewbox_extents_invalid
 If true, calculate_pre_viewbox_extents() will be called before extents() or pre_viewbox_extents() returns.

Friends

class Group

Detailed Description

Drawable is the base class for objects capable of being drawn into a cairo context that also have spatial properties; i.e.

affine transforms can be meaningfully applied to drawables. It is the presence of meaningful affine transforms that differentiates Drawable from its parent Renderable.

However Drawable lacks a concept of filling and outlining which differentiates it from its child Shape.

Affine Transforms
Drawable provides a common interface for managing a transformation matrix that is applied before the object is drawn. These transformations include translation, scaling and shearing (skewing) in the x and y dimensions as well as rotation in the x-y plane.
The methods for effecting the transformation matrix can be effectively grouped into three categories:
  1. Methods causing relative transforms
    • Use a verb form ( Drawable::translate, Drawable::rotate, Drawable::scale, et. al.)
    • As an example rotate(90,DEGREES) causes the current rotation value to increase by 90'. Thus, if the rotation angle before the call to rotate was 0.00, the resulting rotation angle will be 90'. However, if the previous value was 180' the current value will now be 270'.
  2. Methods causing absolute transforms
  3. Accessors for current transformation values
Composition of the Drawable's Internal Matrix
The drawable's internal matrix is composed from the currently set x, y, scaling, rotation, skewing and centroid values.
First, the object is translated to the (x,y) position. It is then scaled along the x and y axes. Before rotation occurs the object is then translated according to the centroid values, rotated so that rotation occurs about the centroid, and then translated back. Finally, skewing is applied.
Specifically, the order of these transforms are:
  1. translate( x, y )
  2. scale( xscale, yscale )
  3. translate( xcentroid, ycentroid )
  4. rotate( r )
  5. translate( -xcentroid, -ycentroid )
  6. skew( xskew, yskew )
External Matrices
The final rendering matrix is created by composing external matrices with the drawable's own transformation matrix.
The order of composition is as follows:
  • All external matrices with a level < 0 are applied in level order
  • The internal matrix is applied
  • All external matrices with a level >= 0 are applied in level order
  • External matrices at the same level are applied in the order they were added
Rendering
Drawable implements the pure virtual render method of parent Renderable by pushing the current cairo state onto the cairo stack, applying any necessary transformation matrix, calling the pure virtual draw method, and popping the cairo stack to restore the state.
Since this class handles the matrices directly, children only need to override the draw method and draw themselves with a local coordinate frame reference.
Inheriting from Drawable
When inheriting from Drawable you should provide a child specific implementation of the draw() method. You should probably also override the extents() method to return a Region object that is meaningful to your child, along with providing a child specific implementation of intersects(x,y) to provide a meaningful (and efficient) method of determining whether your child includes the point (x,y).
Author:
Rick L Vinyard Jr

Member Typedef Documentation

Internals exposed for the unit test framework.

Don't use this.

This is a map between an external matrix and a structure that contains a connection to the matrix' changed signal and a count of how many times that matrix has been added to this drawable.


Constructor & Destructor Documentation

Papyrus::Drawable::Drawable ( const Glib::ustring &  id = Glib::ustring(),
double  tx = 0.0,
double  ty = 0.0,
double  sx = 1.0,
double  sy = 1.0,
double  r = 0.0 
) [protected]

Constructor that sets initial transforms.

If no parameters are specified, initial values set translation to (0,0) with a (1,1) scale ratio and no rotation or shearing.

If either scale parameter < 0.0, the parameter will be reset to 1.0.

References m_sx, and m_sy.

Papyrus::Drawable::~Drawable (  )  [virtual]

References m_signal_destroyed.


Member Function Documentation

void Papyrus::Drawable::add_matrix ( const Matrix::pointer  m,
int  level = 0 
)

Add an transformation matrix at the specified level.

All matrices at a level < 0 are composed before the object's affine matrix matrix and all matrices at a level >= 0 are composed after the object's affine matrix.

Matrices on the same level are composed in the order added.

References invalidate_composed_matrix(), m_matrices, m_matrix_connections, on_matrix_changed(), and redraw().

Referenced by set().

double Papyrus::Drawable::alpha (  )  const

References m_alpha.

Referenced by Papyrus::Image::set_image().

void Papyrus::Drawable::apply_external_matrices ( Matrix m  )  const

Applies external matrices to m and returns the result.

References m_matrices.

Referenced by Papyrus::Reference::calculate_composed_matrix(), calculate_composed_matrix(), and Papyrus::Canvas::calculate_composed_matrix().

Matrix Papyrus::Drawable::calculate_composed_matrix (  )  const [protected, virtual]

Recalculates m_matrix if m_regenerate_matrix is true and sets m_regenerate_matrix to false; does nothing if m_regenerate_matrix is false.

Reimplemented in Papyrus::Canvas, and Papyrus::Reference.

References apply_external_matrices(), m_centroid_x, m_centroid_y, m_r, m_skewx, m_skewy, m_sx, m_sy, m_x, m_y, Papyrus::Matrix::rotate(), Papyrus::Matrix::scale(), Papyrus::Matrix::set_identity(), Papyrus::Matrix::skew(), and Papyrus::Matrix::translate().

Referenced by composed_matrix().

Region Papyrus::Drawable::calculate_extents ( const Matrix m = Matrix::Identity,
ExtentsPerformance  ep = EXTENTS_QUICK 
) const [virtual]
double Papyrus::Drawable::centroid_x (  )  const

Get centroid x position about which the Drawable is rotated.

References m_centroid_x.

Referenced by Papyrus::Reference::calculate_composed_matrix(), and Papyrus::Canvas::calculate_composed_matrix().

double Papyrus::Drawable::centroid_y (  )  const

Get centroid y position about which the Drawable is rotated.

References m_centroid_y.

Referenced by Papyrus::Reference::calculate_composed_matrix(), and Papyrus::Canvas::calculate_composed_matrix().

void Papyrus::Drawable::clear_composite_operator (  ) 

Removes the composite operator.

This is different than setting the composite operator to the default cairo operator which is the OVER operator.

This results in a absolute removal of the operator, causing the scenegraph to not explicitly set the cairo engine to any state when drawing.

References m_composite_operator, and redraw().

virtual pointer Papyrus::Drawable::clone (  )  const [pure virtual]
const Matrix & Papyrus::Drawable::composed_matrix (  )  const

Return the composed matrix of this drawable.

The composed matrix is the internal matrix composed with all external matrices except the viewbox matrix.

If this drawable does not have a viewbox the composed matrix will always be the final matrix when drawing.

References calculate_composed_matrix(), invalidate_matrix(), m_composed_matrix, and m_composed_matrix_invalid.

Referenced by Papyrus::Boxed::calculate_extents(), Papyrus::Canvas::canvas_to_window(), extents(), global_extents(), Papyrus::Reference::global_matrix(), global_matrix(), matrix(), Papyrus::Group::on_child_redraw(), pre_viewbox_extents(), svg_transform(), and Papyrus::Canvas::window_to_canvas().

int Papyrus::Drawable::composite_operator (  ) 

Returns the Cairomm composite operator enumerated value, or -1 if the composite operator is not set.

References m_composite_operator.

void Papyrus::Drawable::distance_global_to_local ( double &  x,
double &  y 
) const

Transform a global distance to the drawable's local coordinates.

References global_matrix(), Papyrus::Matrix::invert(), matrix(), and Papyrus::Matrix::transform_distance().

void Papyrus::Drawable::distance_local_to_global ( double &  x,
double &  y 
) const

Transform a local distance to global coordinates.

References global_matrix(), and Papyrus::Matrix::transform_distance().

virtual void Papyrus::Drawable::draw ( Context cairo  )  const [pure virtual]

Pure virtual draw method to be reimplemented by children.

This method is called by the supplied render method after the local transformation matrix has been applied to the cairo stack.

Implemented in Papyrus::Bezierline, Papyrus::Boxed, Papyrus::Canvas, Papyrus::Grid, Papyrus::Group, Papyrus::Image, Papyrus::Polyline, Papyrus::Reference, Papyrus::Shape, Papyrus::Deltille, Papyrus::Face, Papyrus::Hextille, and Papyrus::Quadrille.

Referenced by render().

bool Papyrus::Drawable::exclude_from_extents (  ) 

Calculate a drawable's extents, applying matrix m.

This default extents calculation calls draw and uses cairo's cairo_path_extents() and cairo_stroke_extents() to calculate the extents.

Algorithmically, this is not the most efficient mechanism, but does provide a basic mechanism allowing for rapid drawable creation if you don't want to worry about the algorithmic details. If true, this drawable will not be included in any extents calculation of a parent

References m_exclude_from_extents.

Region Papyrus::Drawable::extents ( const Matrix m = Matrix::Identity,
ExtentsPerformance  ep = EXTENTS_QUICK 
) const [virtual]
void Papyrus::Drawable::freeze (  )  [virtual]

Freeze the drawable, preventing any changes until it is thawed.

This is an early version that prevents the redraw signal from emitting. However, if other events trigger a redraw the changes will be reflected.

Todo:
Fix the freeze/thaw structure so that this is a true freeze

Reimplemented in Papyrus::Group.

References Papyrus::FROZEN, m_frozen, and m_signal_frozen.

Referenced by Papyrus::Image::on_image_changed(), Papyrus::Tiling::set_columns(), Papyrus::Tiling::set_columns_rows(), Papyrus::Rectangle::set_height(), Papyrus::Tiling::set_rows(), Papyrus::Tiling::set_side_length(), Papyrus::Rectangle::set_width(), and Papyrus::Rectangle::set_xywh().

void Papyrus::Drawable::get_centroid ( double &  centroid_x,
double &  centroid_y 
)

Get the (x,y) centroid about which the Drawable will be rotated.

References m_centroid_x, and m_centroid_y.

double Papyrus::Drawable::get_rotation ( DegRad  unit = RADIANS  )  const

Get rotation r in the specified units.

References m_r, and Papyrus::rad2units().

Referenced by Papyrus::Reference::calculate_composed_matrix(), and Papyrus::Canvas::calculate_composed_matrix().

void Papyrus::Drawable::get_scale ( double &  sx,
double &  sy 
)

convenience method to get scaling in x and y dimensions with a single function call

References m_sx, and m_sy.

double Papyrus::Drawable::get_scale_x (  )  const

The current x dimension scaling value.

References m_sx.

Referenced by Papyrus::Reference::calculate_composed_matrix(), and Papyrus::Canvas::calculate_composed_matrix().

double Papyrus::Drawable::get_scale_y (  )  const

The current y dimension scaling value.

References m_sy.

Referenced by Papyrus::Reference::calculate_composed_matrix(), and Papyrus::Canvas::calculate_composed_matrix().

void Papyrus::Drawable::get_skew ( double &  skewx,
double &  skewy,
DegRad  unit = RADIANS 
)

Get the x and y skewing angles.

References m_skewx, m_skewy, and Papyrus::rad2units().

double Papyrus::Drawable::get_skew_x ( DegRad  unit = RADIANS  )  const
double Papyrus::Drawable::get_skew_y ( DegRad  unit = RADIANS  )  const
void Papyrus::Drawable::get_xy ( double &  x,
double &  y 
)

(X,Y) position

References m_x, and m_y.

Region Papyrus::Drawable::global_extents (  )  const [virtual]

Returns the global extents of this drawable.

Reimplemented in Papyrus::Canvas.

References calculate_extents(), composed_matrix(), global_matrix(), and m_parent.

Matrix Papyrus::Drawable::global_matrix (  )  const [virtual]
void Papyrus::Drawable::global_to_local ( double &  x,
double &  y 
) const

Transform a global point to the drawable's local coordinates.

References global_matrix(), Papyrus::Matrix::invert(), matrix(), and Papyrus::Matrix::transform_point().

void Papyrus::Drawable::hide (  ) 
bool Papyrus::Drawable::inside ( double  x,
double  y 
) [virtual]
void Papyrus::Drawable::invalidate_composed_matrix (  )  [protected]
void Papyrus::Drawable::invalidate_extents (  )  [protected]
void Papyrus::Drawable::invalidate_matrix (  )  [protected]
bool Papyrus::Drawable::is_frozen (  ) 

True if the drawable is frozen.

References m_frozen, and m_frozen_by_parent.

bool Papyrus::Drawable::is_group (  )  [virtual]

True if this Drawable contains other drawables.

Reimplemented in Papyrus::Group.

bool Papyrus::Drawable::is_selectable (  ) 

True if this Drawable will respond to the select method, or false if it will not include itself in the select method.

References m_selectable.

bool Papyrus::Drawable::is_visible (  )  const

References m_visible.

Referenced by Papyrus::Handlebox::on_child_added().

void Papyrus::Drawable::local_to_global ( double &  x,
double &  y 
) const

Transform a local point to global coordinates.

References global_matrix(), and Papyrus::Matrix::transform_point().

const Drawable::MatrixMap & Papyrus::Drawable::matrices (  ) 

Get the map of external matrices for this object.

References m_matrices.

const Matrix & Papyrus::Drawable::matrix (  )  const
const Drawable::MatrixConnMap & Papyrus::Drawable::matrix_connection_map (  ) 

Internals exposed for the unit test framework.

Don't use this.

Get the matrix connection map for this object

References m_matrix_connections.

void Papyrus::Drawable::on_matrix_changed (  )  [protected]

References invalidate_composed_matrix(), and redraw().

Referenced by add_matrix(), and set_viewbox().

void Papyrus::Drawable::on_viewbox_changed (  )  [protected]

References invalidate_matrix(), and redraw().

Papyrus::Drawable::operator Drawable::pointer (  ) 
Papyrus::Drawable::PAPYRUS_RENDERABLE ( Drawable   ) 

Reimplemented in Papyrus::Shape, and Papyrus::Tiling.

Group * Papyrus::Drawable::parent (  )  [virtual]

References m_parent.

Region Papyrus::Drawable::pre_viewbox_extents ( const Matrix m = Matrix::Identity,
ExtentsPerformance  ep = EXTENTS_QUICK 
) const [virtual]
Region Papyrus::Drawable::raw_extents (  )  const [virtual]

These are the extents of the drawable without any matrices applied.

References calculate_extents().

void Papyrus::Drawable::redraw (  )  [protected, virtual]

Convenience method that children can call and will take care of emitting the need redraw signal with the proper parameters.

For efficiency, if a child needs less than a complete redraw the child could reimplement this method.

References extents(), Papyrus::Region::include(), Papyrus::Region::invalidate(), m_frozen, m_frozen_by_parent, m_need_redraw, m_redraw_extents, Papyrus::Object::m_signal_changed, m_signal_redraw, m_visible, x(), Papyrus::Region::xywh(), and y().

Referenced by Papyrus::Group::add(), add_matrix(), Papyrus::Group::clear(), clear_composite_operator(), Papyrus::Grid::disable_axis(), Papyrus::Grid::disable_border(), Papyrus::Grid::enable_axis(), Papyrus::Grid::enable_border(), Papyrus::Group::enable_intermediate_drawing(), hide(), Papyrus::Group::move_to_layer(), Papyrus::Boxed::on_child_added(), Papyrus::Boxed::on_child_changed(), Papyrus::Boxed::on_child_removed(), Papyrus::Boxed::on_cleared(), Papyrus::Tiling::on_default_fill_changed(), Papyrus::Tiling::on_fill_changed(), Papyrus::Shape::on_fill_changed(), on_matrix_changed(), Papyrus::Tiling::on_stroke_changed(), Papyrus::Shape::on_stroke_changed(), on_viewbox_changed(), Papyrus::Boxed::on_watched_event(), redraw_proxy(), Papyrus::Group::remove(), remove_matrix(), reset_position(), rotate(), scale(), Papyrus::Canvas::scroll_to(), Papyrus::Canvas::scroll_to_x(), Papyrus::Canvas::scroll_to_y(), set_alpha(), Papyrus::Canvas::set_background(), Papyrus::Boxed::set_box_position(), set_centroid(), set_centroid_x(), set_centroid_y(), set_composite_operator(), Papyrus::Canvas::set_device_resolution(), set_exclude_from_extents(), Papyrus::Group::set_fill(), Papyrus::Canvas::set_height(), Papyrus::Reference::set_referenced(), set_rotation(), set_scale(), set_scale_x(), set_scale_y(), Papyrus::Canvas::set_scroll_anchor(), Papyrus::Face::set_size(), Papyrus::Canvas::set_size(), Papyrus::Face::set_size_type(), set_skew(), set_skew_x(), set_skew_y(), Papyrus::Group::set_stroke(), Papyrus::Face::set_type(), Papyrus::Canvas::set_units(), set_viewbox(), Papyrus::Canvas::set_width(), set_x(), Papyrus::Grid::set_x_axis_stroke(), Papyrus::Grid::set_x_interval(), Papyrus::Grid::set_x_interval_stroke(), Papyrus::Grid::set_x_max(), Papyrus::Grid::set_x_min(), Papyrus::Grid::set_x_min_max(), set_xy(), Papyrus::Grid::set_xy_axis_stroke(), Papyrus::Grid::set_xy_interval(), Papyrus::Grid::set_xy_interval_stroke(), Papyrus::Grid::set_xy_min_max(), set_y(), Papyrus::Grid::set_y_axis_stroke(), Papyrus::Grid::set_y_interval(), Papyrus::Grid::set_y_interval_stroke(), Papyrus::Grid::set_y_max(), Papyrus::Grid::set_y_min(), Papyrus::Grid::set_y_min_max(), Papyrus::Tiling::shape_changed(), Papyrus::Shape::shape_changed(), show(), skew(), thaw(), and translate().

void Papyrus::Drawable::redraw_proxy (  ) 

This is a proxy for the virtual redraw() method.

The changed signal of the viewbox is connected to this proxy that in turn calls the appropriate version of redraw(). HACK For some reason child Shape can't access this parent method when protected

References redraw().

void Papyrus::Drawable::remove_matrix ( const Matrix::pointer  m,
int  level 
)

Remove matrix m from the specified level.

If matrix m is not on the level specified no action will be taken.

References invalidate_composed_matrix(), m_matrices, m_matrix_connections, and redraw().

void Papyrus::Drawable::remove_matrix ( const Matrix::pointer  m  ) 

Remove matrix m from all matrix levels.

References invalidate_composed_matrix(), m_matrices, m_matrix_connections, and redraw().

void Papyrus::Drawable::render ( Context cairo,
double  x,
double  y,
double  w,
double  h 
) const [virtual]

Reimplemented render method from renderable.

Similar to the render(cairo context) method except checks to see if the renderable is within the bounding box before rendering.

Reimplemented from Papyrus::Renderable.

References extents(), and render().

void Papyrus::Drawable::render ( Context cairo  )  const [virtual]

Reimplemented render method from renderable.

Generally, children should reimplement the draw method rather than this method.

Performs the following actions: 1. Pushes cairo state onto the stack 2. Recalculates local matrix if necessary 3. Applies the local matrix to the current matrix 4. Calls the virtual draw method 5. Restores the cairo state

Implements Papyrus::Renderable.

References draw(), m_alpha, m_composite_operator, m_viewbox, m_visible, matrix(), Papyrus::Context::paint_with_alpha(), Papyrus::Context::restore(), Papyrus::Context::save(), Papyrus::Viewbox::SLICE, Papyrus::Context::transform(), x(), and y().

Referenced by calculate_extents(), Papyrus::Quadrille::draw(), Papyrus::Polyline::draw(), Papyrus::Hextille::draw(), Papyrus::Deltille::draw(), inside(), and render().

void Papyrus::Drawable::reset_position (  ) 

Reset position to default values of xy = (0,0), scale = (1,1), rotation = 0, and shear xy = (0,0).

References invalidate_composed_matrix(), m_centroid_x, m_centroid_y, m_r, m_skewx, m_skewy, m_sx, m_sy, m_x, m_y, and redraw().

void Papyrus::Drawable::rotate ( double  r,
DegRad  unit = RADIANS 
)

Relative rotation of the current value by r.

If previous rotation was pr then new rotation is pr+r

References invalidate_composed_matrix(), m_r, redraw(), and Papyrus::units2rad().

void Papyrus::Drawable::scale ( double  scale_x,
double  scale_y 
)

Independently scales the current x and y scaling values.

Parameters:
scale_x The amount to scale the x dimension by; must be > 0.0 or no change will occur
scale_y The amount to scale the y dimension by; must be > 0.0 or no change will occur

References invalidate_composed_matrix(), m_sx, m_sy, and redraw().

void Papyrus::Drawable::scale ( double  s  ) 

Uniformly scales the current x and y scaling values by s.

Parameters:
s The amount to scale the x and y dimensions by; must be > 0.0 or no change will occur

References invalidate_composed_matrix(), m_sx, m_sy, and redraw().

Drawable::pointer Papyrus::Drawable::self (  ) 

References m_self.

void Papyrus::Drawable::set ( const AttributeValueMap avmap  )  [virtual]
void Papyrus::Drawable::set_alpha ( double  a  ) 

References m_alpha, and redraw().

void Papyrus::Drawable::set_centroid ( double  centroid_x,
double  centroid_y 
)
void Papyrus::Drawable::set_centroid_x ( double  centroid_x  ) 
void Papyrus::Drawable::set_centroid_y ( double  centroid_y  ) 
void Papyrus::Drawable::set_composite_operator ( Cairo::Operator  op  ) 

Sets the composite operator of this drawable.

References m_composite_operator, and redraw().

void Papyrus::Drawable::set_exclude_from_extents ( bool  b = true  ) 

Exclude this drawable from all extents calculations of its parent.

References m_exclude_from_extents, and redraw().

void Papyrus::Drawable::set_rotation ( double  r,
DegRad  unit = RADIANS 
)

Absolute set of the current rotation value to r using the specified units.

References invalidate_composed_matrix(), m_r, redraw(), and Papyrus::units2rad().

Referenced by Papyrus::Polyline::draw().

void Papyrus::Drawable::set_scale ( double  s  ) 

Absolute set of the x and y dimension scalings using a uniform scaling value.

Parameters:
s The amount to scale the x and y dimensions by; must be > 0.0 or no change will occur

References invalidate_composed_matrix(), m_sx, m_sy, and redraw().

void Papyrus::Drawable::set_scale ( double  scale_x,
double  scale_y 
)

Absolute set of the x and y dimension scalings using independent values for each.

Parameters:
scale_x The new x dimension scaling; must be > 0.0 or no change to x scaling will occur
scale_y The new y dimension scaling; must be > 0.0 or no change to y scaling will occur

References invalidate_composed_matrix(), m_sx, m_sy, and redraw().

void Papyrus::Drawable::set_scale_x ( double  sx  ) 

Absolute set of the x dimension scaling value.

Parameters:
sx The new x dimension scaling; must be > 0.0 or no change to x scaling will occur

References invalidate_composed_matrix(), m_sx, and redraw().

void Papyrus::Drawable::set_scale_y ( double  sy  ) 

Absolute set of the y dimension scaling value.

Parameters:
sy The new y dimension scaling; must be > 0.0 or no change to y scaling will occur

References invalidate_composed_matrix(), m_sy, and redraw().

void Papyrus::Drawable::set_selectable ( bool  selectable = true  ) 

Set to true if this Drawable will respond to the select method.

For example, it may not be desirable to have a group respond to the select method itself, and may instead pass the select(x,y) request to its children.

References m_selectable.

Referenced by Papyrus::Group::Group().

void Papyrus::Drawable::set_skew ( double  s,
DegRad  unit = RADIANS 
)

Absolute set of the x-axis and y-axis skewing angles using the same value for each axis.

References invalidate_composed_matrix(), m_skewx, m_skewy, redraw(), and Papyrus::units2rad().

void Papyrus::Drawable::set_skew ( double  skewx,
double  skewy,
DegRad  unit = RADIANS 
)

Absolute set of the x-axis and y-axis skewing angles using separate values for each axis.

References invalidate_composed_matrix(), m_skewx, m_skewy, redraw(), and Papyrus::units2rad().

void Papyrus::Drawable::set_skew_x ( double  skewx,
DegRad  unit = RADIANS 
)

Absolute set of the x-axis skewing angle.

References invalidate_composed_matrix(), m_skewx, redraw(), and Papyrus::units2rad().

void Papyrus::Drawable::set_skew_y ( double  skewy,
DegRad  unit = RADIANS 
)

Absolute set of the y-axis skewing angle.

References invalidate_composed_matrix(), m_skewy, redraw(), and Papyrus::units2rad().

void Papyrus::Drawable::set_viewbox ( const Viewbox viewbox  ) 

Sets this Drawable's viewbox to the provided viewbox.

This method will not maintain a connection to the provided Viewbox, and will create its own copy.

References Papyrus::Viewbox::create(), and set_viewbox().

void Papyrus::Drawable::set_viewbox ( const Region region,
Viewbox::ALIGN  align = Viewbox::ALIGN_XMAX_YMAX,
Viewbox::MEET_OR_SLICE  meet_or_slice = Viewbox::MEET 
)
void Papyrus::Drawable::set_viewbox ( double  x,
double  y,
double  w,
double  h,
Viewbox::ALIGN  align = Viewbox::ALIGN_XMAX_YMAX,
Viewbox::MEET_OR_SLICE  meet_or_slice = Viewbox::MEET 
)
void Papyrus::Drawable::set_viewbox ( Viewbox::pointer  viewbox = Viewbox::pointer()  ) 

Sets this Drawable's viewbox to the provided viewbox.

This method does not copy the viewbox, but will hold shared ownership of the shared smart pointer.

Calling set_viewbox() with no parameters sets the viewbox to a null pointer, thus removing it.

References invalidate_matrix(), m_viewbox, m_viewbox_connection, on_matrix_changed(), and redraw().

Referenced by set_viewbox().

void Papyrus::Drawable::set_x ( double  x  ) 

Absolute move of the x position.

If previous position was (x',y') new position is (x,y').

References invalidate_composed_matrix(), m_x, and redraw().

Referenced by Papyrus::Rectangle::Rectangle(), set(), Papyrus::Circle::set(), and Papyrus::Rectangle::set_xywh().

void Papyrus::Drawable::set_xy ( double  x,
double  y 
)

Absolute move to (x,y).

References invalidate_composed_matrix(), m_x, m_y, and redraw().

void Papyrus::Drawable::set_y ( double  y  ) 

Absolute move of the y position.

If previous position was (x',y') new position is (x',y).

References invalidate_composed_matrix(), m_y, and redraw().

Referenced by Papyrus::Rectangle::Rectangle(), set(), Papyrus::Circle::set(), and Papyrus::Rectangle::set_xywh().

void Papyrus::Drawable::show (  ) 

References m_visible, and redraw().

sigc::signal< void > & Papyrus::Drawable::signal_composed_matrix_invalidated (  ) 

Signal emitted when the composed matrix is invalidated.

References m_signal_composed_matrix_invalidated.

sigc::signal< void > & Papyrus::Drawable::signal_destroyed (  ) 

Signal emitted when this drawable is destroyed.

References m_signal_destroyed.

sigc::signal< void > & Papyrus::Drawable::signal_extents_changed (  ) 

Signal emitted when the extents are changed.

References m_signal_extents_changed.

sigc::signal< void, FrozenThawed > & Papyrus::Drawable::signal_frozen (  ) 

Signal emitted when the frozen/thawed state is changed.

References m_signal_frozen.

sigc::signal< void, double, double, double, double > & Papyrus::Drawable::signal_redraw (  ) 

Signal emitted with x,y,w,h values when this Drawable needs to be redrawn.

References m_signal_redraw.

sigc::signal< void > & Papyrus::Drawable::signal_selectable (  ) 

Signal emitted when the selectable value is changed.

References m_signal_selectable.

void Papyrus::Drawable::skew ( double  s,
DegRad  unit = RADIANS 
)

Relative skewing of the x-axis and y-axis angles by the same value for each axis.

References invalidate_composed_matrix(), m_skewx, m_skewy, redraw(), and Papyrus::units2rad().

void Papyrus::Drawable::skew ( double  x,
double  y,
DegRad  unit = RADIANS 
)

Relative skewing of the x-axis and y-axis angles using separate values for each axis.

References invalidate_composed_matrix(), m_skewx, m_skewy, redraw(), and Papyrus::units2rad().

Glib::ustring Papyrus::Drawable::svg_transform (  )  [protected]
void Papyrus::Drawable::thaw ( bool  force_redraw = false  )  [virtual]

Thaw the drawable, causing any changes to be updated.

Freeze/Thaw are still an early implementation that only prevents the redraw signal from emitting. However, if other events trigger a redraw the 'frozen' changes will still be reflected.

Todo:
Fix the freeze/thaw structure so freezing is really freezing

Reimplemented in Papyrus::Group.

References m_frozen, m_frozen_by_parent, m_need_redraw, Papyrus::Object::m_signal_changed, m_signal_frozen, redraw(), and Papyrus::THAWED.

Referenced by Papyrus::Image::on_image_changed(), Papyrus::Tiling::set_columns(), Papyrus::Tiling::set_columns_rows(), Papyrus::Rectangle::set_height(), Papyrus::Tiling::set_rows(), Papyrus::Tiling::set_side_length(), Papyrus::Rectangle::set_width(), and Papyrus::Rectangle::set_xywh().

void Papyrus::Drawable::translate ( double  tx,
double  ty 
)

Relative translation of the current position by (tx, ty).

If previous position was (x',y') new position is (x'+tx, y'+ty).

References invalidate_composed_matrix(), m_x, m_y, and redraw().

Viewbox::pointer Papyrus::Drawable::viewbox (  ) 

Returns the viewbox associated with this Drawable.

If no viewbox is associated, the pointer returned will be a null smart pointer.

References m_viewbox.

double Papyrus::Drawable::x (  )  const
double Papyrus::Drawable::y (  )  const

Friends And Related Function Documentation

friend class Group [friend]

Member Data Documentation

double Papyrus::Drawable::m_alpha [protected]

Referenced by alpha(), render(), and set_alpha().

The drawable's local matrix.

Referenced by composed_matrix().

When true, this drawable's transformation matrix is invalid and needs to be calculated.

Referenced by composed_matrix(), and invalidate_composed_matrix().

If true, this object will be excluded from a parent's extents calculation.

This variable has no effect on this drawable's calculations of its own extents

Referenced by exclude_from_extents(), and set_exclude_from_extents().

These are the final extents of the drawable.

Referenced by extents(), and matrix().

bool Papyrus::Drawable::m_frozen [protected]

If true the drawable is frozen.

Referenced by Papyrus::Group::freeze(), freeze(), is_frozen(), redraw(), Papyrus::Group::thaw(), and thaw().

If true the drawable is frozen by parent.

Referenced by is_frozen(), redraw(), Papyrus::Group::thaw(), and thaw().

This is the final matrix applied when drawing occurs and is the composed matrix multiplied by the viewbox matrix.

Referenced by matrix().

If true a redraw will occur when thawed or when parent is unthawed.

Referenced by redraw(), Papyrus::Group::thaw(), and thaw().

These are the extents of the drawable without the transformation matrix applied.

Referenced by Papyrus::Group::add(), and pre_viewbox_extents().

If true, calculate_pre_viewbox_extents() will be called before extents() or pre_viewbox_extents() returns.

Referenced by invalidate_composed_matrix(), invalidate_extents(), and pre_viewbox_extents().

double Papyrus::Drawable::m_r [private]

rotation value in radians

Referenced by calculate_composed_matrix(), get_rotation(), reset_position(), rotate(), and set_rotation().

Redraw extents containing areas that need redraws including the current extents plus any old ones.

Referenced by extents(), and redraw().

whether the drawable is selectable

Referenced by is_selectable(), and set_selectable().

weak_pointer Papyrus::Drawable::m_self [protected]

Referenced by self().

Referenced by calculate_extents(), and inside().

Cairo::RefPtr< Cairo::ImageSurface > Papyrus::Drawable::m_sidebuffer_image [static, protected]

Signal emitted when the composed matrix is invalidated.

Referenced by invalidate_composed_matrix(), and signal_composed_matrix_invalidated().

sigc::signal<void> Papyrus::Drawable::m_signal_destroyed [protected]

Signal emitted when this drawable is destroyed.

Referenced by signal_destroyed(), and ~Drawable().

sigc::signal<void> Papyrus::Drawable::m_signal_extents_changed [protected]

Signal emitted when the extents change.

Referenced by Papyrus::Group::add(), invalidate_extents(), and signal_extents_changed().

sigc::signal<void,FrozenThawed> Papyrus::Drawable::m_signal_frozen [protected]

Signal emitted when the drawable is frozen / thawed.

Referenced by freeze(), signal_frozen(), and thaw().

sigc::signal<void, double, double, double, double> Papyrus::Drawable::m_signal_redraw [protected]

Signal emitted when this object has changed and needs to be redrawn.

Referenced by Papyrus::Group::on_child_redraw(), redraw(), and signal_redraw().

sigc::signal<void> Papyrus::Drawable::m_signal_selectable [protected]

Signal emitted when the selectable value is changed.

Referenced by signal_selectable().

double Papyrus::Drawable::m_skewx [private]
double Papyrus::Drawable::m_skewy [private]
double Papyrus::Drawable::m_sx [private]
double Papyrus::Drawable::m_sy [private]

Pointer to a viewbox, which may be null if this Drawable doesn't have a viewbox.

Referenced by extents(), matrix(), render(), set_viewbox(), and viewbox().

sigc::connection Papyrus::Drawable::m_viewbox_connection [protected]

Referenced by set_viewbox().

bool Papyrus::Drawable::m_visible [protected]

Referenced by hide(), is_visible(), redraw(), render(), and show().

double Papyrus::Drawable::m_x [private]
double Papyrus::Drawable::m_y [private]

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

Generated on Fri Apr 16 12:41:06 2010 for papyrus by doxygen 1.6.1