本文整理汇总了C++中ValueBase类的典型用法代码示例。如果您正苦于以下问题:C++ ValueBase类的具体用法?C++ ValueBase怎么用?C++ ValueBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ValueBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LinkableValueNode
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);
}
开发者ID:ChillyCider,项目名称:synfig-reloaded,代码行数:35,代码来源:valuenode_dynamic.cpp
示例2: IMPORT_VALUE
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);
}
开发者ID:jlssepulveda,项目名称:synfig,代码行数:25,代码来源:curvegradient.cpp
示例3: set_average_value_generic
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;
}
开发者ID:ChillyCider,项目名称:synfig-reloaded,代码行数:30,代码来源:valueoperations.cpp
示例4: ret
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);
}
}
开发者ID:BakaMANIA,项目名称:synfig,代码行数:26,代码来源:valuenode_radialcomposite.cpp
示例5: size
Real
synfig::bline_length(const ValueBase &bline, bool bline_loop, std::vector<Real> *lengths)
{
BLinePoint blinepoint0, blinepoint1;
const std::vector<BLinePoint> list(bline.get_list().begin(),bline.get_list().end());
int size(list.size());
if(!bline_loop) size--;
if(size < 1) return Real();
// Calculate the lengths and the total length
Real tl(0), l;
vector<BLinePoint>::const_iterator iter, next(list.begin());
iter = bline_loop ? --list.end() : next++;
for(;next!=list.end(); next++)
{
blinepoint0 = *iter;
blinepoint1 = *next;
etl::hermite<Vector> curve(blinepoint0.get_vertex(), blinepoint1.get_vertex(),
blinepoint0.get_tangent2(), blinepoint1.get_tangent1());
l=curve.length();
if(lengths) lengths->push_back(l);
tl+=l;
iter=next;
}
return tl;
}
开发者ID:breaklyn,项目名称:synfig-osx,代码行数:25,代码来源:valuenode_bline.cpp
示例6: operator
bool operator()( const util::Value<T> &first, const ValueBase &second )const {
// ask second for a converter from itself to Value<T>
const ValueBase::Converter conv = second.getConverterTo( util::Value<T>::staticID );
if ( conv ) {
//try to convert second into T and handle results
util::Value<T> buff;
switch ( conv->convert( second, buff ) ) {
case boost::numeric::cPosOverflow:
LOG( Debug, info ) << "Positive overflow when converting " << second.toString( true ) << " to " << util::Value<T>::staticName() << ".";
return posOverflow( first, buff );
case boost::numeric::cNegOverflow:
LOG( Debug, info ) << "Negative overflow when converting " << second.toString( true ) << " to " << util::Value<T>::staticName() << ".";
return negOverflow( first, buff );
case boost::numeric::cInRange:
return inRange( first, buff );
}
} else {
LOG( Debug, error ) << "No conversion of " << second.getTypeName() << " to " << util::Value<T>::staticName() << " available";
return false;
}
return false;
}
开发者ID:rollwurst,项目名称:isis,代码行数:25,代码来源:type.hpp
示例7: LinkableValueNode
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()));
}
}
开发者ID:aaronaskew,项目名称:synfig,代码行数:26,代码来源:valuenode_boneweightpair.cpp
示例8: while
ValueBase* NIfElseStatement::codeGen(CodeGenContext& context)
{
ValueBase* test = condExpr->codeGen( context );
BasicBlock *btrue = BasicBlock::Create(getGlobalContext(), "thenBlock", context.currentFunction);
BasicBlock *bfalse = BasicBlock::Create(getGlobalContext(), "elseBlock", context.currentFunction);
BasicBlock *bmerge = BasicBlock::Create(getGlobalContext(), "mergeStmt", context.currentFunction);
auto ret = llvm::BranchInst::Create(btrue,bfalse,test->getValue(), context.currentBlock());
auto oldBlock = context.currentBlock();
context.pushBlock(btrue);
auto retThen = thenBlock->codeGen(context);
if (retThen == NULL){
llvm::BranchInst::Create(bmerge,context.currentBlock());
}
while (context.currentBlock() != oldBlock){
context.popBlock();
}
oldBlock = context.currentBlock();
context.pushBlock(bfalse);
ValueBase * retElse = NULL;
if (elseBlock != NULL)
{
retElse = elseBlock->codeGen(context);
}
if (retElse == NULL){
llvm::BranchInst::Create(bmerge,context.currentBlock());
}
while (context.currentBlock() != oldBlock){
context.popBlock();
}
context.pushBlock(bmerge);
return NULL;
}
开发者ID:yukunxie,项目名称:cats,代码行数:35,代码来源:codegen.cpp
示例9: makeArrayRef
ValueBase* NFunctionDeclaration::codeGen(CodeGenContext& context, const std::vector<llvm::Type*> &argTypes)
{
FunctionType *ftype = FunctionType::get(typeOf(type), makeArrayRef(argTypes), false);
Function *function = Function::Create(ftype, GlobalValue::InternalLinkage, id.name.c_str(), context.module);
BasicBlock *bblock = BasicBlock::Create(getGlobalContext(), "entry", function, 0);
Function *oldFunction = context.currentFunction;
context.currentFunction = function;
auto oldBlock = context.currentBlock();
context.pushBlock(bblock);
Function::arg_iterator argsValues = function->arg_begin();
Value* argumentValue;
VariableList::const_iterator it;
std::vector<llvm::Type*>::const_iterator itType = argTypes.begin();
for (it = arguments.begin(); it != arguments.end(); it++) {
argumentValue = argsValues++;
itType = itType ++;
AllocaInst *alloc = new AllocaInst(*itType, (*it)->name.c_str(), context.currentBlock());
ValueBase* value = new LongValue(alloc);
context.locals()[(*it)->name] = value;
new StoreInst(argumentValue, value->getValue(), false, context.currentBlock());
}
block.codeGen(context);
while (context.currentBlock() != oldBlock)
context.popBlock();
context.currentFunction = oldFunction;
return new FunctionValue(function);
}
开发者ID:yukunxie,项目名称:cats,代码行数:35,代码来源:codegen.cpp
示例10: canHoistArrayArgument
static bool canHoistArrayArgument(ApplyInst *SemanticsCall, SILValue Arr,
SILInstruction *InsertBefore,
DominanceInfo *DT) {
// We only know how to hoist inout, owned or guaranteed parameters.
auto Convention = getSelfParameterConvention(SemanticsCall);
if (Convention != ParameterConvention::Indirect_Inout &&
Convention != ParameterConvention::Direct_Owned &&
Convention != ParameterConvention::Direct_Guaranteed)
return false;
ValueBase *SelfVal = Arr;
auto *SelfBB = SelfVal->getParentBlock();
if (DT->dominates(SelfBB, InsertBefore->getParent()))
return true;
if (auto LI = dyn_cast<LoadInst>(SelfVal)) {
// Are we loading a value from an address in a struct defined at a point
// dominating the hoist point.
auto Val = LI->getOperand();
bool DoesNotDominate;
StructElementAddrInst *SEI;
while ((DoesNotDominate = !DT->dominates(Val->getParentBlock(),
InsertBefore->getParent())) &&
(SEI = dyn_cast<StructElementAddrInst>(Val)))
Val = SEI->getOperand();
return !DoesNotDominate;
}
return false;
}
开发者ID:stephentyrone,项目名称:swift,代码行数:31,代码来源:ArraySemantic.cpp
示例11: runtime_error
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);
}
}
开发者ID:BakaMANIA,项目名称:synfig,代码行数:9,代码来源:valuenode_weightedaverage.cpp
示例12: LinkableValueNode
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()));
}
}
开发者ID:aaronaskew,项目名称:synfig,代码行数:57,代码来源:valuenode_bone.cpp
示例13: encode_animated
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;
}
开发者ID:aaronaskew,项目名称:synfig,代码行数:56,代码来源:savecanvas.cpp
示例14: codeGen
ValueBase* NIdentifier::codeGen(CodeGenContext& context)
{
//std::cout << "Creating identifier reference: " << name << endl;
ValueBase *value = context.getVar(name);
if (value == NULL) {
return NULL;
}
return createValue(value->getType(), new LoadInst(value->getValue(), "", false, context.currentBlock()));
}
开发者ID:yukunxie,项目名称:cats,代码行数:10,代码来源:codegen.cpp
示例15: ret
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)));
}
开发者ID:blackwarthog,项目名称:synfig,代码行数:10,代码来源:valuenode_duplicate.cpp
示例16: ret
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);
}
开发者ID:blackwarthog,项目名称:synfig,代码行数:10,代码来源:valuenode_vectory.cpp
示例17: ret
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)));
}
开发者ID:ChillyCider,项目名称:synfig-reloaded,代码行数:12,代码来源:valuenode_or.cpp
示例18:
Array::Array(const Array &obj)
{
for (KeyValueVector::const_iterator it = obj.vector.begin(); it != obj.vector.end(); ++it) {
ValueBase *v = *it;
push(v);
const std::string& n = v->getName();
if (n.length()) updateIndex(n, v);
}
#if DBG
fprintf(stderr, "%s(copy) %lu\n", __func__, vector.size());
#endif
}
开发者ID:mkrufky,项目名称:libdvbtee,代码行数:12,代码来源:array.cpp
示例19: int_pos
Real
synfig::std_to_hom(const ValueBase &bline, Real pos, bool index_loop, bool bline_loop)
{
BLinePoint blinepoint0, blinepoint1;
const std::vector<BLinePoint> list(bline.get_list().begin(),bline.get_list().end());
int size = list.size(), from_vertex;
// trivial cases
if(pos == 0.0 || pos == 1.0)
return pos;
if(!bline_loop) size--;
if(size < 1) return Real();
Real int_pos((int)pos);
Real one(0.0);
if (index_loop)
{
pos = pos - int_pos;
if (pos < 0)
{
pos++;
one=1.0;
}
}
else
{
if (pos < 0) pos = 0;
if (pos > 1) pos = 1;
}
// Calculate the lengths and the total length
Real tl=0, pl=0;
std::vector<Real> lengths;
vector<BLinePoint>::const_iterator iter, next;
tl=bline_length(bline, bline_loop, &lengths);
// If the total length of the bline is zero return pos
if(tl==0.0) return pos;
from_vertex = int(pos*size);
// Calculate the partial length until the bezier that holds the current
std::vector<Real>::const_iterator liter(lengths.begin());
for(int i=0;i<from_vertex; i++, liter++)
pl+=*liter;
// Calculate the remaining length of the position over current bezier
// Setup the curve of the current bezier.
next=list.begin();
iter = bline_loop ? --list.end() : next++;
if (from_vertex > size-1) from_vertex = size-1; // if we are at the end of the last bezier
blinepoint0 = from_vertex ? *(next+from_vertex-1) : *iter;
blinepoint1 = *(next+from_vertex);
etl::hermite<Vector> curve(blinepoint0.get_vertex(), blinepoint1.get_vertex(),
blinepoint0.get_tangent2(), blinepoint1.get_tangent1());
// add the distance on the bezier we are on.
pl+=curve.find_distance(0.0, pos*size - from_vertex);
// and return the homogenous position
return int_pos+pl/tl-one;
}
开发者ID:breaklyn,项目名称:synfig-osx,代码行数:53,代码来源:valuenode_bline.cpp
示例20: IMPORT_VALUE
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;
}
);
开发者ID:aaronaskew,项目名称:synfig,代码行数:13,代码来源:layer_bitmap.cpp
注:本文中的ValueBase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论