From 582aab65e38962c74772eb0311c36567e8273d8e Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 19 Dec 2007 12:21:31 +0000 Subject: [PATCH] NPAL18363: EDF635: We can now select any object in all window. --- src/BasicGUI/BasicGUI_ArcDlg.cxx | 52 +++--- src/BasicGUI/BasicGUI_CurveDlg.cxx | 23 +-- src/BasicGUI/BasicGUI_EllipseDlg.cxx | 85 +++++---- src/BasicGUI/BasicGUI_LineDlg.cxx | 125 ++++++------- src/BasicGUI/BasicGUI_MarkerDlg.cxx | 185 ++++++++++---------- src/BasicGUI/BasicGUI_PlaneDlg.cxx | 202 ++++++++++++---------- src/BasicGUI/BasicGUI_PointDlg.cxx | 149 ++++++++-------- src/BasicGUI/BasicGUI_VectorDlg.cxx | 119 +++++++------ src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx | 135 +++++++-------- 9 files changed, 559 insertions(+), 516 deletions(-) diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index 636d9efb6..b894242d9 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -161,8 +161,8 @@ void BasicGUI_ArcDlg::Init() connect(Group3Pnts2->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseSense(int))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_ARC" )); ConstructorsClicked( 0 ); @@ -181,6 +181,7 @@ void BasicGUI_ArcDlg::ConstructorsClicked (int constructorId) { case 0: { + globalSelection(); // close local contexts, if any localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); //Select Vertex on All Shapes Group3Pnts->show(); @@ -197,6 +198,7 @@ void BasicGUI_ArcDlg::ConstructorsClicked (int constructorId) } case 1: { + globalSelection(); // close local contexts, if any localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); //Select Vertex on All Shapes Group3Pnts->hide(); @@ -247,7 +249,6 @@ bool BasicGUI_ArcDlg::ClickOnApply() return true; } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case @@ -259,7 +260,7 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() myEditCurrentArgument->setText(""); - if ( IObjectCount() != 1 ) + if (IObjectCount() != 1) { switch (getConstructorId()) { @@ -284,29 +285,37 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { + QString aName = GEOMBase::GetName(aSelectedObject); + // Get Selected object if selected subshape TopoDS_Shape aShape; - QString aName = GEOMBase::GetName( aSelectedObject ); - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + 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) // Local Selection { - 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 ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); - aName.append( ":vertex_" + QString::number( anIndex ) ); - } + 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); + } + else // Global Selection + { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } } + } - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); switch (getConstructorId()) { @@ -330,7 +339,6 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : diff --git a/src/BasicGUI/BasicGUI_CurveDlg.cxx b/src/BasicGUI/BasicGUI_CurveDlg.cxx index b310190a3..828caae24 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.cxx +++ b/src/BasicGUI/BasicGUI_CurveDlg.cxx @@ -16,7 +16,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 // // // @@ -113,8 +113,9 @@ void BasicGUI_CurveDlg::Init() myPoints = new GEOM::ListOfGO(); myPoints->length( 0 ); - // globalSelection( GEOM_POINT ); - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + globalSelection(GEOM_POINT); + //globalSelection(); // close local contexts, if any + //localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); @@ -128,7 +129,7 @@ void BasicGUI_CurveDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; initName( tr( "GEOM_CURVE" ) ); @@ -233,6 +234,7 @@ static int isPointInList(list& thePoints, return -1; } + //================================================================================= /*! function : removeUnnecessaryPnt() * purpose : Remove unnecessary points from list \a theOldPoints @@ -346,7 +348,7 @@ void BasicGUI_CurveDlg::SelectionIntoArgument() int k=0; for (list::iterator j=aList.begin();j!=aList.end();j++) - myPoints[k++] = *j; + myPoints[k++] = *j; if(IOC == 0) myOrderedSel.clear(); @@ -374,13 +376,12 @@ void BasicGUI_CurveDlg::SelectionIntoArgument() void BasicGUI_CurveDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - // myGeomGUI->SetState( 0 ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - // globalSelection( GEOM_POINT ); - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + globalSelection(GEOM_POINT); + //globalSelection(); // close local contexts, if any + //localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); ConstructorsClicked( getConstructorId() ); } diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.cxx b/src/BasicGUI/BasicGUI_EllipseDlg.cxx index 007c1990d..dcb7efd5c 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.cxx +++ b/src/BasicGUI/BasicGUI_EllipseDlg.cxx @@ -16,7 +16,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 // // // @@ -108,12 +108,11 @@ void BasicGUI_EllipseDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection(); // close local contexts, if any localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); myPoint = myDir = GEOM::GEOM_Object::_nil(); - // myGeomGUI->SetState( 0 ); - /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); @@ -143,16 +142,17 @@ void BasicGUI_EllipseDlg::Init() connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DY, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; initName( tr( "GEOM_ELLIPSE" ) ); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -163,7 +163,6 @@ void BasicGUI_EllipseDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : @@ -180,8 +179,10 @@ bool BasicGUI_EllipseDlg::ClickOnApply() GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit2->setText( "" ); myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_POINT ); - + //globalSelection(GEOM_POINT); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + return true; } @@ -210,33 +211,46 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument() } Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + Handle(SALOME_InteractiveObject) anIO = firstIObject(); + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { + QString aName = GEOMBase::GetName(aSelectedObject); + // Get Selected object if selected subshape TopoDS_Shape aShape; - QString aName = GEOMBase::GetName( aSelectedObject ); - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + 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(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); + } + else // Global Selection { - 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 ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) - aName.append( ":edge_" + QString::number( anIndex ) ); - else - aName.append( ":vertex_" + QString::number( anIndex ) ); - aSelMgr->clearSelected(); - } + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } } + } - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint = aSelectedObject; else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myDir = aSelectedObject; @@ -259,6 +273,7 @@ void BasicGUI_EllipseDlg::SetEditCurrentArgument() else if ( send == GroupPoints->PushButton2 ) myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument->setFocus(); + globalSelection(); // close local contexts, if any if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); else @@ -289,9 +304,9 @@ void BasicGUI_EllipseDlg::LineEditReturnPressed() void BasicGUI_EllipseDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; @@ -299,7 +314,9 @@ void BasicGUI_EllipseDlg::ActivateThisDialog() GroupPoints->LineEdit2->setText( "" ); myPoint = myDir = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_POINT ); + //globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); } //================================================================================= diff --git a/src/BasicGUI/BasicGUI_LineDlg.cxx b/src/BasicGUI/BasicGUI_LineDlg.cxx index 11132227f..6e3a7c4ef 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.cxx +++ b/src/BasicGUI/BasicGUI_LineDlg.cxx @@ -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 // // // @@ -101,7 +101,6 @@ BasicGUI_LineDlg::BasicGUI_LineDlg(GeometryGUI* theGeometryGUI, QWidget* parent, Init(); } - //================================================================================= // function : ~BasicGUI_LineDlg() // purpose : Destroys the object and frees any allocated resources @@ -110,7 +109,6 @@ BasicGUI_LineDlg::~BasicGUI_LineDlg() { } - //================================================================================= // function : Init() // purpose : @@ -118,12 +116,10 @@ BasicGUI_LineDlg::~BasicGUI_LineDlg() void BasicGUI_LineDlg::Init() { /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - - myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); - - // myGeomGUI->SetState( 0 ); - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + //myEditCurrentArgument = GroupPoints->LineEdit1; + //myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + //globalSelection(); // close local contexts, if any + //localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); @@ -144,14 +140,13 @@ void BasicGUI_LineDlg::Init() connect(GroupFaces->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupFaces->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - ConstructorsClicked (0); + ConstructorsClicked(0); initName( tr("GEOM_LINE") ); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -162,10 +157,10 @@ void BasicGUI_LineDlg::ClickOnOk() ClickOnCancel(); } -//======================================================================= +//================================================================================= // function : ClickOnCancel() // purpose : -//======================================================================= +//================================================================================= void BasicGUI_LineDlg::ClickOnCancel() { GEOMBase_Skeleton::ClickOnCancel(); @@ -179,14 +174,9 @@ bool BasicGUI_LineDlg::ClickOnApply() { if ( !onAccept() ) return false; - GroupPoints->LineEdit1->setText( "" ); - GroupPoints->LineEdit2->setText( "" ); - GroupFaces->LineEdit1->setText( "" ); - GroupFaces->LineEdit2->setText( "" ); - myPoint1 = myPoint2 = myFace1 = myFace2 = GEOM::GEOM_Object::_nil(); - myEditCurrentArgument = GroupPoints->LineEdit1; - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select vertex on all shapes + initName(); + ConstructorsClicked(getConstructorId()); return true; } @@ -200,8 +190,9 @@ void BasicGUI_LineDlg::ConstructorsClicked(int constructorId) { case 0: { - globalSelection(GEOM_POINT); // to break previous local selection + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument->setText(""); myPoint1 = GEOM::GEOM_Object::_nil(); @@ -212,8 +203,9 @@ void BasicGUI_LineDlg::ConstructorsClicked(int constructorId) } case 1: { - globalSelection(GEOM_PLANE); // to break previous local selection + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + myEditCurrentArgument = GroupFaces->LineEdit1; myEditCurrentArgument->setText(""); myFace1 = GEOM::GEOM_Object::_nil(); @@ -222,10 +214,10 @@ void BasicGUI_LineDlg::ConstructorsClicked(int constructorId) GroupFaces->show(); break; } - } + } updateGeometry(); - resize( minimumSize() ); + resize(minimumSize()); SelectionIntoArgument(); } @@ -237,9 +229,9 @@ void BasicGUI_LineDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - if ( IObjectCount() != 1 ) + if (IObjectCount() != 1) { - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupFaces->LineEdit1 ) myFace1 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupFaces->LineEdit2 ) myFace2 = GEOM::GEOM_Object::_nil(); @@ -248,32 +240,44 @@ void BasicGUI_LineDlg::SelectionIntoArgument() // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { - TopoDS_Shape aShape; - QString aName = GEOMBase::GetName( aSelectedObject ); + QString aName = GEOMBase::GetName(aSelectedObject); - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupFaces->LineEdit1 || + myEditCurrentArgument == GroupFaces->LineEdit2) + aNeedType = TopAbs_FACE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + 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_FACE) + aName += QString(":face_%1").arg(anIndex); + else + aName += QString(":vertex_%1").arg(anIndex); + } + else // Global Selection { - 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 ); - if ( myEditCurrentArgument == GroupFaces->LineEdit1 || - myEditCurrentArgument == GroupFaces->LineEdit2 ) - aName.append( ":face_" + QString::number( anIndex ) ); - else - aName.append( ":vertex_" + QString::number( anIndex ) ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); - } + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } } - myEditCurrentArgument->setText( aName ); + } + + myEditCurrentArgument->setText(aName); if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = aSelectedObject; else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = aSelectedObject; @@ -284,7 +288,6 @@ void BasicGUI_LineDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -300,7 +303,6 @@ void BasicGUI_LineDlg::SetEditCurrentArgument() SelectionIntoArgument(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -316,7 +318,6 @@ void BasicGUI_LineDlg::LineEditReturnPressed() GEOMBase_Skeleton::LineEditReturnPressed(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -324,20 +325,10 @@ void BasicGUI_LineDlg::LineEditReturnPressed() void BasicGUI_LineDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - // myGeomGUI->SetState( 0 ); - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - myEditCurrentArgument = GroupPoints->LineEdit1; - myEditCurrentArgument->setFocus(); - - GroupPoints->LineEdit1->setText( "" ); - GroupPoints->LineEdit2->setText( "" ); - GroupFaces->LineEdit1->setText( "" ); - GroupFaces->LineEdit2->setText( "" ); - myPoint1 = myPoint2 = myFace1 = myFace2 = GEOM::GEOM_Object::_nil(); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -346,7 +337,6 @@ void BasicGUI_LineDlg::ActivateThisDialog() //================================================================================= void BasicGUI_LineDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -420,4 +410,3 @@ void BasicGUI_LineDlg::closeEvent( QCloseEvent* e ) { GEOMBase_Skeleton::closeEvent( e ); } - diff --git a/src/BasicGUI/BasicGUI_MarkerDlg.cxx b/src/BasicGUI/BasicGUI_MarkerDlg.cxx index 00a843430..88ade8405 100644 --- a/src/BasicGUI/BasicGUI_MarkerDlg.cxx +++ b/src/BasicGUI/BasicGUI_MarkerDlg.cxx @@ -124,7 +124,6 @@ BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* th Init(); } - //================================================================================= // function : ~BasicGUI_MarkerDlg() // purpose : Destroys the object and frees any allocated resources @@ -133,7 +132,6 @@ BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg() { } - //================================================================================= // function : Init() // purpose : @@ -166,7 +164,7 @@ void BasicGUI_MarkerDlg::Init() connect( buttonOk, SIGNAL( clicked() ), this, SLOT( onOk() ) ); connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) ); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); initName( tr( "LCS_NAME" ) ); @@ -190,7 +188,6 @@ void BasicGUI_MarkerDlg::Init() ConstructorsClicked( 0 ); - //@ /* QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()-> @@ -217,6 +214,7 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId ) { if ( myConstructorId == constructorId && myConstructorId == 0 ) { + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); activate( GEOM_MARKER ); displayPreview(); @@ -225,50 +223,52 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId ) myConstructorId = constructorId; - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); switch (constructorId) - { - case 0: + { + case 0: { Group1->hide(); Group2->hide(); resize(0, 0); aMainGrp->show(); + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); activate( GEOM_MARKER ); break; } - case 1: - { - Group2->hide(); - aMainGrp->hide(); - //PAL6669: resize(0, 0); - Group1->show(); - - globalSelection( GEOM_ALLGEOM ); - myEditCurrentArgument = Group1->LineEdit1; - Group1->LineEdit1->setText(""); - break; - } - case 2: - { - aMainGrp->hide(); - Group1->show(); - //PAL6669: resize(0, 0); - Group2->show(); - - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - myEditCurrentArgument = Group2->LineEdit1; - Group2->LineEdit1->setText(""); - Group2->LineEdit2->setText(""); - Group2->LineEdit3->setText(""); - break; - } + case 1: + { + Group2->hide(); + aMainGrp->hide(); + //PAL6669: resize(0, 0); + Group1->show(); + + globalSelection( GEOM_ALLGEOM ); + myEditCurrentArgument = Group1->LineEdit1; + Group1->LineEdit1->setText(""); + break; + } + case 2: + { + aMainGrp->hide(); + Group1->show(); + //PAL6669: resize(0, 0); + Group2->show(); + + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + myEditCurrentArgument = Group2->LineEdit1; + Group2->LineEdit1->setText(""); + Group2->LineEdit2->setText(""); + Group2->LineEdit3->setText(""); + break; } + } - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(onSelectionDone())); onSelectionDone(); } @@ -312,26 +312,26 @@ bool BasicGUI_MarkerDlg::onApply() //================================================================================= void BasicGUI_MarkerDlg::onSelectionDone0() { - if ( IObjectCount() == 1 ) + if (IObjectCount() == 1) { Standard_Boolean aRes = Standard_False; Handle(SALOME_InteractiveObject) anIO = firstIObject(); - GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - if ( aRes && !aSelectedObj->_is_nil() ) + if (aRes && !aSelectedObj->_is_nil()) { TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + if (GEOMBase::GetShape(aSelectedObj, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { // Existing LCS selected - if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) + if (aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE) { - TopoDS_Face aFace = TopoDS::Face( aShape ); - Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) ); + TopoDS_Face aFace = TopoDS::Face(aShape); + Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(aFace)); - if ( !aPlane.IsNull() ) + if (!aPlane.IsNull()) { gp_Ax3 anAx3 = aPlane->Pln().Position(); gp_Pnt aLoc = anAx3.Location(); @@ -355,19 +355,19 @@ void BasicGUI_MarkerDlg::onSelectionDone0() else { TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes( anIO, aMap ); - if ( aMap.Extent() == 1 ) + aSelMgr->GetIndexes(anIO, aMap); + if (aMap.Extent() == 1) // Local Selection { - int anIndex = aMap( 1 ); + int anIndex = aMap(1); TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); - aSelMgr->clearSelected(); + TopExp::MapShapes(aShape, aShapes); + aShape = aShapes.FindKey(anIndex); + aSelMgr->clearSelected(); // ??? } - if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { - gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); myData[ X ]->SetValue( aPnt.X() ); myData[ Y ]->SetValue( aPnt.Y() ); myData[ Z ]->SetValue( aPnt.Z() ); @@ -380,30 +380,28 @@ void BasicGUI_MarkerDlg::onSelectionDone0() displayPreview(); } - //================================================================================= // function : onSelectionDone() // purpose : Called when selection as changed or other case //================================================================================= void BasicGUI_MarkerDlg::onSelectionDone() { - if ( getConstructorId() == 0 ) { + if (getConstructorId() == 0) { onSelectionDone0(); return; } myEditCurrentArgument->setText(""); - QString aName; - if ( IObjectCount() == 1 ) { + if (IObjectCount() == 1) { Standard_Boolean aRes = Standard_False; Handle(SALOME_InteractiveObject) anIO = firstIObject(); - GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes); - if ( !CORBA::is_nil( aSelectedObj ) && aRes ) { - aName = GEOMBase::GetName( aSelectedObj ); + if (!CORBA::is_nil(aSelectedObj) && aRes) { + QString aName = GEOMBase::GetName(aSelectedObj); - if ( getConstructorId() == 1 ) { // by shape position + if (getConstructorId() == 1) { // by shape position // Get shape's position CORBA::Double Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz, Yx,Yy,Yz; Ox = Oy = Oz = Zx = Zy = Xy = Xz = Yx = Yz = 0; @@ -437,31 +435,39 @@ void BasicGUI_MarkerDlg::onSelectionDone() myData[ DY2 ]->SetValue( Yy ); myData[ DZ2 ]->SetValue( Yz ); - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); } - else if ( getConstructorId() == 2 ) { // by point and two vectors + else if (getConstructorId() == 2) { // by point and two vectors TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) { - GEOM::short_array anIndexes; + if (GEOMBase::GetShape(aSelectedObj, aShape, TopAbs_SHAPE)) + { + TopAbs_ShapeEnum aNeedType = TopAbs_EDGE; + if (myEditCurrentArgument == Group2->LineEdit1) + aNeedType = TopAbs_VERTEX; TColStd_IndexedMapOfInteger aMap; LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - aSelMgr->GetIndexes( anIO, aMap ); + aSelMgr->GetIndexes(anIO, aMap); - if ( !aMap.IsEmpty() ) { - int anIndex = aMap( 1 ); + if (!aMap.IsEmpty()) { + int anIndex = aMap(1); TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); + 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); } if (myEditCurrentArgument == Group2->LineEdit1) { - if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) { - gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); myData[ X ]->SetValue( aPnt.X() ); myData[ Y ]->SetValue( aPnt.Y() ); myData[ Z ]->SetValue( aPnt.Z() ); - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); } else { myData[ X ]->SetValue( 0 ); @@ -473,12 +479,12 @@ void BasicGUI_MarkerDlg::onSelectionDone() if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) { gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape))); gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape))); - gp_Dir aDir(gp_Vec(aP1, aP2)); + gp_Dir aDir (gp_Vec(aP1, aP2)); myData[ DX1 ]->SetValue( aDir.X() ); myData[ DY1 ]->SetValue( aDir.Y() ); myData[ DZ1 ]->SetValue( aDir.Z() ); - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); } else { myData[ DX1 ]->SetValue( 0 ); @@ -495,7 +501,7 @@ void BasicGUI_MarkerDlg::onSelectionDone() myData[ DX2 ]->SetValue( aDir.X() ); myData[ DY2 ]->SetValue( aDir.Y() ); myData[ DZ2 ]->SetValue( aDir.Z() ); - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); } else { myData[ DX2 ]->SetValue( 0 ); @@ -551,22 +557,25 @@ void BasicGUI_MarkerDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == Group1->PushButton1) { + if (send == Group1->PushButton1) { myEditCurrentArgument = Group1->LineEdit1; globalSelection( GEOM_ALLGEOM ); } - else if(send == Group2->PushButton1) { + else if (send == Group2->PushButton1) { myEditCurrentArgument = Group2->LineEdit1; - globalSelection( GEOM_POINT ); + //globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } - else if(send == Group2->PushButton2) { + else if (send == Group2->PushButton2) { myEditCurrentArgument = Group2->LineEdit2; - globalSelection( GEOM_LINE ); - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + //globalSelection( GEOM_LINE ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } - else if(send == Group2->PushButton3) { + else if (send == Group2->PushButton3) { myEditCurrentArgument = Group2->LineEdit3; + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } @@ -593,10 +602,10 @@ void BasicGUI_MarkerDlg::LineEditReturnPressed() void BasicGUI_MarkerDlg::onActivate() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(onSelectionDone())); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -666,10 +675,10 @@ bool BasicGUI_MarkerDlg::isValid( QString& msg ) //================================================================================= bool BasicGUI_MarkerDlg::execute( ObjectList& objects ) { - GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow( - getOperation() )->MakeMarker( myData[ X ]->GetValue(), myData[ Y ]->GetValue(), myData[ Z ]->GetValue(), - myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue(), - myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() ); + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow(getOperation())-> + MakeMarker(myData[ X ]->GetValue(), myData[ Y ]->GetValue(), myData[ Z ]->GetValue(), + myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue(), + myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue()); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx index 0bc6784e8..4216a1239 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -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 // // // @@ -183,7 +183,7 @@ void BasicGUI_PlaneDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Pnts->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupFace->SpinBox_DX, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_PLANE" ) ); @@ -199,70 +199,69 @@ void BasicGUI_PlaneDlg::Init() //================================================================================= void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil(); - switch ( constructorId ) + switch (constructorId) { - case 0: /* plane from a point and a direction (vector, edge...) */ - { - Group3Pnts->hide(); - GroupFace->hide(); - resize(0, 0); - GroupPntDir->show(); - - myEditCurrentArgument = GroupPntDir->LineEdit1; - GroupPntDir->LineEdit1->setText(tr("")); - GroupPntDir->LineEdit2->setText(tr("")); - - /* for the first argument */ - globalSelection( GEOM_POINT ); // to break previous local selection - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - break; - } - case 1: /* plane from 3 points */ - { - GroupPntDir->hide(); - GroupFace->hide(); - resize(0, 0); - Group3Pnts->show(); - - myEditCurrentArgument = Group3Pnts->LineEdit1; - Group3Pnts->LineEdit1->setText(""); - Group3Pnts->LineEdit2->setText(""); - Group3Pnts->LineEdit3->setText(""); - - /* for the first argument */ - globalSelection( GEOM_POINT ); // to break previous local selection - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - break; - } - case 2: /* plane from a planar face selection */ - { - GroupPntDir->hide(); - Group3Pnts->hide(); - resize(0, 0); - GroupFace->show(); - - myEditCurrentArgument = GroupFace->LineEdit1; - GroupFace->LineEdit1->setText(tr("")); - - /* for the first argument */ - globalSelection( GEOM_PLANE ); - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_PLANE ); - aMap.Add( GEOM_MARKER ); - globalSelection( aMap ); - break; - } + case 0: /* plane from a point and a direction (vector, edge...) */ + { + Group3Pnts->hide(); + GroupFace->hide(); + resize(0, 0); + GroupPntDir->show(); + + myEditCurrentArgument = GroupPntDir->LineEdit1; + GroupPntDir->LineEdit1->setText(tr("")); + GroupPntDir->LineEdit2->setText(tr("")); + + /* for the first argument */ + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + break; + } + case 1: /* plane from 3 points */ + { + GroupPntDir->hide(); + GroupFace->hide(); + resize(0, 0); + Group3Pnts->show(); + + myEditCurrentArgument = Group3Pnts->LineEdit1; + Group3Pnts->LineEdit1->setText(""); + Group3Pnts->LineEdit2->setText(""); + Group3Pnts->LineEdit3->setText(""); + + /* for the first argument */ + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + break; } + case 2: /* plane from a planar face selection */ + { + GroupPntDir->hide(); + Group3Pnts->hide(); + resize(0, 0); + GroupFace->show(); + + myEditCurrentArgument = GroupFace->LineEdit1; + GroupFace->LineEdit1->setText(tr("")); + + /* for the first argument */ + //globalSelection( GEOM_PLANE ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_PLANE ); + aMap.Add( GEOM_MARKER ); + globalSelection( aMap ); + break; + } + } myEditCurrentArgument->setFocus(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -273,7 +272,6 @@ void BasicGUI_PlaneDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : @@ -305,7 +303,7 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - if ( IObjectCount() != 1 ) + if (IObjectCount() != 1) { if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); @@ -318,32 +316,47 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { - TopoDS_Shape aShape; - QString aName = GEOMBase::GetName( aSelectedObject ); + QString aName = GEOMBase::GetName(aSelectedObject); - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPntDir->LineEdit2) + aNeedType = TopAbs_EDGE; + else if (myEditCurrentArgument == GroupFace->LineEdit1) + aNeedType = TopAbs_FACE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // Local Selection { - 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 ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) - aName.append( ":edge_" + QString::number( anIndex ) ); - else - aName.append( ":vertex_" + QString::number( anIndex ) ); - - aSelMgr->clearSelected(); - } + 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 if (aNeedType == TopAbs_FACE) + aName += QString(":face_%1").arg(anIndex); + else + aName += QString(":vertex_%1").arg(anIndex); } - myEditCurrentArgument->setText( aName ); + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = aSelectedObject; else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = aSelectedObject; @@ -352,6 +365,7 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject; else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = aSelectedObject; } + displayPreview(); } @@ -374,22 +388,24 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument() myEditCurrentArgument->setFocus(); - if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) + if (myEditCurrentArgument == GroupPntDir->LineEdit2) { + globalSelection(); // close local contexts, if any localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); - else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) { - globalSelection( GEOM_PLANE ); + } + else if (myEditCurrentArgument == GroupFace->LineEdit1) { TColStd_MapOfInteger aMap; aMap.Add( GEOM_PLANE ); aMap.Add( GEOM_MARKER ); globalSelection( aMap ); } - else - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + else { // 3 Pnts + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + } SelectionIntoArgument(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -409,7 +425,6 @@ void BasicGUI_PlaneDlg::LineEditReturnPressed() } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -417,12 +432,10 @@ void BasicGUI_PlaneDlg::LineEditReturnPressed() void BasicGUI_PlaneDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - // myGeomGUI->SetState( 0 ); - - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -431,7 +444,6 @@ void BasicGUI_PlaneDlg::ActivateThisDialog() //================================================================================= void BasicGUI_PlaneDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index dc932e2a4..85cf23b03 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -140,7 +140,6 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren Init(); } - //================================================================================= // function : ~BasicGUI_PointDlg() // purpose : Destructor @@ -149,7 +148,6 @@ BasicGUI_PointDlg::~BasicGUI_PointDlg() { } - //================================================================================= // function : Init() // purpose : @@ -213,35 +211,42 @@ void BasicGUI_PointDlg::Init() connect(GroupRefPoint->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupRefPoint->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupOnCurve->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DZ, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DZ, SLOT(SetStep(double))); - - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupOnCurve->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupXYZ->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupXYZ->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupXYZ->SpinBox_DZ, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupRefPoint->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupRefPoint->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupRefPoint->SpinBox_DZ, SLOT(SetStep(double))); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); initName( tr("GEOM_VERTEX") ); ConstructorsClicked( 0 ); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) +void BasicGUI_PointDlg::ConstructorsClicked (int constructorId) { - switch ( constructorId ) + globalSelection(); // close local contexts, if any + + switch (constructorId) { case 0: { - globalSelection( GEOM_POINT); // to break previous local selection - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupRefPoint->hide(); GroupOnCurve->hide(); @@ -255,8 +260,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) myEditCurrentArgument = GroupRefPoint->LineEdit1; myEditCurrentArgument->setText(""); myRefPoint = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_POINT); // to break previous local selection - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupXYZ->hide(); GroupOnCurve->hide(); @@ -270,8 +275,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) myEditCurrentArgument = GroupOnCurve->LineEdit1; myEditCurrentArgument->setText(""); myEdge = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_LINE); // to break previous local selection - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); GroupXYZ->hide(); GroupRefPoint->hide(); @@ -287,8 +292,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) GroupLineIntersection->LineEdit2->setText(""); myLine1 = GEOM::GEOM_Object::_nil(); myLine2 = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_EDGE); // to break previous local selection - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); GroupXYZ->hide(); GroupRefPoint->hide(); @@ -310,33 +315,30 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) SelectionIntoArgument(); } - //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void BasicGUI_PointDlg::ClickOnOk() { - if ( onAccept() ) + if (onAccept()) ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= bool BasicGUI_PointDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; initName(); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); return true; } - //================================================================================= // function : ClickOnCancel() // purpose : @@ -346,7 +348,6 @@ void BasicGUI_PointDlg::ClickOnCancel() GEOMBase_Skeleton::ClickOnCancel(); } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed (for constructors not using local context) @@ -355,7 +356,7 @@ void BasicGUI_PointDlg::SelectionIntoArgument() { const int id = getConstructorId(); - if ( ( id == 1 || id == 2 ) && myEditCurrentArgument != 0 ) + if ((id == 1 || id == 2) && myEditCurrentArgument != 0) { myEditCurrentArgument->setText(""); myX->setText( "" ); @@ -364,65 +365,74 @@ void BasicGUI_PointDlg::SelectionIntoArgument() myRefPoint = myEdge = GEOM::GEOM_Object::_nil(); } - if ( IObjectCount() == 1 ) + if (IObjectCount() == 1) { Standard_Boolean aRes = Standard_False; Handle(SALOME_InteractiveObject) anIO = firstIObject(); - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); - QString aName = GEOMBase::GetName( aSelectedObject ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { + QString aName = 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 ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - if ( id == 2 || id == 3 ) - aName.append( ":edge_" + QString::number( anIndex ) ); - else - aName.append( ":vertex_" + QString::number( anIndex ) ); - aSelMgr->clearSelected(); - } - } - - if ( id == 0 ) + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { - GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ); - - if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX ) - return; + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (id == 2 || id == 3) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + 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); + } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + if (id == 0) return; + } + } + } + if (id == 0) + { + if (aShape.IsNull()) return; gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); GroupXYZ->SpinBox_DX->SetValue( aPnt.X() ); GroupXYZ->SpinBox_DY->SetValue( aPnt.Y() ); GroupXYZ->SpinBox_DZ->SetValue( aPnt.Z() ); } - else if ( id == 1 ) + else if (id == 1) { myRefPoint = aSelectedObject; - GroupRefPoint->LineEdit1->setText( aName ); + GroupRefPoint->LineEdit1->setText(aName); } - else if ( id == 2 ) + else if (id == 2) { myEdge = aSelectedObject; - GroupOnCurve->LineEdit1->setText( aName ); + GroupOnCurve->LineEdit1->setText(aName); } - else if ( id == 3 ) + else if (id == 3) { if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) { myLine1 = aSelectedObject; - GroupLineIntersection->LineEdit1->setText( aName ); + myEditCurrentArgument->setText(aName); } else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) { myLine2 = aSelectedObject; - GroupLineIntersection->LineEdit2->setText( aName ); + myEditCurrentArgument->setText(aName); } } } @@ -431,7 +441,6 @@ void BasicGUI_PointDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -447,13 +456,14 @@ void BasicGUI_PointDlg::LineEditReturnPressed() } } - //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= void BasicGUI_PointDlg::SetEditCurrentArgument() { + globalSelection(); // close local contexts, if any + QPushButton* send = (QPushButton*)sender(); globalSelection( GEOM_POINT); // to break previous local selection @@ -497,7 +507,6 @@ void BasicGUI_PointDlg::enterEvent(QEvent* e) ActivateThisDialog(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -509,7 +518,6 @@ void BasicGUI_PointDlg::ActivateThisDialog( ) ConstructorsClicked( getConstructorId() ); } - //================================================================================= // function : DeactivateActiveDialog() // purpose : public slot to deactivate if active @@ -520,7 +528,6 @@ void BasicGUI_PointDlg::DeactivateActiveDialog() GEOMBase_Skeleton::DeactivateActiveDialog(); } - //================================================================================= // function : ValueChangedInSpinBox() // purpose : diff --git a/src/BasicGUI/BasicGUI_VectorDlg.cxx b/src/BasicGUI/BasicGUI_VectorDlg.cxx index 534e02591..ac2afbfa5 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.cxx +++ b/src/BasicGUI/BasicGUI_VectorDlg.cxx @@ -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 // // // @@ -160,7 +160,7 @@ void BasicGUI_VectorDlg::Init() connect(GroupDimensions->CheckBox1, SIGNAL(stateChanged(int)), this, SLOT(ReverseVector(int))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr("GEOM_VECTOR") ); @@ -176,42 +176,43 @@ void BasicGUI_VectorDlg::Init() //================================================================================= void BasicGUI_VectorDlg::ConstructorsClicked( int constructorId ) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); myPoint1 = GEOM::GEOM_Object::_nil(); myPoint2 = GEOM::GEOM_Object::_nil(); switch (constructorId) - { + { case 0: - { - GroupDimensions->hide(); - resize(0, 0); - GroupPoints->show(); - - myEditCurrentArgument = GroupPoints->LineEdit1; - GroupPoints->LineEdit1->setText(""); - GroupPoints->LineEdit2->setText(""); - - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - break; - } + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(""); + GroupPoints->LineEdit2->setText(""); + + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } case 1: - { - GroupPoints->hide(); - resize( 0, 0 ); - GroupDimensions->show(); - - double dx( 0. ), dy( 0. ), dz( 0. ); - GroupDimensions->SpinBox_DX->SetValue( dx ); - GroupDimensions->SpinBox_DY->SetValue( dy ); - GroupDimensions->SpinBox_DZ->SetValue( dz ); + { + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); - GroupDimensions->CheckBox1->setChecked( FALSE ); - break; - } + double dx( 0. ), dy( 0. ), dz( 0. ); + GroupDimensions->SpinBox_DX->SetValue( dx ); + GroupDimensions->SpinBox_DY->SetValue( dy ); + GroupDimensions->SpinBox_DZ->SetValue( dz ); + + GroupDimensions->CheckBox1->setChecked( FALSE ); + break; } + } displayPreview(); } @@ -262,39 +263,47 @@ void BasicGUI_VectorDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - if ( IObjectCount() != 1 ) + if (IObjectCount() != 1) { - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); return; } // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { + QString aName = GEOMBase::GetName(aSelectedObject); + TopoDS_Shape aShape; - QString aName = GEOMBase::GetName( aSelectedObject ); + 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) // Local Selection + { + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + int anIndex = aMap(1); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + aSelMgr->clearSelected(); // ??? - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + aName += QString(":vertex_%1").arg(anIndex); + } + else // Global Selection { - 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 ); - aName.append( ":vertex_" + QString::number( anIndex ) ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); - } + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } } - myEditCurrentArgument->setText( aName ); + } + + myEditCurrentArgument->setText(aName); if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = aSelectedObject; else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = aSelectedObject; @@ -303,7 +312,6 @@ void BasicGUI_VectorDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -331,7 +339,6 @@ void BasicGUI_VectorDlg::LineEditReturnPressed() GEOMBase_Skeleton::LineEditReturnPressed(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -339,10 +346,10 @@ void BasicGUI_VectorDlg::LineEditReturnPressed() void BasicGUI_VectorDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -351,7 +358,6 @@ void BasicGUI_VectorDlg::ActivateThisDialog() //================================================================================= void BasicGUI_VectorDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -441,4 +447,3 @@ bool BasicGUI_VectorDlg::execute( ObjectList& objects ) return res; } - diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx index 4b3c61917..6ff682163 100644 --- a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx @@ -293,10 +293,10 @@ void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() QString aName; const int id = getConstructorId(); - if ( IObjectCount() != 1 ) { - if(id == 0) + if (IObjectCount() != 1) { + if (id == 0) myFace = GEOM::GEOM_Object::_nil(); - else if(id == 1) { + else if (id == 1) { if (myEditCurrentArgument == Group2->LineEdit1) myVectX = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == Group2->LineEdit2) @@ -309,53 +309,53 @@ void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() Standard_Boolean aRes = Standard_False; GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); - if(!aRes || CORBA::is_nil( aSelectedObject )) + if (!aRes || CORBA::is_nil(aSelectedObject)) return; - aName = GEOMBase::GetName( aSelectedObject ); + aName = GEOMBase::GetName(aSelectedObject); - if(myEditCurrentArgument == Group1->LineEdit1) + if (myEditCurrentArgument == Group1->LineEdit1) myFace = aSelectedObject; - else if(myEditCurrentArgument == Group2->LineEdit1 || myEditCurrentArgument == Group2->LineEdit2) { - if ( aRes && !aSelectedObject->_is_nil() ) - { - 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 ); - aName = aName + " Edge_" + QString::number( anIndex ); - if(myEditCurrentArgument == Group2->LineEdit1) - myVectX = aShapesOp->GetSubShape(aSelectedObject, anIndex); - else - myVectZ = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - if(myEditCurrentArgument == Group2->LineEdit1) - myVectX = aSelectedObject; - else - myVectZ = aSelectedObject; - } - aSelMgr->clearSelected(); - } - } + else if (myEditCurrentArgument == Group2->LineEdit1 || myEditCurrentArgument == Group2->LineEdit2) + { + if ( aRes && !aSelectedObject->_is_nil() ) + { + 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 ); + aName = aName + ":edge_" + QString::number( anIndex ); + if(myEditCurrentArgument == Group2->LineEdit1) + myVectX = aShapesOp->GetSubShape(aSelectedObject, anIndex); + else + myVectZ = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else { + if (myEditCurrentArgument == Group2->LineEdit1) + myVectX = aSelectedObject; + else + myVectZ = aSelectedObject; + } + aSelMgr->clearSelected(); + } } + } myEditCurrentArgument->setText( aName ); - + updateWPlane(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -364,16 +364,16 @@ void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == Group1->PushButton1) { + if (send == Group1->PushButton1) { myEditCurrentArgument = Group1->LineEdit1; globalSelection( GEOM_PLANE ); } - else if(send == Group2->PushButton1) { + else if (send == Group2->PushButton1) { myEditCurrentArgument = Group2->LineEdit1; GEOM::GEOM_Object_var anObj; localSelection( anObj, TopAbs_EDGE ); } - else if(send == Group2->PushButton2) { + else if (send == Group2->PushButton2) { myEditCurrentArgument = Group2->LineEdit2; GEOM::GEOM_Object_var anObj; localSelection( anObj, TopAbs_EDGE ); @@ -383,7 +383,6 @@ void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() SelectionIntoArgument(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -397,7 +396,6 @@ void BasicGUI_WorkingPlaneDlg::LineEditReturnPressed() } } - //================================================================================= // function : onReverse() // purpose : @@ -407,7 +405,6 @@ void BasicGUI_WorkingPlaneDlg::onReverse() updateWPlane(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -421,21 +418,19 @@ void BasicGUI_WorkingPlaneDlg::ActivateThisDialog( ) ConstructorsClicked( getConstructorId() ); } - //================================================================================= // function : DeactivateActiveDialog() // purpose : public slot to deactivate if active //================================================================================= void BasicGUI_WorkingPlaneDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } -//======================================================================= +//================================================================================= // function : ClickOnCancel() // purpose : -//======================================================================= +//================================================================================= void BasicGUI_WorkingPlaneDlg::ClickOnCancel() { GEOMBase_Skeleton::ClickOnCancel(); @@ -460,7 +455,6 @@ void BasicGUI_WorkingPlaneDlg::closeEvent( QCloseEvent* e ) GEOMBase_Skeleton::closeEvent( e ); } - //================================================================================= // function : updateWPlane // purpose : @@ -498,8 +492,8 @@ bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview ) showError( "Wrong shape selected (has to be a planar face)" ); return false; } - - } else if (id == 1) { // by two vectors (Ox & Oz) + } + else if (id == 1) { // by two vectors (Ox & Oz) if ( CORBA::is_nil( myVectX ) || CORBA::is_nil( myVectZ ) ) { if(!showPreview) showError( "Two vectors have to be selected" ); @@ -555,8 +549,8 @@ bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview ) } myWPlane = gp_Ax3(BRep_Tool::Pnt(VX1), aDirZ, aDirX); - - } else if (id == 2) { // by selection from standard (OXY or OYZ, or OZX) + } + else if (id == 2) { // by selection from standard (OXY or OYZ, or OZX) gp_Ax2 anAx2; if (aOriginType == 1) anAx2 = gp::XOY(); @@ -564,25 +558,26 @@ bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview ) else if (aOriginType == 0) anAx2 = gp::ZOX(); myWPlane = gp_Ax3(anAx2); - - } else { + } + else { return false; } - + if (myReverseCB->isChecked()) - { - myWPlane.YReverse(); - myWPlane.ZReverse(); - } - + { + myWPlane.YReverse(); + myWPlane.ZReverse(); + } + if (showPreview) - { - GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() ); - GEOM::GEOM_Object_var anObj = aBasicOp->MakeMarker( myWPlane.Location().X(), myWPlane.Location().Y(), myWPlane.Location().Z(), - myWPlane.XDirection().X(), myWPlane.XDirection().Y(), myWPlane.XDirection().Z(), - myWPlane.YDirection().X(), myWPlane.YDirection().Y(), myWPlane.YDirection().Z() ); - displayPreview(anObj); - } + { + GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations(getStudyId()); + GEOM::GEOM_Object_var anObj = aBasicOp->MakeMarker + (myWPlane.Location().X() , myWPlane.Location().Y() , myWPlane.Location().Z(), + myWPlane.XDirection().X(), myWPlane.XDirection().Y(), myWPlane.XDirection().Z(), + myWPlane.YDirection().X(), myWPlane.YDirection().Y(), myWPlane.YDirection().Z()); + displayPreview(anObj); + } return true; } -- 2.39.2