void RotationEdit::setMatrix( const Matrix & m ) { setting = true; if ( mode == mAuto ) { mode = mEuler; setupMode(); } switch ( mode ) { case mAuto: case mEuler: { float Y, P, R; m.toEuler( Y, P, R ); v[0]->setValue( Y / PI * 180 ); v[1]->setValue( P / PI * 180 ); v[2]->setValue( R / PI * 180 ); } break; case mAxis: { Vector3 axis; float angle; m.toQuat().toAxisAngle( axis, angle ); v[0]->setValue( angle / PI * 180 ); for ( int x = 0; x < 3; x++ ) v[x+1]->setValue( axis[x] ); } break; } setting = false; }
RotationEdit::RotationEdit( QWidget * parent ) : ValueEdit( parent ), mode( mAuto ), setting( false ) { actMode = new QAction( this ); connect( actMode, &QAction::triggered, this, &RotationEdit::switchMode ); QToolButton * btMode = new QToolButton( this ); btMode->setDefaultAction( actMode ); QHBoxLayout * lay = new QHBoxLayout( this ); lay->setMargin( 0 ); lay->setSpacing( 0 ); lay->addWidget( btMode, 2 ); // Cast QDoubleSpinBox slot auto dsbValueChanged = static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged); for ( int x = 0; x < 4; x++ ) { lay->addWidget( l[x] = new CenterLabel, 1 ); lay->addWidget( v[x] = new QDoubleSpinBox, 5 ); connect( v[x], dsbValueChanged, this, &RotationEdit::sltChanged ); } setFocusProxy( v[0] ); setupMode(); }
void OpenGLSdlGraphicsManager::notifyResize(const uint width, const uint height) { #if SDL_VERSION_ATLEAST(2, 0, 0) // We sometime get outdated resize events from SDL2. So check that the size we get // is the actual current window size. If not ignore the resize. // The issue for example occurs when switching from fullscreen to windowed mode or // when switching between different fullscreen resolutions because SDL_DestroyWindow // for a fullscreen window that doesn't have the SDL_WINDOW_FULLSCREEN_DESKTOP flag // causes a SDL_WINDOWEVENT_RESIZED event with the old resolution to be sent, and this // event is processed after recreating the window at the new resolution. int currentWidth, currentHeight; getWindowDimensions(¤tWidth, ¤tHeight); if (width != (uint)currentWidth || height != (uint)currentHeight) return; setActualScreenSize(width, height); _eventSource->resetKeyboardEmulation(width - 1, height - 1); #else if (!_ignoreResizeEvents && _hwScreen && !(_hwScreen->flags & SDL_FULLSCREEN)) { // We save that we handled a resize event here. We need to know this // so we do not overwrite the users requested window size whenever we // switch aspect ratio or similar. _gotResize = true; if (!setupMode(width, height)) { warning("OpenGLSdlGraphicsManager::notifyResize: Resize failed ('%s')", SDL_GetError()); g_system->quit(); } } #endif }
//------------------------------------------------------------------------------------------------ void liveInput::setupKinect(int device, liveInputMode inputMode){ // kinect.init(false, true, true); // kinect.setRegistration(true); // kinect.open(device); // kinect.setClippedDataToZero(true); // kinect.close(); // kinect.open(device); // kinect.setClippedDataToZero(true); // kinect.close(); // ofSleepMillis(200); kinect.init(false, true, true); kinect.setRegistration(true); kinect.open(device); kinect.setClippedDataToZero(true); w = 640; h = 480; // farThreshold = initialFar; // nearThreshold = initialNear; this->inputMode = inputMode; inputType = LIVE_TYPE_KINECT; setupMode(); }
void OpenGLSdlGraphicsManager::notifyResize(const uint width, const uint height) { if (!_ignoreResizeEvents && _hwScreen && !(_hwScreen->flags & SDL_FULLSCREEN)) { // We save that we handled a resize event here. We need to know this // so we do not overwrite the users requested window size whenever we // switch aspect ratio or similar. _gotResize = true; if (!setupMode(width, height)) { warning("OpenGLSdlGraphicsManager::notifyResize: Resize failed ('%s')", SDL_GetError()); g_system->quit(); } } }
void RotationEdit::switchMode() { Matrix m = getMatrix(); if ( mode == mAxis ) mode = mEuler; else mode = mAxis; setupMode(); setMatrix( m ); }
//------------------------------------------------------------------------------------------------ void liveInput::setupVideo(string videoPath, liveInputMode inputMode){ inputType = LIVE_TYPE_VIDEO; this->inputMode = inputMode; videoPlayer.loadMovie(videoPath); videoPlayer.play(); w = videoPlayer.getWidth(); h = videoPlayer.getHeight(); setupMode(); }
//------------------------------------------------------------------------------------------------ void liveInput::setupRegularCamera( int width, int height, liveInputMode inputMode, int deviceId){ inputType = LIVE_TYPE_CAM; this->inputMode = inputMode; camera.setDeviceID(deviceId); camera.initGrabber(width, height); w = camera.getWidth(); h = camera.getHeight(); setupMode(); }
void RotationEdit::setQuat( const Quat & q ) { setting = true; if ( mode == mAuto ) { mode = mAxis; setupMode(); } Matrix m; m.fromQuat( q ); setMatrix( m ); setting = false; }
//------------------------------------------------------------------------------------------------ void liveInput::setupKinectSequence(string folderPath, liveInputMode inputMode){ advSeq.loadSeq(folderPath, "png"); seq.setup(&advSeq,4); seq.currentSection.bLoop = true; seq.play(); seq.update(); w = seq.getCurrentFrame()->getWidth(); h = seq.getCurrentFrame()->getHeight(); this->inputMode = inputMode; inputType = LIVE_TYPE_KINECT_SEQ; setupMode(); }
bool Transceiver::ReceiveWelcome(IMFrame & frame) { IMFrameSetup * setup =frame.Setup(); // DBGINFO("\r\n%MAC"); // DBGINFO(setup->MAC); // DBGINFO(":"); // DBGINFO(setup->MAC2); if (setup->MAC!=myMAC) { DBGINFO("*****NOT FORME "); DBGINFO(myMAC); BackwardWelcome(frame); return false; } //_helloed=_knocked +200; //we can wait on next connection timer.Watchdog(); serverId=frame.Header.SourceId; myId=setup->address; myChannel=setup->slavechannel; hostRssiSend=setup->rssi; router.myId=myId; HostChannel=0; myChannel=0; _calibrateshift=0; _connected=1; TimerSetup((myId &16)*10); // BroadcastEnable=(setup->mode && IMS_TRANSCEIVER); setupMode(setup->mode); if (myHop==2) { _calibrateshift=200; DBGINFO("C200SHIFT"); } _cycleshift=(timer.Cycle()+myId) % _cycledata; _helloCycle=timer.Cycle()+TimerHelloCycle*_cycledata;//setup next Hello DBGINFO(myId); DBGINFO("CONNECT%"); StopListenBroadcast(); // no listen until data stage return true; }
//------------------------------------------------------------------------------------------------ void liveInput::setupFake(int width, int height, int numPeople, liveInputMode inputMode ){ w = width; h = height; fakes.assign(numPeople, ofPoint()); for(int k = 0; k < fakes.size(); k++){ fakes[k].x = ofRandom(-200, w+200); if( fakes[k].x > w/2 ){ fakes[k].x = ofRandom(w+10, w + 200 ); }else{ fakes[k].x = ofRandom(-20, - 200 ); } fakes[k].y = ofRandom(0, h); } inputType = LIVE_TYPE_FAKE; this->inputMode = inputMode; setupMode(); }
bool OpenGLSdlGraphicsManager::loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format) { // In some cases we might not want to load the requested video mode. This // will assure that the window size is not altered. if (_ignoreLoadVideoMode) { _ignoreLoadVideoMode = false; return true; } // This function should never be called from notifyResize thus we know // that the requested size came from somewhere else. _gotResize = false; // Save the requested dimensions. _lastRequestedWidth = requestedWidth; _lastRequestedHeight = requestedHeight; // Apply the currently saved scale setting. requestedWidth *= _graphicsScale; requestedHeight *= _graphicsScale; // Set up the mode. return setupMode(requestedWidth, requestedHeight); }
RotationEdit::RotationEdit( QWidget * parent ) : ValueEdit( parent ), mode( mAuto ), setting( false ) { actMode = new QAction( this ); connect( actMode, SIGNAL( triggered() ), this, SLOT( switchMode() ) ); QToolButton * btMode = new QToolButton( this ); btMode->setDefaultAction( actMode ); QHBoxLayout * lay = new QHBoxLayout( this ); lay->setMargin( 0 ); lay->setSpacing( 0 ); lay->addWidget( btMode, 2 ); for ( int x = 0; x < 4; x++ ) { lay->addWidget( l[x] = new CenterLabel, 1 ); lay->addWidget( v[x] = new QDoubleSpinBox, 5 ); connect( v[x], SIGNAL( valueChanged( double ) ), this, SLOT( sltChanged() ) ); } setFocusProxy( v[0] ); setupMode(); }
bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { switch (event.type) { case Common::EVENT_KEYUP: return isHotkey(event); case Common::EVENT_KEYDOWN: if (event.kbd.hasFlags(Common::KBD_ALT)) { if ( event.kbd.keycode == Common::KEYCODE_RETURN || event.kbd.keycode == (Common::KeyCode)SDLK_KP_ENTER) { // Alt-Return and Alt-Enter toggle full screen mode beginGFXTransaction(); setFeatureState(OSystem::kFeatureFullscreenMode, !getFeatureState(OSystem::kFeatureFullscreenMode)); endGFXTransaction(); #ifdef USE_OSD if (getFeatureState(OSystem::kFeatureFullscreenMode)) { displayMessageOnOSD(_("Fullscreen mode")); } else { displayMessageOnOSD(_("Windowed mode")); } #endif return true; } if (event.kbd.keycode == Common::KEYCODE_s) { // Alt-s creates a screenshot Common::String filename; for (int n = 0;; n++) { SDL_RWops *file; filename = Common::String::format("scummvm%05d.bmp", n); file = SDL_RWFromFile(filename.c_str(), "r"); if (!file) break; SDL_RWclose(file); } saveScreenshot(filename.c_str()); debug("Saved screenshot '%s'", filename.c_str()); return true; } } else if (event.kbd.hasFlags(Common::KBD_CTRL | Common::KBD_ALT)) { if ( event.kbd.keycode == Common::KEYCODE_PLUS || event.kbd.keycode == Common::KEYCODE_MINUS || event.kbd.keycode == Common::KEYCODE_KP_PLUS || event.kbd.keycode == Common::KEYCODE_KP_MINUS) { // Ctrl+Alt+Plus/Minus Increase/decrease the size const int direction = (event.kbd.keycode == Common::KEYCODE_PLUS || event.kbd.keycode == Common::KEYCODE_KP_PLUS) ? +1 : -1; if (getFeatureState(OSystem::kFeatureFullscreenMode)) { // In case we are in fullscreen we will choose the previous // or next mode. // In case no modes are available we do nothing. if (_fullscreenVideoModes.empty()) { return true; } // Look for the current mode. VideoModeArray::const_iterator i = Common::find(_fullscreenVideoModes.begin(), _fullscreenVideoModes.end(), VideoMode(_desiredFullscreenWidth, _desiredFullscreenHeight)); if (i == _fullscreenVideoModes.end()) { return true; } // Cycle through the modes in the specified direction. if (direction > 0) { ++i; if (i == _fullscreenVideoModes.end()) { i = _fullscreenVideoModes.begin(); } } else { if (i == _fullscreenVideoModes.begin()) { i = _fullscreenVideoModes.end(); } --i; } _desiredFullscreenWidth = i->width; _desiredFullscreenHeight = i->height; // Try to setup the mode. if (!setupMode(_lastRequestedWidth, _lastRequestedHeight)) { warning("OpenGLSdlGraphicsManager::notifyEvent: Fullscreen resize failed ('%s')", SDL_GetError()); g_system->quit(); } } else { // Calculate the next scaling setting. We approximate the // current scale setting in case the user resized the // window. Then we apply the direction change. int windowWidth = 0, windowHeight = 0; getWindowDimensions(&windowWidth, &windowHeight); _graphicsScale = MAX<int>(windowWidth / _lastRequestedWidth, windowHeight / _lastRequestedHeight); _graphicsScale = MAX<int>(_graphicsScale + direction, 1); // Since we overwrite a user resize here we reset its // flag here. This makes enabling AR smoother because it // will change the window size like in surface SDL. _gotResize = false; // Try to setup the mode. if (!setupMode(_lastRequestedWidth * _graphicsScale, _lastRequestedHeight * _graphicsScale)) { warning("OpenGLSdlGraphicsManager::notifyEvent: Window resize failed ('%s')", SDL_GetError()); g_system->quit(); } } #ifdef USE_OSD int windowWidth = 0, windowHeight = 0; getWindowDimensions(&windowWidth, &windowHeight); const Common::String osdMsg = Common::String::format(_("Resolution: %dx%d"), windowWidth, windowHeight); displayMessageOnOSD(osdMsg.c_str()); #endif return true; } else if (event.kbd.keycode == Common::KEYCODE_a) { // In case the user changed the window size manually we will // not change the window size again here. _ignoreLoadVideoMode = _gotResize; // Ctrl+Alt+a toggles the aspect ratio correction state. beginGFXTransaction(); setFeatureState(OSystem::kFeatureAspectRatioCorrection, !getFeatureState(OSystem::kFeatureAspectRatioCorrection)); endGFXTransaction(); // Make sure we do not ignore the next resize. This // effectively checks whether loadVideoMode has been called. assert(!_ignoreLoadVideoMode); #ifdef USE_OSD if (getFeatureState(OSystem::kFeatureAspectRatioCorrection)) displayMessageOnOSD(_("Enabled aspect ratio correction")); else displayMessageOnOSD(_("Disabled aspect ratio correction")); #endif return true; } else if (event.kbd.keycode == Common::KEYCODE_f) { // Never ever try to resize the window when we simply want to enable or disable filtering. // This assures that the window size does not change. _ignoreLoadVideoMode = true; // Ctrl+Alt+f toggles filtering on/off beginGFXTransaction(); setFeatureState(OSystem::kFeatureFilteringMode, !getFeatureState(OSystem::kFeatureFilteringMode)); endGFXTransaction(); // Make sure we do not ignore the next resize. This // effectively checks whether loadVideoMode has been called. assert(!_ignoreLoadVideoMode); #ifdef USE_OSD if (getFeatureState(OSystem::kFeatureFilteringMode)) { displayMessageOnOSD(_("Filtering enabled")); } else { displayMessageOnOSD(_("Filtering disabled")); } #endif return true; } } // Fall through default: return false; } }
bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { switch (event.type) { case Common::EVENT_KEYUP: return isHotkey(event); case Common::EVENT_KEYDOWN: if (event.kbd.hasFlags(Common::KBD_ALT)) { if ( event.kbd.keycode == Common::KEYCODE_RETURN || event.kbd.keycode == (Common::KeyCode)SDLK_KP_ENTER) { // Alt-Return and Alt-Enter toggle full screen mode beginGFXTransaction(); setFeatureState(OSystem::kFeatureFullscreenMode, !getFeatureState(OSystem::kFeatureFullscreenMode)); endGFXTransaction(); #ifdef USE_OSD if (getFeatureState(OSystem::kFeatureFullscreenMode)) { displayMessageOnOSD("Fullscreen mode"); } else { displayMessageOnOSD("Windowed mode"); } #endif return true; } if (event.kbd.keycode == Common::KEYCODE_s) { // Alt-s creates a screenshot Common::String filename; for (int n = 0;; n++) { SDL_RWops *file; filename = Common::String::format("scummvm%05d.bmp", n); file = SDL_RWFromFile(filename.c_str(), "r"); if (!file) break; SDL_RWclose(file); } saveScreenshot(filename.c_str()); debug("Saved screenshot '%s'", filename.c_str()); return true; } } else if (event.kbd.hasFlags(Common::KBD_CTRL | Common::KBD_ALT)) { if ( event.kbd.keycode == Common::KEYCODE_PLUS || event.kbd.keycode == Common::KEYCODE_MINUS || event.kbd.keycode == Common::KEYCODE_KP_PLUS || event.kbd.keycode == Common::KEYCODE_KP_MINUS) { // Ctrl+Alt+Plus/Minus Increase/decrease the size const int direction = (event.kbd.keycode == Common::KEYCODE_PLUS || event.kbd.keycode == Common::KEYCODE_KP_PLUS) ? +1 : -1; if (getFeatureState(OSystem::kFeatureFullscreenMode)) { // In case we are in fullscreen we will choose the previous // or next mode. // In case no modes are available we do nothing. if (_fullscreenVideoModes.empty()) { return true; } // Look for the current mode. VideoModeArray::const_iterator i = Common::find(_fullscreenVideoModes.begin(), _fullscreenVideoModes.end(), VideoMode(_desiredFullscreenWidth, _desiredFullscreenHeight)); if (i == _fullscreenVideoModes.end()) { return true; } // Cycle through the modes in the specified direction. if (direction > 0) { ++i; if (i == _fullscreenVideoModes.end()) { i = _fullscreenVideoModes.begin(); } } else { if (i == _fullscreenVideoModes.begin()) { i = _fullscreenVideoModes.end(); } --i; } _desiredFullscreenWidth = i->width; _desiredFullscreenHeight = i->height; // Try to setup the mode. if (!setupMode(_lastRequestedWidth, _lastRequestedHeight)) { warning("OpenGLSdlGraphicsManager::notifyEvent: Fullscreen resize failed ('%s')", SDL_GetError()); g_system->quit(); } } else { // Calculate the next scaling setting. We approximate the // current scale setting in case the user resized the // window. Then we apply the direction change. _graphicsScale = MAX<int>(_hwScreen->w / _lastRequestedWidth, _hwScreen->h / _lastRequestedHeight); _graphicsScale = MAX<int>(_graphicsScale + direction, 1); // Since we overwrite a user resize here we reset its // flag here. This makes enabling AR smoother because it // will change the window size like in surface SDL. _gotResize = false; // Try to setup the mode. if (!setupMode(_lastRequestedWidth * _graphicsScale, _lastRequestedHeight * _graphicsScale)) { warning("OpenGLSdlGraphicsManager::notifyEvent: Window resize failed ('%s')", SDL_GetError()); g_system->quit(); } } #ifdef USE_OSD const Common::String osdMsg = Common::String::format("Resolution: %dx%d", _hwScreen->w, _hwScreen->h); displayMessageOnOSD(osdMsg.c_str()); #endif return true; } else if (event.kbd.keycode == Common::KEYCODE_a) { // In case the user changed the window size manually we will // not change the window size again here. _ignoreLoadVideoMode = _gotResize; // Ctrl+Alt+a toggles the aspect ratio correction state. beginGFXTransaction(); setFeatureState(OSystem::kFeatureAspectRatioCorrection, !getFeatureState(OSystem::kFeatureAspectRatioCorrection)); endGFXTransaction(); // Make sure we do not ignore the next resize. This // effectively checks whether loadVideoMode has been called. assert(!_ignoreLoadVideoMode); #ifdef USE_OSD Common::String osdMsg = "Aspect ratio correction: "; osdMsg += getFeatureState(OSystem::kFeatureAspectRatioCorrection) ? "enabled" : "disabled"; displayMessageOnOSD(osdMsg.c_str()); #endif return true; } else if (event.kbd.keycode == Common::KEYCODE_f) { // Ctrl+Alt+f toggles the graphics modes. // We are crazy we will allow the OpenGL base class to // introduce new graphics modes like shaders for special // filtering. If some other OpenGL subclass needs this, // we can think of refactoring this. int mode = getGraphicsMode(); const OSystem::GraphicsMode *supportedModes = getSupportedGraphicsModes(); const OSystem::GraphicsMode *modeDesc = nullptr; // Search the current mode. for (; supportedModes->name; ++supportedModes) { if (supportedModes->id == mode) { modeDesc = supportedModes; break; } } assert(modeDesc); // Try to use the next mode in the list. ++modeDesc; if (!modeDesc->name) { modeDesc = getSupportedGraphicsModes(); } // Never ever try to resize the window when we simply want to // switch the graphics mode. This assures that the window size // does not change. _ignoreLoadVideoMode = true; beginGFXTransaction(); setGraphicsMode(modeDesc->id); endGFXTransaction(); // Make sure we do not ignore the next resize. This // effectively checks whether loadVideoMode has been called. assert(!_ignoreLoadVideoMode); #ifdef USE_OSD const Common::String osdMsg = Common::String::format("Graphics mode: %s", _(modeDesc->description)); displayMessageOnOSD(osdMsg.c_str()); #endif return true; } } // Fall through default: return false; } }