1 /* === S I N F G =========================================================== */
2 /*! \file activepointsetoff.cpp
3 ** \brief Template File
5 ** $Id: activepointsetoff.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 "activepointsetoff.h"
32 #include "activepointsetsmart.h"
33 #include "valuenodelinkconnect.h"
34 #include "valuenodereplace.h"
36 #include "activepointset.h"
37 #include "activepointadd.h"
39 #include "valuedescconnect.h"
40 #include <sinfgapp/canvasinterface.h>
46 using namespace sinfg;
47 using namespace sinfgapp;
48 using namespace Action;
50 /* === M A C R O S ========================================================= */
52 ACTION_INIT(Action::ActivepointSetOff);
53 ACTION_SET_NAME(Action::ActivepointSetOff,"activepoint_set_off");
54 ACTION_SET_LOCAL_NAME(Action::ActivepointSetOff,_("Mark Activepoint as \"Off\""));
55 ACTION_SET_TASK(Action::ActivepointSetOff,"set_off");
56 ACTION_SET_CATEGORY(Action::ActivepointSetOff,Action::CATEGORY_ACTIVEPOINT|Action::CATEGORY_VALUEDESC);
57 ACTION_SET_PRIORITY(Action::ActivepointSetOff,-9);
58 ACTION_SET_VERSION(Action::ActivepointSetOff,"0.0");
59 ACTION_SET_CVS_ID(Action::ActivepointSetOff,"$Id: activepointsetoff.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
61 /* === G L O B A L S ======================================================= */
63 /* === P R O C E D U R E S ================================================= */
65 /* === M E T H O D S ======================================================= */
67 Action::ActivepointSetOff::ActivepointSetOff()
69 activepoint.set_time(Time::begin()-1);
75 Action::ActivepointSetOff::get_param_vocab()
77 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
79 ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
80 .set_local_name(_("ValueDesc"))
83 ret.push_back(ParamDesc("activepoint",Param::TYPE_ACTIVEPOINT)
84 .set_local_name(_("Activepoint"))
88 ret.push_back(ParamDesc("time",Param::TYPE_TIME)
89 .set_local_name(_("Time"))
97 Action::ActivepointSetOff::is_canidate(const ParamList &x)
99 if(canidate_check(get_param_vocab(),x))
101 ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
102 if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))
105 // We are only a canidate if this canvas is animated.
106 Canvas::Handle canvas(x.find("canvas")->second.get_canvas());
107 if(canvas->rend_desc().get_time_start()==canvas->rend_desc().get_time_end())
110 // We need either a activepoint or a time.
111 if(x.count("activepoint") || x.count("time"))
118 Action::ActivepointSetOff::set_param(const sinfg::String& name, const Action::Param ¶m)
120 if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
122 value_desc=param.get_value_desc();
124 if(!value_desc.parent_is_value_node())
127 value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
132 index=value_desc.get_index();
139 if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT && !time_set)
141 activepoint=param.get_activepoint();
145 if(name=="time" && param.get_type()==Param::TYPE_TIME && activepoint.get_time()==Time::begin()-1)
147 activepoint.set_time(param.get_time());
156 return Action::CanvasSpecific::set_param(name,param);
160 Action::ActivepointSetOff::is_ready()const
163 sinfg::error("Missing value_node");
165 if(activepoint.get_time()==(Time::begin()-1))
166 sinfg::error("Missing activepoint");
168 if(!value_node || activepoint.get_time()==(Time::begin()-1))
170 return Action::CanvasSpecific::is_ready();
173 // This function is called if a time is specified, but not
174 // a activepoint. In this case, we need to calculate the value
175 // of the activepoint
177 Action::ActivepointSetOff::calc_activepoint()
179 const Time time(activepoint.get_time());
181 try { activepoint=*value_node->list[index].find(time); }
184 activepoint.set_time(time);
185 activepoint.set_state(value_node->list[index].status_at_time(time));
186 activepoint.set_priority(0);
191 Action::ActivepointSetOff::prepare()
195 // Turn the activepoint off
196 activepoint.set_state(false);
198 Action::Handle action(ActivepointSetSmart::create());
200 action->set_param("edit_mode",get_edit_mode());
201 action->set_param("canvas",get_canvas());
202 action->set_param("canvas_interface",get_canvas_interface());
203 action->set_param("value_desc",value_desc);
204 action->set_param("activepoint",activepoint);
206 assert(action->is_ready());
207 if(!action->is_ready())
208 throw Error(Error::TYPE_NOTREADY);
210 add_action_front(action);