/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_TARGET
-
#ifdef USING_PCH
# include "pch.h"
#else
EXTRA_DIST = \
surfacenew.cpp \
pch.h \
- synfig.nsh
+ synfig.nsh \
+ synfig.h \
+ nodebase.h
LAYERHEADERS = \
general.h \
guidset.h \
interpolation.h \
- nodebase.h \
protocol.h \
quick_rng.h \
real.h \
string.h \
string_decl.h \
surfacenew.h \
- synfig.h \
types.h \
vector.h \
version.h \
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
class GUID;
/*! \class Canvas
-** \todo writeme
+** \brief Canvas is a double ended queue of Layers. It is the base class
+* for a Synfig document.
+*
+* As a node it inherits all the parent child relationship and the GUID
+* methods. As a double queue it allows insertion and deletion of Layers
+* and can access to the layers on the queue easily.
*/
class Canvas : public CanvasBase, public Node
{
/*! \see value_node_list(), find_value_node() */
ValueNodeList value_node_list_;
- //! \writeme
+ //! Contains a list of Keyframes that are in the Canvas
+ /*! \see keyframe_list()*/
KeyframeList keyframe_list_;
//! A handle to the parent canvas of this canvas.
//! Contains the value of the last call to set_time()
Time cur_time_;
- //! \writeme
+ //! Map of external Canvases used in this Canvas
mutable std::map<String,Handle> externals_;
//! This flag is set if this canvas is "inline"
bool is_inline_;
+ //! True if the Canvas properties has changed
mutable bool is_dirty_;
+ //! It is set to true when synfig::optimize_layers is called
bool op_flag_;
//! Layer Group database
std::map<String,std::set<etl::handle<Layer> > > group_db_;
- //! Layer Connection database
+ //! Layer Signal Connection database. Seems to be unused.
std::map<etl::loose_handle<Layer>,std::vector<sigc::connection> > connections_;
/*
//! ValueBasenode Changed
sigc::signal<void, etl::handle<ValueNode> > signal_value_node_changed_;
-
+ //! ValueBasenode Renamed
sigc::signal<void, etl::handle<ValueNode> > signal_value_node_renamed_;
-
+ //! Child Value Node Added. Used in Dynamic List Value Nodes
sigc::signal<void, etl::handle<ValueNode>, etl::handle<ValueNode> > signal_value_node_child_added_;
-
+ //! Child Value Node Removed. Used in Dynamic List Value Nodes
sigc::signal<void, etl::handle<ValueNode>, etl::handle<ValueNode> > signal_value_node_child_removed_;
/*
//! Metadata Changed
sigc::signal<void>& signal_meta_data_changed(const String& key) { return signal_map_meta_data_changed_[key]; }
-
+ //! Value Node Changed
sigc::signal<void, etl::handle<ValueNode> >& signal_value_node_changed() { return signal_value_node_changed_; }
-
+ //! Value Node Renamed
sigc::signal<void, etl::handle<ValueNode> >& signal_value_node_renamed() { return signal_value_node_renamed_; }
- //! Dirty
+ //! Dirty
sigc::signal<void>& signal_dirty() { return signal_changed(); }
- //! \writeme
+ //! Child Value Node Added
sigc::signal<void, etl::handle<ValueNode>, etl::handle<ValueNode> >& signal_value_node_child_added() { return signal_value_node_child_added_; }
- //! \writeme
+ //! Child Value Node Removed
sigc::signal<void, etl::handle<ValueNode>, etl::handle<ValueNode> >& signal_value_node_child_removed() { return signal_value_node_child_removed_; }
/*
*/
protected:
-
+ //! Canvas constructor by Canvas name
Canvas(const String &name);
public:
//! Renames the given group
void rename_group(const String&old_name,const String&new_name);
- //! \writeme
+ //! Returns true if the Canvas is in line
bool is_inline()const { return is_inline_; }
//! Returns a handle to the RendDesc for this Canvas
//! Removes a meta data key
void erase_meta_data(const String& key);
- //! \writeme
+ //! Gets the relative ID string for an ancestor Canvas
String get_relative_id(etl::loose_handle<const Canvas> x)const;
- //! \internal \writeme
+ //! Gets the relative ID string for an ancestor Canvas. Don't call it directly
String _get_relative_id(etl::loose_handle<const Canvas> x)const;
//! Returns \c true if the Canvas is a root Canvas. \c false otherwise
/*! The returned handle will be empty if this is a root canvas */
LooseHandle parent()const { return parent_; }
+ //! Returns a handle to the root Canvas
LooseHandle get_root()const;
//! Returns a list of all child canvases in this canvas
//! Sets the time for all the layers in the canvas
void set_time(Time t)const;
- //! \writeme
+ //! Returns the current time of the Canvas
Time get_time()const { return cur_time_; }
//! Returns the number of layers in the canvas
*/
ValueNode::ConstHandle find_value_node(const String &id)const;
- //! \writeme
+ //! Adds a Value node by its Id.
+ /*! Throws an error if the Id is not
+ //! correct or the Value node is already exported
+ **/
void add_value_node(ValueNode::Handle x, const String &id);
//! writeme
//void rename_value_node(ValueNode::Handle x, const String &id);
- //! \writeme
+ //! Removes a Value Node from the Canvas by its Handle
void remove_value_node(ValueNode::Handle x);
- //! \writeme
+ //! Removes a Value Node from the Canvas by its Id
void remove_value_node(const String &id) { remove_value_node(find_value_node(id)); }
//! Finds a child Canvas in the Canvas with the given \a name
//! Adds the given canvas as a child
Handle add_child_canvas(Handle child_canvas, const String &id);
+ //! Remove Child Canvas by its handle. If Current canvas is a child of a parent
+ //! it ask to the parent to remove the Child canvas.
void remove_child_canvas(Handle child_canvas);
+ //! Finds a Layer by its position.
+ //! \see get_context()
etl::handle<Layer> find_layer(const Point &pos);
+ //! Gets the depth of a particular Layer by its handle
int get_depth(etl::handle<Layer>)const;
+ //! Retireves the first layer of the double queue of Layers
Context get_context()const;
-
+ //! Returns the last Canvas layer queue iterator. Notice that it
+ /*! overrides the std::end() member that would return an interator
+ * just past the last element of the queue.*/
iterator end();
-
+ //! Returns the last Canvas layer queue const_iterator. Notice that it
+ /*! overrides the std::end() member that would return an interator
+ * just past the last element of the queue.*/
const_iterator end()const;
-
+ //! Returns the last Canvas layer queue reverse iterator. Notice that it
+ /*! overrides the std::rbegin() member that would return an interator
+ * just past the last element of the queue.*/
reverse_iterator rbegin();
-
+ //! Returns the last Canvas layer queue reverse const iterator. Notice that it
+ /*! overrides the std::rbegin() member that would return an interator
+ * just past the last element of the queue.*/
const_reverse_iterator rbegin()const;
-
+ //! Returns last layer in Canvas layer stack
etl::handle<Layer> &back();
-
+ //! Returns last layer in Canvas layer stack
+ const etl::handle<Layer> &back()const;
+ //! Inserts a layer just before the last layer.
+ //! \see end(), insert(iterator iter,etl::handle<Layer> x)
void push_back(etl::handle<Layer> x);
-
+ //! Inserts a layer just at the beggining of the Canvas layer dqueue
void push_front(etl::handle<Layer> x);
-
+ //! Inserts a layer in the last position of the Canvas layer dqueue
+ //! Uses the standard methods and doesn't perform any parentship
+ //! or signal update
void push_back_simple(etl::handle<Layer> x);
-
+ //! Inserts a layer before the given position by \iter and performs
+ //! the proper child parent relationships and signals update
void insert(iterator iter,etl::handle<Layer> x);
+ //! Removes a layer from the Canvas layer dqueue and its group and parent
+ //! relatioship. Although it is not already used, it clears the connections
+ //! see connections_
void erase(iterator iter);
-
- const etl::handle<Layer> &back()const;
-
+ //! Sets to be a inline canvas of a given Canvas \parent. The inline
+ //! Canvas inherits the groups and the render description.
+ //! \see rend_desc()
void set_inline(LooseHandle parent);
-
+ //! Returns a Canvas handle with "Untitled" as ID
static Handle create();
-
+ //! Creates an inline Canvas for a given Canvas \parent
static Handle create_inline(Handle parent);
-
+ //! Clones (copies) the Canvas if it is inline.
Handle clone(const GUID& deriv_guid=GUID())const;
-
+ //! Stores the external canvas by its file name and the Canvas handle
void register_external_canvas(String file, Handle canvas);
#ifdef _DEBUG
#endif // _DEBUG
private:
+ //! Adds a \layer to a group given by its \group string to the group
+ //! database
void add_group_pair(String group, etl::handle<Layer> layer);
+ //! Removes a \layer from a group given by its \group string to the group
+ //! database
void remove_group_pair(String group, etl::handle<Layer> layer);
+ //! Seems to be used to add the stored signals connections of the layers.
+ //! \see connections_
void add_connection(etl::loose_handle<Layer> layer, sigc::connection connection);
+ //! Seems to be used to disconnect the stored signals connections of the layers.
+ //! \see connections_
void disconnect_connections(etl::loose_handle<Layer> layer);
protected:
+ //! Sets the Canvas to dirty and calls Node::on_changed()
virtual void on_changed();
+ //! Collects the times (TimePoints) of the Layers of the Canvas and
+ //! stores it in the passed Time Set \set
+ //! \see Node::get_times()
virtual void get_times_vfunc(Node::time_set &set) const;
}; // END of class Canvas
+ //! Optimize layers based on its calculated Z depth to perform a quick
+ //! render of the layers to the output.
void optimize_layers(Time time, Context context, Canvas::Handle op_canvas, bool seen_motion_blur=false);
/* === H E A D E R S ======================================================= */
-//#include <cmath>
#include <math.h>
#include <cassert>
#include "gamma.h"
#include <synfig/string.h>
+# include "angle.h"
#ifdef USE_HALF_TYPE
#include <OpenEXR/half.h>
#endif
-#ifndef SYNFIG_NO_ANGLE
-# include "angle.h"
-#endif
-
/* === M A C R O S ========================================================= */
#define use_colorspace_gamma() App::use_colorspace_gamma
static Color YUV(const float& y, const float& u, const float& v, const value_type& a=1)
{ return Color().set_yuv(y,u,v).set_a(a); }
-#ifndef SYNFIG_NO_ANGLE
//! Returns the hue of the chromanance
/*! This is the angle of the U and V components.
** \see set_hue() */
static Color YUV(const float& y, const float& s, const Angle& theta, const value_type& a=1)
{ return Color().set_yuv(y,s,theta).set_a(a); }
-#endif
//! Clamps a color so that its values are in range. Ignores attempting to visualize negative colors.
Color clamped()const;
{
Layer::ParamList params;
Layer::DynamicParamList::const_iterator iter;
-
+ // For each parameter of the layer sets the time by the operator()(time)
for(iter=(*context)->dynamic_param_list().begin();iter!=(*context)->dynamic_param_list().end();iter++)
params[iter->first]=(*iter->second)(time);
-
+ // Sets the modified parameter list to the current context layer
(*context)->set_param_list(params);
-
+ // Calls the set time for the next layer in the context.
(*context)->set_time(context+1,time);
+ // Sets the dirty time the current calling time
(*context)->dirty_time_=time;
}
/* === S Y N F I G ========================================================= */
/*! \file context.h
-** \brief Template Header
+** \brief Iterator for the layers behind the current Layer.
**
** $Id$
**
class Rect;
/*! \class Context
-** \todo writeme
-** \see Layer, Canvas */
+** \brief Context is a class to warp the iterator for a double queue of layers
+* (that is the CanvasBase).
+** \see Layer, Canvas, CanvasBase */
class Context : public CanvasBase::const_iterator
{
public:
Context() { }
+ //! Constructor based on other CanvasBase iterator
Context(const CanvasBase::const_iterator &x):CanvasBase::const_iterator(x) { }
+ //!Assignation operator
Context operator=(const CanvasBase::const_iterator &x)
{ return CanvasBase::const_iterator::operator=(x); }
- /*! \todo write me */
+ //! Returns the color of the context at the Point \pos.
+ //! It is the blended color of the context
Color get_color(const Point &pos)const;
- /*! \todo write me */
+ //! With a given \quality and a given render description it puts the context
+ //! blend result into the painting \surface */
bool accelerated_render(Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb) const;
- /*! \todo write me */
+ //! Sets the context to the Time \time. It is done recursively.
void set_time(Time time)const;
- /*! \writeme */
+ //! Sets the context to the Time \time. It is done recursively. Vector \pos is not used
void set_time(Time time,const Vector &pos)const;
+ //! Returns the bounding rectangle of all the context.
+ //! It is the union of all the layers's bounding rectangle.
Rect get_full_bounding_rect()const;
- /*! \writeme */
+ //! Returns the first context's layer's handle that intesects the given \point */
etl::handle<Layer> hit_check(const Point &point)const;
}; // END of class Context
/* === S Y N F I G ========================================================= */
/*! \file importer.cpp
-** \brief writeme
+** \brief It is the base class for all the importers.
**
** $Id$
**
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
-#include <cstdio>
/* === S Y N F I G ========================================================= */
/*! \file importer.h
-** \brief writeme
+** \brief It is the base class for all the importers.
**
** $Id$
**
/* === H E A D E R S ======================================================= */
+#include <cstdio>
#include <map>
-//#include <cmath>
#include <ETL/handle>
#include "string.h"
-//#include "surface.h"
-//#include "general.h"
-//#include "vector.h"
#include "time.h"
#include "gamma.h"
/* === M A C R O S ========================================================= */
-//! \writeme
-#define SYNFIG_IMPORTER_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Importer *create(const char *filename);
+//! Defines various variables and the create method, common for all importers.
+//! To be used in the private part of the importer class definition.
+#define SYNFIG_IMPORTER_MODULE_EXT \
+ public: static const char name__[], version__[], ext__[],cvs_id__[]; \
+ static Importer *create(const char *filename);
-//! Sets the name of the importer
+//! Sets the name of the importer.
#define SYNFIG_IMPORTER_SET_NAME(class,x) const char class::name__[]=x
-//! \writeme
+//! Sets the primary file extension of the importer.
#define SYNFIG_IMPORTER_SET_EXT(class,x) const char class::ext__[]=x
-//! Sets the version of the importer
+//! Sets the version of the importer.
#define SYNFIG_IMPORTER_SET_VERSION(class,x) const char class::version__[]=x
-//! Sets the CVS ID of the importer
+//! Sets the CVS ID of the importer.
#define SYNFIG_IMPORTER_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
-//! \writeme
+//! Defines de implementation of the create method for the importer
+//! \param filename The file name to be imported by the importer.
#define SYNFIG_IMPORTER_INIT(class) synfig::Importer* class::create(const char *filename) { return new class(filename); }
/* === T Y P E D E F S ===================================================== */
class ProgressCallback;
/*! \class Importer
-** \brief Used for importing bitmaps of various formats, including animations
-** \todo Write more detailed description
+** \brief Used for importing bitmaps of various formats, including animations.
+*
+* It is the base class for all the importers. It defines the has a static Book
+* pointer class that is a map for the importers factory creators and the strings
+* of the extension that the importer can understand. It allows to create the a
+* pointer to a particular importer just by using the extension of the name of file
+* to import. Also it creates a virtual member get_frame that must be declared in
+* the inherited classes.
+* \see module.h
+** \
*/
class Importer : public etl::shared_object
{
public:
+ //! Type that represents a pointer to a Importer's constructor.
+ //! As a pointer to the constructor, it represents a "factory" of importers.
typedef Importer* (*Factory)(const char *filename);
typedef std::map<String,Factory> Book;
static Book* book_;
static Book& book();
+ //! Initializes the Import module by creating a book of importers names
+ //! and its creators and the list of open importers
static bool subsys_init();
+ //! Stops the Import module by deleting the book and the list of open
+ //! importers
static bool subsys_stop();
typedef etl::handle<Importer> Handle;
typedef etl::handle<const Importer> ConstHandle;
private:
+ //! Gamma of the importer.
+ //! \todo Do not hardcode the gamma to 2.2
Gamma gamma_;
protected:
virtual bool get_frame(Surface &surface,Time time, ProgressCallback *callback=NULL)=0;
virtual bool get_frame(Surface &surface,Time time,
bool &trimmed __attribute__ ((unused)),
- unsigned int &width __attribute__ ((unused)), unsigned int &height __attribute__ ((unused)),
- unsigned int &top __attribute__ ((unused)), unsigned int &left __attribute__ ((unused)),
- ProgressCallback *callback=NULL) {
+ unsigned int &width __attribute__ ((unused)),
+ unsigned int &height __attribute__ ((unused)),
+ unsigned int &top __attribute__ ((unused)),
+ unsigned int &left __attribute__ ((unused)),
+ ProgressCallback *callback=NULL)
+ {
return get_frame(surface,time,callback);
}
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === M A C R O S ========================================================= */
-//! \writeme
+//! Defines various variables and the create method, common for all importers.
+//! To be used in the private part of the importer class definition.
#define SYNFIG_LAYER_MODULE_EXT \
public: \
static const char name__[], version__[], cvs_id__[], local_name__[], category__[]; \
#define SYNFIG_LAYER_SET_CVS_ID(class,x) \
const char class::cvs_id__[]=x
-//! \writeme
+//! Defines de implementation of the create method for the importer
#define SYNFIG_LAYER_INIT(class) \
synfig::Layer* class::create() \
{ \
return new class(); \
}
-//! \writeme
+//! Imports a parameter 'x' and perform an action based usually based on
+//! some condition 'y'
#define IMPORT_PLUS(x,y) \
if (param==#x && value.same_type_as(x)) \
{ \
return true; \
}
-//! \writeme
+//! Imports a parameter 'y' if it has the same type than 'x'
#define IMPORT_AS(x,y) \
if (param==y && value.same_type_as(x)) \
{ \
return true; \
}
-//! \writeme
+//! Imports a parameter if it is of the same type as param
#define IMPORT(x) \
IMPORT_AS(x,#x)
-//! \writeme
+//! Exports a parameter 'x' if param is same type as given 'y'
#define EXPORT_AS(x,y) \
if (param==y) \
return ValueBase(x);
-//! \writeme
+//! Exports a parameter if it is the same type as value
#define EXPORT(x) \
EXPORT_AS(x,#x)
-//! \writeme
+//! Exports the name or the local name of the layer
#define EXPORT_NAME() \
if (param=="Name" || param=="name" || param=="name__") \
return name__; \
else if (param=="local_name__") \
return dgettext("synfig",local_name__);
-//! \writeme
+//! Exports the version of the layer
#define EXPORT_VERSION() \
if (param=="Version" || param=="version" || param=="version__") \
return version__;
//! Book of types of layers indexed by layer type name.
/*! While the sifz file is read, each time a new layer entry is found,
- ** the factory constructor that the "factory" pointer member of the
+ ** the factory constructor that the "factory" pointer member of the
** "BookEntry" struct points to, is called, and a new layer of that type
** is created.
** \sa Layer::Factory
static Book& book();
+ //! Inits the book of layers and inserts in it the basic layers that
+ //! doesn't depend on modules
+ /*! \todo motionblur should be in the mod_filter module
+ */
static bool subsys_init();
+ //! Stops the layer system by deleting the book of registered layers
static bool subsys_stop();
+ //! Map of Value Base parameters indexed by name
typedef std::map<String,ValueBase> ParamList;
typedef etl::handle<Layer> Handle;
typedef etl::handle<const Layer> ConstHandle;
+ //! Map of parameters that are animated Value Nodes indexed by the param name
typedef std::map<String,etl::rhandle<ValueNode> > DynamicParamList;
//! A list type which describes all the parameters that a layer has.
//! Handle to the canvas to which this layer belongs
etl::loose_handle<Canvas> canvas_;
+ //! Map of parameter with animated value nodes
DynamicParamList dynamic_param_list_;
//! A description of what this layer does
String description_;
- //! \writeme
+ //! The depth parameter of the layer in the layer stack
float z_depth_;
//! \writeme
//! Contains the name of the group that this layer belongs to
String group_;
- //! \writeme
+ //! Signal to connect to the signal_deleted canvas's member
+ //! Used to do let a layer with a canvas parent that doesn't exists
+ //! Instead of that it connects to a zero canvas
+ //! \see Layer::set_canvas()
sigc::connection parent_death_connect_;
/*
//! Gets the name of the group that this layer belongs to
String get_group()const;
- //! writeme
- //DynamicParamList &dynamic_param_list() { return dynamic_param_list_; }
-
- //! \todo writeme
+ //! Retrieves the dynamic param list member
+ //! \see DynamicParamList
const DynamicParamList &dynamic_param_list()const { return dynamic_param_list_; }
+ //! Connects the parameter to another Value Node
bool connect_dynamic_param(const String& param, etl::loose_handle<ValueNode>);
+
+ //! Disconnects the parameter from any Value Node
bool disconnect_dynamic_param(const String& param);
//! Enables the layer for rendering (Making it \em active)
/*! Returns negative on error */
int get_depth()const;
- //! \writeme
+ //! Gets the non animated z depth of the layer
float get_z_depth()const { return z_depth_; }
- //! \writeme
+ //! Gets the z depth of the layer at a time t
float get_z_depth(const synfig::Time& t)const;
- //! \writeme
+ //! Sets the z depth of the layer (non animated)
void set_z_depth(float x) { z_depth_=x; }
//! Sets the Canvas that this Layer is a part of
//! Returns a handle to the Canvas to which this Layer belongs
etl::loose_handle<Canvas> get_canvas()const;
- //! \writeme
+ //! Returns the description of the layer
const String& get_description()const { return description_; }
- //! \writeme
+ //! Sets the description of the layer
void set_description(const String& x);
//! Returns the layer's description if it's not empty, else its local name
*/
public:
+ //! Returns the rectangle that includes the layer
+ //! \see synfig::Rect
virtual Rect get_bounding_rect()const;
+ //!Returns the rectangle that includes the context of the layer
+ //!\see synfig::Rect synfig::Context
virtual Rect get_full_bounding_rect(Context context)const;
//! Returns a string containing the name of the Layer
//! Gets the version string for this layer
virtual String get_version()const;
- //! \writeme
+ //! Returns a handle to the Transform class of the layer
+ //! \see synfig::Transform
virtual etl::handle<Transform> get_transform()const;
//! Sets the virtual version to use for backwards-compatibility
//! Get a list of all of the parameters and their values
virtual ParamList get_param_list()const;
- //! Sets the \a time for the selected Layer and those under it
+ //! Sets the \a time for the Layer and those under it
/*! \param context Context iterator referring to next Layer.
** \param time writeme
- ** \see Handle::set_time()
+ ** \see Context::set_time()
*/
virtual void set_time(Context context, Time time)const;
/*! \param context Context iterator referring to next Layer.
** \param time writeme
** \param point writeme
- ** \see Handle::set_time()
+ ** \see Context::set_time()
** \todo \a point should be of the type <tt>const Point \&</tt> */
virtual void set_time(Context context, Time time, const Point &point)const;
- //! Gets the color of the Canvas at \a pos
+ //! Gets the blend color of the Layer in the context at \a pos
/*! \param context Context iterator referring to next Layer.
** \param pos Point which indicates where the Color should come from
- ** \see Handle::get_color()
+ ** \see Context::get_color()
*/
virtual Color get_color(Context context, const Point &pos)const;
** \param renddesc The associated RendDesc.
** \param cb Pointer to callback object. May be NULL if there is no callback.
** \return \c true on success, \c false on failure
- ** \see Handle::accelerated_render()
+ ** \see Context::accelerated_render()
*/
virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
/*! \param context Context iterator referring to next Layer.
** \param point The point to check
** \return The handle of the layer under \a point. If there is not
- ** a layer under \a point, then returns an empty handle. */
+ ** a layer under \a point, then returns an empty handle.
+ ** \see Context::hit_check
+ */
virtual Handle hit_check(Context context, const Point &point)const;
//! Duplicates the Layer
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
image.push_back(0); // Alpha black
- // Render the backdrop
+ // Render the backdrop on the surface layer's surface.
if(!context.accelerated_render(&surfacelayer->surface,quality,renddesc,&stageone))
return false;
-
+ // Sets up the interpolation of the context (now the surface layer is the first one)
+ // depending on the quality
if(quality<=4)surfacelayer->c=3;else
if(quality<=5)surfacelayer->c=2;
else if(quality<=6)surfacelayer->c=1;
else surfacelayer->c=0;
surfacelayer->tl=renddesc.get_tl();
surfacelayer->br=renddesc.get_br();
+ // Sets the blend method to straight. See below
surfacelayer->set_blend_method(Color::BLEND_STRAIGHT);
-
+ // Push this layer on the image. The blending result is only this layer
+ // adn the surface layer. The rest of the context is ignored by the straight
+ // blend method of surface layer
image.push_front(const_cast<synfig::Layer_Composite*>(this));
// Set up a surface target
Layer::Vocab
Layer_Composite::get_param_vocab()const
{
+ //! First fills the returning vocabulary with the ancestor class
Layer::Vocab ret(Layer::get_param_vocab());
-
+ //! Now inserts the two parameters that this layer knows.
ret.push_back(ParamDesc(amount_,"amount")
.set_local_name(_("Amount"))
);
ValueBase
Layer_Composite::get_param(const String & param)const
{
+ //! First check if the parameter's string is known.
if(param=="amount")
return get_amount();
if(param=="blend_method")
return static_cast<int>(get_blend_method());
+ //! If it is unknown then call the ancestor's get param member
+ //! to see if it can handle that parameter's string.
return Layer::get_param(param);
}
class Layer_Composite : public Layer
{
private:
-
+ //! The amount of composite
float amount_;
-
+ //! The blend method for the composition
Color::BlendMethod blend_method_;
protected:
-
+ //! Default constructor. Not used directly.
Layer_Composite(
float amount=1.0,
Color::BlendMethod blend_method=Color::BLEND_COMPOSITE
converted_blend_ (false),
transparent_color_ (false)
{ }
-
+ //! Converted blend is used to check if an old version of canvas
+ //! is used in the composition. Old Straight was used as new Composite
+ //! \todo verify this
bool converted_blend_;
+ //! Transparent color is used for old canvas versions.
+ //!Old Straight plus transparent color seems to be the same new than alpha over.
bool transparent_color_;
public:
-
+ //! Gets the amount of the layer
float get_amount()const { return amount_; }
-
+ //! Sets the amount of the layer and returns this layer
Layer_Composite& set_amount(float x) { amount_=x; return *this; }
-
+ //! Gets the blend method of the layer
Color::BlendMethod get_blend_method()const { return blend_method_; }
-
+ //! Sets the blend method of the layer and returns this layer
Layer_Composite& set_blend_method(Color::BlendMethod x) { blend_method_=x; return *this; }
-
+ //! Returns true is amount is 1 and blend method is straight
virtual bool is_solid_color()const { return amount_==1.0f && blend_method_==Color::BLEND_STRAIGHT; }
-
+ //! Returns true if the amount is zero.
bool is_disabled()const { return amount_==0.0f; }
-
+ //! Gets the parameter vocabulary. To be overrided by the derived.
virtual Vocab get_param_vocab()const;
-
+ //! Sets the value for the given parameter.
virtual bool set_param(const String ¶m, const ValueBase &value);
-
+ //! Gets the value of the given parameter
virtual ValueBase get_param(const String ¶m)const;
-
+ //!Returns the rectangle that includes the context of the layer and
+ //! the intersection of the layer in case it is active and not onto
virtual Rect get_full_bounding_rect(Context context)const;
-
+ //! Renders the layer composited on the context and puts it on the target surface.
virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
}; // END of class Layer_Composite
void
Layer_PasteCanvas::on_canvas_set()
{
- //synfig::info("before count()=%d",count());
if(get_canvas() && canvas && canvas->is_inline() && canvas->parent()!=get_canvas())
{
- //synfig::info("during count()=%d",count());
canvas->set_inline(get_canvas());
}
- //synfig::info("after count()=%d",count());
}
ValueBase
/* === C L A S S E S & S T R U C T S ======================================= */
namespace synfig {
-
+/*! \class Layer_PasteCanvas
+** \brief Class of the Pasted Canvas layer.
+*/
class Layer_PasteCanvas : public Layer_Composite, public Layer_NoDeform
{
+ //! Layer module: defines the needed members to belong to a layer's factory.
SYNFIG_LAYER_MODULE_EXT
private:
-
+ //! Parameter Origin of the paste canvas layer
Vector origin;
+ //!Parameter Focus of the zoom of the paste canvas layer
Vector focus;
-
+ //! The canvas parameter
etl::loose_handle<synfig::Canvas> canvas;
-
- //! Recursion depth counter
+ //! Recursion depth counter. Not a parameter
mutable int depth;
-
+ //! Zoom parameter of the paste canvas layer
Real zoom;
-
+ //! Time offset parameter of the paste canvas layer
Time time_offset;
-
+ //! Current time of the paste canvas layer. \see set_time
mutable Time curr_time;
-
+ //! \todo writeme! Not a parameter
bool muck_with_time_;
-
+ //! Parameter that avoid hit check to go depth into the children.
bool children_lock;
-
+ //! Boundaries of the paste canvas layer. It is the canvas's boundary
+ //! affected by the zoom, origin and focus.
mutable Rect bounds;
-
+ //! signal connection for children. Seems to be used only here
sigc::connection child_changed_connection;
// Nasty hack: Remember whether we called an extra ref() when
*/
private:
-
+ //! Signal used when the canvas parameter has changed. \see layertreestore.cpp
sigc::signal<void> signal_subcanvas_changed_;
/*
*/
public:
-
+ //! Wrapper for the subcanvas changed signal
sigc::signal<void>& signal_subcanvas_changed() { return signal_subcanvas_changed_; }
public:
+ //! Recursively update the Render Description for the inner inline only pasted canvases.
+ //! Used for copy and paste Paste Canvas Layers between compositions.
void update_renddesc();
+ //! Every time the Paste Canvas Layer parent canvas is changed, this
+ //! is called and it sets the parent of the canvas parameter to that canvas
+ //! if it is on line
virtual void on_canvas_set();
-
+ //! Sets muck_with_time.
+ //! \todo writeme!
void set_muck_with_time(bool x=false) { muck_with_time_=x; }
+ //! Gets the canvas parameter. It is called sub_canvas to avoid confusion
+ //! with the get_canvas from the Layer class.
etl::handle<synfig::Canvas> get_sub_canvas()const { return canvas; }
+ //! Sets the canvas parameter.
+ //! \see get_sub_canvas()
void set_sub_canvas(etl::handle<synfig::Canvas> x);
-
+ //! Gets zoom parameter
Real get_zoom()const { return zoom; }
-
+ //! Gets time offset parameter
Time get_time_offset()const { return time_offset; }
-
+ //! Get origin parameter
Point get_origin()const { return origin; }
-
+ //! Get focus parameter
+ Vector get_focus()const { return focus; }
+ //! Default constructor
Layer_PasteCanvas();
+ //! Destructor
virtual ~Layer_PasteCanvas();
-
+ //! Returns a string with the localized name of this layer
virtual String get_local_name()const;
-
+ //! Sets the parameter described by \a param to \a value. \see Layer::set_param
virtual bool set_param(const String & param, const synfig::ValueBase &value);
-
+ //! Get the value of the specified parameter. \see Layer::get_param
virtual ValueBase get_param(const String & param)const;
-
+ //! Gets the blend color of the Layer in the context at \a pos
virtual Color get_color(Context context, const Point &pos)const;
-
+ //! Sets the time of the Paste Canvas Layer and those under it
virtual void set_time(Context context, Time time)const;
-
+ //! Renders the Canvas to the given Surface in an accelerated manner
+ //! See Layer::accelerated_render
virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
-
+ //! Gets the parameter vocabulary
virtual Vocab get_param_vocab()const;
-
+ //! Returns the rectangle that includes the layer
virtual synfig::Rect get_bounding_rect()const;
-
+ //! Checks to see if a part of the Paste Canvas Layer is directly under \a point
virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
protected:
+ //! Function to be overloaded that fills the Time Point Set with
+ //! all the children Time Points. In this case the children Time Points
+ //! are the canvas parameter children layers Time points and the Paste Canvas
+ //! Layer time points. \todo clarify all this comments.
virtual void get_times_vfunc(Node::time_set &set) const;
}; // END of class Layer_PasteCanvas
#include "layer_pastecanvas.h"
#include "loadcanvas.h"
#include "valuenode.h"
-#include "valuenode_subtract.h"
#include "valuenode_animated.h"
#include "valuenode_composite.h"
#include "valuenode_const.h"
/* === S Y N F I G ========================================================= */
/*! \file loadcanvas.h
-** \brief writeme
+** \brief Implementation for the Synfig Canvas Loader (canvas file parser)
**
** $Id$
**
namespace synfig {
/*! \class CanvasParser
-** \todo writeme
+** \brief Class that handles xmlpp elements from a sif file and converts
+* them into Synfig objects
*/
class CanvasParser
{
*/
private:
-
+ //! Maximun number of allowed warnings before fatal error is thrown
int max_warnings_;
-
+ //! Total number of warning during canvas parsing
int total_warnings_;
-
+ //! Total number of errors during canvas parsing
int total_errors_;
-
+ //! True if errors doesn't stop canvas parsing
bool allow_errors_;
-
+ //! File name to parse
String filename;
-
+ //! Path of the file name to parse
String path;
-
+ //! Error text when errors found
String errors_text;
+ //! Warning text when warnings found
String warnings_text;
-
+ //! Seems not to be used
GUID guid_;
/*
public:
- //! \todo writeme
+ //! Sets allow errors variable
CanvasParser &set_allow_errors(bool x) { allow_errors_=x; return *this; }
//! Sets the maximum number of warnings before a fatal error is thrown
//! Returns the number of warnings in the last parse
int warning_count()const { return total_warnings_; }
+ //! Sets the path of the file to parse
void set_path(const synfig::String& x) { path=x; }
+ //! Gets the path of the file to parse
const synfig::String& get_path()const { return path; }
+ //! Gets error text string
const synfig::String& get_errors_text()const { return errors_text; }
+ //! Gets warning text string
const synfig::String& get_warnings_text()const { return warnings_text; }
+ //! Register a canvas in the canvas map
+ /*! \param canvas The handle to the canvas to register
+ * \param as The absolute path to the file that represents the canvas
+ * Apart of store the pair canvas and */
static void register_canvas_in_map(Canvas::Handle canvas, String as);
#ifdef _DEBUG
static void show_canvas_map(String file, int line, String text);
#endif // _DEBUG
- //! \todo writeme
+ //! Parse a Cavnas form a file with absolute path.
Canvas::Handle parse_from_file_as(const String &filename,const String &as,String &errors);
+ //! Parse a Canvas from a xmlpp root node
Canvas::Handle parse_as(xmlpp::Element* node,String &errors);
+ //! Set of absolute file names of the canvases currently being parsed
static std::set<String> loading_;
private:
- // Error/Warning handling functions
-
+ //! Error handling function
void error(xmlpp::Node *node,const String &text);
+ //! Fatal Error handling function
void fatal_error(xmlpp::Node *node,const String &text);
+ //! Warning handling function
void warning(xmlpp::Node *node,const String &text);
+ //! Unexpected element error handling function
void error_unexpected_element(xmlpp::Node *node,const String &got, const String &expected);
+ //! Unexpected element error handling function
void error_unexpected_element(xmlpp::Node *node,const String &got);
- // Parsing Functions
-
+ //! Canvas Parsing Function
Canvas::Handle parse_canvas(xmlpp::Element *node,Canvas::Handle parent=0,bool inline_=false, String path=".");
+ //! Canvas definitions Parsing Function (exported value nodes and exported canvases)
void parse_canvas_defs(xmlpp::Element *node,Canvas::Handle canvas);
+ //! Layer Parsing Function
etl::handle<Layer> parse_layer(xmlpp::Element *node,Canvas::Handle canvas);
+ //! Generic Value Base Parsing Function
ValueBase parse_value(xmlpp::Element *node,Canvas::Handle canvas);
+ //! Generic Value Node Parsing Function
etl::handle<ValueNode> parse_value_node(xmlpp::Element *node,Canvas::Handle canvas);
- // ValueBase Parsing Functions
-
+ //! Real Value Base Parsing Function
Real parse_real(xmlpp::Element *node);
+ //! Time Value Base Parsing Function
Time parse_time(xmlpp::Element *node,Canvas::Handle canvas);
+ //! Integer Value Base Parsing Function
int parse_integer(xmlpp::Element *node);
+ //! Vector Value Base Parsing Function
Vector parse_vector(xmlpp::Element *node);
+ //! Color Value Base Parsing Function
Color parse_color(xmlpp::Element *node);
+ //! Angle Value Base Parsing Function
Angle parse_angle(xmlpp::Element *node);
+ //! String Value Base Parsing Function
String parse_string(xmlpp::Element *node);
+ //! Bool Value Base Parsing Function
bool parse_bool(xmlpp::Element *node);
+ //! Segment Value Base Parsing Function
Segment parse_segment(xmlpp::Element *node);
+ //! List Value Base Parsing Function
ValueBase parse_list(xmlpp::Element *node,Canvas::Handle canvas);
+ //! Gradient Value Base Parsing Function
Gradient parse_gradient(xmlpp::Element *node);
+ //! Bline Point Value Base Parsing Function
BLinePoint parse_bline_point(xmlpp::Element *node);
+ //! Keyframe Parsing Function
Keyframe parse_keyframe(xmlpp::Element *node,Canvas::Handle canvas);
- // ValueNode Parsing Functions
-
+ //! ValueNode Animated Parsing Function
etl::handle<ValueNode_Animated> parse_animated(xmlpp::Element *node,Canvas::Handle canvas);
- etl::handle<ValueNode_Subtract> parse_subtract(xmlpp::Element *node,Canvas::Handle canvas);
+ //! Linkable ValueNode Parsing Function
etl::handle<LinkableValueNode> parse_linkable_value_node(xmlpp::Element *node,Canvas::Handle canvas);
+ //! Dynamic List Parsnig Function
etl::handle<ValueNode_DynamicList> parse_dynamic_list(xmlpp::Element *node,Canvas::Handle canvas);
}; // END of CanvasParser
/* === E X T E R N S ======================================================= */
-//! Loads a canvas from \a filename
+//! Loads a canvas from current xmlpp Element
/*! \return The Canvas's handle on success, an empty handle on failure */
extern Canvas::Handle open_canvas(xmlpp::Element* node,String &errors,String &warnings);
+//! Loads a canvas from \a filename
+/*! \return The Canvas's handle on success, an empty handle on failure */
extern Canvas::Handle open_canvas(const String &filename,String &errors,String &warnings);
+//! Loads a canvas from \a filename and its absolute path
+/*! \return The Canvas's handle on success, an empty handle on failure */
extern Canvas::Handle open_canvas_as(const String &filename,const String &as,String &errors,String &warnings);
+//! Returns the Open Canvases Map.
+//! \see open_canvas_map_
std::map<synfig::String, etl::loose_handle<Canvas> >& get_open_canvas_map();
}; // END of namespace synfig
/* === H E A D E R S ======================================================= */
-//#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === S Y N F I G ========================================================= */
/*! \file synfig/module.h
-** \brief writeme
+** \brief Base class for all libraries modules
**
** $Id$
**
#define BEGIN_LAYERS {
//! DEPRECATED - use #INCLUDE_LAYER(class)
+// Really? ^^ The INCLUDE_LAYER(class) macro is defined in a cpp file and
+// is undefined a few lines later. In fact the INCLUDE_LAYER is only
+// used in the layer.cpp file and the functionality is the same. Even
+// more, I think that we should use register_in_book call because maybe
+// the Layer class would like to do something else when register the class.
+//! Register a Layer class in the book of layers
#define LAYER(class) \
synfig::Layer::register_in_book( \
synfig::Layer::BookEntry(class::create, \
class::cvs_id__, \
class::version__));
+//! Register a Layer class in the book of layers with an alias
#define LAYER_ALIAS(class,alias) \
synfig::Layer::register_in_book( \
synfig::Layer::BookEntry(class::create, \
//! Marks the start of the importers in the module's inventory
#define BEGIN_IMPORTERS {
+//! Register an Importer class in the book of importers by the default extension
#define IMPORTER(x) synfig::Importer::book()[synfig::String(x::ext__)]=x::create;
+//!Register an Importer class in the book of importers by one file extension string
#define IMPORTER_EXT(x,y) synfig::Importer::book()[synfig::String(y)]=x::create;
//! Marks the end of the importers in the module's inventory
//! Marks the start of the valuenodes in the module's inventory
#define BEGIN_VALUENODES { synfig::LinkableValueNode::Book &book(synfig::LinkableValueNode::book());
+//! Registers a valuenode that is defined in the module's inventory
#define VALUENODE(class,name,local,version) \
book[name].factory=reinterpret_cast<synfig::LinkableValueNode::Factory>(&class::create); \
book[name].check_type=&class::check_type; \
typedef etl::handle<const Module> ConstHandle;
public:
- typedef Module*(*constructor_type)(ProgressCallback *);
+ //! Type that represents a pointer to a Module's constructor by name.
+ //! As a pointer to the member, it represents a constructor of the module.
+ typedef Module* (*constructor_type)(ProgressCallback *);
typedef std::map<String, Handle > Book;
private:
static Book* book_;
public:
static Book& book();
+ //! Inits the book of importers and add the paths to search for the
+ //! ltdl library utilities.
static bool subsys_init(const String &prefix);
static bool subsys_stop();
+ //! Register not optional modules
static void register_default_modules(ProgressCallback *cb=NULL);
+ //! Register Module by handle
static void Register(Handle mod);
+ //! Register Module by name
static bool Register(const String &module_name, ProgressCallback *cb=NULL);
+ //!Register Module by instance pointer
static inline void Register(Module *mod) { Register(Handle(mod)); }
+ //! Virtual Modules properties wrappers. Must be defined in the modules classes
virtual const char * Name() { return " "; }
virtual const char * Desc() { return " "; }
virtual const char * Author() { return " "; }
#define BE_FRUGAL_WITH_GUIDS 1
#ifndef __sys_clock
-#ifndef _WIN32
-# include <time.h>
-# define __sys_clock ::clock
-#else
-# ifdef __GNUG__
-# include <time.h>
-# define __sys_clock ::clock
-# else
-typedef int clock_t;
-extern clock_t _clock();
-# define CLOCKS_PER_SEC 1000
-# define __sys_clock _clock
-# endif
-#endif
-#endif
+ #ifndef _WIN32
+ # include <time.h>
+ # define __sys_clock ::clock
+ #else
+ # ifdef __GNUG__
+ # include <time.h>
+ # define __sys_clock ::clock
+ # else
+ typedef int clock_t;
+ extern clock_t _clock();
+ # define CLOCKS_PER_SEC 1000
+ # define __sys_clock _clock
+ # endif // __GNUG__
+ #endif // _WIN_32
+#endif // __sys_clock
/* === G L O B A L S ======================================================= */
typedef map<synfig::GUID,Node*> GlobalNodeMap;
#endif
+//! A map to store all the GUIDs with a pointer to the Node.
static GlobalNodeMap* global_node_map_;
static GlobalNodeMap& global_node_map()
void
TimePoint::absorb(const TimePoint& x)
{
+ //! If the Time Point to absorb is itself then bail out
if(get_guid()==x.get_guid())
return;
+ //! Creates a new GUID with the old and the new one using XOR operator
set_guid(get_guid()^x.get_guid());
-
+ //! If the current before/after interpolation is NIL use the interpolation
+ //! provided by the TimePoint to absorb
if(get_after()==INTERPOLATION_NIL)
set_after(x.get_after());
if(get_before()==INTERPOLATION_NIL)
set_before(x.get_before());
-
+ //! If the interpolation of the Time Point to absorb is not the same
+ //! than the interpolation from the Time Point to absorb then
+ //! use UNDEFINED interpolation
if(get_after()!=x.get_after() && x.get_after()!=INTERPOLATION_NIL)
set_after(INTERPOLATION_UNDEFINED);
if(get_before()!=x.get_before() && x.get_before()!=INTERPOLATION_NIL)
TimePointSet::iterator
TimePointSet::insert(const TimePoint& x)
{
+ //! finds a iterator to a Time Point with the same time
+ //! \see inline bool operator==(const TimePoint& lhs,const TimePoint& rhs)
iterator iter(find(x));
+ //! If iter is not a the end of the set (we found one Time Point)
if(iter!=end())
{
+ //! Absorb the time point
const_cast<TimePoint&>(*iter).absorb(x);
return iter;
}
+ //! Else, insert it at the first of the set
return std::set<TimePoint>::insert(x).first;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
Node::Node():
guid_(0),
bchanged(true),
/* === S Y N F I G ========================================================= */
/*! \file node.h
-** \brief Template Header
+** \brief Base class for Layers and Value Nodes.
+** It defines the base members for the parent - child relationship,
+** the times where the node is modified and the handling of
+** the GUID on deletion and changing.
**
** $Id$
**
namespace synfig {
+//!\brief TimePoint class: holds the time and the before and after interpolation mode
+/**
+ * It includes a GUID, to make it unique
+ * \see guid.h interpolation.h
+**/
class TimePoint
{
GUID guid;
void set_before(Interpolation x) { before=x; }
void set_after(Interpolation x) { after=x; }
+ //! Modify the TimePoint based on the values of \x "merging"
+ //! the interpolations. Used to insert a Time Point in a Time Points Set
+ //! \see TimePointSet::iterator TimePointSet::insert(const TimePoint& x)
void absorb(const TimePoint& x);
}; // END of class TimePoint
private:
- //! \writeme
+ //! \ The GUID of the node
GUID guid_;
//! cached time values for all the children
//! \writeme
mutable bool bchanged;
- //! \writeme
+ //! The last time the node was modified since the program started
+ //! \see __sys_clock
mutable int time_last_changed_;
//! \writeme
+ //! \see mutex.h
mutable RWLock rw_lock_;
- //! \writeme
+ //! Variable used to remember that a signal_deleted has been thrown
bool deleting_;
public:
+ //! A set of pointers to parent nodes
//! \todo This should really be private
std::set<Node*> parent_set;
private:
+ //! Node changed signal
sigc::signal<void> signal_changed_;
- //! GUID Changed
+ //! GUID changed signal
/*! \note The second parameter is the *OLD* guid! */
sigc::signal<void,GUID> signal_guid_changed_;
- //! Deleted
+ //! Node deleted signal
sigc::signal<void> signal_deleted_;
/*
void changed();
- //! Gets the GUID for this value node
+ //! Gets the GUID for this Node
const GUID& get_guid()const;
- //! Sets the GUID for this value node
+ //! Sets the GUID for this Node
void set_guid(const GUID& x);
+ //! Gets the time when the Node was changed
int get_time_last_changed()const;
+ //! Adds the parameter \x as the child of the current Node
void add_child(Node*x);
+ //! Removes the parameter \x as a child of the current Node
void remove_child(Node*x);
+ //!Returns how many parenst has the current Node
int parent_count()const;
+ //! Returns the cached times values for all the children
const time_set &get_times() const;
+ //! Writeme!
RWLock& get_rw_lock()const { return rw_lock_; }
protected:
*/
protected:
+ //! Used when the node has changed. Makes changed the parent too.
+ //! To be overloaded by the derivative classes. Emits a signal where the
+ //! the GUI can be connected to.
virtual void on_changed();
+ //! Used when the node's GUID has changed.
+ //! To be overloaded by the derivative classes. Emits a signal where the
+ //! the GUI can be connected to.
virtual void on_guid_changed(GUID guid);
- /*! Function to be overloaded that fills
- */
+ //! Function to be overloaded that fills the Time Point Set with
+ //! all the children Time Points.
virtual void get_times_vfunc(time_set &set) const = 0;
-};
+}; // End of Node class
+//! Finds a node by its GUID.
+//! \see global_node_map()
synfig::Node* find_node(const synfig::GUID& guid);
+//! Returns a Handle to the Node by its GUID
template<typename T> etl::handle<T>
guid_cast(const synfig::GUID& guid)
{
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
#include "savecanvas.h"
#include "general.h"
#include "valuenode.h"
-#include "valuenode_subtract.h"
#include "valuenode_animated.h"
-#include "valuenode_composite.h"
#include "valuenode_const.h"
-#include "valuenode_linear.h"
#include "valuenode_dynamiclist.h"
#include "valuenode_reference.h"
-#include "valuenode_segcalctangent.h"
-#include "valuenode_segcalcvertex.h"
#include "valuenode_bline.h"
#include "time.h"
#include "keyframe.h"
return root;
}
-xmlpp::Element* encode_time(xmlpp::Element* root,Time t, float /*fps*/=0)
+xmlpp::Element* encode_time(xmlpp::Element* root,Time t)
{
root->set_name("time");
- //root->set_attribute("value",t.get_string(fps));
root->set_attribute("value",t.get_string());
return root;
}
case ValueBase::TYPE_REAL:
return encode_real(root,data.get(Real()));
case ValueBase::TYPE_TIME:
- if(canvas)
- return encode_time(root,data.get(Time()),canvas->rend_desc().get_frame_rate());
- else
- return encode_time(root,data.get(Time()));
+ return encode_time(root,data.get(Time()));
case ValueBase::TYPE_INTEGER:
return encode_integer(root,data.get(int()));
case ValueBase::TYPE_COLOR:
for(iter=waypoint_list.begin();iter!=waypoint_list.end();++iter)
{
xmlpp::Element *waypoint_node=root->add_child("waypoint");
- //waypoint_node->set_attribute("time",iter->get_time().get_string(canvas->rend_desc().get_frame_rate()));
waypoint_node->set_attribute("time",iter->get_time().get_string());
- //waypoint_node->add_child(encode_value(iter->get_value(),canvas));
if(iter->get_value_node()->is_exported())
waypoint_node->set_attribute("use",iter->get_value_node()->get_relative_id(canvas));
else {
return root;
}
-xmlpp::Element* encode_subtract(xmlpp::Element* root,ValueNode_Subtract::ConstHandle value_node,Canvas::ConstHandle canvas=0)
-{
- assert(value_node);
- root->set_name("subtract");
-
- ValueNode::ConstHandle lhs=value_node->get_lhs();
- ValueNode::ConstHandle rhs=value_node->get_rhs();
- ValueNode::ConstHandle scalar=value_node->get_scalar();
-
- assert(lhs);
- assert(rhs);
-
- root->set_attribute("type",ValueBase::type_name(value_node->get_type()));
-
- if(lhs==rhs)
- warning("LHS is equal to RHS, this <subtract> will always be zero!");
-
- //if(value_node->get_scalar()!=1)
- // root->set_attribute("scalar",strprintf(VECTOR_VALUE_TYPE_FORMAT,value_node->get_scalar()));
-
- if(!scalar->get_id().empty())
- root->set_attribute("scalar",scalar->get_relative_id(canvas));
- else
- encode_value_node(root->add_child("scalar")->add_child("value_node"),scalar,canvas);
-
- if(!lhs->get_id().empty())
- root->set_attribute("lhs",lhs->get_relative_id(canvas));
- else
- encode_value_node(root->add_child("lhs")->add_child("value_node"),lhs,canvas);
-
- if(!rhs->get_id().empty())
- root->set_attribute("rhs",rhs->get_relative_id(canvas));
- else
- encode_value_node(root->add_child("rhs")->add_child("value_node"),rhs,canvas);
-
- return root;
-}
-
xmlpp::Element* encode_dynamic_list(xmlpp::Element* root,ValueNode_DynamicList::ConstHandle value_node,Canvas::ConstHandle canvas=0)
{
assert(value_node);
ValueBase value((*value_node)(0));
encode_value(root,value,canvas);
- // ValueNode_Const::ConstHandle const_value(ValueNode_Const::create((*value_node)(0)));
- // encode_value_node(root,const_value,canvas);
-
return root;
}
if(ValueNode_Animated::ConstHandle::cast_dynamic(value_node))
encode_animated(root,ValueNode_Animated::ConstHandle::cast_dynamic(value_node),canvas);
else
- if(ValueNode_Subtract::ConstHandle::cast_dynamic(value_node))
- encode_subtract(root,ValueNode_Subtract::ConstHandle::cast_dynamic(value_node),canvas);
- else
if(ValueNode_DynamicList::ConstHandle::cast_dynamic(value_node))
encode_dynamic_list(root,ValueNode_DynamicList::ConstHandle::cast_dynamic(value_node),canvas);
else if(ValueNode_Const::ConstHandle::cast_dynamic(value_node))
}
// Output the <defs> section
- //! \todo check where the parentheses should really go - around the && or the ||?
+ //! Check where the parentheses should really go - around the && or the ||?
+ //! If children is not empty (there are exported canvases in the current canvas)
+ //! they must be listed in the defs section regardless the result of check the
+ //! Value Node list (exported value nodes in the canvas) and if the canvas is
+ //! in line or not. Inline canvases cannot have exported canvases inside.
if((!canvas->is_inline() && !canvas->value_node_list().empty()) || !canvas->children().empty())
{
xmlpp::Element *node=root->add_child("defs");
/* === S Y N F I G ========================================================= */
/*! \file savecanvas.h
-** \brief writeme
+** \brief Implementation for the Synfig Save Canvas to file
**
** $Id$
**
bool save_canvas(const String &filename, Canvas::ConstHandle canvas);
//! Stores a Canvas in a string in XML format
+/*! \return The string with the XML canvas definition */
String canvas_to_string(Canvas::ConstHandle canvas);
void set_file_version(ReleaseVersion version);
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef USING_PCH
# include "pch.h"
#else
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
{
book_=new synfig::Target::Book();
ext_book_=new synfig::Target::ExtBook();
-
+//! \todo Do not hard core gamma to 2.2
default_gamma_=new synfig::Gamma(1.0/2.2);
- //default_gamma_->set_black_level(0.05); // Default to 5% black level.
// At least one target must be available.
book()["null"].factory =
#include <sigc++/signal.h>
#include "string_decl.h"
#include <utility>
-//#include <list>
#include <map>
#include <ETL/handle>
#include "renddesc.h"
-//#include "general.h"
#include "color.h"
#include "canvas.h"
#include "targetparam.h"
/* === M A C R O S ========================================================= */
-//! \writeme
-#define SYNFIG_TARGET_MODULE_EXT public: static const char name__[], \
- version__[], ext__[], cvs_id__[]; \
- static Target* create (const char *filename, \
- synfig::TargetParam p);
+//! Defines various variables and the create method, common for all Targets.
+//! To be used in the private part of the target class definition.
+#define SYNFIG_TARGET_MODULE_EXT \
+ public: static const char name__[], version__[], ext__[], cvs_id__[];\
+ static Target* create (const char *filename, synfig::TargetParam p);
//! Sets the name of the target
#define SYNFIG_TARGET_SET_NAME(class,x) const char class::name__[]=x
-//! \writeme
+//! Sets the primary file extension of the target
#define SYNFIG_TARGET_SET_EXT(class,x) const char class::ext__[]=x
//! Sets the version of the target
//! Sets the CVS ID of the target
#define SYNFIG_TARGET_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
-//! \writeme
+//! Defines de implementation of the create method for the target
+//! \param filename The file name to be created by the target.
+//! |param p The parameters passed to the target (bit rate and vcodec)
#define SYNFIG_TARGET_INIT(class) \
synfig::Target* class::create (const char *filename, \
synfig::TargetParam p) \
class TargetParam;
/*! \class Target
-** \brief Render-target
-** \todo writeme
+** \brief Used to produce rendered animations of the documents
+**
+* It is the base class for all the target renderers. It defines the has a static Book
+* pointer class that is a map for the targets factory creators and the strings
+* of the extension that the renderer can understand. It allows to create the a
+* pointer to a particular renderer just by using the extension of the name of file
+* to import. Also it creates a virtual member render() that must be declared in
+* the inherited classes.
*/
class Target : public etl::shared_object
{
public:
//! Type that represents a pointer to a Target's constructor.
/*! As a pointer to the constructor, it represents a "factory" of targets.
- ** Receives the output filename (including path).
+ ** Receives the output filename (including path) and the parameters of the target.
*/
typedef Target* (*Factory)(const char *filename, TargetParam p);
//! Book of types of targets indexed by the name of the Target.
typedef std::map<String,BookEntry> Book;
+ //! Book of types of targets indexed by the file extension
typedef std::map<String,String> ExtBook;
//! Target Book, indexed by the target's name
static Book& book();
static ExtBook& ext_book();
+ //! Initializes the Target module by creating a book of targets names
+ //! and its creators
static bool subsys_init();
+ //! Stops the Target module by deleting the book and the extension book
static bool subsys_stop();
//! Adjusted Render description set by set_rend_desc()
RendDesc desc;
+ //! Canvas being rendered in this target module
+ //! \see set_canvas()
etl::handle<Canvas> canvas;
+ //! Render quality used for the render process of the target.
int quality_;
+ //! Gamma value used for the render process of the target
Gamma gamma_;
+ //! Used by non alpha supported targets to decide if the background
+ //! must be filled or not
bool remove_alpha;
+ //! When set to true, the target doesn't sync to canvas time.
bool avoid_time_sync_;
protected:
-
+ //! Default constructor
Target();
public:
virtual ~Target() { }
-
+ //! Gets the target quality
int get_quality()const { return quality_; }
-
+ //! Sets the target quality
void set_quality(int q) { quality_=q; }
-
+ //! Sets the target avoid time synchronization
void set_avoid_time_sync(bool x=true) { avoid_time_sync_=x; }
-
+ //! Gets the target avoid time synchronization
bool get_avoid_time_sync()const { return avoid_time_sync_; }
-
+ //! Gets the target remove alpha
bool get_remove_alpha()const { return remove_alpha; }
-
+ //! Sets the target remove alpha
void set_remove_alpha(bool x=true) { remove_alpha=x; }
-
+ //! Gets the target gamma
Gamma &gamma() { return gamma_; }
-
+ //! Sets the target gamma
const Gamma &gamma()const { return gamma_; }
-
+ //! Sets the target canvas. Must be defined by derived targets
virtual void set_canvas(etl::handle<Canvas> c);
-
+ //! Gets the target canvas.
const etl::handle<Canvas> &get_canvas()const { return canvas; }
-
+ //! Gets the target particular render description
RendDesc &rend_desc() { return desc; }
+ //! Gets the target particular render description
const RendDesc &rend_desc()const { return desc; }
-
- //! Renders the canvas to the target
- virtual bool render(ProgressCallback *cb=NULL)=0;
-
//! Sets the RendDesc for the Target to \a desc.
/*! If there are any parts of \a desc that the render target
** is not capable of doing, the render target will adjust
** \a desc to fit its needs.
*/
virtual bool set_rend_desc(RendDesc *d) { desc=*d; return true; }
-
+ //! Renders the canvas to the target
+ virtual bool render(ProgressCallback *cb=NULL)=0;
+ //! Initialization tasks of the derived target.
+ //! @returns true if the initialization has no errors
virtual bool init() { return true; }
//! Creates a new Target described by \a type, outputting to a file described by \a filename.
/* === E N D =============================================================== */
-#include "canvas.h"
#endif
/* === H E A D E R S ======================================================= */
#include <cmath>
-
-#ifndef SYNFIG_NO_ANGLE
#include "angle.h"
-#endif
-
#include "time.h"
#include "vector.h"
/* === H E A D E R S ======================================================= */
-//#include "vector.h"
-//#include "time.h"
+#include "angle.h"
#include "segment.h"
-//#include "color.h"
#include "string.h"
#include <list>
#include <vector>
#include <ETL/trivial>
#include <ETL/handle>
#include "general.h"
-//#include "gradient.h"
#include "blinepoint.h"
#include "exception.h"
#include <OpenEXR/half.h>
#endif
-#ifndef SYNFIG_NO_ANGLE
-#include "angle.h"
-#endif
#include <ETL/ref_count>
operator half()const { return get(Real()); }
#endif
-#ifndef SYNFIG_NO_ANGLE
operator const Angle&()const { return get(Angle()); }
static Type get_type(const Angle&) { return TYPE_ANGLE; }
-#endif
template <class T>
operator std::list<T>()const
/* === H E A D E R S ======================================================= */
-#define SYNFIG_NO_ANGLE
-
-//#define HAS_HASH_MAP 1
-
#ifdef USING_PCH
# include "pch.h"
#else
ValueNode::subsys_stop()
{
delete book_;
-/* if(global_value_node_map.size() || value_node_count)
- {
- if(value_node_count)
- synfig::error("%d ValueNodes haven't been destroyed yet!",value_node_count);
-
- if(global_value_node_map.size()!=value_node_count)
- synfig::error("value node count mismatch! map.size()!=value_node_count (%d!=%d)",global_value_node_map.size(),value_node_count);
-
- GlobalValueNodeMap::iterator iter;
- for(iter=global_value_node_map.begin();iter!=global_value_node_map.end();++iter)
- {
- if(!iter->second->is_exported())
- synfig::info(_("%s: count:%d name:%s type:%s"),
- iter->first.get_string().c_str(),
- iter->second->count(),
- iter->second->get_name().c_str(),
- ValueBase::type_local_name(iter->second->get_type()).c_str()
- );
- else
- synfig::info(_("%s: id:%s count:%d name:%s type:%s"),
- iter->first.get_string().c_str(),
- iter->second->get_id().c_str(),
- iter->second->count(),
- iter->second->get_name().c_str(),
- ValueBase::type_local_name(iter->second->get_type()).c_str()
- );
- }
- }
-*/
return true;
}
#include <map>
#include <sigc++/signal.h>
#include "guid.h"
-
-#ifndef SYNFIG_NO_ANGLE
#include <ETL/angle>
-#endif
#include "node.h"
class Layer;
/*! \class ValueNode
-** \todo writeme
+** \brief Base class for all Value Nodes
*/
class ValueNode : public synfig::Node
{
typedef etl::rhandle<ValueNode> RHandle;
-
+ //!Instantiates the book of ValaueNodes and register all the valid valuenodes on it
static bool subsys_init();
-
+ //!Deletes the book of ValueNodes
static bool subsys_stop();
/*
*/
private:
+ //! The type of the Value Node
+ //! \see ValueBase
ValueBase::Type type;
+ //! The name of the Value Node. This is the string that is used in the
+ //! sif file to define the value type: i.e. <param name="amount">
String name;
+ //! The canvas this Value Node belongs to
etl::loose_handle<Canvas> canvas_;
+ //! The root canvas this Value Node belongs to
etl::loose_handle<Canvas> root_canvas_;
/*
virtual String get_description(bool show_exported_name = true)const;
- //! \writeme
+ //! Clones a Value Node
virtual ValueNode* clone(const GUID& deriv_guid=GUID())const=0;
- //! \writeme
+ //! Returns \true if the Value Node has an ID (has been exported)
bool is_exported()const { return !get_id().empty(); }
//! Returns the type of the ValueNode
//! Returns a handle to the parent canvas, if it has one.
etl::loose_handle<Canvas> get_root_canvas()const { return root_canvas_; }
- //! \writeme
+ //! Sets the parent canvas for the Value Node
void set_parent_canvas(etl::loose_handle<Canvas> x);
- //! \writeme
+ //! Sets the root canvas parent for the Value Node
void set_root_canvas(etl::loose_handle<Canvas> x);
- //! \writeme
+ //! Returns the relative ID of a Node when accessed form the \x Canvas
String get_relative_id(etl::loose_handle<const Canvas> x)const;
+ //! Replaces the Value Node with a given one. It look up all its parents
+ //! remove it self from them and adds the given Value Node
+ //! Notice that it is called twice and the second time it uses
+ //! a replaceable handle to the Node
+ //! \see etl::rhandle
int replace(etl::handle<ValueNode> x);
protected:
}; // END of class ValueNode
/*! \class PlaceholderValueNode
-** \todo writeme
+** Seems to be a Place to hold a Value Node temporarly.
+*
+* Doesn't seem to implement any functionality. Seems to be used when the
+* value node cannot be created using the Const, Animated or Linkable
+* Value Nodes.
+*
*/
class PlaceholderValueNode : public ValueNode
{
/*! \class LinkableValueNode
-** \todo writeme
+** \brief Specialized Class of Value Nodes that has links to other
+** Value Nodes
+*
+* This Value Node is calculated based on a math calculation or a time
+* evaluation of the linked Value Nodes. It is commonly known as
+* Converted Value Nodes. The derived clases defines the behavior.
*/
class LinkableValueNode : public ValueNode
{
//! Type that represents a pointer to a ValueNode's constructor
- /*! As a pointer to the constructor, it represents a "factory" of
+ /*! As a pointer to the constructor, it represents a "factory" of
** objects of this class.
*/
typedef LinkableValueNode* (*Factory)(const ValueBase&);
+ //! This represents a pointer to a Type check member fucntion
+ /*! As a pointer to the member, it represents a fucntion that checks
+ ** the type of the provided ValueBase
+ */
typedef bool (*CheckType)(ValueBase::Type);
struct BookEntry
};
//! Book of types of linkable value nodes indexed by type name.
- /*! While the sifz file is read, each time a new LinkableValueNode entry
- ** is found, the factory constructor that the "factory" pointer member
- ** of the "BookEntry" struct points to, is called, and a new object of
+ /*! While the sifz file is read, each time a new LinkableValueNode entry
+ ** is found, the factory constructor that the "factory" pointer member
+ ** of the "BookEntry" struct points to, is called, and a new object of
** that type is created.
** \sa LinkableValueNode::Factory
*/
static Book& book();
+ //! Creates a Linkable Value Node based on the name and the returned
+ //! value type. Returns a valid Handle if both (name and type) match
static Handle create(const String &name, const ValueBase& x);
+ //! Each derived Linkable Value Node has to implement this fucntion and
+ //! should return true only if the type matches. \name is the name of
+ //! the linked value node and \x is the returned value type
static bool check_type(const String &name, ValueBase::Type x);
public:
ValueNode(type) { }
protected:
+ //! Stores the Value Node \x in the sub parameter i after check if the
+ //! type is the same.
+ //! It has to be defined by the derived class.
virtual bool set_link_vfunc(int i,ValueNode::Handle x)=0;
+ //! Frees all the subparameters of the Linkable Value Node.
+ //! Used by the derived classed destructors.
void unlink_all();
public:
+ //! Returns the number of linked Value Nodes
virtual int link_count()const=0;
+ //! Returns the local name of the 'i' linked Value Node
virtual String link_local_name(int i)const=0;
+ //! Returns the name of the 'i' linked Value Node
virtual String link_name(int i)const=0;
+ //! Returns the child index Value Node based on the name
virtual int get_link_index_from_name(const String &name)const=0;
+ //! Clones a Value Node
virtual ValueNode* clone(const GUID& deriv_guid=GUID())const;
+ //! Sets a new Value Node link by its index
bool set_link(int i,ValueNode::Handle x);
+ //! Sets a new Value Node link by its name
bool set_link(const String &name,ValueNode::Handle x) { return set_link(get_link_index_from_name(name),x); }
+ //! Returns a Loose Handle to the Value Node based on the link's index
ValueNode::LooseHandle get_link(int i)const;
+ //! Returns a Loose Handle to the Value Node based on the link's name
ValueNode::LooseHandle get_link(const String &name)const { return get_link(get_link_index_from_name(name)); }
-
- String
- get_description(int index = -1, bool show_exported_name = true)const;
+ //! Return a full description of the linked ValueNode given by the index
+ String get_description(int index = -1, bool show_exported_name = true)const;
protected:
//! Sets the type of the ValueNode
void set_type(ValueBase::Type t) { ValueNode::set_type(t); }
+ //! Virtual member to get the linked Value Node Handle
virtual ValueNode::LooseHandle get_link_vfunc(int i)const=0;
- // Wrapper for new operator, used by clone()
+ //! Wrapper for new operator, used by clone()
virtual LinkableValueNode* create_new()const=0;
+ //! Returns the cached times values for all the children (linked Value Nodes)
virtual void get_times_vfunc(Node::time_set &set) const;
}; // END of class LinkableValueNode
/*! \class ValueNodeList
** \brief A searchable value_node list container
** \warning Do not confuse with ValueNode_DynamicList!
-** \todo writeme
+*
+* Used by Canvas class to access to the exported value nodes.
*/
class ValueNodeList : public std::list<ValueNode::RHandle>
{
/* === M A C R O S ========================================================= */
-// Fast binary search implementation
-/*
-template<typename I, typename T> inline I
-binary_find(I begin, I end, const T& value)
-{
- I iter(begin+(end-begin)/2);
-
- while(end-begin>1 && !(*iter==value))
- {
- ((*iter<value)?begin:end) = iter;
-
- iter = begin+(end-begin)/2;
- }
- return iter;
-}
-*/
-
-/*
+/*** DEBUG STUFF
template<typename T> String tangent_info(T a, T b, T v)
{
return "...";
}
};
-
-
-
-
template <class T>
struct is_angle_type
{
return ret;
}
-/*
+/** This code seems to be designed to move selected waypoints to other
+ * place. Probably it was commented out because the conflict when other
+ * waypoints are found in the target time. It was also defined and now commented
+ * in valuenode_dynamiclist.h
void
ValueNode_Animated::manipulate_time(const Time& old_begin,const Time& old_end,const Time& new_begin,const Time& new_end)
{
try { prev=find_prev(time); has_prev=true; } catch(...) { }
try { next=find_next(time); has_next=true; } catch(...) { }
- /*
- WaypointList::const_iterator closest;
-
- if(has_prev&&!has_next)
- closest=prev;
- else if(has_next&&!has_prev)
- closest=next;
- else if(time-prev->get_time()<next->get_time()-time)
- closest=prev;
- else
- closest=next;
-
- for(iter=waypoint_list().begin();iter!=waypoint_list().end();++iter)
- {
- const Real dist(abs(iter->get_time()-time));
- if(dist<abs(closest->get_time()-time))
- closest=iter;
- }
- */
-
if(has_prev && !prev->is_static())
waypoint.set_value_node(prev->get_value_node());
if(has_next && !next->is_static())
else
waypoint.set_value((*this)(time));
- /*if(has_prev)
- waypoint.set_after(prev->get_before());
- if(has_next)
- waypoint.set_before(next->get_after());
- */
}
}
waypoint.set_time(time);
ValueNode_Animated::find(const UniqueID &x)const
{
return const_cast<ValueNode_Animated*>(this)->find(x);
- /*
- ValueNode_Animated::WaypointList::const_iterator iter;
- iter=std::find(waypoint_list().begin(),waypoint_list().end(),x);
- if(iter!=waypoint_list().end() && iter->get_uid()!=x.get_uid())
- throw Exception::NotFound(strprintf("ValueNode_Animated::find()const: Can't find UniqueID %d",x.get_uid()));
- return iter;
- */
}
ValueNode_Animated::WaypointList::iterator
ValueNode_Animated::find(const Time &x)const
{
return const_cast<ValueNode_Animated*>(this)->find(x);
- /*
- WaypointList::const_iterator iter(binary_find(waypoint_list().begin(),waypoint_list().end(),x));
-
- if(iter!=waypoint_list().end() && x.is_equal(iter->get_time()))
- return iter;
-
- throw Exception::NotFound(strprintf("ValueNode_Animated::find(): Can't find Waypoint at %s",x.get_string().c_str()));
- */
}
ValueNode_Animated::WaypointList::iterator
ValueNode_Animated::find_next(const Time &x)const
{
return const_cast<ValueNode_Animated*>(this)->find_next(x);
- /*
- WaypointList::const_iterator iter(binary_find(waypoint_list().begin(),waypoint_list().end(),x));
-
- if(iter!=waypoint_list().end())
- {
- if(iter->get_time()-Time::epsilon()>x)
- return iter;
- ++iter;
- if(iter!=waypoint_list().end() && iter->get_time()-Time::epsilon()>x)
- return iter;
- }
-
- throw Exception::NotFound(strprintf("ValueNode_Animated::find_next(): Can't find Waypoint after %s",x.get_string().c_str()));
-*/
}
ValueNode_Animated::WaypointList::iterator
ValueNode_Animated::find_prev(const Time &x)const
{
return const_cast<ValueNode_Animated*>(this)->find_prev(x);
- /*
- WaypointList::const_iterator iter(binary_find(waypoint_list().begin(),waypoint_list().end(),x));
-
- if(iter!=waypoint_list().end())
- {
- if(iter->get_time()+Time::epsilon()<x)
- return iter;
- if(iter!=waypoint_list().begin() && (--iter)->get_time()+Time::epsilon()<x)
- return iter;
- }
- throw Exception::NotFound(strprintf("ValueNode_Animated::find_prev(): Can't find Waypoint after %s",x.get_string().c_str()));
- */
}
void
namespace synfig {
+/*! \class ValueNode_Animated
+ * \brief Virtual class for the derived ValueNode Animated implementations.
+ *
+ * It stores the list of waypoints and defines the base methods for:
+ * add a given waypoint, return a new waypoint at a given time, some find
+ * functions to find waypoints in the list, and to create a handles to
+ * ValueNode_Animated based on the ValueBase Type of the given value node.
+ * Also defines virtual methods to add a new waypoint at a given time using
+ * a value node. They must be redefined by the inherited classes and will
+ * be different depending on the type of value being animated.
+*/
struct ValueNode_Animated : public ValueNode
{
public:
typedef std::pair<WaypointList::const_iterator,bool> const_findresult;
protected:
+ //! List of Waypoints. \see waypoint.h
WaypointList waypoint_list_;
public:
const WaypointList &waypoint_list()const { return waypoint_list_; }
+ //! Creates a new waypoint at a Time \t with a given ValueBase \value
+ //! Must be redefined in the inherited class
virtual WaypointList::iterator new_waypoint(Time t, ValueBase value)=0;
-
+ //! Creates a new waypoint at a Time \t with a given ValueNode handle \value_node
+ //! Must be redefined in the inherited class
virtual WaypointList::iterator new_waypoint(Time t, ValueNode::Handle value_node)=0;
+ //! Returns a new waypoint at a given time but it is not inserted in the Waypoint List.
/*! \note this does not add any waypoint to the ValueNode! */
Waypoint new_waypoint_at_time(const Time& t)const;
+ //! Adds a waypoint \x
+ //! \see : Waypoint new_waypoint_at_time(const Time& t)const;
WaypointList::iterator add(const Waypoint &x);
+ //! Removes a waypoint based on its UniqueId from the waypoint list
void erase(const UniqueID &x);
- //either use find result (return bool and iterator) or
+ //! Finds Waypoint iterator and associated boolean if found. Find by UniqueID
findresult find_uid(const UniqueID &x);
+ //! Finds Waypoint iterator and associated boolean if found. Find by UniqueID
const_findresult find_uid(const UniqueID &x)const;
+ //! Finds Waypoint iterator and associated boolean if found. Find by Time
findresult find_time(const Time &x);
+ //! Finds Waypoint iterator and associated boolean if found. Find by Time
const_findresult find_time(const Time &x)const;
+ //! Finds a Waypoint by given UniqueID \x
WaypointList::iterator find(const UniqueID &x);
+ //! Finds a Waypoint by given UniqueID \x
WaypointList::const_iterator find(const UniqueID &x)const;
+ //! Finds a Waypoint by given Time \x
WaypointList::iterator find(const Time &x);
+ //! Finds a Waypoint by given Time \x
WaypointList::const_iterator find(const Time &x)const;
+ //! Finds next Waypoint at a given time \x starting from current waypoint
WaypointList::iterator find_next(const Time &x);
+ //! Finds next Waypoint at a given time \x starting from current waypoint
WaypointList::const_iterator find_next(const Time &x)const;
+ //! Finds previous Waypoint at a given time \x starting from current waypoint
WaypointList::iterator find_prev(const Time &x);
+ //! Finds previous Waypoint at a given time \x starting from current waypoint
WaypointList::const_iterator find_prev(const Time &x)const;
virtual ~ValueNode_Animated();
+ //! Virtual member to be filled by inherited classes
virtual String get_name()const;
+ //! Virtual member to be filled by inherited classes
virtual String get_local_name()const;
+ //! Creates a Valuenode_Animated by type
static Handle create(ValueBase::Type type);
-
+ //! Creates a Valuenode_Animated by ValueBase and Time
static Handle create(const ValueBase& value, const Time& time);
-
+ //! Creates a Valuenode_Animated by ValueNode and Time
static Handle create(ValueNode::Handle value_node, const Time& time);
+ //! Fills the \list with the waypoints between \begin and \end
int find(const Time& begin,const Time& end,std::vector<Waypoint*>& list);
+ //! Inserts time \delta from time \location to the waypoints.
+ //! used to move waypoints in the time line.
void insert_time(const Time& location, const Time& delta);
protected:
ValueNode_Animated();
+ //! Sets thee type of the Animated Value Node
void set_type(ValueBase::Type t);
+ //! Function to be overloaded that fills the Time Point Set with
+ //! all the children Time Points. Time Point is like Waypoint but
+ //! without value node
virtual void get_times_vfunc(Node::time_set &set) const;
};
bias(0),
time_tension(0.0f)
{
+ //!Writeme
if(value.get_type()==ValueBase::TYPE_ANGLE)
after=before=INTERPOLATION_LINEAR;
}
void
Waypoint::set_value(const ValueBase &x)
{
+ //! If the value node is not set and we are seting the value
+ //! of an angle, then set both interpolation to linear... why?
if(!value_node && x.get_type()==ValueBase::TYPE_ANGLE)
after=before=INTERPOLATION_LINEAR;
void
Waypoint::set_value_node(const etl::handle<ValueNode> &x)
{
+ //! If the value node is not set and we are seting the value
+ //! of an angle, then set both interpolation to linear... why?
if(!value_node && x->get_type()==ValueBase::TYPE_ANGLE)
after=before=INTERPOLATION_LINEAR;
/* === S Y N F I G ========================================================= */
/*! \file waypoint.h
-** \brief Template Header
+** \brief Waypoint class header.
**
** $Id$
**
#include "time.h"
#include "real.h"
#include "value.h"
-//#include "valuenode.h"
#include "uniqueid.h"
#include <vector>
#include "guid.h"
/*! \class Waypoint
-** \brief \writeme
+** \brief Waypoint is used to handle variations along the time of the ValueNodes
+*
+* The Waypoint is a child of a ValueNode (or any of inherited) and it describes the
+* Interpolation type (before and after), the ValueNode (usually waypoints are constant
+* but in fact they can be animated) and the time where the waypoint is.
+* \see Waypoint::get_value(), Waypoint::get_value(const Time &t)
*/
class Waypoint : public UniqueID
{
typedef synfig::Interpolation Interpolation;
+/*! \class Waypoint::Model
+ * \brief Waypoint::Model is a Waypoint model. It is used to store and
+ * retrieve the values of the waypoint that is going to be modified. Once
+ * the model is completely modifed then it can be applied to the waypoint
+ * itself by using the \apply_model() member
+ */
class Model
{
friend class Waypoint;
bias_flag(false),
temporal_tension_flag(false) { }
+ //! Gets before Interpolation
Interpolation get_before()const { return before; }
+ //! Sets before Interpolation
void set_before(Interpolation x) { before=x; before_flag=true;}
-
+ //! Gets after Interpolation
Interpolation get_after()const { return after; }
+ //! Sets after Interpolation
void set_after(Interpolation x) { after=x; after_flag=true;}
-
+ //! Gets tension
const Real &get_tension()const { return tension; }
+ //! Sets tension
void set_tension(const Real &x) { tension=x; tension_flag=true;}
-
+ //! Gets continuity
const Real &get_continuity()const { return continuity; }
+ //! Sets continuity
void set_continuity(const Real &x) { continuity=x; continuity_flag=true;}
-
+ //! Gets bias
const Real &get_bias()const { return bias; }
+ //! Sets bias
void set_bias(const Real &x) { bias=x; bias_flag=true;}
-
+ //! Gets temporal tension
const Real &get_temporal_tension()const { return temporal_tension; }
+ //! Sets temporal tension
void set_temporal_tension(const Real &x) { temporal_tension=x; temporal_tension_flag=true;}
-
+ //! Gets priority
int get_priority()const { return priority; }
+ //! Sets priority
void set_priority(int x) { priority=x; priority_flag=true;}
+ //! Get & Set members for the flags
#define FLAG_MACRO(x) bool get_##x##_flag()const { return x##_flag; } void set_##x##_flag(bool y) { x##_flag=y; }
FLAG_MACRO(priority)
FLAG_MACRO(before)
FLAG_MACRO(temporal_tension)
#undef FLAG_MACRO
+ //! Converts the Model in trivial: None of its values will be applied
void reset()
{
priority_flag=false;
temporal_tension_flag=false;
}
+ //! Checks if none of the Model information is relevant for the Waypoint
+ //! If all the flags are off, the Model doesn't apply wnything to the
+ //! waypoint. \see apply_model(const Model &x)
bool is_trivial()const
{
return !(
private:
+ //! Writeme
int priority_;
+ //! Usually Animated Value Nodes are parents of waypoints
+ //! \see class ValueNode_Animated
etl::loose_handle<ValueNode> parent_;
-
+ //! The two Interpolations before and after
Interpolation before, after;
-
+ //! The value node that is hold by the waypoint
etl::rhandle<ValueNode> value_node;
-
+ //! The time of the waypoint
Time time;
- // The following are for the INTERPOLATION_TCB type
+ //! The following are for the INTERPOLATION_TCB type
Real tension;
Real continuity;
Real bias;
- // The following are for the INTERPOLATION_MANUAL type
+ //! The following are for the INTERPOLATION_MANUAL type
+ //! Seems to be not used
ValueBase cpoint_before,cpoint_after;
-
+ //! Shouldn't be Real?
float time_tension;
/*
public:
+ //! Constructor for constant Waypoint
Waypoint(ValueBase value, Time time);
+ //! Constructor for animated Waypoint
+ //! Is is called anytime?
Waypoint(etl::handle<ValueNode> value_node, Time time);
+ //! Default constructor. Leaves unset the Value Node
Waypoint();
/*
public:
+ //! Applies the content of the Model to the Waypoint. It doesn't alter
+ //! the Value Node hold or the time.
void apply_model(const Model &x);
+ //! Gets the before Interpolation
Interpolation get_before()const { return before; }
+ //! Sets the before Interpolation
void set_before(Interpolation x) { before=x; }
-
+ //! Gets the after Interpolation
Interpolation get_after()const { return after; }
+ //! Sets the after Interpolation
void set_after(Interpolation x) { after=x; }
-
+ //! Gets the value hold by the Waypoint
ValueBase get_value()const;
+ //!Gets the value hold by the Waypoint at time \t when it is animated
ValueBase get_value(const Time &t)const;
+ //!Sets the value of the Waypoint.
+ //!Maybe it would be posible to define set_value(const ValueBase &x, Time &t) ?
void set_value(const ValueBase &x);
-
+ //! Returns the handle to the value node
const etl::rhandle<ValueNode> &get_value_node()const { return value_node; }
+ //! Sets the value node by handle
void set_value_node(const etl::handle<ValueNode> &x);
+ //! Gets tension
const Real &get_tension()const { return tension; }
+ //! Sets tension
void set_tension(const Real &x) { tension=x; }
-
+ //! Gets continuity
const Real &get_continuity()const { return continuity; }
+ //! Sets continuity
void set_continuity(const Real &x) { continuity=x; }
-
+ //! Gets bias
const Real &get_bias()const { return bias; }
+ //! Sets bias
void set_bias(const Real &x) { bias=x; }
+ //! Gets the time of the waypoint
const Time &get_time()const { return time; }
+ //! Sets the time of the waypoint
void set_time(const Time &x);
int get_priority()const { return priority_; }
void set_priority(int x) { priority_=x; }
+ //! Gets parent Value Node
const etl::loose_handle<ValueNode> &get_parent_value_node()const { return parent_; }
+ //! Sets parent Value Node
void set_parent_value_node(const etl::loose_handle<ValueNode> &x) { parent_=x; }
+ //! \true if the Value Node is constant, not null and not exported
bool is_static()const;
+ //!! Gets temporal tension
float get_temporal_tension()const { return time_tension; }
+ //!! Sets temporal tension
void set_temporal_tension(const float& x) { time_tension=x; }
+ //! True if the current waypoint's time is earlier than the compared waypoint's time
bool operator<(const Waypoint &rhs)const
{ return time<rhs.time; }
-
+ //! True if the current waypoint's time is earlier than the given time
bool operator<(const Time &rhs)const
{ return time.is_less_than(rhs); }
+ //! True if the current waypoint's time is later than the given time
bool operator>(const Time &rhs)const
{ return time.is_more_than(rhs); }
-
+ //! True if the waypoint's time is the same than the given time
bool operator==(const Time &rhs)const
{ return time.is_equal(rhs); }
+ //! True if the waypoint's time is different than the given time
bool operator!=(const Time &rhs)const
{ return !time.is_equal(rhs); }
+ //! True if the Waypoint's Unique Id is the same than the argument's Unique ID
bool operator==(const UniqueID &rhs)const
{ return get_uid()==rhs.get_uid(); }
+ //! True if the Waypoint's Unique Id is different than the argument's Unique ID
bool operator!=(const UniqueID &rhs)const
{ return get_uid()!=rhs.get_uid(); }
+ //! Clones the Value Node if it is not exported and returns a Waypoint
+ //! with no parent.
Waypoint clone(const GUID& deriv_guid=GUID())const;
+ //! Returns a hack GUID using the UniqueID's value
GUID get_guid()const;
}; // END of class Waypoint