Salome HOME
Win32 compliation.
[modules/geom.git] / src / RepairGUI / RepairGUI_DivideEdgeDlg.cxx
index 2f3d7a58235d6d2f2fbcc507bc84d71d1a75df57..61fd7ed5b20166b2f6bcb01bd378f1d8cbeb11bf 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  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) 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
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // GEOM GEOMGUI : GUI for Geometry component
 // File   : RepairGUI_DivideEdgeDlg.cxx
 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
@@ -28,7 +29,7 @@
 #include <DlgRef.h>
 #include <GeometryGUI.h>
 #include <GEOMBase.h>
-#include <QtxDoubleSpinBox.h>
+#include <SalomeApp_DoubleSpinBox.h>
 
 #include <SalomeApp_Application.h>
 #include <LightApp_SelectionMgr.h>
@@ -86,7 +87,8 @@ RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg( GeometryGUI* theGeometryGUI, Q
   myIsParameterGr->addButton( rb2, 1 );
   rb1->setChecked( true );
 
-  myValEdt = new SalomeApp_DoubleSpinBox( 0., 1., 0.1, 3, 32, GroupPoints->Box );
+  myValEdt = new SalomeApp_DoubleSpinBox( GroupPoints->Box );
+  initSpinBox( myValEdt, 0., 1., 0.1, "parametric_precision" );
   myValEdt->setValue( 0.5 );
   QLabel* aLbl1 = new QLabel( tr( "GEOM_VALUE" ), GroupPoints->Box );
 
@@ -141,10 +143,11 @@ void RepairGUI_DivideEdgeDlg::Init()
   connect( GroupPoints->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
 
   connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
-          SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
   initName( tr( "DEVIDE_EDGE_NEW_OBJECT_NAME" ) );
   resize(100,100);
+  SelectionIntoArgument();
 }
 
 //=================================================================================
@@ -162,6 +165,7 @@ void RepairGUI_DivideEdgeDlg::ValueChangedInSpinBox()
 //=================================================================================
 void RepairGUI_DivideEdgeDlg::displayPreview()
 {
+  erasePreview();
   if ( myObject->_is_nil() )
     return;
 
@@ -195,6 +199,7 @@ void RepairGUI_DivideEdgeDlg::displayPreview()
 //=================================================================================
 void RepairGUI_DivideEdgeDlg::ClickOnOk()
 {
+  setIsApplyAndClose( true );
   if ( ClickOnApply() )
     ClickOnCancel();
 }
@@ -239,9 +244,8 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument()
 
   if ( aSelList.Extent() == 1 ) {
     Handle(SALOME_InteractiveObject) anIO = aSelList.First();
-    Standard_Boolean aRes;
-    GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
-    if ( !CORBA::is_nil( aSelectedObj ) && aRes )
+    GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO );
+    if ( !CORBA::is_nil( aSelectedObj ) )
     {
       TopoDS_Shape aShape;
       QString aName = GEOMBase::GetName( aSelectedObj );
@@ -257,11 +261,11 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument()
             (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
           anApp->selectionMgr()->GetIndexes( anIO, aMap );
 
-          if ( !aMap.IsEmpty() ) // subshape selection
+          if ( !aMap.IsEmpty() ) // sub-shape selection
           {
             myIndex = aMap( 1 );
             myObject = aSelectedObj;
-           myEditCurrentArgument->setText( aName += QString( ":edge_%1" ).arg( myIndex ) );
+            myEditCurrentArgument->setText( aName += QString( ":edge_%1" ).arg( myIndex ) );
           }
           else if ( aType == TopAbs_EDGE ) // single shape selection
           {
@@ -269,7 +273,7 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument()
             myObject = aSelectedObj;
             myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) );
           }
-          else // face, shell, solid or compound was selected, and NOT its subshape.
+          else // face, shell, solid or compound was selected, and NOT its sub-shape.
           {
             myIndex = -1;
             myObject = GEOM::GEOM_Object::_nil();
@@ -317,7 +321,7 @@ void RepairGUI_DivideEdgeDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
   connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
-          SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
 //  myObject = GEOM::GEOM_Object::_nil();
   myIndex = -1;
@@ -362,8 +366,8 @@ bool RepairGUI_DivideEdgeDlg::isValid( QString& msg )
 //=================================================================================
 bool RepairGUI_DivideEdgeDlg::execute( ObjectList& objects )
 {
-  GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->DivideEdge
-    ( myObject, myIndex, myValEdt->value(), getIsByParameter() );
+  GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() );
+  GEOM::GEOM_Object_var anObj = anOper->DivideEdge( myObject, myIndex, myValEdt->value(), getIsByParameter() );
   bool aResult = !anObj->_is_nil();
   if ( aResult )
   {
@@ -373,7 +377,7 @@ bool RepairGUI_DivideEdgeDlg::execute( ObjectList& objects )
       aParameters << "";
       aParameters << myValEdt->text();
       aParameters << "";
-      anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
+      anObj->SetParameters(aParameters.join(":").toLatin1().constData());
     }
     objects.push_back( anObj._retn() );
   }