Module: synfig/synfig
Branch: genete_blinepoint_peak
Commit: f939a6cec99ae4cacf1ddc02b3986ac97b4fa204
URL:
http://synfig.git.sourceforge.net/git/gitweb.cgi?p=synfig/synfig;a=commit;h=f939a6cec99ae4cacf1ddc02b3986ac97b4fa204
Author: Carlos Lopez <[email protected]>
Date: Wed Sep 15 21:22:20 2010 +0200
Add new action: Make Vertex Peak to make both tangents (0,0)
---
synfig-studio/src/synfigapp/Makefile.am | 2 +
synfig-studio/src/synfigapp/action.cpp | 2 +
.../src/synfigapp/actions/blinepointpeak.cpp | 173 ++++++++++++++++++++
.../src/synfigapp/actions/blinepointpeak.h | 74 +++++++++
4 files changed, 251 insertions(+), 0 deletions(-)
diff --git a/synfig-studio/src/synfigapp/Makefile.am
b/synfig-studio/src/synfigapp/Makefile.am
index 40d466c..4a8c8da 100644
--- a/synfig-studio/src/synfigapp/Makefile.am
+++ b/synfig-studio/src/synfigapp/Makefile.am
@@ -197,6 +197,7 @@ GROUP_ACTION_CC = \
OTHER_ACTION_HH = \
actions/blinepointtangentmerge.h \
actions/blinepointtangentsplit.h \
+ actions/blinepointpeak.h \
actions/colorset.h \
actions/editmodeset.h \
actions/gradientset.h
@@ -204,6 +205,7 @@ OTHER_ACTION_HH = \
OTHER_ACTION_CC = \
actions/blinepointtangentmerge.cpp \
actions/blinepointtangentsplit.cpp \
+ actions/blinepointpeak.cpp \
actions/colorset.cpp \
actions/editmodeset.cpp \
actions/gradientset.cpp
diff --git a/synfig-studio/src/synfigapp/action.cpp
b/synfig-studio/src/synfigapp/action.cpp
index 4b89c3e..1626c03 100644
--- a/synfig-studio/src/synfigapp/action.cpp
+++ b/synfig-studio/src/synfigapp/action.cpp
@@ -112,6 +112,7 @@
#include "actions/blinepointtangentmerge.h"
#include "actions/blinepointtangentsplit.h"
+#include "actions/blinepointpeak.h"
#include "actions/gradientset.h"
#include "actions/colorset.h"
@@ -233,6 +234,7 @@ Action::Main::Main()
ADD_ACTION(Action::BLinePointTangentMerge);
ADD_ACTION(Action::BLinePointTangentSplit);
+ ADD_ACTION(Action::BLinePointPeak);
ADD_ACTION(Action::GradientSet);
ADD_ACTION(Action::ColorSetFromOC);
diff --git a/synfig-studio/src/synfigapp/actions/blinepointpeak.cpp
b/synfig-studio/src/synfigapp/actions/blinepointpeak.cpp
new file mode 100644
index 0000000..17d7ed3
--- /dev/null
+++ b/synfig-studio/src/synfigapp/actions/blinepointpeak.cpp
@@ -0,0 +1,173 @@
+/* === S Y N F I G ========================================================= */
+/*! \file blinepointpeak.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2010 Carlos López
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "blinepointpeak.h"
+#include "valuedescset.h"
+
+#include <synfigapp/canvasinterface.h>
+
+#include <synfigapp/general.h>
+
+#endif
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace synfigapp;
+using namespace Action;
+
+/* === M A C R O S ========================================================= */
+
+ACTION_INIT_NO_GET_LOCAL_NAME(Action::BLinePointPeak);
+ACTION_SET_NAME(Action::BLinePointPeak,"BLinePointPeak");
+ACTION_SET_LOCAL_NAME(Action::BLinePointPeak,N_("Make Peak Vertex"));
+ACTION_SET_TASK(Action::BLinePointPeak,"peak");
+ACTION_SET_CATEGORY(Action::BLinePointPeak,Action::CATEGORY_VALUENODE);
+ACTION_SET_PRIORITY(Action::BLinePointPeak,0);
+ACTION_SET_VERSION(Action::BLinePointPeak,"0.0");
+ACTION_SET_CVS_ID(Action::BLinePointPeak,"$Id$");
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Action::BLinePointPeak::BLinePointPeak()
+{
+ set_dirty(true);
+}
+
+synfig::String
+Action::BLinePointPeak::get_local_name()const
+{
+ return strprintf(_("Make Vertex Peak of '%s'"),
((ValueNode::Handle)(value_node))->get_description().c_str());
+}
+
+Action::ParamVocab
+Action::BLinePointPeak::get_param_vocab()
+{
+ ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
+
+ ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
+ .set_local_name(_("ValueNode of BLinePoint"))
+ );
+
+ ret.push_back(ParamDesc("time",Param::TYPE_TIME)
+ .set_local_name(_("Time"))
+ );
+
+ return ret;
+}
+
+bool
+Action::BLinePointPeak::is_candidate(const ParamList &x)
+{
+ if(candidate_check(get_param_vocab(),x))
+ {
+ ValueNode_Composite::Handle value_node;
+
value_node=ValueNode_Composite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node());
+ if(!value_node ||
value_node->get_type()!=ValueBase::TYPE_BLINEPOINT)
+ return false;
+ return true;
+ }
+ return false;
+}
+
+bool
+Action::BLinePointPeak::set_param(const synfig::String& name, const
Action::Param ¶m)
+{
+ if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
+ {
+ value_node=value_node.cast_dynamic(param.get_value_node());
+
+ return (bool)(value_node);
+ }
+ if(name=="time" && param.get_type()==Param::TYPE_TIME)
+ {
+ time=param.get_time();
+
+ return true;
+ }
+
+ return Action::CanvasSpecific::set_param(name,param);
+}
+
+bool
+Action::BLinePointPeak::is_ready()const
+{
+ if(!value_node || time==(Time::begin()-1))
+ return false;
+ return Action::CanvasSpecific::is_ready();
+}
+
+void
+Action::BLinePointPeak::prepare()
+{
+ clear();
+
+ Action::Handle action;
+
+ action=Action::create("ValueDescSet");
+ if(!action)
+ throw Error(_("Couldn't find action \"ValueDescSet\""));
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+
action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("t1")));
+ action->set_param("time",time);
+ action->set_param("new_value",synfig::ValueBase(Vector(0,0)));
+
+ assert(action->is_ready());
+ if(!action->is_ready())
+ throw Error(Error::TYPE_NOTREADY);
+
+ add_action(action);
+
+ Action::Handle action1;
+
+ action1=Action::create("ValueDescSet");
+ if(!action1)
+ throw Error(_("Couldn't find action \"ValueDescSet\""));
+
+ action1->set_param("canvas",get_canvas());
+ action1->set_param("canvas_interface",get_canvas_interface());
+
action1->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("t2")));
+ action1->set_param("time",time);
+ action1->set_param("new_value",synfig::ValueBase(Vector(0,0)));
+
+ assert(action1->is_ready());
+ if(!action1->is_ready())
+ throw Error(Error::TYPE_NOTREADY);
+
+ add_action(action1);
+}
diff --git a/synfig-studio/src/synfigapp/actions/blinepointpeak.h
b/synfig-studio/src/synfigapp/actions/blinepointpeak.h
new file mode 100644
index 0000000..c1649e6
--- /dev/null
+++ b/synfig-studio/src/synfigapp/actions/blinepointpeak.h
@@ -0,0 +1,74 @@
+/* === S Y N F I G ========================================================= */
+/*! \file blinepointpeak.h
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2010 Carlos López
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_APP_ACTION_BLINEPOINTPEAK_H
+#define __SYNFIG_APP_ACTION_BLINEPOINTPEAK_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfigapp/action.h>
+#include <synfigapp/value_desc.h>
+#include <synfig/blinepoint.h>
+#include <synfig/valuenode_composite.h>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfigapp {
+
+namespace Action {
+
+class BLinePointPeak :
+ public Super
+{
+private:
+
+ synfig::ValueNode_Composite::Handle value_node;
+ synfig::Time time;
+
+public:
+
+ BLinePointPeak();
+
+ static ParamVocab get_param_vocab();
+ static bool is_candidate(const ParamList &x);
+
+ virtual bool set_param(const synfig::String& name, const Param &);
+ virtual bool is_ready()const;
+
+ virtual void prepare();
+
+ ACTION_MODULE_EXT
+};
+
+}; // END of namespace action
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl