From 2c37a9ce3f727614f2836a59e6617d32619a14c0 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 23 Jun 2010 12:32:15 +0000 Subject: [PATCH] Fix opacity problem for base actor class (default value is not set) --- src/VISUGUI/VisuGUI_TransparencyDlg.cxx | 70 ++++++++++++------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/src/VISUGUI/VisuGUI_TransparencyDlg.cxx b/src/VISUGUI/VisuGUI_TransparencyDlg.cxx index 3890d2b5..f14baab8 100644 --- a/src/VISUGUI/VisuGUI_TransparencyDlg.cxx +++ b/src/VISUGUI/VisuGUI_TransparencyDlg.cxx @@ -57,7 +57,8 @@ #include #include -using namespace std; +const int DEFAULT_OPACITY = 100; +const int UNDEF_OPACITY = -1; //================================================================================= // class : VisuGUI_TransparencyDlg() @@ -66,10 +67,10 @@ using namespace std; //================================================================================= VisuGUI_TransparencyDlg::VisuGUI_TransparencyDlg( VisuGUI* theModule, bool modal ) - : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), - myModule(theModule), - mySelectionMgr( VISU::GetSelectionMgr( theModule ) ), - myViewWindow( VISU::GetActiveViewWindow(theModule) ) + : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myModule(theModule), + mySelectionMgr( VISU::GetSelectionMgr( theModule ) ), + myViewWindow( VISU::GetActiveViewWindow(theModule) ) { setModal( modal ); setAttribute( Qt::WA_DeleteOnClose ); @@ -219,8 +220,8 @@ void VisuGUI_TransparencyDlg::SetTransparency() anActor->SetOpacity(opacity); else { VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry()); - if (anActor) - anActor->SetOpacity(opacity); + if (anActor) + anActor->SetOpacity(opacity); } } myViewWindow->Repaint(); @@ -243,42 +244,37 @@ void VisuGUI_TransparencyDlg::ValueHasChanged() //================================================================================= void VisuGUI_TransparencyDlg::onSelectionChanged() { - if( myViewWindow ) { - int opacity = 100; + if ( myViewWindow ) { + int opacity = UNDEF_OPACITY; SALOME_ListIO aList; mySelectionMgr->selectedObjects(aList); - if (aList.Extent() == 1) { - Handle(SALOME_InteractiveObject) FirstIOS = aList.First(); - if (!FirstIOS.IsNull()) { - VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, FirstIOS->getEntry()); - if (anActor) - opacity = int(anActor->GetOpacity() * 100. + 0.5); - } - } else if (aList.Extent() > 1) { - SALOME_ListIteratorOfListIO It (aList); - int setOp = -1; - for (; It.More(); It.Next()) { - Handle(SALOME_InteractiveObject) IO = It.Value(); - if (!IO.IsNull()) { - VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, IO->getEntry()); - if (anActor) { - int op = int(anActor->GetOpacity() * 100. + 0.5); - if (setOp < 0) - setOp = op; - else if (setOp != op) { - setOp = 100; - break; - } - } - } + SALOME_ListIteratorOfListIO It (aList); + for (; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) IO = It.Value(); + if (!IO.IsNull()) { + int op = UNDEF_OPACITY; + VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, IO->getEntry()); + if (anActor) { + op = int(anActor->GetOpacity() * 100. + 0.5); + } + else { + VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, IO->getEntry()); + if (anActor) + op = int(anActor->GetOpacity() * 100. + 0.5); + } + if ( op != UNDEF_OPACITY ) { + if ( opacity == UNDEF_OPACITY ) + opacity = op; + else if ( opacity != op ) { + opacity = DEFAULT_OPACITY; + break; + } + } } - if (setOp >= 0) - opacity = setOp; - } else { } - Slider1->setValue(opacity); + Slider1->setValue( opacity == UNDEF_OPACITY ? DEFAULT_OPACITY : opacity ); } ValueHasChanged(); } -- 2.39.2