From 0d45320fe4eec57548eab6e04018397b0b4862b3 Mon Sep 17 00:00:00 2001 From: dmv Date: Wed, 19 Dec 2007 14:15:59 +0000 Subject: [PATCH] NPAL 18363 --- .../TransformationGUI_MirrorDlg.cxx | 33 +++++++++++++------ .../TransformationGUI_MultiRotationDlg.cxx | 28 ++++++++-------- .../TransformationGUI_MultiTranslationDlg.cxx | 31 ++++++++--------- .../TransformationGUI_RotationDlg.cxx | 26 ++++++++++----- .../TransformationGUI_ScaleDlg.cxx | 12 ++++--- .../TransformationGUI_TranslationDlg.cxx | 26 ++++++++++----- 6 files changed, 95 insertions(+), 61 deletions(-) diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx index b5d2df706..ce2b0a94f 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx @@ -241,11 +241,19 @@ void TransformationGUI_MirrorDlg::SelectionIntoArgument() if(!testResult || CORBA::is_nil( myArgument )) return; + aName = GEOMBase::GetName( aSelectedObject ); + if ( testResult && !aSelectedObject->_is_nil() ) { TopoDS_Shape aShape; if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (getConstructorId() == 1) + aNeedType = TopAbs_EDGE; + else if (getConstructorId() == 2) + aNeedType = TopAbs_FACE; + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); TColStd_IndexedMapOfInteger aMap; aSelMgr->GetIndexes( firstIObject(), aMap ); @@ -254,15 +262,23 @@ void TransformationGUI_MirrorDlg::SelectionIntoArgument() GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); - TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); + 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(); - } + } + else { + if (aShape.ShapeType() != aNeedType) { + myArgument = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } } } - aName = GEOMBase::GetName( aSelectedObject ); } myEditCurrentArgument->setText( aName ); @@ -293,10 +309,10 @@ void TransformationGUI_MirrorDlg::LineEditReturnPressed() void TransformationGUI_MirrorDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if(send == GroupPoints->PushButton1){ myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; @@ -304,15 +320,12 @@ void TransformationGUI_MirrorDlg::SetEditCurrentArgument() { case 0: { - // globalSelection( GEOM_POINT ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); break; } case 1: { - //globalSelection( GEOM_LINE ); - GEOM::GEOM_Object_var anObj; - localSelection( anObj, TopAbs_EDGE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); break; } case 2: diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx index 1b6f1c3b4..f01324aa8 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx @@ -288,6 +288,8 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() if (!testResult || CORBA::is_nil(aSelectedObject) || !GEOMBase::IsShape(aSelectedObject)) return; + QString aName = GEOMBase::GetName( aSelectedObject ); + if (myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1) myBase = aSelectedObject; @@ -297,6 +299,7 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() { TopoDS_Shape aShape; + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); @@ -307,18 +310,22 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); - TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); + aName += QString(":edge_%1").arg(anIndex); myVector = aShapesOp->GetSubShape(aSelectedObject, anIndex); aSelMgr->clearSelected(); } - else + else { + if (aShape.ShapeType() != TopAbs_EDGE) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } myVector = aSelectedObject; + } + } } } - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + myEditCurrentArgument->setText( aName ); displayPreview(); } @@ -331,26 +338,21 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_ALLSHAPES ); if(send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - // globalSelection( GEOM_LINE ); - GEOM::GEOM_Object_var anObj; - localSelection( anObj, TopAbs_EDGE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if(send == GroupDimensions->PushButton1) { myEditCurrentArgument = GroupDimensions->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupDimensions->PushButton2) { myEditCurrentArgument = GroupDimensions->LineEdit2; - // globalSelection( GEOM_LINE ); - GEOM::GEOM_Object_var anObj; - localSelection( anObj, TopAbs_EDGE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx index 3b5e094bc..f017e899f 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx @@ -305,6 +305,8 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() if ( !testResult || CORBA::is_nil( aSelectedObject ) || !GEOMBase::IsShape( aSelectedObject ) ) return; + QString aName = GEOMBase::GetName( aSelectedObject ); + if (myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1) myBase = aSelectedObject; @@ -325,25 +327,27 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); - TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); - aSelMgr->clearSelected(); + aName += QString(":edge_%1").arg(anIndex); if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex); else myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex); } - else + else { + if (aShape.ShapeType() != TopAbs_EDGE) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) myVectorV = aSelectedObject; else myVectorU = aSelectedObject; + } } } } - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + myEditCurrentArgument->setText( aName ); displayPreview(); } @@ -356,32 +360,25 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_ALLSHAPES ); if(send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - // globalSelection( GEOM_LINE ); - GEOM::GEOM_Object_var anObj; - localSelection( anObj, TopAbs_EDGE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if(send == GroupDimensions->PushButton1) { myEditCurrentArgument = GroupDimensions->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupDimensions->PushButton2) { myEditCurrentArgument = GroupDimensions->LineEdit2; - // globalSelection( GEOM_LINE ); - GEOM::GEOM_Object_var anObj; - localSelection( anObj, TopAbs_EDGE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if(send == GroupDimensions->PushButton3) { myEditCurrentArgument = GroupDimensions->LineEdit3; - // globalSelection( GEOM_LINE ); - GEOM::GEOM_Object_var anObj; - localSelection( anObj, TopAbs_EDGE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx index 5f2a52909..0aca76c01 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -273,6 +273,10 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() TopoDS_Shape aShape; if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) + aNeedType = TopAbs_EDGE; + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); TColStd_IndexedMapOfInteger aMap; aSelMgr->GetIndexes( firstIObject(), aMap ); @@ -281,12 +285,19 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); 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); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); aSelMgr->clearSelected(); } + else { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } } if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) @@ -312,18 +323,15 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() void TransformationGUI_RotationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if(send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - if (getConstructorId() == 0) { - //globalSelection( GEOM_LINE ); - GEOM::GEOM_Object_var anObj; - localSelection( anObj, TopAbs_EDGE ); - } + if (getConstructorId() == 0) + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); else localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx index e24173dcf..5db7a9f8d 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx @@ -214,12 +214,16 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument() GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); int anIndex = aMap( 1 ); - TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); + aName += QString(":vertex_%1").arg(anIndex); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); aSelMgr->clearSelected(); } + else { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } } myPoint = aSelectedObject; @@ -257,10 +261,10 @@ void TransformationGUI_ScaleDlg::LineEditReturnPressed() void TransformationGUI_ScaleDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if(send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx index 24dc59016..f41b0eb7c 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -287,6 +287,10 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument() aName = GEOMBase::GetName( aSelectedObject ); if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) + aNeedType = TopAbs_EDGE; + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); TColStd_IndexedMapOfInteger aMap; aSelMgr->GetIndexes( firstIObject(), aMap ); @@ -294,13 +298,19 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument() { 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(); - } + 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); + } else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } } if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) @@ -338,10 +348,10 @@ void TransformationGUI_TranslationDlg::LineEditReturnPressed() void TransformationGUI_TranslationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if (send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); } else if (send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; -- 2.39.2