Salome HOME
PAL12607: Static objects in Geometry GUI libraries.
[modules/geom.git] / src / OperationGUI / OperationGUI_ChamferDlg.cxx
index 856d941d1dd77098a483a18c77772ae882fdee55..fc2b12e96538cd6c60b3faea8ae7654c55bb7857 100644 (file)
 //  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
 //
 //
 //
 //  File   : OperationGUI_ChamferDlg.cxx
 //  Author : Damien COQUERET
 //  Module : GEOM
-
 //  $Header$
 
 #include "OperationGUI_ChamferDlg.h"
 #include "DlgRef_SpinBox.h"
-#include "QAD_Desktop.h"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_Session.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "OCCViewer_ViewModel.h"
+
+#include <TColStd_MapOfInteger.hxx>
+
+#include <qlabel.h>
 #include "qpixmap.h"
 #include <list>
 
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-OperationGUI_ChamferDlg::OperationGUI_ChamferDlg( QWidget* parent, SALOME_Selection* Sel )
-: GEOMBase_Skeleton(parent, "ChamferDlg", Sel, false,
-    WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+OperationGUI_ChamferDlg::OperationGUI_ChamferDlg(GeometryGUI* theGeometryGUI, QWidget* parent)
+  : GEOMBase_Skeleton(theGeometryGUI, parent, "ChamferDlg", false,
+                      WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
-
-  mySelection = Sel;
   myConstructorId = -1;
 
-  QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_ALL")));
-  QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE")));
-  QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_FACE")));
-  QPixmap iconSelect(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_ALL")));
+  QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE")));
+  QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_FACE")));
+  QPixmap iconSelect(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
 
   setCaption( tr( "GEOM_CHAMFER_TITLE" ) );
 
@@ -142,8 +148,10 @@ OperationGUI_ChamferDlg::OperationGUI_ChamferDlg( QWidget* parent, SALOME_Select
   for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
     anIter.data()->RangeStepAndValidator( 0.001, 999.999, SpecificStep, 3 );
 
+  setHelpFileName("chamfer.htm");
+
   /* Initialisations */
-  Init( mySelection );
+  Init();
 }
 
 
@@ -160,9 +168,8 @@ OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg()
 // function : Init()
 // purpose  :
 //=================================================================================
-void OperationGUI_ChamferDlg::Init( SALOME_Selection* Sel )
+void OperationGUI_ChamferDlg::Init()
 {
-  mySelection = Sel;
   myConstructorId = -1;
   reset();
   RadioButton1->setChecked( true );
@@ -197,16 +204,14 @@ void OperationGUI_ChamferDlg::Init( SALOME_Selection* Sel )
              this, SLOT( ValueChangedInSpinBox( double ) ) );
 
   // selection
-  connect( mySelection, SIGNAL( currentSelectionChanged() ),
-           this, SLOT( SelectionIntoArgument() ) );
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+          SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
   initName( tr( "GEOM_CHAMFER" ) );
 
   myGrp2->hide();
   myGrp3->hide();
   myGrp1->show();
-
-  this->show();
 }
 
 
@@ -217,13 +222,14 @@ void OperationGUI_ChamferDlg::Init( SALOME_Selection* Sel )
 void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId )
 {
    // Activate next widget
- if ( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC )
- {
+  if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType() 
+      != OCCViewer_Viewer::Type())
+  {
     RadioButton1->setChecked( true );
     return;
- }
-  
-  if ( myConstructorId == constructorId )
 }
+
+  if (myConstructorId == constructorId)
     return;
 
   // Get values from previous widget
@@ -334,11 +340,11 @@ void OperationGUI_ChamferDlg::SelectionIntoArgument()
   // If selection of main object is activated
   if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 )
   {
-    if ( mySelection->IObjectCount() == 1 )
+    if ( IObjectCount() == 1 )
     {
       Standard_Boolean aResult = Standard_False;
       GEOM::GEOM_Object_var anObj =
-        GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
+        GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
 
       if ( aResult && !anObj->_is_nil() )
       {
@@ -356,16 +362,16 @@ void OperationGUI_ChamferDlg::SelectionIntoArgument()
   // If face selection of second tab is activated
   else if ( aCurrFocus == Face1 || aCurrFocus == Face2 )
   {
-    if ( mySelection->IObjectCount() == 1 )
+    if ( IObjectCount() == 1 )
     {
       Standard_Boolean aResult = Standard_False;
       GEOM::GEOM_Object_var anObj =
-        GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
+        GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
 
       if ( aResult && !anObj->_is_nil() )
       {
          TColStd_IndexedMapOfInteger anIndexes;
-         mySelection->GetIndex( mySelection->firstIObject(), anIndexes );
+        ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
 
          if ( anIndexes.Extent() == 1 )
          {
@@ -384,16 +390,16 @@ void OperationGUI_ChamferDlg::SelectionIntoArgument()
   // If face selection of third tab is activated
   else if ( aCurrFocus == Faces )
   {
-    if ( mySelection->IObjectCount() == 1 )
+    if ( IObjectCount() == 1 )
     {
       Standard_Boolean aResult = Standard_False;
       GEOM::GEOM_Object_var anObj =
-        GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
+        GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
 
       if ( aResult && !anObj->_is_nil() )
       {
          TColStd_IndexedMapOfInteger anIndexes;
-         mySelection->GetIndex( mySelection->firstIObject(), anIndexes );
+        ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
 
          if ( anIndexes.Extent() > 0 )
          {
@@ -456,17 +462,6 @@ void OperationGUI_ChamferDlg::SetEditCurrentArgument()
 }
 
 
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose  :
-//=================================================================================
-void OperationGUI_ChamferDlg::DeactivateActiveDialog()
-{
-  // disconnect selection
-  GEOMBase_Skeleton::DeactivateActiveDialog();
-}
-
-
 //=================================================================================
 // function : ActivateThisDialog()
 // purpose  :
@@ -475,8 +470,8 @@ void OperationGUI_ChamferDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
 
-  connect( mySelection, SIGNAL(currentSelectionChanged()),
-           this, SLOT( SelectionIntoArgument() ) );
+  connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+          SIGNAL(currentSelectionChanged()), this, SLOT( SelectionIntoArgument() ) );
 
   activateSelection();
   displayPreview();