Salome HOME
Fix of transparency on Mandriva2010: it didn't worked because of the returned 'testRe...
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_TransparencyDlg.cxx
index 6e39d15d07cf376a35647b8da8d4c2325e0c6d89..92f56b4fb2557aeded9e384b3ee10331557c9220 100644 (file)
@@ -48,6 +48,7 @@
 #include <SalomeApp_Application.h>
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Study.h>
 
 #include <QLabel>
 #include <QPushButton>
@@ -122,7 +123,7 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg( QWidget* parent )
   //mySlider->setValue( 5 );
   mySlider->setTracking(false);
 
-  mySlider->setTickPosition( QSlider::TicksLeft );
+  mySlider->setTickPosition( QSlider::TicksAbove );
   GroupC1Layout->addWidget( mySlider, 1, 0, 1, 3 );
 
   /*************************************************************************/
@@ -249,6 +250,12 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency()
   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
   if ( !aSelMgr )
     return;
+  
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+  
+  if(!aStudy)
+    return;
+  
   SALOME_ListIO selected;
   aSelMgr->selectedObjects( selected );
   if ( selected.IsEmpty() )
@@ -261,7 +268,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency()
   SUIT_ViewWindow* window = app->desktop()->activeWindow();
   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
   bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
-
+  int aMgrId = window->getViewManager()->getGlobalId();
   if ( isVTK ) {
     SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
     if ( !vtkVW )
@@ -278,6 +285,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency()
     SUIT_OverrideCursor();
     for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
       aView->SetTransparency( It.Value(), newValue );
+      aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue );
     }
     GeometryGUI::Modified();
     aView->Repaint();
@@ -285,12 +293,12 @@ 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 );
+      if( aisShape.IsNull() )
         return;
       int transp = int( 100 - ( aisShape->Transparency() * 100.0 ) + 0.5);
       mySlider->setValue(transp);
@@ -304,10 +312,11 @@ 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() );
+      if ( !aisShape.IsNull() ) {
         ic->SetTransparency( aisShape, newValue, false );
         ic->Redisplay( aisShape, Standard_False, Standard_True );
+       aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue );
       }
     } // for...
     ic->UpdateCurrentViewer();