Ejemplo n.º 1
0
ofxPiMapper::ofxPiMapper(): bShowInfo(false), isSetUp(false){
    ofAddListener(ofEvents().keyPressed, this, &ofxPiMapper::keyPressed);
}
Ejemplo n.º 2
0
void ofApp::exit(){
	ofRemoveListener(ofEvents().draw, this, &ofApp::drawMousePosition, OF_EVENT_ORDER_AFTER_APP+1);
}
Ejemplo n.º 3
0
bool ofGstUtils::startPipeline(){

	bPaused 			= true;
	speed 				= 1.0f;


	if(gst_element_set_state (GST_ELEMENT(gstPipeline), GST_STATE_READY) ==	GST_STATE_CHANGE_FAILURE) {
		ofLog(OF_LOG_ERROR, "GStreamer: unable to set pipeline to ready\n");

		return false;
	}
	if(gst_element_get_state (GST_ELEMENT(gstPipeline), NULL, NULL, 10 * GST_SECOND)==GST_STATE_CHANGE_FAILURE){
		ofLog(OF_LOG_ERROR, "GStreamer: unable to get pipeline to ready\n");
		return false;
	}

	// pause the pipeline
	if(gst_element_set_state(GST_ELEMENT(gstPipeline), GST_STATE_PAUSED) ==	GST_STATE_CHANGE_FAILURE) {
		ofLog(OF_LOG_ERROR, "GStreamer: unable to set pipeline to paused\n");

		return false;
	}

	// wait for paused state to query the duration
	if(!isStream){
		GstState state = GST_STATE_PAUSED;
		if(gst_element_get_state(gstPipeline,&state,NULL,2*GST_SECOND)==GST_STATE_CHANGE_FAILURE){
			ofLog(OF_LOG_ERROR, "GStreamer: unable to get pipeline to paused\n");
			return false;
		}
		bPlaying = true;
		bLoaded = true;
	}



	if(isAppSink){
		ofLogVerbose() << "attaching callbacks";
		// set the appsink to not emit signals, we are using callbacks instead
		// and frameByFrame to get buffers by polling instead of callback
		g_object_set (G_OBJECT (gstSink), "emit-signals", FALSE, "sync", !bFrameByFrame, (void*)NULL);

		if(!bFrameByFrame){
			GstAppSinkCallbacks gstCallbacks;
			gstCallbacks.eos = &on_eos_from_source;
			gstCallbacks.new_preroll = &on_new_preroll_from_source;
			gstCallbacks.new_buffer = &on_new_buffer_from_source;

			gst_app_sink_set_callbacks(GST_APP_SINK(gstSink), &gstCallbacks, this, NULL);
		}

	}

	if(!isStream){
		setSpeed(1.0);
	}

	ofAddListener(ofEvents().update,this,&ofGstUtils::update);

	return true;
}
Ejemplo n.º 4
0
ofxPS3EyeGrabber::~ofxPS3EyeGrabber()
{
    ofRemoveListener(ofEvents().exit, this, &ofxPS3EyeGrabber::exit);
    stop();
    _cam.reset();
}
Ejemplo n.º 5
0
void ofxMouseRuler::setup(){
	visible = true;
	ofRegisterMouseEvents(this);
	ofAddListener(ofEvents().draw, this, &ofxMouseRuler::draw, std::numeric_limits<int>::max());
	setupDone = true;
}
Ejemplo n.º 6
0
//--------------------------------------------------------------
ofxPowerMate::~ofxPowerMate(){
    ofRemoveListener(ofEvents().update, this, &ofxPowerMate::update);
}
Ejemplo n.º 7
0
void TextureEditor::unregisterAppEvents() {
  ofRemoveListener(ofEvents().update, this, &TextureEditor::update);
}
Ejemplo n.º 8
0
void ofxSimpleSerial::stopContinuesRead()
{
    continuesRead = false;
    ofRemoveListener(ofEvents().update, this, &ofxSimpleSerial::update);
}
Ejemplo n.º 9
0
/*
 * Request new data from the device your connected to.
 */
void ofxSimpleSerial::sendRequest()
{
    if(bWriteByte) writeByte('r');
    ofAddListener(ofEvents().update, this, &ofxSimpleSerial::update);
}
Ejemplo n.º 10
0
Application::Application(){
	_surfaceManager.setMediaServer(&_mediaServer);
	_gui.setMediaServer(&_mediaServer);
	_gui.setCmdManager(&_cmdManager);
	_gui.setSurfaceManager(&_surfaceManager);
	
	setState(PresentationState::instance());
	ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed);
	ofAddListener(ofEvents().keyReleased, this, &Application::onKeyReleased);
	ofAddListener(ofEvents().mousePressed, this, &Application::onMousePressed);
	
	ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed);
	ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed);
	ofAddListener(Gui::instance()->backgroundPressedEvent, this, &Application::onBackgroundPressed);
    
    
    //XML, SI LO SE ES UNA CHAPUZA TEMPORAL///////////////////////////////
    if( XML.load("mySettings.xml") ){
        message = "mySettings.xml loaded!";
    }else{
        
        // Ok, we didn't get a file, but that's ok, we're going
        // to go ahead and start making some stuff anyways! First, to
        // make a correct XML document, we need a root element, so
        // let's do that:
    
        
        XML.addChild("SETTINGS");
        
        // now we set our current element so we're on the right
        // element, so when we add new nodes, they're still inside
        // the root element
        XML.setTo("SETTINGS");
        
        message = "unable to load mySettings.xml check data/ folder";
    }
    
    if(XML.exists("//ID")) {
        _idPi	= XML.getValue<int>("//ID");
    }
    if(XML.exists("//IP")) {
        IP = XML.getValue("//IP");
    }
    if(XML.exists("//MODE")) {
        MODO = XML.getValue<int>("//MODE");
    }
   
    
    //OSC/////////////////////////////////////////////////////////////////////
  
    receiver.setup(8000+_idPi);
    cout << "Listening for osc messages on port " << ofToString(8000+_idPi) << "\n";
    
    sender.setup(IP,PORT_OUT);
    cout << "Sending osc messages to this port: " << PORT_OUT << " & this host " << IP<< "\n";
    
    
    //Variables varias
    fullScreen=false;
    orden=0;
    
    
    //Envia un mensaje con que te acabas de conectar
    ofxOscMessage m;
    m.setAddress("/idPi");
    m.addIntArg(_idPi);
    sender.sendMessage(m, false);
}
ofxStateMachine<T>::~ofxStateMachine(){
	ofRemoveListener(ofEvents().update, this, &ofxStateMachine::update);
}
Ejemplo n.º 12
0
//--------------------------------------------------------------
void BYBGui::setup( string language){
    bAccuracyTestRunning = false;
    ofXml xml;
    map<int, string> fingerNames;
    if (xml.load(ofToDataPath("languages/"+language+".xml"))) {
        xml.setTo("fingers");
        int c = xml.getNumChildren("finger");
        xml.setTo("finger[0]");
        for (int i = 0; i < c; i++) {
            fingerNames[xml.getIntValue("ID")] = xml.getValue("name");
            xml.setToSibling();
        }
        xml.setToParent();
        xml.setToParent();
        xml.setTo("buttons");
        if (xml.exists("calibrate")) {
            calibrateButton.name = xml.getValue("calibrate");
        }
        if (xml.exists("accuracy")) {
            accuracyButton.name = xml.getValue("accuracy");
        }
        if (xml.exists("save")) {
            saveButton.name = xml.getValue("save");
        }
        if (xml.exists("load")) {
            loadButton.name = xml.getValue("load");
        }
        if (xml.exists("svm")) {
            svmButton.name = xml.getValue("svm");
        }
        if (xml.exists("euc")) {
            eucButton.name = xml.getValue("euc");
        }
        if (xml.exists("arduino")) {
            arduinoButton.name = xml.getValue("arduino");
        }
        
    }
    for (int i = 0; i < NUM_GRAPHS; i++) {
        graphs[i].setup(ofGetWidth()-5, (string)((fingerNames.count(i)>0)?fingerNames[i]:""));
        graphs[i].setFont(fonts);
        graphs[i].setNormalize(true);
        
    }
    setSizes();
    
    setupParameters();
    setupButtons();
    logo.load("logo.png");
    
    
    
    selectedGraph = selectedFinger= -1;

    ofRegisterKeyEvents(this);
    ofRegisterMouseEvents(this);
    ofAddListener(ofEvents().windowResized, this, &BYBGui::windowResized);
    
    calibrationGui.setPtr(this);
    accuracyGui.setPtr(this);
    
    
    calibrationGui.setButtons();
    accuracyGui.setButtons();
    
    accuracyGui.set(MARGIN, MARGIN, ofGetWidth() - (2*MARGIN), guiArea.height);
    accuracyGui.setup(language);
    calibrationGui.setLanguage(language);
    
    calibrationGui.set(MARGIN, MARGIN, ofGetWidth() - (2*MARGIN), guiArea.height);
    
    calibrationGui.update(0, 0, numSamples, false);
    
    logoRect.set(guiArea.x + MARGIN,guiArea.y + MARGIN, logo.getWidth(), logo.getHeight());
    
    handImg.setup();
    
    handImg.scaleTo(guiArea , OF_ASPECT_RATIO_KEEP);
    
    handImg.x = logoRect.getMaxX() + (calibrateButton.x - logoRect.getMaxX() - handImg.getWidth())/2.0f;
    
    svmButton.setSelected(true);

    bNewPeak = false;
    
}
Ejemplo n.º 13
0
 //--------------------------------------------------------------
 Master::Master() {
     cout << "Master";
     ofAddListener(ofEvents().update, this, &Master::update);
 }
Ejemplo n.º 14
0
ofxPiMapper::~ofxPiMapper(){
    ofRemoveListener(ofEvents().keyPressed, this, &ofxPiMapper::keyPressed);
}
void ofxTLDepthImageSequence::setup(){
	ofxTLImageTrack::setup();
	ofAddListener(ofEvents().exit, this, &ofxTLDepthImageSequence::exit);
}
Ejemplo n.º 16
0
COMXVideo::~COMXVideo()
{
	ofRemoveListener(ofEvents().update, this, &COMXVideo::onUpdate);
	//ofLogVerbose(__func__) << "removed update listener";
}
Ejemplo n.º 17
0
void ofxSlides::disable() {
	ofRemoveListener(ofEvents().update, this, &ofxSlides::update);
	ofRemoveListener(ofEvents().keyPressed, this, &ofxSlides::keyPressed);
	ofRemoveListener(ofEvents().keyReleased, this, &ofxSlides::keyReleased);
}
Ejemplo n.º 18
0
bool COMXVideo::Open(COMXStreamInfo& hints, OMXClock *clock, float display_aspect, bool deinterlace, bool hdmi_clock_sync)
{
	OMX_ERRORTYPE error   = OMX_ErrorNone;

	m_video_codec_name      = "";
	m_codingType            = OMX_VIDEO_CodingUnused;

	m_decoded_width  = hints.width;
	m_decoded_height = hints.height;

	m_hdmi_clock_sync = hdmi_clock_sync;

	if(!m_decoded_width || !m_decoded_height)
	{
		return false;
	}

	if(hints.extrasize > 0 && hints.extradata != NULL)
	{
		m_extrasize = hints.extrasize;
		m_extradata = (uint8_t *)malloc(m_extrasize);
		memcpy(m_extradata, hints.extradata, hints.extrasize);
	}

	ProcessCodec(hints);

	if(deinterlace)
	{
		ofLog(OF_LOG_VERBOSE, "enable deinterlace\n");
		m_deinterlace = true;
	}
	else
	{
		m_deinterlace = false;
	}

	std::string componentName = decoder_name;
	if(!m_omx_decoder.Initialize(componentName, OMX_IndexParamVideoInit))
	{
		return false;
	}

	componentName = "OMX.broadcom.video_render";
	if(!m_omx_render.Initialize(componentName, OMX_IndexParamVideoInit))
	{
		return false;
	}

	componentName = "OMX.broadcom.video_scheduler";
	if(!m_omx_sched.Initialize(componentName, OMX_IndexParamVideoInit))
	{
		return false;
	}

	if(m_deinterlace)
	{
		componentName = "OMX.broadcom.image_fx";
		if(!m_omx_image_fx.Initialize(componentName, OMX_IndexParamImageInit))
		{
			return false;
		}
	}

	if(clock == NULL)
	{
		return false;
	}

	m_av_clock = clock;
	m_omx_clock = m_av_clock->GetOMXClock();

	if(m_omx_clock->GetComponent() == NULL)
	{
		m_av_clock = NULL;
		m_omx_clock = NULL;
		return false;
	}

	if(m_deinterlace)
	{
		m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_image_fx, m_omx_image_fx.GetInputPort());
		m_omx_tunnel_image_fx.Initialize(&m_omx_image_fx, m_omx_image_fx.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
	}
	else
	{
		m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
	}

	m_omx_tunnel_sched.Initialize(&m_omx_sched, m_omx_sched.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
	m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort() + 1, &m_omx_sched, m_omx_sched.GetOutputPort() + 1);

	error = m_omx_tunnel_clock.Establish(false);
	if(error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_tunnel_clock Establish FAIL: " << COMXCore::getOMXError(error);

		return false;
	}

	error = m_omx_decoder.SetStateForComponent(OMX_StateIdle);
	if (error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_decoder OMX_StateIdle FAIL: " << COMXCore::getOMXError(error);
		return false;
	}

	OMX_VIDEO_PARAM_PORTFORMATTYPE formatType;
	OMX_INIT_STRUCTURE(formatType);
	formatType.nPortIndex = m_omx_decoder.GetInputPort();
	formatType.eCompressionFormat = m_codingType;

	if (hints.fpsscale > 0 && hints.fpsrate > 0)
	{
		formatType.xFramerate = (long long)(1<<16)*hints.fpsrate / hints.fpsscale;
	}
	else
	{
		formatType.xFramerate = 25 * (1<<16);
	}
    
	error = m_omx_decoder.SetParameter(OMX_IndexParamVideoPortFormat, &formatType);
	if(error != OMX_ErrorNone)
	{
		return false;
	}

	OMX_PARAM_PORTDEFINITIONTYPE portParam;
	OMX_INIT_STRUCTURE(portParam);
	portParam.nPortIndex = m_omx_decoder.GetInputPort();

	error = m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition, &portParam);
	if(error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_decoder Get OMX_IndexParamPortDefinition FAIL: " << COMXCore::getOMXError(error);
		return false;
	}

	portParam.nPortIndex = m_omx_decoder.GetInputPort();
	int videoBuffers = 60;
	portParam.nBufferCountActual = videoBuffers;

	portParam.format.video.nFrameWidth  = m_decoded_width;
	portParam.format.video.nFrameHeight = m_decoded_height;

	error = m_omx_decoder.SetParameter(OMX_IndexParamPortDefinition, &portParam);
	if(error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_decoder Set OMX_IndexParamPortDefinition FAIL: " << COMXCore::getOMXError(error);
		return false;
	}

	OMX_PARAM_BRCMVIDEODECODEERRORCONCEALMENTTYPE concanParam;
	OMX_INIT_STRUCTURE(concanParam);
	concanParam.bStartWithValidFrame = OMX_FALSE;

	error = m_omx_decoder.SetParameter(OMX_IndexParamBrcmVideoDecodeErrorConcealment, &concanParam);
	if(error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_decoder OMX_IndexParamBrcmVideoDecodeErrorConcealment FAIL: " << COMXCore::getOMXError(error);
		return false;
	}

	if (m_deinterlace)
	{
		// the deinterlace component requires 3 additional video buffers in addition to the DPB (this is normally 2).
		OMX_PARAM_U32TYPE extra_buffers;
		OMX_INIT_STRUCTURE(extra_buffers);
		extra_buffers.nU32 = 3;

		error = m_omx_decoder.SetParameter(OMX_IndexParamBrcmExtraBuffers, &extra_buffers);
		if(error != OMX_ErrorNone)
		{
			ofLogError(__func__) << "m_omx_decoder OMX_IndexParamBrcmExtraBuffers FAIL: " << COMXCore::getOMXError(error);
			return false;
		}
	}

	// broadcom omx entension:
	// When enabled, the timestamp fifo mode will change the way incoming timestamps are associated with output images.
	// In this mode the incoming timestamps get used without re-ordering on output images.
	
    // recent firmware will actually automatically choose the timestamp stream with the least variance, so always enable

    OMX_CONFIG_BOOLEANTYPE timeStampMode;
    OMX_INIT_STRUCTURE(timeStampMode);
    timeStampMode.bEnabled = OMX_TRUE;
    error = m_omx_decoder.SetParameter((OMX_INDEXTYPE)OMX_IndexParamBrcmVideoTimestampFifo, &timeStampMode);
    if (error != OMX_ErrorNone)
    {
        ofLogError(__func__) << "m_omx_decoder OMX_IndexParamBrcmVideoTimestampFifo FAIL: " << COMXCore::getOMXError(error);
        return false;
    }


	if(NaluFormatStartCodes(hints.codec, m_extradata, m_extrasize))
	{
		OMX_NALSTREAMFORMATTYPE nalStreamFormat;
		OMX_INIT_STRUCTURE(nalStreamFormat);
		nalStreamFormat.nPortIndex = m_omx_decoder.GetInputPort();
		nalStreamFormat.eNaluFormat = OMX_NaluFormatStartCodes;

		error = m_omx_decoder.SetParameter((OMX_INDEXTYPE)OMX_IndexParamNalStreamFormatSelect, &nalStreamFormat);
		if (error != OMX_ErrorNone)
		{
			ofLogError(__func__) << "m_omx_decoder OMX_IndexParamNalStreamFormatSelect FAIL: " << COMXCore::getOMXError(error);
			return false;
		}
	}

	if(m_hdmi_clock_sync)
	{
		OMX_CONFIG_LATENCYTARGETTYPE latencyTarget;
		OMX_INIT_STRUCTURE(latencyTarget);
		latencyTarget.nPortIndex = m_omx_render.GetInputPort();
		latencyTarget.bEnabled = OMX_TRUE;
		latencyTarget.nFilter = 2;
		latencyTarget.nTarget = 4000;
		latencyTarget.nShift = 3;
		latencyTarget.nSpeedFactor = -135;
		latencyTarget.nInterFactor = 500;
		latencyTarget.nAdjCap = 20;

		error = m_omx_render.SetConfig(OMX_IndexConfigLatencyTarget, &latencyTarget);
		if (error != OMX_ErrorNone)
		{
			ofLogError(__func__) << "m_omx_render OMX_IndexConfigLatencyTarget FAIL: " << COMXCore::getOMXError(error);
			return false;
		}
	}

	// Alloc buffers for the omx input port.
	error = m_omx_decoder.AllocInputBuffers();
	if (error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_decoder AllocInputBuffers FAIL: " << COMXCore::getOMXError(error);
		return false;
	}

	error = m_omx_tunnel_decoder.Establish(false);
	if(error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_tunnel_decoder Establish FAIL: " << COMXCore::getOMXError(error);
		return false;
	}

	
	error = m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
	if (error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_decoder OMX_StateExecuting FAIL: " << COMXCore::getOMXError(error);
		return false;
	}

	if(m_deinterlace)
	{
		OMX_CONFIG_IMAGEFILTERPARAMSTYPE image_filter;
		OMX_INIT_STRUCTURE(image_filter);

		image_filter.nPortIndex = m_omx_image_fx.GetOutputPort();
		image_filter.nNumParams = 1;
		image_filter.nParams[0] = 3;
		image_filter.eImageFilter = OMX_ImageFilterDeInterlaceAdvanced;

		error = m_omx_image_fx.SetConfig(OMX_IndexConfigCommonImageFilterParameters, &image_filter);
		if(error != OMX_ErrorNone)
		{
			ofLogError(__func__) << "m_omx_image_fx SetConfig FAIL: " << COMXCore::getOMXError(error);
			return false;
		}

		error = m_omx_tunnel_image_fx.Establish(false);
		if(error != OMX_ErrorNone)
		{
			ofLogError(__func__) << "m_omx_image_fx Establish FAIL: " << COMXCore::getOMXError(error);
			return false;
		}

		error = m_omx_image_fx.SetStateForComponent(OMX_StateExecuting);
		if (error != OMX_ErrorNone)
		{
			ofLogError(__func__) << "m_omx_image_fx OMX_StateExecuting FAIL: " << COMXCore::getOMXError(error);
			return false;
		}

		m_omx_image_fx.DisablePort(m_omx_image_fx.GetInputPort(), false);
		m_omx_image_fx.DisablePort(m_omx_image_fx.GetOutputPort(), false);

	}

	error = m_omx_tunnel_sched.Establish(false);
	if(error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_tunnel_sched Establish FAIL: " << COMXCore::getOMXError(error);
		return false;
	}

	
	error = m_omx_sched.SetStateForComponent(OMX_StateExecuting);
	if (error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_sched OMX_StateExecuting FAIL: " << COMXCore::getOMXError(error);
		return false;
	}
	
	
	
	error = m_omx_render.SetStateForComponent(OMX_StateExecuting);
	if (error != OMX_ErrorNone)
	{
		ofLogError(__func__) << "m_omx_render OMX_StateExecuting FAIL: " << COMXCore::getOMXError(error);
		return false;
	}
	ofAddListener(ofEvents().update, this, &COMXVideo::onUpdate);
	if(!SendDecoderConfig())
	{
		return false;
	}

	m_is_open           = true;
	m_drop_state        = false;
	m_setStartTime      = true;
	OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
	OMX_INIT_STRUCTURE(configDisplay);
	configDisplay.nPortIndex = m_omx_render.GetInputPort();
	
	//we provided a rectangle but returned early as we were not ready
	if (displayRect.getWidth()>0) 
	{
		configureDisplay();
	}else 
	{
		
		float fAspect = (float)hints.aspect / (float)m_decoded_width * (float)m_decoded_height;
		float par = hints.aspect ? fAspect/display_aspect : 0.0f;
		// only set aspect when we have a aspect and display doesn't match the aspect
		bool doDisplayChange = true;
		if(doDisplayChange)
		{
			if(par != 0.0f && fabs(par - 1.0f) > 0.01f)
			{
				
				
				AVRational aspect;
				aspect = av_d2q(par, 100);
				configDisplay.set      = OMX_DISPLAY_SET_PIXEL;
				configDisplay.pixel_x  = aspect.num;
				configDisplay.pixel_y  = aspect.den;
				ofLog(OF_LOG_VERBOSE, "Aspect : num %d den %d aspect %f pixel aspect %f\n", aspect.num, aspect.den, hints.aspect, par);
				error = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
				if(error != OMX_ErrorNone)
				{
					return false;
				}
			}
			
		}
	}

	ofLog(OF_LOG_VERBOSE,
	      "%s::%s - decoder_component(0x%p), input_port(0x%x), output_port(0x%x) deinterlace %d hdmiclocksync %d\n",
	      "OMXVideo", __func__, m_omx_decoder.GetComponent(), m_omx_decoder.GetInputPort(), m_omx_decoder.GetOutputPort(),
	      m_deinterlace, m_hdmi_clock_sync);

	m_first_frame   = true;

	// start from assuming all recent frames had valid pts
	m_history_valid_pts = ~0;
	return true;
}
Ejemplo n.º 19
0
void TextureEditor::registerAppEvents() {
  ofAddListener(ofEvents().update, this, &TextureEditor::update);
}
Ejemplo n.º 20
0
 void ProjectionEditor::unregisterAppEvents() {
     ofRemoveListener(ofEvents().update, this, &ProjectionEditor::update);
     ofRemoveListener(ofEvents().messageEvent, this,
                      &ProjectionEditor::gotMessage);
 }
Ejemplo n.º 21
0
void TextureEditor::unregisterKeyEvents() {
  ofRemoveListener(ofEvents().keyPressed, this, &TextureEditor::keyPressed);
  ofRemoveListener(ofEvents().keyReleased, this, &TextureEditor::keyReleased);
}
Ejemplo n.º 22
0
 void ProjectionEditor::unregisterMouseEvents() {
     ofRemoveListener(ofEvents().mouseDragged, this,
                      &ProjectionEditor::mouseDragged);
 }
Ejemplo n.º 23
0
ofxMouseRuler::~ofxMouseRuler(){
	if(setupDone){
		ofUnregisterMouseEvents(this);
		ofRemoveListener(ofEvents().draw, this, &ofxMouseRuler::draw, OF_EVENT_ORDER_AFTER_APP+1);
	}
}
Ejemplo n.º 24
0
 void ProjectionEditor::unregisterKeyEvents() {
     ofRemoveListener(ofEvents().keyPressed, this, &ProjectionEditor::keyPressed);
     ofRemoveListener(ofEvents().keyReleased, this,
                      &ProjectionEditor::keyReleased);
 }
Ejemplo n.º 25
0
ICalendarWatcher::~ICalendarWatcher()
{
    ofRemoveListener(ofEvents().update, this, &ICalendarWatcher::update);
}
void ofxTLDepthImageSequence::playbackStarted(ofxTLPlaybackEventArgs& args){
	ofAddListener(ofEvents().update, this, &ofxTLDepthImageSequence::update);
}
Ejemplo n.º 27
0
//--------------------------------------------------------------
void ofApp::setup(){

	ofSetFrameRate(120);

	ofAddListener(ofEvents().draw, this, &ofApp::drawMousePosition, OF_EVENT_ORDER_AFTER_APP+1);

	testBool.set("bool", true);
	testFloat.set("float", 0.5, 0, 1);
	testColor.set("color", ofColor(120), ofColor(0,0), ofColor(255,255));
	testPoint.set("point", ofPoint(0.5,0.5), ofPoint(0,0), ofPoint(100,100));
	testString.set("string", "teststring");


	gui_flex.setupFlexBoxLayout();


	ofxGuiGroup* control = gui_control.addPanel("active layout", ofJson({
		{"show-header", false},
		{"direction", "horizontal"},
		{"left", 300},
		{"width", "auto"}
	}));
	control->setExclusiveToggles(true);
	control->add(gui_box.getVisible().set("box layout", false));
	control->add(gui_flex.getVisible().set("flexbox layout", true));
	control->add<ofxGuiLabel>("(note: both cases should look identical)");


	vector<ofxGui*> guis;
	guis.push_back(&gui_box);
	guis.push_back(&gui_flex);

	for(ofxGui* gui : guis){

		gui->add(testBool, testFloat);

		vector<ofxGuiGroup*> panels;

		ofxGuiGroup* panel1 = gui->addPanel();
		panel1->setPosition(10, 130);
		panel1->loadTheme("theme_default.json");

		ofxGuiGroup* panel2 = gui->addPanel();
		panel2->loadTheme("theme_light.json");
		panel2->setPosition(panel1->getPosition().x + panel1->getWidth()+10, panel1->getPosition().y);

		panels.push_back(panel1);
		panels.push_back(panel2);

		for(ofxGuiGroup* panel : panels){
			panel->add(testBool);
			panel->add(testPoint);
			panel->add(testFloat);
			panel->add(testColor);
			panel->add(testString);
		}

		ofxGuiGroup* panel3 = gui->addPanel("horizontal", ofJson({
			{"direction", "horizontal"},
			{"flex-direction", "row"}
		}));
		panel3->setPosition(panel2->getPosition().x + panel2->getWidth()+10, panel2->getPosition().y);
		panel3->add(testBool);
		panel3->add(testBool);
		panel3->add(testBool);

		ofxGuiGroup* panel4 = gui->addPanel();
		panel4->setPosition(panel3->getPosition().x, panel3->getPosition().y +  panel3->getHeight()+10);
		panel4->add(testFloat);
		ofxGuiGroup* panel4_vertical = panel4->addGroup("", ofJson({
			{"direction", "horizontal"},
			{"show-header", false},
			{"flex-direction", "row"},
			{"width", 270}
		}));
		panel4_vertical->add(testBool, ofJson({
			{"type", "radio"},
			{"show-name", false},
			{"width", "10%"}
		}));
		panel4_vertical->add(testFloat, ofJson({{"width", "45%"}}));
		panel4_vertical->add(testFloat, ofJson({{"width", "45%"}}));

//		ofJson toggleTheme = {{"show-name", false}, {"width", "10%"}};
//	    ofJson postToggleTheme = {{"fill-color", "rgba(220,80,50,0.5)"}, {"width", "90%"}};
//	    ofJson postToggle2Theme = {{"fill-color", "rgba(220,80,50,0.5)"}, {"width", "45%"}};
//	    ofJson groupTheme = {{"flex-direction", "row"}, {"flex-wrap", "wrap"}, {"width", 320}, {"align-content", "space-between"}};

//	    //////  Groups

//	    menuAudioGroup = menuAudioPanel->addGroup("Audio Analyzer");

//	    powerGroup = menuAudioGroup->addGroup("POWER", groupTheme);
//	    powerGroup->add(energyToggleVal, toggleTheme);
//	    powerGroup->add(energyMultiplierSliderVal, postToggle2Theme);
//	    powerGroup->add(intenSmoothSliderVal, postToggle2Theme);
//	    powerGroup->add<ofxGuiValuePlotter>(energySliderVal);
//	    powerGroup->add(rmsSliderVal);


		//give the flexbox layout a different color to be able to see that something happens when you change the layout
		if(gui == &gui_flex){
			ofJson config = {
				{
					"group-header", {
						 {"background-color", "#123456"}
					 }
				 }
			};
			panel1->setTheme(config);
			panel2->setTheme(config);

		}

	}

}
void ofxTLDepthImageSequence::playbackEnded(ofxTLPlaybackEventArgs& args){
	ofRemoveListener(ofEvents().update, this, &ofxTLDepthImageSequence::update);
}
Ejemplo n.º 29
0
//--------------------------------------------------------------
void mpeClientTCP::threadedFunction() {
    out("Running!");
	
	lastHeartbeatTime = ofGetElapsedTimef();
	
    if(frameLock){
        // let the server know that this client is ready to start
        send("S" + ofToString(id) + "," + clientName);
    }
	else{
		//start a listener
		send("L");
	}

    while(isThreadRunning()) {

		if(frameLock && simulationMode){
			
			float now = ofGetElapsedTimef();
			if(now - lastFrameTime > 1./simulatedFPS){
				if(!useMainThread){
					ofxMPEEventArgs e;
					e.message = "";
					e.frame = frameCount;
					ofNotifyEvent(ofxMPEEvents.mpeFrame, e);
				}
				else {
					triggerFrame = true;
				}

				lastFrameTime = now;
				frameCount++;
			}

            ofSleepMillis(5);
			continue;
		}

		
		if (allConnected && ofGetElapsedTimef() - lastHeartbeatTime > 2.0) {
			//we lost connection... manually disconnect and join reset cycle
			if(tcpClient.close()){
				ofLog(OF_LOG_ERROR, "mpeClientTCP -- server connection timed out. Closing and entering reconnect loop.");
			}
			else{
				ofLog(OF_LOG_ERROR, "mpeClientTCP -- Error when closing TCP connection after timeout.");			
			}
		}
		
		if(!tcpClient.isConnected()){
			//we lost connection, start the retry loop and kill the thread
			lastConnectionAttempt = ofGetElapsedTimef();
			ofAddListener(ofEvents().update, this, &mpeClientTCP::retryConnectionLoop);
			stopThread(true);
			if(useMainThread){
				shouldReset = true;
			}
			else{
				reset();
			}

			if(DEBUG){
                cout << "lost connection to server " << endl;
			}
			//break the loop because we'll need to restart
			return;
		}

        if (!useMainThread || (useMainThread && lock()) ) {
            string msg = tcpClient.receive();
            if (msg.length() > 0 && lastmsg != msg) {
                read(msg);
                lastmsg = msg;
            }

			if(useMainThread){
				unlock();
			}
        }
        ofSleepMillis(5);
    }
}
Ejemplo n.º 30
0
//------------------------------------------------------------
void ofAppGLFWWindow::keyboard_cb(int key, int state) {
	static ofKeyEventArgs keyEventArgs;

	ofLog(OF_LOG_VERBOSE,"key: %i, state: %i",key,state);

	switch (key) {
		case GLFW_KEY_ESC:
			key = OF_KEY_ESC;
			break;
		case GLFW_KEY_F1:
			key = OF_KEY_F1;
			break;
		case GLFW_KEY_F2:
			key = OF_KEY_F2;
			break;
		case GLFW_KEY_F3:
			key = OF_KEY_F3;
			break;
		case GLFW_KEY_F4:
			key = OF_KEY_F4;
			break;
		case GLFW_KEY_F5:
			key = OF_KEY_F5;
			break;
		case GLFW_KEY_F6:
			key = OF_KEY_F6;
			break;
		case GLFW_KEY_F7:
			key = OF_KEY_F7;
			break;
		case GLFW_KEY_F8:
			key = OF_KEY_F8;
			break;
		case GLFW_KEY_F9:
			key = OF_KEY_F9;
			break;
		case GLFW_KEY_F10:
			key = OF_KEY_F10;
			break;
		case GLFW_KEY_F11:
			key = OF_KEY_F11;
			break;
		case GLFW_KEY_F12:
			key = OF_KEY_F12;
			break;
		case GLFW_KEY_LEFT:
			key = OF_KEY_LEFT;
			break;
		case GLFW_KEY_RIGHT:
			key = OF_KEY_RIGHT;
			break;
		case GLFW_KEY_UP:
			key = OF_KEY_UP;
			break;
		case GLFW_KEY_DOWN:
			key = OF_KEY_DOWN;
			break;
		case GLFW_KEY_PAGEUP:
			key = OF_KEY_PAGE_UP;
			break;
		case GLFW_KEY_PAGEDOWN:
			key = OF_KEY_PAGE_DOWN;
			break;
		case GLFW_KEY_HOME:
			key = OF_KEY_HOME;
			break;
		case GLFW_KEY_END:
			key = OF_KEY_END;
			break;
		case GLFW_KEY_INSERT:
			key = OF_KEY_INSERT;
			break;
		case GLFW_KEY_ENTER:
			key = OF_KEY_RETURN;
			break;
		default:
			break;
	}

	//GLFW defaults to uppercase - OF users are used to lowercase
	//if we are uppercase make lowercase
	// a better approach would be to check if shift keys are held down - and apply based on that
	if( key >= 65 && key <= 90 ){
		key += 32;
	}

	if(state == GLFW_PRESS){
		if(ofAppPtr)ofAppPtr->keyPressed(key);

		#ifdef OF_USING_POCO
			keyEventArgs.key = key;
			ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
		#endif

		if (key == OF_KEY_ESC){				// "escape"
			exitApp();
		}
	}else{
		if(ofAppPtr)ofAppPtr->keyReleased(key);

		#ifdef OF_USING_POCO
			keyEventArgs.key = key;
			ofNotifyEvent( ofEvents().keyReleased, keyEventArgs );
		#endif
	}
}