• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ofAbstractParameter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ofAbstractParameter的典型用法代码示例。如果您正苦于以下问题:C++ ofAbstractParameter类的具体用法?C++ ofAbstractParameter怎么用?C++ ofAbstractParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ofAbstractParameter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: serialize

void ofXml::serialize(const ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	string name = parameter.getEscapedName();
	if(name=="") name="UnknownName";
	if(parameter.type()==typeid(ofParameterGroup).name()){
		const ofParameterGroup & group = static_cast<const ofParameterGroup&>(parameter);
		if(!exists(name)){
			addChild(name);
			ofLogVerbose("ofXml") << "creating group " << name;
		}
		setTo(name);
		ofLogVerbose("ofXml") << "group " << name;
		for(int i=0;i<group.size();i++){
			serialize(group.get(i));
		}
		ofLogVerbose("ofXml") << "end group " << name;
		setToParent();
	}else{
		string value = parameter.toString();
		if(!exists(name)){
			addChild(name);
			ofLogVerbose("ofXml") << "creating tag " << name;
		}
		ofLogVerbose("ofXml") << "setting tag " << name << ": " << value;
		setValue(name,value);
	}
}
开发者ID:8morikazuto,项目名称:openFrameworks,代码行数:27,代码来源:ofXml.cpp


示例2: parameterChanged

void OscController::parameterChanged(ofAbstractParameter & parameter){
    string paramName = getParameterName(parameter);
    string address = getAddressByParamName(paramName);
    
    if(address == ""){
        return;
    }
    
    ofxOscMessage msg;
    msg.setAddress(address);
    
    // NOTE: all parameters are sent as float args
    if(parameter.type()==typeid(ofParameter<int>).name()){
        //msg.addFloatArg(parameter.cast<int>());
        ofParameter<int> & p = parameter.cast<int>();
        msg.addFloatArg( ofMap(p.get(), p.getMin(), p.getMax(), 0.0, 1.0) );
    }else if(parameter.type()==typeid(ofParameter<float>).name()){
        //msg.addFloatArg(parameter.cast<float>());
        ofParameter<float> & p = parameter.cast<float>();
        msg.addFloatArg( ofMap(p.get(), p.getMin(), p.getMax(), 0.0, 1.0) );
    }else if(parameter.type()==typeid(ofParameter<bool>).name()){
        msg.addFloatArg(parameter.cast<bool>());
    }
    
    // send message
//    for (int i = 0; i < oscOut.size(); i++) {
//        oscOut[i]->sendMessage(msg);
//    }
    
    //senderTouchOSC.sendMessage(msg);
    senderVezer.sendMessage(msg);
}
开发者ID:mimetikxs,项目名称:oscMapper,代码行数:32,代码来源:OscController.cpp


示例3: ofSerialize

void ofSerialize(ofXml & xml, const ofAbstractParameter & parameter){
	if(!parameter.isSerializable()){
		return;
	}
	string name = parameter.getEscapedName();
	if(name == ""){
		name = "UnknownName";
	}
	ofXml child	= xml.findFirst(name);
	
	if(!child){
		child = xml.appendChild(name);
		ofLogVerbose("ofXml") << "creating group " << name;
	}
	if(parameter.type() == typeid(ofParameterGroup).name()){
		const ofParameterGroup & group = static_cast <const ofParameterGroup &>(parameter);
		
		ofLogVerbose("ofXml") << "group " << name;
		for(auto & p: group){
			ofSerialize(child, *p);
		}
		ofLogVerbose("ofXml") << "end group " << name;
	}else{
		string value = parameter.toString();
		child.set(value);
	}
}
开发者ID:chuckleplant,项目名称:openFrameworks,代码行数:27,代码来源:ofXml.cpp


示例4: addValue

//------------------------------------------------
bool guiValue::addValue(ofAbstractParameter &param){
    if( param.getParent() ){
        paramGroup.setName( param.getParent()->getName() );
    }
    
    paramGroup.add(param);
    return true;
}
开发者ID:carlesgutierrez,项目名称:ofxControlPanel,代码行数:9,代码来源:guiValue.cpp


示例5: getParameterName

string OscController::getParameterName(ofAbstractParameter &parameter){
    string paramName = "";
    const vector<string> hierarchy = parameter.getGroupHierarchyNames();
    for(int i=0; i<(int)hierarchy.size()-1; i++){
        paramName += hierarchy[i] + ".";
    }
    paramName += parameter.getEscapedName();

    return paramName;
}
开发者ID:mimetikxs,项目名称:oscMapper,代码行数:10,代码来源:OscController.cpp


示例6: deserialize

void ofXml::deserialize(ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	string name = parameter.getEscapedName();
	if(parameter.type()==typeid(ofParameterGroup).name()){
		ofParameterGroup & group = static_cast<ofParameterGroup&>(parameter);
		if(setTo(name)){
			for(int i=0;i<group.size();i++){
				deserialize(group.get(i));
			}
			setToParent();
		}
	}else{
		if(exists(name)){
			if(parameter.type()==typeid(ofParameter<int>).name()){
				parameter.cast<int>() = getIntValue(name);
			}else if(parameter.type()==typeid(ofParameter<float>).name()){
				parameter.cast<float>() = getFloatValue(name);
			}else if(parameter.type()==typeid(ofParameter<bool>).name()){
				parameter.cast<bool>() = getBoolValue(name);
			}else if(parameter.type()==typeid(ofParameter<int64_t>).name()){
				parameter.cast<int64_t>() = getInt64Value(name);
			}else if(parameter.type()==typeid(ofParameter<string>).name()){
				parameter.cast<string>() = getValue(name);
			}else{
				parameter.fromString(getValue(name));
			}
		}
	}

}
开发者ID:8morikazuto,项目名称:openFrameworks,代码行数:30,代码来源:ofXml.cpp


示例7: isMappeable

bool OscController::isMappeable(ofAbstractParameter & p) {
    // at the moment, there's no way to control multivalue parameters (colors, vectors, etc) with midi
    // a workarround would be exposing the color components (r,g,b) as individual parameters
    // eg: color1_r, color1_g, color1_b and color2_r, color2_g, color2_b
    if(p.type() == typeid(ofParameter<float>).name()
       || p.type() == typeid(ofParameter<int>).name()
       || p.type() == typeid(ofParameter<bool>).name()){
        return true;
    }
    return false;
}
开发者ID:mimetikxs,项目名称:oscMapper,代码行数:11,代码来源:OscController.cpp


示例8: swapPositions

void ofParameterGroup::swapPositions(ofAbstractParameter & param1, ofAbstractParameter & param2){
	auto iter = obj->parametersIndex.find(param1.getName());
	if (iter != obj->parametersIndex.end()){
		auto iter2 = obj->parametersIndex.find(param2.getName());
		if(iter != obj->parametersIndex.end())
		{
			swapPositions(obj->parametersIndex[param1.getName()], obj->parametersIndex[param2.getName()]);
		}
	}

}
开发者ID:c-mendoza,项目名称:openFrameworks,代码行数:11,代码来源:ofParameterGroup.cpp


示例9: appendParameter

void ofxOscSender::appendParameter( ofxOscMessage & msg, const ofAbstractParameter & parameter, string address){
	msg.setAddress(address+parameter.getEscapedName());
	if(parameter.type()==typeid(ofParameter<int>).name()){
		msg.addIntArg(parameter.cast<int>());
	}else if(parameter.type()==typeid(ofParameter<float>).name()){
		msg.addFloatArg(parameter.cast<float>());
	}else if(parameter.type()==typeid(ofParameter<bool>).name()){
		msg.addIntArg(parameter.cast<bool>());
	}else{
		msg.addStringArg(parameter.toString());
	}
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:openFrameworks,代码行数:12,代码来源:ofxOscSender.cpp


示例10: ofDeserialize

void ofDeserialize(const ofXml & xml, ofAbstractParameter & parameter){
	if(!parameter.isSerializable()){
		return;
	}
	string name = parameter.getEscapedName();
	
	ofXml child = xml.findFirst(name);
	if(child){
		if(parameter.type() == typeid(ofParameterGroup).name()){
			ofParameterGroup & group = static_cast <ofParameterGroup &>(parameter);
			for(auto & p: group){
				ofDeserialize(child, *p);
			}
		}else{
			if(parameter.type() == typeid(ofParameter <int> ).name()){
				parameter.cast <int>() = child.getIntValue();
			}else if(parameter.type() == typeid(ofParameter <float> ).name()){
				parameter.cast <float>() = child.getFloatValue();
			}else if(parameter.type() == typeid(ofParameter <bool> ).name()){
				parameter.cast <bool>() = child.getBoolValue();
			}else if(parameter.type() == typeid(ofParameter <string> ).name()){
				parameter.cast <string>() = child.getValue();
			}else{
				parameter.fromString(child.getValue());
			}
		}
	}
}
开发者ID:chuckleplant,项目名称:openFrameworks,代码行数:28,代码来源:ofXml.cpp


示例11: deserialize

void ofxXmlSettings::deserialize(ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	string name = parameter.getEscapedName();
	if(parameter.type()==typeid(ofParameterGroup).name()){
		ofParameterGroup & group = static_cast<ofParameterGroup&>(parameter);
		if(tagExists(name)){
			pushTag(name);
			for(int i=0;i<group.size();i++){
				deserialize(group.get(i));
			}
			popTag();
		}
	}else{
		if(tagExists(name)){
			if(parameter.type()==typeid(ofParameter<int>).name()){
				parameter.cast<int>() = getValue(name,0);
			}else if(parameter.type()==typeid(ofParameter<float>).name()){
				parameter.cast<float>() = getValue(name,0.0f);
			}else if(parameter.type()==typeid(ofParameter<bool>).name()){
				parameter.cast<bool>() = getValue(name,false);
			}else if(parameter.type()==typeid(ofParameter<string>).name()){
				parameter.cast<string>() = getValue(name,"");
			}else{
				parameter.fromString(getValue(name,""));
			}
		}
	}

}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:29,代码来源:ofxXmlSettings.cpp


示例12: remove

void ofParameterGroup::remove(ofAbstractParameter &param){
	std::for_each(obj->parameters.begin(), obj->parameters.end(), [&](shared_ptr<ofAbstractParameter>& p){
		if(p->isReferenceTo(param)){
			remove(param.getName());
		}
	});
}
开发者ID:RebelMoogle,项目名称:openFrameworks,代码行数:7,代码来源:ofParameterGroup.cpp


示例13: remove

void ofParameterGroup::remove(ofAbstractParameter &param){
	for(auto & p: obj->parameters){
		if(p->isReferenceTo(param)){
			remove(param.getName());
			return;
		}
	}
}
开发者ID:2bbb,项目名称:openFrameworks,代码行数:8,代码来源:ofParameterGroup.cpp


示例14: onSettingChanged

void audioVisualApp::onSettingChanged(ofAbstractParameter &p) {
    string name = p.getName();
    if(name == "Play!") {
        if(outputOn) {
            soundPlayer->play();
        }
    }
}
开发者ID:HellicarAndLewis,项目名称:LectureVisualisation,代码行数:8,代码来源:audioVisualApp.cpp


示例15: paramsChanged

//--------------------------------------------------------------
void PartyCLApp::paramsChanged(ofAbstractParameter& param)
{
    string paramName = param.getName();

    if (paramName == clusterScale.getName() ||
            paramName == velocityScale.getName()) {
        bReset = true;
    }
}
开发者ID:Entropy,项目名称:Entropy,代码行数:10,代码来源:PartyCLApp.cpp


示例16: onClipChanged

void audioVisualApp::onClipChanged(ofAbstractParameter &p) {
    string clipName = soundClips[p.getName()];
    if(soundPlayer->isPlaying()) {
        soundPlayer->stop();
    }
    soundPlayer->load(clipName);
    if(outputOn) {
        soundPlayer->play();
    }
}
开发者ID:HellicarAndLewis,项目名称:LectureVisualisation,代码行数:10,代码来源:audioVisualApp.cpp


示例17: appendParameter

void ofxOscSender::appendParameter( ofxOscBundle & _bundle, const ofAbstractParameter & parameter, string address){
	if(parameter.type()==typeid(ofParameterGroup).name()){
		ofxOscBundle bundle;
		const ofParameterGroup & group = static_cast<const ofParameterGroup &>(parameter);
		for(std::size_t i=0;i<group.size();i++){
			const ofAbstractParameter & p = group[i];
			if(p.isSerializable()){
				appendParameter(bundle,p,address+group.getEscapedName()+"/");
			}
		}
		_bundle.addBundle(bundle);
	}else{
		if(parameter.isSerializable()){
			ofxOscMessage msg;
			appendParameter(msg,parameter,address);
			_bundle.addMessage(msg);
		}
	}
}
开发者ID:sleliyk,项目名称:openFrameworks,代码行数:19,代码来源:ofxOscSender.cpp


示例18: add

void ofParameterGroup::add(ofAbstractParameter & parameter){
	shared_ptr<ofAbstractParameter> param = parameter.newReference();
	const std::string name = param->getEscapedName();
	if(obj->parametersIndex.find(name) != obj->parametersIndex.end()){
		ofLogWarning() << "Adding another parameter with same name '" << param->getName() << "' to group '" << getName() << "'";
	}
	obj->parameters.push_back(param);
	obj->parametersIndex[name] = obj->parameters.size()-1;
	param->setParent(*this);
}
开发者ID:RebelMoogle,项目名称:openFrameworks,代码行数:10,代码来源:ofParameterGroup.cpp


示例19: serialize

void ofxXmlSettings::serialize(const ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	string name = parameter.getEscapedName();
	if(name=="") name="UnknownName";
	if(parameter.type()==typeid(ofParameterGroup).name()){
		const ofParameterGroup & group = static_cast<const ofParameterGroup&>(parameter);
		if(!tagExists(name)) addTag(name);
		pushTag(name);
		for(int i=0;i<group.size();i++){
			serialize(group.get(i));
		}
		popTag();
	}else{
		string value = parameter.toString();
		if(!tagExists(name))
			addValue(name,value);
		else
			setValue(name,value);
	}
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:20,代码来源:ofxXmlSettings.cpp


示例20: isMappeable

//--------------------------------------------------------------
bool MidiController::isMappeable(ofAbstractParameter & p) {
    // ignore non-serializable parameters (eg: toggles from buttons)
    if(!p.isSerializable()){
        return false;
    }
    
    // TODO:
    // at the moment, there's no way to control multivalue parameters (like color, vector, etc) with midi
    // a solution would be exposing the color components in the renderers as individual
    // values like: color1_r, color1_g, color1_b and color2_r, color2_g, color2_b
    if(p.type() == typeid(ofParameter<ofColor>).name()
       || p.type() == typeid(ofParameter<ofFloatColor>).name()){
        return false;
    }
    
    if(p.type() == typeid(ofParameter<float>).name()
       || p.type() == typeid(ofParameter<int>).name()
       || p.type() == typeid(ofParameter<bool>).name()){
        return true;
    }
    
    return false;
}
开发者ID:mimetikxs,项目名称:kinectMapper,代码行数:24,代码来源:MidiController.cpp



注:本文中的ofAbstractParameter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ofBaseHasTexture类代码示例发布时间:2022-05-31
下一篇:
C++ ocpnDC类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap