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 Layer_Composite::set_param(const String & param, const ValueBase &value) { if(param=="amount" && value.same_type_as(amount)) { amount=value.get(amount); set_param_static(param,value.get_static()); } else if(param=="blend_method" && value.same_type_as(int())) { blend_method = static_cast<Color::BlendMethod>(value.get(int())); set_param_static(param,value.get_static()); if (blend_method < 0 || blend_method >= Color::BLEND_END) { warning("illegal value (%d) for blend_method - using Composite instead", blend_method); blend_method = Color::BLEND_COMPOSITE; return false; } if (blend_method == Color::BLEND_STRAIGHT && !reads_context()) { Canvas::Handle canvas(get_canvas()); if (canvas) { String version(canvas->get_version()); if (version == "0.1" || version == "0.2") { if (get_name() == "PasteCanvas") warning("loaded a version %s canvas with a 'Straight' blended PasteCanvas (%s) - check it renders OK", version.c_str(), get_non_empty_description().c_str()); else { blend_method = Color::BLEND_COMPOSITE; converted_blend_ = true; // if this layer has a transparent color, go back and set the color again // now that we know we are converting the blend method as well. that will // make the color non-transparent, and change the blend method to alpha over if (transparent_color_) set_param("color", get_param("color")); } } } } } else return Layer::set_param(param,value); return true; }
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); }
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_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())); } }
bool Advanced_Outline::set_param(const String & param, const ValueBase &value) { IMPORT_VALUE(param_bline); IMPORT_VALUE(param_wplist); IMPORT_VALUE(param_dilist); IMPORT_VALUE(param_start_tip); IMPORT_VALUE(param_end_tip); IMPORT_VALUE(param_cusp_type); IMPORT_VALUE(param_width); IMPORT_VALUE(param_expand); IMPORT_VALUE_PLUS(param_smoothness, { if(value.get(Real()) > 1.0) param_smoothness.set(Real(1.0)); else if(value.get(Real()) < 0.0) param_smoothness.set(Real(0.0)); } );
bool Layer_PasteCanvas::set_param(const String & param, const ValueBase &value) { IMPORT_VALUE(param_origin); IMPORT_VALUE(param_focus); // IMPORT(canvas); if(param=="canvas" && value.same_type_as(Canvas::Handle())) { set_sub_canvas(value.get(Canvas::Handle())); return true; } //! \todo this introduces bug 1844764 if enabled; it was introduced in r954. // http://synfig.org/images/3/3d/Moving-waypoints.sifz is an // example of an animation that has its waypoints displayed // incorrectly without this fix; select the outer layer and drag // the time slider. The linear waypoints don't take effect until // 5s, but the time slider appears to pass the first one at 3s. #if 0 if (param=="time_offset" && value.same_type_as(time_offset)) { if (time_offset != value.get(Time())) { value.put(&time_offset); // notify that the time_offset has changed so we can update the // waypoint positions in parent layers changed(); } return true; } #else IMPORT_VALUE(param_time_offset); #endif IMPORT_VALUE(param_children_lock); IMPORT_VALUE(param_zoom); IMPORT_VALUE(param_outline_grow); IMPORT_VALUE(param_curr_time); IMPORT_VALUE(param_z_range); IMPORT_VALUE(param_z_range_position); IMPORT_VALUE(param_z_range_depth); IMPORT_VALUE(param_z_range_blur); return Layer_Composite::set_param(param,value); }
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())); } }
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); }
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_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))); }
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_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())); } }
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); } }
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); }
bool synfig::Layer_Bitmap::set_param(const String & param, const ValueBase & value) { IMPORT_VALUE(param_tl); IMPORT_VALUE(param_br); IMPORT_VALUE(param_c); IMPORT_VALUE_PLUS(param_gamma_adjust, if(param=="gamma_adjust"&& value.get_type()==ValueBase::TYPE_REAL) { param_gamma_adjust.set(Real(1.0/value.get(Real()))); return true; } );
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_Integer::ValueNode_Integer(const ValueBase &x): LinkableValueNode(x.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); Type &type(x.get_type()); if (type == type_angle) set_link("link", ValueNode_Const::create(round_to_int(Angle::deg(x.get(Angle())).get()))); else if (type == type_bool) set_link("link", ValueNode_Const::create(int(x.get(bool())))); else if (type == type_real) set_link("link", ValueNode_Const::create(round_to_int(x.get(Real())))); else if (type == type_time) set_link("link", ValueNode_Const::create(round_to_int(x.get(Time())))); else { assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+x.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())); } }
bool Rotate::set_param(const String & param, const ValueBase &value) { IMPORT_VALUE(param_origin); IMPORT_VALUE_PLUS(param_amount, { Angle amount=value.get(Angle()); sin_val=Angle::sin(amount).get(); cos_val=Angle::cos(amount).get(); param_amount.set(amount); return true; } );
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); } }
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_Logarithm::ValueNode_Logarithm(const ValueBase &x): LinkableValueNode(x.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); Real value(x.get(Real())); Real infinity(999999.0); Real epsilon(0.000001); value = exp(value); set_link("link", ValueNode_Const::create(Real(value))); set_link("epsilon", ValueNode_Const::create(Real(epsilon))); set_link("infinite", ValueNode_Const::create(Real(infinity))); }
ValueNode_Derivative::ValueNode_Derivative(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("interval", ValueNode_Const::create(Real(0.01))); // Default interval set_link("accuracy", ValueNode_Const::create((int)(NORMAL))); set_link("order", ValueNode_Const::create((int)(FIRST))); Type &type(get_type()); 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_angle) set_link("link",ValueNode_Const::create(value.get(Angle()))); else if (type == type_vector) set_link("link",ValueNode_Const::create(value.get(Vector()))); else throw Exception::BadType(type.description.local_name); }
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); }
ValueNode_Compare::ValueNode_Compare(const ValueBase &x): LinkableValueNode(x.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); bool value(x.get(bool())); set_link("lhs", ValueNode_Const::create(Real(0))); set_link("rhs", ValueNode_Const::create(Real(0))); set_link("greater", ValueNode_Const::create(bool(false))); if (value) set_link("equal",ValueNode_Const::create(bool(true))); else set_link("equal",ValueNode_Const::create(bool(false))); set_link("less", ValueNode_Const::create(bool(false))); }