From: Carlos Lopez Date: Wed, 28 Jul 2010 16:17:47 +0000 (+0200) Subject: Merge branch 'master' into genete_core_review X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6054e41d9bd09ab2addaef1eeb45798a99e77d70;hp=7d6c6aae87f6a9123e30d116a4cd6296eb5086fb;p=synfig.git Merge branch 'master' into genete_core_review --- diff --git a/synfig-core/src/modules/lyr_std/stretch.cpp b/synfig-core/src/modules/lyr_std/stretch.cpp index de0de94..0f1c37d 100644 --- a/synfig-core/src/modules/lyr_std/stretch.cpp +++ b/synfig-core/src/modules/lyr_std/stretch.cpp @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_bmp/main.cpp b/synfig-core/src/modules/mod_bmp/main.cpp index 88fbbbd..dbf86b1 100644 --- a/synfig-core/src/modules/mod_bmp/main.cpp +++ b/synfig-core/src/modules/mod_bmp/main.cpp @@ -22,8 +22,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp b/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp index 9151cfe..d8c07b7 100644 --- a/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp +++ b/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp @@ -24,8 +24,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_bmp/trgt_bmp.cpp b/synfig-core/src/modules/mod_bmp/trgt_bmp.cpp index fe2d433..5a126ff 100644 --- a/synfig-core/src/modules/mod_bmp/trgt_bmp.cpp +++ b/synfig-core/src/modules/mod_bmp/trgt_bmp.cpp @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_dv/trgt_dv.cpp b/synfig-core/src/modules/mod_dv/trgt_dv.cpp index 6174af0..896ae6c 100644 --- a/synfig-core/src/modules/mod_dv/trgt_dv.cpp +++ b/synfig-core/src/modules/mod_dv/trgt_dv.cpp @@ -25,8 +25,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp b/synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp index d1b9219..528166d 100644 --- a/synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp +++ b/synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp @@ -26,8 +26,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_gif/trgt_gif.cpp b/synfig-core/src/modules/mod_gif/trgt_gif.cpp index a520ff3..5c8b49a 100644 --- a/synfig-core/src/modules/mod_gif/trgt_gif.cpp +++ b/synfig-core/src/modules/mod_gif/trgt_gif.cpp @@ -25,8 +25,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_imagemagick/trgt_imagemagick.cpp b/synfig-core/src/modules/mod_imagemagick/trgt_imagemagick.cpp index dc024ae..c23ef14 100644 --- a/synfig-core/src/modules/mod_imagemagick/trgt_imagemagick.cpp +++ b/synfig-core/src/modules/mod_imagemagick/trgt_imagemagick.cpp @@ -25,8 +25,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_jpeg/trgt_jpeg.cpp b/synfig-core/src/modules/mod_jpeg/trgt_jpeg.cpp index b0def32..890b533 100644 --- a/synfig-core/src/modules/mod_jpeg/trgt_jpeg.cpp +++ b/synfig-core/src/modules/mod_jpeg/trgt_jpeg.cpp @@ -25,8 +25,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_libavcodec/main.cpp b/synfig-core/src/modules/mod_libavcodec/main.cpp index 70fa9c5..30aa3c5 100644 --- a/synfig-core/src/modules/mod_libavcodec/main.cpp +++ b/synfig-core/src/modules/mod_libavcodec/main.cpp @@ -22,8 +22,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_libavcodec/mptr.cpp b/synfig-core/src/modules/mod_libavcodec/mptr.cpp index 667968b..4c9bfb8 100644 --- a/synfig-core/src/modules/mod_libavcodec/mptr.cpp +++ b/synfig-core/src/modules/mod_libavcodec/mptr.cpp @@ -22,8 +22,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_libavcodec/trgt_av.cpp b/synfig-core/src/modules/mod_libavcodec/trgt_av.cpp index f329081..5f481f6 100644 --- a/synfig-core/src/modules/mod_libavcodec/trgt_av.cpp +++ b/synfig-core/src/modules/mod_libavcodec/trgt_av.cpp @@ -24,8 +24,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_magickpp/trgt_magickpp.cpp b/synfig-core/src/modules/mod_magickpp/trgt_magickpp.cpp index 875f2b5..0570685 100644 --- a/synfig-core/src/modules/mod_magickpp/trgt_magickpp.cpp +++ b/synfig-core/src/modules/mod_magickpp/trgt_magickpp.cpp @@ -24,8 +24,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_mng/trgt_mng.cpp b/synfig-core/src/modules/mod_mng/trgt_mng.cpp index 3540490..23d6e81 100644 --- a/synfig-core/src/modules/mod_mng/trgt_mng.cpp +++ b/synfig-core/src/modules/mod_mng/trgt_mng.cpp @@ -27,8 +27,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_openexr/trgt_openexr.cpp b/synfig-core/src/modules/mod_openexr/trgt_openexr.cpp index 2ad34f5..fd29524 100644 --- a/synfig-core/src/modules/mod_openexr/trgt_openexr.cpp +++ b/synfig-core/src/modules/mod_openexr/trgt_openexr.cpp @@ -25,8 +25,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_png/trgt_png.cpp b/synfig-core/src/modules/mod_png/trgt_png.cpp index a0a58b1..c4d4df4 100644 --- a/synfig-core/src/modules/mod_png/trgt_png.cpp +++ b/synfig-core/src/modules/mod_png/trgt_png.cpp @@ -25,8 +25,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_ppm/trgt_mpg.cpp b/synfig-core/src/modules/mod_ppm/trgt_mpg.cpp index c90ebfd..ecdecba 100644 --- a/synfig-core/src/modules/mod_ppm/trgt_mpg.cpp +++ b/synfig-core/src/modules/mod_ppm/trgt_mpg.cpp @@ -24,8 +24,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_ppm/trgt_ppm.cpp b/synfig-core/src/modules/mod_ppm/trgt_ppm.cpp index 0859d84..0012c54 100644 --- a/synfig-core/src/modules/mod_ppm/trgt_ppm.cpp +++ b/synfig-core/src/modules/mod_ppm/trgt_ppm.cpp @@ -25,8 +25,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_svg/main.cpp b/synfig-core/src/modules/mod_svg/main.cpp index 1f5be67..1906b70 100644 --- a/synfig-core/src/modules/mod_svg/main.cpp +++ b/synfig-core/src/modules/mod_svg/main.cpp @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/modules/mod_yuv420p/trgt_yuv.cpp b/synfig-core/src/modules/mod_yuv420p/trgt_yuv.cpp index a6d3455..df1e8e2 100644 --- a/synfig-core/src/modules/mod_yuv420p/trgt_yuv.cpp +++ b/synfig-core/src/modules/mod_yuv420p/trgt_yuv.cpp @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/synfig/Makefile.am b/synfig-core/src/synfig/Makefile.am index ac0ddca..78f3ad2 100644 --- a/synfig-core/src/synfig/Makefile.am +++ b/synfig-core/src/synfig/Makefile.am @@ -11,7 +11,9 @@ INCLUDES = \ EXTRA_DIST = \ surfacenew.cpp \ pch.h \ - synfig.nsh + synfig.nsh \ + synfig.h \ + nodebase.h LAYERHEADERS = \ @@ -184,7 +186,6 @@ SYNFIGHEADERS = \ general.h \ guidset.h \ interpolation.h \ - nodebase.h \ protocol.h \ quick_rng.h \ real.h \ @@ -194,7 +195,6 @@ SYNFIGHEADERS = \ string.h \ string_decl.h \ surfacenew.h \ - synfig.h \ types.h \ vector.h \ version.h \ diff --git a/synfig-core/src/synfig/canvas.cpp b/synfig-core/src/synfig/canvas.cpp index 2bbb743..eeecdb0 100644 --- a/synfig-core/src/synfig/canvas.cpp +++ b/synfig-core/src/synfig/canvas.cpp @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/synfig/canvas.h b/synfig-core/src/synfig/canvas.h index a6474da..becfb10 100644 --- a/synfig-core/src/synfig/canvas.h +++ b/synfig-core/src/synfig/canvas.h @@ -115,7 +115,12 @@ class Context; 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 { @@ -174,7 +179,8 @@ private: /*! \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. @@ -194,20 +200,22 @@ private: //! 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 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 > > group_db_; - //! Layer Connection database + //! Layer Signal Connection database. Seems to be unused. std::map,std::vector > connections_; /* @@ -252,11 +260,11 @@ private: //! ValueBasenode Changed sigc::signal > signal_value_node_changed_; - + //! ValueBasenode Renamed sigc::signal > signal_value_node_renamed_; - + //! Child Value Node Added. Used in Dynamic List Value Nodes sigc::signal, etl::handle > signal_value_node_child_added_; - + //! Child Value Node Removed. Used in Dynamic List Value Nodes sigc::signal, etl::handle > signal_value_node_child_removed_; /* @@ -295,18 +303,18 @@ public: //! Metadata Changed sigc::signal& signal_meta_data_changed(const String& key) { return signal_map_meta_data_changed_[key]; } - + //! Value Node Changed sigc::signal >& signal_value_node_changed() { return signal_value_node_changed_; } - + //! Value Node Renamed sigc::signal >& signal_value_node_renamed() { return signal_value_node_renamed_; } - //! Dirty + //! Dirty sigc::signal& signal_dirty() { return signal_changed(); } - //! \writeme + //! Child Value Node Added sigc::signal, etl::handle >& signal_value_node_child_added() { return signal_value_node_child_added_; } - //! \writeme + //! Child Value Node Removed sigc::signal, etl::handle >& signal_value_node_child_removed() { return signal_value_node_child_removed_; } /* @@ -314,7 +322,7 @@ public: */ protected: - + //! Canvas constructor by Canvas name Canvas(const String &name); public: @@ -339,7 +347,7 @@ 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 @@ -390,10 +398,10 @@ public: //! 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 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 x)const; //! Returns \c true if the Canvas is a root Canvas. \c false otherwise @@ -403,6 +411,7 @@ public: /*! 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 @@ -417,7 +426,7 @@ public: //! 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 @@ -456,16 +465,19 @@ public: */ 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 @@ -508,43 +520,66 @@ public: //! 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 find_layer(const Point &pos); + //! Gets the depth of a particular Layer by its handle int get_depth(etl::handle)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 &back(); - + //! Returns last layer in Canvas layer stack + const etl::handle &back()const; + //! Inserts a layer just before the last layer. + //! \see end(), insert(iterator iter,etl::handle x) void push_back(etl::handle x); - + //! Inserts a layer just at the beggining of the Canvas layer dqueue void push_front(etl::handle 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 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 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 &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 @@ -552,16 +587,30 @@ public: #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); + //! Removes a \layer from a group given by its \group string to the group + //! database void remove_group_pair(String group, etl::handle layer); + //! Seems to be used to add the stored signals connections of the layers. + //! \see connections_ void add_connection(etl::loose_handle 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); 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); diff --git a/synfig-core/src/synfig/color.h b/synfig-core/src/synfig/color.h index d54b0e9..ee5f501 100644 --- a/synfig-core/src/synfig/color.h +++ b/synfig-core/src/synfig/color.h @@ -29,20 +29,16 @@ /* === H E A D E R S ======================================================= */ -//#include #include #include #include "gamma.h" #include +# include "angle.h" #ifdef USE_HALF_TYPE #include #endif -#ifndef SYNFIG_NO_ANGLE -# include "angle.h" -#endif - /* === M A C R O S ========================================================= */ #define use_colorspace_gamma() App::use_colorspace_gamma @@ -386,7 +382,6 @@ public: 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() */ @@ -443,7 +438,6 @@ public: 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; diff --git a/synfig-core/src/synfig/context.cpp b/synfig-core/src/synfig/context.cpp index 38e0f67..28d8e41 100644 --- a/synfig-core/src/synfig/context.cpp +++ b/synfig-core/src/synfig/context.cpp @@ -347,13 +347,14 @@ Context::set_time(Time time)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; } diff --git a/synfig-core/src/synfig/context.h b/synfig-core/src/synfig/context.h index c03d312..996abae 100644 --- a/synfig-core/src/synfig/context.h +++ b/synfig-core/src/synfig/context.h @@ -1,6 +1,6 @@ /* === S Y N F I G ========================================================= */ /*! \file context.h -** \brief Template Header +** \brief Iterator for the layers behind the current Layer. ** ** $Id$ ** @@ -49,33 +49,40 @@ class Time; 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 hit_check(const Point &point)const; }; // END of class Context diff --git a/synfig-core/src/synfig/importer.cpp b/synfig-core/src/synfig/importer.cpp index e271110..1784d3a 100644 --- a/synfig-core/src/synfig/importer.cpp +++ b/synfig-core/src/synfig/importer.cpp @@ -1,6 +1,6 @@ /* === S Y N F I G ========================================================= */ /*! \file importer.cpp -** \brief writeme +** \brief It is the base class for all the importers. ** ** $Id$ ** @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/synfig/importer.h b/synfig-core/src/synfig/importer.h index 4391c4e..6185ab5 100644 --- a/synfig-core/src/synfig/importer.h +++ b/synfig-core/src/synfig/importer.h @@ -1,7 +1,6 @@ -#include /* === S Y N F I G ========================================================= */ /*! \file importer.h -** \brief writeme +** \brief It is the base class for all the importers. ** ** $Id$ ** @@ -28,34 +27,35 @@ /* === H E A D E R S ======================================================= */ +#include #include -//#include #include #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 ===================================================== */ @@ -68,19 +68,33 @@ class Surface; 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 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 Handle; @@ -88,6 +102,8 @@ public: typedef etl::handle ConstHandle; private: + //! Gamma of the importer. + //! \todo Do not hardcode the gamma to 2.2 Gamma gamma_; protected: @@ -111,9 +127,12 @@ public: 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); } diff --git a/synfig-core/src/synfig/layer.cpp b/synfig-core/src/synfig/layer.cpp index 8fcbfbf..9d1adf3 100644 --- a/synfig-core/src/synfig/layer.cpp +++ b/synfig-core/src/synfig/layer.cpp @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/synfig/layer.h b/synfig-core/src/synfig/layer.h index 1e321b0..c002330 100644 --- a/synfig-core/src/synfig/layer.h +++ b/synfig-core/src/synfig/layer.h @@ -41,7 +41,8 @@ /* === 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__[]; \ @@ -67,14 +68,15 @@ #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)) \ { \ @@ -85,7 +87,7 @@ 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)) \ { \ @@ -93,27 +95,27 @@ 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__; @@ -192,7 +194,7 @@ public: //! 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 @@ -203,10 +205,16 @@ public: 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 ParamList; typedef etl::handle Handle; @@ -215,6 +223,7 @@ public: typedef etl::handle ConstHandle; + //! Map of parameters that are animated Value Nodes indexed by the param name typedef std::map > DynamicParamList; //! A list type which describes all the parameters that a layer has. @@ -235,12 +244,13 @@ private: //! Handle to the canvas to which this layer belongs etl::loose_handle 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 @@ -249,7 +259,10 @@ private: //! 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_; /* @@ -327,13 +340,14 @@ public: //! 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); + + //! Disconnects the parameter from any Value Node bool disconnect_dynamic_param(const String& param); //! Enables the layer for rendering (Making it \em active) @@ -356,13 +370,13 @@ public: /*! 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 @@ -371,10 +385,10 @@ public: //! Returns a handle to the Canvas to which this Layer belongs etl::loose_handle 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 @@ -388,8 +402,12 @@ public: */ 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 @@ -404,7 +422,8 @@ public: //! 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 get_transform()const; //! Sets the virtual version to use for backwards-compatibility @@ -440,10 +459,10 @@ public: //! 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; @@ -451,14 +470,14 @@ public: /*! \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 const Point \& */ 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; @@ -469,7 +488,7 @@ public: ** \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; @@ -477,7 +496,9 @@ public: /*! \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 diff --git a/synfig-core/src/synfig/layer_bitmap.cpp b/synfig-core/src/synfig/layer_bitmap.cpp index cda5d09..8443429 100644 --- a/synfig-core/src/synfig/layer_bitmap.cpp +++ b/synfig-core/src/synfig/layer_bitmap.cpp @@ -22,8 +22,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/synfig/layer_composite.cpp b/synfig-core/src/synfig/layer_composite.cpp index 6a25efc..5d03787 100644 --- a/synfig-core/src/synfig/layer_composite.cpp +++ b/synfig-core/src/synfig/layer_composite.cpp @@ -92,18 +92,22 @@ Layer_Composite::accelerated_render(Context context,Surface *surface,int quality 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(this)); // Set up a surface target @@ -136,8 +140,9 @@ Layer_Composite::get_full_bounding_rect(Context context)const 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")) ); @@ -200,9 +205,12 @@ Layer_Composite::set_param(const String & param, const ValueBase &value) 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(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); } diff --git a/synfig-core/src/synfig/layer_composite.h b/synfig-core/src/synfig/layer_composite.h index cb9497d..458bae7 100644 --- a/synfig-core/src/synfig/layer_composite.h +++ b/synfig-core/src/synfig/layer_composite.h @@ -48,13 +48,13 @@ class Layer_NoDeform {}; 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 @@ -64,32 +64,37 @@ protected: 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 diff --git a/synfig-core/src/synfig/layer_pastecanvas.cpp b/synfig-core/src/synfig/layer_pastecanvas.cpp index c79c8f0..cd61506 100644 --- a/synfig-core/src/synfig/layer_pastecanvas.cpp +++ b/synfig-core/src/synfig/layer_pastecanvas.cpp @@ -274,13 +274,10 @@ Layer_PasteCanvas::update_renddesc() 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 diff --git a/synfig-core/src/synfig/layer_pastecanvas.h b/synfig-core/src/synfig/layer_pastecanvas.h index 2d4714c..01bf40f 100644 --- a/synfig-core/src/synfig/layer_pastecanvas.h +++ b/synfig-core/src/synfig/layer_pastecanvas.h @@ -44,32 +44,36 @@ /* === 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 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 @@ -104,7 +108,7 @@ private: */ private: - + //! Signal used when the canvas parameter has changed. \see layertreestore.cpp sigc::signal signal_subcanvas_changed_; /* @@ -112,48 +116,66 @@ private: */ public: - + //! Wrapper for the subcanvas changed signal sigc::signal& 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 get_sub_canvas()const { return canvas; } + //! Sets the canvas parameter. + //! \see get_sub_canvas() void set_sub_canvas(etl::handle 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 diff --git a/synfig-core/src/synfig/loadcanvas.cpp b/synfig-core/src/synfig/loadcanvas.cpp index 63f98c1..08a0f06 100644 --- a/synfig-core/src/synfig/loadcanvas.cpp +++ b/synfig-core/src/synfig/loadcanvas.cpp @@ -44,7 +44,6 @@ #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" diff --git a/synfig-core/src/synfig/loadcanvas.h b/synfig-core/src/synfig/loadcanvas.h index 888e1d7..b347850 100644 --- a/synfig-core/src/synfig/loadcanvas.h +++ b/synfig-core/src/synfig/loadcanvas.h @@ -1,6 +1,6 @@ /* === S Y N F I G ========================================================= */ /*! \file loadcanvas.h -** \brief writeme +** \brief Implementation for the Synfig Canvas Loader (canvas file parser) ** ** $Id$ ** @@ -52,7 +52,8 @@ namespace xmlpp { class Node; class Element; }; namespace synfig { /*! \class CanvasParser -** \todo writeme +** \brief Class that handles xmlpp elements from a sif file and converts +* them into Synfig objects */ class CanvasParser { @@ -61,22 +62,23 @@ 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_; /* @@ -98,7 +100,7 @@ public: 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 @@ -113,77 +115,110 @@ public: //! 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 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 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 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 parse_animated(xmlpp::Element *node,Canvas::Handle canvas); - etl::handle parse_subtract(xmlpp::Element *node,Canvas::Handle canvas); + //! Linkable ValueNode Parsing Function etl::handle parse_linkable_value_node(xmlpp::Element *node,Canvas::Handle canvas); + //! Dynamic List Parsnig Function etl::handle 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 >& get_open_canvas_map(); }; // END of namespace synfig diff --git a/synfig-core/src/synfig/main.cpp b/synfig-core/src/synfig/main.cpp index 9e0a56a..31c9afe 100644 --- a/synfig-core/src/synfig/main.cpp +++ b/synfig-core/src/synfig/main.cpp @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -//#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/synfig/module.cpp b/synfig-core/src/synfig/module.cpp index 5d64003..13523b0 100644 --- a/synfig-core/src/synfig/module.cpp +++ b/synfig-core/src/synfig/module.cpp @@ -22,8 +22,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/synfig/module.h b/synfig-core/src/synfig/module.h index 29455e3..19f0c3c 100644 --- a/synfig-core/src/synfig/module.h +++ b/synfig-core/src/synfig/module.h @@ -1,6 +1,6 @@ /* === S Y N F I G ========================================================= */ /*! \file synfig/module.h -** \brief writeme +** \brief Base class for all libraries modules ** ** $Id$ ** @@ -91,6 +91,12 @@ #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, \ @@ -100,6 +106,7 @@ 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, \ @@ -132,8 +139,10 @@ //! 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 @@ -142,6 +151,7 @@ //! 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(&class::create); \ book[name].check_type=&class::check_type; \ @@ -176,21 +186,30 @@ public: typedef etl::handle 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 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 " "; } diff --git a/synfig-core/src/synfig/node.cpp b/synfig-core/src/synfig/node.cpp index 6524109..182483c 100644 --- a/synfig-core/src/synfig/node.cpp +++ b/synfig-core/src/synfig/node.cpp @@ -62,21 +62,21 @@ using namespace synfig; #define BE_FRUGAL_WITH_GUIDS 1 #ifndef __sys_clock -#ifndef _WIN32 -# include -# define __sys_clock ::clock -#else -# ifdef __GNUG__ -# include -# 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 + # define __sys_clock ::clock + #else + # ifdef __GNUG__ + # include + # 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 ======================================================= */ @@ -86,6 +86,7 @@ typedef HASH_MAP_CLASS GlobalNodeMap; typedef map 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() @@ -127,15 +128,20 @@ TimePoint::c_str()const 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) @@ -145,29 +151,21 @@ TimePoint::absorb(const TimePoint& x) 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(*iter).absorb(x); return iter; } + //! Else, insert it at the first of the set return std::set::insert(x).first; } - - - - - - - - - - - - - Node::Node(): guid_(0), bchanged(true), diff --git a/synfig-core/src/synfig/node.h b/synfig-core/src/synfig/node.h index ca5af34..fd91cf2 100644 --- a/synfig-core/src/synfig/node.h +++ b/synfig-core/src/synfig/node.h @@ -1,6 +1,9 @@ /* === 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$ ** @@ -49,6 +52,11 @@ 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; @@ -78,6 +86,9 @@ public: 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 @@ -129,7 +140,7 @@ public: private: - //! \writeme + //! \ The GUID of the node GUID guid_; //! cached time values for all the children @@ -138,17 +149,20 @@ private: //! \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 parent_set; @@ -158,13 +172,14 @@ public: private: + //! Node changed signal sigc::signal signal_changed_; - //! GUID Changed + //! GUID changed signal /*! \note The second parameter is the *OLD* guid! */ sigc::signal signal_guid_changed_; - //! Deleted + //! Node deleted signal sigc::signal signal_deleted_; /* @@ -204,22 +219,28 @@ public: 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: @@ -231,17 +252,26 @@ 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 etl::handle guid_cast(const synfig::GUID& guid) { diff --git a/synfig-core/src/synfig/render.cpp b/synfig-core/src/synfig/render.cpp index af58a0e..fffdd6f 100644 --- a/synfig-core/src/synfig/render.cpp +++ b/synfig-core/src/synfig/render.cpp @@ -22,8 +22,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/synfig/savecanvas.cpp b/synfig-core/src/synfig/savecanvas.cpp index a2ae0d9..7682195 100644 --- a/synfig-core/src/synfig/savecanvas.cpp +++ b/synfig-core/src/synfig/savecanvas.cpp @@ -37,15 +37,10 @@ #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" @@ -104,10 +99,9 @@ xmlpp::Element* encode_real(xmlpp::Element* root,Real v) 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; } @@ -220,10 +214,7 @@ xmlpp::Element* encode_value(xmlpp::Element* root,const ValueBase &data,Canvas:: 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: @@ -270,10 +261,8 @@ xmlpp::Element* encode_animated(xmlpp::Element* root,ValueNode_Animated::ConstHa 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 { @@ -345,44 +334,6 @@ xmlpp::Element* encode_animated(xmlpp::Element* root,ValueNode_Animated::ConstHa 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 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); @@ -480,9 +431,6 @@ xmlpp::Element* encode_linkable_value_node(xmlpp::Element* root,LinkableValueNod 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; } @@ -512,9 +460,6 @@ xmlpp::Element* encode_value_node(xmlpp::Element* root,ValueNode::ConstHandle va 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)) @@ -697,7 +642,11 @@ xmlpp::Element* encode_canvas(xmlpp::Element* root,Canvas::ConstHandle canvas) } // Output the 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"); diff --git a/synfig-core/src/synfig/savecanvas.h b/synfig-core/src/synfig/savecanvas.h index 93a3486..6eb3f59 100644 --- a/synfig-core/src/synfig/savecanvas.h +++ b/synfig-core/src/synfig/savecanvas.h @@ -1,6 +1,6 @@ /* === S Y N F I G ========================================================= */ /*! \file savecanvas.h -** \brief writeme +** \brief Implementation for the Synfig Save Canvas to file ** ** $Id$ ** @@ -47,6 +47,7 @@ namespace synfig { 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); diff --git a/synfig-core/src/synfig/surface.cpp b/synfig-core/src/synfig/surface.cpp index 91e1663..471b85a 100644 --- a/synfig-core/src/synfig/surface.cpp +++ b/synfig-core/src/synfig/surface.cpp @@ -24,8 +24,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef USING_PCH # include "pch.h" #else diff --git a/synfig-core/src/synfig/target.cpp b/synfig-core/src/synfig/target.cpp index b6aa1c4..dbeb37e 100644 --- a/synfig-core/src/synfig/target.cpp +++ b/synfig-core/src/synfig/target.cpp @@ -23,8 +23,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - #ifdef HAVE_CONFIG_H # include #endif @@ -52,9 +50,8 @@ Target::subsys_init() { 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 = diff --git a/synfig-core/src/synfig/target.h b/synfig-core/src/synfig/target.h index 5fcaaeb..39d07d7 100644 --- a/synfig-core/src/synfig/target.h +++ b/synfig-core/src/synfig/target.h @@ -32,27 +32,25 @@ #include #include "string_decl.h" #include -//#include #include #include #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 @@ -61,7 +59,9 @@ //! 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) \ @@ -80,8 +80,14 @@ class ProgressCallback; 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 { @@ -113,7 +119,7 @@ public: 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); @@ -127,6 +133,7 @@ public: //! Book of types of targets indexed by the name of the Target. typedef std::map Book; + //! Book of types of targets indexed by the file extension typedef std::map ExtBook; //! Target Book, indexed by the target's name @@ -138,61 +145,71 @@ public: 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; + //! 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 c); - + //! Gets the target canvas. const etl::handle &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. @@ -204,5 +221,4 @@ public: /* === E N D =============================================================== */ -#include "canvas.h" #endif diff --git a/synfig-core/src/synfig/types.h b/synfig-core/src/synfig/types.h index 6c3b7ea..866e388 100644 --- a/synfig-core/src/synfig/types.h +++ b/synfig-core/src/synfig/types.h @@ -28,11 +28,7 @@ /* === H E A D E R S ======================================================= */ #include - -#ifndef SYNFIG_NO_ANGLE #include "angle.h" -#endif - #include "time.h" #include "vector.h" diff --git a/synfig-core/src/synfig/value.h b/synfig-core/src/synfig/value.h index 7079dba..eff65bb 100644 --- a/synfig-core/src/synfig/value.h +++ b/synfig-core/src/synfig/value.h @@ -28,17 +28,14 @@ /* === 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 #include #include #include #include "general.h" -//#include "gradient.h" #include "blinepoint.h" #include "exception.h" @@ -46,9 +43,6 @@ #include #endif -#ifndef SYNFIG_NO_ANGLE -#include "angle.h" -#endif #include @@ -349,10 +343,8 @@ public: 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 operator std::list()const diff --git a/synfig-core/src/synfig/valuenode.cpp b/synfig-core/src/synfig/valuenode.cpp index cae9692..8f3cc9a 100644 --- a/synfig-core/src/synfig/valuenode.cpp +++ b/synfig-core/src/synfig/valuenode.cpp @@ -24,10 +24,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_NO_ANGLE - -//#define HAS_HASH_MAP 1 - #ifdef USING_PCH # include "pch.h" #else @@ -202,35 +198,6 @@ bool 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; } diff --git a/synfig-core/src/synfig/valuenode.h b/synfig-core/src/synfig/valuenode.h index a7a8f30..379b3f0 100644 --- a/synfig-core/src/synfig/valuenode.h +++ b/synfig-core/src/synfig/valuenode.h @@ -38,10 +38,7 @@ #include #include #include "guid.h" - -#ifndef SYNFIG_NO_ANGLE #include -#endif #include "node.h" @@ -82,7 +79,7 @@ class LinkableValueNode; class Layer; /*! \class ValueNode -** \todo writeme +** \brief Base class for all Value Nodes */ class ValueNode : public synfig::Node { @@ -103,9 +100,9 @@ public: typedef etl::rhandle 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(); /* @@ -113,9 +110,15 @@ public: */ 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. String name; + //! The canvas this Value Node belongs to etl::loose_handle canvas_; + //! The root canvas this Value Node belongs to etl::loose_handle root_canvas_; /* @@ -206,10 +209,10 @@ public: 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 @@ -221,15 +224,20 @@ public: //! Returns a handle to the parent canvas, if it has one. etl::loose_handle get_root_canvas()const { return root_canvas_; } - //! \writeme + //! Sets the parent canvas for the Value Node void set_parent_canvas(etl::loose_handle x); - //! \writeme + //! Sets the root canvas parent for the Value Node void set_root_canvas(etl::loose_handle x); - //! \writeme + //! Returns the relative ID of a Node when accessed form the \x Canvas String get_relative_id(etl::loose_handle 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 x); protected: @@ -240,7 +248,12 @@ 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 { @@ -272,7 +285,12 @@ protected: /*! \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 { @@ -289,11 +307,15 @@ public: //! 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 @@ -305,9 +327,9 @@ public: }; //! 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 */ @@ -315,8 +337,13 @@ public: 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: @@ -324,47 +351,63 @@ 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 { diff --git a/synfig-core/src/synfig/valuenode_animated.cpp b/synfig-core/src/synfig/valuenode_animated.cpp index 3e7e444..e8fb7a6 100644 --- a/synfig-core/src/synfig/valuenode_animated.cpp +++ b/synfig-core/src/synfig/valuenode_animated.cpp @@ -62,24 +62,7 @@ using namespace synfig; /* === M A C R O S ========================================================= */ -// Fast binary search implementation -/* -template inline I -binary_find(I begin, I end, const T& value) -{ - I iter(begin+(end-begin)/2); - - while(end-begin>1 && !(*iter==value)) - { - ((*iter String tangent_info(T a, T b, T v) { return "..."; @@ -148,10 +131,6 @@ struct magnitude : public std::unary_function } }; - - - - template struct is_angle_type { @@ -770,7 +749,10 @@ ValueNode_Animated::find(const Time& begin,const Time& end,std::vectorget_time()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(distget_time()-time)) - closest=iter; - } - */ - if(has_prev && !prev->is_static()) waypoint.set_value_node(prev->get_value_node()); if(has_next && !next->is_static()) @@ -865,11 +827,6 @@ ValueNode_Animated::new_waypoint_at_time(const Time& time)const 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); @@ -894,13 +851,6 @@ ValueNode_Animated::WaypointList::const_iterator ValueNode_Animated::find(const UniqueID &x)const { return const_cast(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 @@ -918,14 +868,6 @@ ValueNode_Animated::WaypointList::const_iterator ValueNode_Animated::find(const Time &x)const { return const_cast(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 @@ -949,20 +891,6 @@ ValueNode_Animated::WaypointList::const_iterator ValueNode_Animated::find_next(const Time &x)const { return const_cast(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 @@ -985,18 +913,6 @@ ValueNode_Animated::WaypointList::const_iterator ValueNode_Animated::find_prev(const Time &x)const { return const_cast(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()get_time()+Time::epsilon() const_findresult; protected: + //! List of Waypoints. \see waypoint.h WaypointList waypoint_list_; public: @@ -59,52 +71,80 @@ 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& 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; }; diff --git a/synfig-core/src/synfig/waypoint.cpp b/synfig-core/src/synfig/waypoint.cpp index 1befa6f..e716dc3 100644 --- a/synfig-core/src/synfig/waypoint.cpp +++ b/synfig-core/src/synfig/waypoint.cpp @@ -59,6 +59,7 @@ Waypoint::Waypoint(ValueBase value, Time time): bias(0), time_tension(0.0f) { + //!Writeme if(value.get_type()==ValueBase::TYPE_ANGLE) after=before=INTERPOLATION_LINEAR; } @@ -92,6 +93,8 @@ Waypoint::Waypoint(): 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; @@ -101,6 +104,8 @@ Waypoint::set_value(const ValueBase &x) void Waypoint::set_value_node(const etl::handle &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; diff --git a/synfig-core/src/synfig/waypoint.h b/synfig-core/src/synfig/waypoint.h index d94cf21..01b465d 100644 --- a/synfig-core/src/synfig/waypoint.h +++ b/synfig-core/src/synfig/waypoint.h @@ -1,6 +1,6 @@ /* === S Y N F I G ========================================================= */ /*! \file waypoint.h -** \brief Template Header +** \brief Waypoint class header. ** ** $Id$ ** @@ -32,7 +32,6 @@ #include "time.h" #include "real.h" #include "value.h" -//#include "valuenode.h" #include "uniqueid.h" #include #include "guid.h" @@ -51,7 +50,12 @@ class GUID; /*! \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 { @@ -63,6 +67,12 @@ public: 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; @@ -91,27 +101,36 @@ public: 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) @@ -122,6 +141,7 @@ public: FLAG_MACRO(temporal_tension) #undef FLAG_MACRO + //! Converts the Model in trivial: None of its values will be applied void reset() { priority_flag=false; @@ -133,6 +153,9 @@ public: 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 !( @@ -160,24 +183,28 @@ public: private: + //! Writeme int priority_; + //! Usually Animated Value Nodes are parents of waypoints + //! \see class ValueNode_Animated etl::loose_handle parent_; - + //! The two Interpolations before and after Interpolation before, after; - + //! The value node that is hold by the waypoint etl::rhandle 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; /* @@ -186,9 +213,13 @@ private: public: + //! Constructor for constant Waypoint Waypoint(ValueBase value, Time time); + //! Constructor for animated Waypoint + //! Is is called anytime? Waypoint(etl::handle value_node, Time time); + //! Default constructor. Leaves unset the Value Node Waypoint(); /* @@ -197,64 +228,92 @@ public: 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 &get_value_node()const { return value_node; } + //! Sets the value node by handle void set_value_node(const etl::handle &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 &get_parent_value_node()const { return parent_; } + //! Sets parent Value Node void set_parent_value_node(const etl::loose_handle &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(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