From 156fe6ad40e3665acd8e4ebff357142aa675d99f Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 19 Dec 2007 13:36:08 +0000 Subject: [PATCH] NPAL18363: EDF635: We can now select any object in all window. --- src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx | 101 ++++++------ src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx | 92 ++++++----- src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx | 105 +++++++------ src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx | 145 +++++++++--------- src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx | 75 +++++---- 5 files changed, 273 insertions(+), 245 deletions(-) diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx index 84f861301..7e45cc653 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.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 // // // @@ -152,39 +152,39 @@ void PrimitiveGUI_BoxDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DZ, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_BOX" ) ); ConstructorsClicked(0); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= void PrimitiveGUI_BoxDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); - + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + switch (constructorId) { case 0: { // globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); - + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -200,7 +200,6 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked(int constructorId) displayPreview(); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -211,7 +210,6 @@ void PrimitiveGUI_BoxDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : @@ -226,63 +224,68 @@ bool PrimitiveGUI_BoxDlg::ClickOnApply() return true; } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed //================================================================================= void PrimitiveGUI_BoxDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; - + myEditCurrentArgument->setText(""); - + if (IObjectCount() != 1) - { - if (myEditCurrentArgument == GroupPoints->LineEdit1) - myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupPoints->LineEdit2) - myPoint2 = GEOM::GEOM_Object::_nil(); - return; - } + { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint1 = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myPoint2 = GEOM::GEOM_Object::_nil(); + return; + } // nbSel == 1 Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult ); - - if(!testResult || CORBA::is_nil( aSelectedObject )) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); + + if (!testResult || CORBA::is_nil(aSelectedObject)) return; TopoDS_Shape aShape; - QString aName = GEOMBase::GetName( aSelectedObject ); - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + 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 { - 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(); - } + 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(); // ??? } + else // Global Selection + { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); - if(myEditCurrentArgument == GroupPoints->LineEdit1) + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = aSelectedObject; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = aSelectedObject; - + displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -290,20 +293,20 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument() void PrimitiveGUI_BoxDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - + if(send == GroupPoints->PushButton1) myEditCurrentArgument = GroupPoints->LineEdit1; else if(send == GroupPoints->PushButton2) myEditCurrentArgument = GroupPoints->LineEdit2; - + // globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - + myEditCurrentArgument->setFocus(); SelectionIntoArgument(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -326,9 +329,9 @@ void PrimitiveGUI_BoxDlg::LineEditReturnPressed() void PrimitiveGUI_BoxDlg::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() ); } diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx index 659471593..1c726635d 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.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 // // // @@ -166,7 +166,7 @@ void PrimitiveGUI_ConeDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DZ, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; initName( tr( "GEOM_CONE" ) ); @@ -180,14 +180,15 @@ void PrimitiveGUI_ConeDlg::Init() //================================================================================= void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); switch(constructorId) { case 0 : { // globalSelection( GEOM_POINT ); - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + globalSelection(); // to break prvious local selection + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); @@ -197,7 +198,7 @@ void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId) GroupPoints->LineEdit2->setText(tr("")); myPoint = myDir = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -256,17 +257,17 @@ void PrimitiveGUI_ConeDlg::ClickOnCancel() //================================================================================= void PrimitiveGUI_ConeDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; - if(IObjectCount() != 1) - { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myPoint = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myDir = GEOM::GEOM_Object::_nil(); - return; - } + if (IObjectCount() != 1) + { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = GEOM::GEOM_Object::_nil(); + return; + } /* nbSel == 1 */ Standard_Boolean testResult = Standard_False; @@ -278,35 +279,48 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument() 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( 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)); + } + else { - 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 == GroupPoints->LineEdit2 ) - aName.append( ":edge_" + 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) myPoint = aSelectedObject; - else if (myEditCurrentArgument == GroupPoints->LineEdit2) + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = aSelectedObject; - + displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -346,7 +360,6 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed() } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -354,12 +367,11 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed() void PrimitiveGUI_ConeDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - ConstructorsClicked( getConstructorId() ); -} + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + ConstructorsClicked(getConstructorId()); +} //================================================================================= // function : DeactivateActiveDialog() diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index e741b4f7b..48bdcf3b6 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.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 // // // @@ -159,7 +159,7 @@ void PrimitiveGUI_CylinderDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->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_CYLINDER" ) ); @@ -173,13 +173,13 @@ void PrimitiveGUI_CylinderDlg::Init() //================================================================================= void PrimitiveGUI_CylinderDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - switch(constructorId) + switch (constructorId) { case 0 : { - // globalSelection( GEOM_POINT ); + globalSelection( GEOM_POINT ); // to break previous local selection localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupDimensions->hide(); @@ -191,7 +191,7 @@ void PrimitiveGUI_CylinderDlg::ConstructorsClicked(int constructorId) GroupPoints->LineEdit2->setText(tr("")); myPoint = myDir = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -250,48 +250,61 @@ void PrimitiveGUI_CylinderDlg::ClickOnCancel() //================================================================================= void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; myEditCurrentArgument->setText(""); - - if(IObjectCount() != 1) - { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myPoint = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myDir = GEOM::GEOM_Object::_nil(); - return; - } - + + if (IObjectCount() != 1) + { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = GEOM::GEOM_Object::_nil(); + return; + } + /* nbSel == 1 */ Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); - - if(!testResult || CORBA::is_nil( aSelectedObject )) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); + + if (!testResult || CORBA::is_nil(aSelectedObject)) return; - QString aName = GEOMBase::GetName( aSelectedObject ); + QString aName = GEOMBase::GetName(aSelectedObject); TopoDS_Shape aShape; - 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(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 ); - if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) - aName.append( ":edge_" + QString::number( anIndex ) ); - else - aName.append( ":vertex_" + QString::number( anIndex ) ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, 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.append(":edge_" + QString::number(anIndex)); + else + aName.append(":vertex_" + QString::number(anIndex)); } - myEditCurrentArgument->setText( aName ); + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = aSelectedObject; @@ -300,7 +313,6 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -309,12 +321,12 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == GroupPoints->PushButton1) { + if (send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; globalSelection( GEOM_POINT ); // to break previous local selection localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } - else if(send == GroupPoints->PushButton2) { + else if (send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; globalSelection( GEOM_LINE ); // to break previous local selection localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); @@ -340,7 +352,6 @@ void PrimitiveGUI_CylinderDlg::LineEditReturnPressed() } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -348,12 +359,11 @@ void PrimitiveGUI_CylinderDlg::LineEditReturnPressed() void PrimitiveGUI_CylinderDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - ConstructorsClicked( getConstructorId() ); -} + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + ConstructorsClicked(getConstructorId()); +} //================================================================================= // function : enterEvent() @@ -464,7 +474,6 @@ double PrimitiveGUI_CylinderDlg::getRadius() const return 0; } - //================================================================================= // function : getHeight() // purpose : diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx index e0a7c5f33..2d92816fa 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.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 // // // @@ -90,7 +90,6 @@ PrimitiveGUI_SphereDlg::PrimitiveGUI_SphereDlg(GeometryGUI* theGeometryGUI, QWid Init(); } - //================================================================================= // function : ~PrimitiveGUI_SphereDlg() // purpose : Destroys the object and frees any allocated resources @@ -100,7 +99,6 @@ PrimitiveGUI_SphereDlg::~PrimitiveGUI_SphereDlg() /* no need to delete child widgets, Qt does it all for us */ } - //================================================================================= // function : Init() // purpose : @@ -134,29 +132,31 @@ void PrimitiveGUI_SphereDlg::Init() connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupDimensions->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_SPHERE")); ConstructorsClicked(0); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) +void PrimitiveGUI_SphereDlg::ConstructorsClicked (int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); - + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + switch (constructorId) { case 0: { + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupDimensions->hide(); resize(0, 0); @@ -166,7 +166,7 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) GroupPoints->LineEdit1->setText(""); myPoint = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -182,7 +182,6 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) displayPreview(); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -193,7 +192,6 @@ void PrimitiveGUI_SphereDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : @@ -208,67 +206,71 @@ bool PrimitiveGUI_SphereDlg::ClickOnApply() return true; } - - -//======================================================================= +//================================================================================= // function : ClickOnCancel() // purpose : -//======================================================================= +//================================================================================= void PrimitiveGUI_SphereDlg::ClickOnCancel() { GEOMBase_Skeleton::ClickOnCancel(); } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void PrimitiveGUI_SphereDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; - + myEditCurrentArgument->setText(""); - - if(IObjectCount() != 1) - { - myPoint = GEOM::GEOM_Object::_nil(); - return; - } - + + if (IObjectCount() != 1) + { + myPoint = GEOM::GEOM_Object::_nil(); + return; + } + /* nbSel == 1 ! */ Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); - - if (!testResult || CORBA::is_nil( aSelectedObject )) + GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); + + if (!testResult || CORBA::is_nil(aSelectedObject)) return; - QString aName = GEOMBase::GetName( aSelectedObject ); + QString aName = GEOMBase::GetName(aSelectedObject); TopoDS_Shape aShape; - 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 ); - aName.append( ":vertex_" + QString::number( anIndex ) ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - aSelMgr->clearSelected(); - } + 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 ) ); + } + else // Global Selection + { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } } + } - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); myPoint = aSelectedObject; - + displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -283,7 +285,6 @@ void PrimitiveGUI_SphereDlg::LineEditReturnPressed() } } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -292,15 +293,15 @@ void PrimitiveGUI_SphereDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == GroupPoints->PushButton1) { + if (send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); SelectionIntoArgument(); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -308,12 +309,11 @@ void PrimitiveGUI_SphereDlg::SetEditCurrentArgument() void PrimitiveGUI_SphereDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - ConstructorsClicked( getConstructorId() ); -} + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + ConstructorsClicked(getConstructorId()); +} //================================================================================= // function : DeactivateActiveDialog() @@ -324,7 +324,6 @@ void PrimitiveGUI_SphereDlg::DeactivateActiveDialog() GEOMBase_Skeleton::DeactivateActiveDialog(); } - //================================================================================= // function : enterEvent() // purpose : @@ -335,7 +334,6 @@ void PrimitiveGUI_SphereDlg::enterEvent(QEvent* e) ActivateThisDialog(); } - //================================================================================= // function : ValueChangedInSpinBox() // purpose : @@ -345,7 +343,6 @@ void PrimitiveGUI_SphereDlg::ValueChangedInSpinBox() displayPreview(); } - //================================================================================= // function : createOperation // purpose : @@ -355,7 +352,6 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_SphereDlg::createOperation() return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } - //================================================================================= // function : isValid // purpose : @@ -369,33 +365,35 @@ bool PrimitiveGUI_SphereDlg::isValid( QString& msg ) // function : execute // purpose : //================================================================================= -bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects ) +bool PrimitiveGUI_SphereDlg::execute (ObjectList& objects) { bool res = false; - + GEOM::GEOM_Object_var anObj; - switch ( getConstructorId() ) + switch (getConstructorId()) { - case 0 : + case 0: { - if ( !CORBA::is_nil( myPoint ) ) { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSpherePntR( myPoint, getRadius() ); + if (!CORBA::is_nil(myPoint)) { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakeSpherePntR(myPoint, getRadius()); res = true; } break; } - case 1 : + case 1: { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSphereR( getRadius() ); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakeSphereR(getRadius()); res = true; break; } } - - if ( !anObj->_is_nil() ) - objects.push_back( anObj._retn() ); - + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + return res; } @@ -405,12 +403,9 @@ bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects ) //================================================================================= void PrimitiveGUI_SphereDlg::closeEvent( QCloseEvent* e ) { - //myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::closeEvent( e ); } - - //================================================================================= // function : getRadius() // purpose : diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx index 4e2451665..c81455344 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx @@ -159,19 +159,18 @@ void PrimitiveGUI_TorusDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI->getApp()->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_TORUS" ) ); ConstructorsClicked(0); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) +void PrimitiveGUI_TorusDlg::ConstructorsClicked (int constructorId) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); @@ -179,7 +178,8 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) { case 0: { - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupDimensions->hide(); resize(0, 0); @@ -216,7 +216,7 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) //================================================================================= void PrimitiveGUI_TorusDlg::ClickOnOk() { - if ( ClickOnApply() ) + if (ClickOnApply()) ClickOnCancel(); } @@ -227,7 +227,7 @@ void PrimitiveGUI_TorusDlg::ClickOnOk() //================================================================================= bool PrimitiveGUI_TorusDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; initName(); @@ -241,7 +241,7 @@ bool PrimitiveGUI_TorusDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_TorusDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; myEditCurrentArgument->setText(""); @@ -257,32 +257,46 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument() /* nbSel == 1 */ Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); - if (!testResult || CORBA::is_nil( aSelectedObject )) + if (!testResult || CORBA::is_nil(aSelectedObject)) return; - QString aName = GEOMBase::GetName( aSelectedObject ); + QString aName = GEOMBase::GetName(aSelectedObject); TopoDS_Shape aShape; - 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(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)); + } + 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 == GroupPoints->LineEdit2 ) - aName.append( ":edge_" + 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) myPoint = aSelectedObject; @@ -292,7 +306,6 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -378,7 +391,6 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_TorusDlg::createOperation() return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } - //================================================================================= // function : isValid // purpose : @@ -388,7 +400,6 @@ bool PrimitiveGUI_TorusDlg::isValid( QString& msg ) return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true; } - //================================================================================= // function : execute // purpose : @@ -426,7 +437,6 @@ bool PrimitiveGUI_TorusDlg::execute( ObjectList& objects ) return res; } - //================================================================================= // function : getRadius1() // purpose : @@ -441,7 +451,6 @@ double PrimitiveGUI_TorusDlg::getRadius1() const return 0; } - //================================================================================= // function : getRadius2() // purpose : -- 2.39.2