1 /* === S I N F G =========================================================== */
2 /*! \file timepointscopy.cpp
3 ** \brief Copy the Time Points File
5 ** $Id: timepointscopy.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 "timepointscopy.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 "activepointsimpleadd.h"
38 #include "waypointsimpleadd.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::TimepointsCopy);
54 ACTION_SET_NAME(Action::TimepointsCopy,"timepoint_copy");
55 ACTION_SET_LOCAL_NAME(Action::TimepointsCopy,"Copy Time Points");
56 ACTION_SET_TASK(Action::TimepointsCopy,"copy");
57 ACTION_SET_CATEGORY(Action::TimepointsCopy,Action::CATEGORY_WAYPOINT|Action::CATEGORY_ACTIVEPOINT);
58 ACTION_SET_PRIORITY(Action::TimepointsCopy,0);
59 ACTION_SET_VERSION(Action::TimepointsCopy,"0.0");
60 ACTION_SET_CVS_ID(Action::TimepointsCopy,"$Id: timepointscopy.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::TimepointsCopy::TimepointsCopy()
75 Action::TimepointsCopy::get_param_vocab()
77 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
79 ret.push_back(ParamDesc("addlayer",Param::TYPE_VALUE)
80 .set_local_name(_("New Selected Layer"))
81 .set_desc(_("A layer to add to our selected list"))
82 .set_supports_multiple()
86 ret.push_back(ParamDesc("addcanvas",Param::TYPE_CANVAS)
87 .set_local_name(_("New Selected Canvas"))
88 .set_desc(_("A canvas to add to our selected list"))
89 .set_supports_multiple()
93 ret.push_back(ParamDesc("addvaluedesc",Param::TYPE_VALUEDESC)
94 .set_local_name(_("New Selected ValueBase"))
95 .set_desc(_("A valuenode's description to add to our selected list"))
96 .set_supports_multiple()
100 ret.push_back(ParamDesc("addtime",Param::TYPE_TIME)
101 .set_local_name(_("New Selected Time Point"))
102 .set_desc(_("A time point to add to our selected list"))
103 .set_supports_multiple()
106 ret.push_back(ParamDesc("deltatime",Param::TYPE_TIME)
107 .set_local_name(_("Time adjustment"))
108 .set_desc(_("The amount of time to adjust all the selected points"))
115 Action::TimepointsCopy::is_canidate(const ParamList &x)
117 if(!canidate_check(get_param_vocab(),x))
120 if( x.find("addlayer") == x.end() &&
121 x.find("addcanvas") == x.end() &&
122 x.find("addvaluedesc") == x.end())
128 Action::TimepointsCopy::set_param(const sinfg::String& name, const Action::Param ¶m)
130 if(name=="addlayer" && param.get_type()==Param::TYPE_LAYER)
132 //add a layer to the list
133 sel_layers.push_back(param.get_layer());
134 //sinfg::info("action got layer");
139 if(name=="addcanvas" && param.get_type()==Param::TYPE_CANVAS)
141 //add a layer to the list
142 sel_canvases.push_back(param.get_canvas());
143 //sinfg::info("action got canvas");
148 if(name=="addvaluedesc" && param.get_type()==Param::TYPE_VALUEDESC)
150 //add a layer to the list
151 sel_values.push_back(param.get_value_desc());
152 //sinfg::info("action got valuedesc");
157 if(name=="addtime" && param.get_type()==Param::TYPE_TIME)
159 //add a layer to the list
160 sel_times.insert(param.get_time());
161 //sinfg::info("action got time");
166 if(name=="deltatime" && param.get_type()==Param::TYPE_TIME)
168 timedelta = param.get_time();
169 //sinfg::info("action got time to move");
174 return Action::CanvasSpecific::set_param(name,param);
178 Action::TimepointsCopy::is_ready()const
180 if((sel_layers.empty() && sel_canvases.empty() && sel_values.empty()) || sel_times.empty())
182 return Action::CanvasSpecific::is_ready();
186 Action::TimepointsCopy::prepare()
190 //sinfg::info("Preparing TimepointsCopy by %f secs",(float)timemove);
192 if(sel_times.empty()) return;
194 //all our lists should be set correctly...
196 //build our sub-action list
197 // and yes we do need to store it temporarily so we don't duplicate
198 // an operation on a specific valuenode, etc....
199 timepoints_ref match;
201 Time fps = get_canvas()->rend_desc().get_frame_rate();
203 //std::vector<sinfg::Layer::Handle>
204 //sinfg::info("Layers %d", sel_layers.size());
206 std::vector<sinfg::Layer::Handle>::iterator i = sel_layers.begin(),
207 end = sel_layers.end();
211 //sinfg::info("Recurse through a layer");
212 recurse_layer(*i,sel_times,match);
216 //std::vector<sinfg::Canvas::Handle> sel_canvases;
217 //sinfg::info("Canvases %d", sel_canvases.size());
219 std::vector<sinfg::Canvas::Handle>::iterator i = sel_canvases.begin(),
220 end = sel_canvases.end();
224 //sinfg::info("Recurse through a canvas");
225 recurse_canvas(*i,sel_times,match);
229 //std::vector<sinfgapp::ValueDesc>
230 //sinfg::info("ValueBasedescs %d", sel_values.size());
232 std::vector<sinfgapp::ValueDesc>::iterator i = sel_values.begin(),
233 end = sel_values.end();
237 //sinfg::info("Recurse through a valuedesc");
238 recurse_valuedesc(*i,sel_times,match);
242 //sinfg::info("built list of waypoints/activepoints to modify");
243 //sinfg::info("\t There are %d waypoint sets and %d activepointsets",
244 // match.waypointbiglist.size(), match.actpointbiglist.size());
245 //process the hell out of em...
247 //must build from both lists
248 timepoints_ref::waytracker::const_iterator i = match.waypointbiglist.begin(),
249 end = match.waypointbiglist.end();
252 //iterate through each waypoint for this specific valuenode
253 std::set<sinfg::Waypoint>::const_iterator j = i->waypoints.begin(),
254 end = i->waypoints.end();
257 Action::Handle action(WaypointSimpleAdd::create());
259 action->set_param("canvas",get_canvas());
260 action->set_param("canvas_interface",get_canvas_interface());
261 action->set_param("value_node",ValueNode::Handle(i->val));
263 //sinfg::info("add waypoint mod...");
264 //NOTE: We may want to store the old time for undoing the action...
267 w.set_time((w.get_time() + timedelta).round(fps));
268 w.mimic(neww); //make sure the new waypoint has a new id
270 action->set_param("waypoint",w);
272 //run the action now that we've added everything
273 assert(action->is_ready());
274 if(!action->is_ready())
275 throw Error(Error::TYPE_NOTREADY);
277 add_action_front(action);
282 //must build from both lists
283 timepoints_ref::acttracker::const_iterator i = match.actpointbiglist.begin(),
284 end = match.actpointbiglist.end();
287 //iterate through each activepoint for this specific valuenode
288 std::set<sinfg::Activepoint>::const_iterator j = i->activepoints.begin(),
289 jend = i->activepoints.end();
290 for(; j != jend; ++j)
292 Action::Handle action(ActivepointSimpleAdd::create());
294 action->set_param("canvas",get_canvas());
295 action->set_param("canvas_interface",get_canvas_interface());
296 action->set_param("value_desc",i->val);
298 //NOTE: We may want to store the old time for undoing the action...
301 a.set_time((a.get_time() + timedelta).round(fps));
302 a.mimic(newa); //make sure the new activepoint has a new id
304 action->set_param("activepoint",a);
306 assert(action->is_ready());
307 if(!action->is_ready())
309 throw Error(Error::TYPE_NOTREADY);
312 add_action_front(action);
319 Action::TimepointsCopy::perform()
321 Action::Super::perform();