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

Fixed view menu updates for global viewer states

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6690 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 2e4d5eb4
...@@ -276,11 +276,6 @@ public: ...@@ -276,11 +276,6 @@ public:
/// Setup the main menubar /// Setup the main menubar
void setupMenuBar(); void setupMenuBar();
private slots:
/// Update the menubat
void slotUpdateMenuBar();
/** @} */ /** @} */
//=========================================================================== //===========================================================================
...@@ -567,6 +562,18 @@ public: ...@@ -567,6 +562,18 @@ public:
QAction* perspectiveProjectionAction_; QAction* perspectiveProjectionAction_;
QAction* orthogonalProjectionAction_; QAction* orthogonalProjectionAction_;
/// Action to globally set Animation
QAction* globalAnimationAction_;
/// Action to globally set backface culling
QAction* globalBackfaceCullingAction_;
/// Action to globally set Two-Sided lighting
QAction* globalTwosidedLightingAction_;
/// Action to globally set multisampling
QAction* globalMultisamplingAction_;
int activeDrawModes_; int activeDrawModes_;
......
...@@ -238,105 +238,34 @@ void CoreWidget::setupMenuBar() ...@@ -238,105 +238,34 @@ void CoreWidget::setupMenuBar()
connect( orthogonalProjectionAction_,SIGNAL( triggered() ), this, SLOT( slotGlobalOrthographicProjection() ) ); connect( orthogonalProjectionAction_,SIGNAL( triggered() ), this, SLOT( slotGlobalOrthographicProjection() ) );
renderingOptionsMenu->addAction( orthogonalProjectionAction_); renderingOptionsMenu->addAction( orthogonalProjectionAction_);
QAction* animation = renderingOptionsMenu->addAction("Animation"); // =====================
uint enabledCount = 0; globalAnimationAction_ = renderingOptionsMenu->addAction("Animation");
uint disabledCount = 0; globalAnimationAction_->setCheckable( true );
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) { globalAnimationAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"animation.png") );
if ( PluginFunctions::viewerProperties(i).animation() ) connect(globalAnimationAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeAnimation(bool) ) );
enabledCount++;
else
disabledCount++;
}
if ( enabledCount != 0 && disabledCount != 0 )
animation->setChecked(Qt::PartiallyChecked);
else if ( enabledCount == 4 )
animation->setChecked( Qt::Checked );
else
animation->setChecked( Qt::Unchecked );
animation->setToolTip("Animate rotation of objects");
animation->setCheckable( true );
animation->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"animation.png") );
connect(animation, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeAnimation(bool) ) );
//====================== //======================
QAction* backfaceCulling = renderingOptionsMenu->addAction("Backface Culling"); globalBackfaceCullingAction_ = renderingOptionsMenu->addAction("Backface Culling");
globalBackfaceCullingAction_->setCheckable( true );
enabledCount = 0; globalBackfaceCullingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") );
disabledCount = 0; connect(globalBackfaceCullingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeBackFaceCulling(bool) ) );
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).backFaceCulling() )
enabledCount++;
else
disabledCount++;
}
backfaceCulling->setCheckable( true );
if ( enabledCount != 0 && disabledCount != 0 )
backfaceCulling->setChecked(Qt::PartiallyChecked);
else if ( enabledCount == 4 )
backfaceCulling->setChecked( Qt::Checked );
else
backfaceCulling->setChecked( Qt::Unchecked );
backfaceCulling->setToolTip("Enable backface culling");
backfaceCulling->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"backFaceCulling.png") );
connect(backfaceCulling, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeBackFaceCulling(bool) ) );
//====================== //======================
QAction* twoSidedLighting = renderingOptionsMenu->addAction("Two-sided Lighting"); globalTwosidedLightingAction_ = renderingOptionsMenu->addAction("Two-sided Lighting");
globalTwosidedLightingAction_->setCheckable( true );
enabledCount = 0; globalTwosidedLightingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
disabledCount = 0; connect(globalTwosidedLightingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeTwoSidedLighting(bool) ) );
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).twoSidedLighting() )
enabledCount++;
else
disabledCount++;
}
twoSidedLighting->setCheckable( true );
if ( enabledCount != 0 && disabledCount != 0 )
twoSidedLighting->setChecked(Qt::PartiallyChecked);
else if ( enabledCount == 4 )
twoSidedLighting->setChecked( Qt::Checked );
else
twoSidedLighting->setChecked( Qt::Unchecked );
twoSidedLighting->setToolTip("Enable two-sided lighting");
twoSidedLighting->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
connect(twoSidedLighting, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeTwoSidedLighting(bool) ) );
//====================== //======================
QAction* multisampling = renderingOptionsMenu->addAction("Multisampling"); globalMultisamplingAction_ = renderingOptionsMenu->addAction("Multisampling");
globalMultisamplingAction_->setCheckable( true );
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 // TODO:Icon for multisampling
// multisampling->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") ); // globalMultisamplingAction_->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"twosidedLighting.png") );
connect(multisampling, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeMultisampling(bool)) ); connect(globalMultisamplingAction_, SIGNAL(triggered(bool)), this , SLOT( slotGlobalChangeMultisampling(bool)) );
//============================================================================================================ //============================================================================================================
// Other toplevel actions // Other toplevel actions
...@@ -523,15 +452,126 @@ void CoreWidget::setupMenuBar() ...@@ -523,15 +452,126 @@ void CoreWidget::setupMenuBar()
mainToolbar_->addSeparator(); mainToolbar_->addSeparator();
mainToolbar_->addAction(AC_load_ini); mainToolbar_->addAction(AC_load_ini);
mainToolbar_->addAction(AC_save_ini); mainToolbar_->addAction(AC_save_ini);
} }
void CoreWidget::slotUpdateMenuBar() {
}
void CoreWidget::slotViewMenuAboutToShow() { void CoreWidget::slotViewMenuAboutToShow() {
uint enabledCount = 0;
uint disabledCount = 0;
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).animation() )
enabledCount++;
else
disabledCount++;
}
if ( enabledCount != 0 && disabledCount != 0 ) {
globalAnimationAction_->setChecked(Qt::PartiallyChecked);
globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));
globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));
globalAnimationAction_->setText(tr("Disable animation"));
} else if ( enabledCount == 4 ) {
globalAnimationAction_->setChecked( Qt::Checked );
globalAnimationAction_->setToolTip(tr("Disable animation for all viewers"));
globalAnimationAction_->setStatusTip(tr("Disable animation for all viewers"));
globalAnimationAction_->setText(tr("Disable animation"));
} else {
globalAnimationAction_->setChecked( Qt::Unchecked );
globalAnimationAction_->setToolTip(tr("Enable animation for all viewers"));
globalAnimationAction_->setStatusTip(tr("Enable animation for all viewers"));
globalAnimationAction_->setText(tr("Enable animation"));
}
//=============================================================================================================================
enabledCount = 0;
disabledCount = 0;
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).backFaceCulling() )
enabledCount++;
else
disabledCount++;
}
if ( enabledCount != 0 && disabledCount != 0 ) {
globalBackfaceCullingAction_->setChecked(Qt::PartiallyChecked);
globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));
globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));
globalBackfaceCullingAction_->setText(tr("Disable backface culling"));
} else if ( enabledCount == 4 ) {
globalBackfaceCullingAction_->setChecked( Qt::Checked );
globalBackfaceCullingAction_->setToolTip(tr("Disable backface culling for all viewers"));
globalBackfaceCullingAction_->setStatusTip(tr("Disable backface culling for all viewers"));
globalBackfaceCullingAction_->setText(tr("Disable backface culling"));
} else {
globalBackfaceCullingAction_->setChecked( Qt::Unchecked );
globalBackfaceCullingAction_->setToolTip(tr("Enable backface culling for all viewers"));
globalBackfaceCullingAction_->setStatusTip(tr("Enable backface culling for all viewers"));
globalBackfaceCullingAction_->setText(tr("Enable backface culling"));
}
//=============================================================================================================================
enabledCount = 0;
disabledCount = 0;
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).twoSidedLighting() )
enabledCount++;
else
disabledCount++;
}
if ( enabledCount != 0 && disabledCount != 0 ) {
globalTwosidedLightingAction_->setChecked(Qt::PartiallyChecked);
globalTwosidedLightingAction_->setToolTip(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"));
} else if ( enabledCount == 4 ) {
globalTwosidedLightingAction_->setChecked( Qt::Checked );
globalTwosidedLightingAction_->setToolTip(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"));
} else {
globalTwosidedLightingAction_->setChecked( Qt::Unchecked );
globalTwosidedLightingAction_->setToolTip(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"));
}
//=============================================================================================================================
enabledCount = 0;
disabledCount = 0;
for ( int i = 0 ; i< PluginFunctions::viewers(); ++i ) {
if ( PluginFunctions::viewerProperties(i).multisampling() )
enabledCount++;
else
disabledCount++;
}
if ( enabledCount != 0 && disabledCount != 0 ) {
globalMultisamplingAction_->setChecked(Qt::PartiallyChecked);
globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers"));
globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers"));
globalMultisamplingAction_->setText(tr("Disable Multisampling"));
} else if ( enabledCount == 4 ) {
globalMultisamplingAction_->setChecked( Qt::Checked );
globalMultisamplingAction_->setToolTip(tr("Disable Multisampling for all viewers"));
globalMultisamplingAction_->setStatusTip(tr("Disable Multisampling for all viewers"));
globalMultisamplingAction_->setText(tr("Disable Multisampling"));
} else {
globalMultisamplingAction_->setChecked( Qt::Unchecked );
globalMultisamplingAction_->setToolTip(tr("Enable Multisampling for all viewers"));
globalMultisamplingAction_->setStatusTip(tr("Enable Multisampling for all viewers"));
globalMultisamplingAction_->setText(tr("&Enable Multisampling"));
}
uint perspectiveCount = 0; uint perspectiveCount = 0;
uint orthogonalCount = 0; uint orthogonalCount = 0;
......
...@@ -178,6 +178,8 @@ void CoreWidget::slotLocalChangeAnimation(bool _animation){ ...@@ -178,6 +178,8 @@ 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);
std::cerr << " Backface Culling " << std::endl;
} }
......
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