//this captures all our control panel events - unless its setup differently in testApp::setup //-------------------------------------------------------------- void SinglePanelImagePixelFactory::eventsIn(guiCallbackData & data){ if(data.getDisplayName() == "Images"){ std::ostringstream localOSS; string contentDirectoryName = data.getString(2).c_str(); localOSS << "panelImages/" << contentDirectoryName; string directoryToList = localOSS.str(); int numberOfImages = content.listDir(directoryToList); images.resize(numberOfImages); //resize the vector, maybe back to zero if(images.size() > 0){ for(int i=0; i < images.size(); i++){ std::ostringstream contentPathOSS; contentPathOSS << directoryToList << "/" << content.entries[i].filename; string contentPath = contentPathOSS.str(); images[i].loadImage(contentPath); } } imageIndexToUse = 0; inited = true; } }
void testApp::drawInputEvent(guiCallbackData &data) { if (data.isElement("draw_input") && data.getInt(0) == 1) { drawInputVideo = true; } else { drawInputVideo = false; } }
void ofApp::onGuiEvent(guiCallbackData & d){ if(d.getDisplayName() == "Scene"){ socket.send("/setScene " +d.getString(0)); currentScene = ofToInt(d.getString(0)); } }
//----------------------NOT CURRENTLY USED---------------------------------------- void testApp::grabBackgroundEvent(guiCallbackData & data){ //we use the event callback to capture the background - we then set the toggle value back to its previous value if( data.isElement( "GRAB_BACKGROUND" ) && data.getInt(0) == 1 ){ // bgExample.captureBackground(); gui.setValueB("GRAB_BACKGROUND", false); } }
void CameraColorSampler::panelValueChanged(guiCallbackData& data) { string name = data.getXmlName(); if(name=="gain") ps3eye.setGain(data.getFloat(0)); else if(name=="shutter") ps3eye.setShutter(data.getFloat(0)); else if(name=="gamma") ps3eye.setGamma(data.getFloat(0)); else if(name=="brightness") ps3eye.setBrightness(data.getFloat(0)); else if(name=="contrast") ps3eye.setContrast(data.getFloat(0)); else if(name=="hue") ps3eye.setHue(data.getFloat(0)); else if(name=="flicker") ps3eye.setFlicker(data.getInt(0)); else if(name=="white_balance") ps3eye.setWhiteBalance(data.getInt(0)+1); }
//this captures all our control panel events - unless its setup differently in testApp::setup //-------------------------------------------------------------- void SlitStretchFactory::eventsIn(guiCallbackData & data){ if(data.getDisplayName() == "Images"){ inited = false; std::ostringstream localOSS; string contentFilename = data.getString(2).c_str(); localOSS << "imagesToSlitAndStretch/" << contentFilename; string contentPath = localOSS.str(); currentContentPath = contentPath; inited = true; doImageResize(); } // // print to terminal if you want to // //this code prints out the name of the events coming in and all the variables passed // printf("testApp::eventsIn - name is %s - \n", data.getXmlName().c_str()); // if( data.getDisplayName() != "" ){ // printf(" element name is %s \n", data.getDisplayName().c_str()); // } // for(int k = 0; k < data.getNumValues(); k++){ // if( data.getType(k) == CB_VALUE_FLOAT ){ // printf("%i float value = %f \n", k, data.getFloat(k)); // } // else if( data.getType(k) == CB_VALUE_INT ){ // printf("%i int value = %i \n", k, data.getInt(k)); // } // else if( data.getType(k) == CB_VALUE_STRING ){ // printf("%i string value = %s \n", k, data.getString(k).c_str()); // } // } // // printf("\n"); }
//This is protected //--------------------------------------------- void ofxControlPanel::eventsIn(guiCallbackData & data){ if( !eventsEnabled ) return; //we notify the ofxControlPanel event object - aka the global ALL events callback ofNotifyEvent(guiEvent, data, this); //we then check custom event groups for(int i = 0; i < customEvents.size(); i++){ for(int k = 0; k < customEvents[i]->names.size(); k++){ if( customEvents[i]->names[k] == data.getXmlName() ){ ofNotifyEvent(customEvents[i]->guiEvent, data, this); } } } }
//-------------------------------------------------------------- void Therenect::eventsIn(guiCallbackData & data){ string eventName = data.getXmlName(); printf("event name is %s\n", eventName.c_str()); if (eventName=="ANTENNA_DISTANCE") { position = 255-data.getInt(0); volumePoint.z = position; pitchPoint.z = position; } else if (eventName=="KINECT_ANGLE") { tiltAngle = data.getInt(0); } else if (eventName=="MIDI_ENABLED") { midi_on = data.getInt(0); if (midi_on) { midi.openPort(gui.getValueI("MIDI_DEVICE", 0)); if (!scale) { scale=1; gui.setValueI("SCALE", scale, 0); } } else { midi.closePort(); scale = 0; midi_note = 0; gui.setValueI("SCALE", scale, 0); } } else if (eventName=="MIDI_DEVICE") { if (midi_on) { midi.closePort(); midi.openPort(gui.getValueI("MIDI_DEVICE", 0)); } } else if (eventName=="MIDI_CHANNEL") { midi_channel = data.getInt(0); } else if (eventName=="WAVE") { oscmode = data.getInt(0); } else if (eventName=="SCALE") { scale = data.getInt(0); } else if (eventName=="FREQ_RANGE") { range = 50.0f+data.getFloat(0)/2.0f; } }
//this captures all our control panel events - unless its setup differently in testApp::setup //-------------------------------------------------------------- void testApp::eventsIn(guiCallbackData & data){ // //lets send all events to our logger // if( !data.isElement( "events logger" ) ){ // string logStr = data.getXmlName(); // // for(int k = 0; k < data.getNumValues(); k++){ // logStr += " - " + data.getString(k); // } // // logger.log(OF_LOG_NOTICE, "event - %s", logStr.c_str()); // } // print to terminal if you want to //this code prints out the name of the events coming in and all the variables passed // printf("testApp::eventsIn - name is %s - \n", data.getXmlName().c_str()); // if( data.getDisplayName() != "" ){ // printf(" element name is %s \n", data.getDisplayName().c_str()); // } // for(int k = 0; k < data.getNumValues(); k++){ // if( data.getType(k) == CB_VALUE_FLOAT ){ // printf("%i float value = %f \n", k, data.getFloat(k)); // } // else if( data.getType(k) == CB_VALUE_INT ){ // printf("%i int value = %i \n", k, data.getInt(k)); // } // else if( data.getType(k) == CB_VALUE_STRING ){ // printf("%i string value = %s \n", k, data.getString(k).c_str()); // } // } // // printf("\n"); // //process events coming from the file listers // simpleFileLister listerChannelA; // simpleFileLister contentChannelA; // simpleFileLister listerChannelB; // simpleFileLister contentChannelB; //example output // testApp::eventsIn - name is CHANNEL_A_IMAGES - // element name is Channel A Images // 0 int value = 2 // 1 string value = ../../../data/images/joelHands // 2 string value = joelHands if(data.getDisplayName() == "Channel A Images"){ std::ostringstream localOSS; string contentDirectoryName = data.getString(2).c_str(); localOSS << "images/" << contentDirectoryName; string directoryToList = localOSS.str(); int numberOfImages = contentChannelA.listDir(directoryToList); channelAImages.resize(numberOfImages); //resize the vector, maybe back to zero if(channelAImages.size() > 0){ //we have some content, load in the first image as a preview std::ostringstream contentOSS; contentOSS << directoryToList << "/" << contentChannelA.entries[0].filename; string iconPath = contentOSS.str(); channelAIcon.loadImage(iconPath); //known to be safe for(int i=0; i < channelAImages.size(); i++){ std::ostringstream contentPathOSS; contentPathOSS << directoryToList << "/" << contentChannelA.entries[i].filename; string contentPath = contentPathOSS.str(); channelAImages[i].loadImage(contentPath); } } } //lazy but pragmatic if(data.getDisplayName() == "Channel B Images"){ std::ostringstream localOSS; string contentDirectoryName = data.getString(2).c_str(); localOSS << "images/" << contentDirectoryName; string directoryToList = localOSS.str(); int numberOfImages = contentChannelB.listDir(directoryToList); channelBImages.resize(numberOfImages); //resize the vector, maybe back to zero if(channelBImages.size() > 0){ //we have some content, load in the first image as a preview std::ostringstream contentOSS; contentOSS << directoryToList << "/" << contentChannelB.entries[0].filename; string iconPath = contentOSS.str(); channelBIcon.loadImage(iconPath); //known to be safe for(int i=0; i < channelBImages.size(); i++){ std::ostringstream contentPathOSS; contentPathOSS << directoryToList << "/" << contentChannelB.entries[i].filename; string contentPath = contentPathOSS.str(); channelBImages[i].loadImage(contentPath); } } } }
void testApp::grabBackgroundEvent(guiCallbackData & data){ if( data.isElement("grab") && data.getInt(0) == 1 ){ bgSub.captureBackground(); gui.setValueB("grab", false); } }
//this captures all our control panel events - unless its setup differently in testApp::setup //-------------------------------------------------------------- void testApp::eventsIn(guiCallbackData & data){ //TODO: would like to 'checkHit' for each GUI element and use that to set the analysisChooser (this would be proper behavior for the GUI) //check whether we are still on the same panel /* analysisChooser gui.getSelectedPanel(); */ //lets send all events to our logger if( !data.isElement( "events logger" ) ){ string logStr = data.getXmlName(); for(int k = 0; k < data.getNumValues(); k++){ logStr += " - " + data.getString(k); } logger.log(OF_LOG_NOTICE, "event - %s", logStr.c_str()); } // print to terminal if you want to //this code prints out the name of the events coming in and all the variables passed //SETUP CAMERA printf("testApp::eventsIn - name is %s - \n", data.getXmlName().c_str()); if( data.getDisplayName() == "set up camera input" ){ //vidGrabber.close(); setupCamera(camWidth,camHeight,camInput,desFrameRate,false); //menuState=1; cout<<"cam is setup\n"; } string thisName=data.getDisplayName(); cout<<thisName<<" this Name\n"; //START ANALYSIS IS NOW FROM A BUTTON if( thisName == "GO" ){ showGui=false; showCursor=false; menuState=1; } //animation time limit if( thisName == "animation time limit" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.maxNumberOfFramesForSynthesis=data.getFloat(k); cout<<masterAnalysis.maxNumberOfFramesForSynthesis<<"masterAnalysis.maxNumberOfFramesForSynthesis \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } //number of frames to grab if( thisName == "number of frames to grab" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.numOfFramesToGrab =data.getFloat(k); cout<<masterAnalysis.numOfFramesToGrab<<"masterAnalysis.numOfFramesToGrab \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } //added Tom 31/12/11 // number of grey levels if( thisName == "number of grey levels" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.numberOfGreyLevels =data.getFloat(k); masterAnalysis.currentGreyLevel=data.getFloat(k); cout<<masterAnalysis.numberOfGreyLevels<<"masterAnalysis.numberOfGreyLevels \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } //fadeTime if( thisName == "fadeTime" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.fadeTime =data.getFloat(k); cout<<masterAnalysis.fadeTime<<"masterAnalysis.fadeTime \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "scan line width" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.scanLineWidth=data.getFloat(k); cout<<masterAnalysis.scanLineWidth<<"masterAnalysis.scanLineWidth \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "scan line speed" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.scanLineSpeed=data.getFloat(k); cout<<masterAnalysis.scanLineSpeed<<"masterAnalysis.scanLineSpeed \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "max white level to ramp to" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.maxResultA=data.getFloat(k); cout<<masterAnalysis.maxResultA<<"masterAnalysis.maxResultA \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "num of seconds to last for" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ //30/12/11 maxNumberOfFramesForSynthesis is now set by multiplying gui time in secs by frameRateWeSet //if the analysis is iResponse this number of frames is per level/cycle so must be divided by number of grey levels // if (currentPanel==6) { // masterAnalysis.maxNumberOfFramesForSynthesis= frameRateWeSet * data.getFloat(k) / masterAnalysis.numberOfGreyLevels; // } // else{ masterAnalysis.maxNumberOfFramesForSynthesis= frameRateWeSet * data.getFloat(k); // } cout<<masterAnalysis.maxNumberOfFramesForSynthesis<<"masterAnalysis.maxNumberOfFramesForSynthesis \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "num of impulses" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.divisionsA=(2*(int)data.getFloat(k)); cout<<"masterAnalysis.divisionsA = "<<masterAnalysis.divisionsA<<" \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "show graph outline" ){ showGraphLine=!showGraphLine; masterAnalysis.showGraphA=showGraphLine; } //Tom S 14 Nov 19:10somehow this function appears to have been repeated so have commented out /* if( thisName == "graph max time" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.maxNumberOfFramesForSynthesis=data.getFloat(k); cout<<masterAnalysis.maxNumberOfFramesForSynthesis<<"masterAnalysis.maxNumberOfFramesForSynthesis \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } }*/ if( thisName == "morse pause time" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.speed=data.getFloat(k); cout<<masterAnalysis.speed<<"masterAnalysis.speed \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "red level" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.red=data.getFloat(k); cout<<masterAnalysis.red<<" masterAnalysis.red \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "green level" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.green=data.getFloat(k); cout<<masterAnalysis.green<<" masterAnalysis.green \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "red level" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.blue=data.getFloat(k); cout<<masterAnalysis.blue<<" masterAnalysis.blue \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } if( thisName == "color multi overall length" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ masterAnalysis.counterMaxColorMulti=data.getFloat(k); cout<<masterAnalysis.counterMaxColorMulti<<"masterAnalysis.maxNumberOfFramesForSynthesis \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } //more cam settings", "SETTINGS" if( data.getDisplayName() == "more cam settings" ){ vidGrabber.videoSettings(); } //LOCATION SELECTIO if( data.getDisplayName()== "location" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_STRING ){ locationChooser=data.getString(k); cout<<data.getString(k)<<" <<-- is our location \n"; } } } //START ANALYSIS //Tom 22/11/11 changed this from starting analysis to choosing panel of gui if( data.getDisplayName()== "choose analysis" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_STRING ){ analysisChooser=data.getString(k); cout<<data.getString(k)<<" "<<k<<" <<-- lets jump to this tab\n"; //Tom 22/11/11 for(int i=0;i<analysisNames.size();i++){ //check if the clicked option in the dropdown matches this analysis name if(analysisNames[i]==data.getString(k)){ //if it does, jump to the correct gui panel //changed 2 to 1 to account for mixing first 2 panels together gui.setSelectedPanel(i+1); //exit for loop exit(); } } } } } //WHAT KIND OF GRAPH if( data.getDisplayName()== "RELAXRATE response curve" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_STRING ){ //copy string straight into class masterAnalysis.whichGraph=data.getString(k); cout<<data.getString(k)<<" <<-- lets run THIS graph\n"; } } } //CAM HEIGHT if( data.getDisplayName() == "camera height" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ printf("%i float value = %f \n", k, data.getFloat(k)); camHeight=data.getFloat(k); } else if( data.getType(k) == CB_VALUE_INT ){ printf("%i int value = %i \n", k, data.getInt(k)); camHeight=data.getInt(k); } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); } } } //FRAME RATE ISNT WORKING - I THINK I HACKED THE LIBRARY TODO SET THIS RIGHT if( data.getDisplayName() == "desired frame rate" ){ for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ printf("%i float value = %f \n", k, data.getFloat(k)); desFrameRate=data.getFloat(k); } else if( data.getType(k) == CB_VALUE_INT ){ printf("%i int value = %i \n", k, data.getInt(k)); desFrameRate=data.getInt(k); } } } //LIST OF CAM SOURCES if( data.getDisplayName() == "inputs" ){ cout<<"input selected\n"; for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_FLOAT ){ printf("%i float value = %f \n", k, data.getFloat(k)); } else if( data.getType(k) == CB_VALUE_INT ){ printf("%i int value = %i \n", k, data.getInt(k)); camInput=data.getInt(k); cout<<camInput<<" camInput \n"; } else if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); camInputName=data.getString(k).c_str(); } } } // TOM - doesn't this refer to the morse text INPUT on the GUI? if( data.getDisplayName() == "morse output" ){ cout<<"getting morse message\r"; } //LIST OF CODECS if( data.getDisplayName() == "codecs" ){ cout<<"input selected\n"; for(int k = 0; k < data.getNumValues(); k++){ if( data.getType(k) == CB_VALUE_STRING ){ printf("%i string value = %s \n", k, data.getString(k).c_str()); codecName=data.getString(k).c_str(); cout<<codecName; //compare the string returned from the gui to get the number so we can pass this into the analysis setup for(int i=0;i<returnedCodecNames.size();i++){ if(returnedCodecNames[i]==codecName){ codecChooser=i; } } } } } //TODO: are any of these camera settings actually working or updating? // //UPDATE THE REPORT STRING FOR CURRENT SETTINGS camStatus="CAMERA STATUS:: width :"+ofToString(camWidth)+" height :"+ofToString(camHeight)+" frame rate :"+ofToString(desFrameRate)+" source :"+camInputName+"codec: "+codecName; }