Salome HOME
Code refactoring
[modules/geom.git] / src / PrimitiveGUI / PrimitiveGUI_DiskDlg.cxx
index 9344092c872b93cb65eea459d0f955270ae068d2..397188996cce99568bebcfd8097962a0c2bc86b4 100755 (executable)
@@ -1,7 +1,4 @@
-//  Copyright (C) 2007-2008  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) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU Lesser General Public
@@ -19,6 +16,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // GEOM GEOMGUI : GUI for Geometry component
 // File   : PrimitiveGUI_DiskDlg.cxx
 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
@@ -51,8 +49,7 @@
 //=================================================================================
 PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
                                             bool modal, Qt::WindowFlags fl)
-  : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
-    myInitial(true)
+  : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
 {
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_DISK_PNT_VEC_R")));
@@ -132,8 +129,8 @@ void PrimitiveGUI_DiskDlg::Init()
   double aStep = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
 
   // min, max, step and decimals for spin boxes & initial values
-  initSpinBox(GroupPntVecR->SpinBox_DX, 0.00001, COORD_MAX, aStep, 5); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox(GroupDimensions->SpinBox_DX, 0.00001, COORD_MAX, aStep, 5); // VSR: TODO: DBL_DIGITS_DISPLAY
+  initSpinBox(GroupPntVecR->SpinBox_DX, 0.00001, COORD_MAX, aStep, "length_precision" );
+  initSpinBox(GroupDimensions->SpinBox_DX, 0.00001, COORD_MAX, aStep, "length_precision" );
 
   // init variables
   myEditCurrentArgument = GroupPntVecR->LineEdit1;
@@ -255,20 +252,9 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked (int constructorId)
   qApp->processEvents();
   updateGeometry();
   resize(minimumSizeHint());
+  SelectionIntoArgument();
 
-  if (myInitial) {
-    myInitial = false;
-    if (constructorId == 1 || constructorId == 2) {
-      // on dialog initialization we init the first field with a selected object (if any)
-      SelectionIntoArgument();
-    }
-    else {
-      displayPreview();
-    }
-  }
-  else {
-    displayPreview();
-  }
+  displayPreview();
 }
 
 //=================================================================================
@@ -323,10 +309,9 @@ void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
 
   // nbSel == 1
   Handle(SALOME_InteractiveObject) anIO = aSelList.First();
-  Standard_Boolean testResult = Standard_False;
-  GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, testResult);
+  GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO );
 
-  if (!testResult || CORBA::is_nil(aSelectedObject))
+  if ( CORBA::is_nil(aSelectedObject) )
     return;
 
   QString aName = GEOMBase::GetName(aSelectedObject);
@@ -351,7 +336,7 @@ void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
       //Find SubShape Object in Father
       GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
 
-      if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
+      if (aFindedObject->_is_nil()) { // Object not found in study
         GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
         aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
       }
@@ -496,7 +481,7 @@ void PrimitiveGUI_DiskDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
-          this, SLOT( SelectionIntoArgument() ) );
+           this, SLOT( SelectionIntoArgument() ) );
 
   ConstructorsClicked( getConstructorId() );
 }
@@ -572,30 +557,29 @@ bool PrimitiveGUI_DiskDlg::execute (ObjectList& objects)
 
   GEOM::GEOM_Object_var anObj;
 
+  GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
+
   switch (getConstructorId()) {
   case 0:
-    anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
-      MakeDiskR(getRadius(), myOrientationType);
+    anObj = anOper->MakeDiskR(getRadius(), myOrientationType);
     if (!anObj->_is_nil() && !IsPreview())
     {
       aParameters << GroupDimensions->SpinBox_DX->text();
-      anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
+      anObj->SetParameters(aParameters.join(":").toLatin1().constData());
     }
     res = true;
     break;
   case 1:
-    anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
-      MakeDiskPntVecR(myPoint, myDir, getRadius());
+    anObj = anOper->MakeDiskPntVecR(myPoint, myDir, getRadius());
     if (!anObj->_is_nil() && !IsPreview())
     {
       aParameters << GroupPntVecR->SpinBox_DX->text();
-      anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
+      anObj->SetParameters(aParameters.join(":").toLatin1().constData());
     }
     res = true;
     break;
   case 2:
-    anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
-      MakeDiskThreePnt(myPoint1, myPoint2, myPoint3);
+    anObj = anOper->MakeDiskThreePnt(myPoint1, myPoint2, myPoint3);
     res = true;
     break;
   }