ValueNode_BoneWeightPair::ValueNode_BoneWeightPair(const ValueBase &value, Canvas::LooseHandle canvas): LinkableValueNode(value.get_type()) { switch(value.get_type()) { case ValueBase::TYPE_BONE_WEIGHT_PAIR: { BoneWeightPair bone_weight_pair(value.get(BoneWeightPair())); ValueBase bone(bone_weight_pair.get_bone()); ValueNode_Bone::Handle bone_value_node; bone_value_node = ValueNode_Bone::create(bone, canvas); set_link("bone",ValueNode_Const::create(bone_value_node, canvas)); set_link("weight",ValueNode_Const::create(Real(bone_weight_pair.get_weight()))); if (getenv("SYNFIG_DEBUG_SET_PARENT_CANVAS")) printf("%s:%d set parent canvas for bwp to %lx\n", __FILE__, __LINE__, uintptr_t(canvas.get())); set_parent_canvas(canvas); ValueNode_Bone::show_bone_map(canvas, __FILE__, __LINE__, "after making new boneweightpair"); break; } default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
ValueNode_Scale::ValueNode_Scale(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("scalar",ValueNode::Handle(ValueNode_Const::create(Real(1.0)))); Type &type(value.get_type()); if (type == type_angle) set_link("link",ValueNode_Const::create(value.get(Angle()))); else if (type == type_color) set_link("link",ValueNode_Const::create(value.get(Color()))); else if (type == type_integer) set_link("link",ValueNode_Const::create(value.get(int()))); else if (type == type_real) set_link("link",ValueNode_Const::create(value.get(Real()))); else if (type == type_time) set_link("link",ValueNode_Const::create(value.get(Time()))); else if (type == type_vector) set_link("link",ValueNode_Const::create(value.get(Vector()))); else { assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+type.description.local_name); } assert(value_node); assert(value_node->get_type()==type); assert(get_type()==type); }
ValueNode_WeightedAverage::ValueNode_WeightedAverage(const ValueBase &value, Canvas::LooseHandle canvas): ValueNode_DynamicList(ValueAverage::convert_to_weighted_type(value.get_type()), value.get_type(), canvas) { if (!check_type(value.get_type())) { assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+value.get_type().description.local_name); } }
ValueNode_Bone::ValueNode_Bone(const ValueBase &value, etl::loose_handle<Canvas> canvas): LinkableValueNode(value.get_type()), setup_(false) { 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); switch(value.get_type()) { case ValueBase::TYPE_BONE: { 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("scalely",ValueNode_Const::create(bone.get_scalely())); set_link("scalex",ValueNode_Const::create(bone.get_scalex())); set_link("scaley",ValueNode_Const::create(bone.get_scaley())); set_link("origin0",ValueNode_Const::create(bone.get_origin0())); set_link("angle0",ValueNode_Const::create(bone.get_angle0())); set_link("length",ValueNode_Const::create(bone.get_length())); set_link("strength",ValueNode_Const::create(bone.get_strength())); #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))); break; } default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
ValueNode_VectorY::ValueNode_VectorY(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_real) set_link("vector",ValueNode_Const::create(Vector(0, value.get(Real())))); else throw Exception::BadType(value.get_type().description.local_name); }
synfig::ValueNode_Add::ValueNode_Add(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("scalar",ValueNode_Const::create(Real(1.0))); Type& type(value.get_type()); if (type == type_angle) { set_link("lhs",ValueNode_Const::create(value.get(Angle()))); set_link("rhs",ValueNode_Const::create(Angle::deg(0))); } else if (type == type_color) { set_link("lhs",ValueNode_Const::create(value.get(Color()))); set_link("rhs",ValueNode_Const::create(Color(0,0,0,0))); } else if (type == type_gradient) { set_link("lhs",ValueNode_Const::create(value.get(Gradient()))); set_link("rhs",ValueNode_Const::create(Gradient())); } else if (type == type_integer) { set_link("lhs",ValueNode_Const::create(value.get(int()))); set_link("rhs",ValueNode_Const::create(int(0))); } else if (type == type_real) { set_link("lhs",ValueNode_Const::create(value.get(Real()))); set_link("rhs",ValueNode_Const::create(Real(0))); } else if (type == type_time) { set_link("lhs",ValueNode_Const::create(value.get(Time()))); set_link("rhs",ValueNode_Const::create(Time(0))); } else if (type == type_vector) { set_link("lhs",ValueNode_Const::create(value.get(Vector()))); set_link("rhs",ValueNode_Const::create(Vector(0,0))); } else { assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+type.description.local_name); } }
synfig::ValueNode_TwoTone::ValueNode_TwoTone(const ValueBase &value):LinkableValueNode(synfig::ValueBase::TYPE_GRADIENT) { Vocab ret(get_children_vocab()); set_children_vocab(ret); switch(value.get_type()) { case ValueBase::TYPE_GRADIENT: set_link("color1",ValueNode_Const::create(value.get(Gradient())(0))); set_link("color2",ValueNode_Const::create(value.get(Gradient())(1))); break; default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
synfig::ValueNode_TwoTone::ValueNode_TwoTone(const ValueBase &value):LinkableValueNode(synfig::type_gradient) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_gradient) { set_link("color1",ValueNode_Const::create(value.get(Gradient())(0))); set_link("color2",ValueNode_Const::create(value.get(Gradient())(1))); } else { throw Exception::BadType(value.get_type().description.local_name); } }
ValueNode_VectorLength::ValueNode_VectorLength(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); switch(value.get_type()) { case ValueBase::TYPE_REAL: set_link("vector",ValueNode_Const::create(Vector(value.get(Real()), 0))); break; default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
ValueNode_Atan2::ValueNode_Atan2(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_angle) { set_link("x",ValueNode_Const::create(Angle::cos(value.get(Angle())).get())); set_link("y",ValueNode_Const::create(Angle::sin(value.get(Angle())).get())); } else { throw Exception::BadType(value.get_type().description.local_name); } }
ValueNode_Exp::ValueNode_Exp(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_real) { set_link("exp",ValueNode_Const::create(Real(0))); set_link("scale",ValueNode_Const::create(value.get(Real()))); } else { throw Exception::BadType(value.get_type().description.local_name); } }
bool Region::set_shape_param(const String & param, const ValueBase &value) { // TODO: move this backward compatibility code to load_canvas if(param=="segment_list") { if(dynamic_param_list().count("segment_list")) { connect_dynamic_param("bline",dynamic_param_list().find("segment_list")->second); disconnect_dynamic_param("segment_list"); synfig::warning("Region::set_param(): Updated valuenode connection to use the new \"bline\" parameter."); } else synfig::warning("Region::set_param(): The parameter \"segment_list\" is deprecated. Use \"bline\" instead."); } if (param=="segment_list" || param=="bline") { if (value.get_type() != type_list) return false; //if (value.get_contained_type()!=type_bline_point) // return false; param_bline=value; return true; } return Layer_Shape::set_shape_param(param, value); }
bool ValueBase::operator==(const ValueBase& rhs)const { if(get_type()!=rhs.get_type()) return false; if(data==rhs.data) return true; switch(get_type()) { case TYPE_TIME: return get(Time()).is_equal(rhs.get(Time())); case TYPE_REAL: return abs(get(Real())-rhs.get(Real()))<=0.00000000000001; case TYPE_INTEGER: return get(int())==rhs.get(int()); case TYPE_BOOL: return get(bool())==rhs.get(bool()); case TYPE_ANGLE: return get(Angle())==rhs.get(Angle()); case TYPE_VECTOR: return get(Vector()).is_equal_to(rhs.get(Vector())); case TYPE_COLOR: return get(Color())==rhs.get(Color()); case TYPE_STRING: return get(String())==rhs.get(String()); case TYPE_CANVAS: return get(Canvas::LooseHandle())==rhs.get(Canvas::LooseHandle()); case TYPE_LIST: return get_list()==rhs.get_list(); case TYPE_VALUENODE_BONE: return get(ValueNode_Bone::Handle())==rhs.get(ValueNode_Bone::Handle()); case TYPE_DASHITEM: return get(DashItem())==rhs.get(DashItem()); case TYPE_SEGMENT: // return get(Segment())==rhs.get(Segment()); case TYPE_GRADIENT: // return get(Gradient())==rhs.get(Gradient()); case TYPE_BONE: // return get(Bone())==rhs.get(Bone()); case TYPE_BLINEPOINT: // return get(BLinePoint())==rhs.get(BLinePoint()); case TYPE_MATRIX: // return get(Matrix())==rhs.get(Matrix()); case TYPE_BONE_WEIGHT_PAIR: // return get(BoneWeightPair())==rhs.get(BoneWeightPair()); case TYPE_WIDTHPOINT: case TYPE_NIL: default: return false; } return false; }
ValueNode_GradientColor::ValueNode_GradientColor(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_color) { set_link("gradient", ValueNode_Const::create(Gradient(value.get(Color()),value.get(Color())))); set_link("index", ValueNode_Const::create(Real(0.5))); set_link("loop", ValueNode_Const::create(bool(false))); } else { throw Exception::BadType(value.get_type().description.local_name); } }
ValueNode_Dynamic::ValueNode_Dynamic(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("origin", ValueNode_Const::create(Vector(0,0))); set_link("force", ValueNode_Const::create(Vector(0,0))); set_link("torque", ValueNode_Const::create(Real(0.0))); set_link("damping", ValueNode_Const::create(Real(0.4))); set_link("friction", ValueNode_Const::create(Real(0.4))); set_link("spring", ValueNode_Const::create(Real(30.0))); set_link("torsion", ValueNode_Const::create(Real(30.0))); set_link("mass", ValueNode_Const::create(Real(0.3))); set_link("inertia", ValueNode_Const::create(Real(0.3))); set_link("spring_rigid",ValueNode_Const::create(false)); set_link("torsion_rigid",ValueNode_Const::create(false)); set_link("origin_drags_tip",ValueNode_Const::create(true)); if (get_type() == type_vector) set_link("tip_static",ValueNode_Const::create(value.get(Vector()))); else throw Exception::BadType(get_type().description.local_name); /* Initial values*/ state.resize(4); reset_state(Time(0.0)); /*Derivative of the base position*/ origin_d_=ValueNode_Derivative::create(ValueBase(Vector())); origin_d_->set_link("order", ValueNode_Const::create((int)(ValueNode_Derivative::SECOND))); /* Initialize the last time called to be 0*/ last_time=Time(0); }
void ValueAverage::set_average_value_weighted(ValueBase &weighted_list, const ValueBase &value) { if (weighted_list.get_type() != type_list) return; ValueBase::List list = weighted_list.get_list(); if (list.empty()) return; types_namespace::TypeWeightedValueBase *t = dynamic_cast<types_namespace::TypeWeightedValueBase *>(&(list.front().get_type())); if (t == NULL) return; if (!check_weighted_type(*t)) return; ValueBase::List values_list; values_list.reserve(list.size()); std::vector<Real> weights_list; weights_list.reserve(list.size()); for(ValueBase::List::const_iterator i = list.begin(); i != list.end(); ++i) { if (i->get_type() != *t) return; weights_list.push_back( t->extract_weight(*i) ); values_list.push_back( t->extract_value(*i) ); } set_average_value_generic( values_list.begin(), values_list.end(), weights_list.begin(), weights_list.end(), value ); std::vector<Real>::const_iterator j = weights_list.begin(); for(ValueBase::List::const_iterator i = values_list.begin(); i != values_list.end(); ++i, ++j) list[i - values_list.begin()] = t->create_weighted_value(*j, *i); weighted_list = list; }
ValueNode_Linear::ValueNode_Linear(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); switch(get_type()) { case ValueBase::TYPE_ANGLE: set_link("slope",ValueNode_Const::create(Angle::deg(0))); set_link("offset",ValueNode_Const::create(value.get(Angle()))); break; case ValueBase::TYPE_COLOR: set_link("slope",ValueNode_Const::create(Color(0,0,0,0))); set_link("offset",ValueNode_Const::create(value.get(Color()))); break; case ValueBase::TYPE_INTEGER: set_link("slope",ValueNode_Const::create(int(0))); set_link("offset",ValueNode_Const::create(value.get(int()))); break; case ValueBase::TYPE_REAL: set_link("slope",ValueNode_Const::create(Real(0))); set_link("offset",ValueNode_Const::create(value.get(Real()))); break; case ValueBase::TYPE_TIME: set_link("slope",ValueNode_Const::create(Time(0))); set_link("offset",ValueNode_Const::create(value.get(Time()))); break; case ValueBase::TYPE_VECTOR: set_link("slope",ValueNode_Const::create(Vector(0,0))); set_link("offset",ValueNode_Const::create(value.get(Vector()))); break; default: throw Exception::BadType(ValueBase::type_local_name(get_type())); } }
ValueNode_IntString::ValueNode_IntString(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_string) { set_link("int",ValueNode_Const::create(int(0))); set_link("width",ValueNode_Const::create(int(0))); set_link("zero_pad",ValueNode_Const::create(bool(false))); } else { throw Exception::BadType(value.get_type().description.local_name); } }
synfig::ValueNode_RadialComposite::ValueNode_RadialComposite(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); Type &type(get_type()); if (type == type_vector) { Vector vect(value.get(Vector())); set_link("r",ValueNode_Const::create(vect.mag())); set_link("t",ValueNode_Const::create(Angle(Angle::tan(vect[1],vect[0])))); } else if (type == type_color) { set_link("y",ValueNode_Const::create(value.get(Color()).get_y())); set_link("s",ValueNode_Const::create(value.get(Color()).get_s())); set_link("h",ValueNode_Const::create(value.get(Color()).get_hue())); set_link("a",ValueNode_Const::create(value.get(Color()).get_a())); } else { assert(0); throw Exception::BadType(type.description.local_name); } }
bool CurveGradient::set_param(const String & param, const ValueBase &value) { IMPORT_VALUE(param_origin); IMPORT_VALUE(param_width); if(param=="bline" && value.get_type()==ValueBase::TYPE_LIST) { param_bline=value; bline_loop=value.get_loop(); sync(); return true; } IMPORT_VALUE(param_gradient); IMPORT_VALUE(param_loop); IMPORT_VALUE(param_zigzag); IMPORT_VALUE(param_perpendicular); IMPORT_VALUE(param_fast); if(param=="offset") return set_param("origin", value); return Layer_Composite::set_param(param,value); }
ValueNode_RealString::ValueNode_RealString(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); switch(value.get_type()) { case ValueBase::TYPE_STRING: set_link("real",ValueNode_Const::create(Real(0))); set_link("width",ValueNode_Const::create(int(0))); set_link("precision",ValueNode_Const::create(int(3))); set_link("zero_pad",ValueNode_Const::create(bool(false))); break; default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
synfig::ValueNode_Range::ValueNode_Range(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); Type &type(value.get_type()); if (type == type_angle) { set_link("min",ValueNode_Const::create(value.get(Angle()))); set_link("max",ValueNode_Const::create(value.get(Angle()))); set_link("link",ValueNode_Const::create(value.get(Angle()))); } else if (type == type_integer) { set_link("min",ValueNode_Const::create(value.get(int()))); set_link("max",ValueNode_Const::create(value.get(int()))); set_link("link",ValueNode_Const::create(value.get(int()))); } else if (type == type_real) { set_link("min",ValueNode_Const::create(value.get(Real()))); set_link("max",ValueNode_Const::create(value.get(Real()))); set_link("link",ValueNode_Const::create(value.get(Real()))); } else if (type == type_time) { set_link("min",ValueNode_Const::create(value.get(Time()))); set_link("max",ValueNode_Const::create(value.get(Time()))); set_link("link",ValueNode_Const::create(value.get(Time()))); } else { assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+type.description.local_name); } assert(min_->get_type()==type); assert(max_->get_type()==type); assert(link_->get_type()==type); assert(get_type()==type); }
LinkableValueNode::Handle LinkableValueNode::create(const String &name, const ValueBase& x) { if(!book().count(name)) return 0; if (!check_type(name, x.get_type()) && // the Duplicate ValueNode is an exception - we don't want the // user creating it for themselves, so check_type() fails for // it even when it is valid !(name == "duplicate" && x.get_type() == ValueBase::TYPE_REAL)) { error(_("Bad type: ValueNode '%s' doesn't accept type '%s'"), book()[name].local_name.c_str(), ValueBase::type_local_name(x.get_type()).c_str()); return 0; } return book()[name].factory(x); }
xmlpp::Element* encode_animated(xmlpp::Element* root,ValueNode_Animated::ConstHandle value_node,Canvas::ConstHandle canvas=0) { assert(value_node); root->set_name("animated"); root->set_attribute("type",ValueBase::type_name(value_node->get_type())); const ValueNode_Animated::WaypointList &waypoint_list=value_node->waypoint_list(); ValueNode_Animated::WaypointList::const_iterator iter; encode_interpolation(root, value_node->get_interpolation(), "interpolation"); for(iter=waypoint_list.begin();iter!=waypoint_list.end();++iter) { xmlpp::Element *waypoint_node=root->add_child("waypoint"); waypoint_node->set_attribute("time",iter->get_time().get_string()); if(iter->get_value_node()->is_exported()) waypoint_node->set_attribute("use",iter->get_value_node()->get_relative_id(canvas)); else { ValueNode::ConstHandle value_node = iter->get_value_node(); if(ValueNode_Const::ConstHandle::cast_dynamic(value_node)) { const ValueBase data = ValueNode_Const::ConstHandle::cast_dynamic(value_node)->get_value(); if (data.get_type() == ValueBase::TYPE_CANVAS) waypoint_node->set_attribute("use",data.get(Canvas::Handle()).get()->get_relative_id(canvas)); else encode_value_node(waypoint_node->add_child("value_node"),iter->get_value_node(),canvas); } else encode_value_node(waypoint_node->add_child("value_node"),iter->get_value_node(),canvas); } if (iter->get_before()!=INTERPOLATION_UNDEFINED) encode_interpolation(waypoint_node,iter->get_before(),"before"); else error("Unknown waypoint type for \"before\" attribute"); if (iter->get_after()!=INTERPOLATION_UNDEFINED) encode_interpolation(waypoint_node,iter->get_after(),"after"); else error("Unknown waypoint type for \"after\" attribute"); if(iter->get_tension()!=0.0) waypoint_node->set_attribute("tension",strprintf("%f",iter->get_tension())); if(iter->get_temporal_tension()!=0.0) waypoint_node->set_attribute("temporal-tension",strprintf("%f",iter->get_temporal_tension())); if(iter->get_continuity()!=0.0) waypoint_node->set_attribute("continuity",strprintf("%f",iter->get_continuity())); if(iter->get_bias()!=0.0) waypoint_node->set_attribute("bias",strprintf("%f",iter->get_bias())); } return root; }
ValueNode_DotProduct::ValueNode_DotProduct(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); switch(value.get_type()) { case ValueBase::TYPE_REAL: set_link("lhs",ValueNode_Const::create(Vector(value.get(Real()),0))); set_link("rhs",ValueNode_Const::create(Vector(1,0))); break; case ValueBase::TYPE_ANGLE: set_link("lhs",ValueNode_Const::create(Vector(Angle::cos(value.get(Angle())).get(), Angle::sin(value.get(Angle())).get()))); set_link("rhs",ValueNode_Const::create(Vector(1,0))); break; default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
synfig::ValueNode_Add::ValueNode_Add(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("scalar",ValueNode_Const::create(Real(1.0))); ValueBase::Type id(value.get_type()); switch(id) { case ValueBase::TYPE_ANGLE: set_link("lhs",ValueNode_Const::create(value.get(Angle()))); set_link("rhs",ValueNode_Const::create(Angle::deg(0))); break; case ValueBase::TYPE_COLOR: set_link("lhs",ValueNode_Const::create(value.get(Color()))); set_link("rhs",ValueNode_Const::create(Color(0,0,0,0))); break; case ValueBase::TYPE_GRADIENT: set_link("lhs",ValueNode_Const::create(value.get(Gradient()))); set_link("rhs",ValueNode_Const::create(Gradient())); break; case ValueBase::TYPE_INTEGER: set_link("lhs",ValueNode_Const::create(value.get(int()))); set_link("rhs",ValueNode_Const::create(int(0))); break; case ValueBase::TYPE_REAL: set_link("lhs",ValueNode_Const::create(value.get(Real()))); set_link("rhs",ValueNode_Const::create(Real(0))); break; case ValueBase::TYPE_TIME: set_link("lhs",ValueNode_Const::create(value.get(Time()))); set_link("rhs",ValueNode_Const::create(Time(0))); break; case ValueBase::TYPE_VECTOR: set_link("lhs",ValueNode_Const::create(value.get(Vector()))); set_link("rhs",ValueNode_Const::create(Vector(0,0))); break; default: assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+ValueBase::type_local_name(id)); } }
ValueNode_Duplicate::ValueNode_Duplicate(const ValueBase &x): LinkableValueNode(x.get_type()), index(1.0) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("from", ValueNode_Const::create(Real(1.0))); set_link("to", ValueNode_Const::create(x.get(Real()))); set_link("step", ValueNode_Const::create(Real(1.0))); }
ValueNode_DotProduct::ValueNode_DotProduct(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); Type &type(value.get_type()); if (type == type_real) { set_link("lhs",ValueNode_Const::create(Vector(value.get(Real()),0))); set_link("rhs",ValueNode_Const::create(Vector(1,0))); } else if (type == type_angle) { set_link("lhs",ValueNode_Const::create(Vector(Angle::cos(value.get(Angle())).get(), Angle::sin(value.get(Angle())).get()))); set_link("rhs",ValueNode_Const::create(Vector(1,0))); } throw Exception::BadType(value.get_type().description.local_name); }
ValueNode_Real::ValueNode_Real(const ValueBase &x): LinkableValueNode(x.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); switch(x.get_type()) { case ValueBase::TYPE_ANGLE: set_link("link", ValueNode_Const::create(Angle::deg(x.get(Angle())).get())); break; case ValueBase::TYPE_BOOL: set_link("link", ValueNode_Const::create(float(x.get(bool())))); break; case ValueBase::TYPE_INTEGER: set_link("link", ValueNode_Const::create(float(x.get(int())))); break; default: assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+ValueBase::type_local_name(x.get_type())); } }
ValueNode_Or::ValueNode_Or(const ValueBase &x): LinkableValueNode(x.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); bool value(x.get(bool())); set_link("link1", ValueNode_Const::create(bool(false))); set_link("link2", ValueNode_Const::create(bool(false))); if (value) set_link("link1",ValueNode_Const::create(bool(true))); }