String ValueNode::get_relative_id(etl::loose_handle<const Canvas> x)const { assert(is_exported()); assert(canvas_); if(x.get()==canvas_.get()) return get_id(); return canvas_->_get_relative_id(x)+':'+get_id(); }
bool Layer::connect_dynamic_param(const String& param, etl::loose_handle<ValueNode> value_node) { if (!value_node) return disconnect_dynamic_param(param); ValueNode::Handle previous; DynamicParamList::iterator i = dynamic_param_list_.find(param); if (i != dynamic_param_list_.end()) previous = i->second; if (previous == value_node) return true; String param_noref = param; dynamic_param_list_[param]=ValueNode::Handle(value_node); if (previous) { // fix 2353284: if two parameters in the same layer are // connected to the same valuenode and we disconnect one of // them, the parent-child relationship for the remaining // connection was being deleted. now we search the parameter // list to see if another parameter uses the same valuenode DynamicParamList::const_iterator iter; for (iter = dynamic_param_list().begin(); iter != dynamic_param_list().end(); iter++) if (iter->second == previous) break; if (iter == dynamic_param_list().end()) remove_child(previous.get()); } add_child(value_node.get()); if(!value_node->is_exported() && get_canvas()) value_node->set_parent_canvas(get_canvas()); dynamic_param_changed(param); changed(); return true; }
bool Layer::connect_dynamic_param(const String& param, etl::loose_handle<ValueNode> value_node) { ValueNode::Handle previous(dynamic_param_list_[param]); if(previous==value_node) return true; dynamic_param_list_[param]=ValueNode::Handle(value_node); if(previous) remove_child(previous.get()); add_child(value_node.get()); if(!value_node->is_exported() && get_canvas()) { value_node->set_parent_canvas(get_canvas()); } changed(); return true; }
void ValueNode_Bone::set_root_canvas(etl::loose_handle<Canvas> canvas) { GUID guid(get_guid()); Canvas::LooseHandle old_canvas(get_root_canvas()); show_bone_map(old_canvas, __FILE__, __LINE__, strprintf("before changing canvas from %lx to (%lx)", uintptr_t(old_canvas.get()), uintptr_t(canvas.get()))); LinkableValueNode::set_root_canvas(canvas); Canvas::LooseHandle new_canvas(get_root_canvas()); // it isn't necessarily what we passed in, because set_root_canvas walks up to the root if (new_canvas != old_canvas) { if (!canvas_map[old_canvas].count(guid)) warning("%s:%d the node we're moving (%lx) isn't in the map", __FILE__, __LINE__, uintptr_t(this)); canvas_map[new_canvas][guid] = canvas_map[old_canvas][guid]; canvas_map[old_canvas].erase(guid); show_bone_map(new_canvas, __FILE__, __LINE__, strprintf("after changing canvas from %lx to %lx", uintptr_t(old_canvas.get()), uintptr_t(new_canvas.get()))); } else if (getenv("SYNFIG_DEBUG_BONE_MAP")) printf("%s:%d canvases are the same\n", __FILE__, __LINE__); }
ValueNode_Bone::ValueNode_Bone(const ValueBase &value, etl::loose_handle<Canvas> canvas): LinkableValueNode(value.get_type()) { if (getenv("SYNFIG_DEBUG_BONE_CONSTRUCTORS")) { printf("\n%s:%d ------------------------------------------------------------------------\n", __FILE__, __LINE__); printf("%s:%d --- ValueNode_Bone() for %s at %lx---\n", __FILE__, __LINE__, GET_GUID_CSTR(get_guid()), uintptr_t(this)); printf("%s:%d ------------------------------------------------------------------------\n\n", __FILE__, __LINE__); } Vocab ret(get_children_vocab()); set_children_vocab(ret); Type &type = value.get_type(); if (type == type_bone_object) { Bone bone(value.get(Bone())); String name(bone.get_name()); if (name.empty()) name = strprintf(_("Bone %d"), ++bone_counter); name = unique_name(name); set_link("name",ValueNode_Const::create(name)); #ifndef HIDE_BONE_FIELDS set_link("origin",ValueNode_Const::create(bone.get_origin())); set_link("angle",ValueNode_Const::create(bone.get_angle())); set_link("scalelx",ValueNode_Const::create(bone.get_scalelx())); set_link("scalex",ValueNode_Const::create(bone.get_scalex())); set_link("length",ValueNode_Const::create(bone.get_length())); set_link("width",ValueNode_Const::create(bone.get_width())); set_link("tipwidth",ValueNode_Const::create(bone.get_tipwidth())); set_link("bone_depth",ValueNode_Const::create(bone.get_depth())); #endif ValueNode_Bone::ConstHandle parent(ValueNode_Bone::Handle::cast_const(bone.get_parent())); if (!parent) parent = get_root_bone(); set_link("parent",ValueNode_Const::create(ValueNode_Bone::Handle::cast_const(parent))); if (getenv("SYNFIG_DEBUG_BONE_MAP")) printf("%s:%d adding to canvas_map\n", __FILE__, __LINE__); canvas_map[get_root_canvas()][get_guid()] = this; if (getenv("SYNFIG_DEBUG_SET_PARENT_CANVAS")) printf("%s:%d set parent canvas for bone %lx to %lx\n", __FILE__, __LINE__, uintptr_t(this), uintptr_t(canvas.get())); set_parent_canvas(canvas); show_bone_map(get_root_canvas(), __FILE__, __LINE__, strprintf("in constructor of %s at %lx", GET_GUID_CSTR(get_guid()), uintptr_t(this))); } else { throw Exception::BadType(value.get_type().description.local_name); } }
void ValueNode_StaticList::set_member_canvas(etl::loose_handle<Canvas> canvas) // line 723 { for (vector<ReplaceableListEntry>::iterator iter = list.begin(); iter != list.end(); iter++) { if (getenv("SYNFIG_DEBUG_SET_PARENT_CANVAS")) printf("%s:%d set parent canvas of member (%lx) to (%lx)\n", __FILE__, __LINE__, uintptr_t((*iter).get()), uintptr_t(canvas.get())); (*iter)->set_parent_canvas(canvas); } }