Example #1
0
void
Action::KeyframeDuplicate::process_value_desc(const synfigapp::ValueDesc& value_desc)
{
	const synfig::Time old_time=keyframe.get_time();
	const synfig::Time new_time=new_keyframe.get_time();

	if(value_desc.is_value_node())
	{
		ValueNode::Handle value_node(value_desc.get_value_node());

		// If we are a dynamic list, then we need to update the ActivePoints
		if(ValueNode_DynamicList::Handle::cast_dynamic(value_node))
		{
			ValueNode_DynamicList::Handle value_node_dynamic(ValueNode_DynamicList::Handle::cast_dynamic(value_node));
			int i;

			for(i=0;i<value_node_dynamic->link_count();i++)
			{
				synfigapp::ValueDesc value_desc(value_node_dynamic,i);
				Activepoint activepoint(value_node_dynamic->list[i].new_activepoint_at_time(old_time));
				activepoint.set_time(new_time);

				Action::Handle action(ActivepointSetSmart::create());

				action->set_param("canvas",get_canvas());
				action->set_param("canvas_interface",get_canvas_interface());
				action->set_param("value_desc",value_desc);
				action->set_param("activepoint",activepoint);

				assert(action->is_ready());
				if(!action->is_ready())
					throw Error(Error::TYPE_NOTREADY);

				add_action_front(action);
			}
		}
		else if(ValueNode_Animated::Handle::cast_dynamic(value_node))
		{
			ValueNode_Animated::Handle value_node_animated(ValueNode_Animated::Handle::cast_dynamic(value_node));
			Waypoint waypoint(value_node_animated->new_waypoint_at_time(old_time));
			waypoint.set_time(new_time);

			Action::Handle action(WaypointSetSmart::create());

			action->set_param("canvas",get_canvas());
			action->set_param("canvas_interface",get_canvas_interface());
			action->set_param("value_node",ValueNode::Handle(value_node_animated));
			action->set_param("waypoint",waypoint);

			assert(action->is_ready());
			if(!action->is_ready())
				throw Error(Error::TYPE_NOTREADY);

			add_action_front(action);
		}
	}
}
//kind of a hack... pointer is ugly
void get_change_times_from_vdesc(const synfigapp::ValueDesc &v, std::set<synfig::Time> &times)
{
	if (v.is_value_node())
	{
		if ( v.get_value_type() == type_string
		  || v.get_value_type() == type_bool
		  || v.get_value_type() == type_canvas )
		{
			std::map<Time, ValueBase> x;
			v.get_value_node()->get_values(x);
			for(std::map<Time, ValueBase>::const_iterator i = x.begin(); i != x.end(); ++i)
				times.insert(i->first);
		}
	}
}
void
Action::KeyframeWaypointSet::process_value_desc(const synfigapp::ValueDesc& value_desc)
{
	if(value_desc.is_value_node())
	{
		ValueNode_Animated::Handle value_node(ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node()));

		if(value_node)
		{
			Action::Handle action(WaypointSetSmart::create());

			action->set_param("canvas",get_canvas());
			action->set_param("canvas_interface",get_canvas_interface());
			action->set_param("value_node",ValueNode::Handle(value_node));

			Waypoint waypoint;
			try
			{
				waypoint=*value_node->find(keyframe.get_time());
			}
			catch(...)
			{
				waypoint.set_time(keyframe.get_time());
				waypoint.set_value((*value_node)(keyframe.get_time()));
			}

			keyframe.apply_model(waypoint_model);
			//*get_canvas()->keyframe_list().find(keyframe)=keyframe;
			KeyframeList::iterator iter;
			if (get_canvas()->keyframe_list().find(keyframe, iter)) *iter = keyframe;

			waypoint.apply_model(waypoint_model);

			action->set_param("waypoint",waypoint);

			assert(action->is_ready());
			if(!action->is_ready())
				throw Error(Error::TYPE_NOTREADY);

			add_action_front(action);
		}
	}
}
Example #4
0
void
Action::KeyframeRemove::process_value_desc(const synfigapp::ValueDesc& value_desc)
{
	const synfig::Time time(keyframe.get_time());

	if(value_desc.is_value_node())
	{
		ValueNode::Handle value_node(value_desc.get_value_node());

		// If we are a dynamic list, then we need to update the ActivePoints
		if(ValueNode_DynamicList::Handle::cast_dynamic(value_node))
		{
			ValueNode_DynamicList::Handle value_node_dynamic(ValueNode_DynamicList::Handle::cast_dynamic(value_node));
			int i;
			for(i=0;i<value_node_dynamic->link_count();i++)
			try
			{
				Activepoint activepoint;
				activepoint=*value_node_dynamic->list[i].find(time);

				synfigapp::ValueDesc value_desc(value_node_dynamic,i);

				Action::Handle action(ActivepointRemove::create());

				action->set_param("canvas",get_canvas());
				action->set_param("canvas_interface",get_canvas_interface());
				action->set_param("value_desc",value_desc);
				action->set_param("activepoint",activepoint);

				assert(action->is_ready());
				if(!action->is_ready())
					throw Error(Error::TYPE_NOTREADY);

				add_action_front(action);
			}
			catch(...)
			{
			}
		}
		else if(ValueNode_Animated::Handle::cast_dynamic(value_node))
		try
		{
			ValueNode_Animated::Handle value_node_animated(ValueNode_Animated::Handle::cast_dynamic(value_node));
			Waypoint waypoint;
			waypoint=*value_node_animated->find(time);
			assert(waypoint.get_time()==time);

			Action::Handle action(WaypointRemove::create());

			action->set_param("canvas",get_canvas());
			action->set_param("canvas_interface",get_canvas_interface());
			action->set_param("value_node",ValueNode::Handle(value_node_animated));
			action->set_param("waypoint",waypoint);

			assert(action->is_ready());
			if(!action->is_ready())
				throw Error(Error::TYPE_NOTREADY);

			add_action_front(action);
		}
		catch(...)
		{
		}
	}
}
Example #5
0
void
Action::KeyframeSet::process_value_desc(const synfigapp::ValueDesc& value_desc)
{
	if(value_desc.is_value_node())
	{
		ValueNode::Handle value_node(value_desc.get_value_node());

		//if(guid_set.count(value_node->get_guid()))
		//	return;
		//guid_set.insert(value_node->get_guid());

		// If we are a dynamic list, then we need to update the ActivePoints
		if(ValueNode_DynamicList::Handle::cast_dynamic(value_node))
		{
			ValueNode_DynamicList::Handle value_node_dynamic(ValueNode_DynamicList::Handle::cast_dynamic(value_node));
			int i;
			for(i=0;i<value_node_dynamic->link_count();i++)
			{
				synfigapp::ValueDesc value_desc(value_node_dynamic,i);
				if(new_time>keyframe_prev && new_time<keyframe_next)
				{
					// In this circumstance, we need to adjust any
					// activepoints between the previous and next
					// keyframes
					scale_activepoints(value_desc,keyframe_prev,old_time,keyframe_prev,new_time);
					scale_activepoints(value_desc,old_time,keyframe_next,new_time,keyframe_next);
				}
				//else
				{
					Action::Handle action(ActivepointSetSmart::create());

					action->set_param("canvas",get_canvas());
					action->set_param("canvas_interface",get_canvas_interface());
					action->set_param("value_desc",value_desc);

					Activepoint activepoint;
					try
					{
						activepoint=*value_node_dynamic->list[i].find(old_time);
						activepoint.set_time(new_time);
					}
					catch(...)
					{
						activepoint.set_time(new_time);
						activepoint.set_state(value_node_dynamic->list[i].status_at_time(old_time));
						activepoint.set_priority(0);
					}
					action->set_param("activepoint",activepoint);

					assert(action->is_ready());
					if(!action->is_ready())
						throw Error(Error::TYPE_NOTREADY);

					add_action_front(action);
				}
			}
		}
		else if(ValueNode_Animated::Handle::cast_dynamic(value_node))
		{
			if(new_time>keyframe_prev && new_time<keyframe_next)
			{
					// In this circumstance, we need to adjust any
					// waypoints between the previous and next
					// keyframes
					scale_waypoints(value_desc,keyframe_prev,old_time,keyframe_prev,new_time);
					scale_waypoints(value_desc,old_time,keyframe_next,new_time,keyframe_next);
			}
			//else
			{
				ValueNode_Animated::Handle value_node_animated(ValueNode_Animated::Handle::cast_dynamic(value_node));

				Action::Handle action(WaypointSetSmart::create());

				action->set_param("canvas",get_canvas());
				action->set_param("canvas_interface",get_canvas_interface());
				action->set_param("value_node",ValueNode::Handle(value_node_animated));

				Waypoint waypoint;
				try
				{
					waypoint=*value_node_animated->find(old_time);
					waypoint.set_time(new_time);
				}
				catch(...)
				{
					waypoint.set_time(new_time);
					waypoint.set_value((*value_node_animated)(old_time));
					waypoint.set_before(synfigapp::Main::get_interpolation());
					waypoint.set_after(synfigapp::Main::get_interpolation());
				}
				action->set_param("waypoint",waypoint);

				assert(action->is_ready());
				if(!action->is_ready())
					throw Error(Error::TYPE_NOTREADY);

				add_action_front(action);
			}
		}
	}
}
Example #6
0
void
CanvasTreeStore::set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc, bool do_children)
{
	Gtk::TreeModel::Children children = row.children();
	while(!children.empty() && erase(children.begin()))
		;

	row[model.value_desc]=value_desc;
	try
	{
		//row[model.icon] = get_tree_pixbuf(value_desc.get_value_type());

		if(value_desc.is_value_node())
		{
			ValueNode::Handle value_node=value_desc.get_value_node();

			// todo: if the parent is animated and expanded, and we drag the time slider so that it changes,
			// it's not updated.  it still shows the previous bone valuenode.

			// maybe replace the ValueNode_Const or ValueNode_Animated with the contained ValueNode_Bone
			value_node = expandable_bone_parent(value_node);

			assert(value_node);

			row[model.value_node] = value_node;
			//row[model.is_canvas] = false;
			//row[model.is_value_node] = true;
			//row[model.is_editable] = synfigapp::is_editable(value_node);
			//row[model.id]=value_node->get_id();

			// Set the canvas
			if(value_desc.parent_is_canvas())
				row[model.canvas]=value_desc.get_canvas();
			else
				row[model.canvas]=canvas_interface()->get_canvas();

			LinkableValueNode::Handle linkable;
			// printf("%s:%d value_node = %s\n", __FILE__, __LINE__, value_node->get_description().c_str());
			linkable=LinkableValueNode::Handle::cast_dynamic(value_node);

			// printf("linkable: %d; do_children: %d\n", bool(linkable), bool(do_children));
			if(linkable && do_children)
			{
				row[model.link_count] = linkable->link_count();
				LinkableValueNode::Vocab vocab(linkable->get_children_vocab());
				LinkableValueNode::Vocab::iterator iter(vocab.begin());
				for(int i=0;i<linkable->link_count();i++, iter++)
				{
					if(iter->get_hidden())
						continue;
					Gtk::TreeRow child_row=*(append(row.children()));
					child_row[model.link_id] = i;
					child_row[model.canvas] = static_cast<Canvas::Handle>(row[model.canvas]);
					child_row[model.name] = linkable->link_local_name(i);
					child_row[model.tooltip] = iter->get_description();
					child_row[model.child_param_desc] = *iter;
					set_row(child_row,synfigapp::ValueDesc(linkable,i));
				}
			}
			return;
		}
		else
		{
			//row[model.is_value_node] = false;
			//row[model.is_editable] = true;
			//row[model.label] = Glib::ustring(row[model.name]);
			return;
		}
	}
	catch(synfig::Exception::IDNotFound x)
	{
		synfig::error(__FILE__":%d: IDNotFound thrown",__LINE__);
		erase(row);
		return;
	}

	// We should never get to this point
	assert(0);
}