Esempio n. 1
0
void QTimeline::load( fs::path filepath )
{
    clear();
 
    XmlTree doc;
    
    try
    {
        doc = XmlTree( loadFile( filepath ) );

        
        for( XmlTree::Iter nodeIt = doc.begin("QTimeline/tracks/track"); nodeIt != doc.end(); ++nodeIt )
        {
            string              trackName   = nodeIt->getAttributeValue<string>("name");
            QTimelineTrackRef   trackRef    = QTimelineTrackRef( new QTimelineTrack( trackName ) );
            mTracks.push_back( trackRef );
            trackRef->loadXmlNode( *nodeIt );
        }
        
        mCueManager->loadXmlNode( doc.getChild( "qTimeline/cueList" ) );
    }
    catch ( ... )
    {
        console() << "Error > QTimeline::load(): " << filepath.filename().generic_string() << endl;
        return;
    }
    
    updateCurrentTime();
}
void AppModel::parseRecipes(XmlTree _root){
    XmlTree t = _root.getChild("dict/dict");
    
    for( XmlTree::Iter child = t.begin(); child != t.end(); ++child ){
        if(child->getTag().compare("key")==0){
            // use this value as the name for a new Recipe object
            RecipeModel rm;
            rm.name = child->getValue();
            recipes.push_back(rm);
        } else {
            XmlTree t2 = *child;
            string whichKey;
            for( XmlTree::Iter grandchild = t2.begin(); grandchild != t2.end(); ++grandchild ){                
                if(grandchild->getTag().compare("key")==0){
                    whichKey = grandchild->getValue();
                } else if(grandchild->getTag().compare("dict")==0){                    
                    if(whichKey.compare("Steps")==0){
                        XmlTree t3 = *grandchild;
                        CookStepModel sm;
                        for( XmlTree::Iter greatChild = t3.begin(); greatChild != t3.end(); ++greatChild ){
                            XmlTree t4 = *greatChild;
                            string stepKey;
                            if(greatChild->getTag().compare("dict")==0){
                                for( XmlTree::Iter baby = t4.begin(); baby != t4.end(); ++baby ){
                                    if(baby->getTag().compare("key")==0){
                                        stepKey = baby->getValue();
                                    } else {
                                        if(stepKey.compare("img")==0){
                                            sm.img = baby->getValue();
                                        } else if(stepKey.compare("video")==0){
                                            sm.video = baby->getValue();
                                        } else {
                                            console() << "I got a property of a cookstep that was unexpected: " << stepKey << ", " << baby->getValue();
                                        }
                                        
                                    }
                                }
                            } else if(greatChild->getTag().compare("key")==0){
                                if(recipes.size()>0 && sm.name.compare("")!=0){
                                    recipes.at(recipes.size()-1).steps.push_back(sm);
                                }
                                sm.name = sm.video = sm.img = "";
                                sm.name = greatChild->getValue();
                            }
                            
                        }
                        if(sm.name.compare("")!=0){
                            recipes.at(recipes.size()-1).steps.push_back(sm);
                        }
                    }
                    
                } else {
                   // do nothing?
                }
                
            }
        }
        
    }
}
Esempio n. 3
0
void Warp::fromXml( const XmlTree &xml )
{
	mControlsX = xml.getAttributeValue<int>( "width", 2 );
	mControlsY = xml.getAttributeValue<int>( "height", 2 );
	mBrightness = xml.getAttributeValue<float>( "brightness", 1.0f );

	// load control points
	mPoints.clear();
	for( auto child = xml.begin( "controlpoint" ); child != xml.end(); ++child ) {
		float x = child->getAttributeValue<float>( "x", 0.0f );
		float y = child->getAttributeValue<float>( "y", 0.0f );
		mPoints.push_back( vec2( x, y ) );
	}

	// load blend params
	auto blend = xml.find( "blend" );
	if( blend != xml.end() ) {
		mExponent = blend->getAttributeValue<float>( "exponent", mExponent );

		auto edges = blend->find( "edges" );
		if( edges != blend->end() ) {
			mEdges.x = edges->getAttributeValue<float>( "left", mEdges.x );
			mEdges.y = edges->getAttributeValue<float>( "top", mEdges.y );
			mEdges.z = edges->getAttributeValue<float>( "right", mEdges.z );
			mEdges.w = edges->getAttributeValue<float>( "bottom", mEdges.w );
		}

		auto gamma = blend->find( "gamma" );
		if( gamma != blend->end() ) {
			mGamma.x = gamma->getAttributeValue<float>( "red", mGamma.x );
			mGamma.y = gamma->getAttributeValue<float>( "green", mGamma.y );
			mGamma.z = gamma->getAttributeValue<float>( "blue", mGamma.z );
		}

		auto luminance = blend->find( "luminance" );
		if( luminance != blend->end() ) {
			mLuminance.x = luminance->getAttributeValue<float>( "red", mLuminance.x );
			mLuminance.y = luminance->getAttributeValue<float>( "green", mLuminance.y );
			mLuminance.z = luminance->getAttributeValue<float>( "blue", mLuminance.z );
		}
	}

	// reconstruct warp
	mIsDirty = true;
}
Esempio n. 4
0
void PlistReader::trace(XmlTree t){
    for( XmlTree::Iter child = t.begin(); child != t.end(); ++child ){
        console() << "Tag: " << child->getTag() << "  Value: " << child->getValue() << endl;
        if(child->getTag().compare("dict")==0){
            trace(*child);
        }
        
    }
}
Esempio n. 5
0
File: Xml.cpp Progetto: Ahbee/Cinder
XmlTree::XmlTree( const XmlTree &rhs )
	: mNodeType( rhs.mNodeType ), mTag( rhs.mTag ), mValue( rhs.mValue ), mDocType( rhs.mDocType ),
	 mParent( 0 ), mAttributes( rhs.mAttributes )
{
	for( XmlTree::ConstIter childIt = rhs.begin(); childIt != rhs.end(); ++childIt ) {
		mChildren.push_back( unique_ptr<XmlTree>( new XmlTree( *childIt ) ) );
		mChildren.back()->mParent = this;
	}
}
Esempio n. 6
0
void FlickrTestApp::setup()
{
	glEnable( GL_TEXTURE_2D );

	const XmlTree xml( loadUrl( Url( "http://api.flickr.com/services/feeds/groups_pool.gne?id=1423039@N24&lang=en-us&format=rss_200" ) ) );
	for( XmlTree::ConstIter item = xml.begin( "rss/channel/item" ); item != xml.end(); ++item ) {
		mUrls.push_back( item->getChild( "media:content" ).getAttributeValue<Url>( "url" ) );
	}

	createTextureFromURL();
	lastTime = getElapsedSeconds();
	activeTex = 0;
}
Esempio n. 7
0
void CanvasComponent::initFromXml(const XmlTree& xml, bool createNodes)
{
    id = xml.getAttributeValue<int>("id");
    // when loading a patch, update globalID so future
    // nodes will be created with a unique id
    if (globalComponentID <= id) {
        // increment global id so each component will have a unique id
        globalComponentID = id+1;
    }
    
    setName(xml.getAttributeValue<std::string>("name"));
    Vec2f pos = Vec2f(xml.getAttributeValue<float>("position.x"), xml.getAttributeValue<float>("position.y"));
    Vec2f size = Vec2f(xml.getAttributeValue<float>("size.x"), xml.getAttributeValue<float>("size.y"));
    canvasRect = Rectf(pos, pos+size);
    
    setSize(size);
    
    showInputPlus = xml.getAttributeValue<bool>("showInputPlus");
    showOutputPlus = xml.getAttributeValue<bool>("showOutputPlus");
    
    if (createNodes)
    {
        // add inputs and outputs
        XmlTree inputNodesTree = xml.getChild("InputNodes");
        for(XmlTree::ConstIter iter = inputNodesTree.begin(); iter != inputNodesTree.end(); ++iter)
        {
            if (iter->getTag() == "Node") {
                addInputNodeFromXml(iter->getChild(""));
            }
        }
        XmlTree outputNodesTree = xml.getChild("OutputNodes");
        for(XmlTree::ConstIter iter = outputNodesTree.begin(); iter != outputNodesTree.end(); ++iter)
        {
            if (iter->getTag() == "Node") {
                addOutputNodeFromXml(iter->getChild(""));
            }
        }
    }
}
Esempio n. 8
0
void DataManager::parseData( XmlTree d ){
    XmlTree data  = d.getChild( "QLT_Genome_Data" );
    string dataPath = data.getChild( "datapath" ).getValue();
    XmlTree sets = data.getChild( "datasets");
    for( XmlTree::Iter dataset = sets.begin(); dataset != sets.end(); ++dataset ){
        GenomeDataStructure gds;
        gds.id = dataset->getAttributeValue<int>("id");
        gds.name = dataset->getChild("title").getValue();
        gds.pathMap = dataPath+dataset->getChild("map").getValue();
        gds.pathBases = dataPath+dataset->getChild("bases").getValue();
        mDataStructure.push_back( gds );
        console() << " GenomeDataStructure : " << gds.name << "         " << gds.pathMap << "   " << gds.pathBases << std::endl;
    }
}
Esempio n. 9
0
void XMLTestApp::setup()
{
	XmlTree doc( loadFile( getAssetPath( "library.xml" ) ) );
	XmlTree musicLibrary( doc.getChild( "library" ) );
	for( XmlTree::ConstIter item = doc.begin("library/album"); item != doc.end(); ++item ) {
		console() << "Node: " << item->getTag() << " Value: " << item->getValue() << endl;
	}

	for( XmlTree::ConstIter track = doc.begin("library/album/track"); track != doc.end(); ++track )
		console() << track->getValue() << endl;

	assert( (musicLibrary / "album")["musician"] == "John Coltrane" );

	// test that /one/two is equivalent to one/two
	vector<string> noLeadingSeparator, leadingSeparator;
	for( XmlTree::ConstIter track = doc.begin("library/album/track"); track != doc.end(); ++track )
		noLeadingSeparator.push_back( track->getValue() );
	for( XmlTree::ConstIter track = doc.begin("/library/album/track"); track != doc.end(); ++track )
		leadingSeparator.push_back( track->getValue() );
	assert( noLeadingSeparator == leadingSeparator );

	XmlTree firstAlbum = doc.getChild( "library/album" );
	for( XmlTree::Iter child = firstAlbum.begin(); child != firstAlbum.end(); ++child ) {
		console() << "Tag: " << child->getTag() << "  Value: " << child->getValue() << endl;
	}
	console() << doc.getChild( "library/owner/city" );
	XmlTree ownerCity = doc.getChild( "///library/////owner/city" );
	console() << "Path: " << ownerCity.getPath() << "  Value: " << ownerCity.getValue() << std::endl;
	console() << doc;
	
	console() << findTrackNamed( doc.getChild( "library" ), "Wolf" );
	
	// Whoops - assignment by value doesn't modifying the original XmlTree
	XmlTree firstTrackCopy = doc.getChild( "/library/album/track" );
	firstTrackCopy.setValue( "Replacement name" );
	console() << doc.getChild( "/library/album/track" ) << std::endl;

	XmlTree &firstTrackRef = doc.getChild( "/library/album/track" );
	firstTrackRef.setValue( "Replacement name" );
	console() << doc.getChild( "/library/album/track" ) << std::endl;

	XmlTree albumCopy = copyFirstAlbum( doc / "library" );
	console() << ( albumCopy / "track" ).getPath() << std::endl; // should print 'newRoot/track'

	// This code only works in VC2010
/*	std::for_each( doc.begin( "library/album" ), doc.end(), []( const XmlTree &child ) {
		app::console() << child.getChild( "title" ).getValue() << std::endl;
	} );*/
}
void WarpPerspectiveBilinear::fromXml(const XmlTree &xml)
{
	WarpBilinear::fromXml(xml);

	// get corners
	unsigned i = 0;
	for(XmlTree::ConstIter child=xml.begin("corner");child!=xml.end();++child) {
		float x = child->getAttributeValue<float>("x", 0.0f);
		float y = child->getAttributeValue<float>("y", 0.0f);

		mWarp->setControlPoint(i, Vec2f(x, y));

		i++;
	}
}
Esempio n. 11
0
WarpList Warp::readSettings( const DataSourceRef &source )
{
	XmlTree  doc;
	WarpList warps;

	// try to load the specified xml file
	try {
		doc = XmlTree( source );
	}
	catch( ... ) {
		return warps;
	}

	// check if this is a valid file
	bool isWarp = doc.hasChild( "warpconfig" );
	if( !isWarp ) return warps;

	//
	if( isWarp ) {
		// get first profile
		XmlTree profileXml = doc.getChild( "warpconfig/profile" );

		// iterate maps
		for( XmlTree::ConstIter child = profileXml.begin( "map" ); child != profileXml.end(); ++child ) {
			XmlTree warpXml = child->getChild( "warp" );

			// create warp of the correct type
			std::string method = warpXml.getAttributeValue<std::string>( "method", "unknown" );
			if( method == "bilinear" ) {
				WarpBilinearRef warp( new WarpBilinear() );
				warp->fromXml( warpXml );
				warps.push_back( warp );
			}
			else if( method == "perspective" ) {
				WarpPerspectiveRef warp( new WarpPerspective() );
				warp->fromXml( warpXml );
				warps.push_back( warp );
			}
			else if( method == "perspectivebilinear" ) {
				WarpPerspectiveBilinearRef warp( new WarpPerspectiveBilinear() );
				warp->fromXml( warpXml );
				warps.push_back( warp );
			}
		}
	}

	return warps;
}
Esempio n. 12
0
UserArea::UserArea(XmlTree area, PhidgetConnector *pc_)
{
    
    // okay so if theres attributes aren't here, it bugs out it would seem?
    pos = Vec2f(area.getAttributeValue<float>( "centerX" ), area.getAttributeValue<float>( "centerY" ));
    angle = area.getAttributeValue<float>( "angle" );
    key = area.getAttributeValue<char>( "key" );
    
    
    // this should be loading from the XML.
    background = "area_background.png";
    
    // there is some serious abstracting to be done here
    string activeArea_str = "active_area.png";
    
    
    
    bg_img.load(background);
    activeArea_img.load(activeArea_str);
    
    // really, still? hmmm
    // mTexture = gl::Texture( loadImage( loadResource( background ) ) );
    
    
    vector<string> videos;
    for( XmlTree::Iter child = area.begin(); child != area.end(); ++child)
    {
        if ( child->getTag() == "video" )
            videos.push_back(child->getValue());
        else if ( child->getTag() == "button" )
        {
            XmlTree b = *child;
            //buttons.push_back(Button::Button(b/*, &UserArea::nextMovie*/));
            buttons.push_back(TwoStateButton(b));
            buttonStates.push_back(false);
           
           // void (UserArea::*func)() = &UserArea::nextMovie;
          /*  void (*func)() = &printTest;
            func(); */
        }
    }
    player = VideoPlayer ( Rectf(0, 0, 640, 480), videos);
    frameCount = rand() % 628;
    
    pc = pc_;
}
Esempio n. 13
0
void ConfigDict::loadXML(DataSourceRef source)
{
	XmlTree doc;
	try {
		doc = XmlTree(source);	
	} catch(rapidxml::parse_error &e) {
		LOG_ERROR("ConfigDict::loadXML - couldnt parse XML data ("<< 
				  "error: "<< e.what() <<" "<<
				  "file: "<< source->getFilePathHint() <<
				  ")");
	}
	
	XmlTree root = *doc.begin();
	
	for(XmlTree::ConstIter setting = root.begin(); setting != root.end(); ++setting) 
	{
		string key = setting->getTag();
		string value = setting->getValue();
		settings.insert(std::pair<string,string>(key, value) );
	}
}
Esempio n. 14
0
void License::init( XmlTree &doc )
{
	if( doc.hasChild( "License" ))
	{
		XmlTree xmlLicense = doc.getChild( "License" );

		string product = xmlLicense.getAttributeValue<string>( "Product", ""  );
		string key     = xmlLicense.getAttributeValue<string>( "Key"    , ""  );

		setProduct( product );
		setKeyPath( getAssetPath( key ));

		for( XmlTree::Iter child = xmlLicense.begin(); child != xmlLicense.end(); ++child )
		{
			if( child->getTag() == "Server" )
			{
				string server = child->getAttributeValue<string>( "Name" );
				addServer( server );
			}
		}
	}
}
TwoStateButton::TwoStateButton(XmlTree xml)
{
    pos.x = xml.getAttributeValue<float>( "posX" );
    pos.y = xml.getAttributeValue<float>( "posY" );
    float angle = xml.getAttributeValue<float>( "angle" );
    device = xml.getAttributeValue<int>( "device" );
    sensor = xml.getAttributeValue<int>( "sensor" );
    
    for( XmlTree::Iter img = xml.begin(); img != xml.end(); ++img)
    {
        if (img->getAttributeValue<string>( "id" ) == "active")
        {
            active = Image(img->getValue(), pos);
        }
        else if (img->getAttributeValue<string>( "id" ) == "inactive")
        {
            inactive = Image(img->getValue(), pos);
        }
    }
    active.setRotation(angle);
    inactive.setRotation(angle);
}
bool BookAR::readAppConfig( const string& appXml )
{	
	vector<string> mdl_files;
	vector<string> thumb_files;
	try
	{
		XmlTree doc(loadFile(appXml));
		XmlTree firstConfig = doc.getChild("SDARConfig");

		for( XmlTree::Iter item = firstConfig.begin(); item != firstConfig.end(); ++item )
		{
			//key
			string name = item->getAttribute("name");
			string thumb = item->getAttribute("thumb");
			mdl_files.push_back(name);
			thumb_files.push_back(thumb);
		}
	}
	catch( ... ) {
		console() << "[ERROR] Failed to readAppConfig from " << appXml<<std::endl;
		return false;
	}
	_ar_tracker->setup(CAM_W, CAM_H, 10, 1000, static_cast<void*>(&mdl_files));

	//thumbs
	int thumb_x = THUMB_X0;
	for (int i=0;i<thumb_files.size();i++)
	{
		Surface thumb_img = loadImage(getAppPath().generic_string()+thumb_files[i]);
		float ratio = thumb_img.getAspectRatio();
		int thumb_w = static_cast<int>(THUMB_H*ratio);
		_thumbs.push_back(shared_ptr<UIElement>(new UIElement(THUMB_BASE + i, thumb_x, THUMB_Y0, thumb_w, THUMB_H, thumb_img)));
		thumb_x += thumb_w+THUMB_SPAC;
	}

	return true;
}
Esempio n. 17
0
void PlistReader::parseRecipes(){
    XmlTree t = root.getChild("dict/dict");
    for( XmlTree::Iter child = t.begin(); child != t.end(); ++child ){
        console() << "Tag: " << child->getTag() << "  Value: " << child->getValue() << endl;
        if(child->getTag().compare("key")==0){
            // use this value as the name for a new Recipe object
            RecipeModel rm;
            rm.name = child->getValue();
            recipeModels.push_back(rm);
        } else {
            console() << "check it out, this is probably a dict:::: " << child->getTag() << "." << endl;
            XmlTree t2 = *child;
            string whichKey;
            for( XmlTree::Iter grandchild = t2.begin(); grandchild != t2.end(); ++grandchild ){
                console() << "\t Tag: " << grandchild->getTag() << "  Value: " << grandchild->getValue() << endl;
                
                if(grandchild->getTag().compare("key")==0){
                    // its a key yo
                    whichKey = grandchild->getValue();
                    console() << "\t\t right after, whichkey is: " << whichKey << endl;
                    
                } else if(grandchild->getTag().compare("dict")==0){
                    // surely these are Steps??
                    
                    if(whichKey.compare("Steps")==0){
                        console() << " I FOUND A DICT AND LO AND BEHOLD its a Steps child... "<< grandchild->getValue() << endl;
                        
                        // it must be time to dig through these bloomin STEPS.
                        // loop through em.
                        
                        XmlTree t3 = *grandchild;
                        StepModel sm;
                        for( XmlTree::Iter greatChild = t3.begin(); greatChild != t3.end(); ++greatChild ){
                            XmlTree t4 = *greatChild;
                            
                            string stepKey;
                            
                            
                            
                            if(greatChild->getTag().compare("dict")==0){
                                
                                for( XmlTree::Iter baby = t4.begin(); baby != t4.end(); ++baby ){
                                    if(baby->getTag().compare("key")==0){
                                        stepKey = baby->getValue();
                                    } else {
                                        // then its likely a value
                                        console() << "\t\t\t\t\t\t\t\t " << stepKey << "  Value: " << baby->getValue() << endl;
                                        if(stepKey.compare("start-image")==0){
                                            sm.start_img = baby->getValue();
                                        } else if(stepKey.compare("name")==0){
                                            sm.name = baby->getValue();
                                        } else if(stepKey.compare("video")==0){
                                            sm.video = baby->getValue();
                                        } else {
                                            console() << "I got a property of a cookstep that was unexpected: " << stepKey << ", " << baby->getValue();
                                        }
                                        
                                    }
                                }
                            } else if(greatChild->getTag().compare("key")==0){
                                if(recipeModels.size()>0 && sm.name.compare("")!=0){
                                    recipeModels.at(recipeModels.size()-1).steps.push_back(sm);
                                }
                                console() << " this should be the name of the step... "<< greatChild->getValue() << endl;
                                sm.name = sm.video = sm.start_img = "";
                                sm.name = greatChild->getValue();
                            }
                            
                        }
                        if(sm.name.compare("")!=0){
                        console() << "putting the stepmodel in the vector..." << endl;
                        recipeModels.at(recipeModels.size()-1).steps.push_back(sm);
                        }
                        
                        
                        
                        
                    }
                    
                } else {
                    // its some kinda value, son
                    console() << "\t\t\t whichkey is: " << whichKey << endl;
                    if(whichKey.compare("menu-image")==0){
                        recipeModels.at(recipeModels.size()-1).menu_img = grandchild->getValue();
                    } else if( whichKey.compare("end-image")==0){
                        recipeModels.at(recipeModels.size()-1).end_img = grandchild->getValue();
                    } else{
                        // do nothing man
                        console() << "doing nothing" << endl;
                    }
                    
                }
                
            }
        }
        
    }
}
Esempio n. 18
0
void Level::loadLevelFromFile(string pathToLevel)
{   
    // root
    id = pathToLevel;
    string realPath = "levels/" + pathToLevel;
    realPath = getAssetPath(realPath).string();
    XmlTree doc((loadFile(realPath)));
    XmlTree root = doc.getChild("level");
    
    // width + height
    width = root.getChild("width").getValue<int>();
    height = root.getChild("height").getValue<int>();
    Map.resize(width, vector<int>(height, -1));
    
    // hero start position
    int hx = root.getChild("heroX").getValue<int>();
    int hy = root.getChild("heroY").getValue<int>();
    hero.position.set(hx * TILESIZE, hy * TILESIZE);
    
    // antenna
    int ax = root.getChild("antennaX").getValue<int>();
    int ay = root.getChild("antennaY").getValue<int>();
    antennaPosition.set(ax * TILESIZE, ay * TILESIZE);
    
    // level-data
    stringstream stream;
    stream << root.getChild("data").getValue();
    int index = 0;
    while (stream.good() && index < width * height) {
        int tileId;
        stream >> tileId;
        setTileAtPosition(index, tileId);
        index++;
    }
    
    // attractors
    if (root.hasChild("attractors")) {
        XmlTree firstAttractor = root.getChild("attractors");
        for (XmlTree::Iter child = firstAttractor.begin(); child != firstAttractor.end(); child++) {
            float x = child->getChild("x").getValue<float>();
            float y = child->getChild("y").getValue<float>();
            Attractor* attractor = new Attractor(x, y);
            attractor->autoConnectTime = child->getChild("autoConnectTime").getValue<float>(attractor->autoConnectTime);
            attractor->autoDisconnectTime = child->getChild("autoDisconnectTime").getValue<float>();
            attractor->autoConnectRadius = child->getChild("autoConnectRadius").getValue<float>();
            attractor->connectTimeout = child->getChild("connectTimeout").getValue<float>();
            attractor->attractForce = child->getChild("attractForce").getValue<float>(attractor->attractForce);
            attractor->maxAttractForce = child->getChild("maxAttractForce").getValue<float>(attractor->maxAttractForce);
            
            addConnector(attractor);
        }
    }
    
    // detractors
    if (root.hasChild("detractors")) {
        XmlTree firstDetractor = root.getChild("detractors");
        for (XmlTree::Iter child = firstDetractor.begin(); child != firstDetractor.end(); child++) {
            float x = child->getChild("x").getValue<float>();
            float y = child->getChild("y").getValue<float>();
            Detractor* detractor = new Detractor(x, y);
            detractor->autoConnectTime = child->getChild("autoConnectTime").getValue<float>(detractor->autoConnectTime);
            detractor->autoDisconnectTime = child->getChild("autoDisconnectTime").getValue<float>();
            detractor->autoConnectRadius = child->getChild("autoConnectRadius").getValue<float>();
            detractor->connectTimeout = child->getChild("connectTimeout").getValue<float>();
            detractor->bounceForce = child->getChild("bounceForce").getValue<float>(detractor->bounceForce);
            detractor->maxBounceForce = child->getChild("maxBounceForce").getValue<float>(detractor->maxBounceForce);
            
            addConnector(detractor);
        }
    }
    
}
void AppModel::parseSettings(XmlTree _root){
    XmlTree t = _root.getChild("dict");
    // is key background?
    // load background
    
    // is key user areas?
    // loop children
    // create userareamodel
    // set x, y, r
    // is it a button?
    
    UserAreaModel uam;
    TouchSensorModel tsm;
    
    string topLevelKey = "";
    for( XmlTree::Iter child = t.begin(); child != t.end(); ++child ){
        string tagType = child->getTag();
        console() << "tag: " << tagType << endl;
        if(tagType.compare("key")==0){
            topLevelKey = child->getValue();
             console() << "topkey: " << topLevelKey << endl;
        } else {
            if(tagType.compare("string")==0 || tagType.compare("false")==0 || tagType.compare("true")==0){
                if(topLevelKey.compare("background")==0){
                    backgroundPath = child->getValue();
                } else if(topLevelKey.compare("button")==0){
                    console() << "Button Value::: " << tagType << "!!!!!" << endl;
                    buttonPath = child->getValue();
                } else if(topLevelKey.compare("fullscreen")==0){
                    console() << "FULLSCREEN VALUE:::: " << tagType << "!!!!!!!!!" << endl;
                    if(tagType.compare("true")==0) isFullScreen = true;
                }
            } else if(tagType.compare("dict")==0){
                // this is either the user areas, or the sensor boards
                // depending on the toplevelkey
                XmlTree t2 = *child;
                string midLevelKey = "";
                for( XmlTree::Iter grandchild = t2.begin(); grandchild != t2.end(); ++grandchild ){
                    console() << grandchild->getTag() << " ::: " << grandchild->getValue() << endl;
                    string gcTagType = grandchild->getTag();
                    if(gcTagType.compare("key")==0){
                        midLevelKey = grandchild->getValue();
                    } else {
                        console() << "GRANCHILDLEVEL: " << grandchild->getValue() << " : " << midLevelKey << ", " << topLevelKey << endl;
                        
                        if(topLevelKey.compare("User Areas")==0){
                            uam = UserAreaModel();
                        } else if(topLevelKey.compare("Sensor Boards")==0){
                            tsm = TouchSensorModel();
                        }
                        
                        
                        // this should always be a dict (either a list of nums and strings for user areas, or nums for sensor boards)
                        XmlTree t3 = *grandchild;
                        string bottomLevelKey = "";
                        for( XmlTree::Iter baby = t3.begin(); baby != t3.end(); ++baby ){
                            string babyTag = baby->getTag();
                            
                            if(babyTag.compare("key")==0){
                                bottomLevelKey = baby->getValue();
                            } else if(babyTag.compare("dict")!=0){
                              //  console() << "BABY LEVEL: " << baby->getValue() << " : " << bottomLevelKey << " : " << midLevelKey << ", " << topLevelKey << endl;
                                
                                if(topLevelKey.compare("User Areas")==0){
                                    if(bottomLevelKey.compare("x")==0){
                                        uam.x = atof(baby->getValue().c_str());
                                    } else if(bottomLevelKey.compare("y")==0){
                                        uam.y = atof(baby->getValue().c_str());
                                    } else if(bottomLevelKey.compare("r")==0){
                                        uam.r = atof(baby->getValue().c_str());
                                    }else if(bottomLevelKey.compare("recipe")==0){
                                        uam.recipe = baby->getValue();
                                    }
                                } else if(topLevelKey.compare("Sensor Boards")==0) {
                                    tsm.sensor = atoi(baby->getValue().c_str());
                                    tsm.keymap = bottomLevelKey[0];
                                    tsm.board = atoi(midLevelKey.c_str());
                                    sensors.push_back(tsm);
                                }
                                
                            } else {
                                if(topLevelKey.compare("User Areas")==0){
                                    uam.name = midLevelKey;
                                } 
                                
                                XmlTree t4 = *baby;
                                string easyModeKey = "";
                                for( XmlTree::Iter zygote = t4.begin(); zygote != t4.end(); ++zygote ){
                                    string zygoteTag = zygote->getTag();
                                    
                                    if(zygoteTag.compare("key")==0){
                                        easyModeKey = zygote->getValue();
                                    } else {
                                      //  console() << "ZYGOTE LEVEL: " << zygote->getValue() << ": " << easyModeKey << " : " << bottomLevelKey << " : " << midLevelKey << ", " << topLevelKey << endl;
                                    }
                                }

                            }
                            
                        
                        
                        }
                        if(topLevelKey.compare("User Areas")==0){
                            areas.push_back(uam);
                        }
                    }
                }
            }
        }
    }
}
Esempio n. 20
0
void QTimeline::loadTheme( const fs::path &filepath )
{
    try
    {
        XmlTree theme = XmlTree( loadFile( filepath ) ).getChild("/QTimelineTheme");
        
        // Time bar
        QTimeline::mTimeBarBgCol            = getThemeColor( theme, "TimeBarBgCol" );
        QTimeline::mTimeBarFgCol            = getThemeColor( theme, "TimeBarFgCol" );
        QTimeline::mTimeBarTextCol          = getThemeColor( theme, "TimeBarTextCol" );
        QTimeline::mTimeBarMouseBarCol      = getThemeColor( theme, "TimeBarMouseBarCol" );
        QTimeline::mTimeBarModuleRangeCol   = getThemeColor( theme, "TimeBarModuleRangeCol" );
        
        // Transport
        QTimeline::mTransportBgCol          = getThemeColor( theme, "TransportBgCol" );
        QTimeline::mTransportTextCol        = getThemeColor( theme, "TransportTextCol" );
        
        // Tracks
        QTimeline::mTracksBgCol             = getThemeColor( theme, "TracksBgCol" );
        QTimeline::mTracksBgOverCol         = getThemeColor( theme, "TracksBgOverCol" );
        
        // Module Items
        QTimeline::mModuleItemBgCol         = getThemeColor( theme, "ModuleItemBgCol" );
        QTimeline::mModuleItemBgOverCol     = getThemeColor( theme, "ModuleItemBgOverCol" );
        QTimeline::mModuleItemTextCol       = getThemeColor( theme, "ModuleItemTextCol" );
        QTimeline::mModuleItemHandleCol     = getThemeColor( theme, "ModuleItemHandleCol" );
        QTimeline::mModuleItemHandleOverCol = getThemeColor( theme, "ModuleItemHandleOverCol" );

        // Audio Items
        QTimeline::mAudioItemBgCol          = getThemeColor( theme, "AudioItemBgCol" );
        QTimeline::mAudioItemBgOverCol      = getThemeColor( theme, "AudioItemBgOverCol" );
        QTimeline::mAudioItemTextCol        = getThemeColor( theme, "AudioItemTextCol" );
        QTimeline::mAudioItemHandleCol      = getThemeColor( theme, "AudioItemHandleCol" );
        QTimeline::mAudioItemHandleOverCol  = getThemeColor( theme, "AudioItemHandleOverCol" );

        // Params
        QTimeline::mParamsBgCol             = getThemeColor( theme, "ParamsBgCol" );
        QTimeline::mParamsBgOverCol         = getThemeColor( theme, "ParamsBgOverCol" );
        QTimeline::mParamsTextCol           = getThemeColor( theme, "ParamsTextCol" );
        
        // Keyframes
        QTimeline::mKeyframesBgCol          = getThemeColor( theme, "KeyframesBgCol" );
        QTimeline::mKeyframesBgOverCol      = getThemeColor( theme, "KeyframesBgOverCol" );
        QTimeline::mKeyframesBgSelectedCol  = getThemeColor( theme, "KeyframesBgSelectedCol" );
        QTimeline::mKeyframesGraphCol       = getThemeColor( theme, "KeyframesGraphCol" );
        
        // Cue list
        QTimeline::mCueListBgCol            = getThemeColor( theme, "CueListBgCol" );
        QTimeline::mCueBgCol                = getThemeColor( theme, "CueBgCol" );
        QTimeline::mCueBgOverCol            = getThemeColor( theme, "CueBgOverCol" );
        QTimeline::mCueFgCol                = getThemeColor( theme, "CueFgCol" );
        QTimeline::mCueTextCol              = getThemeColor( theme, "CueTextCol" );
        QTimeline::mCueHandleCol            = getThemeColor( theme, "CueHandleCol" );
        QTimeline::mCueHandleOverCol        = getThemeColor( theme, "CueHandleOverCol" );
        
        // Menu color palette
        QTimelineMenuColorPalette::mColors.clear();
        XmlTree colorPalette = XmlTree( loadFile( filepath ) ).getChild("/QTimelineTheme/MenuColorPalette");
        for( XmlTree::Iter nodeIt = colorPalette.begin("Color"); nodeIt != colorPalette.end(); ++nodeIt )
            QTimelineMenuColorPalette::mColors.push_back( ColorA(   nodeIt->getAttributeValue<float>("r"),
                                                                    nodeIt->getAttributeValue<float>("g"),
                                                                    nodeIt->getAttributeValue<float>("b"),
                                                                    nodeIt->getAttributeValue<float>("a")   ) );
    }
    catch ( ... )
    {
        console() << "ERROR > QTimeline theme NOT loaded!" << endl;
    }
    
    QTimelineTrackRef               trackRef;
    QTimelineItemRef                itemRef;
    QTimelineCueRef                 cueRef;
    std::vector<QTimelineCueRef>    cueList;
    std::vector<QTimelineParamRef>  params;
    
    mCueManager->setBgColor( QTimeline::mCueListBgCol );
    
    for( size_t k=0; k < mTracks.size(); k++ )
    {
        trackRef                = mTracks[k];
        trackRef->mBgColor      = QTimeline::mTracksBgCol;
        trackRef->mBgOverColor  = QTimeline::mTracksBgOverCol;
        
        for( size_t i=0; i < trackRef->mItems.size(); i++ )
        {
            itemRef = trackRef->mItems[i];
            
            if ( itemRef->getType() == "QTimelineModuleItem" )
            {
                itemRef->setBgColor( QTimeline::mModuleItemBgCol );
                itemRef->setBgOverColor( QTimeline::mModuleItemBgOverCol );
                itemRef->setTextColor( QTimeline::mModuleItemTextCol );
                itemRef->setHandleColor( QTimeline::mModuleItemHandleCol );
                itemRef->setHandleOverColor( QTimeline::mModuleItemHandleOverCol );
            }
            
            else if ( itemRef->getType() == "QTimelineAudioItem" )
            {
                itemRef->setBgColor( QTimeline::mAudioItemBgCol );
                itemRef->setBgOverColor( QTimeline::mAudioItemBgOverCol );
                itemRef->setTextColor( QTimeline::mAudioItemTextCol );
                itemRef->setHandleColor( QTimeline::mAudioItemHandleCol );
                itemRef->setHandleOverColor( QTimeline::mAudioItemHandleOverCol );
            }
            
            params = itemRef->getParams();
            
            for( size_t j=0; j < params.size(); j++ )
            {
                params[j]->setBgColor( QTimeline::mParamsBgCol );
                params[j]->setBgOverColor( QTimeline::mParamsBgOverCol );
                params[j]->setTextColor( QTimeline::mParamsTextCol );
                
                params[j]->setKeyframesBgCol( QTimeline::mKeyframesBgCol );
                params[j]->setKeyframesBgOverCol( QTimeline::mKeyframesBgOverCol );
                params[j]->setKeyframesBgSelectedCol( QTimeline::mKeyframesBgSelectedCol );
                params[j]->setKeyframesGraphCol( QTimeline::mKeyframesGraphCol );
            }
        }
    }
    
    cueList = mCueManager->getCueList();
    
    for( size_t k=0; k < cueList.size(); k++ )
    {
        cueRef = cueList[k];
        cueRef->setBgColor( QTimeline::mCueBgCol );
        cueRef->setBgOverColor( QTimeline::mCueBgOverCol );
        cueRef->setFgColor( QTimeline::mCueFgCol );
        cueRef->setTextColor( QTimeline::mCueTextCol );
        cueRef->setHandleColor( QTimeline::mCueHandleCol );
        cueRef->setHandleOverColor( QTimeline::mCueHandleOverCol );
    }
}