bool QOsgEventHandler::handle( const osgGA::GUIEventAdapter &ea , osgGA::GUIActionAdapter &) { if(ea.getEventType() == osgGA::GUIEventAdapter::FRAME || ea.getEventType() == osgGA::GUIEventAdapter::MOVE) return false; switch(ea.getEventType()) { case(osgGA::GUIEventAdapter::KEYDOWN): { if(ea.getKey() == '-' || ea.getKey() == '+') { const float f = 1.00f + (ea.getKey() == '+' ? +0.004f : -0.004f); if(m_fov * f >= 1.f && m_fov * f <= 179.f) m_fov *= f; emit fovChanged(m_fov); } } break; case(osgGA::GUIEventAdapter::SCROLL): { const float f = 1.00f + (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_DOWN ? -0.08f : +0.08f); if(m_fov * f >= 1.f && m_fov * f <= 179.f) m_fov *= f; emit fovChanged(m_fov); return true; } break; case(osgGA::GUIEventAdapter::RELEASE): if(ea.getButton() == osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON && (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL) != 0) { m_fov = m_fovBackup; emit fovChanged(m_fov); return true; } break; default: break; }; return false; }
/** * @brief setCameraParameters * @param fieldOfView * @param zNear * @param zFar **/ void VolumetricHelicoidWidget::setCameraParameters(double _fieldOfView, double _zNear, double _zFar) { this->FOV=_fieldOfView; this->zNear = _zNear; this->zFar = _zFar; emit zNearChanged(zNear); emit zFarChanged(zFar); emit fovChanged(FOV); }