// Reads from the queue and loads new images.
//--------------------------------------------------------------
void ofxThreadedImageLoader::threadedFunction() {
	while(true) {
		if(shouldLoadImages()) {
			ofImageLoaderEntry entry = getNextImageToLoad();
			if(entry.image == NULL) {
				continue;
			}
		
			if(entry.type == OF_LOAD_FROM_DISK) {
				entry.image->loadImage(entry.filename);
				lock();
				images_to_update.push_back(entry);
				unlock();
			}
			else if(entry.type == OF_LOAD_FROM_URL) {
				lock();
				images_async_loading.push_back(entry);
				unlock();	
				ofLoadURLAsync(entry.url, entry.name);
			}
		}
		else {
			// TODO: what do we do when there ar eno entries left?
		//	ofSleepMillis(1000);
		}
	}
}
//--------------------------------------------------------------
void testApp::setup(){
    
    //EXAMPLE URL
    //http://cbk0.google.com/cbk?output=xml&ll=51.494966,-0.146674
    //http://cbk0.google.com/cbk?output=xml&ll=%s,%s
    //
    data_url = "http://cbk0.google.com/cbk?output=xml&ll=40.434006,-79.928601";//long, lat
    
    thumbnail_url = "http://cbk0.google.com/cbk?output=thumbnail&w=640&h=320&panoid=";//width, height, panoid
    
    zoom_url = "http://cbk0.google.com/cbk?output=tile&panoid=%s&zoom=4&x=%s&y=%s";//PID, ZOOM, X, Y
    
    
    ofRegisterURLNotification(this);
    ofLoadURLAsync(data_url);
    loading = true;
    
    
    fbo.allocate(512*12, 512*6, GL_RGB);
    fbo.begin();
    ofClear(0, 0, 0);
    fbo.end();
    sphere.set(1000, 60);
    sphere.setPosition(ofVec3f(0, 0, 0));
    
    sphere.mapTexCoordsFromTexture(fbo.getTextureReference());
    cam.setPosition(0, 0, 0);
    
}
示例#3
0
// http://a.tiles.mapbox.com/v3/mapbox.mapbox-streets/9/312/161.png
void Tile::load(int x, int y, int z) {

	unsigned __int64 d = powl(2, z);
	x %= d; y %=d;
	x64 = (x<0) ? d+x : x;
	y64 = (y<0) ? d+y : y;
	z64 = z;

 	key = (z64<<32) | (x64<<16) | y64;

	if(cache.count(key)) {
		img.loadImage(cache[key]);
		return;
	}
	img.clear();
	// 
	//name = "v=112&src=app&x="+ofToString(x)+"&s=&y="+ofToString(y)+"&z="+ofToString(z)+"&s=Galileo";
	//url="https://khms1.google.ru/kh/"+name+".png";
	name = ofToString(z)+"/"+ofToString(x)+"/"+ofToString(y);
	url="http://a.tiles.mapbox.com/v3/mapbox.mapbox-streets/"+name+".png";
	
	ofRegisterURLNotification(this);
	cout << url << "\n";
	ofLoadURLAsync(url, ofToString(id)+":"+name);
}
//--------------------------------------------------------------
void testApp::setup(){
    ofRegisterURLNotification(this);

    font.loadFont("frabk.ttf", 48);
    
    ofLoadURLAsync("http://api.wunderground.com/api/c7c1fbefd0d9e77d/geolookup/q/autoip.json", "autoip");
}
示例#5
0
void Map::processQueue()
{
	if (_queue.size() > (_maxPending - _pending.size()))
    {
        std::sort(_queue.begin(),
                  _queue.end(),
                  QueueSorter(getTileCoordinateCenter().zoomTo(getZoom())));
	}

    // Transfer load queued coordinates.
    while (_pending.size() < _maxPending && !_queue.empty())
    {
		const TileCoordinate& coord = *(_queue.begin());

        std::vector<std::string> urls = _provider->getTileUrls(coord);

        if (!urls.empty())
        {
            _pending[coord] = ofLoadURLAsync(urls[0]);
        }
        else
        {

        }

		_queue.erase(_queue.begin());
	}  
}
示例#6
0
//--------------------------------------------------------------
void testApp::sendRequest(){
    if (URLsToLoad[currentURLNo]!="Info") {
        string requestURL=URLsToLoad[currentURLNo];
        int id = ofLoadURLAsync(requestURL, "async_req");
    }else{
        loadingResponseDone=true;
    }
}
示例#7
0
//--------------------------------------------------------------
void testApp::sendRequest(){
    if (currentURL!="Info") {
        int id = ofLoadURLAsync(currentURL, "async_req");
        loading=true;
    }else{
        loadingResponseDone=true;
        loading=true;
        printf("%s", currentURL.c_str());
    }
}
void ofxStreetView::setLatLon(double _lat, double _lon){
    if(!bRegister){
        ofRegisterURLNotification(this);
        bRegister = true;
    }
    
    clear();
    data_url = "http://cbk0.google.com/cbk?output=xml&ll="+ofToString(_lat)+","+ofToString(_lon)+"&dm=1";
    ofLoadURLAsync(data_url);
}
示例#9
0
//--------------------------------------------------------------
void testApp::sendRequest(){
    if (URLsToLoad[currentURLNo]!="Info") {
        string requestURL=URLsToLoad[currentURLNo];
        int id = ofLoadURLAsync(requestURL, "async_req");
        printf("sending request to %s\n", requestURL.c_str());
    }else{
        loadingResponseDone=true;
        printf("%s", URLsToLoad[currentURLNo].c_str());
    }
}
//--------------------------------------------------------------
void ofxStreetViewCollector::setLatLon(double _lat, double _lon){
    bNewDataCollected = true;
    if(!bRegister){
        ofRegisterURLNotification(this);
        bRegister = true;
    }
    
    data_url = "http://cbk0.google.com/cbk?output=xml&ll="+ofToString(_lat)+","+ofToString(_lon);
    ofLoadURLAsync(data_url);
}
示例#11
0
void testApp::callHueApi( string apiUrl , string callTag )
{
    callHistory.push_back( apiUrl ) ;
    ofLoadURLAsync( apiUrl , callTag ) ;
    
    if ( callHistory.size() > 10 )
    {
       // callHistory.erase( callHistory.begin() ) ;
    }
}
示例#12
0
文件: ofApp.cpp 项目: flair2005/Cell
void ofApp::loadTagIndexData()
{
    //TODO:Make sure this doesn't load if new tags are still fading
    if (!isLoadingXml)
	{
		//printf("loading index\n");
        ofLoadURLAsync("http://192.30.139.232/b10/sites/questionnaire//q-7.xml","tag_index_load");
//        ofLoadURLAsync("https://dl.dropboxusercontent.com/u/1619383/cell/index.xml","tag_index_load");
	}
	isLoadingXml = true;
}
//--------------------------------------------------------------
bool ofxStreetViewCollector::setPanoId(string _pano_id){
    if(points.count(_pano_id) == 0){
        if(!bRegister){
            ofRegisterURLNotification(this);
            bRegister = true;
        }
        data_url = "http://cbk0.google.com/cbk?output=xml&panoid="+_pano_id;
        ofLoadURLAsync(data_url);
        return true;
    }
    return false;
}
void ofxStreetView::setPanoId(string _pano_id){
    if(!bRegister){
        ofRegisterURLNotification(this);
        bRegister = true;
    }
    
    if(_pano_id!=pano_id){
        clear();
        pano_id = _pano_id;
        data_url = "http://cbk0.google.com/cbk?output=xml&panoid="+pano_id+"&dm=1";
        ofLoadURLAsync(data_url);
    }
}
示例#15
0
void
ofxQRcode::fetch(const std::string& data, size_t size, size_t margin)
{
  std::stringstream googleChartsQRurl;
  googleChartsQRurl
  << "http://chart.googleapis.com/chart?"   // Google Charts Endpoint
  << "chs=" << size << "x" << size << "&"   // chart size
  << "cht=qr&"                              // chart type: QR Code
  << "chld=L|" << margin << "&"             // Error correction [L,M,Q,H], margin
  << "choe=UTF-8&"                          // Encoding
  << "chl=" << data;                        // QR code data
  
  ofRegisterURLNotification(this);
  ofLoadURLAsync(googleChartsQRurl.str(), "qrcode");
}
void ofxStreetView::downloadPanorama(){
    if(!bPanoLoaded){
        if(pano_id != ""){
            for(int i = 0; i < 3; i++){
                for(int j = 0; j < 7; j++){
                    ofLoadURLAsync("http://cbk0.google.com/cbk?output=tile&panoid="+pano_id+"&zoom="+ofToString(zoom)+"&x="+ofToString(j)+"&y="+ofToString(i));
                }
            }
        }
        
        if(depth_map_base64 != ""){
            makeDepthMesh();
        }
    }
}
示例#17
0
//--------------------------------------------------------------
void ofApp::sendRequest(){
    if (URLsToLoad[currentURLNo]!="Info") {
        if (URLsToLoad[currentURLNo]==recentPostcards && currImgNo!=0) {
            loadingResponseDone=true;
            printf("%s, %s: %i \n", URLsToLoad[currentURLNo].c_str(), recentPostcards.c_str(), currImgNo);
        } else{
            string requestURL=URLsToLoad[currentURLNo];
            int id = ofLoadURLAsync(requestURL, "async_req");
            printf("%s", requestURL.c_str());
        }
        
    }else{
        loadingResponseDone=true;
    }
}
void DownloaderTask::triggerDownload(){
    ofLog(OF_LOG_NOTICE)<<"Download Triggered"<<endl;
    ofNotifyEvent(downloadStarted, downloadFiles.front(), this); //alert UI that download started...
    ofHttpResponse response = ofLoadURL("http://10.11.12.13/get_last_saved_filename");
    ofLog(OF_LOG_NOTICE)<<response.data<<endl;
    
    string newFile = ofToString(response.data);
    if(ofIsStringInString(newFile, "\"")){
        ofStringReplace(newFile, "\"", "");
    }
    if(newFile != lastFileName){
        lastFileName = newFile;
        
        ofLog(OF_LOG_NOTICE)<<"Download url "<<downloadURL+"/static/asattachment"+lastFileName<<endl;
        ofLoadURLAsync(downloadURL+"/static/asattachment"+lastFileName);
    }
    
    
}
void UIRpiCam::load(){
    image.clear();
    string command = "http://"+host+"/rpicam/?width="+ofToString(width);
    command +="&height="+ofToString(height);
    command +="&quality="+ofToString(quality);
    command +="&sharpness="+ofToString(sharpness);
    command +="&contrast="+ofToString(contrast);
    command +="&brightness="+ofToString(brightness);
    command +="&saturation="+ofToString(saturation);
    command +="&rotation="+ofToString(rotation);
    command +="&exposure="+exposure;
    command +="&awb="+awb;
    command +="&imxfx="+imxfx;
    if(bHFlip){
        command +="&-hflip=1";
    }
    if(bVFlip){
        command +="&-vflip=1";
    }
    ofLoadURLAsync(command,"rpiCam");
    bLoading = true;
}
//--------------------------------------------------------------
void testApp::urlResponse(ofHttpResponse & response){
    if(response.status==200 && response.request.url == data_url){
        XML.loadFromBuffer(response.data);
        data_prop_pano_id = XML.getAttribute("panorama:data_properties", "pano_id", "BLANK");
        if(data_prop_pano_id != "BLANK"){
            thumbnail_url+=data_prop_pano_id;
            for(int i = 0; i < 6; i++){
                for(int j = 0; j < 12; j++){
                    ofLoadURLAsync("http://cbk0.google.com/cbk?output=tile&panoid="+ofToString(data_prop_pano_id)+"&zoom=4&x="+ofToString(j)+"&y="+ofToString(i));
                }
            }
        }
    }if(response.status==200 && response.request.url != data_url){
        img.loadImage(response.data);
        
        //you don't have to resize it
//        img.resize(300, 300);
        images.push_back(img);
        
        loading = false;
    }
    
}
// Reads from the queue and loads new images.
//--------------------------------------------------------------
void ofxThreadedImageLoaderSingleton::threadedFunction() {
    deque<ofImageLoaderEntry> images_to_load;

	while( isThreadRunning() ) {
		lock();
		if(images_to_load_buffer.empty()) condition.wait(mutex);
		images_to_load.insert( images_to_load.end(),
							images_to_load_buffer.begin(),
							images_to_load_buffer.end() );

		images_to_load_buffer.clear();
		unlock();
        
        
        while( !images_to_load.empty() ) {
            ofImageLoaderEntry  & entry = images_to_load.front();
            
            if(entry.type == OF_LOAD_FROM_DISK) {
                if(! entry.image->loadImage(entry.filename) )  { 
                    ofLogError() << "ofxThreadedImageLoaderSingleton error loading image " << entry.filename;
                }
                
                lock();
                images_to_update.push_back(entry);
                unlock();
            }else if(entry.type == OF_LOAD_FROM_URL) {
                lock();
                images_async_loading.push_back(entry);
                unlock();
                
                ofLoadURLAsync(entry.url, entry.name);
            }

    		images_to_load.pop_front();
        }
	}
}
示例#22
0
//--------------------------------------------------------------
void testApp::setup(){
    //base setup
    ofSetFrameRate(FRAME_RATE);
    ofBackground(0);
	ofTrueTypeFont::setGlobalDpi(72);
    ofRegisterURLNotification(this);
    
    //
    recentPostcardsBerlin="http://www.ualphabets.com/requests/Berlin/postcards.php";
    recentLettersBerlin="http://www.ualphabets.com/requests/Berlin/letters.php";
    currentAlphabetBerlin="http://www.ualphabets.com/requests/Berlin/alphabet.php";

    recentPostcardsRiga="http://www.ualphabets.com/requests/Riga/connected/postcards.php";
    recentLettersRiga="http://www.ualphabets.com/requests/Riga/connected/letters.php";
    currentAlphabetRiga="http://www.ualphabets.com/requests/Riga/connected/alphabet.php";
    
    currentQuestion="http://www.ualphabets.com/requests/Riga/connected/question.php";
    
    recentPostcards=recentPostcardsBerlin;
    recentLetters=recentLettersBerlin;
    currentAlphabet=currentAlphabetBerlin;
    info="Info";
    
    //setup of the URLS that need to be loaded
    URLsToLoad[0]=info;
    URLsToLoad[1]=currentQuestion;
    URLsToLoad[2]=recentPostcards;
    URLsToLoad[3]=recentLetters;
    URLsToLoad[4]=recentPostcards;
    URLsToLoad[5]=currentAlphabet;
    URLsToLoad[6]=recentPostcards;
    
    currentURLNo=0; //first screen to be shown
    currentURL=URLsToLoad[currentURLNo];
    loading= true; //send the first request on start alphabets/postcards/...
    
    //setup of Riga and Berlin images in lower corners
    berlin.loadImage("intro/intro_Berlin.png");
    riga.loadImage("intro/intro_Riga.png");
    
    //setup for intro screens before actual
    loadingResponseDone=false;
    blendInfo=0;
    introLength=4;
    
    //setup for alphabet screen
    counterDrawAlphabet=0;
    alphabetLength=10;
    alphabetTitle.loadImage("intro/intro_currentAlphabet.png");
    berlinAlphabetLoaded=false;
    
    //setup for postcards and letters screen
    lengthPostcards=8;//in secs
    lengthLetters=10;//in secs
    counterPostcardsAndLetters=0;
    counterNumberPostcards=0;
    lettersTitle.loadImage("intro/intro_titleLetters.png");
    postcardsTitle.loadImage("intro/intro_titlePostcards.png");
    
    //changing questions setup
    questions[0].loadImage("questions/questions_english_ -01.png");
    questions[1].loadImage("questions/questions_english_ -02.png");
    questions[2].loadImage("questions/questions_english_ -03.png");
    questions[3].loadImage("questions/questions_english_ -04.png");
    questions[4].loadImage("questions/questions_english_ -05.png");
    currentQuestionNumber=0;

    
    //the German alphabet
    alphabetGerman[0]="A";
    alphabetGerman[1]="B";
    alphabetGerman[2]="C";
    alphabetGerman[3]="D";
    alphabetGerman[4]="E";
    alphabetGerman[5]="F";
    alphabetGerman[6]="G";
    alphabetGerman[7]="H";
    alphabetGerman[8]="I";
    alphabetGerman[9]="J";
    alphabetGerman[10]="K";
    alphabetGerman[11]="L";
    alphabetGerman[12]="M";
    alphabetGerman[13]="N";
    alphabetGerman[14]="O";
    alphabetGerman[15]="P";
    alphabetGerman[16]="Q";
    alphabetGerman[17]="R";
    alphabetGerman[18]="S";
    alphabetGerman[19]="T";
    alphabetGerman[20]="U";
    alphabetGerman[21]="V";
    alphabetGerman[22]="W";
    alphabetGerman[23]="X";
    alphabetGerman[24]="Y";
    alphabetGerman[25]="Z";
    alphabetGerman[26]="AA";
    alphabetGerman[27]="OO";
    alphabetGerman[28]="UU";
    alphabetGerman[29]=".";
    alphabetGerman[30]="!";
    alphabetGerman[31]="?";
    alphabetGerman[32]="0";
    alphabetGerman[33]="1";
    alphabetGerman[34]="2";
    alphabetGerman[35]="3";
    alphabetGerman[36]="4";
    alphabetGerman[37]="5";
    alphabetGerman[38]="6";
    alphabetGerman[39]="7";
    alphabetGerman[40]="8";
    alphabetGerman[41]="9";
    
    //the latvian alphabet
    alphabetLatvian[0]="A";
    alphabetLatvian[1]="LatvA";
    alphabetLatvian[2]="B";
    alphabetLatvian[3]="C";
    alphabetLatvian[4]="LatvC";
    alphabetLatvian[5]="D";
    alphabetLatvian[6]="E";
    alphabetLatvian[7]="LatvE";
    alphabetLatvian[8]="F";
    alphabetLatvian[9]="G";
    alphabetLatvian[10]="LatvG";
    alphabetLatvian[11]="H";
    alphabetLatvian[12]="I";
    alphabetLatvian[13]="LatvI";
    alphabetLatvian[14]="J";
    alphabetLatvian[15]="K";
    alphabetLatvian[16]="LatvK";
    alphabetLatvian[17]="L";
    alphabetLatvian[18]="LatvL";
    alphabetLatvian[19]="M";
    alphabetLatvian[20]="N";
    alphabetLatvian[21]="LatvN";
    alphabetLatvian[22]="O";
    alphabetLatvian[23]="P";
    alphabetLatvian[24]="R";
    alphabetLatvian[25]="S";
    alphabetLatvian[26]="LatvS";
    alphabetLatvian[27]="T";
    alphabetLatvian[28]="U";
    alphabetLatvian[29]="LatvU";
    alphabetLatvian[30]="V";
    alphabetLatvian[31]="Z";
    alphabetLatvian[32]="LatvZ";
    alphabetLatvian[33]="1";
    alphabetLatvian[34]="2";
    alphabetLatvian[35]="3";
    alphabetLatvian[36]="4";
    alphabetLatvian[37]="5";
    alphabetLatvian[38]="6";
    alphabetLatvian[39]="7";
    alphabetLatvian[40]="8";
    alphabetLatvian[41]="9";
    
    //send the first request
    if (currentURL!="Info") {
        printf("now \n");
        int id = ofLoadURLAsync(currentURL, "async_req");
    } else {
        printf("%s", currentURL.c_str());
        loadingResponseDone=true;
    }
        
}
示例#23
0
//--------------------------------------------------------------
void ofApp::setup(){
    //base setup
    ofSetFrameRate(FRAME_RATE);
    ofBackground(0);
    ofTrueTypeFont::setGlobalDpi(72);
    ofRegisterURLNotification(this);
    ofHideCursor();
    
    //
    recentPostcards="http://www.ualphabets.com/requests/Aarhus/postcards.php";
    recentLetters="http://www.ualphabets.com/requests/Aarhus/letters.php";
    currentAlphabet="http://www.ualphabets.com/requests/Aarhus/alphabet.php";
    currentQuestion="http://www.ualphabets.com/requests/Riga/connected/question.php";
    
    info="Info";
    
    //setup of the URLS that need to be loaded
    URLsToLoad[0]=info;
    URLsToLoad[1]=currentQuestion;
    URLsToLoad[2]=recentPostcards;
    URLsToLoad[3]=currentAlphabet;
    URLsToLoad[4]=recentPostcards;
    URLsToLoad[5]=recentLetters;
    URLsToLoad[6]=recentPostcards;
    
    currentURLNo=0; //first screen to be shown
    currentURL=URLsToLoad[currentURLNo];
    //loading= true; //send the first request on start alphabets/postcards/...
    
    englishTitleScale=0.8;
    
    switchedFromVideo=false;
    
    //setup for intro screens before actual
    loadingResponseDone=false;
    blendInfo=0;
    introLength=5;
    
    //setup for alphabet screen
    counterDrawAlphabet=0;
    alphabetLength=10;
    counterAlphabetsTitle=0;
    alphabetTitle.loadImage("intro/intro_currentAlphabet.png");
    
    //setup for postcards and letters screen
    lengthPostcards=8;//in secs
    lengthLetters=7;//in secs
    counterPostcardsAndLetters=0;
    counterPostcardsTitle=0;
    counterPostcardsQuestion=0;
    counterLettersTitle=0;
    counterNumberPostcards=0;
    lettersTitle.loadImage("intro/intro_titleLetters.png");
    postcardBlendedIn=0;
    postcardBlendedOut=0;
    
    //changing questions setup
    questions[0].loadImage("questions/questions_english_ -01.png");
    questions[1].loadImage("questions/questions_english_ -02.png");
    questions[2].loadImage("questions/questions_english_ -03.png");
    questions[3].loadImage("questions/questions_english_ -04.png");
    
    currentQuestionNumber=0;
    postcardsTitle.loadImage("intro/intro_titlePostcards.png");
    
    //the latvian alphabet
    alphabet[0]="A";
    alphabet[1]="B";
    alphabet[2]="C";
    alphabet[3]="D";
    alphabet[4]="E";
    alphabet[5]="F";
    alphabet[6]="G";
    alphabet[7]="H";
    alphabet[8]="I";
    alphabet[9]="J";
    alphabet[10]="K";
    alphabet[11]="L";
    alphabet[12]="M";
    alphabet[13]="N";
    alphabet[14]="O";
    alphabet[15]="P";
    alphabet[16]="Q";
    alphabet[17]="R";
    alphabet[18]="S";
    alphabet[19]="T";
    alphabet[20]="U";
    alphabet[21]="V";
    alphabet[22]="W";
    alphabet[23]="X";
    alphabet[24]="Y";
    alphabet[25]="Z";
    alphabet[26]="ae";
    alphabet[27]="danisho";
    alphabet[28]="AAA";
    alphabet[29]=".";
    alphabet[30]="!";
    alphabet[31]="?";
    alphabet[32]="0";
    alphabet[33]="1";
    alphabet[34]="2";
    alphabet[35]="3";
    alphabet[36]="4";
    alphabet[37]="5";
    alphabet[38]="6";
    alphabet[39]="7";
    alphabet[40]="8";
    alphabet[41]="9";
    
    
    //send the first request
    if (currentURL!="Info") {
        printf("now \n");
        int id = ofLoadURLAsync(currentURL, "async_req");
    } else {
        printf("%s", currentURL.c_str());
        loadingResponseDone=true;
    }
}
示例#24
0
文件: ofApp.cpp 项目: flair2005/Cell
void ofApp::update()
{
    //if (ofGetFrameRate() < targetframeRate)
    //    frameRate += 0.1;
    //else
    //    frameRate -= 0.1;
    //if (frameRate > targetframeRate * 2) frameRate = targetframeRate * 2;
	//printf("ofGetFrameRate():%f, frameRate:%f, targetFrameRate:%f\n", ofGetFrameRate(), frameRate, targetframeRate);

	//if (ofGetFrameNum() % 30 == 0) 
	//ofSetFrameRate(frameRate);
	ofSetFrameRate(targetframeRate);

	if (gui.getVisible()) 
		ofShowCursor();
	else
		ofHideCursor();
    
	if (!isPaused)
	{
		if (isKinectAttached) kinectManager.update(); // kinectManager.update();
		sceneManager.update();
        resourceManager.update();
	}
    
//    framesSinceMouseMove++;
//    if (framesSinceMouseMove > 100)
//        ofHideCursor();
//    else
//        ofShowCursor();
    
    
    //    if (++currentEllapsedFrames >= xmlCheckFrameFrequency)
    //    {
    //        printf("- Should be loading tag index xml \n");
    //        currentEllapsedFrames = 0;
    //        checkNewTagIndex();
    //    }
    
    
    
    if (isNewIndexXml)
	{
        isNewIndexXml = false;
        tagIndexXml.loadFromBuffer(tagIndexData);
        printf("loaded index data = %s\n", tagIndexData.c_str());
        latestTagTotal = ofToInt(tagIndexXml.getValue(""));
        cout << "loaded xml - latestTagTotal = " << latestTagTotal << ", xml loaded " << timesLoaded << " times" << endl;
        
		if (latestTagTotal != currentTagTotal && !isFirstIndexLoad && !isLoadingXml)
		{
			ofLoadURLAsync("http://192.30.139.232/b10/sites/questionnaire//q-7/" + ofToString(latestTagTotal) + ".xml","tag_data_load");
			//ofLoadURLAsync("https://dl.dropboxusercontent.com/u/1619383/cell/" + ofToString(latestTagTotal) + ".xml","tag_data_load");
			isLoadingXml = true;
		}
		isFirstIndexLoad = false;
		currentTagTotal = latestTagTotal;
    }
    
	if (isNewTagDataXml)
	{
		isNewTagDataXml = false;
		tagDataXml.loadFromBuffer(newTagData);
        latestTag = tagDataXml.getValue("content");
        int question = ofToInt(tagDataXml.getValue("question"));
        printf("latestTag = %s, newTag string length = %li \n", latestTag.c_str(), latestTag.size());
        resourceManager.addNewTag(latestTag, question);
	}
    
    
    
    
    
    
    //return;
	if (ofGetFrameNum() % (int)serverCheckFrequncy == 0 && ofGetFrameNum() > 10)
    {
        
#ifdef CELL_ONLINE
		loadTagIndexData();
#else
        testTagIndexXml.load("xml/_newTagTest/index.xml");
        latestTagTotal = ofToInt(testTagIndexXml.getValue(""));
        printf("loaded tag index xml - latestTagTotal = %i, currentTagTotal = %i\n", latestTagTotal, currentTagTotal);
        if (latestTagTotal != currentTagTotal && !isFirstIndexLoad && !isLoadingXml)
		{
            tempTagXml.load("xml/_newTagTest/" + ofToString(latestTagTotal) + ".xml");
            latestTag = tempTagXml.getValue("content");
            int question = ofToInt(tempTagXml.getValue("question"));
            printf("latestTag = %s, newTag string length = %li \n", latestTag.c_str(), latestTag.size());
            resourceManager.addNewTag(latestTag, question);
        }
        isFirstIndexLoad = false;
		currentTagTotal = latestTagTotal;
#endif
    }
    
}
示例#25
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
	img.clear();
	ofLoadURLAsync("http://images.wildmadagascar.org/pictures/bemaraha/tsingy_forest.JPG","tsingy_forest");
	loading =true;
}
示例#26
0
//--------------------------------------------------------------
void ofApp::setup(){
    //base setup
    ofSetFrameRate(FRAME_RATE);
    ofBackground(0);
    ofTrueTypeFont::setGlobalDpi(72);
    ofRegisterURLNotification(this);
    
    syphonServer.setName("Syphon Output");
    
    //size of LED 2
    screenWidth=480;
    screenHeight=288;
    
    //
    recentPostcards="http://www.ualphabets.com/requests/SaoPaulo/postcards.php";
    recentLetters="http://www.ualphabets.com/requests/SaoPaulo/letters.php";
    currentAlphabet="http://www.ualphabets.com/requests/SaoPaulo/alphabet.php";
    currentQuestion="http://www.ualphabets.com/requests/Riga/connected/question.php";
    
    info="Info";
    
    //setup of the URLS that need to be loaded
    URLsToLoad[0]=info;
    URLsToLoad[1]=currentAlphabet;//currentQuestion;
    URLsToLoad[2]=recentPostcards;
    URLsToLoad[3]=recentLetters;
    URLsToLoad[4]=recentPostcards;
    URLsToLoad[5]=currentAlphabet;
    URLsToLoad[6]=recentPostcards;
    
    currentURLNo=0; //first screen to be shown
    currentURL=URLsToLoad[currentURLNo];
    loading= true; //send the first request on start alphabets/postcards/...
    
    
    //setup for intro screens before actual
    loadingResponseDone=false;
    blendInfoFacade=0;
    blendInfoLED2=0;
    introLength=5;
    
    //setup for alphabet screen
    counterDrawAlphabet=0;
    alphabetLength=11.6;
    counterAlphabetsTitle=0;
    alphabetTitleFacade.loadImage("intro_facade/intro_currentAlphabet.png");
    alphabetTitleLED2.loadImage("intro_LED2/intro_currentAlphabet.png");
    
    //setup for postcards and letters screen
    lengthPostcards=12;//in secs
    lengthLetters=8;//in secs
    counterPostcardsAndLetters=0;
    counterPostcardsTitle=0;
    counterPostcardsQuestion=0;
    counterLettersTitle=0;
    counterNumberPostcards=0;
    lettersTitleFacade.loadImage("intro_facade/intro_titleLetters.png");
    lettersTitleLED2.loadImage("intro_LED2/intro_titleLetters.png");
    currImgNo=0;
    
    //changing questions setup
    questionsFacade[0].loadImage("questions_facade/questions_english_-01.png");
    questionsFacade[1].loadImage("questions_facade/questions_english_-02.png");
    questionsFacade[2].loadImage("questions_facade/questions_english_-03.png");
    questionsFacade[3].loadImage("questions_facade/questions_english_-04.png");
    //LED questions
    questionsLED2[0].loadImage("questions_LED2/questions_english_-01.png");
    questionsLED2[1].loadImage("questions_LED2/questions_english_-02.png");
    questionsLED2[2].loadImage("questions_LED2/questions_english_-03.png");
    questionsLED2[3].loadImage("questions_LED2/questions_english_-04.png");
    currentQuestionNumber=0;
    postcardsTitleLED2.loadImage("intro_LED2/intro_titlePostcards.png");
    
    
    //the latvian alphabet
    alphabet[0]="A";
    alphabet[1]="B";
    alphabet[2]="C";
    alphabet[3]="D";
    alphabet[4]="E";
    alphabet[5]="F";
    alphabet[6]="G";
    alphabet[7]="H";
    alphabet[8]="I";
    alphabet[9]="J";
    alphabet[10]="K";
    alphabet[11]="L";
    alphabet[12]="M";
    alphabet[13]="N";
    alphabet[14]="O";
    alphabet[15]="P";
    alphabet[16]="Q";
    alphabet[17]="R";
    alphabet[18]="S";
    alphabet[19]="T";
    alphabet[20]="U";
    alphabet[21]="V";
    alphabet[22]="W";
    alphabet[23]="X";
    alphabet[24]="Y";
    alphabet[25]="Z";
    alphabet[26]="+";
    alphabet[27]="$";
    alphabet[28]=",";
    alphabet[29]=".";
    alphabet[30]="!";
    alphabet[31]="?";
    alphabet[32]="0";
    alphabet[33]="1";
    alphabet[34]="2";
    alphabet[35]="3";
    alphabet[36]="4";
    alphabet[37]="5";
    alphabet[38]="6";
    alphabet[39]="7";
    alphabet[40]="8";
    alphabet[41]="9";
    
    
    //send the first request
    if (currentURL!="Info") {
        printf("now \n");
        int id = ofLoadURLAsync(currentURL, "async_req");
    } else {
        printf("%s", currentURL.c_str());
        loadingResponseDone=true;
    }
    


}
示例#27
0
void testApp::loadURL_alphabetGerman(ofHttpResponse &response){
    newAlphabet.clear();
    int numberOfLettersAdded=0;
    vector<AlphabetEntry> allLetters;
    for (int i=0; i<allEntries.size(); i++) {
        ofStringReplace(allEntries[i], "letter\":\"", "");
        vector<string> cutEntries =ofSplitString(allEntries[i], "\",\"");
        //delete the first parts in all of them
        ofStringReplace(cutEntries[0], "\"ID\":\"","");
        ofStringReplace(cutEntries[0], "\"", "");
        ofStringReplace(cutEntries[1], "\"", "");
        string letter=cutEntries[1];
        if (i>1) {
            if (allLetters[numberOfLettersAdded-1]._letter!=letter) {
                AlphabetEntry entry(cutEntries[0], cutEntries[1], numberOfLettersAdded);
                allLetters.push_back(entry);
                numberOfLettersAdded++;
            }
        } else{
            AlphabetEntry entry(cutEntries[0], cutEntries[1], i);
            allLetters.push_back(entry);
            numberOfLettersAdded++;
        }
    }
    //printf("number of Letters received: %i\n", numberOfLettersAdded);
    
    for (int j=0; j<42; j++) {
        //go through all letters we have
        for (int i=0; i<allLetters.size(); i++){
            if (allLetters[i]._letter==alphabetGerman[j]) {
                AlphabetEntry entry(ofToString(allLetters[i]._id), allLetters[i]._letter, j);
                newAlphabet.push_back(entry);
                break;
            } else if (i==allLetters.size()-1){
                AlphabetEntry entry("0000", alphabetGerman[j], j);
                newAlphabet.push_back(entry);
                break;
            }
        }
    }
    //if first time load > put the letters directly into the alphabet
    if (allAlphabetBerlin.size()<1) {
        for (int j=0; j<newAlphabet.size(); j++) {
            allAlphabetBerlin.push_back(newAlphabet[j]);
            if (allAlphabetBerlin[j]._id!=0) {
                allAlphabetBerlin[j].loadImage();
            }else{
                //load letter from image directory
                allAlphabetBerlin[j].loadImageDirectory();
            }

        }
    }else{//if there is already something in the alphabet
        for (int j=0; j<42; j++) {
            if (allAlphabetBerlin[j]._id!=newAlphabet[j]._id) {
                allAlphabetBerlin[j]=newAlphabet[j];
                allAlphabetBerlin.push_back(newAlphabet[j]);
                if (allAlphabetBerlin[j]._id!=0) {
                    allAlphabetBerlin[j].loadImage();
                }else{
                    //load letter from image directory
                    allAlphabetBerlin[j].loadImageDirectory();
                }

            }else{
                allAlphabetBerlin[j].reset();
            }
        }
    }
    if (response.status==200 && response.request.name=="async_req") {
        currImgNo1=0;
        currImgNo2=1;
        currImgNo3=2;
        currImgNo4=3;
        currImgNo5=4;
    }
    if (currentAlphabet==currentAlphabetBerlin) {
        currentAlphabet=currentAlphabetRiga;
        //sending request to Riga
        int id = ofLoadURLAsync(currentAlphabet, "async_req");
    } else{
        currentAlphabet=currentAlphabetBerlin;
    }
    berlinAlphabetLoaded=true;
}
示例#28
0
void testApp::loadURL_recentLetters(ofHttpResponse &response){
    if (recentLetters==recentLettersBerlin) {
        allLettersBerlin.clear();
    } else{
        allLettersRiga.clear();
    }
    for (int i=0; i<allEntries.size(); i++) {
        vector<string> cutEntries=ofSplitString(allEntries[i], ",");
        //delete the first parts in all of them
        ofStringReplace(cutEntries[0], "\"ID\":\"", "");
        ofStringReplace(cutEntries[1], "\"letter\":\"", "");
        ofStringReplace(cutEntries[2], "\"owner\":\"", "");
        //delete the last " in all of them
        ofStringReplace(cutEntries[0], "\"", "");
        ofStringReplace(cutEntries[1], "\"", "");
        ofStringReplace(cutEntries[2], "\"", "");
        string rigaBerlin="";
        if (recentLetters==recentLettersBerlin) {
            rigaBerlin="Berlin";
        }else {
            rigaBerlin="Riga";
        }
        Letter entry(cutEntries[0], cutEntries[1], cutEntries[2], i, rigaBerlin);
        if (recentLetters==recentLettersBerlin) {
            if(allLettersBerlin.size()<3){
                allLettersBerlin.push_back(entry);
                allLettersBerlin[allLettersBerlin.size()-1].loadImage();
            } else{
                for (int i=0; i<allLettersBerlin.size(); i++) {
                    /*printf("allPostcardsBerlinsize-1: %i", (int)allPostcardsBerlin.size()-1);
                     printf("i: %i", i);
                     printf("entry id: %i  ", entry._id);
                     printf("postcard id: %i\n", allPostcardsBerlin[i]._id);*/
                    if (entry._id==allLettersBerlin[i]._id) {
                        break;
                    }
                    if (i==allLettersBerlin.size()-1) {
                        allLettersBerlin.insert(allLettersBerlin.begin(),entry);
                        allLettersBerlin[0].loadImage();
                        allLettersBerlin.pop_back();
                        break;
                    }
                }
            }
        } else{
            if(allLettersRiga.size()<3){
                allLettersRiga.push_back(entry);
                allLettersRiga[allLettersRiga.size()-1].loadImage();
            } else{
                for (int i=0; i<allLettersRiga.size(); i++) {
                    if (entry._id==allLettersRiga[i]._id) {
                        break;
                    }
                    if (i==allLettersRiga.size()-1) {
                        allLettersRiga.insert(allLettersBerlin.begin(),entry);
                        allLettersRiga[0].loadImage();
                        allLettersRiga.pop_back();
                        break;
                    }
                }
            }
        }
    }
    if (response.status==200 && response.request.name=="async_req") {
        //setup which ones are shown first
        currLetterImgNo1=allLettersBerlin.size()-1;
        currLetterImgNo2=allLettersBerlin.size()-2;
        currLetterImgNo3=allLettersBerlin.size()-3;
        currLetterImgNo4=allLettersBerlin.size()-4;
        currLetterImgNo5=allLettersBerlin.size()-5;
        
        if (recentLetters==recentLettersBerlin) {
            recentLetters =recentLettersRiga;
            //sending request to Riga
            int id = ofLoadURLAsync(recentLetters, "async_req");
        } else{
            recentLetters=recentLettersBerlin;
        }
    }
}
示例#29
0
//--------------------------------------------------------------
void ofxTwitter::parseResponse(ofxJSONElement result) {
    
    if(result.isMember("statuses")) {
        
        data.clear();
        
        ofxJSONElement trends = result["statuses"];
        
        for(int i = 0; i < trends.size(); i++) {
            
            ofxTwitterTweet tweet;
            
            tweet.id_str = trends[i]["id_str"].asString();
            tweet.created_at = trends[i]["created_at"].asString();
            tweet.language = trends[i]["language"].asString();
            tweet.text = trends[i]["text"].asString();
            
            if(trends[i]["geo"] != Json::Value::null) {
                tweet.geo = trends[i]["geo"]["type"].asString();
                tweet.coordinates.x = trends[i]["geo"]["coordinates"][0].asFloat();
                tweet.coordinates.y = trends[i]["geo"]["coordinates"][1].asFloat();
            }
            
            tweet.source = trends[i]["source"].asString();
            tweet.retweet_count = trends[i]["retweet_count"].asInt();
            tweet.truncated = trends[i]["truncated"].asBool();
            
            ofxJSONElement author = trends[i]["user"];
            
            tweet.user.id_str = author["id_str"].asString();
            tweet.user.uri = "https://twitter.com/"+author["screen_name"].asString();
            
            tweet.user.name = author["name"].asString();
            tweet.user.screen_name = author["screen_name"].asString();
            tweet.user.description = author["description"].asString();
            if(author["location"].asString() != " ") {
                tweet.user.location = author["location"].asString();
            }
            tweet.user.lang = author["lang"].asString();
            tweet.user.url = author["url"].asString();
            
            tweet.user.default_profile = author["default_profile"].asBool();
            tweet.user.default_profile_image = author["default_profile_image"].asBool();
            tweet.user.geo_enabled = author["geo_enabled"].asBool();
            
            tweet.user.profile_image_url = author["profile_image_url"].asString();
            if(author["profile_image_url"] != Json::Value::null && bLoadUserProfileImageOnMemory) {
                ofLoadURLAsync(tweet.user.profile_image_url, "profile_"+tweet.user.id_str);
            }
            
            tweet.user.profile_banner_url = author["profile_banner_url"].asString();
            if(author["profile_banner_url"] != Json::Value::null && bLoadUserBannerImageOnMemory) {
                ofLoadURLAsync(tweet.user.profile_banner_url, "banner_"+tweet.user.id_str);
            }
            
            tweet.user.profile_background_image_url = author["profile_background_image_url"].asString();
            tweet.user.profile_background_color = author["profile_background_color"].asString();
            
            tweet.user.profile_background_tile  = author["profile_background_tile"].asBool();
            tweet.user.profile_use_background_image  = author["profile_use_background_image"].asBool();
            
            data.push_back( tweet );
            //tweet.print();
            
        }
        
        ofLogNotice("ofxTwitter::parseResponse") << "(" << data.size() << ") Tweets ready";
        
    }

}
示例#30
0
void testApp::loadURL_recentPostcards(ofHttpResponse &response){
    if (allEntries.size()>1) {
        for(int i=0; i<allEntries.size(); i++){
            vector<string> cutEntries =ofSplitString(allEntries[i], ",");
            /*for (int i=0; i<cutEntries.size(); i++) {
                printf("%s\n", cutEntries[i].c_str());
            }*/
            //delete the first parts in all of them
            ofStringReplace(cutEntries[0], "\"ID\":\"", "");
            ofStringReplace(cutEntries[1], "\"longitude\":\"", "");
            ofStringReplace(cutEntries[2], "\"latitude\":\"", "");
            ofStringReplace(cutEntries[3], "\"postcardText\":\"", "");
            ofStringReplace(cutEntries[4], "\"owner\":\"", "");
            ofStringReplace(cutEntries[5], "\"date\":\"", "");
            //delete the last " in all of them
            ofStringReplace(cutEntries[0], "\"", "");
            ofStringReplace(cutEntries[1], "\"", "");
            ofStringReplace(cutEntries[2], "\"", "");
            ofStringReplace(cutEntries[3], "\"", "");
            ofStringReplace(cutEntries[4], "\"", "");
            ofStringReplace(cutEntries[5], "\"", "");
            //printf("cutEntries0=%s", cutEntries[0].c_str());
            string rigaBerlin="";
            if (recentPostcards==recentPostcardsBerlin) {
                rigaBerlin="Berlin";
            }else {
                rigaBerlin="Riga";
            }
            Postcard entry(cutEntries[0], cutEntries[1], cutEntries[2],cutEntries[3],cutEntries[4], rigaBerlin, cutEntries[5]);
            if (recentPostcards==recentPostcardsBerlin) {
                if(allPostcardsBerlin.size()<5){
                    allPostcardsBerlin.push_back(entry);
                    allPostcardsBerlin[allPostcardsBerlin.size()-1].loadImage();
                } else{
                    for (int i=0; i<allPostcardsBerlin.size(); i++) {
                        /*printf("allPostcardsBerlinsize-1: %i", (int)allPostcardsBerlin.size()-1);
                        printf("i: %i", i);
                        printf("entry id: %i  ", entry._id);
                        printf("postcard id: %i\n", allPostcardsBerlin[i]._id);*/
                        if (entry._id==allPostcardsBerlin[i]._id) {
                            break;
                        }
                        if (i==allPostcardsBerlin.size()-1) {
                            allPostcardsBerlin.insert(allPostcardsBerlin.begin(),entry);
                            allPostcardsBerlin[0].loadImage();
                            allPostcardsBerlin.pop_back();
                            break;
                        }
                    }
                }
            } else{
                if(allPostcardsRiga.size()<5){
                    allPostcardsRiga.push_back(entry);
                    allPostcardsRiga[allPostcardsRiga.size()-1].loadImage();
                } else{
                    for (int i=0; i<allPostcardsRiga.size(); i++) {
                        /*printf("allPostcardsRigasize-1: %i", (int)allPostcardsRiga.size()-1);
                        printf("i: %i", i);
                        printf("entry id: %i  ", entry._id);
                        printf("postcard id: %i\n", allPostcardsRiga[i]._id);*/
                        if (entry._id==allPostcardsRiga[i]._id) {
                            break;
                        }
                        if (i==allPostcardsRiga.size()-1) {
                            allPostcardsRiga.insert(allPostcardsRiga.begin(),entry);
                            allPostcardsRiga[0].loadImage();
                            allPostcardsRiga.pop_back();
                            break;
                        }
                    }
                }
            }
        }
    }
    
    //just for testing
    //printf("allPostcards size %lu \n", allPostcards.size());
    /*for (int i=0; i<allPostcardsBerlin.size(); i++) {
     allPostcardsBerlin[i].print();
     }*/
    if (response.status==200 && response.request.name=="async_req") {
        //setup which ones are shown first
        if(allPostcardsBerlin.size()>allPostcardsRiga.size()){
            currImgNo=allPostcardsBerlin.size()-1;
        }else{
            currImgNo=allPostcardsRiga.size()-1;
        }
    } else{
        //printf("not loaded \n");
        
    }
    if (recentPostcards==recentPostcardsBerlin) {
        recentPostcards=recentPostcardsRiga;
        //sending request to Riga
        int id = ofLoadURLAsync(recentPostcards, "async_req");
    } else{
        recentPostcards=recentPostcardsBerlin;
    }
}