1 /* === S I N F G =========================================================== */
2 /*! \file timepointsmove.cpp
3 ** \brief Move the Time Points File
5 ** $Id: timepointsmove.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 "timepointsmove.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 "activepointset.h"
38 #include "waypointset.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::TimepointsMove);
54 ACTION_SET_NAME(Action::TimepointsMove,"timepoint_move");
55 ACTION_SET_LOCAL_NAME(Action::TimepointsMove,"Move Time Points");
56 ACTION_SET_TASK(Action::TimepointsMove,"move");
57 ACTION_SET_CATEGORY(Action::TimepointsMove,Action::CATEGORY_WAYPOINT|Action::CATEGORY_ACTIVEPOINT);
58 ACTION_SET_PRIORITY(Action::TimepointsMove,0);
59 ACTION_SET_VERSION(Action::TimepointsMove,"0.0");
60 ACTION_SET_CVS_ID(Action::TimepointsMove,"$Id: timepointsmove.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::TimepointsMove::TimepointsMove()
75 Action::TimepointsMove::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::TimepointsMove::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::TimepointsMove::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 timemove = param.get_time();
169 //sinfg::info("action got time to move");
174 return Action::CanvasSpecific::set_param(name,param);
178 Action::TimepointsMove::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::TimepointsMove::prepare()
190 //sinfg::info("Preparing TimepointsMove by %f secs",(float)timemove);
192 if(sel_times.empty()) return;
194 //all our lists should be set correctly...
197 std::set<sinfg::Time>::iterator i = sel_times.begin(), end = sel_times.end();
201 sinfg::info("Time %f", (float)*i);
205 //build our sub-action list
206 // and yes we do need to store it temporarily so we don't duplicate
207 // an operation on a specific valuenode, etc....
208 timepoints_ref match;
210 Time fps = get_canvas()->rend_desc().get_frame_rate();
212 //std::vector<sinfg::Layer::Handle>
213 //sinfg::info("Layers %d", sel_layers.size());
215 std::vector<sinfg::Layer::Handle>::iterator i = sel_layers.begin(),
216 end = sel_layers.end();
220 //sinfg::info("Recurse through a layer");
221 recurse_layer(*i,sel_times,match);
225 //std::vector<sinfg::Canvas::Handle> sel_canvases;
226 //sinfg::info("Canvases %d", sel_canvases.size());
228 std::vector<sinfg::Canvas::Handle>::iterator i = sel_canvases.begin(),
229 end = sel_canvases.end();
233 //sinfg::info("Recurse through a canvas");
234 recurse_canvas(*i,sel_times,match);
238 //std::vector<sinfgapp::ValueDesc>
239 //sinfg::info("ValueBasedescs %d", sel_values.size());
241 std::vector<sinfgapp::ValueDesc>::iterator i = sel_values.begin(),
242 end = sel_values.end();
246 //sinfg::info("Recurse through a valuedesc");
247 recurse_valuedesc(*i,sel_times,match);
251 //sinfg::info("built list of waypoints/activepoints to modify");
252 //sinfg::info("\t There are %d waypoint sets and %d activepointsets",
253 // match.waypointbiglist.size(), match.actpointbiglist.size());
254 //process the hell out of em...
256 //must build from both lists
257 timepoints_ref::waytracker::const_iterator i = match.waypointbiglist.begin(),
258 end = match.waypointbiglist.end();
261 Action::Handle action(WaypointSet::create());
263 action->set_param("canvas",get_canvas());
264 action->set_param("canvas_interface",get_canvas_interface());
265 action->set_param("value_node",ValueNode::Handle(i->val));
267 //iterate through each waypoint for this specific valuenode
268 std::set<sinfg::Waypoint>::const_iterator j = i->waypoints.begin(),
269 end = i->waypoints.end();
272 //sinfg::info("add waypoint mod...");
273 //NOTE: We may want to store the old time for undoing the action...
275 w.set_time((w.get_time() + timemove).round(fps));
276 action->set_param("waypoint",w);
279 //run the action now that we've added everything
280 assert(action->is_ready());
281 if(!action->is_ready())
282 throw Error(Error::TYPE_NOTREADY);
284 add_action_front(action);
288 //must build from both lists
289 timepoints_ref::acttracker::const_iterator i = match.actpointbiglist.begin(),
290 end = match.actpointbiglist.end();
293 Action::Handle action(ActivepointSet::create());
295 action->set_param("canvas",get_canvas());
296 action->set_param("canvas_interface",get_canvas_interface());
297 action->set_param("value_desc",i->val);
299 //iterate through each activepoint for this specific valuenode
300 std::set<sinfg::Activepoint>::const_iterator j = i->activepoints.begin(),
301 jend = i->activepoints.end();
302 for(; j != jend; ++j)
304 //sinfg::info("add activepoint mod...");
306 //NOTE: We may want to store the old time for undoing the action...
308 a.set_time((a.get_time() + timemove).round(fps));
309 action->set_param("activepoint",a);
312 assert(action->is_ready());
313 if(!action->is_ready())
315 throw Error(Error::TYPE_NOTREADY);
318 add_action_front(action);
324 Action::TimepointsMove::perform()
326 Action::Super::perform();