1 /* === S I N F G =========================================================== */
2 /*! \file activepointremove.cpp
3 ** \brief Template File
5 ** $Id: activepointremove.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 "activepointremove.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::ActivepointRemove);
45 ACTION_SET_NAME(Action::ActivepointRemove,"activepoint_remove");
46 ACTION_SET_LOCAL_NAME(Action::ActivepointRemove,"Remove Activepoint");
47 ACTION_SET_TASK(Action::ActivepointRemove,"remove");
48 ACTION_SET_CATEGORY(Action::ActivepointRemove,Action::CATEGORY_ACTIVEPOINT);
49 ACTION_SET_PRIORITY(Action::ActivepointRemove,0);
50 ACTION_SET_VERSION(Action::ActivepointRemove,"0.0");
51 ACTION_SET_CVS_ID(Action::ActivepointRemove,"$Id: activepointremove.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::ActivepointRemove::ActivepointRemove()
61 activepoint.set_time(Time::begin()-1);
66 Action::ActivepointRemove::get_param_vocab()
68 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
70 ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
71 .set_local_name(_("ValueDesc"))
74 ret.push_back(ParamDesc("activepoint",Param::TYPE_ACTIVEPOINT)
75 .set_local_name(_("Activepoint"))
76 .set_desc(_("Activepoint to be changed"))
83 Action::ActivepointRemove::is_canidate(const ParamList &x)
85 if(canidate_check(get_param_vocab(),x))
87 ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
88 if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))
97 Action::ActivepointRemove::set_param(const sinfg::String& name, const Action::Param ¶m)
99 if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
101 ValueDesc value_desc(param.get_value_desc());
103 if(!value_desc.parent_is_value_node())
106 value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
111 index=value_desc.get_index();
115 if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT)
117 activepoint=param.get_activepoint();
122 return Action::CanvasSpecific::set_param(name,param);
126 Action::ActivepointRemove::is_ready()const
128 if(!value_node || activepoint.get_time()==(Time::begin()-1))
130 return Action::CanvasSpecific::is_ready();
134 Action::ActivepointRemove::perform()
136 ValueNode_DynamicList::ListEntry::ActivepointList::iterator iter;
138 try { iter=value_node->list[index].find(activepoint); }
139 catch(sinfg::Exception::NotFound)
141 throw Error(_("Unable to find activepoint"));
144 value_node->list[index].erase(activepoint);
145 value_node->changed();
148 // Signal that a layer has been inserted
149 if(get_canvas_interface())
151 get_canvas_interface()->signal_value_node_changed()(value_node);
153 else sinfg::warning("CanvasInterface not set on action");
158 Action::ActivepointRemove::undo()
160 try { value_node->list[index].find(activepoint.get_time()); throw Error(_("A Activepoint already exists at this point in time"));}
161 catch(sinfg::Exception::NotFound) { }
163 try { if(value_node->list[index].find(activepoint)!=value_node->list[index].timing_info.end()) throw Error(_("This activepoint is already in the ValueNode"));}
164 catch(sinfg::Exception::NotFound) { }
166 value_node->list[index].add(activepoint);
167 value_node->changed();
169 // Signal that a layer has been inserted
170 if(get_canvas_interface())
172 get_canvas_interface()->signal_value_node_changed()(value_node);
174 else sinfg::warning("CanvasInterface not set on action");