]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/geom.git] / src / PrimitiveGUI / PrimitiveGUI_ConeDlg.cxx
index cd250f83026f50cbb0a8d9fb349de14834200215..e2ad901fe6f69f1bc29e6e6dadfcb8c6a09ae2b9 100644 (file)
@@ -17,7 +17,7 @@
 //  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
 //
 //
 //
 #include "SalomeApp_Application.h"
 #include "LightApp_SelectionMgr.h"
 
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
 #include <qlabel.h>
 
 #include "GEOMImpl_Types.hxx"
@@ -85,7 +92,7 @@ PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg(GeometryGUI* theGeometryGUI, QWidget*
   Layout1->addWidget(GroupDimensions, 2, 0);
   /***************************************************************/
 
-  setHelpFileName( "cone.htm" );
+  setHelpFileName( "create_cone_page.html" );
   
   Init();
 }
@@ -119,12 +126,12 @@ void PrimitiveGUI_ConeDlg::Init()
   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
   
   /* min, max, step and decimals for spin boxes & initial values */
-  GroupPoints->SpinBox_DX->RangeStepAndValidator(0.000, 999.999, step, 3);
-  GroupPoints->SpinBox_DY->RangeStepAndValidator(0.000, 999.999, step, 3);
-  GroupPoints->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3);
-  GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.000, 999.999, step, 3);
-  GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.000, 999.999, step, 3);
-  GroupDimensions->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3);
+  GroupPoints->SpinBox_DX->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+  GroupPoints->SpinBox_DY->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+  GroupPoints->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+  GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+  GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+  GroupDimensions->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
 
   double aRadius1(100.0), aRadius2(0.0), aHeight(300.0); 
   GroupPoints->SpinBox_DX->SetValue(aRadius1);
@@ -159,7 +166,7 @@ void PrimitiveGUI_ConeDlg::Init()
   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double)));
   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DZ, SLOT(SetStep(double)));
   
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+  connect(myGeomGUI->getApp()->selectionMgr(), 
          SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
   
   initName( tr( "GEOM_CONE" ) );
@@ -173,13 +180,15 @@ void PrimitiveGUI_ConeDlg::Init()
 //=================================================================================
 void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId)
 {
-  disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
+  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
   
   switch(constructorId)
     { 
     case 0 :
       {
-       globalSelection( GEOM_POINT );
+       //      globalSelection( GEOM_POINT );
+        globalSelection(); // to break prvious local selection
+       localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
        GroupDimensions->hide();
        resize(0, 0);
        GroupPoints->show();
@@ -189,13 +198,14 @@ void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId)
        GroupPoints->LineEdit2->setText(tr(""));
        myPoint = myDir = GEOM::GEOM_Object::_nil();
        
-       connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+       connect(myGeomGUI->getApp()->selectionMgr(), 
                SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
        break;
       }
     case 1 :
       { 
        GroupPoints->hide();
+        globalSelection(); // close local contexts, if any
        resize( 0, 0 );
        GroupDimensions->show();
 
@@ -248,17 +258,17 @@ void PrimitiveGUI_ConeDlg::ClickOnCancel()
 //=================================================================================
 void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
 {
-  if ( getConstructorId() != 0 )
+  if (getConstructorId() != 0)
     return;
 
-  if(IObjectCount() != 1)
-    {
-      if(myEditCurrentArgument == GroupPoints->LineEdit1)
-       myPoint = GEOM::GEOM_Object::_nil();
-      else if (myEditCurrentArgument == GroupPoints->LineEdit2)
-       myDir = GEOM::GEOM_Object::_nil();
-      return;
-    }
+  if (IObjectCount() != 1)
+  {
+    if (myEditCurrentArgument == GroupPoints->LineEdit1)
+      myPoint = GEOM::GEOM_Object::_nil();
+    else if (myEditCurrentArgument == GroupPoints->LineEdit2)
+      myDir = GEOM::GEOM_Object::_nil();
+    return;
+  }
 
   /* nbSel == 1 */
   Standard_Boolean testResult = Standard_False;
@@ -267,17 +277,56 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
   if(!testResult || CORBA::is_nil( aSelectedObject ))
     return;
 
+  TopoDS_Shape aShape;
+  QString aName = GEOMBase::GetName( aSelectedObject );
+
+  if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
+  {
+    TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
+    if (myEditCurrentArgument == GroupPoints->LineEdit2)
+      aNeedType = TopAbs_EDGE;
+
+    LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+    TColStd_IndexedMapOfInteger aMap;
+    aSelMgr->GetIndexes( firstIObject(), aMap );
+    if (aMap.Extent() == 1)
+    {
+      int anIndex = aMap(1);
+      if (aNeedType == TopAbs_EDGE)
+        aName.append(":edge_" + QString::number(anIndex));
+      else
+        aName.append(":vertex_" + QString::number(anIndex));
+
+      //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
+       GEOM::GEOM_IShapesOperations_var aShapesOp =
+         getGeomEngine()->GetIShapesOperations(getStudyId());
+       aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+      }
+      else
+       aSelectedObject = aFindedObject; // get Object from study       
+    }
+    else
+    {
+      if (aShape.ShapeType() != aNeedType) {
+        aSelectedObject = GEOM::GEOM_Object::_nil();
+        aName = "";
+      }
+    }
+  }
+
+  myEditCurrentArgument->setText(aName);
+
   if (myEditCurrentArgument == GroupPoints->LineEdit1)
     myPoint = aSelectedObject;
   else if (myEditCurrentArgument == GroupPoints->LineEdit2)
     myDir = aSelectedObject;
-  
-  
-  myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
+
   displayPreview();
 }
 
-
 //=================================================================================
 // function : SetEditCurrentArgument()
 // purpose  :
@@ -288,11 +337,13 @@ void PrimitiveGUI_ConeDlg::SetEditCurrentArgument()
   
   if(send == GroupPoints->PushButton1) {
     myEditCurrentArgument = GroupPoints->LineEdit1;
-    globalSelection( GEOM_POINT );
+    globalSelection( GEOM_POINT ); // to break prvious local selection
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
   }
   else if(send == GroupPoints->PushButton2) {
     myEditCurrentArgument = GroupPoints->LineEdit2;
-    globalSelection( GEOM_LINE );
+    globalSelection( GEOM_LINE );// to break prvious local selection
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
   }
   
   myEditCurrentArgument->setFocus();
@@ -315,7 +366,6 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed()
     }
 }
 
-
 //=================================================================================
 // function : ActivateThisDialog()
 // purpose  :
@@ -323,12 +373,11 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed()
 void PrimitiveGUI_ConeDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
-  
-  ConstructorsClicked( getConstructorId() );
-}
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
 
+  ConstructorsClicked(getConstructorId());
+}
 
 //=================================================================================
 // function : DeactivateActiveDialog()
@@ -473,3 +522,23 @@ double PrimitiveGUI_ConeDlg::getHeight() const
     return GroupDimensions->SpinBox_DZ->GetValue();
   return 0;
 }
+
+//=================================================================================
+// function : addSubshapeToStudy
+// purpose  : virtual method to add new SubObjects if local selection
+//=================================================================================
+void PrimitiveGUI_ConeDlg::addSubshapesToStudy()
+{
+  QMap<QString, GEOM::GEOM_Object_var> objMap;
+
+switch (getConstructorId())
+  {
+  case 0:
+    objMap[GroupPoints->LineEdit1->text()] = myPoint;
+    objMap[GroupPoints->LineEdit2->text()] = myDir;
+    break;
+  case 1:
+    return;
+  }
+ addSubshapesToFather( objMap );
+}