Salome HOME
IPAL20717 4.x: information in "Basic Properties" dlg is differently styled.
[modules/geom.git] / src / MeasureGUI / MeasureGUI_CenterMassDlg.cxx
index ed0a1087ef1d82d375629105fe5aec05fc19b07f..58354ef4bb6de9188cf4c50429324207b817350a 100644 (file)
@@ -1,6 +1,6 @@
-//  GEOM GEOMGUI : GUI for Geometry component
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  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
 //  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
 //
+//  GEOM GEOMGUI : GUI for Geometry component
 //  File   : MeasureGUI_CenterMassDlg.cxx
 //  Author : Lucien PIGNOLONI
 //  Module : GEOM
 //  $Header$
-
+//
 #include "MeasureGUI_CenterMassDlg.h"
 #include "MeasureGUI_1Sel3LineEdit_QTD.h"
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
+
+#include "DlgRef_SpinBox.h"
+
 #include "utilities.h"
-#include "QAD_Desktop.h"
+#include "SUIT_Session.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "SalomeApp_Tools.h"
 
 #include <BRep_Tool.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS.hxx>
 #include <gp_Pnt.hxx>
 
+#include <qlabel.h>
+
 //=================================================================================
 // class    : MeasureGUI_CenterMassDlg()
 // purpose  : Constructs a MeasureGUI_CenterMassDlg which is a child of 'parent', with the
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-MeasureGUI_CenterMassDlg::MeasureGUI_CenterMassDlg( QWidget* parent, SALOME_Selection* Sel )
-: GEOMBase_Skeleton( parent, "MeasureGUI_CenterMassDlg", Sel, false,
-    WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+MeasureGUI_CenterMassDlg::MeasureGUI_CenterMassDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
+  : GEOMBase_Skeleton(theGeometryGUI, parent, "MeasureGUI_CenterMassDlg", false,
+                      WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
-  QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr( "ICON_DLG_CENTERMASS" ) ) );
-  QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr( "ICON_SELECT" ) ) );
+  QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CENTERMASS")));
+  QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
 
   setCaption( tr( "GEOM_CMASS_TITLE" ) );
 
   /***************************************************************/
-  
   GroupConstructors->setTitle( tr( "GEOM_CMASS" ) );
   RadioButton1->setPixmap( image0 );
   RadioButton2->close( TRUE );
@@ -75,8 +80,10 @@ MeasureGUI_CenterMassDlg::MeasureGUI_CenterMassDlg( QWidget* parent, SALOME_Sele
   Layout1->addWidget( myGrp, 2, 0 );
   /***************************************************************/
 
+  myHelpFileName = "using_measurement_tools_page.html#center_mass_anchor";
+
   /* Initialisation */
-  Init( Sel );
+  Init();
 }
 
 
@@ -93,10 +100,9 @@ MeasureGUI_CenterMassDlg::~MeasureGUI_CenterMassDlg()
 // function : Init()
 // purpose  :
 //=================================================================================
-void MeasureGUI_CenterMassDlg::Init( SALOME_Selection* Sel )
+void MeasureGUI_CenterMassDlg::Init()
 {
   /* init variables */
-  mySelection = Sel;
   myEditCurrentArgument = myGrp->LineEdit1;
 
    /* signals and slots connections */
@@ -106,7 +112,8 @@ void MeasureGUI_CenterMassDlg::Init( SALOME_Selection* Sel )
   connect( myGrp->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
   connect( myGrp->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
 
-  connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
 
   initName( tr( "GEOM_POINT") );
   globalSelection();
@@ -154,7 +161,7 @@ void MeasureGUI_CenterMassDlg::SelectionIntoArgument()
   erasePreview();
   myObj = GEOM::GEOM_Object::_nil();
 
-  if ( mySelection->IObjectCount() != 1 )
+  if ( IObjectCount() != 1 )
   {
     processObject();
     return;
@@ -162,7 +169,7 @@ void MeasureGUI_CenterMassDlg::SelectionIntoArgument()
 
   Standard_Boolean testResult = Standard_False;
   GEOM::GEOM_Object_var aSelectedObject =
-    GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult );
+    GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
 
   if ( !testResult || aSelectedObject->_is_nil() )
   {
@@ -211,8 +218,8 @@ void MeasureGUI_CenterMassDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
 
-  connect( mySelection, SIGNAL( currentSelectionChanged() ),
-           this,        SLOT  ( SelectionIntoArgument() ) );
+  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
 
   globalSelection();
   displayPreview();
@@ -239,9 +246,9 @@ void MeasureGUI_CenterMassDlg::processObject()
     getParameters( x, y, z );
     
     myGrp->LineEdit1->setText( GEOMBase::GetName( myObj ) );
-    myGrp->LineEdit2->setText( QString( "%1" ).arg( x ) );
-    myGrp->LineEdit3->setText( QString( "%1" ).arg( y ) );
-    myGrp->LineEdit4->setText( QString( "%1" ).arg( z ) );
+    myGrp->LineEdit2->setText( DlgRef_SpinBox::PrintDoubleValue( x ) );
+    myGrp->LineEdit3->setText( DlgRef_SpinBox::PrintDoubleValue( y ) );
+    myGrp->LineEdit4->setText( DlgRef_SpinBox::PrintDoubleValue( z ) );
 
     displayPreview();
   }
@@ -311,7 +318,7 @@ bool MeasureGUI_CenterMassDlg::getParameters( double& theX, double& theY, double
     }
     catch( const SALOME::SALOME_Exception& e )
     {
-      QtCatchCorbaException( e );
+      SalomeApp_Tools::QtCatchCorbaException( e );
       return false;
     }
   }
@@ -332,5 +339,3 @@ bool MeasureGUI_CenterMassDlg::execute( ObjectList& objects )
 
   return true;
 }
-
-