Commit 6fe89f58 authored by Mike Kremer's avatar Mike Kremer
Browse files

Implemented 3D-First-Person-Shooter navigation mode that still doesn't work too well.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7014 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 37a72c9e
...@@ -285,7 +285,7 @@ public: ...@@ -285,7 +285,7 @@ public:
/// Setup the main menubar /// Setup the main menubar
void setupMenuBar(); void setupMenuBar();
/** @} */ /** @} */
//=========================================================================== //===========================================================================
...@@ -554,7 +554,7 @@ public: ...@@ -554,7 +554,7 @@ public:
/// Setup and update the global draw menu /// Setup and update the global draw menu
void slotUpdateGlobalDrawMenu(); void slotUpdateGlobalDrawMenu();
/// Change viewer layout that was selected in the combo box /// Change viewer layout that was selected in the combo box
void setViewerLayout(int _idx); void setViewerLayout(int _idx);
...@@ -579,18 +579,18 @@ public: ...@@ -579,18 +579,18 @@ public:
QAction* perspectiveProjectionAction_; QAction* perspectiveProjectionAction_;
QAction* orthogonalProjectionAction_; QAction* orthogonalProjectionAction_;
/// Action to globally set Animation /// Action to globally set Animation
QAction* globalAnimationAction_; QAction* globalAnimationAction_;
/// Action to globally set backface culling /// Action to globally set backface culling
QAction* globalBackfaceCullingAction_; QAction* globalBackfaceCullingAction_;
/// Action to globally set Two-Sided lighting /// Action to globally set Two-Sided lighting
QAction* globalTwosidedLightingAction_; QAction* globalTwosidedLightingAction_;
/// Action to globally set multisampling /// Action to globally set multisampling
QAction* globalMultisamplingAction_; QAction* globalMultisamplingAction_;
int activeDrawModes_; int activeDrawModes_;
...@@ -642,6 +642,9 @@ public: ...@@ -642,6 +642,9 @@ public:
/// Show / hide wheels /// Show / hide wheels
void slotSwitchWheels(bool _state); void slotSwitchWheels(bool _state);
/// Switch navigation mode
void slotSwitchNavigation(bool _egomode);
/// Set the snapShot name for all examiners /// Set the snapShot name for all examiners
void slotSnapshotName(); void slotSnapshotName();
...@@ -927,15 +930,15 @@ public: ...@@ -927,15 +930,15 @@ public:
/// Set two sided lighting for active viewer /// Set two sided lighting for active viewer
void slotLocalChangeTwoSidedLighting(bool _lighting); void slotLocalChangeTwoSidedLighting(bool _lighting);
/// Set Multisampling for all viewers /// Set Multisampling for all viewers
void slotGlobalChangeMultisampling(bool _lighting); void slotGlobalChangeMultisampling(bool _lighting);
/// Set Multisampling for active viewer /// Set Multisampling for active viewer
void slotLocalChangeMultisampling(bool _lighting); void slotLocalChangeMultisampling(bool _lighting);
/// When using first person mode move backward /// When using first person mode move backward
void moveBack(); void moveBack();
......
...@@ -250,7 +250,7 @@ void CoreWidget::setupMenuBar() ...@@ -250,7 +250,7 @@ void CoreWidget::setupMenuBar()
renderingOptionsMenu->addAction( orthogonalProjectionAction_); renderingOptionsMenu->addAction( orthogonalProjectionAction_);
// ===================== // =====================
globalAnimationAction_ = renderingOptionsMenu->addAction(tr("Animation")); globalAnimationAction_ = renderingOptionsMenu->addAction(tr("Animation"));
globalAnimationAction_->setCheckable( true ); globalAnimationAction_->setCheckable( true );
globalAnimationAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"animation.png") ); globalAnimationAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"animation.png") );
...@@ -259,7 +259,7 @@ void CoreWidget::setupMenuBar() ...@@ -259,7 +259,7 @@ void CoreWidget::setupMenuBar()
//====================== //======================
globalBackfaceCullingAction_ = renderingOptionsMenu->addAction(tr("Backface Culling")); globalBackfaceCullingAction_ = renderingOptionsMenu->addAction(tr("Backface Culling"));
globalBackfaceCullingAction_->setCheckable( true ); globalBackfaceCullingAction_->setCheckable( true );
globalBackfaceCullingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") ); globalBackfaceCullingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") );
connect(globalBackfaceCullingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeBackFaceCulling(bool) ) ); connect(globalBackfaceCullingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeBackFaceCulling(bool) ) );
...@@ -269,14 +269,14 @@ void CoreWidget::setupMenuBar() ...@@ -269,14 +269,14 @@ void CoreWidget::setupMenuBar()
globalTwosidedLightingAction_->setCheckable( true ); globalTwosidedLightingAction_->setCheckable( true );
globalTwosidedLightingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") ); globalTwosidedLightingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
connect(globalTwosidedLightingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeTwoSidedLighting(bool) ) ); connect(globalTwosidedLightingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeTwoSidedLighting(bool) ) );
//====================== //======================
globalMultisamplingAction_ = renderingOptionsMenu->addAction(tr("Multisampling")); globalMultisamplingAction_ = renderingOptionsMenu->addAction(tr("Multisampling"));
globalMultisamplingAction_->setCheckable( true ); globalMultisamplingAction_->setCheckable( true );
// TODO:Icon for multisampling // TODO:Icon for multisampling
// globalMultisamplingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") ); // globalMultisamplingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
connect(globalMultisamplingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeMultisampling(bool)) ); connect(globalMultisamplingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeMultisampling(bool)) );
//============================================================================================================ //============================================================================================================
// Other toplevel actions // Other toplevel actions
...@@ -284,6 +284,17 @@ void CoreWidget::setupMenuBar() ...@@ -284,6 +284,17 @@ void CoreWidget::setupMenuBar()
viewMenu_->addSeparator(); viewMenu_->addSeparator();
QAction* navigationSwitchAction = new QAction( tr("Ego-shooter Navigation"), viewMenu_ );
navigationSwitchAction->setCheckable( true );
navigationSwitchAction->setStatusTip( tr("Switch between normal and ego-shooter navigation mode."));
navigationSwitchAction->setWhatsThis( tr("Switch between normal and ego-shooter navigation mode."));
navigationSwitchAction->setChecked( false );
connect( navigationSwitchAction, SIGNAL( toggled(bool) ), this, SLOT( slotSwitchNavigation(bool) ) );
viewMenu_->addAction( navigationSwitchAction);
viewMenu_->addSeparator();
connect( viewMenu_,SIGNAL( aboutToShow() ), this, SLOT( slotViewMenuAboutToShow() ) ); connect( viewMenu_,SIGNAL( aboutToShow() ), this, SLOT( slotViewMenuAboutToShow() ) );
QAction* homeAction = new QAction(tr("Restore Home View"),viewMenu_); QAction* homeAction = new QAction(tr("Restore Home View"),viewMenu_);
...@@ -470,7 +481,7 @@ void CoreWidget::slotViewMenuAboutToShow() { ...@@ -470,7 +481,7 @@ void CoreWidget::slotViewMenuAboutToShow() {
uint enabledCount = 0; uint enabledCount = 0;
uint disabledCount = 0; uint disabledCount = 0;
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) { for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).animation() ) if ( PluginFunctions::viewerProperties(i).animation() )
enabledCount++; enabledCount++;
...@@ -480,55 +491,55 @@ void CoreWidget::slotViewMenuAboutToShow() { ...@@ -480,55 +491,55 @@ void CoreWidget::slotViewMenuAboutToShow() {
if ( enabledCount != 0 && disabledCount != 0 ) { if ( enabledCount != 0 && disabledCount != 0 ) {
globalAnimationAction_->setChecked(Qt::PartiallyChecked); globalAnimationAction_->setChecked(Qt::PartiallyChecked);
globalAnimationAction_->setToolTip(tr("Disable animation for all viewers")); globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));
globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers")); globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));
globalAnimationAction_->setText(tr("Disable animation")); globalAnimationAction_->setText(tr("Disable animation"));
} else if ( enabledCount == 4 ) { } else if ( enabledCount == 4 ) {
globalAnimationAction_->setChecked( Qt::Checked ); globalAnimationAction_->setChecked( Qt::Checked );
globalAnimationAction_->setToolTip(tr("Disable animation for all viewers")); globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));
globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers")); globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));
globalAnimationAction_->setText(tr("Disable animation")); globalAnimationAction_->setText(tr("Disable animation"));
} else { } else {
globalAnimationAction_->setChecked( Qt::Unchecked ); globalAnimationAction_->setChecked( Qt::Unchecked );
globalAnimationAction_->setToolTip(tr("Enable animation for all viewers")); globalAnimationAction_->setToolTip(tr("Enable animation for all viewers"));
globalAnimationAction_->setStatusTip(tr("Enable animation for all viewers")); globalAnimationAction_->setStatusTip(tr("Enable animation for all viewers"));
globalAnimationAction_->setText(tr("Enable animation")); globalAnimationAction_->setText(tr("Enable animation"));
} }
//============================================================================================================================= //=============================================================================================================================
enabledCount = 0; enabledCount = 0;
disabledCount = 0; disabledCount = 0;
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) { for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).backFaceCulling() ) if ( PluginFunctions::viewerProperties(i).backFaceCulling() )
enabledCount++; enabledCount++;
else else
disabledCount++; disabledCount++;
} }
if ( enabledCount != 0 && disabledCount != 0 ) { if ( enabledCount != 0 && disabledCount != 0 ) {
globalBackfaceCullingAction_->setChecked(Qt::PartiallyChecked); globalBackfaceCullingAction_->setChecked(Qt::PartiallyChecked);
globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers")); globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));
globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers")); globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));
globalBackfaceCullingAction_->setText(tr("Disable backface culling")); globalBackfaceCullingAction_->setText(tr("Disable backface culling"));
} else if ( enabledCount == 4 ) { } else if ( enabledCount == 4 ) {
globalBackfaceCullingAction_->setChecked( Qt::Checked ); globalBackfaceCullingAction_->setChecked( Qt::Checked );
globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers")); globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));
globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers")); globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));
globalBackfaceCullingAction_->setText(tr("Disable backface culling")); globalBackfaceCullingAction_->setText(tr("Disable backface culling"));
} else { } else {
globalBackfaceCullingAction_->setChecked( Qt::Unchecked ); globalBackfaceCullingAction_->setChecked( Qt::Unchecked );
globalBackfaceCullingAction_->setToolTip(tr("Enable backface culling for all viewers")); globalBackfaceCullingAction_->setToolTip(tr("Enable backface culling for all viewers"));
globalBackfaceCullingAction_->setStatusTip(tr("Enable backface culling for all viewers")); globalBackfaceCullingAction_->setStatusTip(tr("Enable backface culling for all viewers"));
globalBackfaceCullingAction_->setText(tr("Enable backface culling")); globalBackfaceCullingAction_->setText(tr("Enable backface culling"));
} }
//============================================================================================================================= //=============================================================================================================================
enabledCount = 0; enabledCount = 0;
disabledCount = 0; disabledCount = 0;
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) { for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).twoSidedLighting() ) if ( PluginFunctions::viewerProperties(i).twoSidedLighting() )
enabledCount++; enabledCount++;
...@@ -538,27 +549,27 @@ void CoreWidget::slotViewMenuAboutToShow() { ...@@ -538,27 +549,27 @@ void CoreWidget::slotViewMenuAboutToShow() {
if ( enabledCount != 0 && disabledCount != 0 ) { if ( enabledCount != 0 && disabledCount != 0 ) {
globalTwosidedLightingAction_->setChecked(Qt::PartiallyChecked); globalTwosidedLightingAction_->setChecked(Qt::PartiallyChecked);
globalTwosidedLightingAction_->setToolTip(tr("Disable two-sided lighting for all viewers")); globalTwosidedLightingAction_->setToolTip(tr("Disable two-sided lighting for all viewers"));
globalTwosidedLightingAction_->setStatusTip(tr("Disable two-sided lighting for all viewers")); globalTwosidedLightingAction_->setStatusTip(tr("Disable two-sided lighting for all viewers"));
globalTwosidedLightingAction_->setText(tr("Disable two-sided lighting")); globalTwosidedLightingAction_->setText(tr("Disable two-sided lighting"));
} else if ( enabledCount == 4 ) { } else if ( enabledCount == 4 ) {
globalTwosidedLightingAction_->setChecked( Qt::Checked ); globalTwosidedLightingAction_->setChecked( Qt::Checked );
globalTwosidedLightingAction_->setToolTip(tr("Disable two-sided lighting for all viewers")); globalTwosidedLightingAction_->setToolTip(tr("Disable two-sided lighting for all viewers"));
globalTwosidedLightingAction_->setStatusTip(tr("Disable two-sided lighting for all viewers")); globalTwosidedLightingAction_->setStatusTip(tr("Disable two-sided lighting for all viewers"));
globalTwosidedLightingAction_->setText(tr("Disable two-sided lighting")); globalTwosidedLightingAction_->setText(tr("Disable two-sided lighting"));
} else { } else {
globalTwosidedLightingAction_->setChecked( Qt::Unchecked ); globalTwosidedLightingAction_->setChecked( Qt::Unchecked );
globalTwosidedLightingAction_->setToolTip(tr("Enable two-sided lighting for all viewers")); globalTwosidedLightingAction_->setToolTip(tr("Enable two-sided lighting for all viewers"));
globalTwosidedLightingAction_->setStatusTip(tr("Enable two-sided lighting for all viewers")); globalTwosidedLightingAction_->setStatusTip(tr("Enable two-sided lighting for all viewers"));
globalTwosidedLightingAction_->setText(tr("Enable two-sided lighting")); globalTwosidedLightingAction_->setText(tr("Enable two-sided lighting"));
} }
//============================================================================================================================= //=============================================================================================================================
enabledCount = 0; enabledCount = 0;
disabledCount = 0; disabledCount = 0;
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) { for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).multisampling() ) if ( PluginFunctions::viewerProperties(i).multisampling() )
enabledCount++; enabledCount++;
...@@ -568,21 +579,21 @@ void CoreWidget::slotViewMenuAboutToShow() { ...@@ -568,21 +579,21 @@ void CoreWidget::slotViewMenuAboutToShow() {
if ( enabledCount != 0 && disabledCount != 0 ) { if ( enabledCount != 0 && disabledCount != 0 ) {
globalMultisamplingAction_->setChecked(Qt::PartiallyChecked); globalMultisamplingAction_->setChecked(Qt::PartiallyChecked);
globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers")); globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers"));
globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers")); globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers"));
globalMultisamplingAction_->setText(tr("Disable Multisampling")); globalMultisamplingAction_->setText(tr("Disable Multisampling"));
} else if ( enabledCount == 4 ) { } else if ( enabledCount == 4 ) {
globalMultisamplingAction_->setChecked( Qt::Checked ); globalMultisamplingAction_->setChecked( Qt::Checked );
globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers")); globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers"));
globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers")); globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers"));
globalMultisamplingAction_->setText(tr("Disable Multisampling")); globalMultisamplingAction_->setText(tr("Disable Multisampling"));
} else { } else {
globalMultisamplingAction_->setChecked( Qt::Unchecked ); globalMultisamplingAction_->setChecked( Qt::Unchecked );
globalMultisamplingAction_->setToolTip(tr("Enable Multisampling for all viewers")); globalMultisamplingAction_->setToolTip(tr("Enable Multisampling for all viewers"));
globalMultisamplingAction_->setStatusTip(tr("Enable Multisampling for all viewers")); globalMultisamplingAction_->setStatusTip(tr("Enable Multisampling for all viewers"));
globalMultisamplingAction_->setText(tr("Enable Multisampling")); globalMultisamplingAction_->setText(tr("Enable Multisampling"));
} }
uint perspectiveCount = 0; uint perspectiveCount = 0;
uint orthogonalCount = 0; uint orthogonalCount = 0;
......
...@@ -75,7 +75,7 @@ void CoreWidget::slotToggleStereoMode() ...@@ -75,7 +75,7 @@ void CoreWidget::slotToggleStereoMode()
} }
cursorPainter_->setEnabled (stereoActive_); cursorPainter_->setEnabled (stereoActive_);
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
examiner_widgets_[i]->setStereoMode(stereoActive_); examiner_widgets_[i]->setStereoMode(stereoActive_);
} }
...@@ -120,10 +120,20 @@ void CoreWidget::slotContextHomeView() { ...@@ -120,10 +120,20 @@ void CoreWidget::slotContextHomeView() {
void CoreWidget::slotSwitchWheels(bool _state) { void CoreWidget::slotSwitchWheels(bool _state) {
std::vector< glViewer* >::iterator it = examiner_widgets_.begin(); std::vector< glViewer* >::iterator it = examiner_widgets_.begin();
for(; it != examiner_widgets_.end(); it++) for(; it != examiner_widgets_.end(); it++)
_state ? (*it)->slotShowWheels() : (*it)->slotHideWheels(); _state ? (*it)->slotShowWheels() : (*it)->slotHideWheels();
} }
/// Switch navigation mode
void CoreWidget::slotSwitchNavigation(bool _egomode) {
std::vector< glViewer* >::iterator it = examiner_widgets_.begin();
for(; it != examiner_widgets_.end(); it++) {
_egomode ? (*it)->navigationMode(glViewer::EGOSHOOTER_NAVIGATION) :
(*it)->navigationMode(glViewer::NORMAL_NAVIGATION);
}
}
/// Set the viewer to home position /// Set the viewer to home position
void CoreWidget::slotGlobalHomeView() { void CoreWidget::slotGlobalHomeView() {
for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i ) for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i )
...@@ -186,7 +196,7 @@ void CoreWidget::slotLocalChangeAnimation(bool _animation){ ...@@ -186,7 +196,7 @@ void CoreWidget::slotLocalChangeAnimation(bool _animation){
void CoreWidget::slotGlobalChangeBackFaceCulling(bool _backFaceCulling){ void CoreWidget::slotGlobalChangeBackFaceCulling(bool _backFaceCulling){
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
PluginFunctions::viewerProperties(i).backFaceCulling(_backFaceCulling); PluginFunctions::viewerProperties(i).backFaceCulling(_backFaceCulling);
} }
/// Set Backface culling for active viewer /// Set Backface culling for active viewer
...@@ -582,14 +592,14 @@ void CoreWidget::slotCoordSysVisibility(bool _visible){ ...@@ -582,14 +592,14 @@ void CoreWidget::slotCoordSysVisibility(bool _visible){
return; return;
} }
if (_visible) if (_visible)
coordSys->show(); coordSys->show();
else else
coordSys->hide(); coordSys->hide();
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
examiner_widgets_[i]->updateGL(); examiner_widgets_[i]->updateGL();
} }
void CoreWidget::slotSetViewingDirection(QAction* _action) { void CoreWidget::slotSetViewingDirection(QAction* _action) {
......
...@@ -169,6 +169,7 @@ glViewer::glViewer( QGraphicsScene* _scene, ...@@ -169,6 +169,7 @@ glViewer::glViewer( QGraphicsScene* _scene,
normalsMode_ = DONT_TOUCH_NORMALS; normalsMode_ = DONT_TOUCH_NORMALS;
projectionMode_ = PERSPECTIVE_PROJECTION; projectionMode_ = PERSPECTIVE_PROJECTION;
navigationMode_ = NORMAL_NAVIGATION;
light_matrix_.identity(); light_matrix_.identity();
...@@ -332,6 +333,23 @@ void glViewer::projectionMode(ProjectionMode _p) ...@@ -332,6 +333,23 @@ void glViewer::projectionMode(ProjectionMode _p)
updateProjectionMatrix(); updateProjectionMatrix();
} }
void glViewer::toggleNavigationMode()
{
if (navigationMode_ == NORMAL_NAVIGATION)
navigationMode(EGOSHOOTER_NAVIGATION);
else
navigationMode(NORMAL_NAVIGATION);
}
void glViewer::navigationMode(NavigationMode _n)
{
if ((navigationMode_ = _n) == NORMAL_NAVIGATION)
emit navigationModeChanged( true );
else
emit navigationModeChanged( false );
}
void glViewer::updateProjectionMatrix() void glViewer::updateProjectionMatrix()
{ {
...@@ -1563,6 +1581,29 @@ void glViewer::mouseMoveEvent(QGraphicsSceneMouseEvent* _e) ...@@ -1563,6 +1581,29 @@ void glViewer::mouseMoveEvent(QGraphicsSceneMouseEvent* _e)
} }
} }
//----------------------------------------------------------------------------------
void glViewer::keyPressEvent ( QKeyEvent* _event ) {
_event->accept();
switch (properties_.actionMode()) {
case Viewer::ExamineMode:
viewKeyEvent(_event);
break;
default: // avoid warning
break;
}
}
//----------------------------------------------------------------------------------
bool glViewer::viewKeyPressEvent(QKeyEvent* _event) {
_event->accept();
return true;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -1682,157 +1723,207 @@ void glViewer::dropEvent(QGraphicsSceneDragDropEvent* _e) ...@@ -1682,157 +1723,207 @@ void glViewer::dropEvent(QGraphicsSceneDragDropEvent* _e)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void glViewer::viewMouseEvent(QMouseEvent* _event) {
glViewer::viewMouseEvent(QMouseEvent* _event)
{
QPointF f (mapFromScene(QPointF(_event->pos().x(), _event->pos().y())));
QPoint pos (f.x(), f.y());
switch (_event->type()) if (navigationMode_ == NORMAL_NAVIGATION) {
{
case QEvent::MouseButtonPress:
{
// shift key -> set rotation center
if (_event->modifiers() & Qt::ShiftModifier)
{
ACG::Vec3d c;
if (fast_pick(pos, c))
{
trackball_center_ = c;
trackball_radius_ = std::max(scene_radius_, (c-glstate_->eye()).norm()*0.9f);
}
}
lastPoint_hitSphere_ = mapToSphere( lastPoint2D_= pos, treatNormalNavigation(_event);
lastPoint3D_ );
isRotating_ = true;
timer_->stop();
} else if (navigationMode_ == EGOSHOOTER_NAVIGATION) {
break; treatEgoShooterNavigation(_event);
} }
}
//----------------------------------------------------------------------------
case QEvent::MouseButtonDblClick: void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) {
{
if (allowRotation_)
flyTo(_event->pos(), _event->button()==Qt::MidButton);
break;
}
// Ego-shooter navigation mode is selected
QPointF f(mapFromScene(QPointF(_event->pos().x(), _event->pos().y())));
QPoint pos(f.x(), f.y());
case QEvent::MouseMove: switch (_event->type()) {
{
double factor = 1.0;
if (_event->modifiers() == Qt::ShiftModifier) case QEvent::MouseButtonDblClick: {