From 46ce96920eb5bd2d6c10ad0dca389c83c0b54520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 3 Aug 2009 08:45:18 +0000 Subject: [PATCH] Add menu entries to set multisampling git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6689 383ad7c9-94d9-4d36-a494-682f7c89f535 --- common/ViewerProperties.cc | 1 + common/ViewerProperties.hh | 12 ++++++++++ widgets/coreWidget/ContextMenu.cc | 12 +++++++++- widgets/coreWidget/CoreWidget.hh | 20 +++++++++++++---- widgets/coreWidget/MenuBar.cc | 35 ++++++++++++++++++++++++++--- widgets/coreWidget/viewerControl.cc | 11 +++++++++ widgets/glWidget/QtBaseViewer.cc | 2 ++ 7 files changed, 85 insertions(+), 8 deletions(-) diff --git a/common/ViewerProperties.cc b/common/ViewerProperties.cc index 30b65e39..d616ffef 100644 --- a/common/ViewerProperties.cc +++ b/common/ViewerProperties.cc @@ -58,6 +58,7 @@ namespace Viewer { locked_(0), backFaceCulling_(false), twoSidedLighting_(true), + multisampling_(true), animation_(false), glState_(0), objectMarker_(0) diff --git a/common/ViewerProperties.hh b/common/ViewerProperties.hh index 44d178c7..aa406cf6 100644 --- a/common/ViewerProperties.hh +++ b/common/ViewerProperties.hh @@ -302,6 +302,18 @@ namespace Viewer { private: bool twoSidedLighting_; + + //=========================================================================== + + public slots: + /// set multisampling on/off + void multisampling(bool _state ) { multisampling_ = _state; emit updated(); } + + /// is multisampling enabled? + bool multisampling() { return multisampling_; }; + + private: + bool multisampling_; //=========================================================================== diff --git a/widgets/coreWidget/ContextMenu.cc b/widgets/coreWidget/ContextMenu.cc index 479ebbae..81608447 100644 --- a/widgets/coreWidget/ContextMenu.cc +++ b/widgets/coreWidget/ContextMenu.cc @@ -165,6 +165,16 @@ void CoreWidget::updatePopupMenuCoordsysNode(QMenu* _menu , const int /*_part*/ twoSidedLighting->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") ); twoSidedLighting->setChecked( PluginFunctions::viewerProperties().twoSidedLighting() ); connect(twoSidedLighting, SIGNAL(triggered(bool)), this , SLOT( slotLocalChangeTwoSidedLighting(bool) ) ); + + //==================================================================================================== + + QAction* multisampling = renderingOptionsMenu->addAction("Multisampling"); + multisampling->setToolTip("Enable Multisampling"); + multisampling->setCheckable( true ); +// TODO:Add icon for multisampling +// twoSidedLighting->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") ); + multisampling->setChecked( PluginFunctions::viewerProperties().multisampling() ); + connect(multisampling, SIGNAL(triggered(bool)), this , SLOT( slotLocalChangeMultisampling(bool) ) ); //==================================================================================================== // Other Toplevel Action @@ -456,7 +466,7 @@ void CoreWidget::updatePopupMenu(const QPoint& _point) { break; case OBJECTCONTEXT: updatePopupMenuObject(contextMenu_ , object ); -// return; + return; break; case COORDSYSCONTEXT: updatePopupMenuCoordsysNode(contextMenu_,target_idx); diff --git a/widgets/coreWidget/CoreWidget.hh b/widgets/coreWidget/CoreWidget.hh index 9274dc3b..f36b3348 100644 --- a/widgets/coreWidget/CoreWidget.hh +++ b/widgets/coreWidget/CoreWidget.hh @@ -273,8 +273,13 @@ public: public: - /// Setup the main menubar - void setupMenuBar(); + /// Setup the main menubar + void setupMenuBar(); + + private slots: + + /// Update the menubat + void slotUpdateMenuBar(); /** @} */ @@ -895,8 +900,15 @@ public: /// Set two sided lighting for active viewer void slotLocalChangeTwoSidedLighting(bool _lighting); - - + + + + /// Set Multisampling for all viewers + void slotGlobalChangeMultisampling(bool _lighting); + + /// Set Multisampling for active viewer + void slotLocalChangeMultisampling(bool _lighting); + private : bool stereoActive_; diff --git a/widgets/coreWidget/MenuBar.cc b/widgets/coreWidget/MenuBar.cc index acd47789..59c411dc 100644 --- a/widgets/coreWidget/MenuBar.cc +++ b/widgets/coreWidget/MenuBar.cc @@ -275,6 +275,7 @@ void CoreWidget::setupMenuBar() disabledCount++; } + backfaceCulling->setCheckable( true ); if ( enabledCount != 0 && disabledCount != 0 ) backfaceCulling->setChecked(Qt::PartiallyChecked); else if ( enabledCount == 4 ) @@ -283,7 +284,6 @@ void CoreWidget::setupMenuBar() backfaceCulling->setChecked( Qt::Unchecked ); backfaceCulling->setToolTip("Enable backface culling"); - backfaceCulling->setCheckable( true ); backfaceCulling->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") ); connect(backfaceCulling, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeBackFaceCulling(bool) ) ); @@ -300,6 +300,7 @@ void CoreWidget::setupMenuBar() disabledCount++; } + twoSidedLighting->setCheckable( true ); if ( enabledCount != 0 && disabledCount != 0 ) twoSidedLighting->setChecked(Qt::PartiallyChecked); else if ( enabledCount == 4 ) @@ -308,10 +309,34 @@ void CoreWidget::setupMenuBar() twoSidedLighting->setChecked( Qt::Unchecked ); twoSidedLighting->setToolTip("Enable two-sided lighting"); - twoSidedLighting->setCheckable( true ); twoSidedLighting->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") ); - twoSidedLighting->setChecked( PluginFunctions::viewerProperties().twoSidedLighting() ); connect(twoSidedLighting, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeTwoSidedLighting(bool) ) ); + + //====================== + + QAction* multisampling = renderingOptionsMenu->addAction("Multisampling"); + + enabledCount = 0; + disabledCount = 0; + for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) { + if ( PluginFunctions::viewerProperties(i).multisampling() ) + enabledCount++; + else + disabledCount++; + } + + multisampling->setCheckable( true ); + if ( enabledCount != 0 && disabledCount != 0 ) + multisampling->setChecked(Qt::PartiallyChecked); + else if ( enabledCount == 4 ) + multisampling->setChecked( Qt::Checked ); + else + multisampling->setChecked( Qt::Unchecked ); + + multisampling->setToolTip("Enable Multisampling"); +// TODO:Icon for multisampling +// multisampling->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") ); + connect(multisampling, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeMultisampling(bool)) ); //============================================================================================================ // Other toplevel actions @@ -501,6 +526,10 @@ void CoreWidget::setupMenuBar() } +void CoreWidget::slotUpdateMenuBar() { + +} + void CoreWidget::slotViewMenuAboutToShow() { uint perspectiveCount = 0; diff --git a/widgets/coreWidget/viewerControl.cc b/widgets/coreWidget/viewerControl.cc index 019d47c5..135b39ec 100644 --- a/widgets/coreWidget/viewerControl.cc +++ b/widgets/coreWidget/viewerControl.cc @@ -198,6 +198,17 @@ void CoreWidget::slotLocalChangeTwoSidedLighting(bool _lighting) { PluginFunctions::viewerProperties().twoSidedLighting(_lighting); } +/// Set Multisampling for all viewers +void CoreWidget::slotGlobalChangeMultisampling(bool _multisampling) { + for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) + PluginFunctions::viewerProperties(i).multisampling( _multisampling ); +} + +/// Set Multisampling for active viewer +void CoreWidget::slotLocalChangeMultisampling(bool _multisampling) { + PluginFunctions::viewerProperties().multisampling( _multisampling ); +} + /// Take a snapshot of the current Viewer void CoreWidget::slotSnapshot() { diff --git a/widgets/glWidget/QtBaseViewer.cc b/widgets/glWidget/QtBaseViewer.cc index ff525a1e..42b74b8f 100644 --- a/widgets/glWidget/QtBaseViewer.cc +++ b/widgets/glWidget/QtBaseViewer.cc @@ -1949,6 +1949,8 @@ void glViewer::applyProperties() { glstate_->set_twosided_lighting( properties_.twoSidedLighting() ); glstate_->set_clear_color( properties_.backgroundColor() ); + + glstate_->allow_multisampling( properties_.multisampling() ); if (properties_.isCCWFront() ) glFrontFace( GL_CCW ); -- GitLab