1 /* === S I N F G =========================================================== */
2 /*! \file timepointsdelete.cpp
3 ** \brief Delete the Time Points File
5 ** $Id: timepointsdelete.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2004 Adrian Bentley
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 "timepointsdelete.h"
32 #include <sinfg/layer_pastecanvas.h>
33 #include <sinfgapp/canvasinterface.h>
34 #include <sinfg/valuenode_dynamiclist.h>
35 #include <sinfg/valuenode_animated.h>
37 #include "activepointremove.h"
38 #include "waypointremove.h"
39 #include <sinfgapp/timegather.h>
47 using namespace sinfg;
48 using namespace sinfgapp;
49 using namespace Action;
51 /* === M A C R O S ========================================================= */
53 ACTION_INIT(Action::TimepointsDelete);
54 ACTION_SET_NAME(Action::TimepointsDelete,"timepoint_delete");
55 ACTION_SET_LOCAL_NAME(Action::TimepointsDelete,"Delete Time Points");
56 ACTION_SET_TASK(Action::TimepointsDelete,"delete");
57 ACTION_SET_CATEGORY(Action::TimepointsDelete,Action::CATEGORY_WAYPOINT|Action::CATEGORY_ACTIVEPOINT);
58 ACTION_SET_PRIORITY(Action::TimepointsDelete,0);
59 ACTION_SET_VERSION(Action::TimepointsDelete,"0.0");
60 ACTION_SET_CVS_ID(Action::TimepointsDelete,"$Id: timepointsdelete.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
62 /* === G L O B A L S ======================================================= */
64 /* === P R O C E D U R E S ================================================= */
66 /* === M E T H O D S ======================================================= */
68 Action::TimepointsDelete::TimepointsDelete()
74 Action::TimepointsDelete::get_param_vocab()
76 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
78 ret.push_back(ParamDesc("addlayer",Param::TYPE_VALUE)
79 .set_local_name(_("New Selected Layer"))
80 .set_desc(_("A layer to add to our selected list"))
81 .set_supports_multiple()
85 ret.push_back(ParamDesc("addcanvas",Param::TYPE_CANVAS)
86 .set_local_name(_("New Selected Canvas"))
87 .set_desc(_("A canvas to add to our selected list"))
88 .set_supports_multiple()
92 ret.push_back(ParamDesc("addvaluedesc",Param::TYPE_VALUEDESC)
93 .set_local_name(_("New Selected ValueBase"))
94 .set_desc(_("A valuenode's description to add to our selected list"))
95 .set_supports_multiple()
99 ret.push_back(ParamDesc("addtime",Param::TYPE_TIME)
100 .set_local_name(_("New Selected Time Point"))
101 .set_desc(_("A time point to add to our selected list"))
102 .set_supports_multiple()
109 Action::TimepointsDelete::is_canidate(const ParamList &x)
111 if(!canidate_check(get_param_vocab(),x))
114 if( x.find("addlayer") == x.end() &&
115 x.find("addcanvas") == x.end() &&
116 x.find("addvaluedesc") == x.end())
122 Action::TimepointsDelete::set_param(const sinfg::String& name, const Action::Param ¶m)
124 if(name=="addlayer" && param.get_type()==Param::TYPE_LAYER)
126 //add a layer to the list
127 sel_layers.push_back(param.get_layer());
132 if(name=="addcanvas" && param.get_type()==Param::TYPE_CANVAS)
134 //add a layer to the list
135 sel_canvases.push_back(param.get_canvas());
140 if(name=="addvaluedesc" && param.get_type()==Param::TYPE_VALUEDESC)
142 //add a layer to the list
143 sel_values.push_back(param.get_value_desc());
148 if(name=="addtime" && param.get_type()==Param::TYPE_TIME)
150 //add a layer to the list
151 sel_times.insert(param.get_time());
156 return Action::CanvasSpecific::set_param(name,param);
160 Action::TimepointsDelete::is_ready()const
162 if((sel_layers.empty() && sel_canvases.empty() && sel_values.empty()) || sel_times.empty())
164 return Action::CanvasSpecific::is_ready();
168 Action::TimepointsDelete::prepare()
172 if(sel_times.empty()) return;
174 //all our lists should be set correctly...
176 //build our sub-action list
177 // and yes we do need to store it temporarily so we don't duplicate
178 // an operation on a specific valuenode, etc....
179 timepoints_ref match;
181 Time fps = get_canvas()->rend_desc().get_frame_rate();
183 //std::vector<sinfg::Layer::Handle>
184 //sinfg::info("Layers %d", sel_layers.size());
186 std::vector<sinfg::Layer::Handle>::iterator i = sel_layers.begin(),
187 end = sel_layers.end();
191 //sinfg::info("Recurse through a layer");
192 recurse_layer(*i,sel_times,match);
196 //std::vector<sinfg::Canvas::Handle> sel_canvases;
197 //sinfg::info("Canvases %d", sel_canvases.size());
199 std::vector<sinfg::Canvas::Handle>::iterator i = sel_canvases.begin(),
200 end = sel_canvases.end();
204 //sinfg::info("Recurse through a canvas");
205 recurse_canvas(*i,sel_times,match);
209 //std::vector<sinfgapp::ValueDesc>
210 //sinfg::info("ValueBasedescs %d", sel_values.size());
212 std::vector<sinfgapp::ValueDesc>::iterator i = sel_values.begin(),
213 end = sel_values.end();
217 //sinfg::info("Recurse through a valuedesc");
218 recurse_valuedesc(*i,sel_times,match);
222 //process the hell out of em...
224 //must build from both lists
225 timepoints_ref::waytracker::const_iterator i = match.waypointbiglist.begin(),
226 end = match.waypointbiglist.end();
229 //iterate through each waypoint for this specific valuenode
230 std::set<sinfg::Waypoint>::const_iterator j = i->waypoints.begin(),
231 end = i->waypoints.end();
234 Action::Handle action(WaypointRemove::create());
236 action->set_param("canvas",get_canvas());
237 action->set_param("canvas_interface",get_canvas_interface());
238 action->set_param("value_node",ValueNode::Handle(i->val));
239 action->set_param("waypoint",*j);
241 //run the action now that we've added everything
242 assert(action->is_ready());
243 if(!action->is_ready())
244 throw Error(Error::TYPE_NOTREADY);
246 add_action_front(action);
251 //must build from both lists
252 timepoints_ref::acttracker::const_iterator i = match.actpointbiglist.begin(),
253 end = match.actpointbiglist.end();
256 //iterate through each activepoint for this specific valuenode
257 std::set<sinfg::Activepoint>::const_iterator j = i->activepoints.begin(),
258 jend = i->activepoints.end();
259 for(; j != jend; ++j)
261 Action::Handle action(ActivepointRemove::create());
263 action->set_param("canvas",get_canvas());
264 action->set_param("canvas_interface",get_canvas_interface());
265 action->set_param("value_desc",i->val);
266 action->set_param("activepoint",*j);
268 //run the action now that everything should be in order
269 assert(action->is_ready());
270 if(!action->is_ready())
272 throw Error(Error::TYPE_NOTREADY);
275 add_action_front(action);
282 Action::TimepointsDelete::perform()
284 Action::Super::perform();