Salome HOME
0021209: Bug GetInPlace with faces. Integrate self-intersections checker.
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_TransparencyDlg.cxx
index 399ba9be9d506acc4cb79283a57076faae0c1e7b..3447f1f975889231cbff805a8a4747b7163241e8 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  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
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 // GEOM GEOMGUI : GUI for Geometry component
@@ -97,8 +97,8 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg( QWidget* parent )
   GroupC1Layout->setMargin( 11 );
   
   QLabel* TextLabelTransparent = new QLabel( tr( "GEOM_TRANSPARENCY_TRANSPARENT" ), GroupC1 );
-  TextLabelTransparent->setAlignment( Qt::AlignRight );
-  GroupC1Layout->addWidget( TextLabelTransparent, 0, 0 );
+  TextLabelTransparent->setAlignment( Qt::AlignLeft );
+  GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 );
   
   myValueLab = new QLabel( GroupC1 );
   myValueLab->setAlignment( Qt::AlignCenter );
@@ -107,8 +107,8 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg( QWidget* parent )
   GroupC1Layout->addWidget( myValueLab, 0, 1 );
 
   QLabel* TextLabelOpaque = new QLabel( tr( "GEOM_TRANSPARENCY_OPAQUE" ), GroupC1 );
-  TextLabelOpaque->setAlignment( Qt::AlignLeft );
-  GroupC1Layout->addWidget( TextLabelOpaque, 0, 2 );
+  TextLabelOpaque->setAlignment( Qt::AlignRight );
+  GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 );
   //GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
   
   mySlider = new QSlider( Qt::Horizontal, GroupC1 );
@@ -242,7 +242,7 @@ void GEOMToolsGUI_TransparencyDlg::SliderHasMoved(int value)
 //=================================================================================
 void GEOMToolsGUI_TransparencyDlg::SetTransparency()
 {
-  float newValue = ( 100 - mySlider->value() ) / 100.;
+  float newValue = mySlider->value() / 100.;
 
   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
   if ( !app )
@@ -276,7 +276,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency()
     SVTK_View* aView = vtkVW->getView();
     if ( myFirstInit ) {        
       myFirstInit = false;
-      int transp = int (100 - ((aView->GetTransparency(FirstIOS))*100.0) + 0.5);
+      int transp = int ((aView->GetTransparency(FirstIOS))*100.0 + 0.5);
       mySlider->setValue(transp);
       ValueHasChanged();
       return;
@@ -293,16 +293,14 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency()
         
   else if ( isOCC ) {
     GEOMBase* gb = new GEOMBase();
-    Standard_Boolean found;
     Handle(GEOM_AISShape) aisShape;
     if ( myFirstInit ) {
       mySlider->setValue(mySlider->maximum());
       myFirstInit = false;
-      aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, found );
-      if( !found )
+      aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, true );
+      if( aisShape.IsNull() )
         return;
-      int transp = int( 100 - ( aisShape->Transparency() * 100.0 ) + 0.5);
-      std::cout << "transp: " << transp << std::endl;
+      int transp = int( aisShape->Transparency() * 100.0 + 0.5);
       mySlider->setValue(transp);
       ValueHasChanged();
       return;
@@ -314,8 +312,8 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency()
       return;
     Handle(AIS_InteractiveContext) ic = vm->getAISContext();
     for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
-      aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), found );
-      if ( found ) {
+      aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
+      if ( !aisShape.IsNull() ) {
         ic->SetTransparency( aisShape, newValue, false );
         ic->Redisplay( aisShape, Standard_False, Standard_True );
        aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue );