Salome HOME
PAL13091: dump study echec. Correctly remove all sub-objects on removal of main object.
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_TransparencyDlg.cxx
index 1610f9149b9602d83a5653aadaed3b7459b64815..d12ccf7a6428282594c1624e214edff2e4880ab2 100644 (file)
@@ -17,7 +17,7 @@
 //  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 #include "GEOMToolsGUI_TransparencyDlg.h"
 #include "GEOMBase.h"
 #include "GEOM_AISShape.hxx"
+#include "GeometryGUI.h"
 
-#include <SALOME_ListIO.hxx>
-#include <SALOME_ListIteratorOfListIO.hxx>
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include <SVTK_ViewModel.h>
+#include <SVTK_ViewWindow.h>
+#include <SVTK_View.h>
 
-#include <VTKViewer_ViewModel.h>
 #include <OCCViewer_ViewModel.h>
 #include <OCCViewer_ViewWindow.h>
 
-#include <SVTK_ViewWindow.h>
-#include <SVTK_RenderWindowInteractor.h>
-
 #include <SUIT_ViewManager.h>
 #include <SUIT_Application.h>
 #include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
 #include <SUIT_OverrideCursor.h>
 
 #include <SalomeApp_Application.h>
-#include <SalomeApp_SelectionMgr.h>
+#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
 
 #include <qframe.h>
 #include <qlabel.h>
@@ -96,9 +99,15 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg( QWidget* parent )
   buttonOk->setText( tr( "GEOM_BUT_OK" ) );
   buttonOk->setAutoDefault( TRUE );
   buttonOk->setDefault( TRUE );
-  GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0 );
-  GroupButtonsLayout->addWidget( buttonOk, 0, 1 );
-  GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2 );
+
+  QPushButton* buttonHelp = new QPushButton( GroupButtons, "buttonHelp" );
+  buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
+  buttonHelp->setAutoDefault( TRUE );
+  buttonHelp->setDefault( TRUE );
+  
+  GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+  GroupButtonsLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 );
+  GroupButtonsLayout->addWidget( buttonHelp, 0, 2 );
 
   /*************************************************************************/
   QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
@@ -137,8 +146,11 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg( QWidget* parent )
   //  mySlider->setValue( 5 ) ;
   ValueHasChanged(mySlider->value());
   
+  myHelpFileName = "transparency.htm";
+
   // signals and slots connections : after ValueHasChanged()
   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+  connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
   connect(mySlider, SIGNAL(valueChanged(int)), this, SLOT(ValueHasChanged(int)));
 }
 
@@ -174,6 +186,24 @@ void GEOMToolsGUI_TransparencyDlg::ClickOnClose()
   return;
 }
 
+//=================================================================================
+// function : ClickOnHelp()
+// purpose  :
+//=================================================================================
+void GEOMToolsGUI_TransparencyDlg::ClickOnHelp()
+{
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app) {
+    GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
+    app->onHelpContextModule(aGeomGUI ? app->moduleName(aGeomGUI->moduleName()) : QString(""), myHelpFileName);
+  }
+  else {
+    SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+                          QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                          arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
+                          QObject::tr("BUT_OK"));
+  }
+}
 
 //=================================================================================
 // function : ValueHasChanged()
@@ -185,7 +215,7 @@ void GEOMToolsGUI_TransparencyDlg::ValueHasChanged( int newValue )
   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
   if ( !app )
     return;
-  SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
+  LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
   if ( !aSelMgr )
     return;
   SALOME_ListIO selected;
@@ -199,25 +229,25 @@ void GEOMToolsGUI_TransparencyDlg::ValueHasChanged( int newValue )
        
   SUIT_ViewWindow* window = app->desktop()->activeWindow();
   bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
-  bool isVTK = ( window && window->getViewManager()->getType() == VTKViewer_Viewer::Type() );
+  bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
 
   if ( isVTK ) {
     SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
     if ( !vtkVW )
       return;
-    SVTK_RenderWindowInteractor* rwi = vtkVW->getRWInteractor();
+    SVTK_View* aView = vtkVW->getView();
     if ( myFirstInit ) {       
       myFirstInit = false;
-      float transp = (rwi->GetTransparency(FirstIOS))*10.0;
+      float transp = (aView->GetTransparency(FirstIOS))*10.0;
       mySlider->setValue(int(transp));
       return;
     }
 
     SUIT_OverrideCursor();
     for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
-      rwi->SetTransparency( It.Value(), newValue/10.0 );
+      aView->SetTransparency( It.Value(), newValue/10.0 );
     }
-    rwi->Render();
+    aView->Repaint();
   } // if ( isVTK )
        
   else if ( isOCC ) {
@@ -249,3 +279,20 @@ void GEOMToolsGUI_TransparencyDlg::ValueHasChanged( int newValue )
     ic->UpdateCurrentViewer();
   } // if ( isOCC )
 }
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose  :
+//=================================================================================
+void GEOMToolsGUI_TransparencyDlg::keyPressEvent( QKeyEvent* e )
+{
+  QDialog::keyPressEvent( e );
+  if ( e->isAccepted() )
+    return;
+
+  if ( e->key() == Key_F1 )
+    {
+      e->accept();
+      ClickOnHelp();
+    }
+}