Salome HOME
NPAL 16768 Select Vertex from Vertex on Shape
[modules/geom.git] / src / PrimitiveGUI / PrimitiveGUI_SphereDlg.cxx
index 3c4e8adeb89af10c8e7d7f1a44872e63b0ff659e..b1b56fea6177724d28440a3bedf927381df83178 100644 (file)
 #include "SalomeApp_Application.h"
 #include "LightApp_SelectionMgr.h"
 
+#include <TopoDS_Shape.hxx>
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
 #include <qlabel.h>
 
 #include "GEOMImpl_Types.hxx"
@@ -112,8 +118,8 @@ void PrimitiveGUI_SphereDlg::Init()
   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
 
   /* min, max, step and decimals for spin boxes */
-  GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3);
-  GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3);
+  GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+  GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY);
   GroupPoints->SpinBox_DX->SetValue(100.0);
   GroupDimensions->SpinBox_DX->SetValue(100.0);
   
@@ -151,7 +157,7 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId)
     {
     case 0:
       {
-       globalSelection( GEOM_POINT );
+       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
        GroupDimensions->hide();
        resize(0, 0);
        GroupPoints->show();
@@ -237,10 +243,28 @@ void PrimitiveGUI_SphereDlg::SelectionIntoArgument()
   
   if (!testResult || CORBA::is_nil( aSelectedObject ))
     return;
-    
+
+  myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
+  TopoDS_Shape aShape;
+  if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() )
+    {
+      LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+      TColStd_IndexedMapOfInteger aMap;
+      aSelMgr->GetIndexes( firstIObject(), aMap );
+      if ( aMap.Extent() == 1 )
+       {
+         GEOM::GEOM_IShapesOperations_var aShapesOp =
+           getGeomEngine()->GetIShapesOperations( getStudyId() );
+         int anIndex = aMap( 1 );
+         TopTools_IndexedMapOfShape aShapes;
+         TopExp::MapShapes( aShape, aShapes );
+         aShape = aShapes.FindKey( anIndex );
+         aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+         aSelMgr->clearSelected();
+       }
+    }
   myPoint = aSelectedObject;
-  myEditCurrentArgument->setText( GEOMBase::GetName( myPoint ) );
-  
   displayPreview();
 }
 
@@ -271,7 +295,7 @@ void PrimitiveGUI_SphereDlg::SetEditCurrentArgument()
   if(send == GroupPoints->PushButton1) {
     GroupPoints->LineEdit1->setFocus();
     myEditCurrentArgument = GroupPoints->LineEdit1;
-    globalSelection( GEOM_POINT );
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
     SelectionIntoArgument();
   }
 }