From 0514da352f2702a939d41fde354a450582b82570 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 10 Jan 2011 10:50:44 +0000 Subject: [PATCH] Eliminate useless GetSubShape() lines in the python dump --- src/BasicGUI/BasicGUI_ArcDlg.cxx | 213 +++------- src/BasicGUI/BasicGUI_ArcDlg.h | 6 +- src/BasicGUI/BasicGUI_CircleDlg.cxx | 210 ++++------ src/BasicGUI/BasicGUI_CircleDlg.h | 6 +- src/BasicGUI/BasicGUI_CurveDlg.cxx | 207 ++------- src/BasicGUI/BasicGUI_CurveDlg.h | 8 +- src/BasicGUI/BasicGUI_EllipseDlg.cxx | 150 ++----- src/BasicGUI/BasicGUI_EllipseDlg.h | 6 +- src/BasicGUI/BasicGUI_LineDlg.cxx | 159 +++---- src/BasicGUI/BasicGUI_LineDlg.h | 12 +- src/BasicGUI/BasicGUI_MarkerDlg.cxx | 303 ++++++-------- src/BasicGUI/BasicGUI_MarkerDlg.h | 13 +- src/BasicGUI/BasicGUI_PlaneDlg.cxx | 253 +++++------ src/BasicGUI/BasicGUI_PlaneDlg.h | 6 +- src/BasicGUI/BasicGUI_PointDlg.cxx | 329 ++++++--------- src/BasicGUI/BasicGUI_PointDlg.h | 14 +- src/BasicGUI/BasicGUI_VectorDlg.cxx | 107 ++--- src/BasicGUI/BasicGUI_VectorDlg.h | 8 +- src/BlocksGUI/BlocksGUI_BlockDlg.cxx | 208 ++++------ src/BlocksGUI/BlocksGUI_BlockDlg.h | 7 +- src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx | 242 +++++------ src/BlocksGUI/BlocksGUI_QuadFaceDlg.h | 11 +- src/BooleanGUI/BooleanGUI_Dialog.cxx | 56 +-- src/BooleanGUI/BooleanGUI_Dialog.h | 8 +- src/BuildGUI/BuildGUI_CompoundDlg.cxx | 31 +- src/BuildGUI/BuildGUI_CompoundDlg.h | 6 +- src/BuildGUI/BuildGUI_EdgeDlg.cxx | 113 ++--- src/BuildGUI/BuildGUI_EdgeDlg.h | 8 +- src/BuildGUI/BuildGUI_FaceDlg.cxx | 36 +- src/BuildGUI/BuildGUI_FaceDlg.h | 5 +- src/BuildGUI/BuildGUI_ShellDlg.cxx | 36 +- src/BuildGUI/BuildGUI_ShellDlg.h | 6 +- src/BuildGUI/BuildGUI_SolidDlg.cxx | 106 +++-- src/BuildGUI/BuildGUI_SolidDlg.h | 11 +- src/BuildGUI/BuildGUI_WireDlg.cxx | 103 +---- src/BuildGUI/BuildGUI_WireDlg.h | 8 +- src/GEOMBase/GEOMBase.cxx | 105 ++++- src/GEOMBase/GEOMBase.h | 10 + src/GEOMBase/GEOMBase_Helper.cxx | 224 +++++++++- src/GEOMBase/GEOMBase_Helper.h | 9 +- src/GEOMBase/GEOM_GenericObjPtr.cxx | 33 ++ src/GEOMBase/GEOM_GenericObjPtr.h | 234 +++++++++++ src/GEOMBase/Makefile.am | 6 +- .../GenerationGUI_FillingDlg.cxx | 110 ++--- src/GenerationGUI/GenerationGUI_FillingDlg.h | 15 +- src/GenerationGUI/GenerationGUI_PipeDlg.cxx | 233 ++++------- src/GenerationGUI/GenerationGUI_PipeDlg.h | 15 +- src/GenerationGUI/GenerationGUI_PrismDlg.cxx | 392 ++++++------------ src/GenerationGUI/GenerationGUI_PrismDlg.h | 21 +- src/GenerationGUI/GenerationGUI_RevolDlg.cxx | 158 ++----- src/GenerationGUI/GenerationGUI_RevolDlg.h | 11 +- src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx | 127 ++---- src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h | 6 +- src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx | 145 ++----- src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h | 6 +- src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx | 136 ++---- src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h | 6 +- src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx | 192 +++------ src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h | 6 +- src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx | 110 ++--- src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h | 8 +- src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx | 84 +--- src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h | 6 +- src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx | 138 ++---- src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h | 6 +- 65 files changed, 2228 insertions(+), 3335 deletions(-) create mode 100644 src/GEOMBase/GEOM_GenericObjPtr.cxx create mode 100644 src/GEOMBase/GEOM_GenericObjPtr.h diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index 1fb73235b..bf23ab463 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -159,7 +159,9 @@ void BasicGUI_ArcDlg::Init() /* init variables */ myEditCurrentArgument = Group3Pnts->LineEdit1; - myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); + myPoint1.nullify(); + myPoint2.nullify(); + myPoint3.nullify(); Group3Pnts2->CheckButton1->setChecked( false ); Group3Pnts->PushButton1->setDown(true); @@ -176,28 +178,16 @@ void BasicGUI_ArcDlg::Init() connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( Group3Pnts->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( Group3Pnts2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts2->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( ReverseSense() ) ); connect( Group3Pnts3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts3->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts3->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( Group3Pnts3->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts3->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts3->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -249,116 +239,80 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() if (aSelList.Extent() != 1) { switch (getConstructorId()) { case 0: - if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); - return; + if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify(); break; case 1: - if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); - return; + if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) myPoint1.nullify(); + else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) myPoint2.nullify(); + else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3.nullify(); break; case 2: - if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); - return; + if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) myPoint1.nullify(); + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) myPoint2.nullify(); + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) myPoint3.nullify(); + break; + default: break; } + return; } - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !CORBA::is_nil( aSelectedObject ) ) { - QString aName = GEOMBase::GetName(aSelectedObject); - - // Get Selected object if selected subshape - TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) // Local Selection - { - int anIndex = aMap(1); - aName += QString(":vertex_%1").arg(anIndex); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if ( aFindedObject->_is_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else - aSelectedObject = aFindedObject; // get Object from study - } - else // Global Selection - { - if (aShape.ShapeType() != TopAbs_VERTEX) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - } + GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText(aName); - - if (!aSelectedObject->_is_nil()) { // clear selection if something selected - globalSelection(); - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - } - switch ( getConstructorId() ) { case 0: - if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) { + if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) { myPoint1 = aSelectedObject; - if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) + if ( myPoint1 && !myPoint2 ) Group3Pnts->PushButton2->click(); } else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) { myPoint2 = aSelectedObject; - if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) + if ( myPoint2 && !myPoint3 ) Group3Pnts->PushButton3->click(); } else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) { myPoint3 = aSelectedObject; - if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) + if ( myPoint3 && !myPoint1 ) Group3Pnts->PushButton1->click(); } break; case 1: if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) { myPoint1 = aSelectedObject; - if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) + if ( myPoint1 && !myPoint2 ) Group3Pnts2->PushButton2->click(); } else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) { myPoint2 = aSelectedObject; - if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) + if ( myPoint2 && !myPoint3 ) Group3Pnts2->PushButton3->click(); } else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) { myPoint3 = aSelectedObject; - if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) + if ( myPoint3 && !myPoint1 ) Group3Pnts2->PushButton1->click(); } break; case 2: if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) { myPoint1 = aSelectedObject; - if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) + if ( myPoint1 && !myPoint2 ) Group3Pnts3->PushButton2->click(); } else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) { myPoint2 = aSelectedObject; - if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) + if ( myPoint2 && !myPoint3 ) Group3Pnts3->PushButton3->click(); } else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) { myPoint3 = aSelectedObject; - if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) + if ( myPoint3 && !myPoint1 ) Group3Pnts3->PushButton1->click(); } break; @@ -466,22 +420,6 @@ void BasicGUI_ArcDlg::SetEditCurrentArgument() } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_ArcDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == Group3Pnts->LineEdit1 || send == Group3Pnts->LineEdit2 || send == Group3Pnts->LineEdit3 || - send == Group3Pnts2->LineEdit1 || send == Group3Pnts2->LineEdit2 || send == Group3Pnts2->LineEdit3 || - send == Group3Pnts3->LineEdit1 || send == Group3Pnts3->LineEdit2 || send == Group3Pnts3->LineEdit3 ) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -517,49 +455,15 @@ GEOM::GEOM_IOperations_ptr BasicGUI_ArcDlg::createOperation() return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); } -//================================================================================= -// function : isEqual -// purpose : it may also be needed to check for min distance between gp_Pnt-s... -//================================================================================= -static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 ) -{ - return thePnt1->_is_equivalent( thePnt2 ); -} - //================================================================================= // function : isValid // purpose : //================================================================================= bool BasicGUI_ArcDlg::isValid( QString& msg ) { - switch (getConstructorId()) { - case 0: - { - if (Group3Pnts->LineEdit1->text().trimmed().isEmpty() || - Group3Pnts->LineEdit2->text().trimmed().isEmpty() || - Group3Pnts->LineEdit3->text().trimmed().isEmpty()) - return false; - break; - } - case 1: - { - if (Group3Pnts2->LineEdit1->text().trimmed().isEmpty() || - Group3Pnts2->LineEdit2->text().trimmed().isEmpty() || - Group3Pnts2->LineEdit3->text().trimmed().isEmpty()) - return false; - break; - } - case 2: - { - if (Group3Pnts3->LineEdit1->text().trimmed().isEmpty() || - Group3Pnts3->LineEdit2->text().trimmed().isEmpty() || - Group3Pnts3->LineEdit3->text().trimmed().isEmpty()) - return false; - break; - } - } - return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() && - !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ); + bool ok = myPoint1 && myPoint2 && myPoint3 && + myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3; + return ok; } //================================================================================= @@ -576,8 +480,8 @@ bool BasicGUI_ArcDlg::execute( ObjectList& objects ) switch ( getConstructorId() ) { case 0: { - if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) { - anObj = anOper->MakeArc( myPoint1, myPoint2, myPoint3 ); + if ( myPoint1 && myPoint2 && myPoint3 ) { + anObj = anOper->MakeArc( myPoint1.get(), myPoint2.get(), myPoint3.get() ); res = true; } break; @@ -585,16 +489,16 @@ bool BasicGUI_ArcDlg::execute( ObjectList& objects ) case 1: { bool Sense = Group3Pnts2->CheckButton1->isChecked(); - if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) { - anObj = anOper->MakeArcCenter( myPoint1, myPoint2, myPoint3, Sense ); + if ( myPoint1 && myPoint2 && myPoint3 ) { + anObj = anOper->MakeArcCenter( myPoint1.get(), myPoint2.get(), myPoint3.get(), Sense ); res = true; } break; } case 2: { - if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) { - anObj = anOper->MakeArcOfEllipse( myPoint1, myPoint2, myPoint3 ); + if ( myPoint1 && myPoint2 && myPoint3 ) { + anObj = anOper->MakeArcOfEllipse( myPoint1.get(), myPoint2.get(), myPoint3.get() ); res = true; } break; @@ -614,12 +518,13 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) { disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); + myPoint1.nullify(); + myPoint2.nullify(); + myPoint3.nullify(); + switch ( constructorId ) { case 0: { - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes - Group3Pnts->show(); Group3Pnts2->hide(); Group3Pnts3->hide(); @@ -632,16 +537,12 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) Group3Pnts->LineEdit1->setEnabled(true); Group3Pnts->LineEdit2->setEnabled(false); Group3Pnts->LineEdit3->setEnabled(false); - myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); myEditCurrentArgument = Group3Pnts->LineEdit1; break; } case 1: { - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes - Group3Pnts->hide(); Group3Pnts2->show(); Group3Pnts3->hide(); @@ -654,16 +555,12 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) Group3Pnts2->LineEdit1->setEnabled(true); Group3Pnts2->LineEdit2->setEnabled(false); Group3Pnts2->LineEdit3->setEnabled(false); - myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); myEditCurrentArgument = Group3Pnts2->LineEdit1; break; } case 2: { - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes - Group3Pnts->hide(); Group3Pnts2->hide(); Group3Pnts3->show(); @@ -676,13 +573,15 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) Group3Pnts3->LineEdit1->setEnabled(true); Group3Pnts3->LineEdit2->setEnabled(false); Group3Pnts3->LineEdit3->setEnabled(false); - myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); myEditCurrentArgument = Group3Pnts3->LineEdit1; break; } } + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes + qApp->processEvents(); updateGeometry(); resize( minimumSizeHint() ); @@ -691,8 +590,7 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - if ( CORBA::is_nil( myPoint1 ) ) - SelectionIntoArgument(); + SelectionIntoArgument(); displayPreview(); } @@ -712,24 +610,15 @@ void BasicGUI_ArcDlg::ReverseSense() //================================================================================= void BasicGUI_ArcDlg::addSubshapesToStudy() { - QMap objMap; - switch ( getConstructorId() ) { case 0: - objMap[Group3Pnts->LineEdit1->text()] = myPoint1; - objMap[Group3Pnts->LineEdit2->text()] = myPoint2; - objMap[Group3Pnts->LineEdit3->text()] = myPoint3; - break; case 1: - objMap[Group3Pnts2->LineEdit1->text()] = myPoint1; - objMap[Group3Pnts2->LineEdit2->text()] = myPoint2; - objMap[Group3Pnts2->LineEdit3->text()] = myPoint3; - break; case 2: - objMap[Group3Pnts3->LineEdit1->text()] = myPoint1; - objMap[Group3Pnts3->LineEdit2->text()] = myPoint2; - objMap[Group3Pnts3->LineEdit3->text()] = myPoint3; + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); + GEOMBase::PublishSubObject( myPoint3.get() ); + break; + default: break; } - addSubshapesToFather( objMap ); } diff --git a/src/BasicGUI/BasicGUI_ArcDlg.h b/src/BasicGUI/BasicGUI_ArcDlg.h index 7694f282d..eaf5eb501 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.h +++ b/src/BasicGUI/BasicGUI_ArcDlg.h @@ -27,7 +27,8 @@ #ifndef BASICGUI_ARCDLG_H #define BASICGUI_ARCDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_3Sel; class DlgRef_3Sel1Check; @@ -56,7 +57,7 @@ private: void enterEvent( QEvent* ); private: - GEOM::GEOM_Object_var myPoint1, myPoint2, myPoint3; + GEOM::GeomObjPtr myPoint1, myPoint2, myPoint3; DlgRef_3Sel* Group3Pnts; DlgRef_3Sel1Check* Group3Pnts2; @@ -68,7 +69,6 @@ private slots: void ActivateThisDialog(); void ConstructorsClicked( int ); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ReverseSense(); diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index 3cebf40e4..c71bdf821 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -150,9 +150,14 @@ void BasicGUI_CircleDlg::Init() /* init variables */ myEditCurrentArgument = GroupPntVecR->LineEdit1; - myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); - - // myGeomGUI->SetState( 0 ); + myPoint.nullify(); + myDir.nullify(); + myPoint1.nullify(); + myPoint2.nullify(); + myPoint3.nullify(); + myPoint4.nullify(); + myPoint5.nullify(); + myPoint6.nullify(); /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -181,9 +186,6 @@ void BasicGUI_CircleDlg::Init() connect( GroupCenter2Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupCenter2Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPntVecR->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupPntVecR->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) ); connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); @@ -212,7 +214,14 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) { disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myDir.nullify(); + myPoint1.nullify(); + myPoint2.nullify(); + myPoint3.nullify(); + myPoint4.nullify(); + myPoint5.nullify(); + myPoint6.nullify(); switch ( constructorId ) { case 0: @@ -320,104 +329,64 @@ void BasicGUI_CircleDlg::SelectionIntoArgument() aSelMgr->selectedObjects( aList ); if ( aList.Extent() != 1 ) { - if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6 = GEOM::GEOM_Object::_nil(); + if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint.nullify(); + else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir.nullify(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify(); + else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4.nullify(); + else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5.nullify(); + else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6.nullify(); return; } - // nbSel == 1 - Handle(SALOME_InteractiveObject) anIO = aList.First(); - - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO ); - if ( !CORBA::is_nil( aSelectedObject ) ) { - QString aName = GEOMBase::GetName( aSelectedObject ); - - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) - aNeedType = TopAbs_EDGE; - - // If selected Vertex or Edge on the some Shape Get selection Subshape - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(anIO, aMap); - if ( aMap.Extent() == 1 ) { // Local Selection - int anIndex = aMap(1); - if ( aNeedType == TopAbs_EDGE ) - aName += QString( ":edge_%1" ).arg( anIndex ); - else - aName += QString( ":vertex_%1" ).arg( anIndex ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); - - if ( aFindedObject->_is_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } - } - else { // Global Selection - if ( aShape.ShapeType() != aNeedType ) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - } + TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ? + TopAbs_EDGE : TopAbs_VERTEX; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText( aName ); - if (!aSelectedObject->_is_nil()) { // clear selection if something selected - globalSelection(); - localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); - } - if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) { myPoint = aSelectedObject; - if ( !myPoint->_is_nil() && myDir->_is_nil() ) + if ( myPoint && !myDir ) GroupPntVecR->PushButton2->click(); } else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) { myDir = aSelectedObject; - if ( !myDir->_is_nil() && myPoint->_is_nil() ) + if ( myDir && !myPoint ) GroupPntVecR->PushButton1->click(); } else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) { myPoint1 = aSelectedObject; - if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) + if ( myPoint1 && !myPoint2 ) Group3Pnts->PushButton2->click(); } else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) { myPoint2 = aSelectedObject; - if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) + if ( myPoint2 && !myPoint3 ) Group3Pnts->PushButton3->click(); } else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) { myPoint3 = aSelectedObject; - if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) + if ( myPoint3 && !myPoint1 ) Group3Pnts->PushButton1->click(); } else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) { myPoint4 = aSelectedObject; - if ( !myPoint4->_is_nil() && myPoint5->_is_nil() ) + if ( myPoint4 && !myPoint5 ) GroupCenter2Pnts->PushButton2->click(); } else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) { myPoint5 = aSelectedObject; - if ( !myPoint5->_is_nil() && myPoint6->_is_nil() ) + if ( myPoint5 && !myPoint6 ) GroupCenter2Pnts->PushButton3->click(); } else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) { myPoint6 = aSelectedObject; - if ( !myPoint6->_is_nil() && myPoint4->_is_nil() ) + if ( myPoint6 && !myPoint4 ) GroupCenter2Pnts->PushButton1->click(); } } @@ -499,14 +468,10 @@ void BasicGUI_CircleDlg::SetEditCurrentArgument() myEditCurrentArgument->setFocus(); - if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) { - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); - } - else { - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - } + TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ? + TopAbs_EDGE : TopAbs_VERTEX; + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); myEditCurrentArgument->setFocus(); // SelectionIntoArgument(); @@ -514,26 +479,6 @@ void BasicGUI_CircleDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_CircleDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPntVecR->LineEdit1 || - send == GroupPntVecR->LineEdit2 || - send == Group3Pnts->LineEdit1 || - send == Group3Pnts->LineEdit2 || - send == Group3Pnts->LineEdit3 || - send == GroupCenter2Pnts->LineEdit1 || - send == GroupCenter2Pnts->LineEdit2 || - send == GroupCenter2Pnts->LineEdit3 ) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() @@ -566,7 +511,6 @@ void BasicGUI_CircleDlg::enterEvent( QEvent* ) //================================================================================= void BasicGUI_CircleDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -602,36 +546,31 @@ GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation() return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); } -//================================================================================= -// function : isEqual -// purpose : it may also be needed to check for min distance between gp_Pnt-s... -//================================================================================= -static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 ) -{ - return thePnt1->_is_equivalent( thePnt2 ); -} - //================================================================================= // function : isValid // purpose : //================================================================================= bool BasicGUI_CircleDlg::isValid( QString& msg ) { - const int id = getConstructorId(); - if ( id == 0 ) { - //return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0; - //nil point means origin of global CS - //nil vector means Z axis - bool ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview()); - return getRadius() > 0 && ok; + bool ok = false; + switch( getConstructorId() ) { + case 0: + // nil point means origin of global CS + // nil vector means Z axis + ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview()) && getRadius() > 0; + break; + case 1: + ok = myPoint1 && myPoint2 && myPoint3 && myPoint1 != myPoint2 && + myPoint1 != myPoint3 && myPoint2 != myPoint3; + break; + case 2: + ok = myPoint4 && myPoint5 && myPoint6 && myPoint4 != myPoint5 && + myPoint5 != myPoint6 && myPoint4 != myPoint6; + break; + default: + break; } - else if ( id == 1 ) - return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() && - !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ); - else if ( id == 2 ) - return !myPoint4->_is_nil() && !myPoint5->_is_nil() && !myPoint6->_is_nil() && - !isEqual( myPoint4, myPoint5 ) && !isEqual( myPoint5, myPoint6 ) && !isEqual( myPoint4, myPoint6 ); - return false; + return ok; } //================================================================================= @@ -651,18 +590,18 @@ bool BasicGUI_CircleDlg::execute( ObjectList& objects ) { QStringList aParameters; aParameters << GroupPntVecR->SpinBox_DX->text(); - anObj = anOper->MakeCirclePntVecR( myPoint, myDir, getRadius() ); + anObj = anOper->MakeCirclePntVecR( myPoint.get(), myDir.get(), getRadius() ); if ( !anObj->_is_nil() && !IsPreview() ) anObj->SetParameters(aParameters.join(":").toLatin1().constData()); res = true; break; } case 1 : - anObj = anOper->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 ); + anObj = anOper->MakeCircleThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get() ); res = true; break; case 2: - anObj = anOper->MakeCircleCenter2Pnt( myPoint4, myPoint5, myPoint6 ); + anObj = anOper->MakeCircleCenter2Pnt( myPoint4.get(), myPoint5.get(), myPoint6.get() ); res = true; break; } @@ -682,25 +621,22 @@ bool BasicGUI_CircleDlg::execute( ObjectList& objects ) //================================================================================= void BasicGUI_CircleDlg::addSubshapesToStudy() { - QMap objMap; - switch ( getConstructorId() ) { case 0: - if (!CORBA::is_nil(myPoint)) - objMap[GroupPntVecR->LineEdit1->text()] = myPoint; - if (!CORBA::is_nil(myDir)) - objMap[GroupPntVecR->LineEdit2->text()] = myDir; + GEOMBase::PublishSubObject( myPoint.get() ); + GEOMBase::PublishSubObject( myDir.get() ); break; case 1: - objMap[Group3Pnts->LineEdit1->text()] = myPoint1; - objMap[Group3Pnts->LineEdit2->text()] = myPoint2; - objMap[Group3Pnts->LineEdit3->text()] = myPoint3; + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); + GEOMBase::PublishSubObject( myPoint3.get() ); break; case 2: - objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4; - objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5; - objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6; + GEOMBase::PublishSubObject( myPoint4.get() ); + GEOMBase::PublishSubObject( myPoint5.get() ); + GEOMBase::PublishSubObject( myPoint6.get() ); break; + default: + break; } - addSubshapesToFather( objMap ); } diff --git a/src/BasicGUI/BasicGUI_CircleDlg.h b/src/BasicGUI/BasicGUI_CircleDlg.h index e15bd8016..cfb0c9e07 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.h +++ b/src/BasicGUI/BasicGUI_CircleDlg.h @@ -27,7 +27,8 @@ #ifndef BASICGUI_CIRCLEDLG_H #define BASICGUI_CIRCLEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_3Sel; class DlgRef_2Sel1Spin; @@ -58,7 +59,7 @@ private: double getRadius() const; private: - GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3, myPoint4, myPoint5, myPoint6; + GEOM::GeomObjPtr myPoint, myDir, myPoint1, myPoint2, myPoint3, myPoint4, myPoint5, myPoint6; DlgRef_2Sel1Spin* GroupPntVecR; DlgRef_3Sel* Group3Pnts; @@ -74,7 +75,6 @@ private slots: void SelectionIntoArgument(); void ConstructorsClicked( int ); - void LineEditReturnPressed(); void SetEditCurrentArgument(); void ValueChangedInSpinBox(); void SetDoubleSpinBoxStep( double ); diff --git a/src/BasicGUI/BasicGUI_CurveDlg.cxx b/src/BasicGUI/BasicGUI_CurveDlg.cxx index 2a962c461..4d59a4b24 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.cxx +++ b/src/BasicGUI/BasicGUI_CurveDlg.cxx @@ -112,8 +112,7 @@ void BasicGUI_CurveDlg::Init() /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myPoints = new GEOM::ListOfGO(); - myPoints->length( 0 ); + myPoints.clear(); globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); @@ -128,7 +127,6 @@ void BasicGUI_CurveDlg::Init() connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupPoints->CheckButton1,SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) ); @@ -154,8 +152,7 @@ void BasicGUI_CurveDlg::ConstructorsClicked( int id ) else GroupPoints->CheckButton1->hide(); - myPoints = new GEOM::ListOfGO(); - myPoints->length( 0 ); + myPoints.clear(); myEditCurrentArgument->setText( "" ); qApp->processEvents(); @@ -177,20 +174,6 @@ void BasicGUI_CurveDlg::SetEditCurrentArgument() SelectionIntoArgument(); } - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_CurveDlg::LineEditReturnPressed() -{ - if ( sender() == GroupPoints->LineEdit1 ) - { - myEditCurrentArgument = GroupPoints->LineEdit1; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : CheckButtonToggled() // purpose : @@ -225,56 +208,29 @@ bool BasicGUI_CurveDlg::ClickOnApply() return true; } -//================================================================================= -/*! function : isPointInList() - * purpose : Check is point (theObject) in the list \a thePoints. - * \author enk - * \retval -1, if point not in list, else 1 in list - */ -//================================================================================= -static int isPointInList( std::list& thePoints, - GEOM::GEOM_Object_var& theObject ) -{ - int len = thePoints.size(); - - if ( len < 1 ) { - return -1; - } - - for ( std::list::iterator i = thePoints.begin(); i != thePoints.end(); i++ ) { - if ( std::string( (*i)->GetEntry() ) == std::string( theObject->GetEntry() ) ) { - return 1; - } - } - - return -1; -} -//================================================================================= -/*! function : removeUnnecessaryPnt() - * purpose : Remove unnecessary points from list \a theOldPoints - * \author enk - * \li \a theOldPoints - ordered sequence with unnecessary point - * \li \a theNewPoints - not ordered sequence with necessary points - */ -//================================================================================= -static void removeUnnecessaryPnt( std::list& theOldPoints, - GEOM::ListOfGO_var& theNewPoints ) +static void synchronize( QList& left, QList& right ) { - std::list objs_to_remove; - for ( std::list::iterator i = theOldPoints.begin(); i != theOldPoints.end(); i++ ) { + // 1. remove items from the "left" list that are not in the "right" list + QMutableListIterator it1( left ); + while ( it1.hasNext() ) { + GEOM::GeomObjPtr o1 = it1.next(); bool found = false; - for ( int j = 0; j < theNewPoints->length() && !found ; j++ ) { - if ( std::string( (*i)->GetEntry() ) == std::string( theNewPoints[j]->GetEntry() ) ) { - found = true; - } - } - if ( !found ) { - objs_to_remove.push_back( *i ); - //cout << "removed: " << (*i)->GetEntry() << endl; - } + QMutableListIterator it2( right ); + while ( it2.hasNext() && !found ) + found = o1 == it2.next(); + if ( !found ) + it1.remove(); } - for ( std::list::iterator i = objs_to_remove.begin(); i != objs_to_remove.end(); i++ ) { - theOldPoints.remove( *i ); + // 2. add items from the "right" list that are not in the "left" list (to keep selection order) + it1 = right; + while ( it1.hasNext() ) { + GEOM::GeomObjPtr o1 = it1.next(); + bool found = false; + QMutableListIterator it2( left ); + while ( it2.hasNext() && !found ) + found = o1 == it2.next(); + if ( !found ) + left << o1; } } @@ -284,98 +240,12 @@ static void removeUnnecessaryPnt( std::list& theOldPoints //================================================================================= void BasicGUI_CurveDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText( "" ); - - SalomeApp_Application* app = myGeomGUI->getApp(); - SalomeApp_Study* appStudy = dynamic_cast(app->activeStudy()); - _PTR(Study) aDStudy = appStudy->studyDS(); - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - - int anIndex; - TopoDS_Shape aShape; - TColStd_IndexedMapOfInteger aMapIndexes; - GEOM::GEOM_Object_var anObject; - std::list aList; - LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); - SALOME_ListIO selected; - aSelMgr->selectedObjects(selected, QString::null, false); - - int IOC = selected.Extent(); - // bool is_append = myPoints->length() < IOC; // if true - add point, else remove - // myPoints->length( IOC ); // this length may be greater than number of objects, - // that will actually be put into myPoints - - for (SALOME_ListIteratorOfListIO anIt (selected); anIt.More(); anIt.Next()) { - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value() ); - if (!CORBA::is_nil(aSelectedObject) ) { - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { - aSelMgr->GetIndexes(anIt.Value(), aMapIndexes); - - if (aMapIndexes.Extent() > 0) { - for (int ii = 1; ii <= aMapIndexes.Extent(); ii++) { - anIndex = aMapIndexes(ii); - QString aName = GEOMBase::GetName( aSelectedObject ); - aName = aName + ":vertex_" + QString::number( anIndex ); - anObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); - //Find Object in study - _PTR(SObject) obj ( aDStudy->FindObjectID( anIt.Value()->getEntry() ) ); - bool inStudy = false; - _PTR(ChildIterator) iit( aDStudy->NewChildIterator( obj ) ); - for (; iit->More() && !inStudy; iit->Next()) { - _PTR(SObject) child( iit->Value() ); - QString aChildName = child->GetName().c_str(); - if ( aChildName == aName ) { - inStudy = true; - CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( iit->Value() ); - anObject = GEOM::GEOM_Object::_narrow( corbaObj ); - } - } - - if ( !inStudy ) - GeometryGUI::GetGeomGen()->AddInStudy( GeometryGUI::ClientStudyToStudy( aDStudy ), - anObject, aName.toLatin1().data(), aSelectedObject ); - - int pos = isPointInList( myOrderedSel, anObject ); - if ( pos == -1 ) { - myOrderedSel.push_back( anObject ); - } - // if (!inStudy) - aList.push_back(anObject); - } - } - else { // aMap.Extent() == 0 - if ( aShape.ShapeType() == TopAbs_VERTEX ) { - int pos = isPointInList( myOrderedSel, aSelectedObject ); - if ( pos == -1 ) - myOrderedSel.push_back( aSelectedObject ); - aList.push_back( aSelectedObject ); - } - } - } - } - } - - myPoints->length( aList.size() ); - - int k = 0; - for ( std::list::iterator j = aList.begin(); j != aList.end(); j++ ) - myPoints[k++] = *j; - - if ( IOC == 0 ) - myOrderedSel.clear(); + QList points = getSelected( TopAbs_VERTEX, -1 ); + synchronize( myPoints, points ); + if ( !myPoints.isEmpty() ) + GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) ); else - removeUnnecessaryPnt( myOrderedSel, myPoints ); - - // if ( myOrderedSel.size() == myPoints->length() ) { - myPoints->length( myOrderedSel.size() ); - k = 0; - for ( std::list::iterator j = myOrderedSel.begin(); j != myOrderedSel.end(); j++ ) - myPoints[k++] = *j; - // } - - if ( myPoints->length() > 0 ) - GroupPoints->LineEdit1->setText( QString::number( myPoints->length() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) ); - + GroupPoints->LineEdit1->setText( "" ); displayPreview(); } @@ -431,7 +301,7 @@ GEOM::GEOM_IOperations_ptr BasicGUI_CurveDlg::createOperation() //================================================================================= bool BasicGUI_CurveDlg::isValid( QString& msg ) { - return myPoints->length() > 1; + return myPoints.count() > 1; } //================================================================================= @@ -446,17 +316,22 @@ bool BasicGUI_CurveDlg::execute( ObjectList& objects ) GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); + GEOM::ListOfGO_var points = new GEOM::ListOfGO(); + points->length( myPoints.count() ); + for ( int i = 0; i < myPoints.count(); i++ ) + points[i] = myPoints[i].copy(); + switch ( getConstructorId() ) { case 0 : - anObj = anOper->MakePolyline( myPoints ); + anObj = anOper->MakePolyline( points.in() ); res = true; break; case 1 : - anObj = anOper->MakeSplineBezier( myPoints ); + anObj = anOper->MakeSplineBezier( points.in() ); res = true; break; case 2 : - anObj = anOper->MakeSplineInterpolation( myPoints, GroupPoints->CheckButton1->isChecked() ); + anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked() ); res = true; break; } @@ -466,3 +341,13 @@ bool BasicGUI_CurveDlg::execute( ObjectList& objects ) return res; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_CurveDlg::addSubshapesToStudy() +{ + for ( int i = 0; i < myPoints.count(); i++ ) + GEOMBase::PublishSubObject( myPoints[i].get() ); +} diff --git a/src/BasicGUI/BasicGUI_CurveDlg.h b/src/BasicGUI/BasicGUI_CurveDlg.h index 7dda99523..797466eac 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.h +++ b/src/BasicGUI/BasicGUI_CurveDlg.h @@ -27,7 +27,8 @@ #ifndef BASICGUI_CURVEDLG_H #define BASICGUI_CURVEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" #include @@ -50,6 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& ); + virtual void addSubshapesToStudy(); private: void Init(); @@ -57,8 +59,7 @@ private: private: DlgRef_1Sel1Check* GroupPoints; - GEOM::ListOfGO_var myPoints; - std::list myOrderedSel; //!< This list used for managing orderes selection + QList myPoints; private slots: void ClickOnOk(); @@ -68,7 +69,6 @@ private slots: void DeactivateActiveDialog(); void ConstructorsClicked( int ); - void LineEditReturnPressed(); void CheckButtonToggled(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.cxx b/src/BasicGUI/BasicGUI_EllipseDlg.cxx index 9cf7b8e01..3f36eddac 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.cxx +++ b/src/BasicGUI/BasicGUI_EllipseDlg.cxx @@ -115,11 +115,11 @@ void BasicGUI_EllipseDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupPoints->PushButton1->setDown(true); - myPoint = myDir = myMajor = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myDir.nullify(); + myMajor.nullify(); /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -144,10 +144,6 @@ void BasicGUI_EllipseDlg::Init() connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupPoints->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupPoints->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); @@ -158,6 +154,9 @@ void BasicGUI_EllipseDlg::Init() initName( tr( "GEOM_ELLIPSE" ) ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + resize( minimumSizeHint() ); SelectionIntoArgument(); displayPreview(); @@ -197,7 +196,9 @@ bool BasicGUI_EllipseDlg::ClickOnApply() initName(); // reset - myPoint = myDir = myMajor = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myDir.nullify(); + myMajor.nullify(); GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit2->setText( "" ); GroupPoints->LineEdit3->setText( "" ); @@ -229,73 +230,33 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit3) myMajor = GEOM::GEOM_Object::_nil(); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify(); + else if (myEditCurrentArgument == GroupPoints->LineEdit3) myMajor.nullify(); return; } - Handle(SALOME_InteractiveObject) anIO = aSelList.First(); - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO ); - if (!CORBA::is_nil(aSelectedObject) ) { - QString aName = GEOMBase::GetName(aSelectedObject); - - // Get Selected object if selected subshape - TopoDS_Shape aShape; - - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if ( myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupPoints->LineEdit3 ) - aNeedType = TopAbs_EDGE; - - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(anIO, aMap); - if (aMap.Extent() == 1) { - int anIndex = aMap(1); - if (aNeedType == TopAbs_EDGE) - aName += QString(":edge_%1").arg(anIndex); - else - aName += QString(":vertex_%1").arg(anIndex); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } - } - else { // Global Selection - if (aShape.ShapeType() != aNeedType) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - } - + TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 || + myEditCurrentArgument == GroupPoints->LineEdit3 ) ? + TopAbs_EDGE : TopAbs_VERTEX; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText( aName ); - - if (!aSelectedObject->_is_nil()) { // clear selection if something selected - globalSelection(); - localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); - } - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { myPoint = aSelectedObject; - if ( !myPoint->_is_nil() && myDir->_is_nil() ) + if ( myPoint && !myDir ) GroupPoints->PushButton2->click(); } else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { - myDir = aSelectedObject; - if ( !myDir->_is_nil() && myMajor->_is_nil() ) + myDir = aSelectedObject; + if ( myDir && !myMajor ) GroupPoints->PushButton3->click(); } else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) { myMajor = aSelectedObject; - if ( !myMajor->_is_nil() && myPoint->_is_nil() ) + if ( myMajor && !myPoint ) GroupPoints->PushButton1->click(); } } @@ -337,10 +298,10 @@ void BasicGUI_EllipseDlg::SetEditCurrentArgument() GroupPoints->LineEdit3->setEnabled( true ); } + TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 || + myEditCurrentArgument == GroupPoints->LineEdit3 ) ? + TopAbs_EDGE : TopAbs_VERTEX; globalSelection(); // close local contexts, if any - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if ( myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupPoints->LineEdit3 ) - aNeedType = TopAbs_EDGE; localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); myEditCurrentArgument->setFocus(); @@ -349,21 +310,6 @@ void BasicGUI_EllipseDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_EllipseDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2 || - send == GroupPoints->LineEdit3 ) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() @@ -382,7 +328,8 @@ void BasicGUI_EllipseDlg::ActivateThisDialog() GroupPoints->LineEdit2->setText( "" ); GroupPoints->LineEdit3->setText( "" ); - myPoint = myDir = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myDir.nullify(); //globalSelection( GEOM_POINT ); globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); @@ -432,18 +379,18 @@ GEOM::GEOM_IOperations_ptr BasicGUI_EllipseDlg::createOperation() //================================================================================= bool BasicGUI_EllipseDlg::isValid( QString& msg ) { - double aMajorR = GroupPoints->SpinBox_DX->value(); - double aMinorR = GroupPoints->SpinBox_DY->value(); - if ( aMajorR < aMinorR ) { - msg = tr( "GEOM_ELLIPSE_ERROR_1" ); - return false; + // nil point means origin of global CS + // nil vector means Z axis + bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ); + if ( ok ) { + double aMajorR = GroupPoints->SpinBox_DX->value(); + double aMinorR = GroupPoints->SpinBox_DY->value(); + if ( aMajorR < aMinorR ) { + msg = tr( "GEOM_ELLIPSE_ERROR_1" ); + ok = false; + } } - //return !myPoint->_is_nil() && !myDir->_is_nil(); - //nil point means origin of global CS - //nil vector means Z axis - bool ok = true; - ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; return ok; } @@ -461,9 +408,9 @@ bool BasicGUI_EllipseDlg::execute( ObjectList& objects ) aParameters<SpinBox_DY->text(); GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); - GEOM::GEOM_Object_var anObj = myMajor->_is_nil() ? - anOper->MakeEllipse ( myPoint, myDir, aMajorR, aMinorR ) : - anOper->MakeEllipseVec( myPoint, myDir, aMajorR, aMinorR, myMajor ); + GEOM::GEOM_Object_var anObj = myMajor ? + anOper->MakeEllipseVec( myPoint.get(), myDir.get(), aMajorR, aMinorR, myMajor.get() ) : + anOper->MakeEllipse ( myPoint.get(), myDir.get(), aMajorR, aMinorR ); if ( !anObj->_is_nil() ) { if ( !IsPreview() ) anObj->SetParameters(aParameters.join(":").toLatin1().constData()); @@ -478,14 +425,7 @@ bool BasicGUI_EllipseDlg::execute( ObjectList& objects ) //================================================================================= void BasicGUI_EllipseDlg::addSubshapesToStudy() { - QMap objMap; - - if (!CORBA::is_nil(myPoint)) - objMap[GroupPoints->LineEdit1->text()] = myPoint; - if (!CORBA::is_nil(myDir)) - objMap[GroupPoints->LineEdit2->text()] = myDir; - if (!CORBA::is_nil(myMajor)) - objMap[GroupPoints->LineEdit3->text()] = myMajor; - - addSubshapesToFather( objMap ); + GEOMBase::PublishSubObject( myPoint.get() ); + GEOMBase::PublishSubObject( myDir.get() ); + GEOMBase::PublishSubObject( myMajor.get() ); } diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.h b/src/BasicGUI/BasicGUI_EllipseDlg.h index 9d169b186..9c91be481 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.h +++ b/src/BasicGUI/BasicGUI_EllipseDlg.h @@ -27,7 +27,8 @@ #ifndef BASICGUI_ELLIPSEDLG_H #define BASICGUI_ELLIPSEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_3Sel2Spin; @@ -55,7 +56,7 @@ private: void enterEvent( QEvent* ); private: - GEOM::GEOM_Object_var myPoint, myDir, myMajor; + GEOM::GeomObjPtr myPoint, myDir, myMajor; DlgRef_3Sel2Spin* GroupPoints; @@ -66,7 +67,6 @@ private slots: void ActivateThisDialog(); void DeactivateActiveDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ValueChangedInSpinBox( double ); diff --git a/src/BasicGUI/BasicGUI_LineDlg.cxx b/src/BasicGUI/BasicGUI_LineDlg.cxx index c0261ec83..d9396d5d0 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.cxx +++ b/src/BasicGUI/BasicGUI_LineDlg.cxx @@ -120,11 +120,12 @@ void BasicGUI_LineDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + myPoint1.nullify(); + myPoint2.nullify(); + myFace1.nullify(); + myFace2.nullify(); + GroupPoints->PushButton1->setDown(true); - /* signals and slots connections */ connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); @@ -140,11 +141,6 @@ void BasicGUI_LineDlg::Init() connect( GroupFaces->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupFaces->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupFaces->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupFaces->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -190,14 +186,11 @@ void BasicGUI_LineDlg::ConstructorsClicked( int constructorId ) switch ( constructorId ) { case 0: { - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument->setText( "" ); GroupPoints->LineEdit2->setText( "" ); - myPoint1 = GEOM::GEOM_Object::_nil(); - myPoint2 = GEOM::GEOM_Object::_nil(); + myPoint1.nullify(); + myPoint2.nullify(); GroupPoints->PushButton1->setDown(true); GroupPoints->PushButton2->setDown(false); GroupPoints->LineEdit1->setEnabled(true); @@ -208,13 +201,10 @@ void BasicGUI_LineDlg::ConstructorsClicked( int constructorId ) } case 1: { - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); - myEditCurrentArgument = GroupFaces->LineEdit1; myEditCurrentArgument->setText(""); - myFace1 = GEOM::GEOM_Object::_nil(); - myFace2 = GEOM::GEOM_Object::_nil(); + myFace1.nullify(); + myFace2.nullify(); GroupFaces->PushButton1->setDown(true); GroupFaces->PushButton2->setDown(false); GroupFaces->LineEdit1->setEnabled(true); @@ -225,6 +215,12 @@ void BasicGUI_LineDlg::ConstructorsClicked( int constructorId ) } } + TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 || + myEditCurrentArgument == GroupFaces->LineEdit2 ) ? + TopAbs_FACE : TopAbs_VERTEX; + globalSelection(); // close local selection to clear it + localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); + qApp->processEvents(); updateGeometry(); resize( minimumSizeHint() ); @@ -244,77 +240,40 @@ void BasicGUI_LineDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - 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(); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify(); + else if (myEditCurrentArgument == GroupFaces->LineEdit1) myFace1.nullify(); + else if (myEditCurrentArgument == GroupFaces->LineEdit2) myFace2.nullify(); displayPreview(); return; } - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !CORBA::is_nil( aSelectedObject ) ) { - QString aName = GEOMBase::GetName( aSelectedObject ); - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if ( myEditCurrentArgument == GroupFaces->LineEdit1 || - myEditCurrentArgument == GroupFaces->LineEdit2 ) - aNeedType = TopAbs_FACE; - - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if ( aMap.Extent() == 1 ) { // Local Selection - int anIndex = aMap( 1 ); - if ( aNeedType == TopAbs_FACE ) - aName += QString( ":face_%1" ).arg( anIndex ); - else - aName += QString( ":vertex_%1" ).arg( anIndex ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); - - if ( aFindedObject->_is_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } - } - else { // Global Selection - if ( aShape.ShapeType() != aNeedType ) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - } - + TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 || + myEditCurrentArgument == GroupFaces->LineEdit2 ) ? + TopAbs_FACE : TopAbs_VERTEX; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText( aName ); - - if (!aSelectedObject->_is_nil()) { // clear selection if something selected - globalSelection(); - localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); - } - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { myPoint1 = aSelectedObject; - if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) + if ( myPoint1 && !myPoint2 ) GroupPoints->PushButton2->click(); } else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { myPoint2 = aSelectedObject; - if ( !myPoint2->_is_nil() && myPoint1->_is_nil() ) + if ( myPoint2 && !myPoint1 ) GroupPoints->PushButton1->click(); } else if ( myEditCurrentArgument == GroupFaces->LineEdit1 ) { myFace1 = aSelectedObject; - if ( !myFace1->_is_nil() && myFace2->_is_nil() ) + if ( myFace1 && !myFace2 ) GroupFaces->PushButton2->click(); } else if ( myEditCurrentArgument == GroupFaces->LineEdit2 ) { myFace2 = aSelectedObject; - if ( !myFace2->_is_nil() && myFace1->_is_nil() ) + if ( myFace2 && !myFace1 ) GroupFaces->PushButton1->click(); } } @@ -322,7 +281,6 @@ void BasicGUI_LineDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -355,10 +313,10 @@ void BasicGUI_LineDlg::SetEditCurrentArgument() GroupFaces->LineEdit2->setEnabled(true); } + TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 || + myEditCurrentArgument == GroupFaces->LineEdit2 ) ? + TopAbs_FACE : TopAbs_VERTEX; globalSelection(); // close local selection to clear it - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if ( myEditCurrentArgument == GroupFaces->LineEdit1 || myEditCurrentArgument == GroupFaces->LineEdit2 ) - aNeedType = TopAbs_FACE; localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); myEditCurrentArgument->setFocus(); @@ -367,23 +325,6 @@ void BasicGUI_LineDlg::SetEditCurrentArgument() displayPreview(); } - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_LineDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPoints->LineEdit1 ) myEditCurrentArgument = GroupPoints->LineEdit1; - else if ( send == GroupPoints->LineEdit2 ) myEditCurrentArgument = GroupPoints->LineEdit2; - else if ( send == GroupFaces->LineEdit1 ) myEditCurrentArgument = GroupFaces->LineEdit1; - else if ( send == GroupFaces->LineEdit2 ) myEditCurrentArgument = GroupFaces->LineEdit2; - else return; - GEOMBase_Skeleton::LineEditReturnPressed(); -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -431,12 +372,18 @@ GEOM::GEOM_IOperations_ptr BasicGUI_LineDlg::createOperation() //================================================================================= bool BasicGUI_LineDlg::isValid( QString& msg ) { - const int id = getConstructorId(); - if ( id == 0 ) - return !myPoint1->_is_nil() && !myPoint2->_is_nil(); - else if ( id == 1 ) - return !myFace1->_is_nil() && !myFace2->_is_nil(); - return false; + bool ok = false; + switch ( getConstructorId() ) { + case 0 : + ok = myPoint1 && myPoint2; + break; + case 1: + ok = myFace1 && myFace2; + break; + default: + break; + } + return ok; } //================================================================================= @@ -450,11 +397,11 @@ bool BasicGUI_LineDlg::execute( ObjectList& objects ) GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() ); switch ( getConstructorId() ) { case 0 : - anObj = anOper->MakeLineTwoPnt( myPoint1, myPoint2 ); + anObj = anOper->MakeLineTwoPnt( myPoint1.get(), myPoint2.get() ); res = true; break; case 1 : - anObj = anOper->MakeLineTwoFaces( myFace1, myFace2 ); + anObj = anOper->MakeLineTwoFaces( myFace1.get(), myFace2.get() ); res = true; break; } @@ -471,16 +418,16 @@ bool BasicGUI_LineDlg::execute( ObjectList& objects ) //================================================================================= void BasicGUI_LineDlg::addSubshapesToStudy() { - QMap objMap; switch ( getConstructorId() ) { case 0 : - objMap[GroupPoints->LineEdit1->text()] = myPoint1; - objMap[GroupPoints->LineEdit2->text()] = myPoint2; + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); break; case 1 : - objMap[GroupFaces->LineEdit1->text()] = myFace1; - objMap[GroupFaces->LineEdit2->text()] = myFace2; + GEOMBase::PublishSubObject( myFace1.get() ); + GEOMBase::PublishSubObject( myFace2.get() ); + break; + default: break; } - addSubshapesToFather( objMap ); } diff --git a/src/BasicGUI/BasicGUI_LineDlg.h b/src/BasicGUI/BasicGUI_LineDlg.h index b71077476..cc3e389cb 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.h +++ b/src/BasicGUI/BasicGUI_LineDlg.h @@ -27,7 +27,8 @@ #ifndef BASICGUI_LINEDLG_H #define BASICGUI_LINEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel; @@ -55,10 +56,10 @@ private: void enterEvent( QEvent* ); private: - GEOM::GEOM_Object_var myPoint1; - GEOM::GEOM_Object_var myPoint2; - GEOM::GEOM_Object_var myFace1; - GEOM::GEOM_Object_var myFace2; + GEOM::GeomObjPtr myPoint1; + GEOM::GeomObjPtr myPoint2; + GEOM::GeomObjPtr myFace1; + GEOM::GeomObjPtr myFace2; DlgRef_2Sel* GroupPoints; DlgRef_2Sel* GroupFaces; @@ -71,7 +72,6 @@ private slots: void DeactivateActiveDialog(); void ConstructorsClicked( int ); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); }; diff --git a/src/BasicGUI/BasicGUI_MarkerDlg.cxx b/src/BasicGUI/BasicGUI_MarkerDlg.cxx index 2b4c26e22..0b8309e73 100644 --- a/src/BasicGUI/BasicGUI_MarkerDlg.cxx +++ b/src/BasicGUI/BasicGUI_MarkerDlg.cxx @@ -168,7 +168,10 @@ BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg() //================================================================================= void BasicGUI_MarkerDlg::Init() { - myShape = myPoint = myVectorX = myVectorY = GEOM::GEOM_Object::_nil(); + myShape.nullify(); + myPoint.nullify(); + myVectorX.nullify(); + myVectorY.nullify(); myBlockPreview = false; myConstructorId = -1; myEditCurrentArgument = Group1->LineEdit1; @@ -187,11 +190,6 @@ void BasicGUI_MarkerDlg::Init() connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) ); connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); @@ -259,7 +257,7 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId ) globalSelection( GEOM_ALLGEOM ); myEditCurrentArgument = Group1->LineEdit1; Group1->LineEdit1->setText( "" ); - myShape = GEOM::GEOM_Object::_nil(); + myShape.nullify(); break; } case 2: @@ -279,9 +277,9 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId ) Group2->LineEdit1->setEnabled( true ); Group2->LineEdit2->setEnabled( false ); Group2->LineEdit3->setEnabled( false ); - myPoint = GEOM::GEOM_Object::_nil(); - myVectorX = GEOM::GEOM_Object::_nil(); - myVectorY = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myVectorX.nullify(); + myVectorY.nullify(); break; } } @@ -328,65 +326,43 @@ bool BasicGUI_MarkerDlg::onApply() //================================================================================= void BasicGUI_MarkerDlg::onSelectionDone0() { - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() == 1) { - Handle(SALOME_InteractiveObject) anIO = aSelList.First(); - GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO ); + GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_FACE ); + TopoDS_Shape aShape; + if ( aSelectedObject && aSelectedObject->GetType() == GEOM_MARKER && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + // Existing LCS selected + TopoDS_Face aFace = TopoDS::Face( aShape ); + Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) ); - if ( !aSelectedObj->_is_nil() ) { - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - // Existing LCS selected - 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 ) ); - - if ( !aPlane.IsNull() ) { - gp_Ax3 anAx3 = aPlane->Pln().Position(); - gp_Pnt aLoc = anAx3.Location(); - gp_Dir aXDir = anAx3.XDirection(); - gp_Dir aYDir = anAx3.YDirection(); - - myData[ X ]->setValue( aLoc.X() ); - myData[ Y ]->setValue( aLoc.Y() ); - myData[ Z ]->setValue( aLoc.Z() ); - - myData[ DX1 ]->setValue( aXDir.X() ); - myData[ DY1 ]->setValue( aXDir.Y() ); - myData[ DZ1 ]->setValue( aXDir.Z() ); - - myData[ DX2 ]->setValue( aYDir.X() ); - myData[ DY2 ]->setValue( aYDir.Y() ); - myData[ DZ2 ]->setValue( aYDir.Z() ); - aSelMgr->clearSelected(); - } - } - else { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes( anIO, aMap ); - if ( aMap.Extent() == 1 ) { // Local Selection - int anIndex = aMap( 1 ); - TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); - aSelMgr->clearSelected(); // ??? - } - - 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() ); - } - } - } + if ( !aPlane.IsNull() ) { + gp_Ax3 anAx3 = aPlane->Pln().Position(); + gp_Pnt aLoc = anAx3.Location(); + gp_Dir aXDir = anAx3.XDirection(); + gp_Dir aYDir = anAx3.YDirection(); + + myData[ X ]->setValue( aLoc.X() ); + myData[ Y ]->setValue( aLoc.Y() ); + myData[ Z ]->setValue( aLoc.Z() ); + + myData[ DX1 ]->setValue( aXDir.X() ); + myData[ DY1 ]->setValue( aXDir.Y() ); + myData[ DZ1 ]->setValue( aXDir.Z() ); + + myData[ DX2 ]->setValue( aYDir.X() ); + myData[ DY2 ]->setValue( aYDir.Y() ); + myData[ DZ2 ]->setValue( aYDir.Z() ); } + displayPreview(); + return; + } + aSelectedObject = getSelected( TopAbs_VERTEX ); + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + myData[ X ]->setValue( aPnt.X() ); + myData[ Y ]->setValue( aPnt.Y() ); + myData[ Z ]->setValue( aPnt.Z() ); + displayPreview(); + return; } - - displayPreview(); } @@ -401,91 +377,49 @@ void BasicGUI_MarkerDlg::onSelectionDone() return; } - myEditCurrentArgument->setText( "" ); - - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() == 1) { - Handle(SALOME_InteractiveObject) anIO = aSelList.First(); - GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO ); - - if ( !CORBA::is_nil( aSelectedObj ) ) { - QString aName = GEOMBase::GetName( aSelectedObj ); - - if ( getConstructorId() == 1 ) { // by shape position - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) - myShape = aSelectedObj; - myEditCurrentArgument->setText( aName ); + TopAbs_ShapeEnum aNeedType; + if ( getConstructorId() == 1 ) // by shape position + aNeedType = TopAbs_SHAPE; + else if ( getConstructorId() == 2 ) // by point and two vectors + aNeedType = myEditCurrentArgument == Group2->LineEdit1 ? TopAbs_VERTEX : TopAbs_EDGE; + + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + myEditCurrentArgument->setText( aName ); + if ( getConstructorId() == 1 ) { // by shape position + myShape = aSelectedObject; + } + else if ( getConstructorId() == 2 ) { // by point and two vectors + if ( myEditCurrentArgument == Group2->LineEdit1 ) { + myPoint = aSelectedObject; + if (myPoint && !myVectorX) + Group2->PushButton2->click(); + } + else if (myEditCurrentArgument == Group2->LineEdit2) { + myVectorX = aSelectedObject; + if (myVectorX && !myVectorY) + Group2->PushButton3->click(); } - else if ( getConstructorId() == 2 ) { // by point and two vectors - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) { - TopAbs_ShapeEnum aNeedType = TopAbs_EDGE; - if ( myEditCurrentArgument == Group2->LineEdit1 ) - aNeedType = TopAbs_VERTEX; - - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes( anIO, aMap ); - - if ( aMap.Extent() == 1 ) { // Local Selection - int anIndex = aMap( 1 ); - if ( aNeedType == TopAbs_EDGE ) - aName += QString( ":edge_%1" ).arg( anIndex ); - else - aName += QString( ":vertex_%1" ).arg( anIndex ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObj, aName ); - if ( aFindedObject->_is_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - aSelectedObj = aShapesOp->GetSubShape( aSelectedObj, anIndex ); - } - else { - aSelectedObj = aFindedObject; // get Object from study - } - } - else { // Global Selection - if ( aShape.ShapeType() != aNeedType ) { - aSelectedObj = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - - if ( myEditCurrentArgument == Group2->LineEdit1 ) { - myPoint = aSelectedObj; - myEditCurrentArgument->setText( aName ); - if (!myPoint->_is_nil() && Group2->LineEdit2->text() == "") - Group2->PushButton2->click(); - } - else if (myEditCurrentArgument == Group2->LineEdit2) { - myVectorX = aSelectedObj; - myEditCurrentArgument->setText( aName ); - if (!myVectorX->_is_nil() && Group2->LineEdit3->text() == "") - Group2->PushButton3->click(); - } - else if ( myEditCurrentArgument == Group2->LineEdit3 ) { - myVectorY = aSelectedObj; - myEditCurrentArgument->setText( aName ); - if (!myVectorX->_is_nil() && Group2->LineEdit1->text() == "") - Group2->PushButton1->click(); - } - } + else if ( myEditCurrentArgument == Group2->LineEdit3 ) { + myVectorY = aSelectedObject; + if (myVectorY && !myPoint) + Group2->PushButton1->click(); } } } else { if ( getConstructorId() == 1 ) { - myShape = GEOM::GEOM_Object::_nil(); - } else if ( getConstructorId() == 2 ) { + myShape.nullify(); + } + else if ( getConstructorId() == 2 ) { if ( myEditCurrentArgument == Group2->LineEdit1 ) - myPoint = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); else if ( myEditCurrentArgument == Group2->LineEdit2 ) - myVectorX = GEOM::GEOM_Object::_nil(); + myVectorX.nullify(); else if ( myEditCurrentArgument == Group2->LineEdit3 ) - myVectorY = GEOM::GEOM_Object::_nil(); + myVectorY.nullify(); } } @@ -538,18 +472,6 @@ void BasicGUI_MarkerDlg::SetEditCurrentArgument() onSelectionDone(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_MarkerDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); -} - //================================================================================= // function : onActivate() // purpose : @@ -597,31 +519,33 @@ GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation() //================================================================================= bool BasicGUI_MarkerDlg::isValid( QString& msg ) { - const int id = getConstructorId(); - switch ( id ) { - case 0: { - gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ), - v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() ); + bool ok = false; + switch ( getConstructorId() ) { + case 0: { + gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ), + v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() ); - bool isOk = false; - // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution() - // Vectors shouldn't be checked for being orthogonal here! - if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) { - isOk = !v1.IsParallel( v2, Precision::Angular() ); - if ( !isOk ) - msg += tr( "VEC_PARALLEL" ); - } - bool ok = true; - for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) - ok = anIter.value()->isValid( msg, !IsPreview()) && ok; - return isOk && ok; + // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution() + // Vectors shouldn't be checked for being orthogonal here! + if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) { + ok = !v1.IsParallel( v2, Precision::Angular() ); + if ( !ok ) + msg += tr( "VEC_PARALLEL" ); } - case 1: - return !myShape->_is_nil(); - case 2: - return !myPoint->_is_nil() && !myVectorX->_is_nil() && !myVectorY->_is_nil(); + for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end() && ok; ++anIter ) + ok = anIter.value()->isValid( msg, !IsPreview()) && ok; + break; } - return false; + case 1: + ok = myShape; + break; + case 2: + ok = myPoint && myVectorX && myVectorY; + break; + default: + break; + } + return ok; } //================================================================================= @@ -650,9 +574,9 @@ bool BasicGUI_MarkerDlg::execute( ObjectList& objects ) aParameters<text(); aParameters<text(); } else if (id == 1) { - anObj = anOper->MakeMarkerFromShape( myShape ); + anObj = anOper->MakeMarkerFromShape( myShape.get() ); } else if (id == 2) { - anObj = anOper->MakeMarkerPntTwoVec( myPoint, myVectorX, myVectorY ); + anObj = anOper->MakeMarkerPntTwoVec( myPoint.get(), myVectorX.get(), myVectorY.get() ); } if ( !anObj->_is_nil() ) { @@ -664,6 +588,29 @@ bool BasicGUI_MarkerDlg::execute( ObjectList& objects ) return true; } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_MarkerDlg::addSubshapesToStudy() +{ + switch ( getConstructorId() ) { + case 0 : + break; + case 1 : + GEOMBase::PublishSubObject( myShape.get() ); + break; + case 2: + GEOMBase::PublishSubObject( myPoint.get() ); + GEOMBase::PublishSubObject( myVectorX.get() ); + GEOMBase::PublishSubObject( myVectorY.get() ); + break; + default: + break; + } + +} + //================================================================================= // function : onValueChanged // purpose : diff --git a/src/BasicGUI/BasicGUI_MarkerDlg.h b/src/BasicGUI/BasicGUI_MarkerDlg.h index 50d3613c5..e2cdb7f07 100644 --- a/src/BasicGUI/BasicGUI_MarkerDlg.h +++ b/src/BasicGUI/BasicGUI_MarkerDlg.h @@ -27,7 +27,8 @@ #ifndef BASICGUI_MARKERDLG_H #define BASICGUI_MARKERDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" #include @@ -57,15 +58,16 @@ protected: const bool = true, const bool = true, const double = -1 ); + virtual void addSubshapesToStudy(); private: void enterEvent( QEvent* ); void onSelectionDone0(); - GEOM::GEOM_Object_var myShape; - GEOM::GEOM_Object_var myPoint; - GEOM::GEOM_Object_var myVectorX; - GEOM::GEOM_Object_var myVectorY; + GEOM::GeomObjPtr myShape; + GEOM::GeomObjPtr myPoint; + GEOM::GeomObjPtr myVectorX; + GEOM::GeomObjPtr myVectorY; private slots: void onOk(); @@ -75,7 +77,6 @@ private slots: void onSelectionDone(); void onValueChanged( double ); void ConstructorsClicked( int ); - void LineEditReturnPressed(); void SetEditCurrentArgument(); private: diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx index e87cde189..7eb3506d7 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -137,6 +137,7 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* pare GroupLCS->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) ); GroupLCS->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) ); GroupLCS->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) ); + GroupLCS->LineEdit1->setReadOnly( true ); GroupLCS->PushButton1->setIcon( image3 ); GroupLCS->PushButton1->setDown( true ); @@ -173,8 +174,16 @@ void BasicGUI_PlaneDlg::Init() /* init variables */ myEditCurrentArgument = GroupPntDir->LineEdit1; - myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil(); - + myPoint.nullify(); + myDir.nullify(); + myPoint1.nullify(); + myPoint2.nullify(); + myPoint3.nullify(); + myFace.nullify(); + myLCS.nullify(); + myVec1.nullify(); + myVec2.nullify(); + // myGeomGUI->SetState( 0 ); myOriginType = 1; @@ -218,15 +227,6 @@ void BasicGUI_PlaneDlg::Init() connect( GroupLCS->RadioButton2, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) ); connect( GroupLCS->RadioButton3, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) ); - connect( GroupPntDir->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupPntDir->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupFace->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group2Vec->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( Group2Vec->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( Group3Pnts->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupFace->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); @@ -262,7 +262,15 @@ void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step ) void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId ) { disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); - myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myDir.nullify(); + myPoint1.nullify(); + myPoint2.nullify(); + myPoint3.nullify(); + myFace.nullify(); + myLCS.nullify(); + myVec1.nullify(); + myVec2.nullify(); switch ( constructorId ) { case 0: /* plane from a point and a direction (vector, edge...) */ @@ -428,115 +436,70 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS = GEOM::GEOM_Object::_nil(); + if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint.nullify(); + else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir.nullify(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify(); + else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace.nullify(); + else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1.nullify(); + else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2.nullify(); + else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS.nullify(); displayPreview(); return; } - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !CORBA::is_nil( aSelectedObject ) ) { - QString aName = GEOMBase::GetName( aSelectedObject ); - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2) - aNeedType = TopAbs_EDGE; - else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) - aNeedType = TopAbs_FACE; - else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) - aNeedType = TopAbs_FACE; - - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if ( aMap.Extent() == 1 ) { // Local Selection - int anIndex = aMap( 1 ); - if ( aNeedType == TopAbs_EDGE ) - aName += QString( ":edge_%1" ).arg( anIndex ); - else if (aNeedType == TopAbs_FACE) - aName += QString( ":face_%1" ).arg( anIndex ); - else - aName += QString( ":vertex_%1" ).arg( anIndex ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); - - if ( aFindedObject->_is_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } - } - else { // Global Selection - if ( aShape.ShapeType() != aNeedType ) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - } - + TopAbs_ShapeEnum aNeedType; + if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2) + aNeedType = TopAbs_EDGE; + else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) + aNeedType = TopAbs_FACE; + else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) + aNeedType = TopAbs_FACE; + else + aNeedType = TopAbs_VERTEX; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText( aName ); - - /* if (!aSelectedObject->_is_nil()) { // clear selection if something selected - globalSelection(); - if ( myEditCurrentArgument == GroupFace->LineEdit1 ) { - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_PLANE ); - aMap.Add( GEOM_MARKER ); - globalSelection( aMap ); - } - else - localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); - }*/ - - if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) { - myPoint = aSelectedObject; - if ( !myPoint->_is_nil() && myDir->_is_nil() ) + if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) { + myPoint = aSelectedObject; + if ( myPoint && !myDir ) GroupPntDir->PushButton2->click(); } else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) { - myDir = aSelectedObject; - if ( !myDir->_is_nil() && myPoint->_is_nil() ) + myDir = aSelectedObject; + if ( myDir && !myPoint ) GroupPntDir->PushButton1->click(); } else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) { myPoint1 = aSelectedObject; - if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) + if ( myPoint1 && !myPoint2 ) Group3Pnts->PushButton2->click(); } else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) { myPoint2 = aSelectedObject; - if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) + if ( myPoint2 && !myPoint3 ) Group3Pnts->PushButton3->click(); } else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) { myPoint3 = aSelectedObject; - if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) + if ( myPoint3 && !myPoint1 ) Group3Pnts->PushButton1->click(); } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = aSelectedObject; else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) { myVec1 = aSelectedObject; - if ( !myVec1->_is_nil() && myVec2->_is_nil() ) + if ( myVec1 && !myVec2 ) Group2Vec->PushButton2->click(); } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) { myVec2 = aSelectedObject; - if ( !myVec2->_is_nil() && myVec1->_is_nil() ) + if ( myVec2 && !myVec1 ) Group2Vec->PushButton1->click(); } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS = aSelectedObject; - } displayPreview(); @@ -631,28 +594,6 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument() } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_PlaneDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPntDir->LineEdit1 || - send == GroupPntDir->LineEdit2 || - send == Group3Pnts->LineEdit1 || - send == Group3Pnts->LineEdit2 || - send == Group3Pnts->LineEdit3 || - send == GroupFace->LineEdit1 || - send == Group2Vec->LineEdit1 || - send == Group2Vec->LineEdit2 || - send == GroupLCS->LineEdit1 ) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -736,47 +677,41 @@ GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation() return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() ); } -//================================================================================= -// function : isEqual -// purpose : it may also be needed to check for min distance between gp_Pnt-s... -//================================================================================= -static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 ) -{ - return thePnt1->_is_equivalent( thePnt2 ); -} - //================================================================================= // function : isValid // purpose : //================================================================================= bool BasicGUI_PlaneDlg::isValid( QString& msg ) { - const int id = getConstructorId(); + bool ok = false; if ( getSize() <= 0 ) { msg = QString( "Please, enter size greater than 0." ); - return false; } - - if ( id == 0 ) { - bool ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() ); - return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir ) && ok; - } - else if ( id == 1 ) { - bool ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() ); - return !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) && - !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ) && ok; - } - else if ( id == 2 ) { - bool ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() ); - return !CORBA::is_nil( myFace ) && ok; - } else if ( id == 3 ) { - bool ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() ); - return !CORBA::is_nil( myVec1 ) && !CORBA::is_nil( myVec2 ) && !isEqual( myVec1, myVec2 ) && ok; - } else if ( id == 4 ) { - bool ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() ); - return ok; + else { + switch ( getConstructorId() ) { + case 0: + ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint && myDir; + break; + case 1: + ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() ) && + myPoint1 && myPoint2 && myPoint3 && + myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3; + break; + case 2: + ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() ) && myFace; + break; + case 3: + ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() ) && + myVec1 && myVec2 && myVec1 != myVec2; + break; + case 4: + ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() ); + break; + default: + break; + } } - return false; + return ok; } //================================================================================= @@ -793,23 +728,23 @@ bool BasicGUI_PlaneDlg::execute( ObjectList& objects ) switch ( getConstructorId() ) { case 0 : - anObj = anOper->MakePlanePntVec( myPoint, myDir, getSize() ); + anObj = anOper->MakePlanePntVec( myPoint.get(), myDir.get(), getSize() ); res = true; break; case 1 : - anObj = anOper->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() ); + anObj = anOper->MakePlaneThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get(), getSize() ); res = true; break; case 2 : - anObj = anOper->MakePlaneFace( myFace, getSize() ); + anObj = anOper->MakePlaneFace( myFace.get(), getSize() ); res = true; break; case 3 : - anObj = anOper->MakePlane2Vec( myVec1, myVec2, getSize() ); + anObj = anOper->MakePlane2Vec( myVec1.get(), myVec2.get(), getSize() ); res = true; break; case 4 : - anObj = anOper->MakePlaneLCS( myLCS, getSize(), myOriginType ); + anObj = anOper->MakePlaneLCS( myLCS.get(), getSize(), myOriginType ); res = true; break; } @@ -827,25 +762,27 @@ bool BasicGUI_PlaneDlg::execute( ObjectList& objects ) //================================================================================= void BasicGUI_PlaneDlg::addSubshapesToStudy() { - QMap objMap; - switch ( getConstructorId() ) { case 0: - objMap[GroupPntDir->LineEdit1->text()] = myPoint; - objMap[GroupPntDir->LineEdit2->text()] = myDir; + GEOMBase::PublishSubObject( myPoint.get() ); + GEOMBase::PublishSubObject( myDir.get() ); break; case 1: - objMap[Group3Pnts->LineEdit1->text()] = myPoint1; - objMap[Group3Pnts->LineEdit2->text()] = myPoint2; - objMap[Group3Pnts->LineEdit3->text()] = myPoint3; + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); + GEOMBase::PublishSubObject( myPoint3.get() ); break; case 2: - objMap[GroupFace->LineEdit1->text()] = myFace; + GEOMBase::PublishSubObject( myFace.get() ); break; case 3: - objMap[Group2Vec->LineEdit1->text()] = myVec1; - objMap[Group2Vec->LineEdit2->text()] = myVec2; + GEOMBase::PublishSubObject( myVec1.get() ); + GEOMBase::PublishSubObject( myVec2.get() ); + break; + case 4: + GEOMBase::PublishSubObject( myLCS.get() ); break; + default: + break; } - addSubshapesToFather( objMap ); } diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.h b/src/BasicGUI/BasicGUI_PlaneDlg.h index 242092823..4b1cfbb65 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.h +++ b/src/BasicGUI/BasicGUI_PlaneDlg.h @@ -27,7 +27,8 @@ #ifndef BASICGUI_PLANEDLG_H #define BASICGUI_PLANEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_1Sel1Spin; class DlgRef_2Sel1Spin; @@ -61,7 +62,7 @@ private: int myOriginType; private: - GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3, myFace, myVec1, myVec2, myLCS; + GEOM::GeomObjPtr myPoint, myDir, myPoint1, myPoint2, myPoint3, myFace, myVec1, myVec2, myLCS; DlgRef_2Sel1Spin* GroupPntDir; DlgRef_3Sel1Spin* Group3Pnts; @@ -77,7 +78,6 @@ private slots: void DeactivateActiveDialog(); void SelectionIntoArgument(); - void LineEditReturnPressed(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); void ValueChangedInSpinBox( double ); diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index f1f65dfb6..7810dcdda 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -68,6 +68,8 @@ #define SPACING 6 #define MARGIN 9 +enum { SelectEdge, SelectWire }; + //================================================================================= // class : BasicGUI_PointDlg() // purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the @@ -150,8 +152,8 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare myBtnPopup = new QMenu(this); QIcon ico_line = QIcon( image6 ); QIcon ico_wire = QIcon( image7 ); - myActions[myBtnPopup->addAction( ico_line, tr( "GEOM_EDGE" ) )] = 0; - myActions[myBtnPopup->addAction( ico_wire, tr( "GEOM_WIRE" ) )] = 1; + myActions[myBtnPopup->addAction( ico_line, tr( "GEOM_EDGE" ) )] = SelectEdge; + myActions[myBtnPopup->addAction( ico_wire, tr( "GEOM_WIRE" ) )] = SelectWire; GroupLineIntersection = new DlgRef_2Sel( centralWidget() ); GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) ); @@ -228,8 +230,11 @@ void BasicGUI_PointDlg::Init() GroupLineIntersection->LineEdit1->setEnabled( true ); GroupLineIntersection->LineEdit2->setEnabled( false ); - myEdge = GEOM::GEOM_Object::_nil(); - myRefPoint = GEOM::GEOM_Object::_nil(); + myEdge.nullify(); + myFace.nullify(); + myRefPoint.nullify(); + myLine1.nullify(); + myLine2.nullify(); myNeedType = TopAbs_VERTEX; myEditCurrentArgument = 0; @@ -273,17 +278,13 @@ void BasicGUI_PointDlg::Init() connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect( myParamCoord, SIGNAL( buttonClicked( int ) ), this, SLOT( ClickParamCoord( int ) ) ); - connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupOnSurface->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( GroupLineIntersection->PushButton1, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( GroupLineIntersection->PushButton2, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( myBtnPopup, SIGNAL( triggered( QAction* ) ), SLOT( onBtnPopup( QAction* ) ) ); - connect( GroupLineIntersection->PushButton1, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupLineIntersection->PushButton2, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupLineIntersection->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupLineIntersection->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( myBtnPopup, SIGNAL( triggered( QAction* ) ), this, SLOT( onBtnPopup( QAction* ) ) ); connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); @@ -333,7 +334,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) case GEOM_POINT_XYZ: { globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + myNeedType = TopAbs_VERTEX; + localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); GroupRefPoint->hide(); GroupOnCurve->hide(); @@ -347,11 +349,12 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) case GEOM_POINT_REF: { globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + myNeedType = TopAbs_VERTEX; + localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); myEditCurrentArgument = GroupRefPoint->LineEdit1; myEditCurrentArgument->setText( "" ); - myRefPoint = GEOM::GEOM_Object::_nil(); + myRefPoint.nullify(); GroupRefPoint->PushButton1->setDown(true); myParamGroup->hide(); GroupXYZ->hide(); @@ -365,11 +368,12 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) case GEOM_POINT_EDGE: { globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + myNeedType = TopAbs_EDGE; + localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); myEditCurrentArgument = GroupOnCurve->LineEdit1; myEditCurrentArgument->setText( "" ); - myEdge = GEOM::GEOM_Object::_nil(); + myEdge.nullify(); GroupOnCurve->PushButton1->setDown(true); GroupRefPoint->hide(); GroupLineIntersection->hide(); @@ -385,16 +389,16 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) case GEOM_POINT_INTINT: { globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); myNeedType = TopAbs_EDGE; + localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); myEditCurrentArgument = GroupLineIntersection->LineEdit1; GroupLineIntersection->LineEdit1->setText( "" ); GroupLineIntersection->LineEdit2->setText( "" ); GroupLineIntersection->LineEdit1->setEnabled( true ); GroupLineIntersection->LineEdit2->setEnabled( false ); - myLine1 = GEOM::GEOM_Object::_nil(); - myLine2 = GEOM::GEOM_Object::_nil(); + myLine1.nullify(); + myLine2.nullify(); GroupLineIntersection->PushButton1->setDown(true); GroupLineIntersection->PushButton2->setDown(false); myParamGroup->hide(); @@ -409,11 +413,12 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) case GEOM_POINT_SURF: { globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + myNeedType = TopAbs_FACE; + localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); myEditCurrentArgument = GroupOnSurface->LineEdit1; myEditCurrentArgument->setText( "" ); - myFace = GEOM::GEOM_Object::_nil(); + myFace.nullify(); GroupOnSurface->PushButton1->setDown(true); GroupRefPoint->hide(); GroupOnCurve->hide(); @@ -479,137 +484,68 @@ void BasicGUI_PointDlg::SelectionIntoArgument() myX->setText( "" ); myY->setText( "" ); myZ->setText( "" ); - myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil(); + myRefPoint.nullify(); + myEdge.nullify(); + myFace.nullify(); } else if ( id == GEOM_POINT_INTINT ) { myEditCurrentArgument->setText( "" ); if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) - myLine1 = GEOM::GEOM_Object::_nil(); + myLine1.nullify(); else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) - myLine2 = GEOM::GEOM_Object::_nil(); + myLine2.nullify(); } - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() == 1) { - Handle(SALOME_InteractiveObject) anIO = aSelList.First(); - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO ); - if ( !CORBA::is_nil( aSelectedObject ) ) { - QString aName = GEOMBase::GetName(aSelectedObject); - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - if ( id == GEOM_POINT_XYZ || id == GEOM_POINT_REF) - myNeedType = TopAbs_VERTEX; - else if ( id == GEOM_POINT_EDGE ) - myNeedType = TopAbs_EDGE; - else if ( id == GEOM_POINT_SURF ) - myNeedType = TopAbs_FACE; - - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(anIO, aMap); - if ( aMap.Extent() == 1 ) { // Local Selection - int anIndex = aMap( 1 ); - if ( myNeedType == TopAbs_FACE ) - aName += QString( ":face_%1" ).arg( anIndex ); - else if ( myNeedType == TopAbs_WIRE ) - aName += QString( ":wire_%1" ).arg( anIndex ); - else if ( myNeedType == TopAbs_EDGE ) - aName += QString( ":edge_%1" ).arg( anIndex ); - else if ( myNeedType == TopAbs_VERTEX ) - aName += QString( ":vertex_%1" ).arg( anIndex ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - if ( aFindedObject->_is_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } - GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ); - } - else { // Global Selection - if ( aShape.ShapeType() != myNeedType ) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - if ( id == GEOM_POINT_XYZ ) return; - } - } - } - - if ( aShape.IsNull() || aShape.ShapeType() != myNeedType) - return; - - myBusy = true; - - if ( id == GEOM_POINT_XYZ ) { - 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 == GEOM_POINT_REF ) { - myRefPoint = aSelectedObject; - GroupRefPoint->LineEdit1->setText( aName ); - } - else if ( id == GEOM_POINT_EDGE ) { - myEdge = aSelectedObject; - GroupOnCurve->LineEdit1->setText( aName ); - } - else if ( id == GEOM_POINT_INTINT ) { - myEditCurrentArgument->setText( aName ); - if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) { - myLine1 = aSelectedObject; - if ( !myLine1->_is_nil() && myLine2->_is_nil() ) { - GroupLineIntersection->PushButton2->setMenu( 0 ); - GroupLineIntersection->PushButton2->click(); - GroupLineIntersection->PushButton2->setDown(true); - GroupLineIntersection->PushButton2->setMenu( myBtnPopup ); - } - } - else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) { - myLine2 = aSelectedObject; - if ( !myLine2->_is_nil() && myLine1->_is_nil() ) { - GroupLineIntersection->PushButton1->setMenu( 0 ); - GroupLineIntersection->PushButton1->click(); - GroupLineIntersection->PushButton1->setDown(true); - GroupLineIntersection->PushButton1->setMenu( myBtnPopup ); - } - } + GEOM::GeomObjPtr aSelectedObject = getSelected( myNeedType ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + myBusy = true; + if ( id == GEOM_POINT_XYZ ) { + 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 == GEOM_POINT_REF ) { + myRefPoint = aSelectedObject; + GroupRefPoint->LineEdit1->setText( aName ); + } + else if ( id == GEOM_POINT_EDGE ) { + myEdge = aSelectedObject; + GroupOnCurve->LineEdit1->setText( aName ); + } + else if ( id == GEOM_POINT_INTINT ) { + myEditCurrentArgument->setText( aName ); + if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) { + myLine1 = aSelectedObject; + if ( myLine1 && !myLine2 ) { + GroupLineIntersection->PushButton2->setMenu( 0 ); + GroupLineIntersection->PushButton2->click(); + GroupLineIntersection->PushButton2->setDown(true); + GroupLineIntersection->PushButton2->setMenu( myBtnPopup ); + } } - else if ( id == GEOM_POINT_SURF ) - { - myFace = aSelectedObject; - GroupOnSurface->LineEdit1->setText( aName ); + else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) { + myLine2 = aSelectedObject; + if ( myLine2 && !myLine1 ) { + GroupLineIntersection->PushButton1->setMenu( 0 ); + GroupLineIntersection->PushButton1->click(); + GroupLineIntersection->PushButton1->setDown(true); + GroupLineIntersection->PushButton1->setMenu( myBtnPopup ); + } } - myBusy = false; } + else if ( id == GEOM_POINT_SURF ) { + myFace = aSelectedObject; + GroupOnSurface->LineEdit1->setText( aName ); + } + myBusy = false; } displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_PointDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupRefPoint->LineEdit1 || - send == GroupOnCurve->LineEdit1 || - send == GroupLineIntersection->LineEdit1 || - send == GroupLineIntersection->LineEdit2 ) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -775,49 +711,45 @@ GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation() //================================================================================= bool BasicGUI_PointDlg::isValid( QString& msg ) { - const int id = getConstructorId(); - if ( id == GEOM_POINT_XYZ ) { - bool ok = true; - ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; - return ok; - } - else if ( id == GEOM_POINT_REF ) { - bool ok = true; - ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; - - return !myRefPoint->_is_nil() && ok; - } - else if ( id == GEOM_POINT_EDGE ) { - bool ok = true; + bool ok = false; + switch ( getConstructorId() ) { + case GEOM_POINT_XYZ : + ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ); + break; + case GEOM_POINT_REF: + ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && + myRefPoint; + break; + case GEOM_POINT_EDGE: if ( myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE ) ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() ); - else { - ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; - } - return !myEdge->_is_nil() && ok; - } - else if ( id == GEOM_POINT_INTINT ) - return ( !myLine1->_is_nil() && !myLine2->_is_nil() ); - else if ( id == GEOM_POINT_SURF ) { - bool ok = true; - if ( myParamCoord->checkedId() == PARAM_VALUE ) { - ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - } - else { - ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; - } - return !myFace->_is_nil() && ok; + else + ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ); + ok = myEdge && ok; + break; + case GEOM_POINT_INTINT: + ok = myLine1 && myLine2; + break; + case GEOM_POINT_SURF: + if ( myParamCoord->checkedId() == PARAM_VALUE ) + ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ); + else + ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ); + ok = myFace && ok; + break; + default: + break; } - return false; + return ok; } //================================================================================= @@ -858,19 +790,19 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) aParameters << GroupRefPoint->SpinBox_DY->text(); aParameters << GroupRefPoint->SpinBox_DZ->text(); - anObj = anOper->MakePointWithReference( myRefPoint, dx, dy, dz ); + anObj = anOper->MakePointWithReference( myRefPoint.get(), dx, dy, dz ); res = true; break; } case GEOM_POINT_EDGE : { if ( myParamCoord->checkedId() == PARAM_VALUE ) { - anObj = anOper->MakePointOnCurve( myEdge, getParameter() ); + anObj = anOper->MakePointOnCurve( myEdge.get(), getParameter() ); aParameters<SpinBox_DX->text(); } else if ( myParamCoord->checkedId() == LENGTH_VALUE ) { bool reversed = GroupOnCurve->CheckButton1->isChecked(); - anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter(), reversed ); + anObj = anOper->MakePointOnCurveByLength( myEdge.get(), getParameter(), reversed ); aParameters<SpinBox_DX->text(); aParameters<SpinBox_DY->text(); aParameters << GroupXYZ->SpinBox_DZ->text(); - anObj = anOper->MakePointOnCurveByCoord( myEdge, x, y, z ); + anObj = anOper->MakePointOnCurveByCoord( myEdge.get(), x, y, z ); } res = true; break; } case GEOM_POINT_INTINT : - anObj = anOper->MakePointOnLinesIntersection( myLine1, myLine2 ); + anObj = anOper->MakePointOnLinesIntersection( myLine1.get(), myLine2.get() ); if ( !anObj->_is_nil() ) { QString aName = getNewObjectName(); if ( anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex") ) @@ -903,7 +835,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) case GEOM_POINT_SURF : { if ( myParamCoord->checkedId() == PARAM_VALUE ) { - anObj = anOper->MakePointOnSurface( myFace, getUParameter(), getVParameter() ); + anObj = anOper->MakePointOnSurface( myFace.get(), getUParameter(), getVParameter() ); aParameters<SpinBox_DX->text(); aParameters<SpinBox_DY->text(); } else { @@ -915,7 +847,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) aParameters << GroupXYZ->SpinBox_DY->text(); aParameters << GroupXYZ->SpinBox_DZ->text(); - anObj = anOper->MakePointOnSurfaceByCoord( myFace, x, y, z ); + anObj = anOper->MakePointOnSurfaceByCoord( myFace.get(), x, y, z ); } res = true; break; @@ -961,26 +893,23 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) //================================================================================= void BasicGUI_PointDlg::addSubshapesToStudy() { - QMap objMap; - switch ( getConstructorId() ) { - case GEOM_POINT_XYZ: - break; case GEOM_POINT_REF: - objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint; + GEOMBase::PublishSubObject( myRefPoint.get() ); break; case GEOM_POINT_EDGE: - objMap[GroupOnCurve->LineEdit1->text()] = myEdge; + GEOMBase::PublishSubObject( myEdge.get() ); break; case GEOM_POINT_INTINT: - objMap[GroupLineIntersection->LineEdit1->text()] = myLine1; - objMap[GroupLineIntersection->LineEdit2->text()] = myLine2; + GEOMBase::PublishSubObject( myLine1.get() ); + GEOMBase::PublishSubObject( myLine2.get() ); break; case GEOM_POINT_SURF: - objMap[GroupOnSurface->LineEdit1->text()] = myFace; + GEOMBase::PublishSubObject( myFace.get() ); + break; + default: break; } - addSubshapesToFather( objMap ); } //================================================================================= @@ -1041,14 +970,8 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate) //================================================================================= void BasicGUI_PointDlg::onBtnPopup( QAction* a ) { - int index = myActions[a]; globalSelection(); // close local contexts, if any - QString type; - if ( index == 0 ) - myNeedType = TopAbs_EDGE; - else - myNeedType = TopAbs_WIRE; - + myNeedType = myActions[a] == SelectEdge ? TopAbs_EDGE : TopAbs_WIRE; localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); } diff --git a/src/BasicGUI/BasicGUI_PointDlg.h b/src/BasicGUI/BasicGUI_PointDlg.h index fad9a1591..67bfae79b 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.h +++ b/src/BasicGUI/BasicGUI_PointDlg.h @@ -27,7 +27,8 @@ #ifndef BASICGUI_POINTDLG_H #define BASICGUI_POINTDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" #include class DlgRef_1Sel1Spin1Check; @@ -76,11 +77,11 @@ private: void updateParamCoord(bool theIsUpdate); private: - GEOM::GEOM_Object_var myEdge; - GEOM::GEOM_Object_var myFace; - GEOM::GEOM_Object_var myRefPoint; - GEOM::GEOM_Object_var myLine1; - GEOM::GEOM_Object_var myLine2; + GEOM::GeomObjPtr myEdge; + GEOM::GeomObjPtr myFace; + GEOM::GeomObjPtr myRefPoint; + GEOM::GeomObjPtr myLine1; + GEOM::GeomObjPtr myLine2; bool myBusy; @@ -108,7 +109,6 @@ private slots: bool ClickOnApply(); void ActivateThisDialog(); void DeactivateActiveDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); diff --git a/src/BasicGUI/BasicGUI_VectorDlg.cxx b/src/BasicGUI/BasicGUI_VectorDlg.cxx index 50cbb35e4..b05f3b093 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.cxx +++ b/src/BasicGUI/BasicGUI_VectorDlg.cxx @@ -119,8 +119,8 @@ void BasicGUI_VectorDlg::Init() /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myPoint1 = GEOM::GEOM_Object::_nil(); - myPoint2 = GEOM::GEOM_Object::_nil(); + myPoint1.nullify(); + myPoint2.nullify(); /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -150,9 +150,6 @@ void BasicGUI_VectorDlg::Init() connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupDimensions->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupDimensions->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); @@ -189,8 +186,8 @@ void BasicGUI_VectorDlg::SetDoubleSpinBoxStep( double step ) void BasicGUI_VectorDlg::ConstructorsClicked( int constructorId ) { disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); - myPoint1 = GEOM::GEOM_Object::_nil(); - myPoint2 = GEOM::GEOM_Object::_nil(); + myPoint1.nullify(); + myPoint2.nullify(); switch ( constructorId ) { case 0: @@ -272,66 +269,32 @@ bool BasicGUI_VectorDlg::ClickOnApply() void BasicGUI_VectorDlg::SelectionIntoArgument() { myEditCurrentArgument->setText( "" ); - + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); SALOME_ListIO aSelList; aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) - myPoint1 = GEOM::GEOM_Object::_nil(); + myPoint1.nullify(); else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myPoint2 = GEOM::GEOM_Object::_nil(); + myPoint2.nullify(); return; } - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if (!CORBA::is_nil(aSelectedObject) ) { - QString aName = GEOMBase::GetName(aSelectedObject); - - TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) { // Local Selection - int anIndex = aMap(1); - aName += QString(":vertex_%1").arg(anIndex); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } - } - else { // Global Selection - if (aShape.ShapeType() != TopAbs_VERTEX) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - } - + GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText(aName); - - if (!aSelectedObject->_is_nil()) { // clear selection if something selected - globalSelection(); - localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); - } - - if (myEditCurrentArgument == GroupPoints->LineEdit1) { + if (myEditCurrentArgument == GroupPoints->LineEdit1) { myPoint1 = aSelectedObject; - if (!myPoint1->_is_nil() && myPoint2->_is_nil()) + if (myPoint1 && !myPoint2) GroupPoints->PushButton2->click(); } else if (myEditCurrentArgument == GroupPoints->LineEdit2) { myPoint2 = aSelectedObject; - if (!myPoint2->_is_nil() && myPoint1->_is_nil()) + if (myPoint2 && !myPoint1) GroupPoints->PushButton1->click(); } } @@ -367,20 +330,6 @@ void BasicGUI_VectorDlg::SetEditCurrentArgument() } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_VectorDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPoints->LineEdit1 ) myEditCurrentArgument = GroupPoints->LineEdit1; - else if ( send == GroupPoints->LineEdit2 ) myEditCurrentArgument = GroupPoints->LineEdit2; - else return; - GEOMBase_Skeleton::LineEditReturnPressed(); -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -454,17 +403,16 @@ GEOM::GEOM_IOperations_ptr BasicGUI_VectorDlg::createOperation() //================================================================================= bool BasicGUI_VectorDlg::isValid( QString& msg ) { + bool ok = false; if(getConstructorId() == 0) - return !myPoint1->_is_nil() && !myPoint2->_is_nil(); + ok = myPoint1 && myPoint2; else if(getConstructorId() == 1) { - bool ok = true; - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; - return ok; + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ); } - return false; + return ok; } //================================================================================= @@ -482,7 +430,7 @@ bool BasicGUI_VectorDlg::execute( ObjectList& objects ) switch ( getConstructorId() ) { case 0 : { - anObj = anOper->MakeVectorTwoPnt( myPoint1, myPoint2 ); + anObj = anOper->MakeVectorTwoPnt( myPoint1.get(), myPoint2.get() ); res = true; break; } @@ -518,15 +466,8 @@ bool BasicGUI_VectorDlg::execute( ObjectList& objects ) //================================================================================= void BasicGUI_VectorDlg::addSubshapesToStudy() { - QMap objMap; - - switch ( getConstructorId() ) { - case 0: - objMap[GroupPoints->LineEdit1->text()] = myPoint1; - objMap[GroupPoints->LineEdit2->text()] = myPoint2; - break; - case 1: - return; + if ( getConstructorId() == 0 ) { + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); } - addSubshapesToFather( objMap ); } diff --git a/src/BasicGUI/BasicGUI_VectorDlg.h b/src/BasicGUI/BasicGUI_VectorDlg.h index 1afe50610..5a8ab1260 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.h +++ b/src/BasicGUI/BasicGUI_VectorDlg.h @@ -27,7 +27,8 @@ #ifndef BASICGUI_VECTORDLG_H #define BASICGUI_VECTORDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel; class DlgRef_3Spin1Check; @@ -55,8 +56,8 @@ private: void Init(); void enterEvent( QEvent* ); - GEOM::GEOM_Object_var myPoint1; - GEOM::GEOM_Object_var myPoint2; + GEOM::GeomObjPtr myPoint1; + GEOM::GeomObjPtr myPoint2; DlgRef_2Sel* GroupPoints; DlgRef_3Spin1Check* GroupDimensions; @@ -68,7 +69,6 @@ private slots: void ActivateThisDialog(); void DeactivateActiveDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); diff --git a/src/BlocksGUI/BlocksGUI_BlockDlg.cxx b/src/BlocksGUI/BlocksGUI_BlockDlg.cxx index 3817b4e15..0677b115f 100644 --- a/src/BlocksGUI/BlocksGUI_BlockDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_BlockDlg.cxx @@ -160,8 +160,12 @@ void BlocksGUI_BlockDlg::ConstructorsClicked (int constructorId) myConstructorId = constructorId; // init fields - myFace1 = myFace2 = GEOM::GEOM_Object::_nil(); - myFace3 = myFace4 = myFace5 = myFace6 = myFace1; + myFace1.nullify(); + myFace2.nullify(); + myFace3.nullify(); + myFace4.nullify(); + myFace5.nullify(); + myFace6.nullify(); switch (constructorId) { case 0: @@ -228,104 +232,79 @@ bool BlocksGUI_BlockDlg::ClickOnApply() void BlocksGUI_BlockDlg::SelectionIntoArgument() { erasePreview(); - myEditCurrentArgument->setText(""); - - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == Group2F->LineEdit1) myFace1 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group2F->LineEdit2) myFace2 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group6F->LineEdit1) myFace1 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group6F->LineEdit2) myFace2 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group6F->LineEdit3) myFace3 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group6F->LineEdit4) myFace4 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group6F->LineEdit5) myFace5 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group6F->LineEdit6) myFace6 = GEOM::GEOM_Object::_nil(); - return; - } - - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( CORBA::is_nil(aSelectedObject) ) - return; - - QString aName = GEOMBase::GetName(aSelectedObject); - // Get Selected object if selected subshape + GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_FACE ); TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) // Local Selection - { - int anIndex = aMap(1); - aName += QString(":face_%1").arg(anIndex); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + myEditCurrentArgument->setText( aName ); + if ( myEditCurrentArgument == Group2F->LineEdit1 ) { + myFace1 = aSelectedObject; + if (!myFace2) Group2F->PushButton2->click(); } - else // Global Selection - { - if (aShape.ShapeType() != TopAbs_FACE) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } + else if ( myEditCurrentArgument == Group2F->LineEdit2 ) { + myFace2 = aSelectedObject; + if (!myFace1) Group2F->PushButton1->click(); + } + else if ( myEditCurrentArgument == Group6F->LineEdit1 ) { + myFace1 = aSelectedObject; + if (!myFace2) Group6F->PushButton2->click(); + else if (!myFace3) Group6F->PushButton3->click(); + else if (!myFace4) Group6F->PushButton4->click(); + else if (!myFace5) Group6F->PushButton5->click(); + else if (!myFace6) Group6F->PushButton6->click(); + } + else if ( myEditCurrentArgument == Group6F->LineEdit2 ) { + myFace2 = aSelectedObject; + if (!myFace3) Group6F->PushButton3->click(); + else if (!myFace4) Group6F->PushButton4->click(); + else if (!myFace5) Group6F->PushButton5->click(); + else if (!myFace6) Group6F->PushButton6->click(); + else if (!myFace1) Group6F->PushButton1->click(); + } + else if ( myEditCurrentArgument == Group6F->LineEdit3 ) { + myFace3 = aSelectedObject; + if (!myFace4) Group6F->PushButton4->click(); + else if (!myFace5) Group6F->PushButton5->click(); + else if (!myFace6) Group6F->PushButton6->click(); + else if (!myFace1) Group6F->PushButton1->click(); + else if (!myFace2) Group6F->PushButton2->click(); + } + else if ( myEditCurrentArgument == Group6F->LineEdit4 ) { + myFace4 = aSelectedObject; + if (!myFace5) Group6F->PushButton5->click(); + else if (!myFace6) Group6F->PushButton6->click(); + else if (!myFace1) Group6F->PushButton1->click(); + else if (!myFace2) Group6F->PushButton2->click(); + else if (!myFace3) Group6F->PushButton3->click(); + } + else if ( myEditCurrentArgument == Group6F->LineEdit5 ) { + myFace5 = aSelectedObject; + if (!myFace6) Group6F->PushButton6->click(); + else if (!myFace1) Group6F->PushButton1->click(); + else if (!myFace2) Group6F->PushButton2->click(); + else if (!myFace3) Group6F->PushButton3->click(); + else if (!myFace4) Group6F->PushButton4->click(); + } + else if ( myEditCurrentArgument == Group6F->LineEdit6 ) { + myFace6 = aSelectedObject; + if (!myFace1) Group6F->PushButton1->click(); + else if (!myFace2) Group6F->PushButton2->click(); + else if (!myFace3) Group6F->PushButton3->click(); + else if (!myFace4) Group6F->PushButton4->click(); + else if (!myFace5) Group6F->PushButton5->click(); } } - - myEditCurrentArgument->setText(aName); - - if (myEditCurrentArgument == Group2F->LineEdit1) { - myFace1 = aSelectedObject; - if (!myFace1->_is_nil() && myFace2->_is_nil()) - Group2F->PushButton2->click(); - } - else if (myEditCurrentArgument == Group2F->LineEdit2) { - myFace2 = aSelectedObject; - if (!myFace2->_is_nil() && myFace1->_is_nil()) - Group2F->PushButton1->click(); - } - else if (myEditCurrentArgument == Group6F->LineEdit1) { - myFace1 = aSelectedObject; - if (!myFace1->_is_nil() && myFace2->_is_nil()) - Group6F->PushButton2->click(); - } - else if (myEditCurrentArgument == Group6F->LineEdit2) { - myFace2 = aSelectedObject; - if (!myFace2->_is_nil() && myFace3->_is_nil()) - Group6F->PushButton3->click(); - } - else if (myEditCurrentArgument == Group6F->LineEdit3) { - myFace3 = aSelectedObject; - if (!myFace3->_is_nil() && myFace4->_is_nil()) - Group6F->PushButton4->click(); - } - else if (myEditCurrentArgument == Group6F->LineEdit4) { - myFace4 = aSelectedObject; - if (!myFace4->_is_nil() && myFace5->_is_nil()) - Group6F->PushButton5->click(); - } - else if (myEditCurrentArgument == Group6F->LineEdit5) { - myFace5 = aSelectedObject; - if (!myFace5->_is_nil() && myFace6->_is_nil()) - Group6F->PushButton6->click(); - } - else if (myEditCurrentArgument == Group6F->LineEdit6) { - myFace6 = aSelectedObject; - if (!myFace6->_is_nil() && myFace1->_is_nil()) - Group6F->PushButton1->click(); + else { + if (myEditCurrentArgument == Group2F->LineEdit1) myFace1.nullify(); + else if (myEditCurrentArgument == Group2F->LineEdit2) myFace2.nullify(); + else if (myEditCurrentArgument == Group6F->LineEdit1) myFace1.nullify(); + else if (myEditCurrentArgument == Group6F->LineEdit2) myFace2.nullify(); + else if (myEditCurrentArgument == Group6F->LineEdit3) myFace3.nullify(); + else if (myEditCurrentArgument == Group6F->LineEdit4) myFace4.nullify(); + else if (myEditCurrentArgument == Group6F->LineEdit5) myFace5.nullify(); + else if (myEditCurrentArgument == Group6F->LineEdit6) myFace6.nullify(); + myEditCurrentArgument->setText( "" ); } displayPreview(); @@ -449,17 +428,15 @@ GEOM::GEOM_IOperations_ptr BlocksGUI_BlockDlg::createOperation() // function : isValid // purpose : //================================================================================= -bool BlocksGUI_BlockDlg::isValid (QString&) +bool BlocksGUI_BlockDlg::isValid(QString&) { bool ok = false; switch (getConstructorId()) { case 0: - ok = !(myFace1->_is_nil() || myFace2->_is_nil()); + ok = myFace1 && myFace2; break; case 1: - ok = !(myFace1->_is_nil() || myFace2->_is_nil() || - myFace3->_is_nil() || myFace4->_is_nil() || - myFace5->_is_nil() || myFace6->_is_nil()); + ok = myFace1 && myFace2 && myFace3 && myFace4 && myFace5 && myFace6; break; default: break; @@ -481,16 +458,14 @@ bool BlocksGUI_BlockDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: - if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2)) { - anObj = anOper->MakeHexa2Faces(myFace1, myFace2); + if ( myFace1 && myFace2 ) { + anObj = anOper->MakeHexa2Faces(myFace1.get(), myFace2.get()); res = true; } break; case 1: - if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2) && - !CORBA::is_nil(myFace3) && !CORBA::is_nil(myFace4) && - !CORBA::is_nil(myFace5) && !CORBA::is_nil(myFace6)) { - anObj = anOper->MakeHexa(myFace1, myFace2, myFace3, myFace4, myFace5, myFace6); + if ( myFace1 && myFace2 && myFace3 && myFace4 && myFace5 && myFace6 ) { + anObj = anOper->MakeHexa(myFace1.get(), myFace2.get(), myFace3.get(), myFace4.get(), myFace5.get(), myFace6.get()); res = true; } break; @@ -508,21 +483,20 @@ bool BlocksGUI_BlockDlg::execute (ObjectList& objects) //================================================================================= void BlocksGUI_BlockDlg::addSubshapesToStudy() { - QMap objMap; - switch (getConstructorId()) { case 0: - objMap[Group2F->LineEdit1->text()] = myFace1; - objMap[Group2F->LineEdit2->text()] = myFace2; + GEOMBase::PublishSubObject( myFace1.get() ); + GEOMBase::PublishSubObject( myFace2.get() ); break; case 1: - objMap[Group6F->LineEdit1->text()] = myFace1; - objMap[Group6F->LineEdit2->text()] = myFace2; - objMap[Group6F->LineEdit3->text()] = myFace3; - objMap[Group6F->LineEdit4->text()] = myFace4; - objMap[Group6F->LineEdit5->text()] = myFace5; - objMap[Group6F->LineEdit6->text()] = myFace6; + GEOMBase::PublishSubObject( myFace1.get() ); + GEOMBase::PublishSubObject( myFace2.get() ); + GEOMBase::PublishSubObject( myFace3.get() ); + GEOMBase::PublishSubObject( myFace4.get() ); + GEOMBase::PublishSubObject( myFace5.get() ); + GEOMBase::PublishSubObject( myFace6.get() ); + break; + default: break; } - addSubshapesToFather(objMap); } diff --git a/src/BlocksGUI/BlocksGUI_BlockDlg.h b/src/BlocksGUI/BlocksGUI_BlockDlg.h index 6351b6ae6..6dab6f90f 100644 --- a/src/BlocksGUI/BlocksGUI_BlockDlg.h +++ b/src/BlocksGUI/BlocksGUI_BlockDlg.h @@ -27,7 +27,8 @@ #ifndef BLOCKSGUI_BLOCKDLG_H #define BLOCKSGUI_BLOCKDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel; class DlgRef_6Sel; @@ -58,8 +59,8 @@ private: private: int myConstructorId; - GEOM::GEOM_Object_var myFace1, myFace2; - GEOM::GEOM_Object_var myFace3, myFace4, myFace5, myFace6; + GEOM::GeomObjPtr myFace1, myFace2; + GEOM::GeomObjPtr myFace3, myFace4, myFace5, myFace6; // to initialize the first selection field with a selected object on the dialog creation bool myInitial; diff --git a/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx index 6886ae2bf..008525609 100644 --- a/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx @@ -146,8 +146,10 @@ void BlocksGUI_QuadFaceDlg::ConstructorsClicked (int constructorId) myConstructorId = constructorId; // init fields - myShape1 = myShape2 = GEOM::GEOM_Object::_nil(); - myShape3 = myShape4 = myShape1; + myShape1.nullify(); + myShape2.nullify(); + myShape3.nullify(); + myShape4.nullify(); // clear line edits QMap::iterator anIterLE; @@ -226,119 +228,104 @@ void BlocksGUI_QuadFaceDlg::SelectionIntoArgument() } } - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - TopAbs_ShapeEnum aType = TopAbs_EDGE; if (aCurrFocus == Vertex1 || aCurrFocus == Vertex2 || aCurrFocus == Vertex3 || aCurrFocus == Vertex4) aType = TopAbs_VERTEX; - QString aName; - GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil(); - - if (aSelList.Extent() == 1) { - anObj = GEOMBase::ConvertIOinGEOMObject(aSelList. First() ); - if ( !anObj->_is_nil() ) { - aName = GEOMBase::GetName(anObj); - - // Get Selected object if selected subshape - TopoDS_Shape aShape; - if (GEOMBase::GetShape(anObj, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) // Local Selection - { - int anIndex = aMap(1); - if (aType == TopAbs_VERTEX) - aName += QString(":vertex_%1").arg(anIndex); - else - aName += QString(":edge_%1").arg(anIndex); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(anObj, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - anObj = aShapesOp->GetSubShape(anObj, anIndex); - } - else - anObj = aFindedObject; // get Object from study - } - else // Global Selection - { - if (aShape.ShapeType() != aType) { - anObj = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - } + GEOM::GeomObjPtr aSelectedObject = getSelected( aType ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + myEditCurrentArgument->setText( aName ); + switch (aCurrFocus) { + // four vertices + case Vertex1: + myShape1 = aSelectedObject; + if (!myShape2) mySelBtn[Vertex2]->click(); + else if (!myShape3) mySelBtn[Vertex3]->click(); + else if (!myShape4) mySelBtn[Vertex4]->click(); + break; + case Vertex2: + myShape2 = aSelectedObject; + if (!myShape3) mySelBtn[Vertex3]->click(); + else if (!myShape4) mySelBtn[Vertex4]->click(); + else if (!myShape1) mySelBtn[Vertex1]->click(); + break; + case Vertex3: + myShape3 = aSelectedObject; + if (!myShape4) mySelBtn[Vertex4]->click(); + else if (!myShape1) mySelBtn[Vertex1]->click(); + else if (!myShape2) mySelBtn[Vertex2]->click(); + break; + case Vertex4: + myShape4 = aSelectedObject; + if (!myShape1) mySelBtn[Vertex1]->click(); + else if (!myShape2) mySelBtn[Vertex2]->click(); + else if (!myShape3) mySelBtn[Vertex3]->click(); + break; + // two edges + case Edge12: + myShape1 = aSelectedObject; + if (!myShape2) mySelBtn[Edge22]->click(); + break; + case Edge22: + myShape2 = aSelectedObject; + if (!myShape1) mySelBtn[Edge12]->click(); + break; + // four edges + case Edge14: + myShape1 = aSelectedObject; + if (!myShape2) mySelBtn[Edge24]->click(); + else if (!myShape3) mySelBtn[Edge34]->click(); + else if (!myShape4) mySelBtn[Edge44]->click(); + break; + case Edge24: + myShape2 = aSelectedObject; + if (!myShape3) mySelBtn[Edge34]->click(); + else if (!myShape4) mySelBtn[Edge44]->click(); + else if (!myShape1) mySelBtn[Edge14]->click(); + break; + case Edge34: + myShape3 = aSelectedObject; + if (!myShape4) mySelBtn[Edge44]->click(); + else if (!myShape1) mySelBtn[Edge14]->click(); + else if (!myShape2) mySelBtn[Edge24]->click(); + break; + case Edge44: + myShape4 = aSelectedObject; + if (!myShape1) mySelBtn[Edge14]->click(); + else if (!myShape2) mySelBtn[Edge24]->click(); + else if (!myShape3) mySelBtn[Edge34]->click(); + break; + default: + break; } } - - myEditCurrentArgument->setText(aName); - - switch (aCurrFocus) { - // four vertices - case Vertex1: - myShape1 = anObj; - if (!myShape1->_is_nil() && myShape2->_is_nil()) - mySelBtn[Vertex2]->click(); - break; - case Vertex2: - myShape2 = anObj; - if (!myShape2->_is_nil() && myShape3->_is_nil()) - mySelBtn[Vertex3]->click(); - break; - case Vertex3: - myShape3 = anObj; - if (!myShape3->_is_nil() && myShape4->_is_nil()) - mySelBtn[Vertex4]->click(); - break; - case Vertex4: - myShape4 = anObj; - if (!myShape4->_is_nil() && myShape1->_is_nil()) - mySelBtn[Vertex1]->click(); - break; - - // two edges - case Edge12: - myShape1 = anObj; - if (!myShape1->_is_nil() && myShape2->_is_nil()) - mySelBtn[Edge22]->click(); - break; - case Edge22: - myShape2 = anObj; - if (!myShape2->_is_nil() && myShape1->_is_nil()) - mySelBtn[Edge12]->click(); - break; - - // four edges - case Edge14: - myShape1 = anObj; - if (!myShape1->_is_nil() && myShape2->_is_nil()) - mySelBtn[Edge24]->click(); - break; - case Edge24: - myShape2 = anObj; - if (!myShape2->_is_nil() && myShape3->_is_nil()) - mySelBtn[Edge34]->click(); - break; - case Edge34: - myShape3 = anObj; - if (!myShape3->_is_nil() && myShape4->_is_nil()) - mySelBtn[Edge44]->click(); - break; - case Edge44: - myShape4 = anObj; - if (!myShape4->_is_nil() && myShape1->_is_nil()) - mySelBtn[Edge14]->click(); - break; - - default: - break; + else { + switch (aCurrFocus) { + case Vertex1: + case Edge12: + case Edge14: + myShape1.nullify(); + break; + case Vertex2: + case Edge22: + case Edge24: + myShape2.nullify(); + break; + case Vertex3: + case Edge34: + myShape3.nullify(); + break; + case Vertex4: + case Edge44: + myShape4.nullify(); + break; + default: + break; + } + myEditCurrentArgument->setText( "" ); } displayPreview(); @@ -506,15 +493,13 @@ bool BlocksGUI_QuadFaceDlg::isValid (QString&) bool ok = false; switch (getConstructorId()) { case 0: - ok = (!myShape1->_is_nil() && !myShape2->_is_nil() && - !myShape3->_is_nil() && !myShape4->_is_nil()); + ok = myShape1 && myShape2 && myShape3 && myShape4; break; case 1: - ok = (!myShape1->_is_nil() && !myShape2->_is_nil()); + ok = myShape1 && myShape2; break; case 2: - ok = (!myShape1->_is_nil() && !myShape2->_is_nil() && - !myShape3->_is_nil() && !myShape4->_is_nil()); + ok = myShape1 && myShape2 && myShape3 && myShape4; break; default: break; @@ -536,15 +521,15 @@ bool BlocksGUI_QuadFaceDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: - anObj = anOper->MakeQuad4Vertices(myShape1, myShape2, myShape3, myShape4); + anObj = anOper->MakeQuad4Vertices(myShape1.get(), myShape2.get(), myShape3.get(), myShape4.get()); res = true; break; case 1: - anObj = anOper->MakeQuad2Edges(myShape1, myShape2); + anObj = anOper->MakeQuad2Edges(myShape1.get(), myShape2.get()); res = true; break; case 2: - anObj = anOper->MakeQuad(myShape1, myShape2, myShape3, myShape4); + anObj = anOper->MakeQuad(myShape1.get(), myShape2.get(), myShape3.get(), myShape4.get()); res = true; break; default: @@ -563,25 +548,24 @@ bool BlocksGUI_QuadFaceDlg::execute (ObjectList& objects) //================================================================================= void BlocksGUI_QuadFaceDlg::addSubshapesToStudy() { - QMap objMap; - switch (getConstructorId()) { case 0: - objMap[mySelName[Vertex1]->text()] = myShape1; - objMap[mySelName[Vertex2]->text()] = myShape2; - objMap[mySelName[Vertex3]->text()] = myShape3; - objMap[mySelName[Vertex4]->text()] = myShape4; + GEOMBase::PublishSubObject( myShape1.get() ); + GEOMBase::PublishSubObject( myShape2.get() ); + GEOMBase::PublishSubObject( myShape3.get() ); + GEOMBase::PublishSubObject( myShape4.get() ); break; case 1: - objMap[mySelName[Edge12]->text()] = myShape1; - objMap[mySelName[Edge22]->text()] = myShape2; + GEOMBase::PublishSubObject( myShape1.get() ); + GEOMBase::PublishSubObject( myShape2.get() ); break; case 2: - objMap[mySelName[Edge14]->text()] = myShape1; - objMap[mySelName[Edge24]->text()] = myShape2; - objMap[mySelName[Edge34]->text()] = myShape3; - objMap[mySelName[Edge44]->text()] = myShape4; + GEOMBase::PublishSubObject( myShape1.get() ); + GEOMBase::PublishSubObject( myShape2.get() ); + GEOMBase::PublishSubObject( myShape3.get() ); + GEOMBase::PublishSubObject( myShape4.get() ); + break; + default: break; } - addSubshapesToFather(objMap); } diff --git a/src/BlocksGUI/BlocksGUI_QuadFaceDlg.h b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.h index 4da07d637..957dcf23d 100644 --- a/src/BlocksGUI/BlocksGUI_QuadFaceDlg.h +++ b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.h @@ -27,7 +27,8 @@ #ifndef BLOCKSGUI_QUADFACEDLG_H #define BLOCKSGUI_QUADFACEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" #include @@ -69,10 +70,10 @@ private: private: int myConstructorId; - GEOM::GEOM_Object_var myShape1; - GEOM::GEOM_Object_var myShape2; - GEOM::GEOM_Object_var myShape3; - GEOM::GEOM_Object_var myShape4; + GEOM::GeomObjPtr myShape1; + GEOM::GeomObjPtr myShape2; + GEOM::GeomObjPtr myShape3; + GEOM::GeomObjPtr myShape4; // to initialize the first selection field with a selected object on the dialog creation bool myInitial; diff --git a/src/BooleanGUI/BooleanGUI_Dialog.cxx b/src/BooleanGUI/BooleanGUI_Dialog.cxx index 768dfdba1..e9c90ce5d 100644 --- a/src/BooleanGUI/BooleanGUI_Dialog.cxx +++ b/src/BooleanGUI/BooleanGUI_Dialog.cxx @@ -135,15 +135,13 @@ void BooleanGUI_Dialog::Init() myGroup->LineEdit1->setText(""); myGroup->LineEdit2->setText(""); - myObject1 = myObject2 = GEOM::GEOM_Object::_nil(); + myObject1.nullify(); + myObject2.nullify(); // signals and slots connections connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(myGroup->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(myGroup->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); @@ -198,21 +196,11 @@ void BooleanGUI_Dialog::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == myGroup->LineEdit1) myObject1 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2 = GEOM::GEOM_Object::_nil(); - return; - } - - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( GEOMBase::IsShape(aSelectedObject) ) - { - myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); + GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_SHAPE ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + myEditCurrentArgument->setText( aName ); // clear selection disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); @@ -222,15 +210,19 @@ void BooleanGUI_Dialog::SelectionIntoArgument() if (myEditCurrentArgument == myGroup->LineEdit1) { myObject1 = aSelectedObject; - if (myObject2->_is_nil()) + if (!myObject2) myGroup->PushButton2->click(); } else if (myEditCurrentArgument == myGroup->LineEdit2) { myObject2 = aSelectedObject; - if (myObject1->_is_nil()) + if (!myObject1) myGroup->PushButton1->click(); } } + else { + if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify(); + else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify(); + } } //================================================================================= @@ -261,19 +253,6 @@ void BooleanGUI_Dialog::SetEditCurrentArgument() send->setDown(true); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BooleanGUI_Dialog::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == myGroup->LineEdit1 || send == myGroup->LineEdit2) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -312,12 +291,7 @@ GEOM::GEOM_IOperations_ptr BooleanGUI_Dialog::createOperation() //================================================================================= bool BooleanGUI_Dialog::isValid (QString&) { - //Handle(SALOME_InteractiveObject) IO = firstIObject(); - //GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject( IO ); - //if ( anObject->_is_nil() ) - // return false; - - return !CORBA::is_nil(myObject1) && !CORBA::is_nil(myObject2); + return myObject1 && myObject2; } //================================================================================= @@ -329,7 +303,7 @@ bool BooleanGUI_Dialog::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation()); - anObj = anOper->MakeBoolean(myObject1, myObject2, myOperation); + anObj = anOper->MakeBoolean(myObject1.get(), myObject2.get(), myOperation); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); diff --git a/src/BooleanGUI/BooleanGUI_Dialog.h b/src/BooleanGUI/BooleanGUI_Dialog.h index b383f7e97..542658a51 100644 --- a/src/BooleanGUI/BooleanGUI_Dialog.h +++ b/src/BooleanGUI/BooleanGUI_Dialog.h @@ -27,7 +27,8 @@ #ifndef BOOLEANGUI_DIALOG_H #define BOOLEANGUI_DIALOG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel; @@ -58,8 +59,8 @@ private: private: int myOperation; - GEOM::GEOM_Object_var myObject1; - GEOM::GEOM_Object_var myObject2; + GEOM::GeomObjPtr myObject1; + GEOM::GeomObjPtr myObject2; DlgRef_2Sel* myGroup; @@ -68,7 +69,6 @@ private slots: bool ClickOnApply(); void SetEditCurrentArgument(); void SelectionIntoArgument(); - void LineEditReturnPressed(); void ActivateThisDialog(); }; diff --git a/src/BuildGUI/BuildGUI_CompoundDlg.cxx b/src/BuildGUI/BuildGUI_CompoundDlg.cxx index 24f18c622..3efc455a3 100644 --- a/src/BuildGUI/BuildGUI_CompoundDlg.cxx +++ b/src/BuildGUI/BuildGUI_CompoundDlg.cxx @@ -99,7 +99,7 @@ void BuildGUI_CompoundDlg::Init() myEditCurrentArgument = GroupShapes->LineEdit1; GroupShapes->LineEdit1->setReadOnly( true ); - myOkShapes = false; + myShapes.clear(); mainFrame()->GroupBoxPublish->show(); @@ -149,22 +149,13 @@ bool BuildGUI_CompoundDlg::ClickOnApply() void BuildGUI_CompoundDlg::SelectionIntoArgument() { myEditCurrentArgument->setText( "" ); - QString aString = ""; /* name of selection */ - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); + myShapes = getSelected( TopAbs_SHAPE, -1 ); - myOkShapes = false; - int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); - if ( nbSel == 0 ) - return; - if ( nbSel != 1 ) - aString = QString( "%1_objects").arg( nbSel ); - - GEOMBase::ConvertListOfIOInListOfGO(aSelList, myShapes, true); - myEditCurrentArgument->setText( aString ); - myOkShapes = true; + if ( !myShapes.isEmpty() ) { + QString aName = myShapes.count() > 1 ? QString( "%1_objects").arg( myShapes.count() ) : GEOMBase::GetName( myShapes[0].get() ); + myEditCurrentArgument->setText( aName ); + } } @@ -223,7 +214,7 @@ GEOM::GEOM_IOperations_ptr BuildGUI_CompoundDlg::createOperation() //================================================================================= bool BuildGUI_CompoundDlg::isValid( QString& ) { - return myOkShapes; + return !myShapes.isEmpty(); } //================================================================================= @@ -233,7 +224,13 @@ bool BuildGUI_CompoundDlg::isValid( QString& ) bool BuildGUI_CompoundDlg::execute( ObjectList& objects ) { GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); - GEOM::GEOM_Object_var anObj = anOper->MakeCompound( myShapes ); + + GEOM::ListOfGO_var objlist = new GEOM::ListOfGO(); + objlist->length( myShapes.count() ); + for ( int i = 0; i < myShapes.count(); i++ ) + objlist[i] = myShapes[i].copy(); + + GEOM::GEOM_Object_var anObj = anOper->MakeCompound( objlist ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); diff --git a/src/BuildGUI/BuildGUI_CompoundDlg.h b/src/BuildGUI/BuildGUI_CompoundDlg.h index 8657e6458..ffbcd864d 100644 --- a/src/BuildGUI/BuildGUI_CompoundDlg.h +++ b/src/BuildGUI/BuildGUI_CompoundDlg.h @@ -27,7 +27,8 @@ #ifndef BUILDGUI_COMPOUNDDLG_H #define BUILDGUI_COMPOUNDDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_1Sel; @@ -55,8 +56,7 @@ private: void enterEvent( QEvent* ); private: - GEOM::ListOfGO myShapes; - bool myOkShapes; + QList myShapes; DlgRef_1Sel* GroupShapes; diff --git a/src/BuildGUI/BuildGUI_EdgeDlg.cxx b/src/BuildGUI/BuildGUI_EdgeDlg.cxx index aa02e252d..c92ea226a 100644 --- a/src/BuildGUI/BuildGUI_EdgeDlg.cxx +++ b/src/BuildGUI/BuildGUI_EdgeDlg.cxx @@ -119,7 +119,9 @@ BuildGUI_EdgeDlg::~BuildGUI_EdgeDlg() void BuildGUI_EdgeDlg::Init() { // init variables - myPoint1 = myPoint2 = myWire = GEOM::GEOM_Object::_nil(); + myPoint1.nullify(); + myPoint2.nullify(); + myWire.nullify(); myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton1->setDown(true); globalSelection(); // close local contexts, if any @@ -138,10 +140,6 @@ void BuildGUI_EdgeDlg::Init() connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupWire->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupWire->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -192,8 +190,8 @@ void BuildGUI_EdgeDlg::ConstructorsClicked( int constructorId ) myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit2->setText( "" ); - myPoint1 = GEOM::GEOM_Object::_nil(); - myPoint2 = GEOM::GEOM_Object::_nil(); + myPoint1.nullify(); + myPoint2.nullify(); GroupPoints->PushButton1->setDown(true); GroupPoints->PushButton2->setDown(false); GroupPoints->LineEdit1->setEnabled(true); @@ -209,7 +207,7 @@ void BuildGUI_EdgeDlg::ConstructorsClicked( int constructorId ) myEditCurrentArgument = GroupWire->LineEdit1; GroupWire->LineEdit1->setText(""); - myWire = GEOM::GEOM_Object::_nil(); + myWire.nullify(); GroupWire->PushButton1->setDown(true); GroupWire->LineEdit1->setEnabled(true); GroupPoints->hide(); @@ -238,61 +236,31 @@ void BuildGUI_EdgeDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupWire->LineEdit1) myWire = GEOM::GEOM_Object::_nil(); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify(); + else if (myEditCurrentArgument == GroupWire->LineEdit1) myWire.nullify(); displayPreview(); return; } - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( !aSelectedObject->_is_nil() ) { - QString aName = GEOMBase::GetName( aSelectedObject ); - TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupWire->LineEdit1 ? TopAbs_WIRE : TopAbs_VERTEX; - - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes( aSelList.First(), aMap ); - if ( aMap.Extent() == 1 ) { // Local Selection - int anIndex = aMap( 1 ); - aName += ( aNeedType == TopAbs_WIRE ? QString( ":wire_%1" ).arg( anIndex ) : QString( ":vertex_%1" ).arg( anIndex ) ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); - if ( CORBA::is_nil( aFindedObject ) ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } - } - else { // Global Selection - if ( aShape.ShapeType() != aNeedType ) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - } - + TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupWire->LineEdit1 ? TopAbs_WIRE : TopAbs_VERTEX; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText( aName ); - if (!aSelectedObject->_is_nil()) { // clear selection if something selected - globalSelection(); - localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); - } + globalSelection(); + localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { myPoint1 = aSelectedObject; - if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) + if ( myPoint1 && !myPoint2 ) GroupPoints->PushButton2->click(); } else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { myPoint2 = aSelectedObject; - if ( !myPoint2->_is_nil() && myPoint1->_is_nil() ) + if ( myPoint2 && !myPoint1 ) GroupPoints->PushButton1->click(); } else if ( myEditCurrentArgument == GroupWire->LineEdit1 ) { @@ -332,19 +300,6 @@ void BuildGUI_EdgeDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BuildGUI_EdgeDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 || send == GroupWire->LineEdit1 ) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -385,13 +340,17 @@ GEOM::GEOM_IOperations_ptr BuildGUI_EdgeDlg::createOperation() bool BuildGUI_EdgeDlg::isValid (QString& msg) { bool ok = false; - if ( getConstructorId() == 0 ) { - ok = !myPoint1->_is_nil() && !myPoint2->_is_nil(); - } - else { - ok = !myWire->_is_nil(); - ok = ok && GroupWire->SpinBox_DX->isValid( msg, !IsPreview() ); - ok = ok && GroupWire->SpinBox_DY->isValid( msg, !IsPreview() ); + switch ( getConstructorId() ) { + case 0: + ok = myPoint1 && myPoint2; + break; + case 1: + ok = GroupWire->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupWire->SpinBox_DY->isValid( msg, !IsPreview() ) && + myWire; + break; + default: + break; } return ok; } @@ -410,7 +369,7 @@ bool BuildGUI_EdgeDlg::execute (ObjectList& objects) switch ( getConstructorId() ) { case 0 : { - anObj = anOper->MakeEdge( myPoint1, myPoint2 ); + anObj = anOper->MakeEdge( myPoint1.get(), myPoint2.get() ); res = true; break; } @@ -423,7 +382,7 @@ bool BuildGUI_EdgeDlg::execute (ObjectList& objects) aParameters << GroupWire->SpinBox_DX->text(); aParameters << GroupWire->SpinBox_DY->text(); - anObj = anOper->MakeEdgeWire( myWire, aLinearTolerance, anAngularTolerance ); + anObj = anOper->MakeEdgeWire( myWire.get(), aLinearTolerance, anAngularTolerance ); if ( !anObj->_is_nil() && !IsPreview() ) anObj->SetParameters( aParameters.join(":").toLatin1().constData() ); @@ -444,15 +403,15 @@ bool BuildGUI_EdgeDlg::execute (ObjectList& objects) //================================================================================= void BuildGUI_EdgeDlg::addSubshapesToStudy() { - QMap objMap; switch ( getConstructorId() ) { case 0 : - objMap[GroupPoints->LineEdit1->text()] = myPoint1; - objMap[GroupPoints->LineEdit2->text()] = myPoint2; + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); break; case 1 : - objMap[GroupWire->LineEdit1->text()] = myWire; + GEOMBase::PublishSubObject( myWire.get() ); + break; + default: break; } - addSubshapesToFather( objMap ); } diff --git a/src/BuildGUI/BuildGUI_EdgeDlg.h b/src/BuildGUI/BuildGUI_EdgeDlg.h index f6e09236f..9ead7e356 100644 --- a/src/BuildGUI/BuildGUI_EdgeDlg.h +++ b/src/BuildGUI/BuildGUI_EdgeDlg.h @@ -27,7 +27,8 @@ #ifndef BUILDGUI_EDGEDLG_H #define BUILDGUI_EDGEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_1Sel2Spin; class DlgRef_2Sel; @@ -56,8 +57,8 @@ private: void enterEvent( QEvent* ); private: - GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the edge */ - GEOM::GEOM_Object_var myWire; /* Wire */ + GEOM::GeomObjPtr myPoint1, myPoint2; /* Points containing the edge */ + GEOM::GeomObjPtr myWire; /* Wire */ DlgRef_2Sel* GroupPoints; DlgRef_1Sel2Spin* GroupWire; @@ -67,7 +68,6 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); }; diff --git a/src/BuildGUI/BuildGUI_FaceDlg.cxx b/src/BuildGUI/BuildGUI_FaceDlg.cxx index 8f204e411..09d682fe2 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.cxx +++ b/src/BuildGUI/BuildGUI_FaceDlg.cxx @@ -101,6 +101,7 @@ void BuildGUI_FaceDlg::Init() GroupWire->LineEdit1->setReadOnly( true ); GroupWire->CheckButton1->setChecked( true ); + myWires.clear(); TColStd_MapOfInteger aMap; aMap.Add( GEOM_EDGE ); @@ -152,26 +153,15 @@ bool BuildGUI_FaceDlg::ClickOnApply() void BuildGUI_FaceDlg::SelectionIntoArgument() { myEditCurrentArgument->setText( "" ); - QString aName; - - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName); - - if ( aNbSel < 1) { - myWires.length(0); - return; + QList types; + types << TopAbs_EDGE << TopAbs_WIRE; + myWires = getSelected( types, -1 ); + + if ( !myWires.isEmpty() ) { + QString aName = myWires.count() > 1 ? QString( "%1_objects").arg( myWires.count() ) : GEOMBase::GetName( myWires[0].get() ); + myEditCurrentArgument->setText( aName ); } - - GEOMBase::ConvertListOfIOInListOfGO(aSelList, myWires); - if ( !myWires.length() ) - return; - if ( aNbSel != 1 ) - aName = tr( "%1_objects" ).arg( aNbSel ); - - myEditCurrentArgument->setText( aName ); } @@ -238,7 +228,7 @@ GEOM::GEOM_IOperations_ptr BuildGUI_FaceDlg::createOperation() //================================================================================= bool BuildGUI_FaceDlg::isValid( QString& ) { - return ( myWires.length() != 0 ); + return !myWires.isEmpty(); } //================================================================================= @@ -248,7 +238,13 @@ bool BuildGUI_FaceDlg::isValid( QString& ) bool BuildGUI_FaceDlg::execute( ObjectList& objects ) { GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); - GEOM::GEOM_Object_var anObj = anOper->MakeFaceWires( myWires, GroupWire->CheckButton1->isChecked() ); + + GEOM::ListOfGO_var objlist = new GEOM::ListOfGO(); + objlist->length( myWires.count() ); + for ( int i = 0; i < myWires.count(); i++ ) + objlist[i] = myWires[i].copy(); + + GEOM::GEOM_Object_var anObj = anOper->MakeFaceWires( objlist.in(), GroupWire->CheckButton1->isChecked() ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); diff --git a/src/BuildGUI/BuildGUI_FaceDlg.h b/src/BuildGUI/BuildGUI_FaceDlg.h index 744a2c503..8e816cc2a 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.h +++ b/src/BuildGUI/BuildGUI_FaceDlg.h @@ -27,7 +27,8 @@ #ifndef BUILDGUI_FACEDLG_H #define BUILDGUI_FACEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_1Sel1Check; @@ -54,7 +55,7 @@ private: void enterEvent( QEvent* ); private: - GEOM::ListOfGO myWires; + QList myWires; DlgRef_1Sel1Check* GroupWire; diff --git a/src/BuildGUI/BuildGUI_ShellDlg.cxx b/src/BuildGUI/BuildGUI_ShellDlg.cxx index 3cf46a471..1a6b23f43 100644 --- a/src/BuildGUI/BuildGUI_ShellDlg.cxx +++ b/src/BuildGUI/BuildGUI_ShellDlg.cxx @@ -101,7 +101,7 @@ void BuildGUI_ShellDlg::Init() myEditCurrentArgument = GroupShell->LineEdit1; GroupShell->LineEdit1->setReadOnly( true ); - myOkFacesAndShells = false; + myFacesAndShells.clear(); TColStd_MapOfInteger aMap; aMap.Add( GEOM_SHELL ); @@ -158,25 +158,15 @@ bool BuildGUI_ShellDlg::ClickOnApply() void BuildGUI_ShellDlg::SelectionIntoArgument() { myEditCurrentArgument->setText( "" ); - QString aString; - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); + QList types; + types << TopAbs_FACE << TopAbs_SHELL << TopAbs_COMPOUND; + myFacesAndShells = getSelected( types, -1 ); - myOkFacesAndShells = false; - int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); - if ( nbSel == 0 ) - return; - if ( nbSel != 1 ) - aString = QString( "%1_objects ").arg( nbSel ); - - GEOMBase::ConvertListOfIOInListOfGO(aSelList, myFacesAndShells, true); - if ( !myFacesAndShells.length() ) - return; - - myEditCurrentArgument->setText( aString ); - myOkFacesAndShells = true; + if ( !myFacesAndShells.isEmpty() ) { + QString aName = myFacesAndShells.count() > 1 ? QString( "%1_objects").arg( myFacesAndShells.count() ) : GEOMBase::GetName( myFacesAndShells[0].get() ); + myEditCurrentArgument->setText( aName ); + } } @@ -251,7 +241,7 @@ GEOM::GEOM_IOperations_ptr BuildGUI_ShellDlg::createOperation() //================================================================================= bool BuildGUI_ShellDlg::isValid( QString& ) { - return myOkFacesAndShells; + return !myFacesAndShells.isEmpty(); } //================================================================================= @@ -261,7 +251,13 @@ bool BuildGUI_ShellDlg::isValid( QString& ) bool BuildGUI_ShellDlg::execute( ObjectList& objects ) { GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); - GEOM::GEOM_Object_var anObj = anOper->MakeShell( myFacesAndShells ); + + GEOM::ListOfGO_var objlist = new GEOM::ListOfGO(); + objlist->length( myFacesAndShells.count() ); + for ( int i = 0; i < myFacesAndShells.count(); i++ ) + objlist[i] = myFacesAndShells[i].copy(); + + GEOM::GEOM_Object_var anObj = anOper->MakeShell( objlist.in() ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); diff --git a/src/BuildGUI/BuildGUI_ShellDlg.h b/src/BuildGUI/BuildGUI_ShellDlg.h index 4e2cc255d..81e0f8d9e 100644 --- a/src/BuildGUI/BuildGUI_ShellDlg.h +++ b/src/BuildGUI/BuildGUI_ShellDlg.h @@ -27,7 +27,8 @@ #ifndef BUILDGUI_SHELLDLG_H #define BUILDGUI_SHELLDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_1Sel; @@ -54,8 +55,7 @@ private: void enterEvent( QEvent* ); private: - GEOM::ListOfGO myFacesAndShells; - bool myOkFacesAndShells;/* to check when arguments is defined */ + QList myFacesAndShells; DlgRef_1Sel* GroupShell; diff --git a/src/BuildGUI/BuildGUI_SolidDlg.cxx b/src/BuildGUI/BuildGUI_SolidDlg.cxx index 4f29cfcff..5c6ffb670 100644 --- a/src/BuildGUI/BuildGUI_SolidDlg.cxx +++ b/src/BuildGUI/BuildGUI_SolidDlg.cxx @@ -102,8 +102,8 @@ void BuildGUI_SolidDlg::Init() GroupSolid->LineEdit1->setReadOnly( true ); GroupSolid->CheckButton1->setChecked( true ); - myOkShells = false; - + myShells.clear(); + globalSelection( GEOM_SHELL ); /* signals and slots connections */ @@ -137,17 +137,6 @@ void BuildGUI_SolidDlg::ClickOnOk() //================================================================================= bool BuildGUI_SolidDlg::ClickOnApply() { - for ( int i = 0, n = myShells.length(); i< n; i++ ) { - if ( !isClosed(i)) { - QString aName = GEOMBase::GetName( myShells[i] ); - SUIT_MessageBox::warning( (QWidget*)SUIT_Session::session()->activeApplication()->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_SHAPE_UNCLOSED").arg(aName) , - QObject::tr("BUT_OK") ); - return false; - } - } - if ( !onAccept() ) return false; @@ -163,25 +152,13 @@ bool BuildGUI_SolidDlg::ClickOnApply() void BuildGUI_SolidDlg::SelectionIntoArgument() { myEditCurrentArgument->setText( "" ); - QString aString = ""; - - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - myOkShells = false; - int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString); - if ( nbSel == 0 ) - return; - if ( nbSel != 1 ) - aString = tr( "%1_objects" ).arg( nbSel ); - - GEOMBase::ConvertListOfIOInListOfGO(aSelList, myShells); - if ( !myShells.length() ) - return; - - myEditCurrentArgument->setText( aString ); - myOkShells = true; + myShells = getSelected( TopAbs_SHELL, -1 ); + + if ( !myShells.isEmpty() ) { + QString aName = myShells.count() > 1 ? QString( "%1_objects").arg( myShells.count() ) : GEOMBase::GetName( myShells[0].get() ); + myEditCurrentArgument->setText( aName ); + } } //================================================================================= @@ -248,43 +225,51 @@ GEOM::GEOM_IOperations_ptr BuildGUI_SolidDlg::createOperation() // function : isValid // purpose : //================================================================================= -bool BuildGUI_SolidDlg::isValid( QString& ) +bool BuildGUI_SolidDlg::isValid( QString& msg ) { - return myOkShells; + bool ok = !myShells.isEmpty(); + for ( int i = 0, n = myShells.count(); i < n && ok; i++ ) { + ok = isClosed( myShells[i].get() ); + if ( !ok ) + msg = QObject::tr("WRN_SHAPE_UNCLOSED").arg( GEOMBase::GetName( myShells[i].get() ) ); + } + return ok; } //================================================================================= // function : isClosed // purpose : Check the object 'i' in myShells list is closed or unclosed //================================================================================= -bool BuildGUI_SolidDlg::isClosed(int i) +bool BuildGUI_SolidDlg::isClosed( GEOM::GEOM_Object_ptr shell ) { - GEOM::GEOM_Object_var aShape = myShells[i]; + bool ok = false; + GEOM::GEOM_IKindOfShape::shape_kind aKind; GEOM::ListOfLong_var anInts; GEOM::ListOfDouble_var aDbls; - if (aShape->_is_nil()) { + if ( !CORBA::is_nil( shell ) ) { + GEOM::MeasureOpPtr anOp; + anOp.take( myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() ) ); + + // Detect kind of shape and parameters + aKind = anOp->KindOfShape(shell, anInts, aDbls); + + if ( anOp->IsDone() ) { + if ( anInts[0] == 1 ) + ok = true; + else if ( anInts[0] == 2 ) + ok = false; + } + else { + MESSAGE ("KindOfShape Operation is NOT DONE!!!"); + } + } + else { MESSAGE ("Shape is NULL!!!"); - return false; } - GEOM::GEOM_IMeasureOperations_var anOp = myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() ); - - // Detect kind of shape and parameters - aKind = anOp->KindOfShape(aShape, anInts, aDbls); - - if ( !anOp->IsDone() ) { - MESSAGE ("KindOfShape Operation is NOT DONE!!!"); - return false; - } - - if ( anInts[0] == 1 ) - return true; - else if ( anInts[0] == 2 ) - return false; - - return false; + return ok; } //================================================================================= @@ -293,19 +278,22 @@ bool BuildGUI_SolidDlg::isClosed(int i) //================================================================================= bool BuildGUI_SolidDlg::execute( ObjectList& objects ) { - bool toCreateSingleSolid = GroupSolid->CheckButton1->isChecked(); - GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); - if ( toCreateSingleSolid ) { - GEOM::GEOM_Object_var anObj = anOper->MakeSolidShells( myShells ); + if ( GroupSolid->CheckButton1->isChecked() ) { + GEOM::ListOfGO_var objlist = new GEOM::ListOfGO(); + objlist->length( myShells.count() ); + for ( int i = 0; i < myShells.count(); i++ ) + objlist[i] = myShells[i].copy(); + + GEOM::GEOM_Object_var anObj = anOper->MakeSolidShells( objlist.in() ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); } else { - for ( int i = 0, n = myShells.length(); i< n; i++ ) { - GEOM::GEOM_Object_var anObj = anOper->MakeSolidShell( myShells[ i ] ); + for ( int i = 0, n = myShells.count(); i< n; i++ ) { + GEOM::GEOM_Object_var anObj = anOper->MakeSolidShell( myShells[ i ].get() ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); diff --git a/src/BuildGUI/BuildGUI_SolidDlg.h b/src/BuildGUI/BuildGUI_SolidDlg.h index c3c58ff60..2ce9bcb96 100644 --- a/src/BuildGUI/BuildGUI_SolidDlg.h +++ b/src/BuildGUI/BuildGUI_SolidDlg.h @@ -27,7 +27,8 @@ #ifndef BUILDGUI_SOLIDDLG_H #define BUILDGUI_SOLIDDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_1Sel1Check; @@ -51,15 +52,13 @@ protected: private: void Init(); - bool isClosed(int i); + bool isClosed( GEOM::GEOM_Object_ptr shell ); void enterEvent( QEvent* ); private: - GEOM::ListOfGO myShells; - bool myOkShells; /* to check when arguments is defined and - all shells are closed */ + QList myShells; - DlgRef_1Sel1Check* GroupSolid; + DlgRef_1Sel1Check* GroupSolid; private slots: void ClickOnOk(); diff --git a/src/BuildGUI/BuildGUI_WireDlg.cxx b/src/BuildGUI/BuildGUI_WireDlg.cxx index bfb66731f..bb161e4bc 100644 --- a/src/BuildGUI/BuildGUI_WireDlg.cxx +++ b/src/BuildGUI/BuildGUI_WireDlg.cxx @@ -119,8 +119,8 @@ void BuildGUI_WireDlg::Init() GroupArgs->LineEdit1->setReadOnly( true ); GroupType->RadioButton1->setChecked(true); - myOkEdgesAndWires = false; - + myEdgesAndWires.clear(); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); /* signals and slots connections */ @@ -158,14 +158,12 @@ void BuildGUI_WireDlg::ClickOnOk() //================================================================================= bool BuildGUI_WireDlg::ClickOnApply() { - if ( !onAccept() || !myOkEdgesAndWires ) + if ( !onAccept() ) return false; initName(); TypeButtonClicked(); - myMapToStudy.clear(); - myEdgesAndWires.length(0); - myOkEdgesAndWires = false; + myEdgesAndWires.clear(); myEditCurrentArgument->setText( "" ); return true; } @@ -196,82 +194,15 @@ void BuildGUI_WireDlg::TypeButtonClicked() void BuildGUI_WireDlg::SelectionIntoArgument() { myEditCurrentArgument->setText( "" ); - QString aString = ""; /* name of selection */ - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); + QList types; + types << TopAbs_EDGE << TopAbs_WIRE; + myEdgesAndWires = getSelected( types, -1 ); - myOkEdgesAndWires = false; - int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString); - - if ( nbSel == 0 ) { - myMapToStudy.clear(); - return; + if ( !myEdgesAndWires.isEmpty() ) { + QString aName = myEdgesAndWires.count() > 1 ? QString( "%1_objects").arg( myEdgesAndWires.count() ) : GEOMBase::GetName( myEdgesAndWires[0].get() ); + myEditCurrentArgument->setText( aName ); } - - TopAbs_ShapeEnum aNeedType = TopAbs_EDGE; - if (GroupType->RadioButton2->isChecked()) - aNeedType = TopAbs_WIRE; - - std::list aList; // subshapes list - TopoDS_Shape aShape; - for (SALOME_ListIteratorOfListIO anIt (aSelList); anIt.More(); anIt.Next()) { - TColStd_IndexedMapOfInteger aMap; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value() ); - if ( !CORBA::is_nil(aSelectedObject) && GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - aSelMgr->GetIndexes( anIt.Value(), aMap ); - - if ( aMap.Extent() > 0 ) { // local selection - for (int ind = 1; ind <= aMap.Extent(); ind++) { - aString = aSelectedObject->GetName(); - int anIndex = aMap(ind); - if ( aNeedType == TopAbs_EDGE ) - aString += QString( ":edge_%1" ).arg( anIndex ); - else - aString += QString( ":wire_%1" ).arg( anIndex ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aString ); - - if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - aList.push_back( aShapesOp->GetSubShape( aSelectedObject, anIndex ) ); - myMapToStudy[aString] = aShapesOp->GetSubShape( aSelectedObject, anIndex ); - } - else { - aList.push_back( aFindedObject ); // get Object from study - } - } - } else { // global selection - if ( aShape.ShapeType() == aNeedType ) { - GEOMBase::ConvertListOfIOInListOfGO(aSelList, myEdgesAndWires); - } else { - aList.clear(); - myEdgesAndWires.length(0); - } - } - } - } - - // convert aList in listofgo - if ( aList.size() ) { - myEdgesAndWires.length( aList.size() ); - int k = 0; - for ( std::list::iterator j = aList.begin(); j != aList.end(); j++ ) - myEdgesAndWires[k++] = *j; - } - - if ( myEdgesAndWires.length() > 1 ) - aString = tr( "%1_objects" ).arg( myEdgesAndWires.length() ); - - if ( !myEdgesAndWires.length() ) { - aString = ""; - myMapToStudy.clear(); - } - - myEditCurrentArgument->setText( aString ); - myOkEdgesAndWires = true; } @@ -340,8 +271,7 @@ GEOM::GEOM_IOperations_ptr BuildGUI_WireDlg::createOperation() //================================================================================= bool BuildGUI_WireDlg::isValid (QString& msg) { - bool ok = GroupArgs->SpinBox_DX->isValid(msg, !IsPreview()); - return myOkEdgesAndWires && ok; + return GroupArgs->SpinBox_DX->isValid(msg, !IsPreview()) && !myEdgesAndWires.isEmpty(); } //================================================================================= @@ -351,7 +281,13 @@ bool BuildGUI_WireDlg::isValid (QString& msg) bool BuildGUI_WireDlg::execute (ObjectList& objects) { GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); - GEOM::GEOM_Object_var anObj = anOper->MakeWire(myEdgesAndWires, GroupArgs->SpinBox_DX->value()); + + GEOM::ListOfGO_var objlist = new GEOM::ListOfGO(); + objlist->length( myEdgesAndWires.count() ); + for ( int i = 0; i < myEdgesAndWires.count(); i++ ) + objlist[i] = myEdgesAndWires[i].copy(); + + GEOM::GEOM_Object_var anObj = anOper->MakeWire(objlist.in(), GroupArgs->SpinBox_DX->value()); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); @@ -365,5 +301,6 @@ bool BuildGUI_WireDlg::execute (ObjectList& objects) //================================================================================= void BuildGUI_WireDlg::addSubshapesToStudy() { - addSubshapesToFather( myMapToStudy ); + for ( int i = 0; i < myEdgesAndWires.count(); i++ ) + GEOMBase::PublishSubObject( myEdgesAndWires[i].get() ); } diff --git a/src/BuildGUI/BuildGUI_WireDlg.h b/src/BuildGUI/BuildGUI_WireDlg.h index 2ebe55958..6aada55b3 100644 --- a/src/BuildGUI/BuildGUI_WireDlg.h +++ b/src/BuildGUI/BuildGUI_WireDlg.h @@ -27,7 +27,8 @@ #ifndef BUILDGUI_WIREDLG_H #define BUILDGUI_WIREDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_1Sel1Spin; class DlgRef_3Radio; @@ -56,14 +57,11 @@ private: void enterEvent( QEvent* ); private: - GEOM::ListOfGO myEdgesAndWires; - bool myOkEdgesAndWires; /* to check when arguments is defined */ + QList myEdgesAndWires; DlgRef_1Sel1Spin* GroupArgs; DlgRef_3Radio* GroupType; - QMap myMapToStudy; - private slots: void ClickOnOk(); bool ClickOnApply(); diff --git a/src/GEOMBase/GEOMBase.cxx b/src/GEOMBase/GEOMBase.cxx index 1a8bc880f..fc04203fb 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -774,13 +774,35 @@ QString GEOMBase::GetName( GEOM::GEOM_Object_ptr object ) { QString name; SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); - CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( object ); - if ( study && strcmp( IOR.in(), "" ) != 0 ) { - _PTR(SObject) aSObj( study->studyDS()->FindObjectIOR( std::string( IOR.in() ) ) ); - _PTR(GenericAttribute) anAttr; - if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") ) { - _PTR(AttributeName) aNameAttr( anAttr ); - name = aNameAttr->Value().c_str(); + + if ( !CORBA::is_nil( object ) ) { + // 1. search if object is already published in the study + CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( object ); + if ( study && strcmp( IOR.in(), "" ) != 0 ) { + _PTR(SObject) aSObj( study->studyDS()->FindObjectIOR( std::string( IOR.in() ) ) ); + _PTR(GenericAttribute) anAttr; + if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") ) { + _PTR(AttributeName) aNameAttr( anAttr ); + name = aNameAttr->Value().c_str(); + } + } + + // 2. if object is not found in the study, try default name + if ( name.isEmpty() ) { + if ( object->IsMainShape() ) { + name = GetDefaultName( "geomObj" ); + } + else { + GEOM::GEOM_Object_var mainShape = object->GetMainShape(); + if ( !CORBA::is_nil( mainShape ) ) { + GEOM::ListOfLong_var indices = object->GetSubShapeIndices(); + if ( indices->length() > 0 ) { + TopAbs_ShapeEnum type = (TopAbs_ShapeEnum)( object->GetShapeType() ); + name = QString( "%1:%2_%3" ).arg( GetName( mainShape.in() ) ) + .arg( TypeName( type ) ).arg( indices[0] ); + } + } + } } } @@ -795,3 +817,72 @@ bool GEOMBase::IsShape( GEOM::GEOM_Object_ptr object ) { return !object->_is_nil() && object->IsShape(); } + +//======================================================================= +// function : TypeName() +// purpose : Get string representation for the shape type +//======================================================================= +QString GEOMBase::TypeName( TopAbs_ShapeEnum type ) +{ + QString name = "shape"; + switch( type ) { + case TopAbs_COMPSOLID: + name = "compsolid"; break; + case TopAbs_COMPOUND: + name = "compound"; break; + case TopAbs_SOLID: + name = "solid"; break; + case TopAbs_SHELL: + name = "shell"; break; + case TopAbs_FACE: + name = "face"; break; + case TopAbs_WIRE: + name = "wire"; break; + case TopAbs_EDGE: + name = "edge"; break; + case TopAbs_VERTEX: + name = "vertex"; break; + default: + break; + } + return name; +} + +//================================================================ +// Function : GetEntry +// Purpose : Get study entry for the given object (if it is published) +//================================================================ +QString GEOMBase::GetEntry( GEOM::GEOM_Object_ptr object ) +{ + QString entry; + SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + if ( study && !CORBA::is_nil( object ) ) { + QString objIOR = GetIORFromObject( object ); + if ( !objIOR.isEmpty() ) { + _PTR(SObject) SO( study->studyDS()->FindObjectIOR( objIOR.toLatin1().constData() ) ); + if ( SO ) + entry = SO->GetID().c_str(); + } + } + return entry; +} + +//================================================================ +// Function : PublishSubObject +// Purpose : Publish sub-shape under the main object +//================================================================ +void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object ) +{ + SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + if ( study && !CORBA::is_nil( object ) ) { + _PTR(Study) studyDS = study->studyDS(); + QString entry = GetEntry( object ); + GEOM::GEOM_Object_var father = object->GetMainShape(); + QString fatherEntry = GetEntry( father ); + if ( entry.isEmpty() && !CORBA::is_nil( father ) && !fatherEntry.isEmpty() ) { + QString name = GetName( object ); + GeometryGUI::GetGeomGen()->AddInStudy( GeometryGUI::ClientStudyToStudy( studyDS ), + object, name.toLatin1().data(), father.in() ); + } + } +} diff --git a/src/GEOMBase/GEOMBase.h b/src/GEOMBase/GEOMBase.h index cce06e658..13d9ed035 100644 --- a/src/GEOMBase/GEOMBase.h +++ b/src/GEOMBase/GEOMBase.h @@ -122,7 +122,17 @@ public : /* Gets name of object */ static QString GetName( GEOM::GEOM_Object_ptr object ); + /* Check if object has shape */ static bool IsShape( GEOM::GEOM_Object_ptr object ); + + /* Get string representation of shape type */ + static QString TypeName( TopAbs_ShapeEnum type ); + + /* Get study entry for the given object */ + static QString GetEntry( GEOM::GEOM_Object_ptr object ); + + /* Publish sub-shape under the main object */ + static void PublishSubObject( GEOM::GEOM_Object_ptr object ); }; #endif // GEOMBASE_H diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index ff06a5709..079781662 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include @@ -52,6 +53,7 @@ #include #include +#include //To disable automatic genericobj management, the following line should be commented. //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx @@ -982,11 +984,6 @@ QString GEOMBase_Helper::getPrefix( GEOM::GEOM_Object_ptr theObj ) const if ( !myPrefix.isEmpty() || theObj->_is_nil() ) return myPrefix; - //TopoDS_Shape aShape; - //if ( !GEOMBase::GetShape( theObj, aShape ) ) - // return ""; - // - //long aType = aShape.ShapeType(); GEOM::shape_type aType = theObj->GetShapeType(); switch ( aType ) @@ -1074,6 +1071,43 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather (GEOM::GEOM_Object_ptr return GEOM::GEOM_Object::_nil(); } +//================================================================ +// Function : findObjectInFather +// Purpose : It should return an object if its founded in study or +// return Null object if the object is not founded +//================================================================ +GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather( GEOM::GEOM_Object_ptr theFather, + int theIndex ) +{ + GEOM::GEOM_Object_var object; + bool found = false; + + SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + if ( study ) { + _PTR(Study) studyDS = study->studyDS(); + QString IOR = GEOMBase::GetIORFromObject( theFather ); + _PTR(SObject) sobject( studyDS->FindObjectIOR( IOR.toLatin1().constData() ) ); + if ( sobject ) { + _PTR(ChildIterator) it( studyDS->NewChildIterator( sobject ) ); + for ( ; it->More() && !found; it->Next() ) { + GEOM::GEOM_Object_var cobject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( it->Value() ) ); + if ( !CORBA::is_nil( cobject ) ) { + GEOM::ListOfLong_var indices = cobject->GetSubShapeIndices(); + int length = indices->length(); + for ( int i = 0; i < length && !found; i++ ) { + if ( indices[i] == theIndex ) { + object = cobject; + found = true; + } + } + } + } + } + } + + return object._retn(); +} + //================================================================ // Function : addSubshapesToStudy // Purpose : Virtual method to add subshapes if needs @@ -1084,28 +1118,172 @@ void GEOMBase_Helper::addSubshapesToStudy() } //================================================================ -// Function : addSubshapesToFather -// Purpose : Method to add Father Subshapes to Study if it`s not exist +// Function : getSelected +// Purpose : Get selected object by specified type +// +// Returns valid object if only one object of the specified type is selected +// (no matter global or local selection is activated). If \a type is TopAbs_SHAPE, +// geometrical object of any valid type is expected. +// +// \param type type of the object to be obtained from selection +// \return selected geometrical object or nil object if selection is not satisfactory +//================================================================ +GEOM::GeomObjPtr GEOMBase_Helper::getSelected( TopAbs_ShapeEnum type ) +{ + QList types; + types << type; + return getSelected( types ); +} + //================================================================ -void GEOMBase_Helper::addSubshapesToFather( QMap& theMap ) +// Function : getSelected +// Purpose : Get selected object by specified types +// +// Returns valid object if only one object of the specified type is selected +// (no matter global or local selection is activated). The list of allowed +// shape types is passed via \a types. If \a types includes TopAbs_SHAPE, +// geometrical object of any valid type is expected. +// +// \param types list of allowed shape types for the objects to be obtained from selection +// \return selected geometrical object or nil object if selection is not satisfactory +//================================================================ +GEOM::GeomObjPtr GEOMBase_Helper::getSelected( const QList& types ) { - //GetStudyDS - SalomeApp_Application* app = - dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); - _PTR(Study) aDStudy = appStudy->studyDS(); + QList selected = getSelected( types, 1 ); + return selected.count() > 0 ? selected[0] : GEOM::GeomObjPtr(); +} + +//================================================================ +// Function : getSelected +// Purpose : Get selected object(s) by specified type +// +// Returns list of selected objects if selection satisfies specifies selection options. +// (no matter global or local selection is activated). If \a type is TopAbs_SHAPE, +// geometrical objects of any valid type are expected. +// +// The \a type parameter specifies allowed type of the object(s) being selected. +// The \a count parameter specifies exact number of the objects to be retrieved from selection. +// The \a strict parameter specifies policy being applied to the selection. +// If \a count < 0, then any number of the selected objects is valid (including 0). +// In this case, if \a strict is \c true (default), all selected objects should satisfy +// the specified \a type. +// If \a count > 0, only specified number of the objects is retrieved from the selection. +// In this case, if \a strict is \c true (default), function returns empty list if total number of selected +// objects does not correspond to the \a count parameter. Otherwise (if \a strict is \c false), +// function returns valid list of objects if at least \a count objects satisfy specified \a type. +// +// \param type type of the object(s) to be obtained from selection +// \param count number of items to be retrieved from selection +// \param strict selection policy +// \return list of selected geometrical objects or empty list if selection is not satisfactory +//================================================================ +QList GEOMBase_Helper::getSelected( TopAbs_ShapeEnum type, int count, bool strict ) +{ + QList types; + types << type; + return getSelected( types, count, strict ); +} + +static bool typeInList( TopAbs_ShapeEnum type, const QList& types ) +{ + bool ok = false; + for ( int i = 0; i < types.count() && !ok; i++ ) + ok = types[i] == TopAbs_SHAPE || types[i] == type; + return ok; +} + +//================================================================ +// Function : getSelected +// Purpose : Get selected objects by specified types +// +// Returns list of selected objects if selection satisfies specifies selection options. +// (no matter global or local selection is activated). If \a types includes TopAbs_SHAPE, +// geometrical objects of any valid type are expected. +// +// The \a types parameter specifies allowed types of the object(s) being selected. +// The \a count parameter specifies exact number of the objects to be retrieved from selection. +// The \a strict parameter specifies policy being applied to the selection. +// If \a count < 0, then any number of the selected objects is valid (including 0). +// In this case, if \a strict is \c true (default), all selected objects should satisfy +// the specified \a type. +// If \a count > 0, only specified number of the objects is retrieved from the selection. +// In this case, if \a strict is \c true (default), function returns empty list if total number of selected +// objects does not correspond to the \a count parameter. Otherwise (if \a strict is \c false), +// function returns valid list of objects if at least \a count objects satisfy specified \a type. +// +// \param types list of allowed shape types for the objects to be obtained from selection +// \param count number of items to be retrieved from selection +// \param strict selection policy +// \return list of selected geometrical objects or empty list if selection is not satisfactory +//================================================================ +QList GEOMBase_Helper::getSelected( const QList& types, int count, bool strict ) +{ + SUIT_Session* session = SUIT_Session::session(); + QList result; - for( QMap::Iterator it = theMap.begin(); it != theMap.end(); it++ ) { - GEOM::GEOM_Object_var aFatherObj = it.value()->GetMainShape(); - if ( !aFatherObj->_is_nil() ) { - QString aFatherEntry = getEntry( aFatherObj ); - if ( aFatherEntry != "") { // additional checking that object is valid 0020598 EDF 1191 - GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aFatherObj, it.key().toLatin1().data() ); - //Add Object to study if its not exist - if ( aFindedObject->_is_nil() ) - GeometryGUI::GetGeomGen()->AddInStudy(GeometryGUI::ClientStudyToStudy(aDStudy), - it.value(), it.key().toLatin1().data(), aFatherObj ); + SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); + if ( app ) { + LightApp_SelectionMgr* selMgr = app->selectionMgr(); + if ( selMgr ) { + SALOME_ListIO selected; + selMgr->selectedObjects( selected ); + SALOME_ListIteratorOfListIO it( selected ); + bool stopped = false; + for ( ; it.More() && !stopped; it.Next() ) { + Handle(SALOME_InteractiveObject) IO = it.Value(); + GEOM::GeomObjPtr object = GEOMBase::ConvertIOinGEOMObject( IO ); + if ( object ) { + TColStd_IndexedMapOfInteger subShapes; + selMgr->GetIndexes( IO, subShapes ); + int nbSubShapes = subShapes.Extent(); + if ( nbSubShapes == 0 ) { + // global selection + if ( typeInList( (TopAbs_ShapeEnum)(object->GetShapeType()), types ) ) { + result << object; + if ( count > 0 ) { + if ( strict && result.count() > count ) { + result.clear(); + stopped = true; + } + else if ( !strict && result.count() == count ) + stopped = true; + } + } + else if ( strict ) { + result.clear(); + stopped = true; + } + } + else { + // local selection + for ( int i = 1; i <= nbSubShapes && !stopped; i++ ) { + int idx = subShapes( i ); + GEOM::GeomObjPtr subShape = findObjectInFather( object.get(), idx ); + if ( !subShape ) { + // sub-shape is not yet published in the study + GEOM::ShapesOpPtr shapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); + subShape.take( shapesOp->GetSubShape( object.get(), idx ) ); // take ownership! + } + if ( typeInList( (TopAbs_ShapeEnum)(subShape->GetShapeType()), types ) ) { + result << subShape; + if ( count > 0 ) { + if ( strict && result.count() > count ) { + result.clear(); + stopped = true; + } + else if ( !strict && result.count() == count ) + stopped = true; + } + } + else if ( strict ) { + result.clear(); + stopped = true; + } + } + } + } } } } + return result; } diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index 0a3fc2914..4faf7b88c 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -28,6 +28,7 @@ #define GEOMBASE_HELPER_H #include "GEOM_GEOMBase.hxx" +#include "GEOM_GenericObjPtr.h" #include #include @@ -166,9 +167,13 @@ protected: virtual void addSubshapesToStudy(); GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, const QString& theName ); - //This Metod to find SubObject in theFather Object by Name (theName) + GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, int theIndex ); + // These methods are used to find published sub-object (sub-shape) in the parent object (main shape) - void addSubshapesToFather( QMap& theMap ); + GEOM::GeomObjPtr getSelected( TopAbs_ShapeEnum type ); + GEOM::GeomObjPtr getSelected( const QList& types ); + QList getSelected( TopAbs_ShapeEnum type, int count, bool strict = true ); + QList getSelected( const QList& types, int count, bool strict = true ); void SetIsPreview(const bool thePreview) {isPreview = thePreview;} bool IsPreview() {return isPreview;} diff --git a/src/GEOMBase/GEOM_GenericObjPtr.cxx b/src/GEOMBase/GEOM_GenericObjPtr.cxx new file mode 100644 index 000000000..649cad499 --- /dev/null +++ b/src/GEOMBase/GEOM_GenericObjPtr.cxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// 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 +// +// File : GEOM_GenericObjPtr.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#include "GEOM_GenericObjPtr.h" + +namespace GEOM +{ + template<> bool GenericObjPtr::isSame( GEOM::GEOM_Object_ptr theLeft, GEOM::GEOM_Object_ptr theRight ) + { + return !CORBA::is_nil( theLeft ) && !CORBA::is_nil( theRight ) && theLeft->IsSame( theRight ); + } +} diff --git a/src/GEOMBase/GEOM_GenericObjPtr.h b/src/GEOMBase/GEOM_GenericObjPtr.h new file mode 100644 index 000000000..61d017970 --- /dev/null +++ b/src/GEOMBase/GEOM_GenericObjPtr.h @@ -0,0 +1,234 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// 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 +// +// File : GEOM_GenericObjPtr.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#ifndef GEOM_GenericObjPtr_H +#define GEOM_GenericObjPtr_H + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(GEOM_Gen) + +namespace GEOM +{ + /*! + \class GenericObjPtr + \brief A smart pointer for the SALOME GenericObj interface. + + This class can be used in conjunction with the references to the CORBA objects which + interfaces are inherited from the SALOME::GenericObj CORBA interface. + + The smart pointer class automatically invokes Register() / Destroy() functions of th + interface in order to prevent memory leaks and other such problems caused by improper + usage of the CORBA references. + + Smart pointers can be easily copied, stored within class as data members, passed to the + functions requiring native CORBA reference as parameters, etc. + + Usage: + - If you want to assign the smart pointer to the CORBA _var type variable, use copy() + function to make a copy of the stored CORBA object. Otherwise you might cause Segmentation + Fault error. + - To pass the smart pointer to the function that requires CORBA _ptr type parameter, + use get() function. + - If you want to take an ownership on the CORBA object, use take() function. + In case of SALOME Generic object this is useful when some function returns newly created + object that should be removed by the caller as soon as the object is no more required. + For example, function GetSubShape() of the GEOM_IShapesOperation interface always creates + new servant object and returns new object reference to it. If the object is not published + in the study, it has to be destroyed and the coresponding servant should be deleted. + + Examples: + \code + typedef GEOM::GenericObjPtr MyIPtr; + void MyInterface_ptr foo(); + void MyInterface_ptr bar( MyInterface_ptr p ); + + MyIPtr v1; // create empty (nil) pointer + MyIPtr v2 = foo(); // get some CORBA reference and store it within the smart pointer + v1 = v2; // copy smart pointer (reference counter is incremented) + v2 = bar( v1.get() ); // pass smart pointer to the function + MyInterface_var var = v2.copy(); // initialize _var variable with the smart pointer contents + v1.take( foo() ); // take ownership on the newly created object + \endcode + */ + + template class GenericObjPtr + { + typedef typename TInterface::_var_type TInterfaceVar; + typedef typename TInterface::_ptr_type TInterfacePtr; + + private: + TInterfaceVar myObject; + + private: + //! Increment counter for the object. + void Register() + { + if ( !CORBA::is_nil( this->myObject ) ) + this->myObject->Register(); + } + + //! Decrement counter for the object. + void Destroy() + { + if ( !CORBA::is_nil( this->myObject ) ) { + this->myObject->Destroy(); + this->myObject = TInterface::_nil(); + } + } + + public: + //! Initialize pointer to nil generic object reference. + GenericObjPtr() + {} + + //! Initialize pointer to the given generic object reference. + GenericObjPtr( TInterfacePtr theObject ) + { + this->myObject = TInterface::_duplicate( theObject ); + this->Register(); + } + + //! Initialize pointer with a new reference to the same object referenced by given pointer. + GenericObjPtr( const GenericObjPtr& thePointer ) + { + this->myObject = thePointer.myObject; + this->Register(); + } + + //! Destroy pointer and remove the reference to the object. + ~GenericObjPtr() + { + this->Destroy(); + } + + //! Assign object to reference and remove reference to an old object. + GenericObjPtr& operator=( TInterfacePtr theObject ) + { + this->Destroy(); + this->myObject = TInterface::_duplicate( theObject ); + this->Register(); + return *this; + } + + //! Assign object to reference and remove reference to an old object. + GenericObjPtr& operator=( const GenericObjPtr& thePointer ) + { + this->Destroy(); + this->myObject = thePointer.myObject; + this->Register(); + return *this; + } + + static bool isSame( TInterfacePtr theLeft, TInterfacePtr theRight ) + { + return theLeft->_is_equivalent( theRight ); + } + + //! Check equivalence + bool operator==( TInterfacePtr theObject ) + { + return isSame( this->myObject, theObject ); + } + + //! Check equivalence + bool operator==( const GenericObjPtr& thePointer ) + { + return isSame( this->myObject, thePointer.get() );; + } + + //! Check difference + bool operator!=( TInterfacePtr theObject ) + { + return !isSame( this->myObject, theObject ); + } + + //! Check difference + bool operator!=( const GenericObjPtr& thePointer ) + { + return !isSame( this->myObject, thePointer.get() );; + } + + //! Provides normal pointer target member access using operator ->. + TInterfacePtr operator->() const + { + return this->get(); + } + + //! Check validity of the pointer. + operator bool() const + { + return !this->isNull(); + } + + //! Initialize pointer to the given generic object reference and take ownership on it. + void take( TInterfacePtr theObject ) + { + this->Destroy(); + this->myObject = TInterface::_duplicate( theObject ); + } + + //! Get the contained object. + TInterfacePtr get() const + { + return this->myObject; + } + + //! Make the copy of the contained object and return it (caller becomes owner of the CORBA reference). + TInterfacePtr copy() const + { + return TInterface::_duplicate( this->myObject ); + } + + //! Check if pointer is null. + bool isNull() const + { + return CORBA::is_nil( this->myObject ); + } + + //! Nullify pointer. + void nullify() + { + this->Destroy(); + } + }; + + typedef GenericObjPtr GeomObjPtr; + typedef GenericObjPtr BasicOpPtr; + typedef GenericObjPtr TransformOpPtr; + typedef GenericObjPtr I3DPrimOpPtr; + typedef GenericObjPtr ShapesOpPtr; + typedef GenericObjPtr BlocksOpPtr; + typedef GenericObjPtr BooleanOpPtr; + typedef GenericObjPtr CurvesOpPtr; + typedef GenericObjPtr LocalOpPtr; + typedef GenericObjPtr HealingOpPtr; + typedef GenericObjPtr InsertOpPtr; + typedef GenericObjPtr MeasureOpPtr; + typedef GenericObjPtr GroupOpPtr; + typedef GenericObjPtr AdvancedOpPtr; + + template<> bool GenericObjPtr::isSame( GEOM::GEOM_Object_ptr theLeft, GEOM::GEOM_Object_ptr theRight ); +} + +#endif // GEOM_GenericObjPtr_H diff --git a/src/GEOMBase/Makefile.am b/src/GEOMBase/Makefile.am index 9d45bc750..c5cbe96c3 100644 --- a/src/GEOMBase/Makefile.am +++ b/src/GEOMBase/Makefile.am @@ -33,13 +33,15 @@ salomeinclude_HEADERS = \ GEOMBase_Skeleton.h \ GEOMBase_Helper.h \ GEOM_Operation.h \ - GEOM_GEOMBase.hxx + GEOM_GEOMBase.hxx \ + GEOM_GenericObjPtr.h dist_libGEOMBase_la_SOURCES = \ GEOMBase.cxx \ GEOMBase_Skeleton.cxx \ GEOMBase_Helper.cxx \ - GEOM_Operation.cxx + GEOM_Operation.cxx \ + GEOM_GenericObjPtr.cxx MOC_FILES = \ GEOMBase_Skeleton_moc.cxx diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx index 930aedc65..7223d4b1d 100644 --- a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx @@ -105,15 +105,6 @@ void GenerationGUI_FillingDlg::Init() myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly( true ); - myMinDeg = 2; - myMaxDeg = 5; - myTol3D = 0.0001; - myTol2D = 0.0001; - myNbIter = 0; - myMethod = 0; - myIsApprox = false; - myOkCompound = false; - globalSelection( GEOM_COMPOUND ); int SpecificStep1 = 1; @@ -125,11 +116,11 @@ void GenerationGUI_FillingDlg::Init() initSpinBox( GroupPoints->SpinBox4, 1, MAX_NUMBER, SpecificStep1 ); initSpinBox( GroupPoints->SpinBox5, 0.00001, 10000.0, SpecificStep2, "len_tol_precision" ); - GroupPoints->SpinBox1->setValue( myMinDeg ); - GroupPoints->SpinBox2->setValue( myTol2D ); - GroupPoints->SpinBox3->setValue( myNbIter ); - GroupPoints->SpinBox4->setValue( myMaxDeg ); - GroupPoints->SpinBox5->setValue( myTol3D ); + GroupPoints->SpinBox1->setValue( 2 ); + GroupPoints->SpinBox2->setValue( 0.0001 ); + GroupPoints->SpinBox3->setValue( 0 ); + GroupPoints->SpinBox4->setValue( 5 ); + GroupPoints->SpinBox5->setValue( 0.0001 ); GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_DEFAULT")); GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_USEORI")); @@ -140,7 +131,6 @@ void GenerationGUI_FillingDlg::Init() connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(MethodChanged())); @@ -208,37 +198,19 @@ void GenerationGUI_FillingDlg::SelectionIntoArgument() erasePreview(); myEditCurrentArgument->setText(""); - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) - myOkCompound = false; - return; - } - - // nbSel == 1 - GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( CORBA::is_nil( aSelectedObject ) ) - return; - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - TopoDS_Shape S; - myOkCompound = false; - - if (GEOMBase::GetShape(aSelectedObject, S) && S.ShapeType() == TopAbs_COMPOUND) { - // myCompound should be a compound of edges - for (TopoDS_Iterator it (S); it.More(); it.Next()) - if ( it.Value().ShapeType() != TopAbs_EDGE && - it.Value().ShapeType() != TopAbs_WIRE ) - return; - myCompound = aSelectedObject; - myOkCompound = true; + myCompound = getSelected( TopAbs_COMPOUND ); + if ( myCompound ) { + if ( myCompound->GetMaxShapeType() < GEOM::WIRE || myCompound->GetMinShapeType() > GEOM::EDGE ) { + myCompound.nullify(); + } + else { + QString aName = GEOMBase::GetName( myCompound.get() ); + myEditCurrentArgument->setText( aName ); + } } } - myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); displayPreview(); } @@ -260,20 +232,6 @@ void GenerationGUI_FillingDlg::SetEditCurrentArgument() } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void GenerationGUI_FillingDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPoints->LineEdit1 ) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -305,19 +263,6 @@ void GenerationGUI_FillingDlg::enterEvent( QEvent* ) //================================================================================= void GenerationGUI_FillingDlg::ValueChangedInSpinBox( double newValue ) { - QObject* send = (QObject*)sender(); - - if ( send == GroupPoints->SpinBox1 ) - myMinDeg = int( newValue ); - else if ( send == GroupPoints->SpinBox2 ) - myTol2D = newValue; - else if ( send == GroupPoints->SpinBox3 ) - myNbIter = int(newValue); - else if ( send == GroupPoints->SpinBox4 ) - myMaxDeg = int(newValue); - else if ( send == GroupPoints->SpinBox5 ) - myTol3D = newValue; - displayPreview(); } @@ -327,7 +272,6 @@ void GenerationGUI_FillingDlg::ValueChangedInSpinBox( double newValue ) //================================================================================= void GenerationGUI_FillingDlg::MethodChanged() { - myMethod = GroupPoints->ComboBox1->currentIndex(); displayPreview(); } @@ -337,7 +281,6 @@ void GenerationGUI_FillingDlg::MethodChanged() //================================================================================= void GenerationGUI_FillingDlg::ApproxChanged() { - myIsApprox = GroupPoints->CheckBox1->isChecked(); displayPreview(); } @@ -357,14 +300,13 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_FillingDlg::createOperation() //================================================================================= bool GenerationGUI_FillingDlg::isValid( QString& msg ) { - bool ok = true; - ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints->SpinBox4->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints->SpinBox5->isValid( msg, !IsPreview() ) && ok; - - return myOkCompound > 0 && ok; + bool ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox4->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox5->isValid( msg, !IsPreview() ) && + myCompound; + return ok; } //================================================================================= @@ -386,8 +328,14 @@ bool GenerationGUI_FillingDlg::execute( ObjectList& objects ) } GEOM::GEOM_Object_var anObj = - anOper->MakeFilling( myCompound, myMinDeg, myMaxDeg, myTol2D, myTol3D, - myNbIter, aMethod, myIsApprox ); + anOper->MakeFilling( myCompound.get(), + GroupPoints->SpinBox1->value(), + GroupPoints->SpinBox4->value(), + GroupPoints->SpinBox2->value(), + GroupPoints->SpinBox5->value(), + GroupPoints->SpinBox3->value(), + aMethod, + GroupPoints->CheckBox1->isChecked() ); if ( !anObj->_is_nil() ) { if ( !IsPreview() ) diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.h b/src/GenerationGUI/GenerationGUI_FillingDlg.h index a6ebd66a9..5d73962f7 100644 --- a/src/GenerationGUI/GenerationGUI_FillingDlg.h +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.h @@ -27,7 +27,8 @@ #ifndef GENERATIONGUI_FILLINGDLG_H #define GENERATIONGUI_FILLINGDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_1Sel5Spin1Check; @@ -54,23 +55,13 @@ private: void enterEvent( QEvent* ); private: - GEOM::GEOM_Object_var myCompound; /* compound of curves */ - Standard_Integer myMinDeg; - Standard_Integer myMaxDeg; - Standard_Real myTol3D; - Standard_Real myTol2D; - Standard_Integer myNbIter; - bool myIsApprox; - int myMethod; - bool myOkCompound; /* to check when curv. compound is defined */ - + GEOM::GeomObjPtr myCompound; /* compound of curves */ DlgRef_1Sel5Spin1Check* GroupPoints; private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ValueChangedInSpinBox( double ); diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx index ca440e62d..1b75a21ab 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx @@ -114,8 +114,8 @@ void GenerationGUI_PipeDlg::Init() GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); GroupPoints->LineEdit3->setText(""); - myPath = myVec = GEOM::GEOM_Object::_nil(); - myOkBase = myOkPath = myOkVec = false; + myPath.nullify(); + myVec.nullify(); GroupPoints->CheckButton1->setEnabled(false); @@ -129,10 +129,6 @@ void GenerationGUI_PipeDlg::Init() connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(SelectionTypeButtonClicked())); initName(tr("GEOM_PIPE")); @@ -155,27 +151,27 @@ void GenerationGUI_PipeDlg::ConstructorsClicked( int constructorId ) { erasePreview(); - switch (constructorId) - { - case 0: - { - GroupPoints->TextLabel3->hide(); - GroupPoints->PushButton3->hide(); - GroupPoints->LineEdit3->hide(); - break; - } - case 1: - { - GroupPoints->TextLabel3->show(); - GroupPoints->PushButton3->show(); - GroupPoints->LineEdit3->show(); - break; - } + switch (constructorId) { + case 0: + GroupPoints->TextLabel3->hide(); + GroupPoints->PushButton3->hide(); + GroupPoints->LineEdit3->hide(); + GroupPoints->PushButton1->click(); + break; + case 1: + GroupPoints->TextLabel3->show(); + GroupPoints->PushButton3->show(); + GroupPoints->LineEdit3->show(); + break; + default: + break; } + qApp->processEvents(); updateGeometry(); resize(100,100); + SelectionIntoArgument(); displayPreview(); } @@ -195,9 +191,9 @@ void GenerationGUI_PipeDlg::SelectionTypeButtonClicked() aMap.Add(GEOM_LINE); globalSelection(aMap); } - if(myEditCurrentArgument == GroupPoints->LineEdit2) { + if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { myEditCurrentArgument->setText(""); - myOkPath = false; + myPath.nullify(); } displayPreview(); } @@ -223,7 +219,7 @@ bool GenerationGUI_PipeDlg::ClickOnApply() initName(); if ( getConstructorId() != 1 ) - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked( getConstructorId() ); // activate selection and connect selection manager GroupPoints->PushButton1->click(); return true; @@ -237,109 +233,48 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument() { erasePreview(); myEditCurrentArgument->setText(""); - if (myEditCurrentArgument == GroupPoints->LineEdit1) myOkBase = false; - else if (myEditCurrentArgument == GroupPoints->LineEdit2) myOkPath = false; - else if (myEditCurrentArgument == GroupPoints->LineEdit3) myOkVec = false; - - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() < 1) - return; - - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - QString aName = GEOMBase::GetName(aSelectedObject); - - if ( aSelectedObject->_is_nil() ) - return; - - TopoDS_Shape S; - if (!GEOMBase::GetShape(aSelectedObject, S)) - return; - - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - myOkBase = false; - GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true); - if (aSelList.Extent() > 1) - aName = QString( "%1_objects").arg( aSelList.Extent() ); - - if ( aSelList.Extent() > 0 ) { - // check base shapes - for (int i=0; i < myBaseObjects.length(); i++) { - GEOMBase::GetShape(myBaseObjects[i], S); - if (S.ShapeType() == TopAbs_COMPSOLID || - /*S.ShapeType() == TopAbs_COMPOUND ||*/ - S.ShapeType() == TopAbs_SOLID || - S.ShapeType() == TopAbs_SHAPE) - return; - if ( getConstructorId() == 1 && - (S.ShapeType() == TopAbs_SHELL || - S.ShapeType() == TopAbs_VERTEX)) - return; - } - } - myEditCurrentArgument->setText(aName); - myOkBase = true; - } else if (myEditCurrentArgument == GroupPoints->LineEdit2 || - myEditCurrentArgument == GroupPoints->LineEdit3) { - myEditCurrentArgument == GroupPoints->LineEdit2 ? myOkPath = false : myOkVec = false; - bool myOk = false; - - if (myEditCurrentArgument == GroupPoints->LineEdit2 && !GroupPoints->CheckButton1->isChecked() ){ - myPath = aSelectedObject; - myOkPath = true; - myEditCurrentArgument->setText(aName); - } else { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) { - int anIndex = aMap(1); - aName.append(":edge_" + QString::number(anIndex)); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - myOk = true; - } else { // get Object from study - aSelectedObject = aFindedObject; - myOk = true; - } - } else { - myOk = true; - if (S.ShapeType() != TopAbs_EDGE) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - myOk = false; - } - } - if (myEditCurrentArgument == GroupPoints->LineEdit2) { - myPath = aSelectedObject; - myOkPath = myOk; - } else if (myEditCurrentArgument == GroupPoints->LineEdit3) { - myVec = aSelectedObject; - myOkVec = myOk; - } - myEditCurrentArgument->setText(aName); - - if (myOkPath) { - if (!myOkBase) - GroupPoints->PushButton1->click(); - else if (!myOkVec) - GroupPoints->PushButton3->click(); - } else if (myOkVec) { - if (!myOkBase) - GroupPoints->PushButton1->click(); - else if (!myOkPath) - GroupPoints->PushButton2->click(); - } + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { + myBaseObjects.clear(); + QList objects = getSelected( TopAbs_SHAPE, -1 ); + for ( int i = 0; i < objects.count(); i++ ) { + GEOM::shape_type stype = objects[i]->GetMaxShapeType(); + GEOM::shape_type maxallowed = getConstructorId() == 1 ? GEOM::FACE : GEOM::SHELL; + GEOM::shape_type minallowed = getConstructorId() == 1 ? GEOM::EDGE : GEOM::VERTEX; + if ( stype < maxallowed || stype > minallowed ) + continue; + myBaseObjects << objects[i]; + } + if ( !myBaseObjects.isEmpty() ) { + QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() ); + myEditCurrentArgument->setText( aName ); + } + } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + QList types; + types << TopAbs_EDGE << TopAbs_WIRE; + myPath = getSelected( types ); + if ( myPath ) { + QString aName = GEOMBase::GetName( myPath.get() ); + myEditCurrentArgument->setText( aName ); + if ( getConstructorId() == 1 && !myVec ) + GroupPoints->PushButton3->click(); + else if ( myBaseObjects.isEmpty() ) + GroupPoints->PushButton1->click(); + } + } + else if (myEditCurrentArgument == GroupPoints->LineEdit3) { + myVec = getSelected( TopAbs_EDGE ); + if ( myVec ) { + QString aName = GEOMBase::GetName( myVec.get() ); + myEditCurrentArgument->setText( aName ); + if ( myBaseObjects.isEmpty() ) + GroupPoints->PushButton1->click(); + else if ( !myPath ) + GroupPoints->PushButton2->click(); } } + displayPreview(); } @@ -395,26 +330,6 @@ void GenerationGUI_PipeDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void GenerationGUI_PipeDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2 || - send == GroupPoints->LineEdit3) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } - - if (send == GroupPoints->LineEdit2) - GroupPoints->CheckButton1->setEnabled(true); - else - GroupPoints->CheckButton1->setEnabled(false); -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -453,12 +368,18 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_PipeDlg::createOperation() //================================================================================= bool GenerationGUI_PipeDlg::isValid (QString&) { + bool ok = false; switch ( getConstructorId() ) { case 0 : - return myOkBase && myOkPath; + ok = !myBaseObjects.isEmpty() && myPath; + break; case 1 : - return myOkBase && myOkPath && myOkVec; + ok = !myBaseObjects.isEmpty() && myPath && myVec; + break; + default: + break; } + return ok; } //================================================================================= @@ -467,18 +388,17 @@ bool GenerationGUI_PipeDlg::isValid (QString&) //================================================================================= bool GenerationGUI_PipeDlg::execute (ObjectList& objects) { - GEOM::GEOM_Object_var anObj, aBase; + GEOM::GEOM_Object_var anObj; GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); - for (int i=0; i < myBaseObjects.length(); i++) { - aBase = myBaseObjects[i]; + for (int i = 0; i < myBaseObjects.count(); i++) { switch ( getConstructorId() ) { case 0 : - anObj = anOper->MakePipe(aBase, myPath); + anObj = anOper->MakePipe(myBaseObjects[i].get(), myPath.get()); break; case 1 : - anObj = anOper->MakePipeBiNormalAlongVector(aBase, myPath, myVec); + anObj = anOper->MakePipeBiNormalAlongVector(myBaseObjects[i].get(), myPath.get(), myVec.get()); break; } @@ -494,11 +414,8 @@ bool GenerationGUI_PipeDlg::execute (ObjectList& objects) //================================================================================= void GenerationGUI_PipeDlg::addSubshapesToStudy() { - QMap objMap; - - objMap[GroupPoints->LineEdit2->text()] = myPath; - - addSubshapesToFather(objMap); + GEOMBase::PublishSubObject( myPath.get() ); + GEOMBase::PublishSubObject( myVec.get() ); } //================================================================================= @@ -507,5 +424,5 @@ void GenerationGUI_PipeDlg::addSubshapesToStudy() //================================================================================= bool GenerationGUI_PipeDlg::extractPrefix() const { - return myBaseObjects.length() > 1; + return myBaseObjects.count() > 1; } diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.h b/src/GenerationGUI/GenerationGUI_PipeDlg.h index 35c3316a8..bef9dd172 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.h +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.h @@ -27,7 +27,8 @@ #ifndef GENERATIONGUI_PIPEDLG_H #define GENERATIONGUI_PIPEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_3Sel1Check; @@ -56,20 +57,16 @@ private: void enterEvent( QEvent* ); private: - GEOM::ListOfGO myBaseObjects; /* Base shapes */ - GEOM::GEOM_Object_var myPath; /* Shape, defining the path */ - GEOM::GEOM_Object_var myVec; /* Vector, defining the constant binormal direction */ - bool myOkBase; - bool myOkPath; - bool myOkVec; /* to check when arguments are defined */ + QList myBaseObjects; /* Base shapes */ + GEOM::GeomObjPtr myPath; /* Shape, defining the path */ + GEOM::GeomObjPtr myVec; /* Vector, defining the constant binormal direction */ - DlgRef_3Sel1Check* GroupPoints; + DlgRef_3Sel1Check* GroupPoints; private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx index 7c3c4b1b8..1bdd4afc5 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx @@ -54,8 +54,7 @@ //================================================================================= GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl) - : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl), - myInitial(true) + : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM"))); @@ -72,7 +71,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWi mainFrame()->RadioButton3->setIcon(image3); mainFrame()->RadioButton1->setChecked(true); - myBothway = myBothway2 = myBothway3 = false; GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget()); GroupPoints->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV")); @@ -84,7 +82,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWi GroupPoints->LineEdit1->setReadOnly(true); GroupPoints->LineEdit2->setReadOnly(true); GroupPoints->CheckButton1->setText(tr("GEOM_BOTHWAY")); - GroupPoints->CheckButton1->setChecked(myBothway); GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE")); GroupPoints2 = new DlgRef_3Sel1Check(centralWidget()); @@ -96,7 +93,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWi GroupPoints2->PushButton2->setIcon(image1); GroupPoints2->PushButton3->setIcon(image1); GroupPoints2->CheckButton1->setText(tr("GEOM_BOTHWAY")); - GroupPoints2->CheckButton1->setChecked(myBothway2); GroupPoints3 = new DlgRef_1Sel3Spin1Check(centralWidget()); GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ")); @@ -106,7 +102,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWi GroupPoints3->TextLabel3->setText(tr("GEOM_DY")); GroupPoints3->TextLabel4->setText(tr("GEOM_DZ")); GroupPoints3->CheckButton1->setText(tr("GEOM_BOTHWAY")); - GroupPoints3->CheckButton1->setChecked(myBothway3); QVBoxLayout* layout = new QVBoxLayout(centralWidget()); layout->setMargin(0); layout->setSpacing(6); @@ -170,8 +165,10 @@ void GenerationGUI_PrismDlg::Init() GroupPoints3->LineEdit1->setText(""); - myPoint1 = myPoint2 = myVec = GEOM::GEOM_Object::_nil(); - myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false; + myBaseObjects.clear(); + myPoint1.nullify(); + myPoint2.nullify(); + myVec.nullify(); // signals and slots connections connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -182,10 +179,7 @@ void GenerationGUI_PrismDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway())); @@ -194,18 +188,13 @@ void GenerationGUI_PrismDlg::Init() connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints2->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway())); - - connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints2->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway())); - connect(GroupPoints3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); - connect(GroupPoints3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); - connect(GroupPoints3->SpinBox_DZ, SIGNAL(valueChanged (double)), this, SLOT(ValueChangedInSpinBox())); - connect(GroupPoints3->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway())); + connect(GroupPoints3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints3->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway())); initName(tr("GEOM_EXTRUSION")); @@ -230,49 +219,38 @@ void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep (double step) //================================================================================= void GenerationGUI_PrismDlg::ConstructorsClicked (int constructorId) { - disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - switch (constructorId) { case 0: - { - GroupPoints2->hide(); - GroupPoints3->hide(); - GroupPoints->show(); - - GroupPoints->LineEdit1->setText(GroupPoints2->LineEdit1->text()); // keep base - GroupPoints->LineEdit2->setText(""); - myVec = GEOM::GEOM_Object::_nil(); - myOkVec = false; - - GroupPoints->PushButton1->click(); - break; - } + GroupPoints2->hide(); + GroupPoints3->hide(); + GroupPoints->show(); + + GroupPoints->LineEdit2->setText(""); + myVec.nullify(); + + GroupPoints->PushButton1->click(); + break; case 1: - { - GroupPoints->hide(); - GroupPoints2->show(); - GroupPoints3->hide(); - - GroupPoints2->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base - GroupPoints2->LineEdit2->setText(""); - GroupPoints2->LineEdit3->setText(""); - myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); - myOkPnt1 = myOkPnt2 = false; - - GroupPoints2->PushButton1->click(); - break; - } + GroupPoints->hide(); + GroupPoints2->show(); + GroupPoints3->hide(); + + GroupPoints2->LineEdit2->setText(""); + GroupPoints2->LineEdit3->setText(""); + myPoint1.nullify(); + myPoint2.nullify(); + + GroupPoints2->PushButton1->click(); + break; case 2: - { - GroupPoints->hide(); - GroupPoints2->hide(); - GroupPoints3->show(); - - GroupPoints3->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base - - GroupPoints3->PushButton1->click(); - break; - } + GroupPoints->hide(); + GroupPoints2->hide(); + GroupPoints3->show(); + + GroupPoints3->PushButton1->click(); + break; + default: + break; } qApp->processEvents(); @@ -317,146 +295,58 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() erasePreview(); myEditCurrentArgument->setText(""); - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - QString aBaseName = ""; /* name of base object selection */ - int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aBaseName, true); - - if (nbSel > 1) - aBaseName = QString( "%1_objects").arg( nbSel ); - - // Base Object(s) selected - if (myEditCurrentArgument == GroupPoints->LineEdit1 || - myEditCurrentArgument == GroupPoints2->LineEdit1 || - getConstructorId() == 2 ) { - myOkBase = false; - if ( nbSel > 0 ) { - GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true); - myEditCurrentArgument->setText( aBaseName ); - myOkBase = true; + if ( myEditCurrentArgument == GroupPoints->LineEdit1 || + myEditCurrentArgument == GroupPoints2->LineEdit1 || + myEditCurrentArgument == GroupPoints3->LineEdit1 ) { + myBaseObjects.clear(); + QList objects = getSelected( TopAbs_SHAPE, -1 ); + for ( int i = 0; i < objects.count(); i++ ) { + GEOM::shape_type stype = objects[i]->GetMaxShapeType(); + if ( stype < GEOM::SHELL || stype > GEOM::VERTEX ) + continue; + myBaseObjects << objects[i]; } - displayPreview(); - return; - } - - if (getConstructorId() == 0) - { - if (aSelList.Extent() < 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit2) - myOkVec = false; - return; + if ( !myBaseObjects.isEmpty() ) { + QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() ); + GroupPoints->LineEdit1->setText( aName ); + GroupPoints2->LineEdit1->setText( aName ); + GroupPoints3->LineEdit1->setText( aName ); } - - GEOM::GEOM_Object_var aSelectedObject = - GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( CORBA::is_nil(aSelectedObject) ) - return; - - QString aName = GEOMBase::GetName(aSelectedObject); - - // Get Selected object if selected subshape - bool myOk = true; - TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) { - int anIndex = aMap(1); - aName.append(":edge_" + QString::number(anIndex)); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } - } - else { // Global Selection - if (aShape.ShapeType() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - myOk = false; - } - } - } - - if (myEditCurrentArgument == GroupPoints->LineEdit2 && myOk) { - myEditCurrentArgument->setText(aName); - myOkVec = true; - myVec = aSelectedObject; + else { + GroupPoints->LineEdit1->setText( "" ); + GroupPoints2->LineEdit1->setText( "" ); + GroupPoints3->LineEdit1->setText( "" ); } } - else if (getConstructorId() == 1) { // getConstructorId()==1 - extrusion using 2 points - if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPoints2->LineEdit2) { - myPoint1 = GEOM::GEOM_Object::_nil(); - myOkPnt1 = false; - } - else if (myEditCurrentArgument == GroupPoints2->LineEdit3) { - myPoint2 = GEOM::GEOM_Object::_nil(); - myOkPnt2 = false; - } - return; + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { + myVec = getSelected( TopAbs_EDGE ); + if ( myVec ) { + QString aName = GEOMBase::GetName( myVec.get() ); + myEditCurrentArgument->setText( aName ); + if ( myBaseObjects.isEmpty() ) + GroupPoints->PushButton1->click(); } - - GEOM::GEOM_Object_var aSelectedObject = - GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( CORBA::is_nil(aSelectedObject) ) - return; - - QString aName = GEOMBase::GetName(aSelectedObject); - TopoDS_Shape aShape; - bool myOk = true; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) { - int anIndex = aMap(1); - aName.append(":vertex_" + QString::number(anIndex)); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; - } - } - else { - if ((aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit2) || - (aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit3)) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - myOk = false; - } - } - } - - myEditCurrentArgument->setText(aName); - - if (myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk) { - myOkPnt1 = true; - myPoint1 = aSelectedObject; - if (!myOkPnt2) - GroupPoints2->PushButton3->click(); + } + if ( myEditCurrentArgument == GroupPoints2->LineEdit2 ) { + myPoint1 = getSelected( TopAbs_VERTEX ); + if ( myPoint1 ) { + QString aName = GEOMBase::GetName( myPoint1.get() ); + myEditCurrentArgument->setText( aName ); + if ( !myPoint2 ) + GroupPoints2->PushButton3->click(); + else if ( myBaseObjects.isEmpty() ) + GroupPoints2->PushButton1->click(); } - else if (myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk) { - myOkPnt2 = true; - myPoint2 = aSelectedObject; - if (!myOkBase) - GroupPoints2->PushButton1->click(); + } + if ( myEditCurrentArgument == GroupPoints2->LineEdit3 ) { + myPoint2 = getSelected( TopAbs_VERTEX ); + if ( myPoint2 ) { + QString aName = GEOMBase::GetName( myPoint2.get() ); + myEditCurrentArgument->setText( aName ); + if ( myBaseObjects.isEmpty() ) + GroupPoints2->PushButton1->click(); + else if ( !myPoint1 ) + GroupPoints2->PushButton2->click(); } } @@ -523,24 +413,6 @@ void GenerationGUI_PrismDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void GenerationGUI_PrismDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2 || - send == GroupPoints2->LineEdit1 || - send == GroupPoints2->LineEdit2 || - send == GroupPoints2->LineEdit3 || - send == GroupPoints3->LineEdit1) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -598,24 +470,26 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation() //================================================================================= bool GenerationGUI_PrismDlg::isValid (QString& msg) { - bool ok = true; - if( getConstructorId() == 0 ) - ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - else if( getConstructorId() == 2 ) - { - ok = GroupPoints3->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints3->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints3->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; + bool ok = false; + switch ( getConstructorId() ) { + case 0: + ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && + !myBaseObjects.isEmpty() && myVec; + break; + case 1: + ok = !myBaseObjects.isEmpty() && myPoint1 && myPoint2; + break; + case 2: + ok = GroupPoints3->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupPoints3->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupPoints3->SpinBox_DZ->isValid( msg, !IsPreview() ) && + !myBaseObjects.isEmpty(); + break; + default: + break; } - if (getConstructorId() == 0) - return (myOkBase && myOkVec) && ok; // by vector and height - else if (getConstructorId() == 1) - return (myOkBase && myOkPnt1 && myOkPnt2); // by two points - else if (getConstructorId() == 2) - return myOkBase && ok; - - return false; + return ok; } //================================================================================= @@ -625,19 +499,17 @@ bool GenerationGUI_PrismDlg::isValid (QString& msg) bool GenerationGUI_PrismDlg::execute (ObjectList& objects) { QStringList aParameters; - GEOM::GEOM_Object_var anObj, aBaseObj; + GEOM::GEOM_Object_var anObj; GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); - for (int i=0; i < myBaseObjects.length(); i++) { - aBaseObj = myBaseObjects[i]; - + for (int i = 0; i < myBaseObjects.count(); i++) { switch (getConstructorId()) { case 0: - if (!myBothway) - anObj = anOper->MakePrismVecH(aBaseObj, myVec, getHeight()); + if (!GroupPoints->CheckButton1->isChecked()) + anObj = anOper->MakePrismVecH(myBaseObjects[i].get(), myVec.get(), getHeight()); else - anObj = anOper->MakePrismVecH2Ways(aBaseObj, myVec, getHeight()); + anObj = anOper->MakePrismVecH2Ways(myBaseObjects[i].get(), myVec.get(), getHeight()); if (!anObj->_is_nil() && !IsPreview()) { aParameters << GroupPoints->SpinBox_DX->text(); @@ -645,20 +517,20 @@ bool GenerationGUI_PrismDlg::execute (ObjectList& objects) } break; case 1: - if (!myBothway2) - anObj = anOper->MakePrismTwoPnt(aBaseObj, myPoint1, myPoint2); + if (!GroupPoints2->CheckButton1->isChecked()) + anObj = anOper->MakePrismTwoPnt(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get()); else - anObj = anOper->MakePrismTwoPnt2Ways(aBaseObj, myPoint1, myPoint2); + anObj = anOper->MakePrismTwoPnt2Ways(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get()); break; case 2: double dx = GroupPoints3->SpinBox_DX->value(); double dy = GroupPoints3->SpinBox_DY->value(); double dz = GroupPoints3->SpinBox_DZ->value(); - if (!myBothway3) - anObj = anOper->MakePrismDXDYDZ(aBaseObj, dx, dy, dz); + if (!GroupPoints3->CheckButton1->isChecked()) + anObj = anOper->MakePrismDXDYDZ(myBaseObjects[i].get(), dx, dy, dz); else - anObj = anOper->MakePrismDXDYDZ2Ways(aBaseObj, dx, dy, dz); + anObj = anOper->MakePrismDXDYDZ2Ways(myBaseObjects[i].get(), dx, dy, dz); if (!anObj->_is_nil() && !IsPreview()) { aParameters << GroupPoints3->SpinBox_DX->text(); @@ -692,25 +564,8 @@ void GenerationGUI_PrismDlg::onReverse() //================================================================================= void GenerationGUI_PrismDlg::onBothway() { - bool anOldValue; - switch (getConstructorId()) { - case 0: - anOldValue = myBothway; - myBothway = !anOldValue; - GroupPoints->CheckButton2->setEnabled(!myBothway); - displayPreview(); - break; - case 1: - anOldValue = myBothway2; - myBothway2 = !anOldValue; - displayPreview(); - break; - case 2: - anOldValue = myBothway3; - myBothway3 = !anOldValue; - displayPreview(); - break; - } + GroupPoints->CheckButton2->setEnabled(!GroupPoints->CheckButton1->isChecked()); + displayPreview(); } //================================================================================= @@ -719,18 +574,17 @@ void GenerationGUI_PrismDlg::onBothway() //================================================================================= void GenerationGUI_PrismDlg::addSubshapesToStudy() { - QMap objMap; - switch (getConstructorId()) { case 0: - objMap[GroupPoints->LineEdit2->text()] = myVec; + GEOMBase::PublishSubObject( myVec.get() ); break; case 1: - objMap[GroupPoints2->LineEdit2->text()] = myPoint1; - objMap[GroupPoints2->LineEdit3->text()] = myPoint2; + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); + break; + default: break; } - addSubshapesToFather(objMap); } //================================================================================= @@ -739,5 +593,5 @@ void GenerationGUI_PrismDlg::addSubshapesToStudy() //================================================================================= bool GenerationGUI_PrismDlg::extractPrefix() const { - return myBaseObjects.length() > 1; + return myBaseObjects.count() > 1; } diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.h b/src/GenerationGUI/GenerationGUI_PrismDlg.h index 0a0bad169..bebfa3fec 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.h +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.h @@ -27,7 +27,8 @@ #ifndef GENERATIONGUI_PRISMDLG_H #define GENERATIONGUI_PRISMDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel1Spin2Check; class DlgRef_3Sel1Check; @@ -59,20 +60,9 @@ private: double getHeight() const; private: - GEOM::ListOfGO myBaseObjects; /* Base shapes */ - GEOM::GEOM_Object_var myVec; /* Vector, defining the direction */ - GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points for extrusion */ - - bool myOkBase; - bool myOkVec; - bool myOkPnt1; - bool myOkPnt2; - bool myBothway; - bool myBothway2; - bool myBothway3; - - // to initialize the first selection field with a selected object on the dialog creation - bool myInitial; + QList myBaseObjects; /* Base shapes */ + GEOM::GeomObjPtr myVec; /* Vector, defining the direction */ + GEOM::GeomObjPtr myPoint1, myPoint2; /* Points for extrusion */ DlgRef_2Sel1Spin2Check* GroupPoints; DlgRef_3Sel1Check* GroupPoints2; // for second layout for extrusion using 2 points @@ -82,7 +72,6 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx index 53ba3d625..837165e6d 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx @@ -68,7 +68,6 @@ GenerationGUI_RevolDlg::GenerationGUI_RevolDlg (GeometryGUI* theGeometryGUI, QWi mainFrame()->RadioButton2->close(); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->close(); - myBothway = false; GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget()); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); @@ -119,8 +118,9 @@ void GenerationGUI_RevolDlg::Init() GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); - myAxis = GEOM::GEOM_Object::_nil(); - myOkBase = myOkAxis = false; + + myBaseObjects.clear(); + myAxis.nullify(); // signals and slots connections connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -129,9 +129,6 @@ void GenerationGUI_RevolDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway())); connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); @@ -180,32 +177,6 @@ bool GenerationGUI_RevolDlg::ClickOnApply() return true; } -//======================================================================= -//function : isAcceptableBase -//purpose : return true if theBase can be used as algo argument -//======================================================================= -static bool isAcceptableBase (const TopoDS_Shape& theBase) -{ - switch (theBase.ShapeType()) { - case TopAbs_VERTEX: - case TopAbs_EDGE: - case TopAbs_WIRE: - case TopAbs_FACE: - case TopAbs_SHELL: - return true; - case TopAbs_SOLID: - case TopAbs_COMPSOLID: - return false; - case TopAbs_COMPOUND: { - TopExp_Explorer exp(theBase, TopAbs_SOLID); - return !exp.More(); - } - default: - return false; - } - return false; -} - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection is changed or on dialog initialization or activation @@ -214,76 +185,30 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument() { erasePreview(); myEditCurrentArgument->setText(""); - if (myEditCurrentArgument == GroupPoints->LineEdit1) myOkBase = false; - else if (myEditCurrentArgument == GroupPoints->LineEdit2) myOkAxis = false; - - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() < 1) - return; - - GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - QString aName = GEOMBase::GetName(aSelectedObject); - - if ( aSelectedObject->_is_nil() ) - return; - - TopoDS_Shape S; - if (!GEOMBase::GetShape(aSelectedObject, S) || S.IsNull()) - return; - - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - myOkBase = false; - if (aSelList.Extent() > 1) - aName = QString( "%1_objects").arg( aSelList.Extent() ); - - if ( aSelList.Extent() > 0 ) { - GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true); - // check base shapes - for (int i=0; i < myBaseObjects.length(); i++) { - GEOMBase::GetShape(myBaseObjects[i], S); - if (!isAcceptableBase(S)) - return; - } + + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { + myBaseObjects.clear(); + QList objects = getSelected( TopAbs_SHAPE, -1 ); + for ( int i = 0; i < objects.count(); i++ ) { + GEOM::shape_type stype = objects[i]->GetMaxShapeType(); + if ( stype < GEOM::SHELL || stype > GEOM::VERTEX ) + continue; + myBaseObjects << objects[i]; + } + if ( !myBaseObjects.isEmpty() ) { + QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() ); myEditCurrentArgument->setText( aName ); - myOkBase = true; } } else if (myEditCurrentArgument == GroupPoints->LineEdit2) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) { - int anIndex = aMap(1); - aName.append(":edge_" + QString::number(anIndex)); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); - myAxis = aShapesOp->GetSubShape(aSelectedObject, anIndex); - myOkAxis = true; - } else { - myAxis = aFindedObject; - myOkAxis = true; - } - } else { - myOkAxis = true; - if (S.ShapeType() != TopAbs_EDGE) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - myOkAxis = false; - } - myAxis = aSelectedObject; + myAxis = getSelected( TopAbs_EDGE ); + if ( myAxis ) { + QString aName = GEOMBase::GetName( myAxis.get() ); + myEditCurrentArgument->setText( aName ); + if ( myBaseObjects.isEmpty() ) + GroupPoints->PushButton1->click(); } - myEditCurrentArgument->setText(aName); - if (myOkAxis && !myOkBase) - GroupPoints->PushButton1->click(); } - displayPreview(); } @@ -321,20 +246,6 @@ void GenerationGUI_RevolDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void GenerationGUI_RevolDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -391,8 +302,7 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_RevolDlg::createOperation() //================================================================================= bool GenerationGUI_RevolDlg::isValid (QString& msg) { - bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ); - return myOkBase && myOkAxis && ok; + return GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && !myBaseObjects.isEmpty() && myAxis; } //================================================================================= @@ -401,16 +311,14 @@ bool GenerationGUI_RevolDlg::isValid (QString& msg) //================================================================================= bool GenerationGUI_RevolDlg::execute (ObjectList& objects) { - GEOM::GEOM_Object_var anObj, aBase; + GEOM::GEOM_Object_var anObj; GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); - for (int i=0; i < myBaseObjects.length(); i++) { - aBase = myBaseObjects[i]; - - if (!myBothway) - anObj = anOper->MakeRevolutionAxisAngle(aBase, myAxis, getAngle() * PI180); + for (int i = 0; i < myBaseObjects.count(); i++) { + if (!GroupPoints->CheckButton1->isChecked()) + anObj = anOper->MakeRevolutionAxisAngle(myBaseObjects[i].get(), myAxis.get(), getAngle() * PI180); else - anObj = anOper->MakeRevolutionAxisAngle2Ways(aBase, myAxis, getAngle() * PI180); + anObj = anOper->MakeRevolutionAxisAngle2Ways(myBaseObjects[i].get(), myAxis.get(), getAngle() * PI180); if (!anObj->_is_nil()) { if (!IsPreview()) { @@ -441,9 +349,7 @@ void GenerationGUI_RevolDlg::onReverse() //================================================================================= void GenerationGUI_RevolDlg::onBothway() { - bool anOldValue = myBothway; - myBothway = !anOldValue; - GroupPoints->CheckButton2->setEnabled(!myBothway); + GroupPoints->CheckButton2->setEnabled(!GroupPoints->CheckButton1->isChecked()); displayPreview(); } @@ -453,11 +359,7 @@ void GenerationGUI_RevolDlg::onBothway() //================================================================================= void GenerationGUI_RevolDlg::addSubshapesToStudy() { - QMap objMap; - - objMap[GroupPoints->LineEdit2->text()] = myAxis; - - addSubshapesToFather(objMap); + GEOMBase::PublishSubObject( myAxis.get() ); } //================================================================================= @@ -466,5 +368,5 @@ void GenerationGUI_RevolDlg::addSubshapesToStudy() //================================================================================= bool GenerationGUI_RevolDlg::extractPrefix() const { - return myBaseObjects.length() > 1; + return myBaseObjects.count() > 1; } diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.h b/src/GenerationGUI/GenerationGUI_RevolDlg.h index aee184f00..199d7f3d4 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.h +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.h @@ -27,7 +27,8 @@ #ifndef GENERATIONGUI_REVOLUTIONDLG_H #define GENERATIONGUI_REVOLUTIONDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel1Spin2Check; @@ -57,11 +58,8 @@ private: double getAngle() const; private: - GEOM::ListOfGO myBaseObjects; /* Base shapes */ - GEOM::GEOM_Object_var myAxis; /* Axis of the revolution */ - bool myOkBase; - bool myOkAxis; - bool myBothway; + QList myBaseObjects; /* Base shapes */ + GEOM::GeomObjPtr myAxis; /* Axis of the revolution */ DlgRef_2Sel1Spin2Check* GroupPoints; @@ -69,7 +67,6 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ValueChangedInSpinBox(); diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx index 5ca674101..a5a400628 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx @@ -43,7 +43,6 @@ #include #include -//#include //================================================================================= // class : PrimitiveGUI_BoxDlg() @@ -123,7 +122,8 @@ void PrimitiveGUI_BoxDlg::Init() GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); - myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + myPoint1.nullify(); + myPoint2.nullify(); double initValue = 200.0; GroupDimensions->SpinBox_DX->setValue(initValue); @@ -139,9 +139,6 @@ void PrimitiveGUI_BoxDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); @@ -242,70 +239,36 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify(); return; } - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( CORBA::is_nil(aSelectedObject) ) - return; - - QString aName = GEOMBase::GetName(aSelectedObject); - - // Get Selected object if selected subshape + GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX ); TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) // Local Selection - { - int anIndex = aMap(1); - aName.append(":vertex_" + QString::number(anIndex)); + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); + myEditCurrentArgument->setText(aName); - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } + // clear selection + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + if (myEditCurrentArgument == GroupPoints->LineEdit1) { + myPoint1 = aSelectedObject; + if (myPoint1 && !myPoint2) + GroupPoints->PushButton2->click(); } - else // Global Selection - { - if (aShape.ShapeType() != TopAbs_VERTEX) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + myPoint2 = aSelectedObject; + if (myPoint2 && !myPoint1) + GroupPoints->PushButton1->click(); } + } - - myEditCurrentArgument->setText(aName); - - // clear selection - disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - myGeomGUI->getApp()->selectionMgr()->clearSelected(); - connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), - this, SLOT(SelectionIntoArgument())); - - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - myPoint1 = aSelectedObject; - if (!myPoint1->_is_nil() && myPoint2->_is_nil()) - GroupPoints->PushButton2->click(); - } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { - myPoint2 = aSelectedObject; - if (!myPoint2->_is_nil() && myPoint1->_is_nil()) - GroupPoints->PushButton1->click(); - } - displayPreview(); } @@ -351,19 +314,6 @@ void PrimitiveGUI_BoxDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_BoxDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -413,18 +363,21 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_BoxDlg::createOperation() //================================================================================= bool PrimitiveGUI_BoxDlg::isValid (QString& msg) { - bool ok = true; + bool ok = false; if( getConstructorId() == 1 ) { - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; - - ok = fabs( GroupDimensions->SpinBox_DX->value() ) > Precision::Confusion() && ok; - ok = fabs( GroupDimensions->SpinBox_DY->value() ) > Precision::Confusion() && ok; - ok = fabs( GroupDimensions->SpinBox_DZ->value() ) > Precision::Confusion() && ok; + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && + qAbs( GroupDimensions->SpinBox_DX->value() ) > Precision::Confusion() && + qAbs( GroupDimensions->SpinBox_DY->value() ) > Precision::Confusion() && + qAbs( GroupDimensions->SpinBox_DZ->value() ) > Precision::Confusion(); + } + else + { + ok = myPoint1 && myPoint2 && myPoint1 != myPoint2; } - return getConstructorId() == 0 ? !(myPoint1->_is_nil() || myPoint2->_is_nil()) : ok; + return ok; } //================================================================================= @@ -442,8 +395,8 @@ bool PrimitiveGUI_BoxDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: { - if (!CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2)) { - anObj = anOper->MakeBoxTwoPnt(myPoint1, myPoint2); + if ( myPoint1 && myPoint2 ) { + anObj = anOper->MakeBoxTwoPnt(myPoint1.get(), myPoint2.get()); res = true; } } @@ -481,9 +434,7 @@ bool PrimitiveGUI_BoxDlg::execute (ObjectList& objects) void PrimitiveGUI_BoxDlg::addSubshapesToStudy() { if (getConstructorId() == 0) { - QMap objMap; - objMap[GroupPoints->LineEdit1->text()] = myPoint1; - objMap[GroupPoints->LineEdit2->text()] = myPoint2; - addSubshapesToFather(objMap); + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); } } diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h index bdc8e6af8..48a94363f 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h @@ -27,7 +27,8 @@ #ifndef PRIMITIVEGUI_BOXDLG_H #define PRIMITIVEGUI_BOXDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel; class DlgRef_3Spin; @@ -56,7 +57,7 @@ private: void enterEvent( QEvent* ); private: - GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the vector */ + GEOM::GeomObjPtr myPoint1, myPoint2; /* Points containing the vector */ DlgRef_2Sel* GroupPoints; DlgRef_3Spin* GroupDimensions; @@ -65,7 +66,6 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx index 4b4791414..1f02d00b2 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx @@ -129,7 +129,8 @@ void PrimitiveGUI_ConeDlg::Init() GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); - myPoint = myDir = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myDir.nullify(); double aRadius1(100.0), aRadius2(0.0), aHeight(300.0); GroupPoints->SpinBox_DX->setValue(aRadius1); @@ -148,9 +149,6 @@ void PrimitiveGUI_ConeDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); @@ -257,77 +255,37 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil(); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify(); return; } - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( CORBA::is_nil(aSelectedObject) ) - return; - - QString aName = GEOMBase::GetName(aSelectedObject); - - // Get Selected object if selected subshape + TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if (myEditCurrentArgument == GroupPoints->LineEdit2) - aNeedType = TopAbs_EDGE; - - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) // Local Selection - { - int anIndex = aMap(1); - if (aNeedType == TopAbs_EDGE) - aName.append(":edge_" + QString::number(anIndex)); - else - aName.append(":vertex_" + QString::number(anIndex)); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + + myEditCurrentArgument->setText(aName); + + // clear selection + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + if (myEditCurrentArgument == GroupPoints->LineEdit1) { + myPoint = aSelectedObject; + if (myPoint && !myDir) + GroupPoints->PushButton2->click(); } - else // Global Selection - { - if (aShape.ShapeType() != aNeedType) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + myDir = aSelectedObject; + if (myDir && !myPoint) + GroupPoints->PushButton1->click(); } } - myEditCurrentArgument->setText(aName); - - // clear selection - disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - myGeomGUI->getApp()->selectionMgr()->clearSelected(); - connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), - this, SLOT(SelectionIntoArgument())); - - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - myPoint = aSelectedObject; - if (!myPoint->_is_nil() && myDir->_is_nil()) - GroupPoints->PushButton2->click(); - } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { - myDir = aSelectedObject; - if (!myDir->_is_nil() && myPoint->_is_nil()) - GroupPoints->PushButton1->click(); - } - displayPreview(); } @@ -371,20 +329,6 @@ void PrimitiveGUI_ConeDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_ConeDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -433,24 +377,22 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_ConeDlg::createOperation() //================================================================================= bool PrimitiveGUI_ConeDlg::isValid (QString& msg) { - if (!getRadius1() && !getRadius2()) - return false; - - bool ok = true; + bool ok = false; if( getConstructorId() == 0 ) { - ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; + ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) && + myPoint && myDir; } else if( getConstructorId() == 1 ) { - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ); } - ok = fabs( getHeight() ) > Precision::Confusion() && ok; - return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) && ok : ok; + ok = ( getRadius1() > 0 || getRadius2() > 0 ) && qAbs( getHeight() ) > Precision::Confusion() && ok; + return ok; } //================================================================================= @@ -467,8 +409,8 @@ bool PrimitiveGUI_ConeDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: - if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { - anObj = anOper->MakeConePntVecR1R2H(myPoint, myDir, getRadius1(), getRadius2(), getHeight()); + if ( myPoint && myDir ) { + anObj = anOper->MakeConePntVecR1R2H(myPoint.get(), myDir.get(), getRadius1(), getRadius2(), getHeight()); if (!anObj->_is_nil() && !IsPreview()) { QStringList aParameters; @@ -548,15 +490,8 @@ double PrimitiveGUI_ConeDlg::getHeight() const //================================================================================= void PrimitiveGUI_ConeDlg::addSubshapesToStudy() { - QMap objMap; - - switch (getConstructorId()) { - case 0: - objMap[GroupPoints->LineEdit1->text()] = myPoint; - objMap[GroupPoints->LineEdit2->text()] = myDir; - break; - case 1: - return; + if ( getConstructorId() == 0 ) { + GEOMBase::PublishSubObject( myPoint.get() ); + GEOMBase::PublishSubObject( myDir.get() ); } - addSubshapesToFather(objMap); } diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h index abea2e72b..ed369e4f9 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h @@ -27,7 +27,8 @@ #ifndef PRIMITIVEGUI_CONEDLG_H #define PRIMITIVEGUI_CONEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel3Spin; class DlgRef_3Spin; @@ -59,7 +60,7 @@ private: double getHeight() const; private: - GEOM::GEOM_Object_var myPoint, myDir; + GEOM::GeomObjPtr myPoint, myDir; DlgRef_2Sel3Spin* GroupPoints; DlgRef_3Spin* GroupDimensions; @@ -68,7 +69,6 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index 29532dabb..cff112c7a 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -127,7 +127,8 @@ void PrimitiveGUI_CylinderDlg::Init() GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); - myPoint = myDir = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myDir.nullify(); double aRadius(100.0), aHeight(300.0); GroupPoints->SpinBox_DX->setValue(aRadius); @@ -144,9 +145,6 @@ void PrimitiveGUI_CylinderDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); @@ -250,76 +248,38 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() if (aSelList.Extent() != 1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) - myPoint = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myDir = GEOM::GEOM_Object::_nil(); + myDir.nullify(); return; } - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if (CORBA::is_nil(aSelectedObject)) - return; - - QString aName = GEOMBase::GetName(aSelectedObject); - - // Get Selected object if selected subshape + TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if (myEditCurrentArgument == GroupPoints->LineEdit2) - aNeedType = TopAbs_EDGE; - - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) { // Local Selection - int anIndex = aMap(1); - if (aNeedType == TopAbs_EDGE) - aName.append(":edge_" + QString::number(anIndex)); - else - aName.append(":vertex_" + QString::number(anIndex)); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + + myEditCurrentArgument->setText(aName); + + // clear selection + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + if (myEditCurrentArgument == GroupPoints->LineEdit1) { + myPoint = aSelectedObject; + if (myPoint && !myDir) + GroupPoints->PushButton2->click(); } - else { // Global Selection - if (aShape.ShapeType() != aNeedType) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + myDir = aSelectedObject; + if (myDir && !myPoint) + GroupPoints->PushButton1->click(); } } - myEditCurrentArgument->setText(aName); - - // clear selection - disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - myGeomGUI->getApp()->selectionMgr()->clearSelected(); - connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), - this, SLOT(SelectionIntoArgument())); - - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - myPoint = aSelectedObject; - if (!myPoint->_is_nil() && myDir->_is_nil()) - GroupPoints->PushButton2->click(); - } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { - myDir = aSelectedObject; - if (!myDir->_is_nil() && myPoint->_is_nil()) - GroupPoints->PushButton1->click(); - } - displayPreview(); } @@ -363,20 +323,6 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_CylinderDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -425,19 +371,20 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_CylinderDlg::createOperation() //================================================================================= bool PrimitiveGUI_CylinderDlg::isValid (QString& msg) { - bool ok = true; + bool ok = false; if( getConstructorId() == 0 ) { - ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && + myPoint && myDir; } else if( getConstructorId() == 1 ) { - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ); } - ok = fabs( getHeight() ) > Precision::Confusion() && ok; - return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) && ok : ok; + ok = qAbs( getHeight() ) > Precision::Confusion() && ok; + return ok; } //================================================================================= @@ -454,8 +401,8 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: - if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { - anObj = anOper->MakeCylinderPntVecRH(myPoint, myDir, getRadius(), getHeight()); + if ( myPoint && myDir ) { + anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight()); if (!anObj->_is_nil() && !IsPreview()) { QStringList aParameters; @@ -519,15 +466,8 @@ double PrimitiveGUI_CylinderDlg::getHeight() const //================================================================================= void PrimitiveGUI_CylinderDlg::addSubshapesToStudy() { - QMap objMap; - - switch (getConstructorId()) { - case 0: - objMap[GroupPoints->LineEdit1->text()] = myPoint; - objMap[GroupPoints->LineEdit2->text()] = myDir; - break; - case 1: - return; + if ( getConstructorId() == 0 ) { + GEOMBase::PublishSubObject( myPoint.get() ); + GEOMBase::PublishSubObject( myDir.get() ); } - addSubshapesToFather(objMap); } diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h index 370153dd6..563999960 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h @@ -27,7 +27,8 @@ #ifndef PRIMITIVEGUI_CYLINDERDLG_H #define PRIMITIVEGUI_CYLINDERDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel2Spin; class DlgRef_2Spin; @@ -58,7 +59,7 @@ private: double getHeight() const; private: - GEOM::GEOM_Object_var myPoint, myDir; + GEOM::GeomObjPtr myPoint, myDir; // to initialize the first selection field with a selected object on the dialog creation bool myInitial; @@ -70,7 +71,6 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); diff --git a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx index 397188996..07bbd4cc6 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx @@ -142,7 +142,11 @@ void PrimitiveGUI_DiskDlg::Init() Group3Pnts->LineEdit1->setText(""); Group3Pnts->LineEdit2->setText(""); Group3Pnts->LineEdit3->setText(""); - myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myDir.nullify(); + myPoint1.nullify(); + myPoint2.nullify(); + myPoint3.nullify(); GroupPntVecR->SpinBox_DX->setValue(100); GroupDimensions->SpinBox_DX->setValue(100); @@ -156,17 +160,10 @@ void PrimitiveGUI_DiskDlg::Init() connect(GroupPntVecR->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPntVecR->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPntVecR->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPntVecR->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); @@ -299,91 +296,53 @@ void PrimitiveGUI_DiskDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group3Pnts->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group3Pnts->LineEdit3) myPoint3 = GEOM::GEOM_Object::_nil(); + if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint.nullify(); + else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir.nullify(); + else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1.nullify(); + else if (myEditCurrentArgument == Group3Pnts->LineEdit2) myPoint2.nullify(); + else if (myEditCurrentArgument == Group3Pnts->LineEdit3) myPoint3.nullify(); return; } - // nbSel == 1 - Handle(SALOME_InteractiveObject) anIO = aSelList.First(); - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO ); - - if ( CORBA::is_nil(aSelectedObject) ) - return; - - QString aName = GEOMBase::GetName(aSelectedObject); - - // If selected Vertex or Edge on the some Shape Get selection Subshape + TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPntVecR->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if (myEditCurrentArgument == GroupPntVecR->LineEdit2) - aNeedType = TopAbs_EDGE; - - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(anIO, aMap); - if (aMap.Extent() == 1) { // Local Selection - int anIndex = aMap(1); - if (aNeedType == TopAbs_EDGE) - aName += QString(":edge_%1").arg(anIndex); - else - aName += QString(":vertex_%1").arg(anIndex); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + + myEditCurrentArgument->setText(aName); + + // clear selection + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + if (myEditCurrentArgument == GroupPntVecR->LineEdit1) { + myPoint = aSelectedObject; + if (myPoint && !myDir) + GroupPntVecR->PushButton2->click(); } - else { // Global Selection - if (aShape.ShapeType() != aNeedType) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } + else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) { + myDir = aSelectedObject; + if (myDir && !myPoint) + GroupPntVecR->PushButton1->click(); + } + else if (myEditCurrentArgument == Group3Pnts->LineEdit1) { + myPoint1 = aSelectedObject; + if (myPoint1 && !myPoint2) + Group3Pnts->PushButton2->click(); + } + else if (myEditCurrentArgument == Group3Pnts->LineEdit2) { + myPoint2 = aSelectedObject; + if (myPoint2 && !myPoint3) + Group3Pnts->PushButton3->click(); + } + else if (myEditCurrentArgument == Group3Pnts->LineEdit3) { + myPoint3 = aSelectedObject; + if (myPoint3 && !myPoint1) + Group3Pnts->PushButton1->click(); } - } - - myEditCurrentArgument->setText(aName); - - // clear selection - disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - myGeomGUI->getApp()->selectionMgr()->clearSelected(); - connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), - this, SLOT(SelectionIntoArgument())); - - if (myEditCurrentArgument == GroupPntVecR->LineEdit1) { - myPoint = aSelectedObject; - if (!myPoint->_is_nil() && myDir->_is_nil()) - GroupPntVecR->PushButton2->click(); - } - else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) { - myDir = aSelectedObject; - if (!myDir->_is_nil() && myPoint->_is_nil()) - GroupPntVecR->PushButton1->click(); - } - else if (myEditCurrentArgument == Group3Pnts->LineEdit1) { - myPoint1 = aSelectedObject; - if (!myPoint1->_is_nil() && myPoint2->_is_nil()) - Group3Pnts->PushButton2->click(); - } - else if (myEditCurrentArgument == Group3Pnts->LineEdit2) { - myPoint2 = aSelectedObject; - if (!myPoint2->_is_nil() && myPoint3->_is_nil()) - Group3Pnts->PushButton3->click(); - } - else if (myEditCurrentArgument == Group3Pnts->LineEdit3) { - myPoint3 = aSelectedObject; - if (!myPoint3->_is_nil() && myPoint1->_is_nil()) - Group3Pnts->PushButton1->click(); } displayPreview(); @@ -456,23 +415,6 @@ void PrimitiveGUI_DiskDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_DiskDlg::LineEditReturnPressed() -{ -QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPntVecR->LineEdit1 || - send == GroupPntVecR->LineEdit2 || - send == Group3Pnts->LineEdit1 || - send == Group3Pnts->LineEdit2 || - send == Group3Pnts->LineEdit3) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -529,21 +471,14 @@ static bool isEqual (const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Obje //================================================================================= bool PrimitiveGUI_DiskDlg::isValid (QString& msg) { - bool ok = true; - if( getConstructorId() == 0 ) - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - else if( getConstructorId() == 1 ) - ok = GroupPntVecR->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - - const int id = getConstructorId(); - if (id == 0) - return ok; - else if (id == 1) - return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0 && ok; - else if (id == 2) - return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() && - !isEqual(myPoint1, myPoint2) && !isEqual(myPoint1, myPoint3) && !isEqual(myPoint2, myPoint3); - return false; + bool ok = false; + if ( getConstructorId() == 0 ) + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && getRadius() > 0; + else if ( getConstructorId() == 1 ) + ok = GroupPntVecR->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint && myDir && getRadius() > 0; + else if ( getConstructorId() == 2 ) + ok = myPoint1 && myPoint2 && myPoint3 && myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3; + return ok; } //================================================================================= @@ -570,7 +505,7 @@ bool PrimitiveGUI_DiskDlg::execute (ObjectList& objects) res = true; break; case 1: - anObj = anOper->MakeDiskPntVecR(myPoint, myDir, getRadius()); + anObj = anOper->MakeDiskPntVecR(myPoint.get(), myDir.get(), getRadius()); if (!anObj->_is_nil() && !IsPreview()) { aParameters << GroupPntVecR->SpinBox_DX->text(); @@ -579,7 +514,7 @@ bool PrimitiveGUI_DiskDlg::execute (ObjectList& objects) res = true; break; case 2: - anObj = anOper->MakeDiskThreePnt(myPoint1, myPoint2, myPoint3); + anObj = anOper->MakeDiskThreePnt(myPoint1.get(), myPoint2.get(), myPoint3.get()); res = true; break; } @@ -612,18 +547,17 @@ double PrimitiveGUI_DiskDlg::getRadius() const //================================================================================= void PrimitiveGUI_DiskDlg::addSubshapesToStudy() { - QMap objMap; - switch (getConstructorId()) { case 1: - objMap[GroupPntVecR->LineEdit1->text()] = myPoint; - objMap[GroupPntVecR->LineEdit2->text()] = myDir; + GEOMBase::PublishSubObject( myPoint.get() ); + GEOMBase::PublishSubObject( myDir.get() ); break; case 2: - objMap[Group3Pnts->LineEdit1->text()] = myPoint1; - objMap[Group3Pnts->LineEdit2->text()] = myPoint2; - objMap[Group3Pnts->LineEdit3->text()] = myPoint3; + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); + GEOMBase::PublishSubObject( myPoint3.get() ); + break; + default: break; } - addSubshapesToFather(objMap); } diff --git a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h index e7f4e9cc2..bd7708b05 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h @@ -24,7 +24,8 @@ #ifndef BASICGUI_DISKDLG_H #define BASICGUI_DISKDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_3Sel; class DlgRef_2Sel1Spin; @@ -58,7 +59,7 @@ private: int myOrientationType; private: - GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3; + GEOM::GeomObjPtr myPoint, myDir, myPoint1, myPoint2, myPoint3; DlgRef_2Sel1Spin* GroupPntVecR; DlgRef_3Sel* Group3Pnts; @@ -74,7 +75,6 @@ private slots: void SelectionIntoArgument(); void ConstructorsClicked( int ); - void LineEditReturnPressed(); void SetEditCurrentArgument(); void ValueChangedInSpinBox(); void SetDoubleSpinBoxStep( double ); diff --git a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx index b5b4b4aaf..2cb125bbb 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx @@ -124,8 +124,8 @@ void PrimitiveGUI_FaceDlg::Init() /* init variables */ myEditCurrentArgument = GroupPlane->LineEdit1; GroupType->RadioButton1->setChecked(true); - myEdge = GEOM::GEOM_Object::_nil(); - myFace = GEOM::GEOM_Object::_nil(); + myEdge.nullify(); + myFace.nullify(); globalSelection(); // close local contexts, if any // localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); @@ -159,7 +159,6 @@ void PrimitiveGUI_FaceDlg::Init() connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect( GroupPlane->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPlane->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupPlane->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupPlane->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); @@ -233,6 +232,10 @@ void PrimitiveGUI_FaceDlg::TypeButtonClicked() localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); GroupPlane->TextLabel1->setText( tr( "GEOM_FACE" ) ); } + myEditCurrentArgument = GroupPlane->LineEdit1; + myEditCurrentArgument->setText( "" ); + myEdge.nullify(); + myFace.nullify(); } //================================================================================= @@ -287,8 +290,8 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId ) localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); myEditCurrentArgument = GroupPlane->LineEdit1; myEditCurrentArgument->setText(""); - myEdge = GEOM::GEOM_Object::_nil(); - myFace = GEOM::GEOM_Object::_nil(); + myEdge.nullify(); + myFace.nullify(); GroupType->RadioButton1->setChecked( true ); TypeButtonClicked(); GroupDimensions->hide(); @@ -324,54 +327,24 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if ( aSelList.Extent() != 1 ) { - if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge = GEOM::GEOM_Object::_nil(); + if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge.nullify(); return; } - // nbSel == 1 - TopAbs_ShapeEnum aNeedType = TopAbs_EDGE; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !CORBA::is_nil( aSelectedObject ) ) { - QString aName = GEOMBase::GetName( aSelectedObject ); - - TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - if (GroupType->RadioButton2->isChecked()) - aNeedType = TopAbs_FACE; - - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes( aSelList.First(), aMap ); - if ( aMap.Extent() == 1 ) { // Local Selection - int anIndex = aMap( 1 ); - if ( aNeedType == TopAbs_EDGE ) - aName += QString( ":edge_%1" ).arg( anIndex ); - else - aName += QString( ":face_%1" ).arg( anIndex ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); - - if ( aFindedObject->_is_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); - } - else - aSelectedObject = aFindedObject; // get Object from study - } - else { // Global Selection - if ( aShape.ShapeType() != aNeedType ) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } - } + TopAbs_ShapeEnum aNeedType = GroupType->RadioButton2->isChecked() ? TopAbs_FACE : TopAbs_EDGE; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText( aName ); + if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_EDGE ) myEdge = aSelectedObject; else if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_FACE ) myFace = aSelectedObject; } + displayPreview(); } @@ -397,20 +370,6 @@ void PrimitiveGUI_FaceDlg::SetEditCurrentArgument() SelectionIntoArgument(); } - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_FaceDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPlane->LineEdit1 ) myEditCurrentArgument = GroupPlane->LineEdit1; - else return; - GEOMBase_Skeleton::LineEditReturnPressed(); -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -458,28 +417,19 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_FaceDlg::createOperation() //================================================================================= bool PrimitiveGUI_FaceDlg::isValid( QString& msg ) { - bool ok = true; + bool ok = false; if( getConstructorId() == 0 ) { - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ); } else if( getConstructorId() == 1 ) { - ok = GroupPlane->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupPlane->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + ok = GroupPlane->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupPlane->SpinBox_DY->isValid( msg, !IsPreview() ) && + ( GroupType->RadioButton1->isChecked() ? myEdge : myFace ); } - - const int id = getConstructorId(); - if ( id == 0 ) - return ok; - else if ( id == 1 ) { - if (GroupType->RadioButton1->isChecked()) - return !myEdge->_is_nil() && ok; - else if (GroupType->RadioButton2->isChecked()) - return !myFace->_is_nil() && ok; - } - return false; + return ok; } //================================================================================= @@ -508,8 +458,8 @@ bool PrimitiveGUI_FaceDlg::execute (ObjectList& objects) break; case 1: anObj = GroupType->RadioButton1->isChecked() ? - anOper->MakeFaceObjHW(myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()) : - anOper->MakeFaceObjHW(myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()); + anOper->MakeFaceObjHW(myEdge.get(), GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()) : + anOper->MakeFaceObjHW(myFace.get(), GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()); if (!anObj->_is_nil() && !IsPreview()) { aParameters << GroupPlane->SpinBox_DX->text(); @@ -532,14 +482,10 @@ bool PrimitiveGUI_FaceDlg::execute (ObjectList& objects) //================================================================================= void PrimitiveGUI_FaceDlg::addSubshapesToStudy() { - QMap objMap; - switch ( getConstructorId() ) { - case 1 : + if ( getConstructorId() == 1 ) { if ( GroupType->RadioButton1->isChecked() ) - objMap[GroupPlane->LineEdit1->text()] = myEdge; + GEOMBase::PublishSubObject( myEdge.get() ); if ( GroupType->RadioButton2->isChecked() ) - objMap[GroupPlane->LineEdit1->text()] = myFace; - break; + GEOMBase::PublishSubObject( myFace.get() ); } - addSubshapesToFather( objMap ); } diff --git a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h index f4def5b7f..6d657ad10 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h @@ -24,7 +24,8 @@ #ifndef BASICGUI_FACEDLG_H #define BASICGUI_FACEDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Spin; class DlgRef_1Sel2Spin; @@ -54,8 +55,8 @@ private: void enterEvent( QEvent* ); private: - GEOM::GEOM_Object_var myEdge; - GEOM::GEOM_Object_var myFace; + GEOM::GeomObjPtr myEdge; + GEOM::GeomObjPtr myFace; int myOrientationType; @@ -72,7 +73,6 @@ private slots: void DeactivateActiveDialog(); void ConstructorsClicked( int ); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ValueChangedInSpinBox( double ); diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx index 1102a37a5..fab3651b2 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx @@ -109,7 +109,7 @@ void PrimitiveGUI_SphereDlg::Init() myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly( true ); - myPoint = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -128,7 +128,6 @@ void PrimitiveGUI_SphereDlg::Init() connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); @@ -173,7 +172,7 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked( int constructorId ) myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText( "" ); - myPoint = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -241,65 +240,21 @@ void PrimitiveGUI_SphereDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - myPoint = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); return; } - /* nbSel == 1 ! */ - GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( CORBA::is_nil( aSelectedObject ) ) - return; - - QString aName = GEOMBase::GetName( aSelectedObject ); + GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX ); TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull() ) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if ( aMap.Extent() == 1 ) { // Local Selection - int anIndex = aMap( 1 ); - aName.append( ":vertex_" + QString::number( anIndex ) ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName ); - - if ( aFindedObject->_is_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); - aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } - } - else { // Global Selection - if (aShape.ShapeType() != TopAbs_VERTEX) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + myEditCurrentArgument->setText( aName ); + myPoint = aSelectedObject; } - myEditCurrentArgument->setText( aName ); - myPoint = aSelectedObject; - displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_SphereDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPoints->LineEdit1 ) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -379,12 +334,12 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_SphereDlg::createOperation() //================================================================================= bool PrimitiveGUI_SphereDlg::isValid( QString& msg ) { - bool ok = true; + bool ok = false; if( getConstructorId() == 0 ) - ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; + ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint; else if( getConstructorId() == 1 ) - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - return getConstructorId() == 0 ? !myPoint->_is_nil() && ok : ok; + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ); + return ok; } //================================================================================= @@ -402,8 +357,8 @@ bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects ) switch ( getConstructorId() ) { case 0 : { - if ( !CORBA::is_nil( myPoint ) ) { - anObj = anOper->MakeSpherePntR( myPoint, getRadius() ); + if ( myPoint ) { + anObj = anOper->MakeSpherePntR( myPoint.get(), getRadius() ); if (!anObj->_is_nil() && !IsPreview()) { QStringList aParameters; @@ -455,14 +410,7 @@ double PrimitiveGUI_SphereDlg::getRadius() const //================================================================================= void PrimitiveGUI_SphereDlg::addSubshapesToStudy() { - QMap objMap; - - switch ( getConstructorId() ) { - case 0: - objMap[GroupPoints->LineEdit1->text()] = myPoint; - break; - case 1: - return; + if ( getConstructorId() == 0 ) { + GEOMBase::PublishSubObject( myPoint.get() ); } - addSubshapesToFather( objMap ); } diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h index 8f288af12..1c82622c2 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h @@ -27,7 +27,8 @@ #ifndef PRIMITIVEGUI_SPHEREDLG_H #define PRIMITIVEGUI_SPHEREDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_1Sel1Spin; class DlgRef_1Spin; @@ -57,7 +58,7 @@ private: double getRadius() const; private: - GEOM::GEOM_Object_var myPoint; /* Center point */ + GEOM::GeomObjPtr myPoint; /* Center point */ DlgRef_1Sel1Spin* GroupPoints; DlgRef_1Spin* GroupDimensions; @@ -67,7 +68,6 @@ private slots: bool ClickOnApply(); void ActivateThisDialog(); void DeactivateActiveDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx index 3b7ba62aa..f709fd9a2 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx @@ -126,7 +126,8 @@ void PrimitiveGUI_TorusDlg::Init() GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); - myPoint = myDir = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); + myDir.nullify(); GroupPoints->SpinBox_DX->setValue(300.0); GroupPoints->SpinBox_DY->setValue(100.0); @@ -142,9 +143,6 @@ void PrimitiveGUI_TorusDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); @@ -242,80 +240,42 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument() erasePreview(); myEditCurrentArgument->setText(""); - if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil(); - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); SALOME_ListIO aSelList; aSelMgr->selectedObjects(aSelList); - if (aSelList.Extent() != 1) - return; - - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( CORBA::is_nil(aSelectedObject) ) + if (aSelList.Extent() != 1) { + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify(); return; + } - QString aName = GEOMBase::GetName(aSelectedObject); - - // Get Selected object if selected subshape + TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX; + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if (myEditCurrentArgument == GroupPoints->LineEdit2) - aNeedType = TopAbs_EDGE; - - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) { // Local Selection - int anIndex = aMap(1); - if (aNeedType == TopAbs_EDGE) - aName.append(":edge_" + QString::number(anIndex)); - else - aName.append(":vertex_" + QString::number(anIndex)); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_nil()) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else { - aSelectedObject = aFindedObject; // get Object from study - } + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + + myEditCurrentArgument->setText(aName); + + // clear selection + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + if (myEditCurrentArgument == GroupPoints->LineEdit1) { + myPoint = aSelectedObject; + if (myPoint && !myDir) + GroupPoints->PushButton2->click(); } - else { // Global Selection - if (aShape.ShapeType() != aNeedType) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + myDir = aSelectedObject; + if (myDir && !myPoint) + GroupPoints->PushButton1->click(); } } - myEditCurrentArgument->setText(aName); - - // clear selection - disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - myGeomGUI->getApp()->selectionMgr()->clearSelected(); - connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), - this, SLOT(SelectionIntoArgument())); - - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - myPoint = aSelectedObject; - if (!myPoint->_is_nil() && myDir->_is_nil()) - GroupPoints->PushButton2->click(); - } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { - myDir = aSelectedObject; - if (!myDir->_is_nil() && myPoint->_is_nil()) - GroupPoints->PushButton1->click(); - } - displayPreview(); } @@ -359,20 +319,6 @@ void PrimitiveGUI_TorusDlg::SetEditCurrentArgument() displayPreview(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_TorusDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -421,18 +367,19 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_TorusDlg::createOperation() //================================================================================= bool PrimitiveGUI_TorusDlg::isValid (QString& msg) { - bool ok = true; + bool ok = false; if( getConstructorId() == 0 ) { - ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && + myPoint && myDir; } else if( getConstructorId() == 1 ) { - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ); } - return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) && ok : ok; + return ok; } //================================================================================= @@ -449,8 +396,8 @@ bool PrimitiveGUI_TorusDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: - if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { - anObj = anOper->MakeTorusPntVecRR(myPoint, myDir, getRadius1(), getRadius2()); + if ( myPoint && myDir ) { + anObj = anOper->MakeTorusPntVecRR(myPoint.get(), myDir.get(), getRadius1(), getRadius2()); if (!anObj->_is_nil() && !IsPreview()) { QStringList aParameters; @@ -514,15 +461,8 @@ double PrimitiveGUI_TorusDlg::getRadius2() const //================================================================================= void PrimitiveGUI_TorusDlg::addSubshapesToStudy() { - QMap objMap; - - switch (getConstructorId()) { - case 0: - objMap[GroupPoints->LineEdit1->text()] = myPoint; - objMap[GroupPoints->LineEdit2->text()] = myDir; - break; - case 1: - return; + if ( getConstructorId() == 0 ) { + GEOMBase::PublishSubObject( myPoint.get() ); + GEOMBase::PublishSubObject( myDir.get() ); } - addSubshapesToFather(objMap); } diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h index 8cc2a57e2..1cd406a5c 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h @@ -27,7 +27,8 @@ #ifndef PRIMITIVEGUI_TORUSDLG_H #define PRIMITIVEGUI_TORUSDLG_H -#include +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" class DlgRef_2Sel2Spin; class DlgRef_2Spin; @@ -58,7 +59,7 @@ private: double getRadius2() const; private: - GEOM::GEOM_Object_var myPoint, myDir; + GEOM::GeomObjPtr myPoint, myDir; DlgRef_2Sel2Spin* GroupPoints; DlgRef_2Spin* GroupDimensions; @@ -67,7 +68,6 @@ private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ConstructorsClicked( int ); -- 2.39.2