From c5830a8430fc7ae7f41fd90d649fd1e361b7664c Mon Sep 17 00:00:00 2001 From: dmv Date: Wed, 26 Dec 2007 12:52:34 +0000 Subject: [PATCH] NPAL 18378 --- src/BasicGUI/BasicGUI_ArcDlg.cxx | 38 +++++++++- src/BasicGUI/BasicGUI_ArcDlg.h | 1 + src/BasicGUI/BasicGUI_CircleDlg.cxx | 45 ++++++++++-- src/BasicGUI/BasicGUI_CircleDlg.h | 2 +- src/BasicGUI/BasicGUI_EllipseDlg.cxx | 27 ++++++- src/BasicGUI/BasicGUI_EllipseDlg.h | 2 +- src/BasicGUI/BasicGUI_LineDlg.cxx | 36 +++++++-- src/BasicGUI/BasicGUI_LineDlg.h | 1 + src/BasicGUI/BasicGUI_MarkerDlg.cxx | 8 +- src/BasicGUI/BasicGUI_PlaneDlg.cxx | 40 +++++++++- src/BasicGUI/BasicGUI_PlaneDlg.h | 2 +- src/BasicGUI/BasicGUI_PointDlg.cxx | 40 +++++++++- src/BasicGUI/BasicGUI_PointDlg.h | 2 +- src/BasicGUI/BasicGUI_VectorDlg.cxx | 35 ++++++++- src/BasicGUI/BasicGUI_VectorDlg.h | 1 + src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx | 19 +++-- src/GEOMBase/GEOMBase_Helper.cxx | 73 ++++++++++++++++++- src/GEOMBase/GEOMBase_Helper.h | 7 ++ src/GenerationGUI/GenerationGUI_PipeDlg.cxx | 30 ++++++-- src/GenerationGUI/GenerationGUI_PipeDlg.h | 1 + src/GenerationGUI/GenerationGUI_PrismDlg.cxx | 49 +++++++++++-- src/GenerationGUI/GenerationGUI_PrismDlg.h | 1 + src/GenerationGUI/GenerationGUI_RevolDlg.cxx | 32 +++++++- src/GenerationGUI/GenerationGUI_RevolDlg.h | 1 + src/OperationGUI/OperationGUI_ChamferDlg.cxx | 2 +- src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx | 30 +++++++- src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h | 2 +- src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx | 37 ++++++++-- src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h | 2 +- src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx | 36 +++++++-- src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h | 2 +- src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx | 35 +++++++-- src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h | 2 +- src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx | 37 ++++++++-- src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h | 1 + .../TransformationGUI_MirrorDlg.cxx | 42 +++++++++-- .../TransformationGUI_MirrorDlg.h | 2 +- .../TransformationGUI_MultiRotationDlg.cxx | 51 ++++++++++--- .../TransformationGUI_MultiRotationDlg.h | 2 +- .../TransformationGUI_MultiTranslationDlg.cxx | 45 ++++++++++-- .../TransformationGUI_MultiTranslationDlg.h | 2 +- .../TransformationGUI_RotationDlg.cxx | 39 +++++++++- .../TransformationGUI_RotationDlg.h | 2 +- .../TransformationGUI_ScaleDlg.cxx | 32 +++++++- .../TransformationGUI_ScaleDlg.h | 2 +- .../TransformationGUI_TranslationDlg.cxx | 40 +++++++++- .../TransformationGUI_TranslationDlg.h | 1 + 47 files changed, 798 insertions(+), 141 deletions(-) diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index b894242d9..46e1434e4 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -299,12 +299,18 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() aSelMgr->GetIndexes(firstIObject(), aMap); if (aMap.Extent() == 1) // Local Selection { - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); int anIndex = aMap(1); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); // ??? - aName += QString(":vertex_%1").arg(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 // Global Selection { @@ -486,3 +492,27 @@ void BasicGUI_ArcDlg::ReverseSense(int sense) { displayPreview(); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_ArcDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[Group3Pnts->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts->LineEdit3->text()] = myPoint3; + break; + case 1: + objMap[Group3Pnts2->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts2->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts2->LineEdit3->text()] = myPoint3; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_ArcDlg.h b/src/BasicGUI/BasicGUI_ArcDlg.h index d2fa847b7..485ce7931 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.h +++ b/src/BasicGUI/BasicGUI_ArcDlg.h @@ -56,6 +56,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init(); diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index 9fe4edf76..6245a874b 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -328,18 +328,21 @@ void BasicGUI_CircleDlg::SelectionIntoArgument() aSelMgr->GetIndexes(anIO, aMap); if (aMap.Extent() == 1) // Local Selection { - 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(); // ??? - if (aNeedType == TopAbs_EDGE) aName += QString(":edge_%1").arg(anIndex); else aName += QString(":vertex_%1").arg(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 // Global Selection { @@ -555,3 +558,31 @@ void BasicGUI_CircleDlg::closeEvent (QCloseEvent* e) { GEOMBase_Skeleton::closeEvent(e); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_CircleDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPntVecR->LineEdit1->text()] = myPoint; + objMap[GroupPntVecR->LineEdit2->text()] = myDir; + break; + case 1: + objMap[Group3Pnts->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts->LineEdit3->text()] = myPoint3; + break; + case 2: + objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4; + objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5; + objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_CircleDlg.h b/src/BasicGUI/BasicGUI_CircleDlg.h index c97ab51ed..698bec7f1 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.h +++ b/src/BasicGUI/BasicGUI_CircleDlg.h @@ -60,8 +60,8 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - virtual void closeEvent( QCloseEvent* e ); + virtual void addSubshapesToStudy(); private: void Init(); diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.cxx b/src/BasicGUI/BasicGUI_EllipseDlg.cxx index dcb7efd5c..75909f4f6 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.cxx +++ b/src/BasicGUI/BasicGUI_EllipseDlg.cxx @@ -231,15 +231,21 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument() aSelMgr->GetIndexes(anIO, aMap); if (aMap.Extent() == 1) { - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); int anIndex = aMap(1); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); // ??? - if (aNeedType == TopAbs_EDGE) aName += QString(":edge_%1").arg(anIndex); else aName += QString(":vertex_%1").arg(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 // Global Selection { @@ -398,3 +404,16 @@ void BasicGUI_EllipseDlg::closeEvent( QCloseEvent* e ) GEOMBase_Skeleton::closeEvent( e ); } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_EllipseDlg::addSubshapesToStudy() +{ + QMap objMap; + + objMap[GroupPoints->LineEdit1->text()] = myPoint; + objMap[GroupPoints->LineEdit2->text()] = myDir; + + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.h b/src/BasicGUI/BasicGUI_EllipseDlg.h index f3c5db3ac..31fa1ad1e 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.h +++ b/src/BasicGUI/BasicGUI_EllipseDlg.h @@ -58,8 +58,8 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - virtual void closeEvent( QCloseEvent* e ); + virtual void addSubshapesToStudy(); private : void Init(); diff --git a/src/BasicGUI/BasicGUI_LineDlg.cxx b/src/BasicGUI/BasicGUI_LineDlg.cxx index 6e3a7c4ef..17451f049 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.cxx +++ b/src/BasicGUI/BasicGUI_LineDlg.cxx @@ -172,6 +172,7 @@ void BasicGUI_LineDlg::ClickOnCancel() //================================================================================= bool BasicGUI_LineDlg::ClickOnApply() { + if ( !onAccept() ) return false; @@ -244,7 +245,7 @@ void BasicGUI_LineDlg::SelectionIntoArgument() if (!CORBA::is_nil(aSelectedObject) && aRes) { QString aName = GEOMBase::GetName(aSelectedObject); - + TopoDS_Shape aShape; if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { @@ -258,15 +259,21 @@ void BasicGUI_LineDlg::SelectionIntoArgument() aSelMgr->GetIndexes(firstIObject(), aMap); if (aMap.Extent() == 1) // Local Selection { - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - int anIndex = aMap( 1 ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); // ??? - + int anIndex = aMap( 1 ); if (aNeedType == TopAbs_FACE) aName += QString(":face_%1").arg(anIndex); else aName += QString(":vertex_%1").arg(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 // Global Selection { @@ -410,3 +417,20 @@ void BasicGUI_LineDlg::closeEvent( QCloseEvent* e ) { GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_LineDlg::addSubshapesToStudy() +{ + if (getConstructorId() != 0) + return; + + QMap objMap; + + objMap[GroupPoints->LineEdit1->text()] = myPoint1; + objMap[GroupPoints->LineEdit2->text()] = myPoint2; + + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_LineDlg.h b/src/BasicGUI/BasicGUI_LineDlg.h index ef0f2bd37..ed6484d68 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.h +++ b/src/BasicGUI/BasicGUI_LineDlg.h @@ -57,6 +57,7 @@ protected: virtual bool execute( ObjectList& objects ); virtual void closeEvent( QCloseEvent* e ); + virtual void addSubshapesToStudy(); private : void Init(); diff --git a/src/BasicGUI/BasicGUI_MarkerDlg.cxx b/src/BasicGUI/BasicGUI_MarkerDlg.cxx index 88ade8405..c56e5d3fe 100644 --- a/src/BasicGUI/BasicGUI_MarkerDlg.cxx +++ b/src/BasicGUI/BasicGUI_MarkerDlg.cxx @@ -451,14 +451,14 @@ void BasicGUI_MarkerDlg::onSelectionDone() if (!aMap.IsEmpty()) { int anIndex = aMap(1); - TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes(aShape, aShapes); - aShape = aShapes.FindKey(anIndex); - if (aNeedType == TopAbs_EDGE) aName += QString("_edge_%1").arg(anIndex); else aName += QString("_vertex_%1").arg(anIndex); + + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes(aShape, aShapes); + aShape = aShapes.FindKey(anIndex); } if (myEditCurrentArgument == Group2->LineEdit1) { diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx index 4216a1239..5b970481e 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -335,17 +335,24 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() aSelMgr->GetIndexes(firstIObject(), aMap); if (aMap.Extent() == 1) // Local Selection { - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - int anIndex = aMap(1); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); // ??? + int anIndex = aMap(1); if (aNeedType == TopAbs_EDGE) aName += QString(":edge_%1").arg(anIndex); else if (aNeedType == TopAbs_FACE) aName += QString(":face_%1").arg(anIndex); else aName += QString(":vertex_%1").arg(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 // Global Selection { @@ -563,3 +570,28 @@ void BasicGUI_PlaneDlg::closeEvent( QCloseEvent* e ) GEOMBase_Skeleton::closeEvent( e ); } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_PlaneDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPntDir->LineEdit1->text()] = myPoint; + objMap[GroupPntDir->LineEdit2->text()] = myDir; + break; + case 1: + objMap[Group3Pnts->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts->LineEdit3->text()] = myPoint3; + break; + case 2: + objMap[GroupFace->LineEdit1->text()] = myFace; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.h b/src/BasicGUI/BasicGUI_PlaneDlg.h index c03f934c0..776ecfb53 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.h +++ b/src/BasicGUI/BasicGUI_PlaneDlg.h @@ -57,7 +57,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index 85cf23b03..0ad39e8b0 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -386,15 +386,21 @@ void BasicGUI_PointDlg::SelectionIntoArgument() aSelMgr->GetIndexes(firstIObject(), aMap); if (aMap.Extent() == 1) // Local Selection { - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); int anIndex = aMap(1); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); // ??? - if (aNeedType == TopAbs_EDGE) aName += QString(":edge_%1").arg(anIndex); else aName += QString(":vertex_%1").arg(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 // Global Selection { @@ -669,3 +675,29 @@ void BasicGUI_PointDlg::closeEvent( QCloseEvent* e ) { GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_PointDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + break; + case 1: + objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint; + break; + case 2: + objMap[GroupOnCurve->LineEdit1->text()] = myEdge; + break; + case 3: + objMap[GroupLineIntersection->LineEdit1->text()] = myLine1; + objMap[GroupLineIntersection->LineEdit2->text()] = myLine2; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_PointDlg.h b/src/BasicGUI/BasicGUI_PointDlg.h index cb4b02d60..e82fca247 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.h +++ b/src/BasicGUI/BasicGUI_PointDlg.h @@ -64,7 +64,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/BasicGUI/BasicGUI_VectorDlg.cxx b/src/BasicGUI/BasicGUI_VectorDlg.cxx index ac2afbfa5..46d0a0033 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.cxx +++ b/src/BasicGUI/BasicGUI_VectorDlg.cxx @@ -287,12 +287,19 @@ void BasicGUI_VectorDlg::SelectionIntoArgument() aSelMgr->GetIndexes(firstIObject(), aMap); if (aMap.Extent() == 1) // Local Selection { - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - int anIndex = aMap(1); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); // ??? + int anIndex = aMap(1); aName += QString(":vertex_%1").arg(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 // Global Selection { @@ -447,3 +454,23 @@ bool BasicGUI_VectorDlg::execute( ObjectList& objects ) return res; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_VectorDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint1; + objMap[GroupPoints->LineEdit2->text()] = myPoint2; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_VectorDlg.h b/src/BasicGUI/BasicGUI_VectorDlg.h index 1656038f8..8915e813a 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.h +++ b/src/BasicGUI/BasicGUI_VectorDlg.h @@ -58,6 +58,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private : void Init(); diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx index 6ff682163..e672b56af 100644 --- a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx @@ -223,7 +223,7 @@ void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) myEditCurrentArgument = Group2->LineEdit1; Group2->LineEdit1->setText(""); - Group2->LineEdit2->setText(""); + Group2->LineEdit2->setText(""); myVectX = GEOM::GEOM_Object::_nil(); myVectZ = GEOM::GEOM_Object::_nil(); @@ -328,17 +328,15 @@ void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() 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 ); aName = aName + ":edge_" + QString::number( anIndex ); - if(myEditCurrentArgument == Group2->LineEdit1) - myVectX = aShapesOp->GetSubShape(aSelectedObject, anIndex); - else - myVectZ = aShapesOp->GetSubShape(aSelectedObject, anIndex); + + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + if(myEditCurrentArgument == Group2->LineEdit1) + myVectX = aShapesOp->GetSubShape(aSelectedObject, anIndex); + else + myVectZ = aShapesOp->GetSubShape(aSelectedObject, anIndex); } else { if (myEditCurrentArgument == Group2->LineEdit1) @@ -581,3 +579,4 @@ bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview ) return true; } + diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 7fdc7a14c..95ff8f0ec 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -770,6 +770,7 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction ) showError(); } else { + addSubshapesToStudy(); // add Subshapes if local selection const int nbObjs = objects.size(); int aNumber = 1; for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) { @@ -1025,8 +1026,74 @@ bool GEOMBase_Helper::selectObjects( ObjectList& objects ) return true; } - - +//================================================================ +// Function : findObjectInFather +// Purpose : It should return an object if its founded in study or +// return Null object if the object is not founded +//================================================================ +GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather( GEOM::GEOM_Object_ptr theFather, const char* theName) +{ + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + _PTR(Study) aDStudy = appStudy->studyDS(); + string IOR = GEOMBase::GetIORFromObject( theFather ); + _PTR(SObject) SObj ( aDStudy->FindObjectIOR( IOR ) ); + + bool inStudy = false; + GEOM::GEOM_Object_var aReturnObject; + for (_PTR(ChildIterator) iit (aDStudy->NewChildIterator( SObj )); iit->More(); iit->Next()) { + _PTR(SObject) child (iit->Value()); + QString aChildName = child->GetName(); + if (aChildName == theName) { + inStudy = true; + CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(iit->Value()); + aReturnObject = GEOM::GEOM_Object::_narrow( corbaObj ); + } + } + if (!inStudy) + return GEOM::GEOM_Object::_nil(); + else + return aReturnObject._retn(); +} +//================================================================ +// Function : addSubshapesToStudy +// Purpose : Virtual method to add subshapes if needs +//================================================================ +void GEOMBase_Helper::addSubshapesToStudy() +{ + //Impemented in Dialogs, called from Accept method +} + +//================================================================ +// Function : addSubshapesToFather +// Purpose : Method to add Father Subshapes to Study if it`s not exist +//================================================================ +void GEOMBase_Helper::addSubshapesToFather( QMap& theMap ) +{ + //GetStudyDS + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + _PTR(Study) aDStudy = appStudy->studyDS(); + + GEOM::GEOM_IGroupOperations_var anOp = getGeomEngine()->GetIGroupOperations( getStudyId() ); + + for( QMap::Iterator it = theMap.begin(); it != theMap.end(); it++ ) + { + if ( !anOp->_is_nil() ) { + GEOM::GEOM_Object_var aFatherObj = anOp->GetMainShape( it.data() ); + GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aFatherObj, it.key() ); + + //Add Object to study if its not exist + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) + GeometryGUI::GetGeomGen()->AddInStudy(GeometryGUI::ClientStudyToStudy(aDStudy), + it.data(), it.key(), aFatherObj ); + } + else { + //cout << " anOperations is NULL! " << endl; + } + } +} - \ No newline at end of file diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index f55088e97..211a0070f 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -36,6 +36,7 @@ #include CORBA_CLIENT_HEADER(GEOM_Gen) #include +#include #include //#if defined WNT @@ -182,6 +183,12 @@ protected: // as a top-level object. virtual const char* getNewObjectName() const; + virtual void addSubshapesToStudy(); + + GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather( GEOM::GEOM_Object_ptr theFather, const char* theName ); + //This Metod to find SubObject in theFather Object by Name (theName) + + void addSubshapesToFather( QMap& theMap ); void SetIsPreview(const bool thePreview) {isPreview = thePreview;} bool IsPreview() {return isPreview;} diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx index 356be1f82..4b315e519 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx @@ -218,13 +218,22 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); - myPath = aShapesOp->GetSubShape(aSelectedObject, anIndex); aName.append( ":edge_" + QString::number( anIndex ) ); - myOkPath = true; - aSelMgr->clearSelected(); + + //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() ); + myPath = aShapesOp->GetSubShape(aSelectedObject, anIndex); + myOkPath = true; + } + else { // get Object from study + myPath = aFindedObject; + myOkPath = true; + } } else { myOkPath = true; @@ -343,5 +352,16 @@ bool GenerationGUI_PipeDlg::execute( ObjectList& objects ) return true; } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void GenerationGUI_PipeDlg::addSubshapesToStudy() +{ + QMap objMap; + + objMap[GroupPoints->LineEdit2->text()] = myPath; + addSubshapesToFather( objMap ); +} diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.h b/src/GenerationGUI/GenerationGUI_PipeDlg.h index 6921b3760..7272ddae4 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.h +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.h @@ -49,6 +49,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& msg ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init(); diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx index 82479fa79..0a8419a99 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx @@ -299,12 +299,19 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); aName.append( ":edge_" + QString::number( anIndex ) ); - aSelMgr->clearSelected(); + + //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() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2) { @@ -359,11 +366,18 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if (aMap.Extent() == 1) { - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); int anIndex = aMap(1); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); aName.append(":vertex_" + QString::number(anIndex)); - aSelMgr->clearSelected(); + + //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; } else { @@ -585,3 +599,24 @@ void GenerationGUI_PrismDlg::onBothway2() myBothway2 = !anOldValue; displayPreview(); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void GenerationGUI_PrismDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myVec; + break; + case 1: + objMap[GroupPoints2->LineEdit2->text()] = myPoint1; + objMap[GroupPoints2->LineEdit3->text()] = myPoint2; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.h b/src/GenerationGUI/GenerationGUI_PrismDlg.h index a8b81837a..81ddfb0bd 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.h +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.h @@ -50,6 +50,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& msg ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init(); diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx index 604423f56..716ab67f6 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx @@ -248,12 +248,23 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); + int anIndex = aMap( 1 ); aName.append( ":edge_" + QString::number( anIndex ) ); - myAxis = aShapesOp->GetSubShape(aSelectedObject, anIndex); - myOkAxis = true; + + //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() ); + myAxis = aShapesOp->GetSubShape(aSelectedObject, anIndex); + myOkAxis = true; + } + else { + myAxis = aFindedObject; + myOkAxis = true; + } } else { myOkAxis = true; @@ -417,3 +428,16 @@ void GenerationGUI_RevolDlg::onBothway() GroupPoints->CheckButton2->setEnabled(!myBothway); displayPreview(); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void GenerationGUI_RevolDlg::addSubshapesToStudy() +{ + QMap objMap; + + objMap[GroupPoints->LineEdit2->text()] = myAxis; + + addSubshapesToFather( objMap ); +} diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.h b/src/GenerationGUI/GenerationGUI_RevolDlg.h index 0c7d8e5bb..a8a49d56c 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.h +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.h @@ -51,6 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& msg ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private : void Init(); diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.cxx b/src/OperationGUI/OperationGUI_ChamferDlg.cxx index 69f2bdcaf..3c9a62fb7 100644 --- a/src/OperationGUI/OperationGUI_ChamferDlg.cxx +++ b/src/OperationGUI/OperationGUI_ChamferDlg.cxx @@ -725,7 +725,7 @@ void OperationGUI_ChamferDlg::activateSelection() myEditCurrentArgument == mySelName[ Faces ] ) ) localSelection( myShape, TopAbs_FACE ); else if (!myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ] ) - localSelection( myShape, TopAbs_EDGE ); + localSelection( myShape, TopAbs_EDGE ); else { TColStd_MapOfInteger aMap; diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx index 7e45cc653..9adcb3b9c 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx @@ -260,12 +260,19 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument() aSelMgr->GetIndexes(firstIObject(), aMap); if (aMap.Extent() == 1) // Local Selection { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); aName.append( ":vertex_" + QString::number( anIndex ) ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); // ??? + + //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 // Global Selection { @@ -424,3 +431,18 @@ void PrimitiveGUI_BoxDlg::closeEvent( QCloseEvent* e ) { GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_BoxDlg::addSubshapesToStudy() +{ + QMap objMap; + if ( getConstructorId() == 0 ) + { + objMap[GroupPoints->LineEdit1->text()] = myPoint1; + objMap[GroupPoints->LineEdit2->text()] = myPoint2; + addSubshapesToFather( objMap ); + } +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h index 9e7139889..5ff6bf50c 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h @@ -52,7 +52,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx index 1c726635d..51bbf5494 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx @@ -290,17 +290,22 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if (aMap.Extent() == 1) { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); int anIndex = aMap(1); - - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); // ??? - 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 { @@ -516,3 +521,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 objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint; + objMap[GroupPoints->LineEdit2->text()] = myDir; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h index 6ac583460..f6b3f94cf 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h @@ -50,7 +50,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index 48bdcf3b6..eef00b55a 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -284,16 +284,22 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() aSelMgr->GetIndexes(firstIObject(), aMap); if (aMap.Extent() == 1) // Local Selection { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); int anIndex = aMap(1); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); // ??? - 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 // Global Selection { @@ -487,3 +493,23 @@ double PrimitiveGUI_CylinderDlg::getHeight() const return GroupDimensions->SpinBox_DY->GetValue(); return 0; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_CylinderDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint; + objMap[GroupPoints->LineEdit2->text()] = myDir; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h index d6f8391be..1980db249 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h @@ -51,7 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx index 2d92816fa..168bc650c 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx @@ -248,13 +248,19 @@ void PrimitiveGUI_SphereDlg::SelectionIntoArgument() aSelMgr->GetIndexes(firstIObject(), aMap); if (aMap.Extent() == 1) // Local Selection { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); - 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 // Global Selection { @@ -419,3 +425,22 @@ double PrimitiveGUI_SphereDlg::getRadius() const return GroupDimensions->SpinBox_DX->GetValue(); return 0; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_SphereDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h index 7885126b2..8e1297ffa 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h @@ -51,7 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx index c81455344..157e0eb0e 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx @@ -275,17 +275,22 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument() aSelMgr->GetIndexes(firstIObject(), aMap); if (aMap.Extent() == 1) // Local Selection { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap(1); - - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); - 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 // Global Selection { @@ -464,3 +469,23 @@ double PrimitiveGUI_TorusDlg::getRadius2() const return GroupDimensions->SpinBox_DY->GetValue(); return 0; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_TorusDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint; + objMap[GroupPoints->LineEdit2->text()] = myDir; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h index 08e86ced1..1703b6a43 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h @@ -51,6 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init(); diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx index ce2b0a94f..75b1c04b0 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx @@ -259,17 +259,22 @@ void TransformationGUI_MirrorDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); - int id = getConstructorId(); if (aNeedType == TopAbs_VERTEX) aName += QString(":vertex_%1").arg(anIndex); else aName += QString(":edge_%1").arg(anIndex); - - myArgument = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + myArgument = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + myArgument = aFindedObject; // get Object from study } else { if (aShape.ShapeType() != aNeedType) { @@ -478,3 +483,28 @@ void TransformationGUI_MirrorDlg::CreateCopyModeChanged(bool isCreateCopy) { this->GroupBoxName->setEnabled(isCreateCopy); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_MirrorDlg::addSubshapesToStudy() +{ + bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); + if (toCreateCopy) { + QMap objMap; + + switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myArgument; + break; + case 1: + objMap[GroupPoints->LineEdit2->text()] = myArgument; + break; + case 2: + return; + } + addSubshapesToFather( objMap ); + } +} diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.h b/src/TransformationGUI/TransformationGUI_MirrorDlg.h index 44d8f5dda..25f576739 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.h +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.h @@ -52,7 +52,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx index f01324aa8..6a949fe00 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx @@ -305,23 +305,30 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); TColStd_IndexedMapOfInteger aMap; aSelMgr->GetIndexes( firstIObject(), aMap ); - if ( aMap.Extent() == 1 ) - { + if ( aMap.Extent() == 1 ) + { + int anIndex = aMap( 1 ); + aName += QString(":edge_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - int anIndex = aMap( 1 ); - aName += QString(":edge_%1").arg(anIndex); myVector = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); } - else { - if (aShape.ShapeType() != TopAbs_EDGE) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - myVector = aSelectedObject; + else + myVector = aFindedObject; // get existing object + } + else { + if (aShape.ShapeType() != TopAbs_EDGE) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; } - + myVector = aSelectedObject; + } + } } } @@ -509,3 +516,23 @@ void TransformationGUI_MultiRotationDlg::closeEvent( QCloseEvent* e ) // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_MultiRotationDlg::addSubshapesToStudy() +{ + QMap objMap; + + switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myVector; + break; + case 1: + objMap[GroupDimensions->LineEdit2->text()] = myVector; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h index d82780fd2..44d7d5176 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h @@ -51,7 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx index f017e899f..a998495ce 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx @@ -324,14 +324,26 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); aName += QString(":edge_%1").arg(anIndex); - if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) - myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex); - else - myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) + myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex); + else + myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else { + if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) + myVectorV = aFindedObject; + else + myVectorU = aFindedObject; + } } else { if (aShape.ShapeType() != TopAbs_EDGE) { @@ -570,3 +582,24 @@ void TransformationGUI_MultiTranslationDlg::closeEvent( QCloseEvent* e ) // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy() +{ + QMap objMap; + + switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myVectorU; + break; + case 1: + objMap[GroupDimensions->LineEdit2->text()] = myVectorU; + objMap[GroupDimensions->LineEdit3->text()] = myVectorV; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h index c36073d8b..c5746db3e 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h @@ -51,7 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx index 0aca76c01..bfcd16845 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -282,15 +282,22 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); if (aNeedType == TopAbs_EDGE) aName += QString(":edge_%1").arg(anIndex); else aName += QString(":vertex_%1").arg(anIndex); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = 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) { @@ -535,3 +542,27 @@ void TransformationGUI_RotationDlg::onReverse() double anOldValue = GroupPoints->SpinBox_DX->GetValue(); GroupPoints->SpinBox_DX->SetValue( -anOldValue ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_RotationDlg::addSubshapesToStudy() +{ + bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); + if (toCreateCopy) { + QMap objMap; + switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myAxis; + break; + case 1: + objMap[GroupPoints->LineEdit2->text()] = myCentPoint; + objMap[GroupPoints->LineEdit4->text()] = myPoint1; + objMap[GroupPoints->LineEdit5->text()] = myPoint2; + break; + } + addSubshapesToFather( objMap ); + } +} diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.h b/src/TransformationGUI/TransformationGUI_RotationDlg.h index 4a18bbc1d..4ea6ea9e5 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.h @@ -49,7 +49,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx index 5db7a9f8d..455862c73 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx @@ -211,12 +211,20 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); aName += QString(":vertex_%1").arg(anIndex); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = 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); + aSelMgr->clearSelected(); + } + else + aSelectedObject = aFindedObject; // get Object from study } else { if (aShape.ShapeType() != TopAbs_VERTEX) { @@ -391,3 +399,19 @@ void TransformationGUI_ScaleDlg::CreateCopyModeChanged(bool isCreateCopy) { this->GroupBoxName->setEnabled(isCreateCopy); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_ScaleDlg::addSubshapesToStudy() +{ + bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); + if (toCreateCopy) { + QMap objMap; + + objMap[GroupPoints->LineEdit2->text()] = myPoint; + + addSubshapesToFather( objMap ); + } +} diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.h b/src/TransformationGUI/TransformationGUI_ScaleDlg.h index 0190f04d5..7f77c6b42 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.h +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.h @@ -50,7 +50,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx index f41b0eb7c..41c6645e3 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -296,14 +296,22 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); if (aNeedType == TopAbs_EDGE) aName += QString(":edge_%1").arg(anIndex); else aName += QString(":vertex_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = 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; } else // Global Selection { if (aShape.ShapeType() != aNeedType) { @@ -539,3 +547,29 @@ void TransformationGUI_TranslationDlg::CreateCopyModeChanged(bool isCreateCopy) { GroupBoxName->setEnabled(isCreateCopy); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_TranslationDlg::addSubshapesToStudy() +{ + bool toCreateCopy = IsPreview() || GroupPoints->CheckBox1->isChecked(); + if (toCreateCopy) { + QMap objMap; + + switch (getConstructorId()) + { + case 0: + return; + case 1: + objMap[GroupPoints->LineEdit2->text()] = myPoint1; + objMap[GroupPoints->LineEdit3->text()] = myPoint2; + break; + case 2: + objMap[GroupPoints->LineEdit2->text()] = myVector; + break; + } + addSubshapesToFather( objMap ); + } +} diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.h b/src/TransformationGUI/TransformationGUI_TranslationDlg.h index dac586af0..11975c136 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.h +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.h @@ -50,6 +50,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init(); -- 2.39.2