]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix opacity problem for base actor class (default value is not set)
authorvsr <vsr@opencascade.com>
Wed, 23 Jun 2010 12:32:15 +0000 (12:32 +0000)
committervsr <vsr@opencascade.com>
Wed, 23 Jun 2010 12:32:15 +0000 (12:32 +0000)
src/VISUGUI/VisuGUI_TransparencyDlg.cxx

index 3890d2b5d8156a373e862ad33793831c361940ad..f14baab8ba105d6a46439d95cf88d3794219d2dd 100644 (file)
@@ -57,7 +57,8 @@
 #include <QGroupBox>
 #include <QKeyEvent>
 
-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<SVTK_ViewWindow>(theModule) )
+  : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+    myModule(theModule),
+    mySelectionMgr( VISU::GetSelectionMgr( theModule ) ),
+    myViewWindow( VISU::GetActiveViewWindow<SVTK_ViewWindow>(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();
 }