]> SALOME platform Git repositories - modules/visu.git/blobdiff - src/VISUGUI/VisuGUI_TransparencyDlg.cxx
Salome HOME
Merge from BR_WIN_INDUS_514 branch 21/03/2011 (Windows industrialization)
[modules/visu.git] / src / VISUGUI / VisuGUI_TransparencyDlg.cxx
index 5b5b026e4930edfb99bbbe7241f66278255fe53b..6ea3a861ede334e754154ca8a51caad3ab1828a5 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU VISUGUI : GUI of VISU component
 //  File   : VisuGUI_TransparencyDlg.cxx
 //  Author : Nicolas REJNERI
@@ -56,7 +57,8 @@
 #include <QGroupBox>
 #include <QKeyEvent>
 
-using namespace std;
+const int DEFAULT_OPACITY = 100;
+const int UNDEF_OPACITY = -1;
 
 //=================================================================================
 // class    : VisuGUI_TransparencyDlg()
@@ -65,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 );
@@ -90,8 +92,8 @@ VisuGUI_TransparencyDlg::VisuGUI_TransparencyDlg( VisuGUI* theModule,
   GroupC1Layout->setMargin(11);
 
   TextLabelTransparent = new QLabel(tr("TRANSPARENCY_TRANSPARENT" ), GroupC1);
-  TextLabelTransparent->setAlignment(Qt::AlignLeft);
-  GroupC1Layout->addWidget(TextLabelTransparent, 0, 0);
+  TextLabelTransparent->setAlignment(Qt::AlignRight);
+  GroupC1Layout->addWidget(TextLabelTransparent, 0, 2);
 
   ValueLab = new QLabel(GroupC1);
   ValueLab->setAlignment(Qt::AlignCenter);
@@ -100,8 +102,8 @@ VisuGUI_TransparencyDlg::VisuGUI_TransparencyDlg( VisuGUI* theModule,
   GroupC1Layout->addWidget(ValueLab, 0, 1);
 
   TextLabelOpaque = new QLabel(tr("TRANSPARENCY_OPAQUE" ), GroupC1);
-  TextLabelOpaque->setAlignment(Qt::AlignRight);
-  GroupC1Layout->addWidget(TextLabelOpaque, 0, 2);
+  TextLabelOpaque->setAlignment(Qt::AlignLeft);
+  GroupC1Layout->addWidget(TextLabelOpaque, 0, 1);
 
   Slider1 = new QSlider( Qt::Horizontal, GroupC1 );
   Slider1->setMinimum( 0 );
@@ -176,18 +178,18 @@ void VisuGUI_TransparencyDlg::ClickOnOk()
 //=======================================================================
 void VisuGUI_TransparencyDlg::ClickOnHelp()
 {
-  QString aHelpFileName = "viewing_3d_presentations_intro_page.html#width_opacity_anchor";
+  QString aHelpFileName = "viewing_3d_presentations_page.html#width_opacity_anchor";
   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
   if (app) {
     VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
     app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
   }
   else {
-               QString platform;
+                QString platform;
 #ifdef WIN32
-               platform = "winapplication";
+                platform = "winapplication";
 #else
-               platform = "application";
+                platform = "application";
 #endif
     SUIT_MessageBox::warning(0, tr("WRN_WARNING"),
                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
@@ -205,7 +207,7 @@ void VisuGUI_TransparencyDlg::SetTransparency()
 {
   if( myViewWindow ) {
     SUIT_OverrideCursor wc;
-    float opacity = this->Slider1->value() / 100.;
+    float opacity = (100 - this->Slider1->value() ) / 100.;
 
     SALOME_ListIO aList;
     mySelectionMgr->selectedObjects(aList);
@@ -214,12 +216,12 @@ void VisuGUI_TransparencyDlg::SetTransparency()
     for (; anIter.More(); anIter.Next()) {
       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
       VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry());
-      if (anActor)
-       anActor->SetOpacity(opacity);
-      else {
-       VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry());
       if (anActor)
         anActor->SetOpacity(opacity);
+      else {
+        VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry());
+       if (anActor)
+         anActor->SetOpacity(opacity);
       }
     }
     myViewWindow->Repaint();
@@ -242,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( 100 - ( opacity == UNDEF_OPACITY ? DEFAULT_OPACITY : opacity ) );
   }
   ValueHasChanged();
 }