1 /* === S I N F G =========================================================== */
2 /*! \file blinepointtangentmerge.cpp
3 ** \brief Template File
5 ** $Id: blinepointtangentmerge.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "blinepointtangentmerge.h"
32 #include "valuedescset.h"
34 #include "activepointset.h"
35 #include "activepointadd.h"
37 #include "valuedescconnect.h"
38 #include <sinfgapp/canvasinterface.h>
44 using namespace sinfg;
45 using namespace sinfgapp;
46 using namespace Action;
48 /* === M A C R O S ========================================================= */
50 ACTION_INIT(Action::BLinePointTangentMerge);
51 ACTION_SET_NAME(Action::BLinePointTangentMerge,"bline_point_tangent_merge");
52 ACTION_SET_LOCAL_NAME(Action::BLinePointTangentMerge,_("Merge Tangents"));
53 ACTION_SET_TASK(Action::BLinePointTangentMerge,"merge");
54 ACTION_SET_CATEGORY(Action::BLinePointTangentMerge,Action::CATEGORY_VALUENODE);
55 ACTION_SET_PRIORITY(Action::BLinePointTangentMerge,0);
56 ACTION_SET_VERSION(Action::BLinePointTangentMerge,"0.0");
57 ACTION_SET_CVS_ID(Action::BLinePointTangentMerge,"$Id: blinepointtangentmerge.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
59 /* === G L O B A L S ======================================================= */
61 /* === P R O C E D U R E S ================================================= */
63 /* === M E T H O D S ======================================================= */
65 Action::BLinePointTangentMerge::BLinePointTangentMerge()
67 time=(Time::begin()-1);
72 Action::BLinePointTangentMerge::get_param_vocab()
74 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
76 ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
77 .set_local_name(_("ValueNode of BLinePoint"))
80 ret.push_back(ParamDesc("time",Param::TYPE_TIME)
81 .set_local_name(_("Time"))
88 Action::BLinePointTangentMerge::is_canidate(const ParamList &x)
90 if(canidate_check(get_param_vocab(),x))
92 ValueNode_Composite::Handle value_node;
93 value_node=ValueNode_Composite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node());
94 if(!value_node || value_node->get_type()!=ValueBase::TYPE_BLINEPOINT)
96 sinfg::Time time(x.find("time")->second.get_time());
97 if((*value_node->get_link("split"))(time).get(bool())==false)
105 Action::BLinePointTangentMerge::set_param(const sinfg::String& name, const Action::Param ¶m)
107 if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
109 value_node=value_node.cast_dynamic(param.get_value_node());
111 return (bool)(value_node);
113 if(name=="time" && param.get_type()==Param::TYPE_TIME)
115 time=param.get_time();
120 return Action::CanvasSpecific::set_param(name,param);
124 Action::BLinePointTangentMerge::is_ready()const
127 sinfg::error("Missing or bad value_node");
129 if(time==(Time::begin()-1))
130 sinfg::error("Missing time");
132 if(!value_node || time==(Time::begin()-1))
134 return Action::CanvasSpecific::is_ready();
138 Action::BLinePointTangentMerge::prepare()
142 Action::Handle action;
145 action=Action::create("value_desc_set");
147 throw Error(_("Couldn't find action \"value_desc_set\""));
149 action->set_param("canvas",get_canvas());
150 action->set_param("canvas_interface",get_canvas_interface());
151 action->set_param("value_desc",ValueDesc(value_node,3));
152 action->set_param("time",time);
153 action->set_param("new_value",sinfg::ValueBase(false));
155 assert(action->is_ready());
156 if(!action->is_ready())
157 throw Error(Error::TYPE_NOTREADY);
162 action=Action::create("value_desc_set");
164 throw Error(_("Couldn't find action \"value_desc_set\""));
166 action->set_param("canvas",get_canvas());
167 action->set_param("canvas_interface",get_canvas_interface());
168 action->set_param("value_desc",ValueDesc(value_node,5));
169 action->set_param("time",time);
170 action->set_param("new_value",(*value_node->get_link("t1"))(time));
172 assert(action->is_ready());
173 if(!action->is_ready())
174 throw Error(Error::TYPE_NOTREADY);