1 /* === S I N F G =========================================================== */
2 /*! \file acitvepointadd.cpp
3 ** \brief Template File
5 ** $Id: activepointadd.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 "activepointadd.h"
32 #include <sinfgapp/canvasinterface.h>
38 using namespace sinfg;
39 using namespace sinfgapp;
40 using namespace Action;
42 /* === M A C R O S ========================================================= */
44 ACTION_INIT(Action::ActivepointAdd);
45 ACTION_SET_NAME(Action::ActivepointAdd,"activepoint_add");
46 ACTION_SET_LOCAL_NAME(Action::ActivepointAdd,"Add Activepoint");
47 ACTION_SET_TASK(Action::ActivepointAdd,"add");
48 ACTION_SET_CATEGORY(Action::ActivepointAdd,Action::CATEGORY_ACTIVEPOINT);
49 ACTION_SET_PRIORITY(Action::ActivepointAdd,0);
50 ACTION_SET_VERSION(Action::ActivepointAdd,"0.0");
51 ACTION_SET_CVS_ID(Action::ActivepointAdd,"$Id: activepointadd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
53 /* === G L O B A L S ======================================================= */
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 Action::ActivepointAdd::ActivepointAdd()
61 activepoint.set_time(Time::begin()-1);
67 Action::ActivepointAdd::get_param_vocab()
69 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
71 ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
72 .set_local_name(_("ValueDesc"))
75 ret.push_back(ParamDesc("activepoint",Param::TYPE_ACTIVEPOINT)
76 .set_local_name(_("New Activepoint"))
77 .set_desc(_("Activepoint to be added"))
81 ret.push_back(ParamDesc("time",Param::TYPE_TIME)
82 .set_local_name(_("Time"))
83 .set_desc(_("Time where activepoint is to be added"))
91 Action::ActivepointAdd::is_canidate(const ParamList &x)
93 if(canidate_check(get_param_vocab(),x))
95 ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
96 if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))
99 // We need either a activepoint or a time.
100 if(x.count("activepoint") || x.count("time"))
107 Action::ActivepointAdd::set_param(const sinfg::String& name, const Action::Param ¶m)
109 if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
111 ValueDesc value_desc(param.get_value_desc());
113 if(!value_desc.parent_is_value_node())
116 value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
121 index=value_desc.get_index();
128 if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT && !time_set)
130 activepoint=param.get_activepoint();
134 if(name=="time" && param.get_type()==Param::TYPE_TIME && activepoint.get_time()==Time::begin()-1)
136 activepoint.set_time(param.get_time());
145 return Action::CanvasSpecific::set_param(name,param);
149 Action::ActivepointAdd::is_ready()const
151 if(!value_node || activepoint.get_time()==(Time::begin()-1))
153 return Action::CanvasSpecific::is_ready();
156 // This function is called if a time is specified, but not
157 // a activepoint. In this case, we need to calculate the value
158 // of the activepoint
160 Action::ActivepointAdd::calc_activepoint()
162 const Time time(activepoint.get_time());
163 activepoint.set_state(value_node->list[index].status_at_time(time));
164 activepoint.set_priority(0);
166 // In this case, nothing is really changing, so there will be
167 // no need to redraw the window
172 Action::ActivepointAdd::perform()
174 try { value_node->list[index].find(activepoint.get_time()); throw Error(_("A Activepoint already exists at this point in time"));}
175 catch(sinfg::Exception::NotFound) { }
177 try { if(value_node->list[index].find(activepoint)!=value_node->list[index].timing_info.end()) throw Error(_("This activepoint is already in the ValueNode"));}
178 catch(sinfg::Exception::NotFound) { }
180 value_node->list[index].add(activepoint);
181 value_node->changed();
183 /*if(get_canvas_interface())
185 get_canvas_interface()->signal_value_node_changed()(value_node);
187 else sinfg::warning("CanvasInterface not set on action");
192 Action::ActivepointAdd::undo()
194 value_node->list[index].erase(activepoint);
195 value_node->changed();
197 // Signal that a layer has been inserted
198 if(get_canvas_interface())
200 get_canvas_interface()->signal_value_node_changed()(value_node);
202 else sinfg::warning("CanvasInterface not set on action");