From: dmv Date: Wed, 9 Jan 2008 07:44:01 +0000 (+0000) Subject: improvements from Salome3x NPAL 16768, 16218, 16820, 16547 X-Git-Tag: for_M2008_07022008~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5c457ea8ebd59aa2405400b4dca912e112bb6be4;p=modules%2Fgeom.git improvements from Salome3x NPAL 16768, 16218, 16820, 16547 --- diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index 3dcaa192e..f9668b5ce 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -33,7 +33,15 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include +#include #include "GEOMImpl_Types.hxx" @@ -93,7 +101,7 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg(GeometryGUI* theGeometryGUI, QWidget* parent, Group3Pnts2->PushButton2->setPixmap(image2); Group3Pnts2->PushButton3->setPixmap(image2); - Group3Pnts2->radioButton4->setText(tr("GEOM_REVERSE")); + Group3Pnts2->CheckButton1->setText(tr("GEOM_REVERSE")); Layout1->addWidget( Group3Pnts, 2, 0 ); Layout1->addWidget( Group3Pnts2, 2, 0 ); @@ -123,7 +131,7 @@ void BasicGUI_ArcDlg::Init() /* init variables */ myEditCurrentArgument = Group3Pnts->LineEdit1; myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); - Group3Pnts2->radioButton4->setChecked(FALSE); + Group3Pnts2->CheckButton1->setChecked(FALSE); /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); @@ -151,10 +159,10 @@ void BasicGUI_ArcDlg::Init() connect(Group3Pnts2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group3Pnts2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group3Pnts2->radioButton4, SIGNAL(stateChanged(int)), this, SLOT(ReverseSense(int))); + connect(Group3Pnts2->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseSense(int))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_ARC" )); ConstructorsClicked( 0 ); @@ -173,7 +181,8 @@ void BasicGUI_ArcDlg::ConstructorsClicked (int constructorId) { case 0: { - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); //Select Vertex on All Shapes Group3Pnts->show(); resize(0, 0); @@ -189,7 +198,8 @@ void BasicGUI_ArcDlg::ConstructorsClicked (int constructorId) } case 1: { - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); //Select Vertex on All Shapes Group3Pnts->hide(); resize(0, 0); @@ -239,7 +249,6 @@ bool BasicGUI_ArcDlg::ClickOnApply() return true; } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case @@ -251,7 +260,7 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() myEditCurrentArgument->setText(""); - if ( IObjectCount() != 1 ) + if (IObjectCount() != 1) { switch (getConstructorId()) { @@ -276,14 +285,48 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { + QString aName = GEOMBase::GetName(aSelectedObject); + + // Get Selected object if selected subshape + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // Local Selection + { + int anIndex = aMap(1); + aName += QString(":vertex_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + switch (getConstructorId()) { case 0: { - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject; else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = aSelectedObject; else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject; @@ -291,7 +334,6 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() } case 1: { - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) myPoint1 = aSelectedObject; else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) myPoint2 = aSelectedObject; else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3 = aSelectedObject; @@ -303,7 +345,6 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -427,7 +468,7 @@ bool BasicGUI_ArcDlg::execute( ObjectList& objects ) case 1: { bool Sense; - (Group3Pnts2->radioButton4->isChecked()) ? Sense = true : Sense = false; + (Group3Pnts2->CheckButton1->isChecked()) ? Sense = true : Sense = false; if ( !CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2) &&!CORBA::is_nil(myPoint3) ) { anObj = GEOM::GEOM_ICurvesOperations::_narrow(getOperation())-> @@ -451,3 +492,27 @@ void BasicGUI_ArcDlg::ReverseSense(int sense) { displayPreview(); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_ArcDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[Group3Pnts->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts->LineEdit3->text()] = myPoint3; + break; + case 1: + objMap[Group3Pnts2->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts2->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts2->LineEdit3->text()] = myPoint3; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_ArcDlg.h b/src/BasicGUI/BasicGUI_ArcDlg.h index 9fdcc6ba6..fcead28cc 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.h +++ b/src/BasicGUI/BasicGUI_ArcDlg.h @@ -52,6 +52,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init(); diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index 244c0d97f..450ffd984 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,14 +33,23 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include #include -#include "GEOMImpl_Types.hxx" +#include +#include +#include +#include + +//#include + +//#include "GEOMImpl_Types.hxx" #include "utilities.h" //================================================================================= // class : BasicGUI_CircleDlg() -// purpose : Constructs a BasicGUI_CircleDlg which is a child of 'parent', with the +// purpose : Constructs a BasicGUI_CircleDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. @@ -65,7 +74,7 @@ BasicGUI_CircleDlg::BasicGUI_CircleDlg(GeometryGUI* theGeometryGUI, QWidget* par GroupPntVecR = new DlgRef_2Sel1Spin(this, "GroupPntVecR"); GroupPntVecR->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - + GroupPntVecR->TextLabel1->setText(tr("GEOM_CENTER_POINT")); GroupPntVecR->TextLabel2->setText(tr("GEOM_VECTOR")); GroupPntVecR->TextLabel3->setText(tr("GEOM_RADIUS")); @@ -146,7 +155,7 @@ void BasicGUI_CircleDlg::Init() connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); @@ -165,10 +174,11 @@ void BasicGUI_CircleDlg::Init() connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPntVecR->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPntVecR->SpinBox_DX, SLOT(SetStep(double))); - - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPntVecR->SpinBox_DX, SLOT(SetStep(double))); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_CIRCLE" ) ); @@ -183,23 +193,25 @@ void BasicGUI_CircleDlg::Init() //================================================================================= void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0 ); + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + + disconnect(aSelMgr, 0, this, 0); myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); - switch ( constructorId ) + switch (constructorId) { - case 0: - { - Group3Pnts->hide(); - GroupCenter2Pnts->hide(); - resize(0, 0); - GroupPntVecR->show(); - - myEditCurrentArgument = GroupPntVecR->LineEdit1; - GroupPntVecR->LineEdit1->setText(""); - GroupPntVecR->LineEdit2->setText(""); - break; - } + case 0: + { + Group3Pnts->hide(); + GroupCenter2Pnts->hide(); + resize(0, 0); + GroupPntVecR->show(); + + myEditCurrentArgument = GroupPntVecR->LineEdit1; + GroupPntVecR->LineEdit1->setText(""); + GroupPntVecR->LineEdit2->setText(""); + break; + } case 1: { GroupPntVecR->hide(); @@ -212,26 +224,26 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) Group3Pnts->LineEdit2->setText(""); Group3Pnts->LineEdit3->setText(""); break; - } - case 2: - { - GroupPntVecR->hide(); - Group3Pnts->hide(); - resize( 0, 0 ); - GroupCenter2Pnts->show(); - - myEditCurrentArgument = GroupCenter2Pnts->LineEdit1; - GroupCenter2Pnts->LineEdit1->setText(""); - GroupCenter2Pnts->LineEdit2->setText(""); - GroupCenter2Pnts->LineEdit3->setText(""); - break; - } + } + case 2: + { + GroupPntVecR->hide(); + Group3Pnts->hide(); + resize( 0, 0 ); + GroupCenter2Pnts->show(); + + myEditCurrentArgument = GroupCenter2Pnts->LineEdit1; + GroupCenter2Pnts->LineEdit1->setText(""); + GroupCenter2Pnts->LineEdit2->setText(""); + GroupCenter2Pnts->LineEdit3->setText(""); + break; + } } - + myEditCurrentArgument->setFocus(); - globalSelection( GEOM_POINT ); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + connect(aSelMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } //================================================================================= @@ -254,14 +266,14 @@ bool BasicGUI_CircleDlg::ClickOnApply() return false; initName(); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); return true; } -//======================================================================= +//================================================================================= // function : ClickOnCancel() // purpose : -//======================================================================= +//================================================================================= void BasicGUI_CircleDlg::ClickOnCancel() { GEOMBase_Skeleton::ClickOnCancel(); @@ -274,35 +286,80 @@ void BasicGUI_CircleDlg::ClickOnCancel() void BasicGUI_CircleDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - - if ( IObjectCount() != 1 ) + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aList; + 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 = 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(); return; } // nbSel == 1 + Handle(SALOME_InteractiveObject) anIO = aList.First(); + Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) - { - - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); - if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = aSelectedObject; - else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = aSelectedObject; - else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject; - else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = aSelectedObject; - else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject; - else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4 = aSelectedObject; - else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5 = aSelectedObject; - else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6 = aSelectedObject; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) + { + QString aName = GEOMBase::GetName(aSelectedObject); + + // If selected Vertex or Edge on the some Shape Get selection Subshape + 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + + if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint = aSelectedObject; + else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir = aSelectedObject; + else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1 = aSelectedObject; + else if (myEditCurrentArgument == Group3Pnts->LineEdit2) myPoint2 = aSelectedObject; + else if (myEditCurrentArgument == Group3Pnts->LineEdit3) myPoint3 = aSelectedObject; + else if (myEditCurrentArgument == GroupCenter2Pnts->LineEdit1) myPoint4 = aSelectedObject; + else if (myEditCurrentArgument == GroupCenter2Pnts->LineEdit2) myPoint5 = aSelectedObject; + else if (myEditCurrentArgument == GroupCenter2Pnts->LineEdit3) myPoint6 = aSelectedObject; } displayPreview(); } @@ -324,13 +381,17 @@ void BasicGUI_CircleDlg::SetEditCurrentArgument() else if ( send == GroupCenter2Pnts->PushButton1 ) myEditCurrentArgument = GroupCenter2Pnts->LineEdit1; else if ( send == GroupCenter2Pnts->PushButton2 ) myEditCurrentArgument = GroupCenter2Pnts->LineEdit2; else if ( send == GroupCenter2Pnts->PushButton3 ) myEditCurrentArgument = GroupCenter2Pnts->LineEdit3; - + myEditCurrentArgument->setFocus(); - - if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) - globalSelection( GEOM_LINE ); - else - globalSelection( GEOM_POINT ); + + 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); + } SelectionIntoArgument(); } @@ -355,7 +416,6 @@ void BasicGUI_CircleDlg::LineEditReturnPressed() } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -363,16 +423,12 @@ void BasicGUI_CircleDlg::LineEditReturnPressed() void BasicGUI_CircleDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - globalSelection( GEOM_POINT ); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - // myGeomGUI->SetState( 0 ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); ConstructorsClicked( getConstructorId() ); } - //================================================================================= // function : enterEvent() // purpose : @@ -408,11 +464,12 @@ void BasicGUI_CircleDlg::ValueChangedInSpinBox() //================================================================================= double BasicGUI_CircleDlg::getRadius() const { - switch ( getConstructorId() ) - { - case 0 : - return GroupPntVecR->SpinBox_DX->GetValue(); - } + switch (getConstructorId()) + { + case 0: + return GroupPntVecR->SpinBox_DX->GetValue(); + } + return 0.; } //================================================================================= @@ -437,7 +494,7 @@ static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Obje // function : isValid // purpose : //================================================================================= -bool BasicGUI_CircleDlg::isValid( QString& msg ) +bool BasicGUI_CircleDlg::isValid(QString& msg) { const int id = getConstructorId(); if ( id == 0 ) @@ -455,33 +512,37 @@ bool BasicGUI_CircleDlg::isValid( QString& msg ) // function : execute // purpose : //================================================================================= -bool BasicGUI_CircleDlg::execute( ObjectList& objects ) +bool BasicGUI_CircleDlg::execute(ObjectList& objects) { bool res = false; - + GEOM::GEOM_Object_var anObj; - - switch ( getConstructorId() ) + + switch (getConstructorId()) { - cout << "constructior ID = " << getConstructorId() << endl; - case 0 : - anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCirclePntVecR( myPoint, myDir, getRadius() ); + case 0: + anObj = GEOM::GEOM_ICurvesOperations::_narrow(getOperation())-> + MakeCirclePntVecR(myPoint, myDir, getRadius()); res = true; break; - case 1 : - anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 ); + case 1: + anObj = GEOM::GEOM_ICurvesOperations::_narrow(getOperation())-> + MakeCircleThreePnt(myPoint1, myPoint2, myPoint3); res = true; break; - case 2 : - anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCircleCenter2Pnt( myPoint4, myPoint5, myPoint6 ); + case 2: + anObj = GEOM::GEOM_ICurvesOperations::_narrow(getOperation())-> + MakeCircleCenter2Pnt(myPoint4, myPoint5, myPoint6); res = true; break; } - - if ( !anObj->_is_nil() ) - objects.push_back( anObj._retn() ); - else cout << "Execute Object is NULL!" << endl; - + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + else { + MESSAGE("Execute Object is NULL!"); + } + return res; } @@ -489,8 +550,35 @@ bool BasicGUI_CircleDlg::execute( ObjectList& objects ) // function : closeEvent // purpose : //================================================================================= -void BasicGUI_CircleDlg::closeEvent( QCloseEvent* e ) +void BasicGUI_CircleDlg::closeEvent (QCloseEvent* e) { - GEOMBase_Skeleton::closeEvent( e ); + GEOMBase_Skeleton::closeEvent(e); } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_CircleDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPntVecR->LineEdit1->text()] = myPoint; + objMap[GroupPntVecR->LineEdit2->text()] = myDir; + break; + case 1: + objMap[Group3Pnts->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts->LineEdit3->text()] = myPoint3; + break; + case 2: + objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4; + objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5; + objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_CircleDlg.h b/src/BasicGUI/BasicGUI_CircleDlg.h index 3bf6e2015..cbe68d98b 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.h +++ b/src/BasicGUI/BasicGUI_CircleDlg.h @@ -54,8 +54,8 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - virtual void closeEvent( QCloseEvent* e ); + virtual void addSubshapesToStudy(); private: void Init(); @@ -68,6 +68,7 @@ private: DlgRef_2Sel1Spin* GroupPntVecR; DlgRef_3Sel_QTD* Group3Pnts; DlgRef_3Sel_QTD* GroupCenter2Pnts; + private slots: void ClickOnOk(); void ClickOnCancel(); diff --git a/src/BasicGUI/BasicGUI_CurveDlg.cxx b/src/BasicGUI/BasicGUI_CurveDlg.cxx index 799adc746..a28c91af5 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.cxx +++ b/src/BasicGUI/BasicGUI_CurveDlg.cxx @@ -16,7 +16,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -30,6 +30,7 @@ #include "SUIT_Desktop.h" #include "SUIT_Session.h" #include "SalomeApp_Application.h" +#include "SalomeApp_Study.h" #include "LightApp_SelectionMgr.h" #include @@ -39,6 +40,12 @@ #include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_ListIO.hxx" +#include +#include +#include +#include +#include + #include "GEOMImpl_Types.hxx" using namespace std; @@ -106,7 +113,8 @@ void BasicGUI_CurveDlg::Init() myPoints = new GEOM::ListOfGO(); myPoints->length( 0 ); - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); @@ -120,7 +128,7 @@ void BasicGUI_CurveDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; initName( tr( "GEOM_CURVE" ) ); @@ -225,6 +233,7 @@ static int isPointInList(list& thePoints, return -1; } + //================================================================================= /*! function : removeUnnecessaryPnt() * purpose : Remove unnecessary points from list \a theOldPoints @@ -263,40 +272,97 @@ void BasicGUI_CurveDlg::SelectionIntoArgument() myEditCurrentArgument->setText(""); Standard_Boolean aRes = Standard_False; - int i = 0; int IOC = IObjectCount(); - bool is_append = myPoints->length() < IOC; // if true - add point, else remove - myPoints->length( IOC ); // this length may be greater than number of objects, + // 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( selectedIO() ); anIt.More(); anIt.Next() ) + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + _PTR(Study) aDStudy = appStudy->studyDS(); + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); + + int anIndex; + TopoDS_Shape aShape; + TColStd_IndexedMapOfInteger aMapIndexes; + GEOM::GEOM_Object_var anObject; + std::list aList; + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected, QString::null, false ); + + for ( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() ) { GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) { - //TopoDS_Shape aPointShape; - //if ( myGeomBase->GetShape( aSelectedObject, aPointShape, TopAbs_VERTEX ) ) - int pos = isPointInList(myOrderedSel,aSelectedObject); - if(is_append && pos==-1) - myOrderedSel.push_back(aSelectedObject); - myPoints[i++] = 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; + for (_PTR(ChildIterator) iit (aDStudy->NewChildIterator(obj)); iit->More(); iit->Next()) { + _PTR(SObject) child (iit->Value()); + QString aChildName = child->GetName(); + 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, aSelectedObject); + + int pos = isPointInList(myOrderedSel, anObject); + if (pos==-1) { + myOrderedSel.push_back(anObject); + } + // if (!inStudy) + aList.push_back(anObject); + } + } else { // aMap.Extent() == 0 + int pos = isPointInList(myOrderedSel,aSelectedObject); + if(pos==-1) + myOrderedSel.push_back(aSelectedObject); + aList.push_back(aSelectedObject); + } + } } } - myPoints->length( i ); // this is the right length, smaller of equal to the previously set + myPoints->length( aList.size() ); + + int k=0; + for (list::iterator j=aList.begin();j!=aList.end();j++) + myPoints[k++] = *j; + if(IOC == 0) myOrderedSel.clear(); else - removeUnnecessaryPnt(myOrderedSel,myPoints); - - if(myOrderedSel.size() == myPoints->length()){ - int k=0; - for (list::iterator j=myOrderedSel.begin();j!=myOrderedSel.end();j++) - myPoints[k++] = *j; - } else { - //cout << "ERROR: Ordered sequence size != selection sequence size! ("<length()<<")"<LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) ); + removeUnnecessaryPnt(myOrderedSel, myPoints); + + // if ( myOrderedSel.size() == myPoints->length() ) { + myPoints->length( myOrderedSel.size() ); + k=0; + for (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_" ) ); displayPreview(); } @@ -309,12 +375,11 @@ void BasicGUI_CurveDlg::SelectionIntoArgument() void BasicGUI_CurveDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - // myGeomGUI->SetState( 0 ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); ConstructorsClicked( getConstructorId() ); } diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.cxx b/src/BasicGUI/BasicGUI_EllipseDlg.cxx index c1a1e5dc3..04baab168 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.cxx +++ b/src/BasicGUI/BasicGUI_EllipseDlg.cxx @@ -16,7 +16,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -32,6 +32,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -101,12 +108,11 @@ void BasicGUI_EllipseDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); myPoint = myDir = GEOM::GEOM_Object::_nil(); - // myGeomGUI->SetState( 0 ); - /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); @@ -136,16 +142,17 @@ void BasicGUI_EllipseDlg::Init() connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DY, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; initName( tr( "GEOM_ELLIPSE" ) ); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -156,7 +163,6 @@ void BasicGUI_EllipseDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : @@ -173,8 +179,10 @@ bool BasicGUI_EllipseDlg::ClickOnApply() GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit2->setText( "" ); myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_POINT ); - + //globalSelection(GEOM_POINT); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + return true; } @@ -203,10 +211,53 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument() } Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + Handle(SALOME_InteractiveObject) anIO = firstIObject(); + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + QString aName = GEOMBase::GetName(aSelectedObject); + + // Get Selected object if selected subshape + TopoDS_Shape aShape; + + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPoints->LineEdit2) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(anIO, aMap); + if (aMap.Extent() == 1) + { + 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } else { + aSelectedObject = aFindedObject; // get Object from study + } + } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint = aSelectedObject; else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myDir = aSelectedObject; } @@ -222,15 +273,17 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument() void BasicGUI_EllipseDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_POINT ); if ( send == GroupPoints->PushButton1 ) myEditCurrentArgument = GroupPoints->LineEdit1; else if ( send == GroupPoints->PushButton2 ) myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument->setFocus(); + globalSelection(); // close local contexts, if any if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) - globalSelection( GEOM_LINE ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); else - globalSelection( GEOM_POINT ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); SelectionIntoArgument(); } @@ -257,9 +310,9 @@ void BasicGUI_EllipseDlg::LineEditReturnPressed() void BasicGUI_EllipseDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; @@ -267,7 +320,9 @@ void BasicGUI_EllipseDlg::ActivateThisDialog() GroupPoints->LineEdit2->setText( "" ); myPoint = myDir = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_POINT ); + //globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); } //================================================================================= @@ -349,3 +404,16 @@ void BasicGUI_EllipseDlg::closeEvent( QCloseEvent* e ) GEOMBase_Skeleton::closeEvent( e ); } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_EllipseDlg::addSubshapesToStudy() +{ + QMap objMap; + + objMap[GroupPoints->LineEdit1->text()] = myPoint; + objMap[GroupPoints->LineEdit2->text()] = myDir; + + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.h b/src/BasicGUI/BasicGUI_EllipseDlg.h index 038700f53..5cf4f5a73 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.h +++ b/src/BasicGUI/BasicGUI_EllipseDlg.h @@ -52,8 +52,8 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - virtual void closeEvent( QCloseEvent* e ); + virtual void addSubshapesToStudy(); private : void Init(); diff --git a/src/BasicGUI/BasicGUI_LineDlg.cxx b/src/BasicGUI/BasicGUI_LineDlg.cxx index 1291c8638..e4c65f7dc 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.cxx +++ b/src/BasicGUI/BasicGUI_LineDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,6 +33,12 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -55,26 +61,39 @@ BasicGUI_LineDlg::BasicGUI_LineDlg(GeometryGUI* theGeometryGUI, QWidget* parent, { QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM",tr("ICON_DLG_LINE_2P"))); QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM",tr("ICON_DLG_LINE_2F"))); setCaption(tr("GEOM_LINE_TITLE")); + QGroupBox* aFrame = new QGroupBox( 1, Qt::Horizontal, this ); + aFrame->setInsideMargin( 0 ); + aFrame->setFrameStyle( QFrame::NoFrame ); + /***************************************************************/ GroupConstructors->setTitle(tr("GEOM_LINE")); RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); + RadioButton2->setPixmap(image2); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_2Sel_QTD(this, "GroupPoints"); + GroupPoints = new DlgRef_2Sel_QTD( aFrame, "GroupPoints"); GroupPoints->GroupBox1->setTitle(tr("GEOM_POINTS")); GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg("1")); GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg("2")); GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton2->setPixmap(image1); - GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly( true ); - Layout1->addWidget(GroupPoints, 2, 0); + GroupFaces = new DlgRef_2Sel_QTD( aFrame, "GroupFaces"); + GroupFaces->GroupBox1->setTitle(tr("GEOM_FACES")); + GroupFaces->TextLabel1->setText(tr("GEOM_FACE_I").arg("1")); + GroupFaces->TextLabel2->setText(tr("GEOM_FACE_I").arg("2")); + GroupFaces->PushButton1->setPixmap(image1); + GroupFaces->PushButton2->setPixmap(image1); + GroupFaces->LineEdit1->setReadOnly( true ); + GroupFaces->LineEdit2->setReadOnly( true ); + + Layout1->addWidget(aFrame, 2, 0); /***************************************************************/ setHelpFileName("create_line_page.html"); @@ -82,7 +101,6 @@ BasicGUI_LineDlg::BasicGUI_LineDlg(GeometryGUI* theGeometryGUI, QWidget* parent, Init(); } - //================================================================================= // function : ~BasicGUI_LineDlg() // purpose : Destroys the object and frees any allocated resources @@ -91,7 +109,6 @@ BasicGUI_LineDlg::~BasicGUI_LineDlg() { } - //================================================================================= // function : Init() // purpose : @@ -99,34 +116,37 @@ BasicGUI_LineDlg::~BasicGUI_LineDlg() void BasicGUI_LineDlg::Init() { /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - - myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); - - // myGeomGUI->SetState( 0 ); - globalSelection( GEOM_POINT ); + //myEditCurrentArgument = GroupPoints->LineEdit1; + //myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + //globalSelection(); // close local contexts, if any + //localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + 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(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + ConstructorsClicked(0); initName( tr("GEOM_LINE") ); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -137,10 +157,10 @@ void BasicGUI_LineDlg::ClickOnOk() ClickOnCancel(); } -//======================================================================= +//================================================================================= // function : ClickOnCancel() // purpose : -//======================================================================= +//================================================================================= void BasicGUI_LineDlg::ClickOnCancel() { GEOMBase_Skeleton::ClickOnCancel(); @@ -152,13 +172,55 @@ void BasicGUI_LineDlg::ClickOnCancel() //================================================================================= bool BasicGUI_LineDlg::ClickOnApply() { + if ( !onAccept() ) return false; - + initName(); + ConstructorsClicked(getConstructorId()); return true; } +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +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(""); + myPoint1 = GEOM::GEOM_Object::_nil(); + myPoint2 = GEOM::GEOM_Object::_nil(); + GroupPoints->show(); + GroupFaces->hide(); + break; + } + 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(); + GroupPoints->hide(); + GroupFaces->show(); + break; + } + } + + updateGeometry(); + resize(minimumSize()); + SelectionIntoArgument(); +} //================================================================================= // function : SelectionIntoArgument() @@ -168,27 +230,71 @@ void BasicGUI_LineDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - if ( IObjectCount() != 1 ) + if (IObjectCount() != 1) { - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupFaces->LineEdit1 ) myFace1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupFaces->LineEdit2 ) myFace2 = GEOM::GEOM_Object::_nil(); return; } // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + QString aName = GEOMBase::GetName(aSelectedObject); + + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupFaces->LineEdit1 || + myEditCurrentArgument == GroupFaces->LineEdit2) + aNeedType = TopAbs_FACE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // Local Selection + { + int anIndex = aMap( 1 ); + if (aNeedType == TopAbs_FACE) + aName += QString(":face_%1").arg(anIndex); + else + aName += QString(":vertex_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = aSelectedObject; else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = aSelectedObject; + else if ( myEditCurrentArgument == GroupFaces->LineEdit1 ) myFace1 = aSelectedObject; + else if ( myEditCurrentArgument == GroupFaces->LineEdit2 ) myFace2 = aSelectedObject; } displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -198,11 +304,12 @@ void BasicGUI_LineDlg::SetEditCurrentArgument() QPushButton* send = (QPushButton*)sender(); if ( send == GroupPoints->PushButton1 ) myEditCurrentArgument = GroupPoints->LineEdit1; else if ( send == GroupPoints->PushButton2 ) myEditCurrentArgument = GroupPoints->LineEdit2; + else if ( send == GroupFaces->PushButton1 ) myEditCurrentArgument = GroupFaces->LineEdit1; + else if ( send == GroupFaces->PushButton2 ) myEditCurrentArgument = GroupFaces->LineEdit2; myEditCurrentArgument->setFocus(); SelectionIntoArgument(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -212,11 +319,12 @@ 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 : @@ -224,18 +332,10 @@ void BasicGUI_LineDlg::LineEditReturnPressed() void BasicGUI_LineDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - // myGeomGUI->SetState( 0 ); - globalSelection( GEOM_POINT ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - myEditCurrentArgument = GroupPoints->LineEdit1; - myEditCurrentArgument->setFocus(); - - GroupPoints->LineEdit1->setText( "" ); - GroupPoints->LineEdit2->setText( "" ); - myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -244,7 +344,6 @@ void BasicGUI_LineDlg::ActivateThisDialog() //================================================================================= void BasicGUI_LineDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -273,7 +372,12 @@ GEOM::GEOM_IOperations_ptr BasicGUI_LineDlg::createOperation() //================================================================================= bool BasicGUI_LineDlg::isValid( QString& msg ) { - return !myPoint1->_is_nil() && !myPoint2->_is_nil(); + 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; } //================================================================================= @@ -282,10 +386,27 @@ bool BasicGUI_LineDlg::isValid( QString& msg ) //================================================================================= bool BasicGUI_LineDlg::execute( ObjectList& objects ) { - GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakeLineTwoPnt( myPoint1, myPoint2 ); + bool res = false; + GEOM::GEOM_Object_var anObj; + switch ( getConstructorId() ) + { + case 0 : + { + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakeLineTwoPnt( myPoint1, myPoint2 ); + res = true; + break; + } + case 1 : + { + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakeLineTwoFaces( myFace1, myFace2 ); + res = true; + break; + } + } if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); - return true; + + return res; } //================================================================================= @@ -297,3 +418,23 @@ void BasicGUI_LineDlg::closeEvent( QCloseEvent* e ) GEOMBase_Skeleton::closeEvent( e ); } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_LineDlg::addSubshapesToStudy() +{ + QMap objMap; + switch ( getConstructorId() ) + { + case 0 : + objMap[GroupPoints->LineEdit1->text()] = myPoint1; + objMap[GroupPoints->LineEdit2->text()] = myPoint2; + break; + case 1 : + objMap[GroupFaces->LineEdit1->text()] = myFace1; + objMap[GroupFaces->LineEdit2->text()] = myFace2; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_LineDlg.h b/src/BasicGUI/BasicGUI_LineDlg.h index 65eba2b98..9985759fd 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.h +++ b/src/BasicGUI/BasicGUI_LineDlg.h @@ -53,6 +53,7 @@ protected: virtual bool execute( ObjectList& objects ); virtual void closeEvent( QCloseEvent* e ); + virtual void addSubshapesToStudy(); private : void Init(); @@ -60,8 +61,11 @@ private : GEOM::GEOM_Object_var myPoint1; GEOM::GEOM_Object_var myPoint2; + GEOM::GEOM_Object_var myFace1; + GEOM::GEOM_Object_var myFace2; DlgRef_2Sel_QTD* GroupPoints; + DlgRef_2Sel_QTD* GroupFaces; private slots: void ClickOnOk(); @@ -70,7 +74,7 @@ private slots: void ActivateThisDialog(); void DeactivateActiveDialog(); - + void ConstructorsClicked(int constructorId); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BasicGUI/BasicGUI_MarkerDlg.cxx b/src/BasicGUI/BasicGUI_MarkerDlg.cxx index 82028782c..7b6cf2766 100644 --- a/src/BasicGUI/BasicGUI_MarkerDlg.cxx +++ b/src/BasicGUI/BasicGUI_MarkerDlg.cxx @@ -124,7 +124,6 @@ BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* th Init(); } - //================================================================================= // function : ~BasicGUI_MarkerDlg() // purpose : Destroys the object and frees any allocated resources @@ -133,7 +132,6 @@ BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg() { } - //================================================================================= // function : Init() // purpose : @@ -166,7 +164,7 @@ void BasicGUI_MarkerDlg::Init() connect( buttonOk, SIGNAL( clicked() ), this, SLOT( onOk() ) ); connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) ); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); initName( tr( "LCS_NAME" ) ); @@ -190,7 +188,6 @@ void BasicGUI_MarkerDlg::Init() ConstructorsClicked( 0 ); - //@ /* QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()-> @@ -217,6 +214,7 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId ) { if ( myConstructorId == constructorId && myConstructorId == 0 ) { + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); activate( GEOM_MARKER ); displayPreview(); @@ -225,50 +223,52 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId ) myConstructorId = constructorId; - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); switch (constructorId) - { - case 0: + { + case 0: { Group1->hide(); Group2->hide(); resize(0, 0); aMainGrp->show(); + globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); activate( GEOM_MARKER ); break; } - case 1: - { - Group2->hide(); - aMainGrp->hide(); - //PAL6669: resize(0, 0); - Group1->show(); - - globalSelection( GEOM_ALLGEOM ); - myEditCurrentArgument = Group1->LineEdit1; - Group1->LineEdit1->setText(""); - break; - } - case 2: - { - aMainGrp->hide(); - Group1->show(); - //PAL6669: resize(0, 0); - Group2->show(); - - globalSelection( GEOM_POINT ); - myEditCurrentArgument = Group2->LineEdit1; - Group2->LineEdit1->setText(""); - Group2->LineEdit2->setText(""); - Group2->LineEdit3->setText(""); - break; - } + case 1: + { + Group2->hide(); + aMainGrp->hide(); + //PAL6669: resize(0, 0); + Group1->show(); + + globalSelection( GEOM_ALLGEOM ); + myEditCurrentArgument = Group1->LineEdit1; + Group1->LineEdit1->setText(""); + break; + } + case 2: + { + aMainGrp->hide(); + Group1->show(); + //PAL6669: resize(0, 0); + Group2->show(); + + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + myEditCurrentArgument = Group2->LineEdit1; + Group2->LineEdit1->setText(""); + Group2->LineEdit2->setText(""); + Group2->LineEdit3->setText(""); + break; } + } - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(onSelectionDone())); onSelectionDone(); } @@ -312,26 +312,26 @@ bool BasicGUI_MarkerDlg::onApply() //================================================================================= void BasicGUI_MarkerDlg::onSelectionDone0() { - if ( IObjectCount() == 1 ) + if (IObjectCount() == 1) { Standard_Boolean aRes = Standard_False; Handle(SALOME_InteractiveObject) anIO = firstIObject(); - GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - if ( aRes && !aSelectedObj->_is_nil() ) + if (aRes && !aSelectedObj->_is_nil()) { TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + if (GEOMBase::GetShape(aSelectedObj, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { // Existing LCS selected - if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) + if (aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE) { - TopoDS_Face aFace = TopoDS::Face( aShape ); - Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) ); + TopoDS_Face aFace = TopoDS::Face(aShape); + Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(aFace)); - if ( !aPlane.IsNull() ) + if (!aPlane.IsNull()) { gp_Ax3 anAx3 = aPlane->Pln().Position(); gp_Pnt aLoc = anAx3.Location(); @@ -355,19 +355,19 @@ void BasicGUI_MarkerDlg::onSelectionDone0() else { TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes( anIO, aMap ); - if ( aMap.Extent() == 1 ) + aSelMgr->GetIndexes(anIO, aMap); + if (aMap.Extent() == 1) // Local Selection { - int anIndex = aMap( 1 ); + int anIndex = aMap(1); TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); - aSelMgr->clearSelected(); + TopExp::MapShapes(aShape, aShapes); + aShape = aShapes.FindKey(anIndex); + aSelMgr->clearSelected(); // ??? } - if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { - gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); myData[ X ]->SetValue( aPnt.X() ); myData[ Y ]->SetValue( aPnt.Y() ); myData[ Z ]->SetValue( aPnt.Z() ); @@ -380,30 +380,28 @@ void BasicGUI_MarkerDlg::onSelectionDone0() displayPreview(); } - //================================================================================= // function : onSelectionDone() // purpose : Called when selection as changed or other case //================================================================================= void BasicGUI_MarkerDlg::onSelectionDone() { - if ( getConstructorId() == 0 ) { + if (getConstructorId() == 0) { onSelectionDone0(); return; } myEditCurrentArgument->setText(""); - QString aName; - if ( IObjectCount() == 1 ) { + if (IObjectCount() == 1) { Standard_Boolean aRes = Standard_False; Handle(SALOME_InteractiveObject) anIO = firstIObject(); - GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes); - if ( !CORBA::is_nil( aSelectedObj ) && aRes ) { - aName = GEOMBase::GetName( aSelectedObj ); + if (!CORBA::is_nil(aSelectedObj) && aRes) { + QString aName = GEOMBase::GetName(aSelectedObj); - if ( getConstructorId() == 1 ) { // by shape position + if (getConstructorId() == 1) { // by shape position // Get shape's position CORBA::Double Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz, Yx,Yy,Yz; Ox = Oy = Oz = Zx = Zy = Xy = Xz = Yx = Yz = 0; @@ -437,31 +435,39 @@ void BasicGUI_MarkerDlg::onSelectionDone() myData[ DY2 ]->SetValue( Yy ); myData[ DZ2 ]->SetValue( Yz ); - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); } - else if ( getConstructorId() == 2 ) { // by point and two vectors + else if (getConstructorId() == 2) { // by point and two vectors TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) { - GEOM::short_array anIndexes; + if (GEOMBase::GetShape(aSelectedObj, aShape, TopAbs_SHAPE)) + { + TopAbs_ShapeEnum aNeedType = TopAbs_EDGE; + if (myEditCurrentArgument == Group2->LineEdit1) + aNeedType = TopAbs_VERTEX; TColStd_IndexedMapOfInteger aMap; LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - aSelMgr->GetIndexes( anIO, aMap ); + aSelMgr->GetIndexes(anIO, aMap); + + if (!aMap.IsEmpty()) { + int anIndex = aMap(1); + if (aNeedType == TopAbs_EDGE) + aName += QString("_edge_%1").arg(anIndex); + else + aName += QString("_vertex_%1").arg(anIndex); - if ( !aMap.IsEmpty() ) { - int anIndex = aMap( 1 ); TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); + TopExp::MapShapes(aShape, aShapes); + aShape = aShapes.FindKey(anIndex); } if (myEditCurrentArgument == Group2->LineEdit1) { - if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) { - gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); myData[ X ]->SetValue( aPnt.X() ); myData[ Y ]->SetValue( aPnt.Y() ); myData[ Z ]->SetValue( aPnt.Z() ); - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); } else { myData[ X ]->SetValue( 0 ); @@ -473,12 +479,12 @@ void BasicGUI_MarkerDlg::onSelectionDone() if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) { gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape))); gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape))); - gp_Dir aDir(gp_Vec(aP1, aP2)); + gp_Dir aDir (gp_Vec(aP1, aP2)); myData[ DX1 ]->SetValue( aDir.X() ); myData[ DY1 ]->SetValue( aDir.Y() ); myData[ DZ1 ]->SetValue( aDir.Z() ); - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); } else { myData[ DX1 ]->SetValue( 0 ); @@ -495,7 +501,7 @@ void BasicGUI_MarkerDlg::onSelectionDone() myData[ DX2 ]->SetValue( aDir.X() ); myData[ DY2 ]->SetValue( aDir.Y() ); myData[ DZ2 ]->SetValue( aDir.Z() ); - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(aName); } else { myData[ DX2 ]->SetValue( 0 ); @@ -551,21 +557,26 @@ void BasicGUI_MarkerDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == Group1->PushButton1) { + if (send == Group1->PushButton1) { myEditCurrentArgument = Group1->LineEdit1; globalSelection( GEOM_ALLGEOM ); } - else if(send == Group2->PushButton1) { + else if (send == Group2->PushButton1) { myEditCurrentArgument = Group2->LineEdit1; - globalSelection( GEOM_POINT ); + //globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } - else if(send == Group2->PushButton2) { + else if (send == Group2->PushButton2) { myEditCurrentArgument = Group2->LineEdit2; - globalSelection( GEOM_LINE ); + //globalSelection( GEOM_LINE ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } - else if(send == Group2->PushButton3) { + else if (send == Group2->PushButton3) { myEditCurrentArgument = Group2->LineEdit3; - globalSelection( GEOM_LINE ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); @@ -591,10 +602,10 @@ void BasicGUI_MarkerDlg::LineEditReturnPressed() void BasicGUI_MarkerDlg::onActivate() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(onSelectionDone())); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -664,10 +675,10 @@ bool BasicGUI_MarkerDlg::isValid( QString& msg ) //================================================================================= bool BasicGUI_MarkerDlg::execute( ObjectList& objects ) { - GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow( - getOperation() )->MakeMarker( myData[ X ]->GetValue(), myData[ Y ]->GetValue(), myData[ Z ]->GetValue(), - myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue(), - myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() ); + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow(getOperation())-> + MakeMarker(myData[ X ]->GetValue(), myData[ Y ]->GetValue(), myData[ Z ]->GetValue(), + myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue(), + myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue()); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx index b9ba65afc..64936d546 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -35,6 +35,13 @@ #include +#include +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -176,7 +183,7 @@ void BasicGUI_PlaneDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Pnts->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupFace->SpinBox_DX, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_PLANE" ) ); @@ -192,68 +199,69 @@ void BasicGUI_PlaneDlg::Init() //================================================================================= void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil(); - switch ( constructorId ) + switch (constructorId) { - case 0: /* plane from a point and a direction (vector, edge...) */ - { - Group3Pnts->hide(); - GroupFace->hide(); - resize(0, 0); - GroupPntDir->show(); - - myEditCurrentArgument = GroupPntDir->LineEdit1; - GroupPntDir->LineEdit1->setText(tr("")); - GroupPntDir->LineEdit2->setText(tr("")); - - /* for the first argument */ - globalSelection( GEOM_POINT ); - break; - } - case 1: /* plane from 3 points */ - { - GroupPntDir->hide(); - GroupFace->hide(); - resize(0, 0); - Group3Pnts->show(); - - myEditCurrentArgument = Group3Pnts->LineEdit1; - Group3Pnts->LineEdit1->setText(""); - Group3Pnts->LineEdit2->setText(""); - Group3Pnts->LineEdit3->setText(""); - - /* for the first argument */ - globalSelection( GEOM_POINT ); - break; - } - case 2: /* plane from a planar face selection */ - { - GroupPntDir->hide(); - Group3Pnts->hide(); - resize(0, 0); - GroupFace->show(); - - myEditCurrentArgument = GroupFace->LineEdit1; - GroupFace->LineEdit1->setText(tr("")); - - /* for the first argument */ - //globalSelection( GEOM_PLANE ); - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_PLANE ); - aMap.Add( GEOM_MARKER ); - globalSelection( aMap ); - break; - } + case 0: /* plane from a point and a direction (vector, edge...) */ + { + Group3Pnts->hide(); + GroupFace->hide(); + resize(0, 0); + GroupPntDir->show(); + + myEditCurrentArgument = GroupPntDir->LineEdit1; + GroupPntDir->LineEdit1->setText(tr("")); + GroupPntDir->LineEdit2->setText(tr("")); + + /* for the first argument */ + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + break; + } + case 1: /* plane from 3 points */ + { + GroupPntDir->hide(); + GroupFace->hide(); + resize(0, 0); + Group3Pnts->show(); + + myEditCurrentArgument = Group3Pnts->LineEdit1; + Group3Pnts->LineEdit1->setText(""); + Group3Pnts->LineEdit2->setText(""); + Group3Pnts->LineEdit3->setText(""); + + /* for the first argument */ + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + break; } + case 2: /* plane from a planar face selection */ + { + GroupPntDir->hide(); + Group3Pnts->hide(); + resize(0, 0); + GroupFace->show(); + + myEditCurrentArgument = GroupFace->LineEdit1; + GroupFace->LineEdit1->setText(tr("")); + + /* for the first argument */ + //globalSelection( GEOM_PLANE ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_PLANE ); + aMap.Add( GEOM_MARKER ); + globalSelection( aMap ); + break; + } + } myEditCurrentArgument->setFocus(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -264,7 +272,6 @@ void BasicGUI_PlaneDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : @@ -296,7 +303,7 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - if ( IObjectCount() != 1 ) + if (IObjectCount() != 1) { if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); @@ -309,10 +316,55 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + QString aName = GEOMBase::GetName(aSelectedObject); + + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPntDir->LineEdit2) + aNeedType = TopAbs_EDGE; + else if (myEditCurrentArgument == GroupFace->LineEdit1) + aNeedType = TopAbs_FACE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // Local Selection + { + + int anIndex = aMap(1); + if (aNeedType == TopAbs_EDGE) + aName += QString(":edge_%1").arg(anIndex); + else if (aNeedType == TopAbs_FACE) + aName += QString(":face_%1").arg(anIndex); + else + aName += QString(":vertex_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = aSelectedObject; else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = aSelectedObject; else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject; @@ -332,6 +384,7 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() void BasicGUI_PlaneDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_POINT ); if ( send == GroupPntDir->PushButton1 ) myEditCurrentArgument = GroupPntDir->LineEdit1; else if ( send == GroupPntDir->PushButton2 ) myEditCurrentArgument = GroupPntDir->LineEdit2; @@ -342,22 +395,24 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument() myEditCurrentArgument->setFocus(); - if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) - globalSelection( GEOM_LINE ); - else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) { - //globalSelection( GEOM_PLANE ); + if (myEditCurrentArgument == GroupPntDir->LineEdit2) { + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + } + else if (myEditCurrentArgument == GroupFace->LineEdit1) { TColStd_MapOfInteger aMap; aMap.Add( GEOM_PLANE ); aMap.Add( GEOM_MARKER ); globalSelection( aMap ); } - else - globalSelection( GEOM_POINT ); + else { // 3 Pnts + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + } SelectionIntoArgument(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -377,7 +432,6 @@ void BasicGUI_PlaneDlg::LineEditReturnPressed() } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -385,12 +439,10 @@ void BasicGUI_PlaneDlg::LineEditReturnPressed() void BasicGUI_PlaneDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - // myGeomGUI->SetState( 0 ); - - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -399,7 +451,6 @@ void BasicGUI_PlaneDlg::ActivateThisDialog() //================================================================================= void BasicGUI_PlaneDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -519,3 +570,28 @@ void BasicGUI_PlaneDlg::closeEvent( QCloseEvent* e ) GEOMBase_Skeleton::closeEvent( e ); } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_PlaneDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPntDir->LineEdit1->text()] = myPoint; + objMap[GroupPntDir->LineEdit2->text()] = myDir; + break; + case 1: + objMap[Group3Pnts->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts->LineEdit3->text()] = myPoint3; + break; + case 2: + objMap[GroupFace->LineEdit1->text()] = myFace; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.h b/src/BasicGUI/BasicGUI_PlaneDlg.h index 05e8c69ec..7eaf7ed3f 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.h +++ b/src/BasicGUI/BasicGUI_PlaneDlg.h @@ -53,7 +53,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index f0ed67e26..573e8bda8 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -10,14 +10,14 @@ // // 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 +// 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 // // // @@ -49,10 +49,12 @@ #include #include + using namespace std; + //================================================================================= // class : BasicGUI_PointDlg() -// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the +// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. @@ -65,6 +67,7 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_POINT_EDGE"))); QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_POINT_REF"))); + QPixmap image4(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_POINT_LINES"))); setCaption(tr("GEOM_POINT_TITLE")); @@ -77,6 +80,8 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren RadioButton1->setPixmap(image0); RadioButton2->setPixmap(image3); RadioButton3->setPixmap(image1); + RadioButton4->show(); + RadioButton4->setPixmap(image4); GroupXYZ = new DlgRef_3Spin( aFrame, "GroupXYZ" ); GroupXYZ->GroupBox1->setTitle(tr("GEOM_COORDINATES")); @@ -98,6 +103,13 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren GroupRefPoint->TextLabel3->setText(tr("GEOM_DY")); GroupRefPoint->TextLabel4->setText(tr("GEOM_DZ")); + GroupLineIntersection = new DlgRef_2Sel_QTD (aFrame, "GroupLineIntersection"); + GroupLineIntersection->GroupBox1->setTitle(tr("GEOM_LINE_INTERSECTION")); + GroupLineIntersection->TextLabel1->setText(tr("GEOM_LINE1")); + GroupLineIntersection->PushButton1->setPixmap(image2); + GroupLineIntersection->TextLabel2->setText(tr("GEOM_LINE2")); + GroupLineIntersection->PushButton2->setPixmap(image2); + Layout1->addWidget( aFrame, 2, 0 ); /***************************************************************/ @@ -123,12 +135,12 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren myY->setPalette( aPal ); myZ->setPalette( aPal ); - setHelpFileName("create_point_page.html"); - + // setHelpFileName("create_point_page.html"); + setHelpFileName("point.htm"); + Init(); } - //================================================================================= // function : ~BasicGUI_PointDlg() // purpose : Destructor @@ -137,7 +149,6 @@ BasicGUI_PointDlg::~BasicGUI_PointDlg() { } - //================================================================================= // function : Init() // purpose : @@ -146,6 +157,8 @@ void BasicGUI_PointDlg::Init() { GroupOnCurve->LineEdit1->setReadOnly( true ); GroupRefPoint->LineEdit1->setReadOnly( true ); + GroupLineIntersection->LineEdit1->setReadOnly( true ); + GroupLineIntersection->LineEdit2->setReadOnly( true ); myEdge = GEOM::GEOM_Object::_nil(); myRefPoint = GEOM::GEOM_Object::_nil(); @@ -155,7 +168,7 @@ void BasicGUI_PointDlg::Init() /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); - + /* min, max, step and decimals for spin boxes */ GroupXYZ->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); GroupXYZ->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); @@ -186,6 +199,10 @@ void BasicGUI_PointDlg::Init() connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupOnCurve->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupLineIntersection->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupLineIntersection->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupLineIntersection->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupLineIntersection->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupXYZ->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); @@ -195,40 +212,47 @@ void BasicGUI_PointDlg::Init() connect(GroupRefPoint->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupRefPoint->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupOnCurve->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DZ, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DZ, SLOT(SetStep(double))); - - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupOnCurve->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupXYZ->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupXYZ->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupXYZ->SpinBox_DZ, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupRefPoint->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupRefPoint->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupRefPoint->SpinBox_DZ, SLOT(SetStep(double))); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + initName( tr("GEOM_VERTEX") ); - + ConstructorsClicked( 0 ); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) -{ - switch ( constructorId ) +void BasicGUI_PointDlg::ConstructorsClicked (int constructorId) +{ + globalSelection(); // close local contexts, if any + + switch (constructorId) { case 0: { - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupRefPoint->hide(); GroupOnCurve->hide(); - + GroupLineIntersection->hide(); GroupXYZ->show(); - myCoordGrp->hide(); break; } @@ -238,13 +262,12 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) myEditCurrentArgument->setText(""); myRefPoint = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_POINT ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupXYZ->hide(); GroupOnCurve->hide(); - GroupRefPoint->show(); - + GroupLineIntersection->hide(); myCoordGrp->show(); break; } @@ -254,16 +277,32 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) myEditCurrentArgument->setText(""); myEdge = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_EDGE ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); GroupXYZ->hide(); GroupRefPoint->hide(); - GroupOnCurve->show(); - + GroupLineIntersection->hide(); myCoordGrp->show(); break; } + case 3: + { + myEditCurrentArgument = GroupLineIntersection->LineEdit1; + GroupLineIntersection->LineEdit1->setText(""); + GroupLineIntersection->LineEdit2->setText(""); + myLine1 = GEOM::GEOM_Object::_nil(); + myLine2 = GEOM::GEOM_Object::_nil(); + + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + + GroupXYZ->hide(); + GroupRefPoint->hide(); + GroupOnCurve->hide(); + GroupLineIntersection->show(); + myCoordGrp->hide(); + break; + } } myX->setText( "" ); @@ -277,33 +316,30 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) SelectionIntoArgument(); } - //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void BasicGUI_PointDlg::ClickOnOk() { - if ( onAccept() ) + if (onAccept()) ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= bool BasicGUI_PointDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; - + initName(); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); return true; } - //================================================================================= // function : ClickOnCancel() // purpose : @@ -313,7 +349,6 @@ void BasicGUI_PointDlg::ClickOnCancel() GEOMBase_Skeleton::ClickOnCancel(); } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed (for constructors not using local context) @@ -322,7 +357,7 @@ void BasicGUI_PointDlg::SelectionIntoArgument() { const int id = getConstructorId(); - if ( ( id == 1 || id == 2 ) && myEditCurrentArgument != 0 ) + if ((id == 1 || id == 2) && myEditCurrentArgument != 0) { myEditCurrentArgument->setText(""); myX->setText( "" ); @@ -331,56 +366,81 @@ void BasicGUI_PointDlg::SelectionIntoArgument() myRefPoint = myEdge = GEOM::GEOM_Object::_nil(); } - if ( IObjectCount() == 1 ) + if (IObjectCount() == 1) { Standard_Boolean aRes = Standard_False; Handle(SALOME_InteractiveObject) anIO = firstIObject(); - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { - if ( id == 0 ) - { - // get CORBA reference to data object - TopoDS_Shape aShape = myGeomGUI->GetShapeReader().GetShape - ( myGeomGUI->GetGeomGen(), aSelectedObject ); - if ( aShape.IsNull() ) - return; + QString aName = GEOMBase::GetName(aSelectedObject); - if ( aShape.ShapeType() != TopAbs_VERTEX ) + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (id == 2 || id == 3) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // Local Selection { - TColStd_IndexedMapOfInteger aMap; - LightApp_Application* anApp = - (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - anApp->selectionMgr()->GetIndexes( anIO, aMap ); - - if ( aMap.Extent() == 1 ) - { - int anIndex = aMap( 1 ); - TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); - - if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX ) - return; - } + int anIndex = aMap(1); + if (aNeedType == TopAbs_EDGE) + aName += QString(":edge_%1").arg(anIndex); else - return; + aName += QString(":vertex_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + if (id == 0) return; + } + } + } + if (id == 0) + { + if (aShape.IsNull()) return; gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); GroupXYZ->SpinBox_DX->SetValue( aPnt.X() ); GroupXYZ->SpinBox_DY->SetValue( aPnt.Y() ); GroupXYZ->SpinBox_DZ->SetValue( aPnt.Z() ); } - else if ( id == 1 ) + else if (id == 1) { myRefPoint = aSelectedObject; - GroupRefPoint->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); + GroupRefPoint->LineEdit1->setText(aName); } - else if ( id == 2 ) + else if (id == 2) { myEdge = aSelectedObject; - GroupOnCurve->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); + GroupOnCurve->LineEdit1->setText(aName); + } + else if (id == 3) + { + if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) { + myLine1 = aSelectedObject; + myEditCurrentArgument->setText(aName); + } + else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) { + myLine2 = aSelectedObject; + myEditCurrentArgument->setText(aName); + } } } } @@ -388,7 +448,6 @@ void BasicGUI_PointDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -396,38 +455,54 @@ void BasicGUI_PointDlg::SelectionIntoArgument() void BasicGUI_PointDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupRefPoint->LineEdit1 || send == GroupOnCurve->LineEdit1 ) - { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } + if ( send == GroupRefPoint->LineEdit1 || send == GroupOnCurve->LineEdit1 || + send == GroupLineIntersection->LineEdit1 || send == GroupLineIntersection->LineEdit2 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } - //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= void BasicGUI_PointDlg::SetEditCurrentArgument() { + globalSelection(); // close local contexts, if any + QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_POINT); // to break previous local selection if ( send == GroupRefPoint->PushButton1 ) { GroupRefPoint->LineEdit1->setFocus(); myEditCurrentArgument = GroupRefPoint->LineEdit1; - - globalSelection( GEOM_POINT ); + + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } else if ( send == GroupOnCurve->PushButton1 ) { GroupOnCurve->LineEdit1->setFocus(); myEditCurrentArgument = GroupOnCurve->LineEdit1; - - globalSelection( GEOM_EDGE ); + + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } -} + else if ( send == GroupLineIntersection->PushButton1 ) + { + GroupLineIntersection->LineEdit1->setFocus(); + myEditCurrentArgument = GroupLineIntersection->LineEdit1; + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + } + else if ( send == GroupLineIntersection->PushButton2 ) + { + GroupLineIntersection->LineEdit2->setFocus(); + myEditCurrentArgument = GroupLineIntersection->LineEdit2; + + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + } +} //================================================================================= // function : enterEvent() @@ -439,7 +514,6 @@ void BasicGUI_PointDlg::enterEvent(QEvent* e) ActivateThisDialog(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -451,7 +525,6 @@ void BasicGUI_PointDlg::ActivateThisDialog( ) ConstructorsClicked( getConstructorId() ); } - //================================================================================= // function : DeactivateActiveDialog() // purpose : public slot to deactivate if active @@ -462,7 +535,6 @@ void BasicGUI_PointDlg::DeactivateActiveDialog() GEOMBase_Skeleton::DeactivateActiveDialog(); } - //================================================================================= // function : ValueChangedInSpinBox() // purpose : @@ -519,6 +591,8 @@ bool BasicGUI_PointDlg::isValid( QString& msg ) return !myRefPoint->_is_nil(); else if ( id == 2 ) return !myEdge->_is_nil(); + else if ( id == 3) + return ( !myLine1->_is_nil() && !myLine2->_is_nil() ); return false; } @@ -539,7 +613,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) double x = GroupXYZ->SpinBox_DX->GetValue(); double y = GroupXYZ->SpinBox_DY->GetValue(); double z = GroupXYZ->SpinBox_DZ->GetValue(); - + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x,y,z ); res = true; break; @@ -549,7 +623,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) double dx = GroupRefPoint->SpinBox_DX->GetValue(); double dy = GroupRefPoint->SpinBox_DY->GetValue(); double dz = GroupRefPoint->SpinBox_DZ->GetValue(); - + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> MakePointWithReference( myRefPoint, dx, dy, dz ); res = true; @@ -560,6 +634,11 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) MakePointOnCurve( myEdge, getParameter() ); res = true; break; + case 3 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> + MakePointOnLinesIntersection( myLine1, myLine2 ); + res = true; + break; } if ( getConstructorId() == 1 || getConstructorId() == 2 ) @@ -579,7 +658,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) myZ->setText( "" ); } } - + if ( !anObj->_is_nil() ) { //printf( "--> a valid point is created\n" ); @@ -597,3 +676,29 @@ void BasicGUI_PointDlg::closeEvent( QCloseEvent* e ) { GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_PointDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + break; + case 1: + objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint; + break; + case 2: + objMap[GroupOnCurve->LineEdit1->text()] = myEdge; + break; + case 3: + objMap[GroupLineIntersection->LineEdit1->text()] = myLine1; + objMap[GroupLineIntersection->LineEdit2->text()] = myLine2; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_PointDlg.h b/src/BasicGUI/BasicGUI_PointDlg.h index 5d9e7cd7f..8a19f1ab9 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.h +++ b/src/BasicGUI/BasicGUI_PointDlg.h @@ -33,6 +33,7 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel1Spin.h" #include "DlgRef_3Spin.h" +#include "DlgRef_2Sel_QTD.h" #include "DlgRef_1Sel3Spin.h" class QLineEdit; @@ -60,7 +61,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : @@ -70,10 +71,13 @@ private : GEOM::GEOM_Object_var myEdge; GEOM::GEOM_Object_var myRefPoint; + GEOM::GEOM_Object_var myLine1; + GEOM::GEOM_Object_var myLine2; DlgRef_3Spin* GroupXYZ; DlgRef_1Sel3Spin* GroupRefPoint; DlgRef_1Sel1Spin* GroupOnCurve; + DlgRef_2Sel_QTD* GroupLineIntersection; QGroupBox* myCoordGrp; QLineEdit* myX; diff --git a/src/BasicGUI/BasicGUI_VectorDlg.cxx b/src/BasicGUI/BasicGUI_VectorDlg.cxx index e879a2502..e920eb6ce 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.cxx +++ b/src/BasicGUI/BasicGUI_VectorDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,6 +33,12 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -154,7 +160,7 @@ void BasicGUI_VectorDlg::Init() connect(GroupDimensions->CheckBox1, SIGNAL(stateChanged(int)), this, SLOT(ReverseVector(int))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr("GEOM_VECTOR") ); @@ -170,42 +176,43 @@ void BasicGUI_VectorDlg::Init() //================================================================================= void BasicGUI_VectorDlg::ConstructorsClicked( int constructorId ) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); myPoint1 = GEOM::GEOM_Object::_nil(); myPoint2 = GEOM::GEOM_Object::_nil(); switch (constructorId) - { + { case 0: - { - GroupDimensions->hide(); - resize(0, 0); - GroupPoints->show(); - - myEditCurrentArgument = GroupPoints->LineEdit1; - GroupPoints->LineEdit1->setText(""); - GroupPoints->LineEdit2->setText(""); - - globalSelection( GEOM_POINT ); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - break; - } + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(""); + GroupPoints->LineEdit2->setText(""); + + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } case 1: - { - GroupPoints->hide(); - resize( 0, 0 ); - GroupDimensions->show(); - - double dx( 0. ), dy( 0. ), dz( 0. ); - GroupDimensions->SpinBox_DX->SetValue( dx ); - GroupDimensions->SpinBox_DY->SetValue( dy ); - GroupDimensions->SpinBox_DZ->SetValue( dz ); + { + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); - GroupDimensions->CheckBox1->setChecked( FALSE ); - break; - } + double dx( 0. ), dy( 0. ), dz( 0. ); + GroupDimensions->SpinBox_DX->SetValue( dx ); + GroupDimensions->SpinBox_DY->SetValue( dy ); + GroupDimensions->SpinBox_DZ->SetValue( dz ); + + GroupDimensions->CheckBox1->setChecked( FALSE ); + break; } + } displayPreview(); } @@ -256,21 +263,55 @@ void BasicGUI_VectorDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - if ( IObjectCount() != 1 ) + if (IObjectCount() != 1) { - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); return; } // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + QString aName = GEOMBase::GetName(aSelectedObject); + + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = aSelectedObject; else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = aSelectedObject; } @@ -278,7 +319,6 @@ void BasicGUI_VectorDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -306,7 +346,6 @@ void BasicGUI_VectorDlg::LineEditReturnPressed() GEOMBase_Skeleton::LineEditReturnPressed(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -314,10 +353,10 @@ void BasicGUI_VectorDlg::LineEditReturnPressed() void BasicGUI_VectorDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -326,7 +365,6 @@ void BasicGUI_VectorDlg::ActivateThisDialog() //================================================================================= void BasicGUI_VectorDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -417,3 +455,22 @@ bool BasicGUI_VectorDlg::execute( ObjectList& objects ) return res; } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_VectorDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint1; + objMap[GroupPoints->LineEdit2->text()] = myPoint2; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/BasicGUI/BasicGUI_VectorDlg.h b/src/BasicGUI/BasicGUI_VectorDlg.h index a9dcb51b8..b0dc0dcd0 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.h +++ b/src/BasicGUI/BasicGUI_VectorDlg.h @@ -54,6 +54,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private : void Init(); diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx index 80db362aa..31c84cb9e 100644 --- a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx @@ -43,6 +43,9 @@ #include #include #include +#include +#include +#include // QT Includes #include @@ -209,7 +212,9 @@ void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) } case 1: { - globalSelection( GEOM_LINE ); + //globalSelection( GEOM_LINE ); + GEOM::GEOM_Object_var anObj; + localSelection( anObj, TopAbs_EDGE ); Group1->hide(); Group3->hide(); @@ -218,7 +223,7 @@ void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) myEditCurrentArgument = Group2->LineEdit1; Group2->LineEdit1->setText(""); - Group2->LineEdit2->setText(""); + Group2->LineEdit2->setText(""); myVectX = GEOM::GEOM_Object::_nil(); myVectZ = GEOM::GEOM_Object::_nil(); @@ -285,12 +290,13 @@ bool BasicGUI_WorkingPlaneDlg::ClickOnApply() void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); + QString aName; const int id = getConstructorId(); - if ( IObjectCount() != 1 ) { - if(id == 0) + if (IObjectCount() != 1) { + if (id == 0) myFace = GEOM::GEOM_Object::_nil(); - else if(id == 1) { + else if (id == 1) { if (myEditCurrentArgument == Group2->LineEdit1) myVectX = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == Group2->LineEdit2) @@ -303,22 +309,51 @@ void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() Standard_Boolean aRes = Standard_False; GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); - if(!aRes || CORBA::is_nil( aSelectedObject )) + if (!aRes || CORBA::is_nil(aSelectedObject)) return; - if(myEditCurrentArgument == Group1->LineEdit1) + aName = GEOMBase::GetName(aSelectedObject); + + if (myEditCurrentArgument == Group1->LineEdit1) myFace = aSelectedObject; - else if(myEditCurrentArgument == Group2->LineEdit1) - myVectX = aSelectedObject; - else if(myEditCurrentArgument == Group2->LineEdit2) - myVectZ = aSelectedObject; + else if (myEditCurrentArgument == Group2->LineEdit1 || myEditCurrentArgument == Group2->LineEdit2) + { + if ( aRes && !aSelectedObject->_is_nil() ) + { + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) + { + int anIndex = aMap( 1 ); + aName = aName + ":edge_" + QString::number( anIndex ); + + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + if(myEditCurrentArgument == Group2->LineEdit1) + myVectX = aShapesOp->GetSubShape(aSelectedObject, anIndex); + else + myVectZ = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else { + if (myEditCurrentArgument == Group2->LineEdit1) + myVectX = aSelectedObject; + else + myVectZ = aSelectedObject; + } + aSelMgr->clearSelected(); + } + } + } + + myEditCurrentArgument->setText( aName ); - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); - updateWPlane(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -327,24 +362,25 @@ void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == Group1->PushButton1) { + if (send == Group1->PushButton1) { myEditCurrentArgument = Group1->LineEdit1; globalSelection( GEOM_PLANE ); } - else if(send == Group2->PushButton1) { + else if (send == Group2->PushButton1) { myEditCurrentArgument = Group2->LineEdit1; - globalSelection( GEOM_LINE ); + GEOM::GEOM_Object_var anObj; + localSelection( anObj, TopAbs_EDGE ); } - else if(send == Group2->PushButton2) { + else if (send == Group2->PushButton2) { myEditCurrentArgument = Group2->LineEdit2; - globalSelection( GEOM_LINE ); + GEOM::GEOM_Object_var anObj; + localSelection( anObj, TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); SelectionIntoArgument(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -358,7 +394,6 @@ void BasicGUI_WorkingPlaneDlg::LineEditReturnPressed() } } - //================================================================================= // function : onReverse() // purpose : @@ -368,7 +403,6 @@ void BasicGUI_WorkingPlaneDlg::onReverse() updateWPlane(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -382,21 +416,19 @@ void BasicGUI_WorkingPlaneDlg::ActivateThisDialog( ) ConstructorsClicked( getConstructorId() ); } - //================================================================================= // function : DeactivateActiveDialog() // purpose : public slot to deactivate if active //================================================================================= void BasicGUI_WorkingPlaneDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } -//======================================================================= +//================================================================================= // function : ClickOnCancel() // purpose : -//======================================================================= +//================================================================================= void BasicGUI_WorkingPlaneDlg::ClickOnCancel() { GEOMBase_Skeleton::ClickOnCancel(); @@ -421,7 +453,6 @@ void BasicGUI_WorkingPlaneDlg::closeEvent( QCloseEvent* e ) GEOMBase_Skeleton::closeEvent( e ); } - //================================================================================= // function : updateWPlane // purpose : @@ -459,8 +490,8 @@ bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview ) showError( "Wrong shape selected (has to be a planar face)" ); return false; } - - } else if (id == 1) { // by two vectors (Ox & Oz) + } + else if (id == 1) { // by two vectors (Ox & Oz) if ( CORBA::is_nil( myVectX ) || CORBA::is_nil( myVectZ ) ) { if(!showPreview) showError( "Two vectors have to be selected" ); @@ -516,8 +547,8 @@ bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview ) } myWPlane = gp_Ax3(BRep_Tool::Pnt(VX1), aDirZ, aDirX); - - } else if (id == 2) { // by selection from standard (OXY or OYZ, or OZX) + } + else if (id == 2) { // by selection from standard (OXY or OYZ, or OZX) gp_Ax2 anAx2; if (aOriginType == 1) anAx2 = gp::XOY(); @@ -525,25 +556,27 @@ bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview ) else if (aOriginType == 0) anAx2 = gp::ZOX(); myWPlane = gp_Ax3(anAx2); - - } else { + } + else { return false; } - + if (myReverseCB->isChecked()) - { - myWPlane.YReverse(); - myWPlane.ZReverse(); - } - + { + myWPlane.YReverse(); + myWPlane.ZReverse(); + } + if (showPreview) - { - GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() ); - GEOM::GEOM_Object_var anObj = aBasicOp->MakeMarker( myWPlane.Location().X(), myWPlane.Location().Y(), myWPlane.Location().Z(), - myWPlane.XDirection().X(), myWPlane.XDirection().Y(), myWPlane.XDirection().Z(), - myWPlane.YDirection().X(), myWPlane.YDirection().Y(), myWPlane.YDirection().Z() ); - displayPreview(anObj); - } + { + GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations(getStudyId()); + GEOM::GEOM_Object_var anObj = aBasicOp->MakeMarker + (myWPlane.Location().X() , myWPlane.Location().Y() , myWPlane.Location().Z(), + myWPlane.XDirection().X(), myWPlane.XDirection().Y(), myWPlane.XDirection().Z(), + myWPlane.YDirection().X(), myWPlane.YDirection().Y(), myWPlane.YDirection().Z()); + displayPreview(anObj); + } return true; } + diff --git a/src/DlgRef/DlgRef_3Sel1Check_QTD.cxx b/src/DlgRef/DlgRef_3Sel1Check_QTD.cxx index a1442eab4..e30a066a7 100644 --- a/src/DlgRef/DlgRef_3Sel1Check_QTD.cxx +++ b/src/DlgRef/DlgRef_3Sel1Check_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** -** Form implementation generated from reading ui file 'UIFiles/DlgRef_3Sel1Check_QTD.ui' +** Form implementation generated from reading ui file 'DlgRef_3Sel1Check_QTD.ui' ** -** Created: Wed Feb 21 10:49:18 2007 +** Created: Mon Oct 29 18:14:59 2007 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -46,7 +46,7 @@ DlgRef_3Sel1Check_QTD::DlgRef_3Sel1Check_QTD( QWidget* parent, const char* name, LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); - GroupBox1Layout->addWidget( LineEdit1, 0, 2 ); + GroupBox1Layout->addMultiCellWidget( LineEdit1, 0, 0, 2, 3 ); TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); @@ -60,7 +60,7 @@ DlgRef_3Sel1Check_QTD::DlgRef_3Sel1Check_QTD( QWidget* parent, const char* name, LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); - GroupBox1Layout->addWidget( LineEdit2, 1, 2 ); + GroupBox1Layout->addMultiCellWidget( LineEdit2, 1, 1, 2, 3 ); TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); @@ -74,22 +74,22 @@ DlgRef_3Sel1Check_QTD::DlgRef_3Sel1Check_QTD( QWidget* parent, const char* name, LineEdit3 = new QLineEdit( GroupBox1, "LineEdit3" ); - GroupBox1Layout->addWidget( LineEdit3, 2, 2 ); + GroupBox1Layout->addMultiCellWidget( LineEdit3, 2, 2, 2, 3 ); TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); GroupBox1Layout->addWidget( TextLabel3, 2, 0 ); + Spacer3 = new QSpacerItem( 16, 721, QSizePolicy::Minimum, QSizePolicy::Expanding ); + GroupBox1Layout->addItem( Spacer3, 4, 3 ); - radioButton4 = new QRadioButton( GroupBox1, "radioButton4" ); + CheckButton1 = new QCheckBox( GroupBox1, "CheckButton1" ); - GroupBox1Layout->addMultiCellWidget( radioButton4, 3, 3, 0, 1 ); - Spacer3 = new QSpacerItem( 16, 721, QSizePolicy::Minimum, QSizePolicy::Expanding ); - GroupBox1Layout->addItem( Spacer3, 4, 2 ); + GroupBox1Layout->addMultiCellWidget( CheckButton1, 3, 3, 0, 2 ); DlgRef_3Sel1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); languageChange(); - resize( QSize(490, 878).expandedTo(minimumSizeHint()) ); + resize( QSize(403, 441).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); // tab order @@ -122,6 +122,6 @@ void DlgRef_3Sel1Check_QTD::languageChange() TextLabel2->setText( tr( "TL2" ) ); PushButton3->setText( QString::null ); TextLabel3->setText( tr( "TL3" ) ); - radioButton4->setText( tr( "radioButton4" ) ); + CheckButton1->setText( tr( "CheckButton1" ) ); } diff --git a/src/DlgRef/DlgRef_3Sel1Check_QTD.h b/src/DlgRef/DlgRef_3Sel1Check_QTD.h index 7fdf6227e..52a73f98e 100644 --- a/src/DlgRef/DlgRef_3Sel1Check_QTD.h +++ b/src/DlgRef/DlgRef_3Sel1Check_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** -** Form interface generated from reading ui file 'UIFiles/DlgRef_3Sel1Check_QTD.ui' +** Form interface generated from reading ui file 'DlgRef_3Sel1Check_QTD.ui' ** -** Created: Wed Feb 21 10:48:39 2007 +** Created: Mon Oct 29 18:14:59 2007 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! @@ -23,7 +23,7 @@ class QGroupBox; class QPushButton; class QLineEdit; class QLabel; -class QRadioButton; +class QCheckBox; class GEOM_DLGREF_EXPORT DlgRef_3Sel1Check_QTD : public QWidget { @@ -43,7 +43,7 @@ public: QPushButton* PushButton3; QLineEdit* LineEdit3; QLabel* TextLabel3; - QRadioButton* radioButton4; + QCheckBox* CheckButton1; protected: QGridLayout* DlgRef_3Sel1Check_QTDLayout; diff --git a/src/DlgRef/UIFiles/DlgRef_3Sel1Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_3Sel1Check_QTD.ui index 6f9ef127c..b14325d36 100644 --- a/src/DlgRef/UIFiles/DlgRef_3Sel1Check_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_3Sel1Check_QTD.ui @@ -8,8 +8,8 @@ 0 0 - 490 - 878 + 403 + 441 @@ -74,7 +74,7 @@ - + LineEdit1 @@ -111,7 +111,7 @@ - + LineEdit2 @@ -148,7 +148,7 @@ - + LineEdit3 @@ -169,15 +169,7 @@ TL3 - - - radioButton4 - - - radioButton4 - - - + Spacer3 @@ -194,6 +186,14 @@ + + + CheckButton1 + + + CheckButton1 + + diff --git a/src/DlgRef/UIFiles/ui_to_cxx b/src/DlgRef/UIFiles/ui_to_cxx index 54fd541d3..d7a050dfd 100755 --- a/src/DlgRef/UIFiles/ui_to_cxx +++ b/src/DlgRef/UIFiles/ui_to_cxx @@ -102,6 +102,14 @@ #uic -o DlgRef_3Check_QTD.h DlgRef_3Check_QTD.ui #uic -o DlgRef_3Check_QTD.cxx -impl DlgRef_3Check_QTD.h DlgRef_3Check_QTD.ui -uic -o DlgRef_4Sel1Spin2Check_QTD.h DlgRef_4Sel1Spin2Check_QTD.ui -uic -o DlgRef_4Sel1Spin2Check_QTD.cxx -impl DlgRef_4Sel1Spin2Check_QTD.h DlgRef_4Sel1Spin2Check_QTD.ui +#uic -o DlgRef_4Sel1Spin2Check_QTD.h DlgRef_4Sel1Spin2Check_QTD.ui +#uic -o DlgRef_4Sel1Spin2Check_QTD.cxx -impl DlgRef_4Sel1Spin2Check_QTD.h DlgRef_4Sel1Spin2Check_QTD.ui +#uic -o DlgRef_4Sel1Spin2Check_QTD.h DlgRef_4Sel1Spin2Check_QTD.ui +#uic -o DlgRef_4Sel1Spin2Check_QTD.cxx -impl DlgRef_4Sel1Spin2Check_QTD.h DlgRef_4Sel1Spin2Check_QTD.ui + +#uic -o DlgRef_2Sel3Spin2Rb_QTD.h DlgRef_2Sel3Spin2Rb_QTD.ui +#uic -o DlgRef_2Sel3Spin2Rb_QTD.cxx -impl DlgRef_2Sel3Spin2Rb_QTD.h DlgRef_2Sel3Spin2Rb_QTD.ui + +uic -o DlgRef_3Sel1Check_QTD.h DlgRef_3Sel1Check_QTD.ui +uic -o DlgRef_3Sel1Check_QTD.cxx -impl DlgRef_3Sel1Check_QTD.h DlgRef_3Sel1Check_QTD.ui>>>>>>> 1.6.2.3 diff --git a/src/GEOM/GEOM_Gen_i.cc b/src/GEOM/GEOM_Gen_i.cc index 5bdc06417..5e85a6195 100644 --- a/src/GEOM/GEOM_Gen_i.cc +++ b/src/GEOM/GEOM_Gen_i.cc @@ -5016,6 +5016,77 @@ GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFillet( GEOM::GEOM_Shape_ptr shape, return result ; } +//================================================================================ +// function : MakeFilletR1R2() +// purpose : Create a cylinder topology +//================================================================================ +GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFilletR1R2( GEOM::GEOM_Shape_ptr shape, + CORBA::Double radius1, + CORBA::Double radius2, + CORBA::Short ShapeType, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID ) + throw (SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + GEOM::GEOM_Shape_var result; + TopoDS_Shape tds ; + + const TopoDS_Shape aShape = GetTopoShape(shape) ; + if( aShape.IsNull() ) { + THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM); + } + + BRepFilletAPI_MakeFillet fill(aShape); + + try { + /* case all */ + if(ListOfID.length() == 0) { + TopExp_Explorer Exp ( aShape, TopAbs_EDGE ); + for (Exp; Exp.More(); Exp.Next()) { + TopoDS_Edge E =TopoDS::Edge(Exp.Current()); + fill.Add(E); + } + for (int i = 1;i<=fill.NbContours();i++) { +#if OCC_VERSION_MAJOR >= 5 + fill.SetRadius(radius1,radius2,i,i); +#else + fill.SetRadius(radius1,radius2,i); +#endif + } + tds = fill.Shape(); + + } else { + + /* case selection */ + for ( unsigned int ind = 0; ind < ListOfID.length(); ind++ ) { + TopoDS_Shape ss ; + if( GetShapeFromIndex( aShape, (TopAbs_ShapeEnum)ShapeType, ListOfID[ind], ss ) ) { + TopoDS_Edge E = TopoDS::Edge(ss) ; + fill.Add( E ); + } + } + for (int i = 1;i<=fill.NbContours();i++) { +#if OCC_VERSION_MAJOR >= 5 + fill.SetRadius(radius1,radius2,i,i); +#else + fill.SetRadius(radius1,radius2,i); +#endif + } + tds = fill.Shape(); + } + } + catch(Standard_Failure) { + THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeFilletR1R2", SALOME::BAD_PARAM); + } + + if (tds.IsNull()) { + THROW_SALOME_CORBA_EXCEPTION("Make Fillet aborted", SALOME::BAD_PARAM); + } + result = CreateObject(tds); + InsertInLabelOneArgument(aShape, shape, tds, result, myCurrentOCAFDoc) ; + + return result ; +} //================================================================================ // function : MakeChamfer @@ -5080,6 +5151,68 @@ GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeChamfer( GEOM::GEOM_Shape_ptr shape, return result ; } +//================================================================================ +// function : MakeChamferAD +// purpose : Create a Chamfer topology by Lenght & Angle +//================================================================================ +GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeChamferAD( GEOM::GEOM_Shape_ptr shape, + CORBA::Double d, + CORBA::Double angle, + CORBA::Short ShapeType, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID ) + throw (SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + GEOM::GEOM_Shape_var result; + TopoDS_Shape tds ; + + const TopoDS_Shape aShape = GetTopoShape(shape) ; + if( aShape.IsNull() ) { + THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM); + } + + BRepFilletAPI_MakeChamfer MC(aShape); + + try { + /* case all */ + TopTools_IndexedDataMapOfShapeListOfShape M; + TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,M); + if(ListOfID.length() == 0) { + for (int i = 1;i<=M.Extent();i++) { + TopoDS_Edge E = TopoDS::Edge(M.FindKey(i)); + TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First()); + if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E)) + MC.AddDA(d,angle,E,F); + } + tds = MC.Shape(); + + } else { + + /* case selection */ + for ( unsigned int ind = 0; ind < ListOfID.length(); ind++ ) { + TopoDS_Shape ss ; + if( GetShapeFromIndex( aShape, (TopAbs_ShapeEnum)ShapeType, ListOfID[ind], ss ) ) { + TopoDS_Edge E = TopoDS::Edge( ss ) ; + TopoDS_Face F = TopoDS::Face(M.FindFromKey(E).First()); + if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E)) + MC.AddDA(d,angle,E,F); + } + } + tds = MC.Shape(); + } + } + catch(Standard_Failure) { + THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeChamferAD", SALOME::BAD_PARAM); + } + + if (tds.IsNull()) { + THROW_SALOME_CORBA_EXCEPTION("Make ChamferAD aborted", SALOME::BAD_PARAM); + } + result = CreateObject(tds); + InsertInLabelOneArgument(aShape, shape, tds, result, myCurrentOCAFDoc) ; + return result ; +} + //================================================================================= // function : CheckShape() // purpose : diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index efa81ac91..114ff2f53 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -774,6 +774,7 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction ) showError(); } else { + addSubshapesToStudy(); // add Subshapes if local selection const int nbObjs = objects.size(); int aNumber = 1; for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) { @@ -1029,8 +1030,75 @@ bool GEOMBase_Helper::selectObjects( ObjectList& objects ) return true; } +//================================================================ +// Function : findObjectInFather +// Purpose : It should return an object if its founded in study or +// return Null object if the object is not founded +//================================================================ +GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather( GEOM::GEOM_Object_ptr theFather, const char* theName) +{ + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + _PTR(Study) aDStudy = appStudy->studyDS(); + string IOR = GEOMBase::GetIORFromObject( theFather ); + _PTR(SObject) SObj ( aDStudy->FindObjectIOR( IOR ) ); + + bool inStudy = false; + GEOM::GEOM_Object_var aReturnObject; + for (_PTR(ChildIterator) iit (aDStudy->NewChildIterator( SObj )); iit->More() && !inStudy; iit->Next()) { + _PTR(SObject) child (iit->Value()); + QString aChildName = child->GetName(); + if (aChildName == theName) { + inStudy = true; + CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(iit->Value()); + aReturnObject = GEOM::GEOM_Object::_narrow( corbaObj ); + } + } + if (inStudy) + return aReturnObject._retn(); + return GEOM::GEOM_Object::_nil(); +} +//================================================================ +// Function : addSubshapesToStudy +// Purpose : Virtual method to add subshapes if needs +//================================================================ +void GEOMBase_Helper::addSubshapesToStudy() +{ + //Impemented in Dialogs, called from Accept method +} + +//================================================================ +// Function : addSubshapesToFather +// Purpose : Method to add Father Subshapes to Study if it`s not exist +//================================================================ +void GEOMBase_Helper::addSubshapesToFather( QMap& theMap ) +{ + //GetStudyDS + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + _PTR(Study) aDStudy = appStudy->studyDS(); + + GEOM::GEOM_IGroupOperations_var anOp = getGeomEngine()->GetIGroupOperations( getStudyId() ); + + for( QMap::Iterator it = theMap.begin(); it != theMap.end(); it++ ) + { + if ( !anOp->_is_nil() ) { + GEOM::GEOM_Object_var aFatherObj = anOp->GetMainShape( it.data() ); + GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aFatherObj, it.key() ); + + //Add Object to study if its not exist + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) + GeometryGUI::GetGeomGen()->AddInStudy(GeometryGUI::ClientStudyToStudy(aDStudy), + it.data(), it.key(), aFatherObj ); + } + else { + //cout << " anOperations is NULL! " << endl; + } + } +} + - - \ No newline at end of file diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index e8c689864..911d6e443 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -38,6 +38,7 @@ #include CORBA_CLIENT_HEADER(GEOM_Gen) #include +#include #include @@ -175,6 +176,12 @@ protected: // as a top-level object. virtual const char* getNewObjectName() const; + virtual void addSubshapesToStudy(); + + GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, const char* theName ); + //This Metod to find SubObject in theFather Object by Name (theName) + + void addSubshapesToFather( QMap& theMap ); void SetIsPreview(const bool thePreview) {isPreview = thePreview;} bool IsPreview() {return isPreview;} diff --git a/src/GEOMBase/GEOMBase_aWarningDlg.cxx b/src/GEOMBase/GEOMBase_aWarningDlg.cxx new file mode 100644 index 000000000..52a453035 --- /dev/null +++ b/src/GEOMBase/GEOMBase_aWarningDlg.cxx @@ -0,0 +1,126 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 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 : GEOMBase_aWarningDlg.cxx +// Author : Dmitry Matveitchev +// Module : GEOM +// $Header: /home/server/cvs/GEOM/GEOM_SRC/src/GEOMBase/GEOMBase_aWarningDlg.cxx + +#include "GEOMBase_aWarningDlg.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef WNT +using namespace std; +#endif + +GEOMBase_aWarningDlg::GEOMBase_aWarningDlg( QWidget* parent, const char* name, const QString theText, int theNum ) + :QDialog( parent, name ) +{ + if(!name) + setName( "Warning" ); + if ( theNum < 15 ) + resize(296, (120 + (14*theNum)) ); + else + resize(296, 300); + setCaption(name); /* appears on the title bar */ + setSizeGripEnabled(TRUE); + + QGridLayout* topLayout = new QGridLayout(this); + topLayout->setSpacing(6); + topLayout->setMargin(11); + + QGroupBox* mainGrp = new QGroupBox(this, "mainGrp"); + mainGrp->setColumnLayout(0, Qt::Vertical); + mainGrp->layout()->setSpacing(0); + mainGrp->layout()->setMargin(0); + + QGridLayout* mainGrpLayout = new QGridLayout(mainGrp->layout()); + mainGrpLayout->setAlignment(Qt::AlignTop); + mainGrpLayout ->setSpacing(6); + mainGrpLayout->setMargin(11); + topLayout->addWidget(mainGrp, 0, 0); + + QLabel* TextLabel = new QLabel(mainGrp, "TextLabel"); + TextLabel->setText( QObject::tr( "GEOM_REALLY_DELETE" ).arg( theNum ) ); + mainGrpLayout->addWidget(TextLabel, 0, 0); + + QScrollView* viewer = new QScrollView (mainGrp, "viewer"); + viewer->setResizePolicy( QScrollView::AutoOneFit ); + QLabel* TextLabel1 = new QLabel(viewer, "TextLabel1"); + TextLabel1->setText( theText ); + TextLabel1->setAlignment(Qt::AlignTop); + viewer->addChild(TextLabel1); + mainGrpLayout->addWidget(viewer, 1, 0); + + //Create Buttons + + QGroupBox* btnGrp = new QGroupBox(this, "btnGrp"); + btnGrp->setColumnLayout(0, Qt::Vertical); + btnGrp->layout()->setSpacing(0); + btnGrp->layout()->setMargin(0); + QGridLayout* btnGrpLayout = new QGridLayout(btnGrp->layout()); + btnGrpLayout->setAlignment(Qt::AlignTop); + btnGrpLayout->setSpacing(6); + btnGrpLayout->setMargin(11); + topLayout->addWidget(btnGrp, 1, 0); + + /* No button */ + myButtonOk = new QPushButton(btnGrp, "buttonOk"); + myButtonOk->setText(tr("GEOM_BUT_YES")); + myButtonOk->setAutoDefault(TRUE); + btnGrpLayout->addWidget(myButtonOk, 0, 0); + + btnGrpLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1); + + /* Yes button */ + myButtonCancel = new QPushButton(btnGrp, "buttonCancel"); + myButtonCancel->setText(tr("GEOM_BUT_NO")); + myButtonCancel->setAutoDefault(TRUE); + myButtonCancel->setDefault(TRUE); + btnGrpLayout->addWidget(myButtonCancel, 0, 2); + + /* signals and slots connections */ + connect(myButtonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(myButtonCancel, SIGNAL(clicked()), this, SLOT(reject())); +} + + +//====================================================================================== +// function : ~GEOMBase_aWarningDlg() destructor +// purpose : Destroys the object and frees any allocated resources +//====================================================================================== +GEOMBase_aWarningDlg::~GEOMBase_aWarningDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + + diff --git a/src/GEOMBase/GEOMBase_aWarningDlg.h b/src/GEOMBase/GEOMBase_aWarningDlg.h new file mode 100644 index 000000000..6601062bb --- /dev/null +++ b/src/GEOMBase/GEOMBase_aWarningDlg.h @@ -0,0 +1,56 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 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 : GEOMBase_aWarningDlg.h +// Author : Dmitry Matveitchev +// Module : GEOM +// $Header: /home/server/cvs/GEOM/GEOM_SRC/src/GEOMBase/GEOMBase_aWarningDlg.h + +#ifndef GEOMBase_aWarningDLG_H +#define GEOMBase_aWarningDLG_H + +#include +#include + +class QString; +class QPushButton; + +//================================================================================= +// class : GEOMBase_aWarningDlg +// purpose : +//================================================================================= +class GEOMBase_aWarningDlg : public QDialog +{ + Q_OBJECT + +public: + GEOMBase_aWarningDlg( QWidget* parent, const char* name, QString theText, int nb ); + ~GEOMBase_aWarningDlg(); + +private: + QPushButton* myButtonOk; + QPushButton* myButtonCancel; + +}; + +#endif diff --git a/src/GEOMBase/Makefile.am b/src/GEOMBase/Makefile.am index 85293c18f..078b1c4a2 100644 --- a/src/GEOMBase/Makefile.am +++ b/src/GEOMBase/Makefile.am @@ -38,6 +38,7 @@ salomeinclude_HEADERS = \ GEOMBase_Skeleton.h \ GEOMBase_Helper.h \ GEOM_Operation.h \ + GEOMBase_aWarningDlg.h \ GEOM_GEOMBase.hxx dist_libGEOMBase_la_SOURCES = \ @@ -45,10 +46,12 @@ dist_libGEOMBase_la_SOURCES = \ GEOMBase_Skeleton.cxx \ GEOMBase_aParameterDlg.cxx \ GEOMBase_Helper.cxx \ + GEOMBase_aWarningDlg.cxx \ GEOM_Operation.cxx MOC_FILES = \ GEOMBase_Skeleton_moc.cxx \ + GEOMBase_aWarningDlg_moc.cxx \ GEOMBase_aParameterDlg_moc.cxx nodist_libGEOMBase_la_SOURCES= \ diff --git a/src/GEOMContext/GEOM_icons.po b/src/GEOMContext/GEOM_icons.po index 2af178b9c..770de62ce 100644 --- a/src/GEOMContext/GEOM_icons.po +++ b/src/GEOMContext/GEOM_icons.po @@ -117,6 +117,10 @@ msgstr "conedxyz.png" msgid "ICON_DLG_LINE_2P" msgstr "line2points.png" +#LineDlg +msgid "ICON_DLG_LINE_2F" +msgstr "line2faces.png" + #LineDlg msgid "ICON_DLG_LINE_EDGE" msgstr "lineedge.png" @@ -166,6 +170,10 @@ msgstr "point2.png" msgid "ICON_DLG_POINT_EDGE" msgstr "pointonedge.png" +#PoinDlg +msgid "ICON_DLG_POINT_LINES" +msgstr "point_line_intersection.png" + #ArcDlg msgid "ICON_DLG_ARC" msgstr "arc.png" diff --git a/src/GEOMContext/GEOM_msg_en.po b/src/GEOMContext/GEOM_msg_en.po index 9d956d722..d30baa067 100644 --- a/src/GEOMContext/GEOM_msg_en.po +++ b/src/GEOMContext/GEOM_msg_en.po @@ -310,6 +310,10 @@ msgstr "Points" msgid "GEOM_POINT_I" msgstr "Point %1" +#Face i +msgid "GEOM_FACE_I" +msgstr "Face %1" + #Arguments msgid "GEOM_ARGUMENTS" msgstr "Arguments" @@ -362,6 +366,10 @@ msgstr "Coord. :" msgid "GEOM_REVERSE" msgstr "Reverse" +#Bothway +msgid "GEOM_BOTHWAY" +msgstr "Both Directions" + #Reverse U msgid "GEOM_REVERSE_U" msgstr "Reverse U" @@ -633,6 +641,14 @@ msgstr "Faces" msgid "GEOM_LINE" msgstr "Line" +#Line 1 +msgid "GEOM_LINE1" +msgstr "Line 1" + +#Line 2 +msgid "GEOM_LINE2" +msgstr "Line 2" + #Plane msgid "GEOM_PLANE" msgstr "Plane" diff --git a/src/GEOMGUI/GEOMGUI_OCCSelector.cxx b/src/GEOMGUI/GEOMGUI_OCCSelector.cxx index 0452e97ba..0cd04c86f 100644 --- a/src/GEOMGUI/GEOMGUI_OCCSelector.cxx +++ b/src/GEOMGUI/GEOMGUI_OCCSelector.cxx @@ -190,7 +190,11 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) Handle(AIS_InteractiveContext) ic = vw->getAISContext(); // "entry - list_of_int" map for LOCAL selection +#ifndef WNT NCollection_DataMap indexesMap; +#else + NCollection_DataMap indexesMap; +#endif QMap globalSelMap; // only Key=entry from this map is used. value(int) is NOT used at all. SelectMgr_IndexedMapOfOwner ownersmap; // map of owners to be selected diff --git a/src/GEOMGUI/GEOM_images.po b/src/GEOMGUI/GEOM_images.po index 387b20ec3..01755c674 100644 --- a/src/GEOMGUI/GEOM_images.po +++ b/src/GEOMGUI/GEOM_images.po @@ -121,6 +121,10 @@ msgstr "conedxyz.png" msgid "ICON_DLG_LINE_2P" msgstr "line2points.png" +#LineDlg +msgid "ICON_DLG_LINE_2F" +msgstr "line2faces.png" + #LineDlg msgid "ICON_DLG_LINE_EDGE" msgstr "lineedge.png" @@ -181,6 +185,10 @@ msgstr "point3.png" msgid "ICON_DLG_POINT_EDGE" msgstr "pointonedge.png" +#PoinDlg +msgid "ICON_DLG_POINT_LINES" +msgstr "point_line_intersection.png" + #ArcDlg msgid "ICON_DLG_ARC" msgstr "arc.png" diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index fa302d3a0..7a4a29d8d 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -239,7 +239,7 @@ msgstr "Warning" #: GeometryGUI.cxx:3854 msgid "GEOM_REALLY_DELETE" -msgstr "Do you really want to delete object(s) ?" +msgstr "Do you really want to delete this %1 object(s):" # #============================================================================== @@ -305,6 +305,10 @@ msgstr "Points" msgid "GEOM_POINT_I" msgstr "Point %1" +#Face i +msgid "GEOM_FACE_I" +msgstr "Face %1" + #Arguments msgid "GEOM_ARGUMENTS" msgstr "Arguments" @@ -357,6 +361,10 @@ msgstr "Coord. :" msgid "GEOM_REVERSE" msgstr "Reverse" +#Bothway +msgid "GEOM_BOTHWAY" +msgstr "Both Directions" + #Reverse U msgid "GEOM_REVERSE_U" msgstr "Reverse U" @@ -682,6 +690,14 @@ msgstr "Face or LCS" msgid "GEOM_LINE" msgstr "Line" +#Line 1 +msgid "GEOM_LINE1" +msgstr "Line 1" + +#Line 2 +msgid "GEOM_LINE2" +msgstr "Line 2" + #Plane msgid "GEOM_PLANE" msgstr "Plane" @@ -1352,6 +1368,9 @@ msgstr "Parametric point" msgid "GEOM_REF_POINT" msgstr "Point with reference" +msgid "GEOM_LINE_INTERSECTION" +msgstr "Point On Lines Intersection" + # #============================================================================== # @@ -2908,22 +2927,22 @@ msgid "STB_SHADING" msgstr "Shading" msgid "TOP_DISPLAY_ALL" -msgstr "Display all" +msgstr "Show all" msgid "MEN_DISPLAY_ALL" -msgstr "Display all" +msgstr "Show all" msgid "STB_DISPLAY_ALL" -msgstr "Display all" +msgstr "Show all" msgid "TOP_ERASE_ALL" -msgstr "Erase all" +msgstr "Hide all" msgid "MEN_ERASE_ALL" -msgstr "Erase all" +msgstr "Hide all" msgid "STB_ERASE_ALL" -msgstr "Erase all" +msgstr "Hide all" msgid "TOP_DISPLAY" msgstr "Show" @@ -2935,13 +2954,13 @@ msgid "STB_DISPLAY" msgstr "Show object(s)" msgid "TOP_DISPLAY_ONLY" -msgstr "Display only" +msgstr "Show only" msgid "MEN_DISPLAY_ONLY" -msgstr "Display only" +msgstr "Show only" msgid "STB_DISPLAY_ONLY" -msgstr "Display only" +msgstr "Show only" msgid "TOP_ERASE" msgstr "Hide" diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index a2ff2d479..11d602f2c 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -215,8 +215,8 @@ GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName ) if ( (libs = getenv( "LD_LIBRARY_PATH" )) ) { QStringList dirList = QStringList::split( ":", libs, false ); // skip empty entries #else - if( ( libs = getenv( "PATH" ) ) ) { - QStringList dirList = QStringList::split( ";", libs, false ); // skip empty entries + if ( (libs = getenv( "PATH" )) ) { + QStringList dirList = QStringList::split( ";", libs, false ); // skip empty entries #endif for( int i = dirList.count()-1; i >= 0; i-- ) { QString dir = dirList[ i ]; diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 2571cae0b..6eefda984 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -692,6 +692,66 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Objec return aPrism; } +//============================================================================= +/*! + * MakePrismVecH2Ways + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) theVec, + double theH) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Prism object + Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM); + + //Add a new Prism function for creation a Prism relatively to vector + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL; + + GEOMImpl_IPrism aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetVector(aRefVec); + aCI.SetH(theH); + + //Compute the Prism value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + //SetErrorCode("Prism driver failed"); + SetErrorCode("Extrusion can not be created, check input data"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways(" + << theBase << ", " << theVec << ", " << theH << ")"; + + SetErrorCode(OK); + return aPrism; +} + //============================================================================= /*! * MakePrismTwoPnt @@ -753,6 +813,67 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt return aPrism; } +//============================================================================= +/*! + * MakePrismTwoPnt2Ways + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways + (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL; + + //Add a new Prism object + Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM); + + //Add a new Prism function for creation a Prism relatively to two points + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL; + + GEOMImpl_IPrism aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction(); + + if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetFirstPoint(aRefPnt1); + aCI.SetLastPoint(aRefPnt2); + + //Compute the Prism value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + //SetErrorCode("Prism driver failed"); + SetErrorCode("Extrusion can not be created, check input data"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways(" + << theBase << ", " << thePoint1 << ", " << thePoint2 << ")"; + + SetErrorCode(OK); + return aPrism; +} + //============================================================================= /*! @@ -871,6 +992,63 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle( return aRevolution; } +//============================================================================= +/*! + * MakeRevolutionAxisAngle2Ways + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways + (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || theAxis.IsNull()) return NULL; + + //Add a new Revolution object + Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION); + + //Add a new Revolution function for creation a revolution relatively to axis + Handle(GEOM_Function) aFunction = + aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL; + + GEOMImpl_IRevolution aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction(); + + if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetAxis(aRefAxis); + aCI.SetAngle(theAngle); + + //Compute the Revolution value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Revolution driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways(" + << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; + + SetErrorCode(OK); + return aRevolution; +} //============================================================================= /*! diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index d3d7ba49c..f87ddd5d5 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -59,10 +59,17 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakePrismVecH (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theVec, double theH); + Standard_EXPORT Handle(GEOM_Object) MakePrismVecH2Ways (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) theVec, double theH); + Standard_EXPORT Handle(GEOM_Object) MakePrismTwoPnt (Handle(GEOM_Object) theBase, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2); + Standard_EXPORT Handle(GEOM_Object) MakePrismTwoPnt2Ways (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2); + Standard_EXPORT Handle(GEOM_Object) MakePipe (Handle(GEOM_Object) theBase, Handle(GEOM_Object) thePath); @@ -70,6 +77,10 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Handle(GEOM_Object) theAxis, double theAngle); + Standard_EXPORT Handle(GEOM_Object) MakeRevolutionAxisAngle2Ways (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) theAxis, + double theAngle); + Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell); Standard_EXPORT Handle(GEOM_Object) MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, int theNbIter); diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index 6ed1de04e..08d1fde18 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -231,6 +231,60 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve return aPoint; } +//============================================================================= +/*! + * MakePointOnLinesIntersection + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection + (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2) +{ + SetErrorCode(KO); + + if (theLine1.IsNull() || theLine2.IsNull()) return NULL; + + //Add a new Point object + Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT); + + //Add a new Point function for creation a point relativley another point + Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL; + + GEOMImpl_IPoint aPI (aFunction); + + Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + aPI.SetLine1(aRef1); + aPI.SetLine2(aRef2); + + //Compute the point value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Point driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection(" + << theLine1 << ", " << theLine2 << ")"; + + SetErrorCode(OK); + return aPoint; +} + //============================================================================= /*! * MakeTangentOnCurve @@ -501,6 +555,60 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt return aLine; } +//============================================================================= +/*! + * MakeLineTwoFaces + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces + (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2) +{ + SetErrorCode(KO); + + if (theFace1.IsNull() || theFace2.IsNull()) return NULL; + + //Add a new Line object + Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE); + + //Add a new Line function + Handle(GEOM_Function) aFunction = + aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL; + + GEOMImpl_ILine aPI (aFunction); + + Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + aPI.SetFace1(aRef1); + aPI.SetFace2(aRef2); + + //Compute the Line value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Line driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces(" + << theFace1 << ", " << theFace2 << ")"; + + SetErrorCode(OK); + return aLine; +} //============================================================================= /*! diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx index 1b44aa4e8..e6155178b 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx @@ -41,6 +41,9 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakePointOnCurve (Handle(GEOM_Object) theCurve, double theParameter); + Standard_EXPORT Handle(GEOM_Object) MakePointOnLinesIntersection + (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2); + // Vector Standard_EXPORT Handle(GEOM_Object) MakeVectorDXDYDZ (double theDX, double theDY, double theDZ); @@ -54,6 +57,9 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeLineTwoPnt (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2); + Standard_EXPORT Handle(GEOM_Object) MakeLineTwoFaces (Handle(GEOM_Object) theFace1, + Handle(GEOM_Object) theFace2); + Standard_EXPORT Handle(GEOM_Object) MakeLine (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir); diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index 1cf41ed4e..d6628ca43 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -256,7 +256,6 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEO return aCircle; } - //============================================================================= /*! * MakeCirclePntVecR diff --git a/src/GEOMImpl/GEOMImpl_ILine.hxx b/src/GEOMImpl/GEOMImpl_ILine.hxx index 09d5fba74..99a60b778 100644 --- a/src/GEOMImpl/GEOMImpl_ILine.hxx +++ b/src/GEOMImpl/GEOMImpl_ILine.hxx @@ -22,8 +22,10 @@ #include "GEOM_Function.hxx" -#define LINE_ARG_PNT1 1 -#define LINE_ARG_PNT2 2 +#define LINE_ARG_PNT1 1 +#define LINE_ARG_PNT2 2 +#define LINE_ARG_FACE1 3 +#define LINE_ARG_FACE2 4 class GEOMImpl_ILine { @@ -33,9 +35,13 @@ class GEOMImpl_ILine void SetPoint1(Handle(GEOM_Function) theRef) { _func->SetReference(LINE_ARG_PNT1, theRef); } void SetPoint2(Handle(GEOM_Function) theRef) { _func->SetReference(LINE_ARG_PNT2, theRef); } + void SetFace1(Handle(GEOM_Function) theRef) { _func->SetReference(LINE_ARG_FACE1, theRef); } + void SetFace2(Handle(GEOM_Function) theRef) { _func->SetReference(LINE_ARG_FACE2, theRef); } Handle(GEOM_Function) GetPoint1() { return _func->GetReference(LINE_ARG_PNT1); } Handle(GEOM_Function) GetPoint2() { return _func->GetReference(LINE_ARG_PNT2); } + Handle(GEOM_Function) GetFace1() { return _func->GetReference(LINE_ARG_FACE1); } + Handle(GEOM_Function) GetFace2() { return _func->GetReference(LINE_ARG_FACE2); } private: diff --git a/src/GEOMImpl/GEOMImpl_IPoint.hxx b/src/GEOMImpl/GEOMImpl_IPoint.hxx index 91dd98383..b796a51f5 100755 --- a/src/GEOMImpl/GEOMImpl_IPoint.hxx +++ b/src/GEOMImpl/GEOMImpl_IPoint.hxx @@ -30,6 +30,8 @@ #define ARG_PARAM 5 #define ARG_CURVE 6 +#define ARG_LINE1 7 +#define ARG_LINE2 8 class GEOMImpl_IPoint { @@ -50,8 +52,12 @@ class GEOMImpl_IPoint Handle(GEOM_Function) GetRef() { return _func->GetReference(ARG_REF); } void SetCurve(Handle(GEOM_Function) theRef) { _func->SetReference(ARG_CURVE, theRef); } + void SetLine1(Handle(GEOM_Function) theRef) { _func->SetReference(ARG_LINE1, theRef); } + void SetLine2(Handle(GEOM_Function) theRef) { _func->SetReference(ARG_LINE2, theRef); } Handle(GEOM_Function) GetCurve() { return _func->GetReference(ARG_CURVE); } + Handle(GEOM_Function) GetLine1() { return _func->GetReference(ARG_LINE1); } + Handle(GEOM_Function) GetLine2() { return _func->GetReference(ARG_LINE2); } void SetParameter(double theParam) { _func->SetReal(ARG_PARAM, theParam); } diff --git a/src/GEOMImpl/GEOMImpl_LineDriver.cxx b/src/GEOMImpl/GEOMImpl_LineDriver.cxx index a7bf8d433..4f7b9263c 100644 --- a/src/GEOMImpl/GEOMImpl_LineDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_LineDriver.cxx @@ -27,13 +27,15 @@ #include #include - +#include #include #include #include #include #include #include +#include +#include #include #include @@ -92,6 +94,40 @@ Standard_Integer GEOMImpl_LineDriver::Execute(TFunction_Logbook& log) const } aShape = BRepBuilderAPI_MakeEdge(P1, P2).Shape(); + } else if (aType == LINE_TWO_FACES) { + Handle(GEOM_Function) aRefFace1 = aPI.GetFace1(); + Handle(GEOM_Function) aRefFace2 = aPI.GetFace2(); + TopoDS_Shape aShape1 = aRefFace1->GetValue(); + TopoDS_Shape aShape2 = aRefFace2->GetValue(); + if (aShape1.ShapeType() != TopAbs_FACE || + aShape2.ShapeType() != TopAbs_FACE) { + Standard_ConstructionError::Raise("Wrong arguments: two faces must be given"); + } + if (aShape1.IsSame(aShape2)) { + Standard_ConstructionError::Raise("The end faces must be different"); + } + BRepAlgoAPI_Section E (aShape1, aShape2, Standard_False); + E.Approximation(Standard_True); + E.Build(); + if (!E.IsDone()) { + Standard_ConstructionError::Raise("Line can not be performed on the given faces"); + } + else + { + TopExp_Explorer Exp (E, TopAbs_EDGE); + if ( Exp.More() ){ + aShape = Exp.Current(); + Exp.Next(); + } + else + { + Standard_ConstructionError::Raise("Faces not have intersection line"); + aShape = E.Shape(); + } + if ( Exp.More() ) + aShape = E.Shape(); + } + } else if (aType == LINE_PNT_DIR) { Handle(GEOM_Function) aRefPnt = aPI.GetPoint1(); Handle(GEOM_Function) aRefDir = aPI.GetPoint2(); diff --git a/src/GEOMImpl/GEOMImpl_PointDriver.cxx b/src/GEOMImpl/GEOMImpl_PointDriver.cxx index 3b8f5270d..a511c53ea 100644 --- a/src/GEOMImpl/GEOMImpl_PointDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PointDriver.cxx @@ -27,7 +27,8 @@ #include #include - +#include +#include #include #include #include @@ -97,7 +98,34 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const aP = aFP + (aLP - aFP) * aPI.GetParameter(); aPnt = aCurve->Value(aP); - } else { + } else if (aType == POINT_LINES_INTERSECTION) { + Handle(GEOM_Function) aRef1 = aPI.GetLine1(); + Handle(GEOM_Function) aRef2 = aPI.GetLine2(); + + TopoDS_Shape aRefShape1 = aRef1->GetValue(); + TopoDS_Shape aRefShape2 = aRef2->GetValue(); + + if (aRefShape1.ShapeType() != TopAbs_EDGE || aRefShape2.ShapeType() != TopAbs_EDGE ) { + Standard_TypeMismatch::Raise + ("Creation Point On Lines Intersection Aborted : Line shape is not an edge"); + } + //Calculate Lines Intersection Point + BRepExtrema_DistShapeShape dst (aRefShape1, aRefShape2); + if (dst.IsDone()) + { + gp_Pnt P1, P2; + for (int i = 1; i <= dst.NbSolution(); i++) { + P1 = dst.PointOnShape1(i); + P2 = dst.PointOnShape2(i); + Standard_Real Dist = P1.Distance(P2); + if ( Dist <= Precision::Confusion() ) + aPnt = P1; + else + Standard_TypeMismatch::Raise ("Lines not have an Intersection Point"); + } + } + } + else { return 0; } diff --git a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx index 8d049aa56..11bb15ad6 100644 --- a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -38,6 +39,8 @@ #include #include +#include +#include #include //======================================================================= @@ -73,7 +76,7 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const TopoDS_Shape aShape; - if (aType == PRISM_BASE_VEC_H) { + if (aType == PRISM_BASE_VEC_H || aType == PRISM_BASE_VEC_H_2WAYS) { Handle(GEOM_Function) aRefBase = aCI.GetBase(); Handle(GEOM_Function) aRefVector = aCI.GetVector(); TopoDS_Shape aShapeBase = aRefBase->GetValue(); @@ -89,11 +92,18 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const } if (aV.Magnitude() > Precision::Confusion()) { aV.Normalize(); + if (aType == PRISM_BASE_VEC_H_2WAYS) { + gp_Trsf aTrsf; + aTrsf.SetTranslation( (-aV) * aCI.GetH() ); + BRepBuilderAPI_Transform aTransformation(aShapeBase, aTrsf, Standard_False); + aShapeBase = aTransformation.Shape(); + aCI.SetH( aCI.GetH()*2 ); + } aShape = BRepPrimAPI_MakePrism(aShapeBase, aV * aCI.GetH(), Standard_False).Shape(); } } } - } else if (aType == PRISM_BASE_TWO_PNT) { + } else if (aType == PRISM_BASE_TWO_PNT || aType == PRISM_BASE_TWO_PNT_2WAYS) { Handle(GEOM_Function) aRefBase = aCI.GetBase(); Handle(GEOM_Function) aRefPnt1 = aCI.GetFirstPoint(); Handle(GEOM_Function) aRefPnt2 = aCI.GetLastPoint(); @@ -107,6 +117,14 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const if (!V1.IsNull() && !V2.IsNull()) { gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); if (aV.Magnitude() > gp::Resolution()) { + if (aType == PRISM_BASE_TWO_PNT_2WAYS) + { + gp_Trsf aTrsf; + aTrsf.SetTranslation(-aV); + BRepBuilderAPI_Transform aTransformation(aShapeBase, aTrsf, Standard_False); + aShapeBase = aTransformation.Shape(); + aV = aV * 2; + } aShape = BRepPrimAPI_MakePrism(aShapeBase, aV, Standard_False).Shape(); } } diff --git a/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx index 2f790ca3e..9d3d91ca3 100644 --- a/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -35,7 +36,7 @@ #include #include #include - +#include #include #include #include @@ -77,7 +78,7 @@ Standard_Integer GEOMImpl_RevolutionDriver::Execute(TFunction_Logbook& log) cons TopoDS_Shape aShape; - if (aType == REVOLUTION_BASE_AXIS_ANGLE) { + if (aType == REVOLUTION_BASE_AXIS_ANGLE || aType == REVOLUTION_BASE_AXIS_ANGLE_2WAYS) { Handle(GEOM_Function) aRefBase = aCI.GetBase(); Handle(GEOM_Function) aRefAxis = aCI.GetAxis(); TopoDS_Shape aShapeBase = aRefBase->GetValue(); @@ -106,9 +107,17 @@ Standard_Integer GEOMImpl_RevolutionDriver::Execute(TFunction_Logbook& log) cons Standard_ConstructionError::Raise("Vertex to be rotated is too close to Revolution Axis"); } } - + double anAngle = aCI.GetAngle(); gp_Ax1 anAxis (BRep_Tool::Pnt(V1), aV); - BRepPrimAPI_MakeRevol MR (aShapeBase, anAxis, aCI.GetAngle(), Standard_False); + if (aType == REVOLUTION_BASE_AXIS_ANGLE_2WAYS) + { + gp_Trsf aTrsf; + aTrsf.SetRotation(anAxis, ( -anAngle )); + BRepBuilderAPI_Transform aTransformation(aShapeBase, aTrsf, Standard_False); + aShapeBase = aTransformation.Shape(); + anAngle = anAngle * 2; + } + BRepPrimAPI_MakeRevol MR (aShapeBase, anAxis, anAngle, Standard_False); if (!MR.IsDone()) MR.Build(); if (!MR.IsDone()) StdFail_NotDone::Raise("Revolution algorithm has failed"); aShape = MR.Shape(); diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index c33d81b14..be924b3f7 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -89,10 +89,11 @@ #define EXPORT_SHAPE 1 #define IMPORT_SHAPE 1 -#define POINT_XYZ 1 -#define POINT_XYZ_REF 2 -#define POINT_CURVE_PAR 3 -//#define POINT_FACE_PAR 4 +#define POINT_XYZ 1 +#define POINT_XYZ_REF 2 +#define POINT_CURVE_PAR 3 +#define POINT_LINES_INTERSECTION 4 +//#define POINT_FACE_PAR 5 #define VECTOR_TWO_PNT 1 #define VECTOR_DX_DY_DZ 2 @@ -104,8 +105,9 @@ #define PLANE_THREE_PNT 3 #define PLANE_TANGENT_FACE 4 -#define LINE_TWO_PNT 1 -#define LINE_PNT_DIR 2 +#define LINE_TWO_PNT 1 +#define LINE_PNT_DIR 2 +#define LINE_TWO_FACES 3 #define TRANSLATE_TWO_POINTS 1 #define TRANSLATE_VECTOR 2 @@ -156,10 +158,13 @@ #define SPHERE_R 1 #define SPHERE_PNT_R 2 -#define PRISM_BASE_VEC_H 1 -#define PRISM_BASE_TWO_PNT 2 +#define PRISM_BASE_VEC_H 1 +#define PRISM_BASE_TWO_PNT 2 +#define PRISM_BASE_VEC_H_2WAYS 3 +#define PRISM_BASE_TWO_PNT_2WAYS 4 -#define REVOLUTION_BASE_AXIS_ANGLE 1 +#define REVOLUTION_BASE_AXIS_ANGLE 1 +#define REVOLUTION_BASE_AXIS_ANGLE_2WAYS 2 #define PIPE_BASE_PATH 1 #define PIPE_DIFFERENT_SECTIONS 2 diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index 8ee1a8648..fe4cca690 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -31,6 +31,8 @@ #include "GeometryGUI.h" #include "GEOM_Actor.h" #include "GEOMBase.h" +#include "GEOMBase_aWarningDlg.h" + #include "GEOM_Operation.h" #include "GEOM_Displayer.h" @@ -323,13 +325,53 @@ void GEOMToolsGUI::OnEditDelete() return; } // VSR 17/11/04: check if all objects selected belong to GEOM component <-- finish - - if ( SUIT_MessageBox::warn2( app->desktop(), - QObject::tr( "GEOM_WRN_WARNING" ), - QObject::tr( "GEOM_REALLY_DELETE" ), - QObject::tr( "GEOM_BUT_YES" ), - QObject::tr( "GEOM_BUT_NO" ), 1, 0, 0 ) != 1 ) - return; + QString aNameList; + int nbSel = 0; + //Get Main Objects Names + Handle(SALOME_InteractiveObject) anIObject; + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) + { + QString aName = It.Value()->getName(); + if ( aName != "" && aName.ref(0) != '*') { + aNameList.append(" - " + aName + "\n"); + nbSel++; + } + anIObject = It.Value(); + } + // Append Child Names of Last Selected Object + _PTR(SObject) obj ( aStudy->FindObjectID( anIObject->getEntry() ) ); + for (_PTR(ChildIterator) iit (aStudy->NewChildIterator(obj)); iit->More(); iit->Next()) { + _PTR(SObject) child (iit->Value()); + QString aName = child->GetName(); + if (aName != "" && aName.ref(0) != '*') { + aNameList.append(" - " + aName + "\n"); + nbSel++; + //append childs child + for (_PTR(ChildIterator) iitt(aStudy->NewChildIterator(child)); iitt->More(); iitt->Next()) { + _PTR(SObject) childchild(iitt->Value()); + QString aName = childchild->GetName(); + if (aName != "" && aName.ref(0) != '*') { + aNameList.append(" - " + aName + "\n"); + nbSel++; + for (_PTR(ChildIterator) itt(aStudy->NewChildIterator(childchild)); itt->More(); itt->Next()) + { + _PTR(SObject) childs(itt->Value()); + QString aName = childs->GetName(); + if (aName != "" && aName.ref(0) != '*') { + aNameList.append(" - " + aName + "\n"); + nbSel++; + } + } + } + } + } + } //end of child append + + GEOMBase_aWarningDlg* Dialog = new GEOMBase_aWarningDlg( app->desktop(), QObject::tr( "GEOM_WRN_WARNING" ), aNameList, nbSel); + int r = Dialog->exec(); + + if (!r) + return; // QAD_Operation* op = new SALOMEGUI_ImportOperation(.....); // op->start(); diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index e730e0e03..276a9d556 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -349,6 +349,39 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismVecH return GetObject(anObject); } +//============================================================================= +/*! + * MakePrismVecH2Ways + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismVecH2Ways + (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theVec, + CORBA::Double theH) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBase == NULL || theVec == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject + (theBase->GetStudyID(), theBase->GetEntry()); + Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject + (theVec->GetStudyID(), theVec->GetEntry()); + + if (aBase.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); + + //Create the Prism + Handle(GEOM_Object) anObject = + GetOperations()->MakePrismVecH2Ways(aBase, aVec, theH); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakePrismTwoPnt @@ -387,6 +420,44 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPnt return GetObject(anObject); } +//============================================================================= +/*! + * MakePrismTwoPnt2Ways + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPnt2Ways + (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBase == NULL || thePoint1 == NULL || thePoint2 == NULL) + return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject + (theBase->GetStudyID(), theBase->GetEntry()); + Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject + (thePoint1->GetStudyID(), thePoint1->GetEntry()); + Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject + (thePoint2->GetStudyID(), thePoint2->GetEntry()); + + if (aBase.IsNull() || aPoint1.IsNull() || aPoint2.IsNull()) + return aGEOMObject._retn(); + + //Create the Prism + Handle(GEOM_Object) anObject = + GetOperations()->MakePrismTwoPnt2Ways(aBase, aPoint1, aPoint2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakePipe @@ -452,6 +523,39 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle return GetObject(anObject); } +//============================================================================= +/*! + * MakeRevolutionAxisAngle2Ways + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle2Ways + (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBase == NULL || theAxis == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject + (theBase->GetStudyID(), theBase->GetEntry()); + Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject + (theAxis->GetStudyID(), theAxis->GetEntry()); + + if (aBase.IsNull() || anAxis.IsNull()) return aGEOMObject._retn(); + + //Create the Revolution + Handle(GEOM_Object) anObject = + GetOperations()->MakeRevolutionAxisAngle2Ways(aBase, anAxis, theAngle); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeFilling diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index 6c3febbc9..f0397e5e9 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -82,10 +82,18 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr theVec, CORBA::Double theH); + GEOM::GEOM_Object_ptr MakePrismVecH2Ways (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theH); + GEOM::GEOM_Object_ptr MakePrismTwoPnt (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePoint1, GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr MakePrismTwoPnt2Ways (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePath); @@ -93,6 +101,10 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr theAxis, CORBA::Double theAngle); + GEOM::GEOM_Object_ptr MakeRevolutionAxisAngle2Ways (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle); + GEOM::GEOM_Object_ptr MakeFilling(GEOM::GEOM_Object_ptr theShape, CORBA::Long theMinDeg, CORBA::Long theMaxDeg, CORBA::Double theTol2D, CORBA::Double theTol3D, CORBA::Long theNbIter); GEOM::GEOM_Object_ptr MakeThruSections(const GEOM::ListOfGO& theSeqSections, diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.cc b/src/GEOM_I/GEOM_IBasicOperations_i.cc index 4257ae0a2..fe525509c 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.cc +++ b/src/GEOM_I/GEOM_IBasicOperations_i.cc @@ -105,6 +105,39 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointWithReference return GetObject(anObject); } +//============================================================================= +/*! + * MakePointOnLinesIntersection + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection + (GEOM::GEOM_Object_ptr theLine1, GEOM::GEOM_Object_ptr theLine2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theLine1 == NULL || theLine2 == NULL) return aGEOMObject._retn(); + + //Get the reference Lines + + Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject + (theLine1->GetStudyID(), theLine1->GetEntry()); + Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject + (theLine2->GetStudyID(), theLine2->GetEntry()); + if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn(); + + //Create the point + + Handle(GEOM_Object) anObject = + GetOperations()->MakePointOnLinesIntersection(aRef1, aRef2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakePointOnCurve @@ -290,6 +323,38 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt return GetObject(anObject); } +//============================================================================= +/*! + * MakeLineTwoFaces + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces + (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theFace1 == NULL || theFace2 == NULL) return aGEOMObject._retn(); + + //Get the reference points + + Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject + (theFace1->GetStudyID(), theFace1->GetEntry()); + Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject + (theFace2->GetStudyID(), theFace2->GetEntry()); + if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn(); + + //Create the Line + + Handle(GEOM_Object) anObject = + GetOperations()->MakeLineTwoFaces(aRef1, aRef2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} //============================================================================= /*! diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.hh b/src/GEOM_I/GEOM_IBasicOperations_i.hh index 9a54e2b96..753e0df16 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.hh +++ b/src/GEOM_I/GEOM_IBasicOperations_i.hh @@ -53,6 +53,9 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i : GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter); + GEOM::GEOM_Object_ptr MakePointOnLinesIntersection (GEOM::GEOM_Object_ptr theLine1, + GEOM::GEOM_Object_ptr theLine2); + GEOM::GEOM_Object_ptr MakeTangentOnCurve (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theParameter); @@ -69,6 +72,9 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i : GEOM::GEOM_Object_ptr MakeLineTwoPnt (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2); + GEOM::GEOM_Object_ptr MakeLineTwoFaces (GEOM::GEOM_Object_ptr theFace1, + GEOM::GEOM_Object_ptr theFace2); + GEOM::GEOM_Object_ptr MakePlaneThreePnt (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, GEOM::GEOM_Object_ptr thePnt3, diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 5694df6da..666ec0861 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -545,6 +545,20 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the return anObj; } +//============================================================================= +// MakePointOnLinesIntersection: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnLinesIntersection (GEOM::GEOM_Object_ptr theRefLine1, + GEOM::GEOM_Object_ptr theRefLine2) +{ + beginService( " GEOM_Superv_i::MakePointOnLinesIntersection" ); + MESSAGE("GEOM_Superv_i::MakePointOnLinesIntersection"); + getBasicOp(); + GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnLinesIntersection(theRefLine1, theRefLine2); + endService( " GEOM_Superv_i::MakePointOnLinesIntersection" ); + return anObj; +} + //============================================================================= // MakeTangentOnCurve: //============================================================================= @@ -602,6 +616,20 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeLineTwoPnt (GEOM::GEOM_Object_ptr thePn return anObj; } +//============================================================================= +// MakeLineTwoFaces: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeLineTwoFaces (GEOM::GEOM_Object_ptr theFace1, + GEOM::GEOM_Object_ptr theFace2) +{ + beginService( " GEOM_Superv_i::MakeLineTwoFaces"); + MESSAGE("GEOM_Superv_i::MakeLineTwoFaces"); + getBasicOp(); + GEOM::GEOM_Object_ptr anObj = myBasicOp->MakeLineTwoFaces(theFace1, theFace2); + endService( " GEOM_Superv_i::MakeLineTwoFaces"); + return anObj; +} + //============================================================================= // MakePlaneThreePnt: //============================================================================= @@ -880,6 +908,20 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismVecH (GEOM::GEOM_Object_ptr theBas return anObj; } +//============================================================================= +// MakePrismVecH2Ways: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismVecH2Ways (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theH) +{ + beginService( " GEOM_Superv_i::MakePrismVecH2Ways" ); + MESSAGE("GEOM_Superv_i::MakePrismVecH2Ways"); + get3DPrimOp(); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakePrismVecH2Ways(theBase, theVec, theH); + endService( " GEOM_Superv_i::MakePrismVecH2Ways" ); + return anObj; +} //============================================================================= // MakePrismTwoPnt: @@ -896,6 +938,21 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismTwoPnt (GEOM::GEOM_Object_ptr theB return anObj; } +//============================================================================= +// MakePrismTwoPnt2Ways: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismTwoPnt2Ways (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + beginService( " GEOM_Superv_i::MakePrismTwoPnt2Ways" ); + MESSAGE("GEOM_Superv_i::MakePrismTwoPnt2Ways"); + get3DPrimOp(); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakePrismTwoPnt2Ways(theBase, thePoint1, thePoint2); + endService( " GEOM_Superv_i::MakePrismTwoPnt2Ways" ); + return anObj; +} + //============================================================================= // MakePipe: //============================================================================= @@ -925,6 +982,21 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeRevolutionAxisAngle (GEOM::GEOM_Object_ return anObj; } +//============================================================================= +// MakeRevolutionAxisAngle: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeRevolutionAxisAngle2Ways (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle) +{ + beginService( " GEOM_Superv_i::MakeRevolutionAxisAngle2Ways" ); + MESSAGE("GEOM_Superv_i::MakeRevolutionAxisAngle2Ways"); + get3DPrimOp(); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeRevolutionAxisAngle2Ways(theBase, theAxis, theAngle); + endService( " GEOM_Superv_i::MakeRevolutionAxisAngle2Ways" ); + return anObj; +} + //============================================================================= // MakeFilling: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index da8451222..0d3039704 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -142,6 +142,8 @@ public: CORBA::Double theZ); GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theParameter); + GEOM::GEOM_Object_ptr MakePointOnLinesIntersection (GEOM::GEOM_Object_ptr theRefLine1, + GEOM::GEOM_Object_ptr theRefLine2); GEOM::GEOM_Object_ptr MakeTangentOnCurve (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theParameter); GEOM::GEOM_Object_ptr MakeVectorDXDYDZ (CORBA::Double theDX, @@ -151,6 +153,8 @@ public: GEOM::GEOM_Object_ptr thePnt2); GEOM::GEOM_Object_ptr MakeLineTwoPnt (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2); + GEOM::GEOM_Object_ptr MakeLineTwoFaces (GEOM::GEOM_Object_ptr theFace1, + GEOM::GEOM_Object_ptr theFace2); GEOM::GEOM_Object_ptr MakePlaneThreePnt (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, GEOM::GEOM_Object_ptr thePnt3, @@ -213,14 +217,23 @@ public: GEOM::GEOM_Object_ptr MakePrismVecH (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theVec, CORBA::Double theH); + GEOM::GEOM_Object_ptr MakePrismVecH2Ways (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theH); GEOM::GEOM_Object_ptr MakePrismTwoPnt (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePoint1, GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr MakePrismTwoPnt2Ways (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePath); GEOM::GEOM_Object_ptr MakeRevolutionAxisAngle (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theAxis, CORBA::Double theAngle); + GEOM::GEOM_Object_ptr MakeRevolutionAxisAngle2Ways (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle); GEOM::GEOM_Object_ptr MakeFilling (GEOM::GEOM_Object_ptr theShape, CORBA::Long theMinDeg, CORBA::Long theMaxDeg, CORBA::Double theTol2D, CORBA::Double theTol3D, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 54b2762d6..67188c761 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -82,6 +82,7 @@ def TestAll (geompy, math): #Create base geometry 2D Line = geompy.MakeLineTwoPnt(p0, pxyz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr Line1 = geompy.MakeLine(pz, vxy) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + Line2 = geompy.MakeLineTwoPnt(pxyz, pz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr Plane = geompy.MakePlane(pz, vxyz, trimsize) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr Plane1 = geompy.MakePlaneThreePnt(px, pz, p200, trimsize) #(4 Doubles)->GEOM_Object_ptr @@ -100,6 +101,9 @@ def TestAll (geompy, math): #Test point on curve creation p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr + #Test point on lines intersection + pLine = geompy.MakeVertexOnLinesIntersection( Line1, Line2 ) + #Create base geometry 3D Box = geompy.MakeBoxTwoPnt(p0, p200) #(2 GEOM_Object_ptr)->GEOM_Object_ptr Box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) #(3 Doubles)->GEOM_Object_ptr @@ -149,6 +153,9 @@ def TestAll (geompy, math): #ShapeList for Sewing S = geompy.MakeRotation(Face, vxy, angle1) + + #Test Line on Faces Intersection + Line3 = geompy.MakeLineTwoFaces( prism1_faces[0], prism1_faces[1]) #(2 GEOM_Object_ptr)->GEOM_Object_ptr #Create advanced objects Copy = geompy.MakeCopy(Box) #(GEOM_Object_ptr)->GEOM_Object_ptr @@ -206,9 +213,8 @@ def TestAll (geompy, math): IDlist_f) #(GEOM_Object_ptr, 2 Doubles, ListOfLong)->GEOM_Object_ptr Chamfer3 = geompy.MakeChamferEdges(Prism, d1, d2, IDlist_e) #(GEOM_Object_ptr, 2 Doubles, ListOfLong)->GEOM_Object_ptr - Chamfer4 = geompy.MakeChamferFacesAD(Prism, d1, 0.2, + Chamfer4 = geompy.MakeChamferFacesAD(Prism, d1, 20. * math.pi / 180., IDlist_f) #(GEOM_Object_ptr, 2 Doubles, ListOfLong)->GEOM_Object_ptr - #Create Patterns MultiTrans1D = geompy.MakeMultiTranslation1D(Fillet, vz, step1, nbtimes1) MultiTrans2D = geompy.MakeMultiTranslation2D(Fillet, vz, step1, nbtimes1, vy, step2, nbtimes2) @@ -235,6 +241,7 @@ def TestAll (geompy, math): id_pz = geompy.addToStudy(pz, "Vertex Z") id_pxyz = geompy.addToStudy(pxyz, "Vertex XYZ") id_p200 = geompy.addToStudy(p200, "Vertex 200") + id_pLine = geompy.addToStudy(pLine, "Vertex on Lines Intersection") id_vx = geompy.addToStudy(vx, "Vector X") id_vy = geompy.addToStudy(vy, "Vector Y") @@ -247,6 +254,7 @@ def TestAll (geompy, math): id_Line = geompy.addToStudy(Line, "Line") id_Line1 = geompy.addToStudy(Line1, "Line by point and vector") + id_Line3 = geompy.addToStudy(Line3, "Line on Two Faces Intersection") id_Plane = geompy.addToStudy(Plane, "Plane") id_Plane1 = geompy.addToStudy(Plane1, "Plane by 3 points") @@ -315,6 +323,7 @@ def TestAll (geompy, math): id_Fillet = geompy.addToStudy(Fillet, "Fillet") id_Fillet2 = geompy.addToStudy(Fillet2, "Fillet2") + id_Chamfer = geompy.addToStudy(Chamfer, "Chamfer on Edge") id_Chamfer2 = geompy.addToStudy(Chamfer2, "Chamfer on Faces") id_Chamfer3 = geompy.addToStudy(Chamfer3, "Chamfer on Edges") diff --git a/src/GEOM_SWIG/batchmode_geompy.py b/src/GEOM_SWIG/batchmode_geompy.py index 145f962fb..6485368cf 100644 --- a/src/GEOM_SWIG/batchmode_geompy.py +++ b/src/GEOM_SWIG/batchmode_geompy.py @@ -155,6 +155,12 @@ def MakeVertexOnCurve(curve,par): print "MakePointOnCurve : ", BasicOp.GetErrorCode() return anObj +def MakeVertexOnLinesIntersection(line1,line2): + anObj = BasicOp.MakePointOnLinesIntersection(line1,line2) + if BasicOp.IsDone() == 0: + print "MakePointOnLinesIntersection : ", BasicOp.GetErrorCode() + return anObj + def MakeVectorDXDYDZ(dx,dy,dz): anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz) if BasicOp.IsDone() == 0: @@ -179,6 +185,12 @@ def MakeLineTwoPnt(p1, p2): print "MakeLineTwoPnt : ", BasicOp.GetErrorCode() return anObj +def MakeLineTwoFaces(f1, f2): + anObj = BasicOp.MakeLineTwoFaces(f1,f2) + if BasicOp.IsDone() == 0: + print "MakeLineTwoFaces : ", BasicOp.GetErrorCode() + return anObj + def MakePlane(p1,v1,trimsize): anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize) if BasicOp.IsDone() == 0: @@ -382,12 +394,24 @@ def MakePrism(baseShape,point1,point2): print "MakePrismTwoPnt : ", PrimOp.GetErrorCode() return anObj +def MakePrism2Ways(baseShape,point1,point2): + anObj = PrimOp.MakePrismTwoPnt2Ways(baseShape,point1,point2) + if PrimOp.IsDone() == 0: + print "MakePrismTwoPnt2Ways : ", PrimOp.GetErrorCode() + return anObj + def MakePrismVecH(baseShape,vector,height): anObj = PrimOp.MakePrismVecH(baseShape,vector,height) if PrimOp.IsDone() == 0: print "MakePrismVecH : ", PrimOp.GetErrorCode() return anObj +def MakePrismVecH2Ways(baseShape,vector,height): + anObj = PrimOp.MakePrismVecH2Ways(baseShape,vector,height) + if PrimOp.IsDone() == 0: + print "MakePrismVecH2Ways : ", PrimOp.GetErrorCode() + return anObj + def MakePipe(baseShape,pathShape): anObj = PrimOp.MakePipe(baseShape,pathShape) if PrimOp.IsDone() == 0: @@ -400,6 +424,12 @@ def MakeRevolution(aShape,axis,angle): print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode() return anObj +def MakeRevolution2Ways(aShape,axis,angle): + anObj = PrimOp.MakeRevolutionAxisAngle2Ways(aShape,axis,angle) + if PrimOp.IsDone() == 0: + print "MakeRevolutionAxisAngle2Ways : ", PrimOp.GetErrorCode() + return anObj + # ----------------------------------------------------------------------------- # Create base shapes # ----------------------------------------------------------------------------- diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index 1e237b527..7a997f564 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -39,3 +39,4 @@ for k in dir(geom): globals()[k]=getattr(geom,k) del k from geompyDC import ShapeType,GEOM,kind, info + diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx index 7fad7b6c6..2d124940d 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx @@ -36,6 +36,11 @@ #include #include +#include +#include +#include +#include +#include #include #include #if OCC_VERSION_MAJOR >= 5 @@ -128,7 +133,7 @@ void GenerationGUI_PipeDlg::Init() initName(tr("GEOM_PIPE")); - globalSelection( GEOM_ALLSHAPES ); + // globalSelection( GEOM_ALLSHAPES ); } @@ -194,19 +199,54 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument() return; myBase = aSelectedObject; + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); myOkBase = true; } else if(myEditCurrentArgument == GroupPoints->LineEdit2) { myOkPath = false; - if(!GEOMBase::GetShape(aSelectedObject, S) || - !(S.ShapeType() == TopAbs_WIRE || S.ShapeType() == TopAbs_EDGE) ) + if( !GEOMBase::GetShape(aSelectedObject, S) ) return; + + QString aName = GEOMBase::GetName( aSelectedObject ); - myPath = aSelectedObject; - myOkPath = true; + if ( testResult && !aSelectedObject->_is_nil() && aSelectedObject != myBase) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + + aSelMgr->GetIndexes( firstIObject(), 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + myPath = aShapesOp->GetSubShape(aSelectedObject, anIndex); + myOkPath = true; + } + else { // get Object from study + myPath = aFindedObject; + myOkPath = true; + } + } + else { + myOkPath = true; + if (S.ShapeType() != TopAbs_EDGE) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + myOkPath = false; + } + myPath = aSelectedObject; + } + } + myEditCurrentArgument->setText( aName ); } - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); displayPreview(); } @@ -219,14 +259,18 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument() void GenerationGUI_PipeDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); + globalSelection( GEOM_ALLSHAPES ); myEditCurrentArgument = GroupPoints->LineEdit1; } else if(send == GroupPoints->PushButton2) { GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; + globalSelection(); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); } SelectionIntoArgument(); } @@ -308,5 +352,16 @@ bool GenerationGUI_PipeDlg::execute( ObjectList& objects ) return true; } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void GenerationGUI_PipeDlg::addSubshapesToStudy() +{ + QMap objMap; + + objMap[GroupPoints->LineEdit2->text()] = myPath; + addSubshapesToFather( objMap ); +} diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.h b/src/GenerationGUI/GenerationGUI_PipeDlg.h index 09f5a7215..b926d6de7 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.h +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.h @@ -51,6 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& msg ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init(); diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx index 205fea0e2..92fd0fb38 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include @@ -66,9 +73,9 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg(GeometryGUI* theGeometryGUI, QWid RadioButton3->close(TRUE); RadioButton1->setChecked(true); + myBothway = myBothway2 = false; GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints"); - GroupPoints->CheckButton1->hide(); GroupPoints->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV")); GroupPoints->TextLabel1->setText(tr("GEOM_BASE")); GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); @@ -77,9 +84,11 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg(GeometryGUI* theGeometryGUI, QWid GroupPoints->PushButton2->setPixmap(image1); 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_3Sel_QTD(this, "GroupPoints2"); + GroupPoints2 = new DlgRef_3Sel1Check_QTD(this, "GroupPoints2"); GroupPoints2->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV_2P")); GroupPoints2->TextLabel1->setText(tr("GEOM_BASE")); GroupPoints2->TextLabel2->setText(tr("GEOM_POINT_I").arg("1")); @@ -87,6 +96,8 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg(GeometryGUI* theGeometryGUI, QWid GroupPoints2->PushButton1->setPixmap(image1); GroupPoints2->PushButton2->setPixmap(image1); GroupPoints2->PushButton3->setPixmap(image1); + GroupPoints2->CheckButton1->setText(tr("GEOM_BOTHWAY")); + GroupPoints2->CheckButton1->setChecked(myBothway2); Layout1->addWidget(GroupPoints, 2, 0); Layout1->addWidget(GroupPoints2, 2, 0); @@ -150,12 +161,13 @@ void GenerationGUI_PrismDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway())); connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); - 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(onBothway2())); connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); @@ -271,22 +283,54 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() // nbSel == 1 Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_ptr aSelectedObject = + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); if (!testResult) return; + bool myOk = true; + TopoDS_Shape aShape; + QString aName = GEOMBase::GetName( aSelectedObject ); + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) + { + 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else { + if (aShape.ShapeType() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + myOk = false; + } + } + } + if (myEditCurrentArgument == GroupPoints->LineEdit1) { myBase = aSelectedObject; myOkBase = true; } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + else if (myEditCurrentArgument == GroupPoints->LineEdit2 && myOk) { + myOkVec = true; myVec = aSelectedObject; - myOkVec = true; } - - myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); + myEditCurrentArgument->setText( aName ); } else // getConstructorId()==1 - extrusion using 2 points { @@ -312,26 +356,60 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() if (!testResult || 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() ) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; + } + else + { + 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->LineEdit1) { myBase = aSelectedObject; myOkBase = true; } - else if (myEditCurrentArgument == GroupPoints2->LineEdit2) { - myPoint1 = aSelectedObject; + else if (myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk) { myOkPnt1 = true; + myPoint1 = aSelectedObject; } - else if (myEditCurrentArgument == GroupPoints2->LineEdit3) { - myPoint2 = aSelectedObject; + else if (myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk) { myOkPnt2 = true; + myPoint2 = aSelectedObject; } - - myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); } displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -358,31 +436,30 @@ void GenerationGUI_PrismDlg::LineEditReturnPressed() void GenerationGUI_PrismDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_ALLSHAPES ); if (send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if (send == GroupPoints->PushButton2) { GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - globalSelection( GEOM_LINE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if (send == GroupPoints2->PushButton1) { GroupPoints2->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints2->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if (send == GroupPoints2->PushButton2) { GroupPoints2->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints2->LineEdit2; - globalSelection( GEOM_POINT ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } else if (send == GroupPoints2->PushButton3) { GroupPoints2->LineEdit3->setFocus(); myEditCurrentArgument = GroupPoints2->LineEdit3; - globalSelection( GEOM_POINT ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } myEditCurrentArgument->setFocus(); @@ -432,7 +509,7 @@ void GenerationGUI_PrismDlg::ValueChangedInSpinBox() //================================================================================= double GenerationGUI_PrismDlg::getHeight() const { - return GroupPoints->SpinBox_DX->GetValue(); + return GroupPoints->SpinBox_DX->GetValue(); } //================================================================================= @@ -451,11 +528,9 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation() bool GenerationGUI_PrismDlg::isValid( QString& ) { if (getConstructorId() == 0) - // by vector and height - return (myOkBase && myOkVec); - - // by two points - return (myOkBase && myOkPnt1 && myOkPnt2); + return (myOkBase && myOkVec); // by vector and height + else + return (myOkBase && myOkPnt1 && myOkPnt2); // by two points } //================================================================================= @@ -470,14 +545,22 @@ bool GenerationGUI_PrismDlg::execute( ObjectList& objects ) { case 0: { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> - MakePrismVecH(myBase, myVec, getHeight()); + if (!myBothway) + anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> + MakePrismVecH(myBase, myVec, getHeight()); + else + anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> + MakePrismVecH2Ways(myBase, myVec, getHeight() ); break; } case 1: { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> + if (!myBothway2) + anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> MakePrismTwoPnt(myBase, myPoint1, myPoint2); + else + anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> + MakePrismTwoPnt2Ways(myBase, myPoint1, myPoint2); break; } } @@ -497,3 +580,43 @@ void GenerationGUI_PrismDlg::onReverse() double anOldValue = GroupPoints->SpinBox_DX->GetValue(); GroupPoints->SpinBox_DX->SetValue( -anOldValue ); } + +//================================================================================= +// function : onBothway() +// purpose : +//================================================================================= +void GenerationGUI_PrismDlg::onBothway() +{ + bool anOldValue = myBothway; + myBothway = !anOldValue; + GroupPoints->CheckButton2->setEnabled(!myBothway); + displayPreview(); +} + +void GenerationGUI_PrismDlg::onBothway2() +{ + bool anOldValue = myBothway2; + myBothway2 = !anOldValue; + displayPreview(); +} + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void GenerationGUI_PrismDlg::addSubshapesToStudy() +{ + QMap objMap; + + switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myVec; + break; + case 1: + objMap[GroupPoints2->LineEdit2->text()] = myPoint1; + objMap[GroupPoints2->LineEdit3->text()] = myPoint2; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.h b/src/GenerationGUI/GenerationGUI_PrismDlg.h index e9b265634..5f90c0fe1 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.h +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.h @@ -32,7 +32,7 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_2Sel1Spin2Check.h" -#include "DlgRef_3Sel_QTD.h" +#include "DlgRef_3Sel1Check_QTD.h" //================================================================================= // class : GenerationGUI_PrismDlg @@ -52,6 +52,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& msg ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init(); @@ -66,9 +67,11 @@ private: bool myOkVec; bool myOkPnt1; bool myOkPnt2; + bool myBothway; + bool myBothway2; DlgRef_2Sel1Spin2Check* GroupPoints; - DlgRef_3Sel_QTD* GroupPoints2; // for second layout for extrusion using 2 points + DlgRef_3Sel1Check_QTD* GroupPoints2; // for second layout for extrusion using 2 points private slots: void ClickOnOk(); @@ -81,6 +84,8 @@ private slots: void SetEditCurrentArgument(); void ValueChangedInSpinBox(); void onReverse(); + void onBothway(); + void onBothway2(); }; #endif // DIALOGBOX_PRISM_H diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx index 8dcdad347..928fd15f6 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include #include @@ -66,9 +73,9 @@ GenerationGUI_RevolDlg::GenerationGUI_RevolDlg(GeometryGUI* theGeometryGUI, QWid RadioButton1->setPixmap(image0); RadioButton2->close(TRUE); RadioButton3->close(TRUE); + myBothway = false; GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints"); - GroupPoints->CheckButton1->hide(); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); GroupPoints->TextLabel2->setText(tr("GEOM_AXIS")); @@ -77,6 +84,7 @@ GenerationGUI_RevolDlg::GenerationGUI_RevolDlg(GeometryGUI* theGeometryGUI, QWid GroupPoints->PushButton2->setPixmap(image1); GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly( true ); + GroupPoints->CheckButton1->setText(tr("GEOM_BOTHWAY")); GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE")); Layout1->addWidget(GroupPoints, 2, 0); @@ -128,6 +136,7 @@ void GenerationGUI_RevolDlg::Init() 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())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); @@ -212,6 +221,7 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument() // nbSel == 1 Standard_Boolean testResult = Standard_False; GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); + QString aName = GEOMBase::GetName( aSelectedObject ); if (!testResult) return; @@ -227,10 +237,48 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument() myOkBase = true; } else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - myAxis = aSelectedObject; - myOkAxis = true; + if ( testResult && !aSelectedObject->_is_nil() ) + { + TopoDS_Shape aShape; + + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) + { + + 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + myAxis = aShapesOp->GetSubShape(aSelectedObject, anIndex); + myOkAxis = true; + } + else { + myAxis = aFindedObject; + myOkAxis = true; + } + } + else { + myOkAxis = true; + if (aShape.ShapeType() != TopAbs_EDGE) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + myOkAxis = false; + } + myAxis = aSelectedObject; + } + } + } } - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + myEditCurrentArgument->setText( aName ); displayPreview(); } @@ -252,7 +300,7 @@ void GenerationGUI_RevolDlg::SetEditCurrentArgument() else if(send == GroupPoints->PushButton2) { GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - globalSelection( GEOM_LINE ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); } SelectionIntoArgument(); } @@ -345,8 +393,12 @@ bool GenerationGUI_RevolDlg::execute( ObjectList& objects ) { GEOM::GEOM_Object_var anObj; - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( - getOperation() )->MakeRevolutionAxisAngle( myBase, myAxis, getAngle() * PI180 ); + if (!myBothway) + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( + getOperation() )->MakeRevolutionAxisAngle( myBase, myAxis, getAngle() * PI180 ); + else + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( + getOperation() )->MakeRevolutionAxisAngle2Ways( myBase, myAxis, getAngle() * PI180 ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); @@ -364,3 +416,28 @@ void GenerationGUI_RevolDlg::onReverse() double anOldValue = GroupPoints->SpinBox_DX->GetValue(); GroupPoints->SpinBox_DX->SetValue( -anOldValue ); } + +//================================================================================= +// function : onBothway() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::onBothway() +{ + bool anOldValue = myBothway; + myBothway = !anOldValue; + GroupPoints->CheckButton2->setEnabled(!myBothway); + displayPreview(); +} + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void GenerationGUI_RevolDlg::addSubshapesToStudy() +{ + QMap objMap; + + objMap[GroupPoints->LineEdit2->text()] = myAxis; + + addSubshapesToFather( objMap ); +} diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.h b/src/GenerationGUI/GenerationGUI_RevolDlg.h index 83be6522b..c7004e51d 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.h +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.h @@ -53,6 +53,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& msg ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private : void Init(); @@ -63,6 +64,7 @@ private : GEOM::GEOM_Object_var myAxis; /* Axis of the revolution */ bool myOkBase; bool myOkAxis; + bool myBothway; DlgRef_2Sel1Spin2Check* GroupPoints; @@ -75,6 +77,7 @@ private slots: void SetEditCurrentArgument(); void ValueChangedInSpinBox(); void onReverse(); + void onBothway(); }; #endif // DIALOGBOX_REVOLUTION_H diff --git a/src/GroupGUI/GroupGUI_GroupDlg.cxx b/src/GroupGUI/GroupGUI_GroupDlg.cxx index 47f441e75..5aafaee7c 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.cxx +++ b/src/GroupGUI/GroupGUI_GroupDlg.cxx @@ -93,7 +93,7 @@ GroupGUI_GroupDlg::GroupGUI_GroupDlg(Mode mode, GeometryGUI* theGeometryGUI, QWi myMainName->setReadOnly( true ); myMainName->setEnabled( myMode == CreateGroup ); - mySelSubBtn = new QPushButton( tr( "SELECT_SUB_SHAPES" ), aFrame ); + mySelSubBtn = new QRadioButton (tr( "SELECT_SUB_SHAPES" ), aFrame ); mySelAllBtn = new QPushButton( tr( "SELECT_ALL" ), aFrame ); myAddBtn = new QPushButton( tr( "ADD" ), aFrame ); myRemBtn = new QPushButton( tr( "REMOVE" ), aFrame ); @@ -128,7 +128,7 @@ GroupGUI_GroupDlg::~GroupGUI_GroupDlg() void GroupGUI_GroupDlg::Init() { // san -- TODO: clear selected sub-shapes... - + mySelSubBtn->setChecked( true ); if ( myMode == CreateGroup ) { initName( tr( "GROUP_PREFIX" ) ); @@ -181,6 +181,12 @@ void GroupGUI_GroupDlg::Init() connect( myIdList, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) ); activateSelection(); + // activate subshapes selection if Main Shape is Selected + if ( !CORBA::is_nil( myMainObj ) ) { + myEditCurrentArgument = 0; + activateSelection(); + updateState(); + } } //================================================================================= @@ -266,7 +272,7 @@ void GroupGUI_GroupDlg::SetEditCurrentArgument() if ( send == mySelBtn ) myEditCurrentArgument = myMainName; - else if ( send == mySelSubBtn || send == mySelAllBtn ) + else if ( (QRadioButton*)sender() == mySelSubBtn || send == mySelAllBtn ) myEditCurrentArgument = 0; activateSelection(); @@ -296,7 +302,10 @@ void GroupGUI_GroupDlg::SelectionIntoArgument() if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) { myMainObj = anObj; myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) ); - updateState(); + // activate subshapes selection by default + myEditCurrentArgument = 0; + activateSelection(); + updateState(); return; } } @@ -654,7 +663,6 @@ void GroupGUI_GroupDlg::updateState() break; } } - if ( !isAdd ) { aMapIndex.Clear(); break; diff --git a/src/GroupGUI/GroupGUI_GroupDlg.h b/src/GroupGUI/GroupGUI_GroupDlg.h index 3e9f34618..98c1e604d 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.h +++ b/src/GroupGUI/GroupGUI_GroupDlg.h @@ -35,6 +35,7 @@ class QGroupBox; class QLineEdit; class QListBox; +class QRadioButton; //================================================================================= // class : GroupGUI_GroupDlg @@ -93,7 +94,7 @@ private: QGroupBox* GroupMedium; QPushButton* mySelBtn; QLineEdit* myMainName; - QPushButton* mySelSubBtn; + QRadioButton* mySelSubBtn; QPushButton* mySelAllBtn; QPushButton* myAddBtn; QPushButton* myRemBtn; diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.cxx b/src/OperationGUI/OperationGUI_ChamferDlg.cxx index 32520e8a7..e5914d23d 100644 --- a/src/OperationGUI/OperationGUI_ChamferDlg.cxx +++ b/src/OperationGUI/OperationGUI_ChamferDlg.cxx @@ -370,7 +370,7 @@ void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId ) myGrp3->show(); myGrp4->hide(); mySpinBox[ SpinBox31 ]->SetValue( D1 ); - mySpinBox[ SpinBox32 ]->SetValue( D2 ); + mySpinBox[ SpinBox32 ]->SetValue( D2 ); mySpinBox[ SpinBox33 ]->SetValue( D ); mySpinBox[ SpinBox34 ]->SetValue( Angle ); break; @@ -378,7 +378,7 @@ void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId ) myGrp1->hide(); myGrp2->hide(); myGrp3->hide(); - myGrp4->show(); + myGrp4->show(); mySpinBox[ SpinBox41 ]->SetValue( D1 ); mySpinBox[ SpinBox42 ]->SetValue( D2 ); mySpinBox[ SpinBox43 ]->SetValue( D ); @@ -725,7 +725,7 @@ void OperationGUI_ChamferDlg::activateSelection() myEditCurrentArgument == mySelName[ Faces ] ) ) localSelection( myShape, TopAbs_FACE ); else if (!myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ] ) - localSelection( myShape, TopAbs_EDGE ); + localSelection( myShape, TopAbs_EDGE ); else { TColStd_MapOfInteger aMap; @@ -846,7 +846,7 @@ bool OperationGUI_ChamferDlg::execute( ObjectList& objects ) GEOM::ListOfLong_var anArray = new GEOM::ListOfLong; anArray->length( myFaces.Extent() ); for ( int i = 1, n = myFaces.Extent(); i <= n; i++ ) - anArray[ i - 1 ] = myFaces( i ); + anArray[ i - 1 ] = myFaces( i ); if ( flag ) anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->MakeChamferFaces( myShape, @@ -861,7 +861,8 @@ bool OperationGUI_ChamferDlg::execute( ObjectList& objects ) anArray ); } else if ( anId == 3 ) - { GEOM::ListOfLong_var anArray = new GEOM::ListOfLong; + { + GEOM::ListOfLong_var anArray = new GEOM::ListOfLong; anArray->length( myEdges.Extent() ); for ( int i = 1, n = myEdges.Extent(); i <= n; i++ ) anArray[ i - 1 ] = myEdges( i ); @@ -880,5 +881,3 @@ bool OperationGUI_ChamferDlg::execute( ObjectList& objects ) return true; } - - diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.h b/src/OperationGUI/OperationGUI_ChamferDlg.h index 76f06f594..41669752a 100644 --- a/src/OperationGUI/OperationGUI_ChamferDlg.h +++ b/src/OperationGUI/OperationGUI_ChamferDlg.h @@ -1,101 +1,101 @@ -// GEOM GEOMGUI : GUI for Geometry component -// -// Copyright (C) 2003 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 : OperationGUI_ChamferDlg.h -// Author : Damien COQUERET -// Module : GEOM - -#ifndef DIALOGBOX_CHAMFER_H -#define DIALOGBOX_CHAMFER_H - -#include "GEOMBase_Skeleton.h" -#include - -class DlgRef_SpinBox; - -//================================================================================= -// class : OperationGUI_ChamferDlg -// purpose : -//================================================================================= -class OperationGUI_ChamferDlg : public GEOMBase_Skeleton -{ - Q_OBJECT - - enum { MainObj1, MainObj2, Face1, Face2, MainObj3, Faces, MainObj4, Edges}; - enum { SpinBox1, - SpinBox21, SpinBox22, SpinBox23, SpinBox24, - SpinBox31, SpinBox32, SpinBox33, SpinBox34, - SpinBox41, SpinBox42, SpinBox43, SpinBox44 }; - enum { RadioButton21, RadioButton22, - RadioButton31, RadioButton32, - RadioButton41, RadioButton42 }; -public: - OperationGUI_ChamferDlg(GeometryGUI* theGeometryGUI, QWidget* parent); - virtual ~OperationGUI_ChamferDlg(); - -protected: - // redefined from GEOMBase_Helper - virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool isValid( QString& msg ); - virtual bool execute( ObjectList& objects ); - -private slots: - void ClickOnOk(); - bool ClickOnApply(); - void ActivateThisDialog(); - void LineEditReturnPressed(); - void RadioButtonPressed(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); - void ValueChangedInSpinBox( double newValue ); - void ConstructorsClicked( int constructorId ); - -private: - void Init(); - void enterEvent( QEvent* e ); - void reset(); - void createSelWg( const QString&, QPixmap&, QWidget*, const int ); - int getConstructorId() const; - void activateSelection(); - void enableWidgets(); - -private: - int myConstructorId; - - GEOM::GEOM_Object_var myShape; - QMap< int, int > myFace; // indexes of faces from second tab ( Face1,2 ) - TColStd_IndexedMapOfInteger myFaces; // indexes of faces from first tab ( Faces ) - TColStd_IndexedMapOfInteger myEdges; // indexes of edges from fourth tab (Edges) - - QFrame* myGrp1; - QFrame* myGrp2; - QFrame* myGrp3; - QFrame* myGrp4; - - QMap< int, QPushButton* > mySelBtn; - QMap< int, QLineEdit* > mySelName; - QMap< int, DlgRef_SpinBox* > mySpinBox; - QMap< int, QRadioButton* > myRadioButton; -}; - -#endif // DIALOGBOX_CHAMFER_H +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 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 : OperationGUI_ChamferDlg.h +// Author : Damien COQUERET +// Module : GEOM + +#ifndef DIALOGBOX_CHAMFER_H +#define DIALOGBOX_CHAMFER_H + +#include "GEOMBase_Skeleton.h" +#include + +class DlgRef_SpinBox; + +//================================================================================= +// class : OperationGUI_ChamferDlg +// purpose : +//================================================================================= +class OperationGUI_ChamferDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + + enum { MainObj1, MainObj2, Face1, Face2, MainObj3, Faces, MainObj4, Edges}; + enum { SpinBox1, + SpinBox21, SpinBox22, SpinBox23, SpinBox24, + SpinBox31, SpinBox32, SpinBox33, SpinBox34, + SpinBox41, SpinBox42, SpinBox43, SpinBox44 }; + enum { RadioButton21, RadioButton22, + RadioButton31, RadioButton32, + RadioButton41, RadioButton42 }; +public: + OperationGUI_ChamferDlg(GeometryGUI* theGeometryGUI, QWidget* parent); + virtual ~OperationGUI_ChamferDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void RadioButtonPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox( double newValue ); + void ConstructorsClicked( int constructorId ); + +private: + void Init(); + void enterEvent( QEvent* e ); + void reset(); + void createSelWg( const QString&, QPixmap&, QWidget*, const int ); + int getConstructorId() const; + void activateSelection(); + void enableWidgets(); + +private: + int myConstructorId; + + GEOM::GEOM_Object_var myShape; + QMap< int, int > myFace; // indexes of faces from second tab ( Face1,2 ) + TColStd_IndexedMapOfInteger myFaces; // indexes of faces from first tab ( Faces ) + TColStd_IndexedMapOfInteger myEdges; // indexes of edges from fourth tab (Edges) + + QFrame* myGrp1; + QFrame* myGrp2; + QFrame* myGrp3; + QFrame* myGrp4; + + QMap< int, QPushButton* > mySelBtn; + QMap< int, QLineEdit* > mySelName; + QMap< int, DlgRef_SpinBox* > mySpinBox; + QMap< int, QRadioButton* > myRadioButton; +}; + +#endif // DIALOGBOX_CHAMFER_H diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx index 5b61ece14..c42d9fccb 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,6 +33,12 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -146,38 +152,39 @@ void PrimitiveGUI_BoxDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DZ, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_BOX" ) ); ConstructorsClicked(0); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= void PrimitiveGUI_BoxDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); - + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + switch (constructorId) { case 0: { - globalSelection( GEOM_POINT ); + // globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); - + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -193,7 +200,6 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked(int constructorId) displayPreview(); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -204,7 +210,6 @@ void PrimitiveGUI_BoxDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : @@ -219,45 +224,75 @@ bool PrimitiveGUI_BoxDlg::ClickOnApply() return true; } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed //================================================================================= void PrimitiveGUI_BoxDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; - + myEditCurrentArgument->setText(""); - + if (IObjectCount() != 1) - { - if (myEditCurrentArgument == GroupPoints->LineEdit1) - myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == GroupPoints->LineEdit2) - myPoint2 = GEOM::GEOM_Object::_nil(); - return; - } + { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint1 = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myPoint2 = GEOM::GEOM_Object::_nil(); + return; + } // nbSel == 1 Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult ); - - if(!testResult || CORBA::is_nil( aSelectedObject )) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); + + if (!testResult || CORBA::is_nil(aSelectedObject)) return; - - if(myEditCurrentArgument == GroupPoints->LineEdit1) + + TopoDS_Shape aShape; + QString aName = GEOMBase::GetName(aSelectedObject); + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // Local Selection + { + int anIndex = aMap( 1 ); + aName.append( ":vertex_" + QString::number( anIndex ) ); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = aSelectedObject; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = aSelectedObject; - - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); - + displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -265,19 +300,20 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument() void PrimitiveGUI_BoxDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - + if(send == GroupPoints->PushButton1) myEditCurrentArgument = GroupPoints->LineEdit1; else if(send == GroupPoints->PushButton2) myEditCurrentArgument = GroupPoints->LineEdit2; - - globalSelection( GEOM_POINT ); - + + // globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + myEditCurrentArgument->setFocus(); SelectionIntoArgument(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -300,9 +336,9 @@ void PrimitiveGUI_BoxDlg::LineEditReturnPressed() void PrimitiveGUI_BoxDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + ConstructorsClicked( getConstructorId() ); } @@ -395,3 +431,18 @@ void PrimitiveGUI_BoxDlg::closeEvent( QCloseEvent* e ) { GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_BoxDlg::addSubshapesToStudy() +{ + QMap objMap; + if ( getConstructorId() == 0 ) + { + objMap[GroupPoints->LineEdit1->text()] = myPoint1; + objMap[GroupPoints->LineEdit2->text()] = myPoint2; + addSubshapesToFather( objMap ); + } +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h index 9e7139889..5ff6bf50c 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h @@ -52,7 +52,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx index ffb24f596..959312890 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -159,7 +166,7 @@ void PrimitiveGUI_ConeDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DZ, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; initName( tr( "GEOM_CONE" ) ); @@ -173,13 +180,15 @@ void PrimitiveGUI_ConeDlg::Init() //================================================================================= void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); switch(constructorId) { case 0 : { - globalSelection( GEOM_POINT ); + // globalSelection( GEOM_POINT ); + globalSelection(); // to break prvious local selection + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); @@ -189,7 +198,7 @@ void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId) GroupPoints->LineEdit2->setText(tr("")); myPoint = myDir = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -248,17 +257,17 @@ void PrimitiveGUI_ConeDlg::ClickOnCancel() //================================================================================= void PrimitiveGUI_ConeDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; - if(IObjectCount() != 1) - { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myPoint = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myDir = GEOM::GEOM_Object::_nil(); - return; - } + if (IObjectCount() != 1) + { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = GEOM::GEOM_Object::_nil(); + return; + } /* nbSel == 1 */ Standard_Boolean testResult = Standard_False; @@ -267,17 +276,56 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument() if(!testResult || CORBA::is_nil( aSelectedObject )) return; + TopoDS_Shape aShape; + QString aName = GEOMBase::GetName( aSelectedObject ); + + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPoints->LineEdit2) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if (aMap.Extent() == 1) + { + 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = aSelectedObject; else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = aSelectedObject; - - - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -288,11 +336,13 @@ void PrimitiveGUI_ConeDlg::SetEditCurrentArgument() if(send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_POINT ); + globalSelection( GEOM_POINT ); // to break prvious local selection + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - globalSelection( GEOM_LINE ); + globalSelection( GEOM_LINE );// to break prvious local selection + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); @@ -315,7 +365,6 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed() } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -323,12 +372,11 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed() void PrimitiveGUI_ConeDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - ConstructorsClicked( getConstructorId() ); -} + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + ConstructorsClicked(getConstructorId()); +} //================================================================================= // function : DeactivateActiveDialog() @@ -473,3 +521,23 @@ double PrimitiveGUI_ConeDlg::getHeight() const return GroupDimensions->SpinBox_DZ->GetValue(); return 0; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_ConeDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint; + objMap[GroupPoints->LineEdit2->text()] = myDir; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h index 6ac583460..f6b3f94cf 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h @@ -50,7 +50,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index 87358c260..341125900 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -152,7 +159,7 @@ void PrimitiveGUI_CylinderDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; initName( tr( "GEOM_CYLINDER" ) ); @@ -166,13 +173,14 @@ void PrimitiveGUI_CylinderDlg::Init() //================================================================================= void PrimitiveGUI_CylinderDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - switch(constructorId) + switch (constructorId) { case 0 : { - globalSelection( GEOM_POINT ); + globalSelection( GEOM_POINT ); // to break previous local selection + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupDimensions->hide(); resize(0, 0); @@ -183,7 +191,7 @@ void PrimitiveGUI_CylinderDlg::ConstructorsClicked(int constructorId) GroupPoints->LineEdit2->setText(tr("")); myPoint = myDir = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -242,38 +250,75 @@ void PrimitiveGUI_CylinderDlg::ClickOnCancel() //================================================================================= void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; myEditCurrentArgument->setText(""); - - if(IObjectCount() != 1) - { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myPoint = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myDir = GEOM::GEOM_Object::_nil(); - return; - } - + + if (IObjectCount() != 1) + { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = GEOM::GEOM_Object::_nil(); + return; + } + /* nbSel == 1 */ Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); - - if(!testResult || CORBA::is_nil( aSelectedObject )) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); + + if (!testResult || CORBA::is_nil(aSelectedObject)) return; - + + QString aName = GEOMBase::GetName(aSelectedObject); + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPoints->LineEdit2) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // Local Selection + { + 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = aSelectedObject; else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = aSelectedObject; - - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); - displayPreview(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -282,13 +327,15 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == GroupPoints->PushButton1) { + if (send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_POINT ); + globalSelection( GEOM_POINT ); // to break previous local selection + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } - else if(send == GroupPoints->PushButton2) { + else if (send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - globalSelection( GEOM_LINE ); + globalSelection( GEOM_LINE ); // to break previous local selection + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); @@ -311,7 +358,6 @@ void PrimitiveGUI_CylinderDlg::LineEditReturnPressed() } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -319,12 +365,11 @@ void PrimitiveGUI_CylinderDlg::LineEditReturnPressed() void PrimitiveGUI_CylinderDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - ConstructorsClicked( getConstructorId() ); -} + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + ConstructorsClicked(getConstructorId()); +} //================================================================================= // function : enterEvent() @@ -435,7 +480,6 @@ double PrimitiveGUI_CylinderDlg::getRadius() const return 0; } - //================================================================================= // function : getHeight() // purpose : @@ -449,3 +493,23 @@ double PrimitiveGUI_CylinderDlg::getHeight() const return GroupDimensions->SpinBox_DY->GetValue(); return 0; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_CylinderDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint; + objMap[GroupPoints->LineEdit2->text()] = myDir; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h index d6f8391be..1980db249 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h @@ -51,7 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx index 71ae63761..b51e1c222 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,6 +33,12 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -84,7 +90,6 @@ PrimitiveGUI_SphereDlg::PrimitiveGUI_SphereDlg(GeometryGUI* theGeometryGUI, QWid Init(); } - //================================================================================= // function : ~PrimitiveGUI_SphereDlg() // purpose : Destroys the object and frees any allocated resources @@ -94,7 +99,6 @@ PrimitiveGUI_SphereDlg::~PrimitiveGUI_SphereDlg() /* no need to delete child widgets, Qt does it all for us */ } - //================================================================================= // function : Init() // purpose : @@ -128,30 +132,32 @@ void PrimitiveGUI_SphereDlg::Init() connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); initName(tr("GEOM_SPHERE")); ConstructorsClicked(0); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) +void PrimitiveGUI_SphereDlg::ConstructorsClicked (int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); - + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + switch (constructorId) { case 0: { - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); @@ -160,7 +166,7 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) GroupPoints->LineEdit1->setText(""); myPoint = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -176,7 +182,6 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) displayPreview(); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -187,7 +192,6 @@ void PrimitiveGUI_SphereDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : @@ -202,49 +206,77 @@ bool PrimitiveGUI_SphereDlg::ClickOnApply() return true; } - - -//======================================================================= +//================================================================================= // function : ClickOnCancel() // purpose : -//======================================================================= +//================================================================================= void PrimitiveGUI_SphereDlg::ClickOnCancel() { GEOMBase_Skeleton::ClickOnCancel(); } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void PrimitiveGUI_SphereDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; - + myEditCurrentArgument->setText(""); - - if(IObjectCount() != 1) - { - myPoint = GEOM::GEOM_Object::_nil(); - return; - } - + + if (IObjectCount() != 1) + { + myPoint = GEOM::GEOM_Object::_nil(); + return; + } + /* nbSel == 1 ! */ Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); - - if (!testResult || CORBA::is_nil( aSelectedObject )) + GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); + + if (!testResult || CORBA::is_nil(aSelectedObject)) return; - + + QString aName = GEOMBase::GetName(aSelectedObject); + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); myPoint = aSelectedObject; - myEditCurrentArgument->setText( GEOMBase::GetName( myPoint ) ); - + displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -259,7 +291,6 @@ void PrimitiveGUI_SphereDlg::LineEditReturnPressed() } } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -268,15 +299,15 @@ void PrimitiveGUI_SphereDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == GroupPoints->PushButton1) { + if (send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); SelectionIntoArgument(); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -284,12 +315,11 @@ void PrimitiveGUI_SphereDlg::SetEditCurrentArgument() void PrimitiveGUI_SphereDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - ConstructorsClicked( getConstructorId() ); -} + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + ConstructorsClicked(getConstructorId()); +} //================================================================================= // function : DeactivateActiveDialog() @@ -300,7 +330,6 @@ void PrimitiveGUI_SphereDlg::DeactivateActiveDialog() GEOMBase_Skeleton::DeactivateActiveDialog(); } - //================================================================================= // function : enterEvent() // purpose : @@ -311,7 +340,6 @@ void PrimitiveGUI_SphereDlg::enterEvent(QEvent* e) ActivateThisDialog(); } - //================================================================================= // function : ValueChangedInSpinBox() // purpose : @@ -321,7 +349,6 @@ void PrimitiveGUI_SphereDlg::ValueChangedInSpinBox() displayPreview(); } - //================================================================================= // function : createOperation // purpose : @@ -331,7 +358,6 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_SphereDlg::createOperation() return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } - //================================================================================= // function : isValid // purpose : @@ -345,33 +371,35 @@ bool PrimitiveGUI_SphereDlg::isValid( QString& msg ) // function : execute // purpose : //================================================================================= -bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects ) +bool PrimitiveGUI_SphereDlg::execute (ObjectList& objects) { bool res = false; - + GEOM::GEOM_Object_var anObj; - switch ( getConstructorId() ) + switch (getConstructorId()) { - case 0 : + case 0: { - if ( !CORBA::is_nil( myPoint ) ) { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSpherePntR( myPoint, getRadius() ); + if (!CORBA::is_nil(myPoint)) { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakeSpherePntR(myPoint, getRadius()); res = true; } break; } - case 1 : + case 1: { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSphereR( getRadius() ); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakeSphereR(getRadius()); res = true; break; } } - - if ( !anObj->_is_nil() ) - objects.push_back( anObj._retn() ); - + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + return res; } @@ -381,12 +409,9 @@ bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects ) //================================================================================= void PrimitiveGUI_SphereDlg::closeEvent( QCloseEvent* e ) { - //myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::closeEvent( e ); } - - //================================================================================= // function : getRadius() // purpose : @@ -400,3 +425,22 @@ double PrimitiveGUI_SphereDlg::getRadius() const return GroupDimensions->SpinBox_DX->GetValue(); return 0; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_SphereDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h index 7885126b2..8e1297ffa 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h @@ -51,7 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx index f88b18f20..2cf16f2d7 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -152,19 +159,18 @@ void PrimitiveGUI_TorusDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI->getApp()->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_TORUS" ) ); ConstructorsClicked(0); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) +void PrimitiveGUI_TorusDlg::ConstructorsClicked (int constructorId) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); @@ -172,7 +178,8 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) { case 0: { - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupDimensions->hide(); resize(0, 0); @@ -209,7 +216,7 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) //================================================================================= void PrimitiveGUI_TorusDlg::ClickOnOk() { - if ( ClickOnApply() ) + if (ClickOnApply()) ClickOnCancel(); } @@ -220,7 +227,7 @@ void PrimitiveGUI_TorusDlg::ClickOnOk() //================================================================================= bool PrimitiveGUI_TorusDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; initName(); @@ -234,7 +241,7 @@ bool PrimitiveGUI_TorusDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_TorusDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; myEditCurrentArgument->setText(""); @@ -250,21 +257,60 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument() /* nbSel == 1 */ Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); - if (!testResult || CORBA::is_nil( aSelectedObject )) + if (!testResult || CORBA::is_nil(aSelectedObject)) return; + QString aName = GEOMBase::GetName(aSelectedObject); + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPoints->LineEdit2) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // Local Selection + { + 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 == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = aSelectedObject; else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = aSelectedObject; - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -288,14 +334,16 @@ void PrimitiveGUI_TorusDlg::LineEditReturnPressed() void PrimitiveGUI_TorusDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_POINT ); // to break previous local selection if (send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_POINT ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } else if (send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - globalSelection( GEOM_LINE ); + GEOM::GEOM_Object_var anObj; + localSelection( anObj, TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); @@ -348,7 +396,6 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_TorusDlg::createOperation() return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } - //================================================================================= // function : isValid // purpose : @@ -358,7 +405,6 @@ bool PrimitiveGUI_TorusDlg::isValid( QString& msg ) return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true; } - //================================================================================= // function : execute // purpose : @@ -396,7 +442,6 @@ bool PrimitiveGUI_TorusDlg::execute( ObjectList& objects ) return res; } - //================================================================================= // function : getRadius1() // purpose : @@ -411,7 +456,6 @@ double PrimitiveGUI_TorusDlg::getRadius1() const return 0; } - //================================================================================= // function : getRadius2() // purpose : @@ -425,3 +469,23 @@ double PrimitiveGUI_TorusDlg::getRadius2() const return GroupDimensions->SpinBox_DY->GetValue(); return 0; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_TorusDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint; + objMap[GroupPoints->LineEdit2->text()] = myDir; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h index 08e86ced1..1703b6a43 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h @@ -51,6 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init(); diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx index d800bf5d7..345ce98fe 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include @@ -229,10 +236,54 @@ void TransformationGUI_MirrorDlg::SelectionIntoArgument() return; } Standard_Boolean testResult = Standard_False; - myArgument = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult ); + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult ); + myArgument = aSelectedObject; if(!testResult || CORBA::is_nil( myArgument )) return; - aName = GEOMBase::GetName( myArgument ); + + aName = GEOMBase::GetName( aSelectedObject ); + + if ( testResult && !aSelectedObject->_is_nil() ) + { + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (getConstructorId() == 1) + aNeedType = TopAbs_EDGE; + else if (getConstructorId() == 2) + aNeedType = TopAbs_FACE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) + { + int anIndex = aMap( 1 ); + if (aNeedType == 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 = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + myArgument = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + myArgument = aFindedObject; // get Object from study + } + else { + if (aShape.ShapeType() != aNeedType) { + myArgument = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + } } myEditCurrentArgument->setText( aName ); @@ -263,10 +314,10 @@ void TransformationGUI_MirrorDlg::LineEditReturnPressed() void TransformationGUI_MirrorDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if(send == GroupPoints->PushButton1){ myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; @@ -274,12 +325,12 @@ void TransformationGUI_MirrorDlg::SetEditCurrentArgument() { case 0: { - globalSelection( GEOM_POINT ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); break; } case 1: { - globalSelection( GEOM_LINE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); break; } case 2: @@ -432,3 +483,28 @@ void TransformationGUI_MirrorDlg::CreateCopyModeChanged(bool isCreateCopy) { this->GroupBoxName->setEnabled(isCreateCopy); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_MirrorDlg::addSubshapesToStudy() +{ + bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); + if (toCreateCopy) { + QMap objMap; + + switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myArgument; + break; + case 1: + objMap[GroupPoints->LineEdit2->text()] = myArgument; + break; + case 2: + return; + } + addSubshapesToFather( objMap ); + } +} diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.h b/src/TransformationGUI/TransformationGUI_MirrorDlg.h index 44d8f5dda..25f576739 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.h +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.h @@ -52,7 +52,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx index b3339abdf..e71497d84 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include @@ -281,14 +288,51 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() if (!testResult || CORBA::is_nil(aSelectedObject) || !GEOMBase::IsShape(aSelectedObject)) return; + QString aName = GEOMBase::GetName( aSelectedObject ); + if (myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1) myBase = aSelectedObject; else if (myEditCurrentArgument == GroupPoints->LineEdit2 || - myEditCurrentArgument == GroupDimensions->LineEdit2) - myVector = aSelectedObject; - - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + myEditCurrentArgument == GroupDimensions->LineEdit2) { + if ( testResult && !aSelectedObject->_is_nil() ) + { + TopoDS_Shape aShape; + + + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) + { + int anIndex = aMap( 1 ); + aName += QString(":edge_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + myVector = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + myVector = aFindedObject; // get existing object + } + else { + if (aShape.ShapeType() != TopAbs_EDGE) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + myVector = aSelectedObject; + } + + } + } + } + myEditCurrentArgument->setText( aName ); displayPreview(); } @@ -301,22 +345,21 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_ALLSHAPES ); if(send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - globalSelection( GEOM_LINE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if(send == GroupDimensions->PushButton1) { myEditCurrentArgument = GroupDimensions->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupDimensions->PushButton2) { myEditCurrentArgument = GroupDimensions->LineEdit2; - globalSelection( GEOM_LINE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); @@ -473,3 +516,23 @@ void TransformationGUI_MultiRotationDlg::closeEvent( QCloseEvent* e ) // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_MultiRotationDlg::addSubshapesToStudy() +{ + QMap objMap; + + switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myVector; + break; + case 1: + objMap[GroupDimensions->LineEdit2->text()] = myVector; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h index d82780fd2..44d7d5176 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h @@ -51,7 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx index 553c06609..b9993d6cf 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -298,16 +305,61 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() if ( !testResult || CORBA::is_nil( aSelectedObject ) || !GEOMBase::IsShape( aSelectedObject ) ) return; + QString aName = GEOMBase::GetName( aSelectedObject ); + if (myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1) myBase = aSelectedObject; else if (myEditCurrentArgument == GroupPoints->LineEdit2 || - myEditCurrentArgument == GroupDimensions->LineEdit2) - myVectorU = aSelectedObject; - else if (myEditCurrentArgument == GroupDimensions->LineEdit3) - myVectorV = aSelectedObject; + myEditCurrentArgument == GroupDimensions->LineEdit2 || + myEditCurrentArgument == GroupDimensions->LineEdit3 ) { + if ( testResult && !aSelectedObject->_is_nil() ) + { + TopoDS_Shape aShape; + + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) + { + int anIndex = aMap( 1 ); + aName += QString(":edge_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) + myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex); + else + myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else { + if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) + myVectorV = aFindedObject; + else + myVectorU = aFindedObject; + } + } + else { + if (aShape.ShapeType() != TopAbs_EDGE) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) + myVectorV = aSelectedObject; + else + myVectorU = aSelectedObject; + } + } + } + } - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + myEditCurrentArgument->setText( aName ); displayPreview(); } @@ -320,26 +372,25 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_ALLSHAPES ); if(send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - globalSelection( GEOM_LINE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if(send == GroupDimensions->PushButton1) { myEditCurrentArgument = GroupDimensions->LineEdit1; - globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupDimensions->PushButton2) { myEditCurrentArgument = GroupDimensions->LineEdit2; - globalSelection( GEOM_LINE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if(send == GroupDimensions->PushButton3) { myEditCurrentArgument = GroupDimensions->LineEdit3; - globalSelection( GEOM_LINE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); @@ -531,3 +582,24 @@ void TransformationGUI_MultiTranslationDlg::closeEvent( QCloseEvent* e ) // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy() +{ + QMap objMap; + + switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myVectorU; + break; + case 1: + objMap[GroupDimensions->LineEdit2->text()] = myVectorU; + objMap[GroupDimensions->LineEdit3->text()] = myVectorV; + break; + } + addSubshapesToFather( objMap ); +} diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h index c36073d8b..c5746db3e 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h @@ -51,7 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx index 9412b8f4f..f0cca0130 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include @@ -262,6 +269,44 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() if(!testResult || CORBA::is_nil( aSelectedObject )) return; + aName = GEOMBase::GetName( aSelectedObject ); + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + 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 = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) myAxis = aSelectedObject; else if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) @@ -271,7 +316,6 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() else if(myEditCurrentArgument == GroupPoints->LineEdit5) myPoint2 = aSelectedObject; - aName = GEOMBase::GetName( aSelectedObject ); } myEditCurrentArgument->setText( aName ); @@ -286,25 +330,27 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() void TransformationGUI_RotationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if(send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - getConstructorId() == 0 ? globalSelection( GEOM_LINE ) : - globalSelection( GEOM_POINT ); + if (getConstructorId() == 0) + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + else + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } else if (send == GroupPoints->PushButton4) { myEditCurrentArgument = GroupPoints->LineEdit4; - globalSelection( GEOM_POINT ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } else if (send == GroupPoints->PushButton5) { myEditCurrentArgument = GroupPoints->LineEdit5; - globalSelection( GEOM_POINT ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } myEditCurrentArgument->setFocus(); @@ -496,3 +542,27 @@ void TransformationGUI_RotationDlg::onReverse() double anOldValue = GroupPoints->SpinBox_DX->GetValue(); GroupPoints->SpinBox_DX->SetValue( -anOldValue ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_RotationDlg::addSubshapesToStudy() +{ + bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); + if (toCreateCopy) { + QMap objMap; + switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit2->text()] = myAxis; + break; + case 1: + objMap[GroupPoints->LineEdit2->text()] = myCentPoint; + objMap[GroupPoints->LineEdit4->text()] = myPoint1; + objMap[GroupPoints->LineEdit5->text()] = myPoint2; + break; + } + addSubshapesToFather( objMap ); + } +} diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.h b/src/TransformationGUI/TransformationGUI_RotationDlg.h index 4a18bbc1d..4ea6ea9e5 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.h @@ -49,7 +49,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private: diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx index 0a3f8876f..7a992b2ae 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx @@ -33,6 +33,12 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include + #include #include @@ -194,10 +200,45 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument() return; } Standard_Boolean testResult = Standard_False; - myPoint = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult ); + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult ); + aName = GEOMBase::GetName( aSelectedObject ); + + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) + { + int anIndex = aMap( 1 ); + aName += QString(":vertex_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + aSelMgr->clearSelected(); + } + else + aSelectedObject = aFindedObject; // get Object from study + } + else { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myPoint = aSelectedObject; + if(!testResult || CORBA::is_nil( myPoint )) return; - aName = GEOMBase::GetName( myPoint ); + } myEditCurrentArgument->setText( aName ); @@ -228,14 +269,14 @@ void TransformationGUI_ScaleDlg::LineEditReturnPressed() void TransformationGUI_ScaleDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if(send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); } else if(send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - globalSelection( GEOM_POINT ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } myEditCurrentArgument->setFocus(); @@ -358,3 +399,19 @@ void TransformationGUI_ScaleDlg::CreateCopyModeChanged(bool isCreateCopy) { this->GroupBoxName->setEnabled(isCreateCopy); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_ScaleDlg::addSubshapesToStudy() +{ + bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); + if (toCreateCopy) { + QMap objMap; + + objMap[GroupPoints->LineEdit2->text()] = myPoint; + + addSubshapesToFather( objMap ); + } +} diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.h b/src/TransformationGUI/TransformationGUI_ScaleDlg.h index 0190f04d5..7f77c6b42 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.h +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.h @@ -50,7 +50,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - + virtual void addSubshapesToStudy(); virtual void closeEvent( QCloseEvent* e ); private : diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx index 0e414beba..e5f0f183a 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -33,6 +33,13 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include +#include + #include #include @@ -276,14 +283,50 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument() if (!testResult || CORBA::is_nil( aSelectedObject )) return; + TopoDS_Shape aShape; + aName = GEOMBase::GetName( aSelectedObject ); + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + 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 = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; + } else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) myPoint1 = aSelectedObject; else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) myVector = aSelectedObject; else if (myEditCurrentArgument == GroupPoints->LineEdit3) myPoint2 = aSelectedObject; - - aName = GEOMBase::GetName( aSelectedObject ); } myEditCurrentArgument->setText( aName ); @@ -313,19 +356,21 @@ void TransformationGUI_TranslationDlg::LineEditReturnPressed() void TransformationGUI_TranslationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if (send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); } else if (send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; - getConstructorId() == 1 ? globalSelection( GEOM_POINT ) : - globalSelection( GEOM_LINE ); + if (getConstructorId() == 1) + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + else + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if (send == GroupPoints->PushButton3) { myEditCurrentArgument = GroupPoints->LineEdit3; - globalSelection( GEOM_POINT ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } myEditCurrentArgument->setFocus(); @@ -502,3 +547,29 @@ void TransformationGUI_TranslationDlg::CreateCopyModeChanged(bool isCreateCopy) { GroupBoxName->setEnabled(isCreateCopy); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_TranslationDlg::addSubshapesToStudy() +{ + bool toCreateCopy = IsPreview() || GroupPoints->CheckBox1->isChecked(); + if (toCreateCopy) { + QMap objMap; + + switch (getConstructorId()) + { + case 0: + return; + case 1: + objMap[GroupPoints->LineEdit2->text()] = myPoint1; + objMap[GroupPoints->LineEdit3->text()] = myPoint2; + break; + case 2: + objMap[GroupPoints->LineEdit2->text()] = myVector; + break; + } + addSubshapesToFather( objMap ); + } +} diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.h b/src/TransformationGUI/TransformationGUI_TranslationDlg.h index dac586af0..11975c136 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.h +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.h @@ -50,6 +50,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); + virtual void addSubshapesToStudy(); private: void Init();