1 | /* === S Y N F I G ========================================================= */ |
---|
2 | /*! \file blinepointtangentsplit.cpp |
---|
3 | ** \brief Template File |
---|
4 | ** |
---|
5 | ** $Id$ |
---|
6 | ** |
---|
7 | ** \legal |
---|
8 | ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley |
---|
9 | ** Copyright (c) 2007, 2008 Chris Moore |
---|
10 | ** Copyright (c) 2009 Nikita Kitaev |
---|
11 | ** Copyright (c) 2012 Carlos López |
---|
12 | ** |
---|
13 | ** This package is free software; you can redistribute it and/or |
---|
14 | ** modify it under the terms of the GNU General Public License as |
---|
15 | ** published by the Free Software Foundation; either version 2 of |
---|
16 | ** the License, or (at your option) any later version. |
---|
17 | ** |
---|
18 | ** This package is distributed in the hope that it will be useful, |
---|
19 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
21 | ** General Public License for more details. |
---|
22 | ** \endlegal |
---|
23 | */ |
---|
24 | /* ========================================================================= */ |
---|
25 | |
---|
26 | /* === H E A D E R S ======================================================= */ |
---|
27 | |
---|
28 | #ifdef USING_PCH |
---|
29 | # include "pch.h" |
---|
30 | #else |
---|
31 | #ifdef HAVE_CONFIG_H |
---|
32 | # include <config.h> |
---|
33 | #endif |
---|
34 | |
---|
35 | #include "blinepointtangentsplit.h" |
---|
36 | #include "valuedescset.h" |
---|
37 | |
---|
38 | #include "activepointset.h" |
---|
39 | #include "activepointadd.h" |
---|
40 | |
---|
41 | #include "valuedescconnect.h" |
---|
42 | #include <synfigapp/canvasinterface.h> |
---|
43 | |
---|
44 | #include <synfigapp/general.h> |
---|
45 | #include <synfig/valuenodes/valuenode_radialcomposite.h> |
---|
46 | |
---|
47 | #endif |
---|
48 | |
---|
49 | using namespace std; |
---|
50 | using namespace etl; |
---|
51 | using namespace synfig; |
---|
52 | using namespace synfigapp; |
---|
53 | using namespace Action; |
---|
54 | |
---|
55 | /* === M A C R O S ========================================================= */ |
---|
56 | |
---|
57 | ACTION_INIT_NO_GET_LOCAL_NAME(Action::BLinePointTangentSplit); |
---|
58 | ACTION_SET_NAME(Action::BLinePointTangentSplit,"BLinePointTangentSplit"); |
---|
59 | ACTION_SET_LOCAL_NAME(Action::BLinePointTangentSplit,N_("Split Tangents")); |
---|
60 | ACTION_SET_TASK(Action::BLinePointTangentSplit,"disconnect"); |
---|
61 | ACTION_SET_CATEGORY(Action::BLinePointTangentSplit,Action::CATEGORY_VALUENODE); |
---|
62 | ACTION_SET_PRIORITY(Action::BLinePointTangentSplit,0); |
---|
63 | ACTION_SET_VERSION(Action::BLinePointTangentSplit,"0.1"); |
---|
64 | ACTION_SET_CVS_ID(Action::BLinePointTangentSplit,"$Id$"); |
---|
65 | |
---|
66 | ACTION_INIT_NO_GET_LOCAL_NAME(Action::BLinePointTangentSplitRadius); |
---|
67 | ACTION_SET_NAME(Action::BLinePointTangentSplitRadius,"BLinePointTangentSplitRadius"); |
---|
68 | ACTION_SET_LOCAL_NAME(Action::BLinePointTangentSplitRadius,N_("Split Tangents's Radius")); |
---|
69 | ACTION_SET_TASK(Action::BLinePointTangentSplitRadius,"type_vector"); |
---|
70 | ACTION_SET_CATEGORY(Action::BLinePointTangentSplitRadius,Action::CATEGORY_VALUENODE); |
---|
71 | ACTION_SET_PRIORITY(Action::BLinePointTangentSplitRadius,0); |
---|
72 | ACTION_SET_VERSION(Action::BLinePointTangentSplitRadius,"0.0"); |
---|
73 | ACTION_SET_CVS_ID(Action::BLinePointTangentSplitRadius,"$Id$"); |
---|
74 | |
---|
75 | ACTION_INIT_NO_GET_LOCAL_NAME(Action::BLinePointTangentSplitAngle); |
---|
76 | ACTION_SET_NAME(Action::BLinePointTangentSplitAngle,"BLinePointTangentSplitAngle"); |
---|
77 | ACTION_SET_LOCAL_NAME(Action::BLinePointTangentSplitAngle,N_("Split Tangents's Angle")); |
---|
78 | ACTION_SET_TASK(Action::BLinePointTangentSplitAngle,"type_angle"); |
---|
79 | ACTION_SET_CATEGORY(Action::BLinePointTangentSplitAngle,Action::CATEGORY_VALUENODE); |
---|
80 | ACTION_SET_PRIORITY(Action::BLinePointTangentSplitAngle,0); |
---|
81 | ACTION_SET_VERSION(Action::BLinePointTangentSplitAngle,"0.0"); |
---|
82 | ACTION_SET_CVS_ID(Action::BLinePointTangentSplitAngle,"$Id$"); |
---|
83 | |
---|
84 | /* === G L O B A L S ======================================================= */ |
---|
85 | |
---|
86 | /* === P R O C E D U R E S ================================================= */ |
---|
87 | |
---|
88 | /* === M E T H O D S ======================================================= */ |
---|
89 | |
---|
90 | |
---|
91 | //// BLINEPOINT TANGENT SPLIT ////////// |
---|
92 | Action::BLinePointTangentSplit::BLinePointTangentSplit() |
---|
93 | { |
---|
94 | time=(Time::begin()-1); |
---|
95 | set_dirty(true); |
---|
96 | } |
---|
97 | |
---|
98 | synfig::String |
---|
99 | Action::BLinePointTangentSplit::get_local_name()const |
---|
100 | { |
---|
101 | return strprintf(_("Split Tangents of '%s'"), ((ValueNode::Handle)(value_node))->get_description().c_str()); |
---|
102 | } |
---|
103 | |
---|
104 | Action::ParamVocab |
---|
105 | Action::BLinePointTangentSplit::get_param_vocab() |
---|
106 | { |
---|
107 | ParamVocab ret(Action::CanvasSpecific::get_param_vocab()); |
---|
108 | ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE) |
---|
109 | .set_local_name(_("ValueNode of Spline Point")) |
---|
110 | ); |
---|
111 | ret.push_back(ParamDesc("time",Param::TYPE_TIME) |
---|
112 | .set_local_name(_("Time")) |
---|
113 | ); |
---|
114 | return ret; |
---|
115 | } |
---|
116 | |
---|
117 | bool |
---|
118 | Action::BLinePointTangentSplit::is_candidate(const ParamList &x) |
---|
119 | { |
---|
120 | if(candidate_check(get_param_vocab(),x)) |
---|
121 | { |
---|
122 | ValueNode_Composite::Handle value_node; |
---|
123 | value_node=ValueNode_Composite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()); |
---|
124 | if(!value_node || value_node->get_type()!=type_bline_point) |
---|
125 | { |
---|
126 | // Before return false, let's check whether the value_node |
---|
127 | // is radial composite and vector type |
---|
128 | ValueNode_RadialComposite::Handle radial_value_node; |
---|
129 | radial_value_node=ValueNode_RadialComposite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()); |
---|
130 | if(radial_value_node && radial_value_node->get_type()==type_vector) |
---|
131 | // value_node is radial composite and vector (user rigth click on a tangent) |
---|
132 | { |
---|
133 | ValueNode_Composite::Handle blinepoint=NULL; |
---|
134 | std::set<Node*>::iterator iter; |
---|
135 | // now check if the parent of radial_value_node is a blinepoint type |
---|
136 | for(iter=radial_value_node->parent_set.begin();iter!=radial_value_node->parent_set.end();++iter) |
---|
137 | { |
---|
138 | blinepoint=ValueNode_Composite::Handle::cast_dynamic(*iter); |
---|
139 | if(blinepoint && blinepoint->get_type()==type_bline_point) |
---|
140 | break; |
---|
141 | } |
---|
142 | if(blinepoint) |
---|
143 | value_node=blinepoint; |
---|
144 | } |
---|
145 | } |
---|
146 | // at this point we should have a value node and it should be blinepoint |
---|
147 | // if we haven't, then return false |
---|
148 | if(!value_node || value_node->get_type()!=type_bline_point) |
---|
149 | return false; |
---|
150 | synfig::Time time(x.find("time")->second.get_time()); |
---|
151 | bool split_radius=(*value_node->get_link("split_radius"))(time).get(bool()); |
---|
152 | bool split_angle=(*value_node->get_link("split_angle"))(time).get(bool()); |
---|
153 | if(split_radius==true && split_angle==true) |
---|
154 | return false; |
---|
155 | return true; |
---|
156 | } |
---|
157 | return false; |
---|
158 | } |
---|
159 | |
---|
160 | bool |
---|
161 | Action::BLinePointTangentSplit::set_param(const synfig::String& name, const Action::Param ¶m) |
---|
162 | { |
---|
163 | if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE) |
---|
164 | { |
---|
165 | value_node=value_node.cast_dynamic(param.get_value_node()); |
---|
166 | if(value_node && value_node->get_type()==type_bline_point) |
---|
167 | return true; |
---|
168 | ValueNode_RadialComposite::Handle radial_value_node; |
---|
169 | radial_value_node=ValueNode_RadialComposite::Handle::cast_dynamic(param.get_value_node()); |
---|
170 | if(radial_value_node && radial_value_node->get_type()==type_vector) |
---|
171 | // value_node is radial composite and vector (user rigth click on a tangent) |
---|
172 | { |
---|
173 | ValueNode_Composite::Handle blinepoint; |
---|
174 | std::set<Node*>::iterator iter; |
---|
175 | // now check if the parent of value_node is a blinepoint type |
---|
176 | for(iter=radial_value_node->parent_set.begin();iter!=radial_value_node->parent_set.end();++iter) |
---|
177 | { |
---|
178 | blinepoint=ValueNode_Composite::Handle::cast_dynamic(*iter); |
---|
179 | if(blinepoint && blinepoint->get_type()==type_bline_point) |
---|
180 | { |
---|
181 | value_node=blinepoint; |
---|
182 | return true; |
---|
183 | } |
---|
184 | } |
---|
185 | return false; |
---|
186 | } |
---|
187 | return false; |
---|
188 | } |
---|
189 | if(name=="time" && param.get_type()==Param::TYPE_TIME) |
---|
190 | { |
---|
191 | time=param.get_time(); |
---|
192 | return true; |
---|
193 | } |
---|
194 | return Action::CanvasSpecific::set_param(name,param); |
---|
195 | } |
---|
196 | |
---|
197 | bool |
---|
198 | Action::BLinePointTangentSplit::is_ready()const |
---|
199 | { |
---|
200 | if(!value_node) |
---|
201 | synfig::error("Missing or bad value_node"); |
---|
202 | if(time==(Time::begin()-1)) |
---|
203 | synfig::error("Missing time"); |
---|
204 | if(!value_node || time==(Time::begin()-1)) |
---|
205 | return false; |
---|
206 | return Action::CanvasSpecific::is_ready(); |
---|
207 | } |
---|
208 | |
---|
209 | void |
---|
210 | Action::BLinePointTangentSplit::prepare() |
---|
211 | { |
---|
212 | clear(); |
---|
213 | { |
---|
214 | Action::Handle action; |
---|
215 | action=Action::create("ValueDescSet"); |
---|
216 | if(!action) |
---|
217 | throw Error(_("Couldn't find action \"ValueDescSet\"")); |
---|
218 | action->set_param("canvas",get_canvas()); |
---|
219 | action->set_param("canvas_interface",get_canvas_interface()); |
---|
220 | action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("split_radius"))); |
---|
221 | action->set_param("time",time); |
---|
222 | action->set_param("new_value",synfig::ValueBase(true)); |
---|
223 | assert(action->is_ready()); |
---|
224 | if(!action->is_ready()) |
---|
225 | throw Error(Error::TYPE_NOTREADY); |
---|
226 | add_action(action); |
---|
227 | } |
---|
228 | { |
---|
229 | Action::Handle action; |
---|
230 | action=Action::create("ValueDescSet"); |
---|
231 | if(!action) |
---|
232 | throw Error(_("Couldn't find action \"ValueDescSet\"")); |
---|
233 | action->set_param("canvas",get_canvas()); |
---|
234 | action->set_param("canvas_interface",get_canvas_interface()); |
---|
235 | action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("split_angle"))); |
---|
236 | action->set_param("time",time); |
---|
237 | action->set_param("new_value",synfig::ValueBase(true)); |
---|
238 | assert(action->is_ready()); |
---|
239 | if(!action->is_ready()) |
---|
240 | throw Error(Error::TYPE_NOTREADY); |
---|
241 | add_action(action); |
---|
242 | } |
---|
243 | } |
---|
244 | |
---|
245 | |
---|
246 | //// BLINEPOINT TANGENT SPLIT RADIUS ////////// |
---|
247 | Action::BLinePointTangentSplitRadius::BLinePointTangentSplitRadius() |
---|
248 | { |
---|
249 | time=(Time::begin()-1); |
---|
250 | set_dirty(true); |
---|
251 | } |
---|
252 | |
---|
253 | synfig::String |
---|
254 | Action::BLinePointTangentSplitRadius::get_local_name()const |
---|
255 | { |
---|
256 | return strprintf(_("Split Tangents's Radius of '%s'"), ((ValueNode::Handle)(value_node))->get_description().c_str()); |
---|
257 | } |
---|
258 | |
---|
259 | Action::ParamVocab |
---|
260 | Action::BLinePointTangentSplitRadius::get_param_vocab() |
---|
261 | { |
---|
262 | ParamVocab ret(Action::CanvasSpecific::get_param_vocab()); |
---|
263 | ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE) |
---|
264 | .set_local_name(_("ValueNode of Spline Point")) |
---|
265 | ); |
---|
266 | ret.push_back(ParamDesc("time",Param::TYPE_TIME) |
---|
267 | .set_local_name(_("Time")) |
---|
268 | ); |
---|
269 | return ret; |
---|
270 | } |
---|
271 | |
---|
272 | bool |
---|
273 | Action::BLinePointTangentSplitRadius::is_candidate(const ParamList &x) |
---|
274 | { |
---|
275 | if(candidate_check(get_param_vocab(),x)) |
---|
276 | { |
---|
277 | ValueNode_Composite::Handle value_node; |
---|
278 | value_node=ValueNode_Composite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()); |
---|
279 | if(!value_node || value_node->get_type()!=type_bline_point) |
---|
280 | { |
---|
281 | // Before return false, let's check whether the value_node |
---|
282 | // is radial composite and vector type |
---|
283 | ValueNode_RadialComposite::Handle radial_value_node; |
---|
284 | radial_value_node=ValueNode_RadialComposite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()); |
---|
285 | if(radial_value_node && radial_value_node->get_type()==type_vector) |
---|
286 | // value_node is radial composite and vector (user rigth click on a tangent) |
---|
287 | { |
---|
288 | ValueNode_Composite::Handle blinepoint=NULL; |
---|
289 | std::set<Node*>::iterator iter; |
---|
290 | // now check if the parent of radial_value_node is a blinepoint type |
---|
291 | for(iter=radial_value_node->parent_set.begin();iter!=radial_value_node->parent_set.end();++iter) |
---|
292 | { |
---|
293 | blinepoint=ValueNode_Composite::Handle::cast_dynamic(*iter); |
---|
294 | if(blinepoint && blinepoint->get_type()==type_bline_point) |
---|
295 | break; |
---|
296 | } |
---|
297 | if(blinepoint) |
---|
298 | value_node=blinepoint; |
---|
299 | } |
---|
300 | } |
---|
301 | // at this point we should have a value node and it should be blinepoint |
---|
302 | // if we haven't, then return false |
---|
303 | if(!value_node || value_node->get_type()!=type_bline_point) |
---|
304 | return false; |
---|
305 | synfig::Time time(x.find("time")->second.get_time()); |
---|
306 | bool split_radius=(*value_node->get_link("split_radius"))(time).get(bool()); |
---|
307 | if(split_radius==true) |
---|
308 | return false; |
---|
309 | return true; |
---|
310 | } |
---|
311 | return false; |
---|
312 | } |
---|
313 | |
---|
314 | bool |
---|
315 | Action::BLinePointTangentSplitRadius::set_param(const synfig::String& name, const Action::Param ¶m) |
---|
316 | { |
---|
317 | if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE) |
---|
318 | { |
---|
319 | value_node=value_node.cast_dynamic(param.get_value_node()); |
---|
320 | if(value_node && value_node->get_type()==type_bline_point) |
---|
321 | return true; |
---|
322 | ValueNode_RadialComposite::Handle radial_value_node; |
---|
323 | radial_value_node=ValueNode_RadialComposite::Handle::cast_dynamic(param.get_value_node()); |
---|
324 | if(radial_value_node && radial_value_node->get_type()==type_vector) |
---|
325 | // value_node is radial composite and vector (user rigth click on a tangent) |
---|
326 | { |
---|
327 | ValueNode_Composite::Handle blinepoint; |
---|
328 | std::set<Node*>::iterator iter; |
---|
329 | // now check if the parent of value_node is a blinepoint type |
---|
330 | for(iter=radial_value_node->parent_set.begin();iter!=radial_value_node->parent_set.end();++iter) |
---|
331 | { |
---|
332 | blinepoint=ValueNode_Composite::Handle::cast_dynamic(*iter); |
---|
333 | if(blinepoint && blinepoint->get_type()==type_bline_point) |
---|
334 | { |
---|
335 | value_node=blinepoint; |
---|
336 | return true; |
---|
337 | } |
---|
338 | } |
---|
339 | return false; |
---|
340 | } |
---|
341 | return false; |
---|
342 | } |
---|
343 | if(name=="time" && param.get_type()==Param::TYPE_TIME) |
---|
344 | { |
---|
345 | time=param.get_time(); |
---|
346 | return true; |
---|
347 | } |
---|
348 | return Action::CanvasSpecific::set_param(name,param); |
---|
349 | } |
---|
350 | |
---|
351 | bool |
---|
352 | Action::BLinePointTangentSplitRadius::is_ready()const |
---|
353 | { |
---|
354 | if(!value_node) |
---|
355 | synfig::error("Missing or bad value_node"); |
---|
356 | if(time==(Time::begin()-1)) |
---|
357 | synfig::error("Missing time"); |
---|
358 | if(!value_node || time==(Time::begin()-1)) |
---|
359 | return false; |
---|
360 | return Action::CanvasSpecific::is_ready(); |
---|
361 | } |
---|
362 | |
---|
363 | void |
---|
364 | Action::BLinePointTangentSplitRadius::prepare() |
---|
365 | { |
---|
366 | clear(); |
---|
367 | { |
---|
368 | Action::Handle action; |
---|
369 | action=Action::create("ValueDescSet"); |
---|
370 | if(!action) |
---|
371 | throw Error(_("Couldn't find action \"ValueDescSet\"")); |
---|
372 | action->set_param("canvas",get_canvas()); |
---|
373 | action->set_param("canvas_interface",get_canvas_interface()); |
---|
374 | action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("split_radius"))); |
---|
375 | action->set_param("time",time); |
---|
376 | action->set_param("new_value",synfig::ValueBase(true)); |
---|
377 | assert(action->is_ready()); |
---|
378 | if(!action->is_ready()) |
---|
379 | throw Error(Error::TYPE_NOTREADY); |
---|
380 | add_action(action); |
---|
381 | } |
---|
382 | } |
---|
383 | |
---|
384 | //// BLINEPOINT TANGENT SPLIT ANGLE ////////// |
---|
385 | Action::BLinePointTangentSplitAngle::BLinePointTangentSplitAngle() |
---|
386 | { |
---|
387 | time=(Time::begin()-1); |
---|
388 | set_dirty(true); |
---|
389 | } |
---|
390 | |
---|
391 | synfig::String |
---|
392 | Action::BLinePointTangentSplitAngle::get_local_name()const |
---|
393 | { |
---|
394 | return strprintf(_("Split Tangents's Angle of '%s'"), ((ValueNode::Handle)(value_node))->get_description().c_str()); |
---|
395 | } |
---|
396 | |
---|
397 | Action::ParamVocab |
---|
398 | Action::BLinePointTangentSplitAngle::get_param_vocab() |
---|
399 | { |
---|
400 | ParamVocab ret(Action::CanvasSpecific::get_param_vocab()); |
---|
401 | ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE) |
---|
402 | .set_local_name(_("ValueNode of Spline Point")) |
---|
403 | ); |
---|
404 | ret.push_back(ParamDesc("time",Param::TYPE_TIME) |
---|
405 | .set_local_name(_("Time")) |
---|
406 | ); |
---|
407 | return ret; |
---|
408 | } |
---|
409 | |
---|
410 | bool |
---|
411 | Action::BLinePointTangentSplitAngle::is_candidate(const ParamList &x) |
---|
412 | { |
---|
413 | if(candidate_check(get_param_vocab(),x)) |
---|
414 | { |
---|
415 | ValueNode_Composite::Handle value_node; |
---|
416 | value_node=ValueNode_Composite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()); |
---|
417 | if(!value_node || value_node->get_type()!=type_bline_point) |
---|
418 | { |
---|
419 | // Before return false, let's check whether the value_node |
---|
420 | // is radial composite and vector type |
---|
421 | ValueNode_RadialComposite::Handle radial_value_node; |
---|
422 | radial_value_node=ValueNode_RadialComposite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()); |
---|
423 | if(radial_value_node && radial_value_node->get_type()==type_vector) |
---|
424 | // value_node is radial composite and vector (user rigth click on a tangent) |
---|
425 | { |
---|
426 | ValueNode_Composite::Handle blinepoint=NULL; |
---|
427 | std::set<Node*>::iterator iter; |
---|
428 | // now check if the parent of radial_value_node is a blinepoint type |
---|
429 | for(iter=radial_value_node->parent_set.begin();iter!=radial_value_node->parent_set.end();++iter) |
---|
430 | { |
---|
431 | blinepoint=ValueNode_Composite::Handle::cast_dynamic(*iter); |
---|
432 | if(blinepoint && blinepoint->get_type()==type_bline_point) |
---|
433 | break; |
---|
434 | } |
---|
435 | if(blinepoint) |
---|
436 | value_node=blinepoint; |
---|
437 | } |
---|
438 | } |
---|
439 | // at this point we should have a value node and it should be blinepoint |
---|
440 | // if we haven't, then return false |
---|
441 | if(!value_node || value_node->get_type()!=type_bline_point) |
---|
442 | return false; |
---|
443 | synfig::Time time(x.find("time")->second.get_time()); |
---|
444 | bool split_angle=(*value_node->get_link("split_angle"))(time).get(bool()); |
---|
445 | if(split_angle==true) |
---|
446 | return false; |
---|
447 | return true; |
---|
448 | } |
---|
449 | return false; |
---|
450 | } |
---|
451 | |
---|
452 | bool |
---|
453 | Action::BLinePointTangentSplitAngle::set_param(const synfig::String& name, const Action::Param ¶m) |
---|
454 | { |
---|
455 | if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE) |
---|
456 | { |
---|
457 | value_node=value_node.cast_dynamic(param.get_value_node()); |
---|
458 | if(value_node && value_node->get_type()==type_bline_point) |
---|
459 | return true; |
---|
460 | ValueNode_RadialComposite::Handle radial_value_node; |
---|
461 | radial_value_node=ValueNode_RadialComposite::Handle::cast_dynamic(param.get_value_node()); |
---|
462 | if(radial_value_node && radial_value_node->get_type()==type_vector) |
---|
463 | // value_node is radial composite and vector (user rigth click on a tangent) |
---|
464 | { |
---|
465 | ValueNode_Composite::Handle blinepoint; |
---|
466 | std::set<Node*>::iterator iter; |
---|
467 | // now check if the parent of value_node is a blinepoint type |
---|
468 | for(iter=radial_value_node->parent_set.begin();iter!=radial_value_node->parent_set.end();++iter) |
---|
469 | { |
---|
470 | blinepoint=ValueNode_Composite::Handle::cast_dynamic(*iter); |
---|
471 | if(blinepoint && blinepoint->get_type()==type_bline_point) |
---|
472 | { |
---|
473 | value_node=blinepoint; |
---|
474 | return true; |
---|
475 | } |
---|
476 | } |
---|
477 | return false; |
---|
478 | } |
---|
479 | return false; |
---|
480 | } |
---|
481 | if(name=="time" && param.get_type()==Param::TYPE_TIME) |
---|
482 | { |
---|
483 | time=param.get_time(); |
---|
484 | return true; |
---|
485 | } |
---|
486 | return Action::CanvasSpecific::set_param(name,param); |
---|
487 | } |
---|
488 | |
---|
489 | bool |
---|
490 | Action::BLinePointTangentSplitAngle::is_ready()const |
---|
491 | { |
---|
492 | if(!value_node) |
---|
493 | synfig::error("Missing or bad value_node"); |
---|
494 | if(time==(Time::begin()-1)) |
---|
495 | synfig::error("Missing time"); |
---|
496 | if(!value_node || time==(Time::begin()-1)) |
---|
497 | return false; |
---|
498 | return Action::CanvasSpecific::is_ready(); |
---|
499 | } |
---|
500 | |
---|
501 | void |
---|
502 | Action::BLinePointTangentSplitAngle::prepare() |
---|
503 | { |
---|
504 | clear(); |
---|
505 | { |
---|
506 | Action::Handle action; |
---|
507 | action=Action::create("ValueDescSet"); |
---|
508 | if(!action) |
---|
509 | throw Error(_("Couldn't find action \"ValueDescSet\"")); |
---|
510 | action->set_param("canvas",get_canvas()); |
---|
511 | action->set_param("canvas_interface",get_canvas_interface()); |
---|
512 | action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("split_angle"))); |
---|
513 | action->set_param("time",time); |
---|
514 | action->set_param("new_value",synfig::ValueBase(true)); |
---|
515 | assert(action->is_ready()); |
---|
516 | if(!action->is_ready()) |
---|
517 | throw Error(Error::TYPE_NOTREADY); |
---|
518 | add_action(action); |
---|
519 | } |
---|
520 | } |
---|