本文整理汇总了C++中ofXml::setToParent方法的典型用法代码示例。如果您正苦于以下问题:C++ ofXml::setToParent方法的具体用法?C++ ofXml::setToParent怎么用?C++ ofXml::setToParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofXml
的用法示例。
在下文中一共展示了ofXml::setToParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveXML
void Socket::saveXML(ofXml &xml) {
xml.setTo("socket");
if (enabled) xml.setAttribute("enabled", "on");
else xml.setAttribute("enabled", "off");
xml.setAttribute("host", ofToString(host));
xml.setAttribute("send", ofToString(send));
xml.setAttribute("receive", ofToString(receive));
xml.setToParent();
}
示例2: loadSequencerFromXml
void ofxControlPanel::loadSequencerFromXml(ofXml &xml)
{
if (xml.exists("Sequencer"))
{
xml.setTo("Sequencer");
if (!sequencerMade) {
createSequencer();
}
sequencer->setFromXml(xml);
xml.setToParent();
}
else {
ofLog(OF_LOG_ERROR, "No sequencer found in preset");
}
}
示例3: setupFromXml
void setupFromXml(string filename) {
size = ofVec2f(ofGetWidth(), ofGetHeight());
if (xml.load(filename)) {
xml.setTo("STAR[0]");
do {
xml.setTo("POSITION");
int x = xml.getValue<float>("X");
int y = xml.getValue<float>("Y");
xml.setToParent();
int m = xml.getValue<int>("MAGNITUDE");
int id = xml.getValue<int>("ID");
BPStar s;
s.setPosition(x, y);
s.setMagnitude(m);
s.setId(id);
stars.push_back(s);
}while( xml.setToSibling() ); // go to next STAR
} else {
}
shader.load("","SkyShader.frag");
skyShader.setup();
}
示例4: addClass
void KinectV2Classifier::setFromLearnXml(ofXml &xml)
{
xml.setTo("LearnInfo");
if (xml.exists("Classes")) {
xml.setTo("Classes");
if (xml.exists("Class[0]"))
{
xml.setTo("Class[0]");
do {
addClass(xml.getValue<string>("Name"));
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
}
if (xml.exists("Ranges")) {
xml.setTo("Ranges");
if (xml.exists("Joint[0]"))
{
int idx = 0;
xml.setTo("Joint[0]");
do {
min[idx] = xml.getValue<float>("Min");
max[idx] = xml.getValue<float>("Max");
idx++;
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
}
if (xml.exists("Training")) {
xml.setTo("Training");
if (xml.exists("Entry[0]"))
{
xml.setTo("Entry[0]");
do {
double label = xml.getValue<double>("Label");
vector<string> featureVectorS = ofSplitString(xml.getValue<string>("Features"), ",");
vector<float> entry;
entry.push_back(label);
for (auto f : featureVectorS) {
entry.push_back(ofToFloat(f));
}
data.addEntry(entry);
}
while(xml.setToSibling());
xml.setToParent();
}
xml.setToParent();
}
if (xml.exists("Model")) {
xml.setTo("Model");
string path = xml.getValue<string>("Path");
svm.loadModel(path);
trained = true;
xml.setToParent();
}
xml.setToParent();
}
示例5: ofJoinString
void KinectV2Classifier::setLearnXml(ofXml &xml)
{
// first save the classifier
if (trained) {
svm.saveModel(ofToDataPath("svmModel.dat"));
}
// event-parameter mappings
xml.addChild("LearnInfo");
xml.setTo("LearnInfo");
// classes
xml.addChild("Classes");
xml.setTo("Classes");
for (int i=0; i<classes.size(); i++) {
ofXml xml_;
xml_.addChild("Class");
xml_.setTo("Class");
xml_.addValue("Name", classes[i]);
xml.addXml(xml_);
}
xml.setToParent();
// ranges
xml.addChild("Ranges");
xml.setTo("Ranges");
for (int i=0; i<min.size(); i++) {
ofXml xml_;
xml_.addChild("Joint");
xml_.setTo("Joint");
xml_.addValue("Min", min[i]);
xml_.addValue("Max", max[i]);
xml.addXml(xml_);
}
xml.setToParent();
vector<vector<float> > & entries = data.getEntries();
if (entries.size() > 0) {
xml.addChild("Training");
xml.setTo("Training");
for (int i = 0; i < entries.size(); i++) {
vector<string> featureStringV;
for (int f=1; f<entries[i].size(); f++) {
featureStringV.push_back(ofToString(entries[i][f]));
}
string featureString = ofJoinString(featureStringV, ",");
double label = entries[i][0];
ofXml xml_;
xml_.addChild("Entry");
xml_.setTo("Entry");
xml_.addValue("Label", label);
xml_.addValue("Features", featureString);
xml.addXml(xml_);
}
xml.setToParent();
}
if (trained) {
xml.addChild("Model");
xml.setTo("Model");
xml.addValue("Path", ofToDataPath("svmModel.dat"));
xml.setToParent();
}
xml.setToParent();
}
示例6: buildFromXml
void ofxShaderGraph::buildFromXml(ofXml x){
unordered_set<string> root_names;
x.reset();
unsigned long n = x.getNumChildren();
params.setName(x.getName());
//first pass, create all nodes and set defaults
for(unsigned long i=0; i<n; i++){
x.reset();
x.setToChild(i);
if(x.getName()!="node")
continue;
string name = x.getAttribute("name");
if(name==""){
cout<<"ofxShaderGraph warning: anonymous node in XML"<<endl;
continue;
}
ofxBaseShaderNode *node;
ofFbo::Settings node_fbo_settings = fbo_settings;
//check for modifications to fbo_settings
if(x.setTo("scale")){
float scale = x.getFloatValue();
node_fbo_settings.width*=scale;
node_fbo_settings.height*=scale;
x.setToParent();
}
string format = x.getAttribute("format");
if(format!=""){
if(format=="rgba8")
node_fbo_settings.internalformat = GL_RGBA8;
else if(format=="rgba16")
node_fbo_settings.internalformat = GL_RGBA16;
else if(format=="rgba32f")
node_fbo_settings.internalformat = GL_RGBA32F;
else if(format=="rgba16f")
node_fbo_settings.internalformat = GL_RGBA16F;
else if(format=="rgb8")
node_fbo_settings.internalformat = GL_RGB8;
else if(format=="rgb16")
node_fbo_settings.internalformat = GL_RGB16;
else if(format=="rgb32f")
node_fbo_settings.internalformat = GL_RGB32F;
else if(format=="rgb16f")
node_fbo_settings.internalformat = GL_RGB16F;
}
//check for node to swap buffers with
string swap_name = x.getAttribute("swap");
if(swap_name != ""){
//don't duplicate pairs
if(swap.count(swap_name)==0){
cout<<"ofxShaderGraph: "<<name<<" swaps with "<<swap_name<<endl;
swap.insert(pair<string, string>(name, swap_name));
}else{
cout<<"ofxShaderGraph warning: ignoring duplicate swap of"<<name<<" with "<<swap_name<<endl;
}
}
//check for color to init buffer to
if(x.setTo("init")){
float val = x.getFloatValue();
init.insert(pair<string, float>(name, val));
x.setToParent();
}
//check for shader path
string shader_name = x.getAttribute("shader");
if(shader_name == ""){
//shaderless node
node = new ofxConstantShaderNode(allocator, node_fbo_settings, name);
}
else{
ofShader *shader = new ofShader();
stringstream shader_path;
shader_path<<ofToDataPath("../../src/shader/")<<shader_name;
shader->load(shader_path.str());
if(!shader->isLoaded()){
cout<<"ofxShaderGraph warning: shader "<<shader_name<<" failed to load from path "<<shader_path.str()<<endl;
}
else{
cout<<"ofxShaderGraph: loaded shader "<<shader_name<<endl;
}
node = new ofxBaseShaderNode(allocator, node_fbo_settings, name, shader);
}
//grab all of the new node's parameters
params.add(node->getParameterGroup());
//put it in the map from names to nodes
nodes.insert(pair<string, ofxBaseShaderNode*>(name, node));
//everything goes in root_names, to be removed when is appears as an input
root_names.insert(name);
cout<<"ofxShaderGraph: inserted node "<<name<<endl;
//set defaults
if(x.setTo("defaults") && x.setToChild(0)){
do{
string param_type = x.getName();
string param_name = x.getAttribute("name");
if(param_type=="float"){
float v = x.getFloatValue();
node->setParameter(param_name, v);
//.........这里部分代码省略.........