Commit b9060149 authored by Jan Möbius's avatar Jan Möbius
Browse files

Removed key handling from QtBaseViewer

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4477 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ef080ca4
...@@ -136,7 +136,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -136,7 +136,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
examiner_widgets_.push_back(examinerWidget); examiner_widgets_.push_back(examinerWidget);
examinerWidget->disableKeyHandling(true);
examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
stackedWidget_->addWidget(examinerWidget); stackedWidget_->addWidget(examinerWidget);
...@@ -170,7 +169,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -170,7 +169,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Initialize all examiners // Initialize all examiners
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examiner_widgets_[i]->disableKeyHandling(true);
} }
QGridLayout* layout = new QGridLayout(tmp); QGridLayout* layout = new QGridLayout(tmp);
......
...@@ -125,7 +125,6 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent, ...@@ -125,7 +125,6 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent,
blending_(true), blending_(true),
sceneGraphDialog_(0), sceneGraphDialog_(0),
options_(_options), options_(_options),
disableKeyHandling_(false),
snapshotName_("snap.png"), snapshotName_("snap.png"),
snapshotCounter_(0), snapshotCounter_(0),
snapshot_(0), snapshot_(0),
......
...@@ -836,26 +836,13 @@ private: ...@@ -836,26 +836,13 @@ private:
*/ */
void signalKeyPressEvent(QKeyEvent*); void signalKeyPressEvent(QKeyEvent*);
public:
/** \brief Enable or disable internal Key handling
*
* With this function you can enable or disable viewers internal key handling.
* If disabled, all key events are passed to the widgets parent.
*/
void disableKeyHandling(bool _state );
/** \brief get the current key handling state.
*
*/
bool keyHandlingState();
protected: protected:
/** \brief Get keyPress events from the glArea /** \brief Get keyPress events from the glArea
* *
* This function is called by the internal gl widget when receiving a key press event. * This function is called by the internal gl widget when receiving a key press event.
*/ */
virtual void glKeyPressEvent(QKeyEvent*); virtual void glKeyPressEvent(QKeyEvent* _event) { _event->ignore(); };
/** \brief Get keyRelease events from the glArea /** \brief Get keyRelease events from the glArea
* *
...@@ -863,7 +850,7 @@ private: ...@@ -863,7 +850,7 @@ private:
* Here these events are simply passed to the parent widget. * Here these events are simply passed to the parent widget.
* *
*/ */
virtual void glKeyReleaseEvent(QKeyEvent* _event); virtual void glKeyReleaseEvent(QKeyEvent* _event) { _event->ignore(); };
/** \brief Handle key events in view mode /** \brief Handle key events in view mode
* *
...@@ -874,9 +861,6 @@ private: ...@@ -874,9 +861,6 @@ private:
*/ */
virtual bool viewKeyPressEvent(QKeyEvent* _event) = 0; virtual bool viewKeyPressEvent(QKeyEvent* _event) = 0;
private:
bool disableKeyHandling_;
/** @} */ /** @} */
//=========================================================================== //===========================================================================
......
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 3663 $
// $Author: moebius $
// $Date: 2008-11-06 14:55:30 +0100 (Do, 06. Nov 2008) $
//
//=============================================================================
//=============================================================================
//
// CLASS QtBaseViewer - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
#include "QtBaseViewer.hh"
#include <QInputDialog>
//== NAMESPACES ===============================================================
//== IMPLEMENTATION ==========================================================
void QtBaseViewer::disableKeyHandling(bool _state ) {
disableKeyHandling_ = _state;
};
//-----------------------------------------------------------------------------
bool QtBaseViewer::keyHandlingState() {
return disableKeyHandling_;
};
//-----------------------------------------------------------------------------
void QtBaseViewer::glKeyReleaseEvent(QKeyEvent* _event) {
_event->ignore();
};
//-----------------------------------------------------------------------------
void QtBaseViewer::glKeyPressEvent(QKeyEvent* _event)
{
// Pass key event to parent widget without any handling
if ( disableKeyHandling_ ) {
_event->ignore();
return;
}
bool handled(false);
// CTRL + ALT events
if ((_event->modifiers() & Qt::ControlModifier) &&
(_event->modifiers() & Qt::AltModifier))
{
switch (_event->key())
{
// Stereo steeing: eye distance
case Qt::Key_E:
{
bool save(glareaGrabbed_);
bool ok(false);
// release grabbing to process input dialog
if(save) releaseGLArea();
double val = QInputDialog::getDouble( this, "Eye Dist", "Eye Dist:",
eyeDist_,
0.0, 100.0, 10,
&ok);
// restore old setting
if(save) grabGLArea();
if (ok) {
eyeDist_ = val;
handled = true;
updateGL();
}
break;
}
// Stereo setting: focal length
case Qt::Key_F:
{
bool save(glareaGrabbed_);
bool ok(false);
// release grabbing to process input dialog
if(save) releaseGLArea();
double val = QInputDialog::getDouble( this, "Focal Dist", "Focal Dist:",
focalDist_,
0.0, 100.0, 10,
&ok);
//restore old setting
if(save) grabGLArea();
if (ok) {
focalDist_ = val;
handled = true;
updateGL();
}
break;
}
}
} else { // Normal events
switch (_event->key())
{
// Lock / unlock update
case Qt::Key_ScrollLock:
{
if (!updateLocked_) {
lockUpdate();
handled = true;
std::cerr << "Display update locked\n";
} else {
unlockAndUpdate();
handled = true;
std::cerr << "Display update un-locked\n";
}
break;
}
case Qt::Key_Escape:
{
actionMode(lastActionMode_);
handled = true;
break;
}
}
}
// If the event has not been handled by the baseviewer, check for Key events from subclasses
if(!handled) {
handled = viewKeyPressEvent(_event);
}
// give event to application
if (!handled) {
_event->ignore();
emit(signalKeyPressEvent(_event));
}
}
//=============================================================================
//=============================================================================
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment