# studio::Duckmatic Class Reference

`#include <duckmatic.h>`

Inheritance diagram for studio::Duckmatic:

List of all members.

## Public Types

typedef std::map< synfig::GUID, etl::smart_ptr< synfig::Point > > | DuckDataMap
typedef studio::DuckMap | DuckMap
typedef studio::Duck | Duck
typedef Duck::Type | Type
typedef std::list< float > | GuideList

## Public Member Functions

| Duckmatic ()
virtual | ~Duckmatic ()
sigc::signal< void > & | signal_duck_selection_changed ()
sigc::signal< void > & | signal_strokes_changed ()
sigc::signal< void > & | signal_grid_changed ()
sigc::signal< void > & | signal_sketch_saved ()
GuideList & | get_guide_list_x ()
GuideList & | get_guide_list_y ()
const GuideList & | get_guide_list_x () const
const GuideList & | get_guide_list_y () const
void | set_guide_snap (bool x=true)
bool | get_guide_snap () const
void | toggle_guide_snap ()
void | set_grid_snap (bool x=true)
| Sets the state of the grid snap flag.
bool | get_grid_snap () const
| Gets the state of the grid snap flag.
void | enable_grid_snap ()
void | disable_grid_snap ()
void | toggle_grid_snap ()
synfig::Point | snap_point_to_grid (const synfig::Point &x, float radius=0.1) const
bool | get_show_persistent_strokes () const
void | set_show_persistent_strokes (bool x)
void | set_grid_size (const synfig::Vector &s)
| Sets the size of the grid.
const synfig::Vector & | get_grid_size () const
| Returns the size of the grid.
const synfig::Time & | get_time () const
bool | get_axis_lock () const
void | set_axis_lock (bool x)
void | set_time (synfig::Time x)
bool | is_duck_group_selectable (const etl::handle< Duck > &x) const
DuckList | get_duck_list () const
const std::list< etl::handle < Bezier > > & | bezier_list () const
const std::list< etl::handle < Stroke > > & | stroke_list () const
const std::list< etl::handle < Stroke > > & | persistent_stroke_list () const
std::list< etl::handle< Stroke > > & | persistent_stroke_list ()
etl::handle< Duck > | get_selected_duck () const
DuckList | get_selected_ducks () const
bool | duck_is_selected (const etl::handle< Duck > &duck) const
| Returns true if the given duck is currently selected.
void | refresh_selected_ducks ()
void | clear_selected_ducks ()
int | count_selected_ducks () const
void | toggle_select_duck (const etl::handle< Duck > &duck)
void | select_duck (const etl::handle< Duck > &duck)
void | toggle_select_ducks_in_box (const synfig::Vector &tl, const synfig::Vector &br)
void | select_ducks_in_box (const synfig::Vector &tl, const synfig::Vector &br)
void | unselect_duck (const etl::handle< Duck > &duck)
void | start_duck_drag (const synfig::Vector &offset)
void | translate_selected_ducks (const synfig::Vector &vector)
bool | end_duck_drag ()
void | signal_edited_selected_ducks ()
void | signal_user_click_selected_ducks (int button)
etl::handle< Duck > | find_similar_duck (etl::handle< Duck > duck)
etl::handle< Duck > | add_similar_duck (etl::handle< Duck > duck)
void | add_stroke (etl::smart_ptr< std::list< synfig::Point > > stroke_point_list, const synfig::Color &color=synfig::Color(0, 0, 0))
void | add_persistent_stroke (etl::smart_ptr< std::list< synfig::Point > > stroke_point_list, const synfig::Color &color=synfig::Color(0, 0, 0))
void | clear_persistent_strokes ()
void | add_duck (const etl::handle< Duck > &duck)
void | add_bezier (const etl::handle< Bezier > &bezier)
void | erase_duck (const etl::handle< Duck > &duck)
void | erase_bezier (const etl::handle< Bezier > &bezier)
etl::handle< Duck > | last_duck () const
| Returns the last duck added.
etl::handle< Bezier > | last_bezier () const
etl::handle< Duck > | find_duck (synfig::Point pos, synfig::Real radius=0, Duck::Type type=Duck::TYPE_DEFAULT)
GuideList::iterator | find_guide_x (synfig::Point pos, float radius=0.1)
GuideList::iterator | find_guide_y (synfig::Point pos, float radius=0.1)
GuideList::const_iterator | find_guide_x (synfig::Point pos, float radius=0.1) const
GuideList::const_iterator | find_guide_y (synfig::Point pos, float radius=0.1) const
etl::handle< Bezier > | find_bezier (synfig::Point pos, synfig::Real radius=0, float *location=0)
etl::handle< Bezier > | find_bezier (synfig::Point pos, synfig::Real scale, synfig::Real radius, float *location=0)
bool | add_to_ducks (const synfigapp::ValueDesc &value_desc, etl::handle< CanvasView > canvas_view, const synfig::TransformStack &transform_stack_, synfig::ParamDesc *param_desc=0, int multiple=0)
void | set_type_mask (Type x)
Type | get_type_mask () const
void | select_all_ducks ()
void | unselect_all_ducks ()
void | clear_ducks ()
bool | save_sketch (const synfig::String &filename) const
bool | load_sketch (const synfig::String &filename)
const synfig::String & | get_sketch_filename () const
void | set_duck_dragger (etl::handle< DuckDrag_Base > x)
etl::handle< DuckDrag_Base > | get_duck_dragger () const
void | clear_duck_dragger ()

## Protected Attributes

etl::handle< Bezier > | selected_bezier
synfig::Time | cur_time
bool | grid_snap
| This flag is set if operations should snap to the grid.
bool | guide_snap
synfig::Vector | grid_size
| This vector describes the grid size.
bool | show_persistent_strokes
bool | axis_lock

## Friends

class | DuckDrag_Base
class | DuckDrag_Translate
class | Push

## Classes

struct | Bezier
class | Push
struct | Stroke

## Detailed Description

This class helps organize any of the devices displayed in the work area that the user may want to interact with. This includes ducks, beziers, and strokes

Note:
  At some point I'll probably rename this class to "DuckOMatic".

## Member Typedef Documentation

typedef std::map<synfig::GUID,etl::smart_ptr<synfig::Point> > studio::Duckmatic::DuckDataMap

typedef studio::DuckMap studio::Duckmatic::DuckMap

typedef studio::Duck studio::Duckmatic::Duck

typedef Duck::Type studio::Duckmatic::Type

typedef std::list<float> studio::Duckmatic::GuideList

## Constructor & Destructor Documentation

Duckmatic::Duckmatic | ( |  | ) |

References axis_lock, and clear_duck_dragger().

Duckmatic::~Duckmatic | ( |  | ) | `[virtual]`

References clear_ducks().

## Member Function Documentation

sigc::signal<void>& studio::Duckmatic::signal_duck_selection_changed | ( |  | ) | `[inline]`

Referenced by studio::WorkArea::WorkArea().

sigc::signal<void>& studio::Duckmatic::signal_strokes_changed | ( |  | ) | `[inline]`

Referenced by studio::WorkArea::WorkArea().

sigc::signal<void>& studio::Duckmatic::signal_grid_changed | ( |  | ) | `[inline]`

Referenced by set_grid_size(), set_grid_snap(), set_guide_snap(), and studio::WorkArea::WorkArea().

sigc::signal<void>& studio::Duckmatic::signal_sketch_saved | ( |  | ) | `[inline]`

Referenced by studio::WorkArea::WorkArea().

GuideList& studio::Duckmatic::get_guide_list_x | ( |  | ) | `[inline]`

Referenced by studio::Renderer_Guides::get_guide_list_x(), studio::WorkArea::load_meta_data(), and studio::WorkArea::save_meta_data().

GuideList& studio::Duckmatic::get_guide_list_y | ( |  | ) | `[inline]`

Referenced by studio::Renderer_Guides::get_guide_list_y(), studio::WorkArea::load_meta_data(), and studio::WorkArea::save_meta_data().

const GuideList& studio::Duckmatic::get_guide_list_x | ( |  | ) | const`[inline]`

const GuideList& studio::Duckmatic::get_guide_list_y | ( |  | ) | const`[inline]`

void Duckmatic::set_guide_snap | ( | bool | x = `true` | ) |

References guide_snap, and signal_grid_changed().

Referenced by studio::WorkArea::load_meta_data(), and toggle_guide_snap().

bool studio::Duckmatic::get_guide_snap | ( |  | ) | const`[inline]`

References guide_snap.

Referenced by studio::WorkArea::save_meta_data(), and toggle_guide_snap().

void studio::Duckmatic::toggle_guide_snap | ( |  | ) | `[inline]`

References get_guide_snap(), and set_guide_snap().

void Duckmatic::set_grid_snap | ( | bool | x = `true` | ) |

Sets the state of the grid snap flag.

References grid_snap, and signal_grid_changed().

Referenced by disable_grid_snap(), enable_grid_snap(), studio::WorkArea::load_meta_data(), and toggle_grid_snap().

bool studio::Duckmatic::get_grid_snap | ( |  | ) | const`[inline]`

Gets the state of the grid snap flag.

References grid_snap.

Referenced by studio::WorkArea::save_meta_data(), and snap_point_to_grid().

void studio::Duckmatic::enable_grid_snap | ( |  | ) | `[inline]`

References set_grid_snap().

void studio::Duckmatic::disable_grid_snap | ( |  | ) | `[inline]`

References set_grid_snap().

void studio::Duckmatic::toggle_grid_snap | ( |  | ) | `[inline]`

Reimplemented in studio::WorkArea.

References grid_snap, and set_grid_snap().

Referenced by studio::WorkArea::toggle_grid_snap().

Point Duckmatic::snap_point_to_grid | ( | const synfig::Point & | x,
|  | float | radius = `0.1` |
| ) |  |  | const

References axis_lock, find_guide_x(), find_guide_y(), get_grid_size(), get_grid_snap(), and guide_snap.

Referenced by studio::DuckDrag_Translate::duck_drag().

bool studio::Duckmatic::get_show_persistent_strokes | ( |  | ) | const`[inline]`

References show_persistent_strokes.

void Duckmatic::set_show_persistent_strokes | ( | bool | x | ) |

References show_persistent_strokes.

void Duckmatic::set_grid_size | ( | const synfig::Vector & | s | ) |

Sets the size of the grid.

Reimplemented in studio::WorkArea.

References grid_size, and signal_grid_changed().

Referenced by studio::WorkArea::set_grid_size().

const synfig::Vector& studio::Duckmatic::get_grid_size | ( |  | ) | const`[inline]`

Returns the size of the grid.

References grid_size.

Referenced by studio::Renderer_Timecode::get_grid_size(), studio::Renderer_Grid::get_grid_size(), studio::WorkArea::load_meta_data(), studio::WorkArea::refresh_dimension_info(), studio::WorkArea::save_meta_data(), and snap_point_to_grid().

const synfig::Time& studio::Duckmatic::get_time | ( |  | ) | const`[inline]`

References cur_time.

Referenced by add_to_ducks(), studio::WorkArea::async_render_preview(), studio::DuckDrag_Translate::duck_drag(), studio::WorkArea::sync_render_preview(), studio::WorkArea::sync_render_preview_hook(), and studio::WorkArea::sync_update_preview().

bool studio::Duckmatic::get_axis_lock | ( |  | ) | const`[inline]`

References axis_lock.

void studio::Duckmatic::set_axis_lock | ( | bool | x | ) | `[inline]`

References axis_lock.

void studio::Duckmatic::set_time | ( | synfig::Time | x | ) | `[inline]`

References cur_time.

bool Duckmatic::is_duck_group_selectable | ( | const etl::handle< Duck > & | x | ) | const

References get_type_mask(), and studio::Duck::TYPE_POSITION.

Referenced by select_all_ducks(), select_ducks_in_box(), and toggle_select_ducks_in_box().

DuckList Duckmatic::get_duck_list | ( |  | ) | const

References studio::Duck::TYPE_POSITION, studio::Duck::TYPE_TANGENT, and studio::Duck::TYPE_VERTEX.

Referenced by studio::DuckDrag_Translate::duck_drag().

const std::list<etl::handle<Bezier> >& studio::Duckmatic::bezier_list | ( |  | ) | const`[inline]`

Referenced by find_bezier().

const std::list<etl::handle<Stroke> >& studio::Duckmatic::stroke_list | ( |  | ) | const`[inline]`

const std::list<etl::handle<Stroke> >& studio::Duckmatic::persistent_stroke_list | ( |  | ) | const`[inline]`

std::list<etl::handle<Stroke> >& studio::Duckmatic::persistent_stroke_list | ( |  | ) | `[inline]`

etl::handle< Duckmatic::Duck > Duckmatic::get_selected_duck | ( |  | ) | const

Todo:
  We should modify this to support multiple selections

DuckList Duckmatic::get_selected_ducks | ( |  | ) | const

References get_type_mask().

Referenced by studio::DuckDrag_Translate::begin_duck_drag(), studio::DuckDrag_Translate::duck_drag(), signal_edited_selected_ducks(), and signal_user_click_selected_ducks().

bool Duckmatic::duck_is_selected | ( | const etl::handle< Duck > & | duck | ) | const

Returns true if the given duck is currently selected.

Referenced by toggle_select_duck().

void Duckmatic::refresh_selected_ducks | ( |  | ) |

void Duckmatic::clear_selected_ducks | ( |  | ) |

int Duckmatic::count_selected_ducks | ( |  | ) | const

void Duckmatic::toggle_select_duck | ( | const etl::handle< Duck > & | duck | ) |

References duck_is_selected(), select_duck(), and unselect_duck().

Referenced by toggle_select_ducks_in_box().

void Duckmatic::select_duck | ( | const etl::handle< Duck > & | duck | ) |

Referenced by select_all_ducks(), select_ducks_in_box(), and toggle_select_duck().

void Duckmatic::toggle_select_ducks_in_box | ( | const synfig::Vector & | tl,
|  | const synfig::Vector & | br |
| ) |  |  |

References is_duck_group_selectable(), and toggle_select_duck().

void Duckmatic::select_ducks_in_box | ( | const synfig::Vector & | tl,
|  | const synfig::Vector & | br |
| ) |  |  |

References is_duck_group_selectable(), and select_duck().

void Duckmatic::unselect_duck | ( | const etl::handle< Duck > & | duck | ) |

Referenced by select_all_ducks(), toggle_select_duck(), and unselect_all_ducks().

void Duckmatic::start_duck_drag | ( | const synfig::Vector & | offset | ) |

References find_duck().

void Duckmatic::translate_selected_ducks | ( | const synfig::Vector & | vector | ) |

bool Duckmatic::end_duck_drag | ( |  | ) |

void Duckmatic::signal_edited_selected_ducks | ( |  | ) |

References get_selected_ducks(), studio::App::restrict_radius_ducks, and studio::Duck::TYPE_ANGLE.

Referenced by studio::DuckDrag_Translate::end_duck_drag().

void Duckmatic::signal_user_click_selected_ducks | ( | int | button | ) |

References get_selected_ducks().

Referenced by studio::DuckDrag_Translate::end_duck_drag().

etl::handle< Duckmatic::Duck > Duckmatic::find_similar_duck | ( | etl::handle< Duck > | duck | ) |

Referenced by add_similar_duck().

etl::handle< Duckmatic::Duck > Duckmatic::add_similar_duck | ( | etl::handle< Duck > | duck | ) |

References add_duck(), and find_similar_duck().

Referenced by add_to_ducks().

void Duckmatic::add_stroke | ( | etl::smart_ptr< std::list< synfig::Point > > | stroke_point_list,
|  | const synfig::Color & | color = `synfig::Color(0,0,0)` |
| ) |  |  |

Referenced by add_persistent_stroke().

void Duckmatic::add_persistent_stroke | ( | etl::smart_ptr< std::list< synfig::Point > > | stroke_point_list,
|  | const synfig::Color & | color = `synfig::Color(0,0,0)` |
| ) |  |  |

References add_stroke().

Referenced by load_sketch().

void Duckmatic::clear_persistent_strokes | ( |  | ) |

void Duckmatic::add_duck | ( | const etl::handle< Duck > & | duck | ) |

References studio::DuckMap::insert().

Referenced by add_similar_duck(), and add_to_ducks().

void Duckmatic::add_bezier | ( | const etl::handle< Bezier > & | bezier | ) |

Referenced by add_to_ducks().

void Duckmatic::erase_duck | ( | const etl::handle< Duck > & | duck | ) |

void Duckmatic::erase_bezier | ( | const etl::handle< Bezier > & | bezier | ) |

etl::handle< Duckmatic::Duck > Duckmatic::last_duck | ( |  | ) | const

Returns the last duck added.

Referenced by add_to_ducks().

etl::handle< Duckmatic::Bezier > Duckmatic::last_bezier | ( |  | ) | const

Referenced by add_to_ducks().

etl::handle< Duckmatic::Duck > Duckmatic::find_duck | ( | synfig::Point | pos,
|  | synfig::Real | radius = `0`,
|  | Duck::Type | type = `Duck::TYPE_DEFAULT` |
| ) |  |  |

Note:
  parameter is in canvas coordinates

A radius of "zero" will have an unlimited radius

References get_type_mask(), studio::Duck::TYPE_DEFAULT, studio::Duck::TYPE_RADIUS, studio::Duck::TYPE_TANGENT, and studio::Duck::TYPE_VERTEX.

Referenced by studio::DuckDrag_Translate::begin_duck_drag(), and start_duck_drag().

Duckmatic::GuideList::iterator Duckmatic::find_guide_x | ( | synfig::Point | pos,
|  | float | radius = `0.1` |
| ) |  |  |

Referenced by find_guide_x(), and snap_point_to_grid().

Duckmatic::GuideList::iterator Duckmatic::find_guide_y | ( | synfig::Point | pos,
|  | float | radius = `0.1` |
| ) |  |  |

Referenced by find_guide_y(), and snap_point_to_grid().

GuideList::const_iterator studio::Duckmatic::find_guide_x | ( | synfig::Point | pos,
|  | float | radius = `0.1` |
| ) |  |  | const`[inline]`

References find_guide_x().

GuideList::const_iterator studio::Duckmatic::find_guide_y | ( | synfig::Point | pos,
|  | float | radius = `0.1` |
| ) |  |  | const`[inline]`

References find_guide_y().

etl::handle< Duckmatic::Bezier > Duckmatic::find_bezier | ( | synfig::Point | pos,
|  | synfig::Real | radius = `0`,
|  | float * | location = `0` |
| ) |  |  |

Note:
  parameter is in canvas coordinates

A radius of "zero" will have an unlimited radius

Note:
  parameter is in canvas coordinates

A radius of "zero" will have an unlimited radius

etl::handle< Duckmatic::Bezier > Duckmatic::find_bezier | ( | synfig::Point | pos,
|  | synfig::Real | scale,
|  | synfig::Real | radius,
|  | float * | location = `0` |
| ) |  |  |

References bezier_list().

bool Duckmatic::add_to_ducks | ( | const synfigapp::ValueDesc & | value_desc,
|  | etl::handle< CanvasView > | canvas_view,
|  | const synfig::TransformStack & | transform_stack_,
|  | synfig::ParamDesc * | param_desc = `0`,
|  | int | multiple = `0` |
| ) |  |  |

References add_bezier(), add_duck(), add_similar_duck(), studio::Duckmatic::Bezier::c1, studio::Duckmatic::Bezier::c2, calc_duck_guid(), synfigapp::ValueDesc::get_layer(), get_time(), synfigapp::ValueDesc::get_value(), synfigapp::ValueDesc::get_value_node(), synfigapp::ValueDesc::get_value_type(), guid_string(), synfigapp::is_editable(), synfigapp::ValueDesc::is_value_node(), last_bezier(), last_duck(), studio::Duckmatic::Bezier::p1, studio::Duckmatic::Bezier::p2, REAL_COOKIE, studio::Duck::set_transform_stack(), TANGENT_BEZIER_SCALE, TANGENT_HANDLE_SCALE, studio::Duck::TYPE_ANGLE, studio::Duck::TYPE_POSITION, studio::Duck::TYPE_RADIUS, studio::Duck::TYPE_TANGENT, studio::Duck::TYPE_VERTEX, and studio::Duck::TYPE_WIDTH.

void studio::Duckmatic::set_type_mask | ( | Type | x | ) | `[inline]`

Todo:
  This needs to be documented further.

Type studio::Duckmatic::get_type_mask | ( |  | ) | const`[inline]`

Todo:
  This needs to be documented further.

Referenced by find_duck(), get_selected_ducks(), is_duck_group_selectable(), and studio::Renderer_Ducks::render_vfunc().

void Duckmatic::select_all_ducks | ( |  | ) |

References is_duck_group_selectable(), select_duck(), and unselect_duck().

void Duckmatic::unselect_all_ducks | ( |  | ) |

References unselect_duck().

void Duckmatic::clear_ducks | ( |  | ) |

References show_persistent_strokes.

Referenced by ~Duckmatic().

bool Duckmatic::save_sketch | ( | const synfig::String & | filename | ) | const

bool Duckmatic::load_sketch | ( | const synfig::String & | filename | ) |

References add_persistent_stroke().

Referenced by studio::WorkArea::WorkArea().

const synfig::String& studio::Duckmatic::get_sketch_filename | ( |  | ) | const`[inline]`

Referenced by studio::WorkArea::save_meta_data().

void studio::Duckmatic::set_duck_dragger | ( | etl::handle< DuckDrag_Base > | x | ) | `[inline]`

etl::handle<DuckDrag_Base> studio::Duckmatic::get_duck_dragger | ( |  | ) | const`[inline]`

void studio::Duckmatic::clear_duck_dragger | ( |  | ) | `[inline]`

References DuckDrag_Translate.

Referenced by Duckmatic().

## Friends And Related Function Documentation

friend class DuckDrag_Base `[friend]`

friend class DuckDrag_Translate `[friend]`

Referenced by clear_duck_dragger().

friend class Push `[friend]`

## Member Data Documentation

etl::handle<Bezier> studio::Duckmatic::selected_bezier `[protected]`

synfig::Time studio::Duckmatic::cur_time `[protected]`

Referenced by studio::WorkArea::async_render_preview(), studio::WorkArea::async_update_preview(), get_time(), set_time(), studio::WorkArea::sync_render_preview(), and studio::WorkArea::sync_update_preview().

bool studio::Duckmatic::grid_snap `[protected]`

This flag is set if operations should snap to the grid.

Todo:
  perhaps there should be two of these flags, one for each axis?

See also:
  show_grid, grid_size

Referenced by get_grid_snap(), set_grid_snap(), and toggle_grid_snap().

bool studio::Duckmatic::guide_snap `[protected]`

Referenced by get_guide_snap(), set_guide_snap(), and snap_point_to_grid().

synfig::Vector studio::Duckmatic::grid_size `[protected]`

This vector describes the grid size.

See also:
  grid_snap, show_grid

Referenced by get_grid_size(), and set_grid_size().

bool studio::Duckmatic::show_persistent_strokes `[protected]`

Referenced by clear_ducks(), get_show_persistent_strokes(), and set_show_persistent_strokes().

bool studio::Duckmatic::axis_lock `[protected]`

Referenced by Duckmatic(), get_axis_lock(), set_axis_lock(), and snap_point_to_grid().

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

- duckmatic.h
- duckmatic.cpp