From: dmv Date: Mon, 15 Oct 2007 07:04:29 +0000 (+0000) Subject: NPAL16557 NPAL16558 NPAL16578 NPAL16549 NPAL16561 X-Git-Tag: V3_2_9rc1~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8c52376a9b7b6e8655307c869dce2c9134b64002;p=modules%2Fgeom.git NPAL16557 NPAL16558 NPAL16578 NPAL16549 NPAL16561 --- diff --git a/Makefile.in b/Makefile.in index e5697da5c..d5d2bfb1e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -64,11 +64,13 @@ chamfer.png \ chamferall.png \ chamferedge.png \ chamferface.png \ +chamferedgefromface.png \ change_orientation.png \ check.png \ circle.png \ circlepointvector.png \ circle3points.png \ +circlecenter2pnts.png \ common.png \ cone.png \ conedxyz.png \ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index edc35ef21..815775ff9 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1801,7 +1801,15 @@ module GEOM GEOM_Object MakeCircleThreePnt (in GEOM_Object thePnt1, in GEOM_Object thePnt2, in GEOM_Object thePnt3); - + /*! + * Create a circle with given center, with a radius equals the distance from center to Point1 + * and on a plane defined by all of three points. + * \param thePnt1,thePnt2,thePnt3 Points, defining the circle. + * \return New GEOM_Object, containing the created circle. + */ + GEOM_Object MakeCircleCenter2Pnt (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3); /*! * Create an ellipse with given center, normal vector and radiuses. * \param thePnt Ellipse center. @@ -1935,6 +1943,10 @@ module GEOM GEOM_Object MakeFilletEdges (in GEOM_Object theShape, in double theR, in ListOfLong theEdges); + GEOM_Object MakeFilletEdgesR1R2 (in GEOM_Object theShape, + in double theR1, + in double theR2, + in ListOfLong theEdges); /*! * Perform a fillet on all edges of the specified faces of the given shape. @@ -1948,6 +1960,10 @@ module GEOM GEOM_Object MakeFilletFaces (in GEOM_Object theShape, in double theR, in ListOfLong theFaces); + GEOM_Object MakeFilletFacesR1R2 (in GEOM_Object theShape, + in double theR1, + in double theR2, + in ListOfLong theFaces); /*! * Perform a symmetric chamfer on all edges of the given shape. @@ -1972,6 +1988,13 @@ module GEOM GEOM_Object MakeChamferEdge (in GEOM_Object theShape, in double theD1, in double theD2, in long theFace1, in long theFace2); + /*! + * The Same but with params theD = Chamfer Lenght + * and theAngle = Chamfer Angle (Angle in radians) + */ + GEOM_Object MakeChamferEdgeAD (in GEOM_Object theShape, + in double theD, in double theAngle, + in long theFace1, in long theFace2); /*! * Perform a chamfer on all edges of the specified faces. @@ -1989,6 +2012,32 @@ module GEOM GEOM_Object MakeChamferFaces (in GEOM_Object theShape, in double theD1, in double theD2, in ListOfLong theFaces); + /*! + * The Same but with params theD = Chamfer Lenght + * and theAngle = Chamfer Angle (Angle in radians) + */ + GEOM_Object MakeChamferFacesAD (in GEOM_Object theShape, + in double theD, in double theAngle, + in ListOfLong theFaces); + + /*! + * Perform a chamfer on edges, + * with distance D1 on the first specified face (if several for one edge) + * \param theShape Shape, to perform chamfer on. + * \param theD1 theD2 Chamfer size + * \param theEdges Sequence of edges of \a theShape. + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeChamferEdges (in GEOM_Object theShape, + in double theD1, in double theD2, + in ListOfLong theEdges); + /*! + * The Same but with params theD = Chamfer Lenght + * and theAngle = Chamfer Angle (Angle in radians) + */ + GEOM_Object MakeChamferEdgesAD (in GEOM_Object theShape, + in double theD, in double theAngle, + in ListOfLong theEdges); /*! * Perform an Archimde operation on the given shape with given parameters. diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 875946b9d..e217d4077 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -414,6 +414,9 @@ module GEOM GEOM_Object MakeCircleThreePnt (in GEOM_Object thePnt1, in GEOM_Object thePnt2, in GEOM_Object thePnt3) ; + GEOM_Object MakeCircleCenter2Pnt (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3) ; GEOM_Object MakeEllipse (in GEOM_Object thePnt, in GEOM_Object theVec, in double theRMajor, @@ -439,17 +442,37 @@ module GEOM GEOM_Object MakeFilletEdges (in GEOM_Object theShape, in double theR, in GEOM_List theEdges) ; + GEOM_Object MakeFilletEdgesR1R2 (in GEOM_Object theShape, + in double theR1, + in double theR2, + in GEOM_List theEdges) ; GEOM_Object MakeFilletFaces (in GEOM_Object theShape, in double theR, in GEOM_List theFaces) ; + GEOM_Object MakeFilletFacesR1R2 (in GEOM_Object theShape, + in double theR1, + in double theR2, + in GEOM_List theFaces) ; GEOM_Object MakeChamferAll (in GEOM_Object theShape, in double theD) ; GEOM_Object MakeChamferEdge (in GEOM_Object theShape, in double theD1, in double theD2, in long theFace1, in long theFace2) ; + GEOM_Object MakeChamferEdgeAD (in GEOM_Object theShape, + in double theD, in double theAngle, + in long theFace1, in long theFace2) ; GEOM_Object MakeChamferFaces (in GEOM_Object theShape, in double theD1, in double theD2, in GEOM_List theFaces) ; + GEOM_Object MakeChamferFacesAD (in GEOM_Object theShape, + in double theD, in double theAngle, + in GEOM_List theFaces) ; + GEOM_Object MakeChamferEdges (in GEOM_Object theShape, + in double theD1, in double theD2, + in GEOM_List theEdges) ; + GEOM_Object MakeChamferEdgesAD (in GEOM_Object theShape, + in double theD, in double theAngle, + in GEOM_List theEdges) ; GEOM_Object MakeArchimede (in GEOM_Object theShape, in double theWeight, in double theWaterDensity, diff --git a/resources/chamferall.png b/resources/chamferall.png index c90b6740e..7fdbd1325 100644 Binary files a/resources/chamferall.png and b/resources/chamferall.png differ diff --git a/resources/chamferedge.png b/resources/chamferedge.png index e8d5ccd57..c6ea12222 100644 Binary files a/resources/chamferedge.png and b/resources/chamferedge.png differ diff --git a/resources/chamferedgefromface.png b/resources/chamferedgefromface.png new file mode 100755 index 000000000..816125a02 Binary files /dev/null and b/resources/chamferedgefromface.png differ diff --git a/resources/chamferface.png b/resources/chamferface.png index 4e3f36b25..68d5959cd 100644 Binary files a/resources/chamferface.png and b/resources/chamferface.png differ diff --git a/resources/circlecenter2pnts.png b/resources/circlecenter2pnts.png new file mode 100755 index 000000000..7b3daa2d5 Binary files /dev/null and b/resources/circlecenter2pnts.png differ diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index 42c3e5aa5..0fcbcb236 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -36,6 +36,8 @@ #include #include "GEOMImpl_Types.hxx" +#include "GEOM_Object.hxx" +#include "GEOM_Engine.hxx" #include "utilities.h" @@ -53,6 +55,7 @@ BasicGUI_CircleDlg::BasicGUI_CircleDlg(GeometryGUI* theGeometryGUI, QWidget* par { QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CIRCLE_PV"))); QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CIRCLE_PNTS"))); + QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CIRCLE_C2P"))); QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); setCaption(tr("GEOM_CIRCLE_TITLE")); @@ -61,7 +64,7 @@ BasicGUI_CircleDlg::BasicGUI_CircleDlg(GeometryGUI* theGeometryGUI, QWidget* par GroupConstructors->setTitle(tr("GEOM_CIRCLE")); RadioButton1->setPixmap(image0); RadioButton2->setPixmap(image2); - RadioButton3->close(TRUE); + RadioButton3->setPixmap(image3); GroupPntVecR = new DlgRef_2Sel1Spin(this, "GroupPntVecR"); GroupPntVecR->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); @@ -88,8 +91,22 @@ BasicGUI_CircleDlg::BasicGUI_CircleDlg(GeometryGUI* theGeometryGUI, QWidget* par Group3Pnts->LineEdit2->setReadOnly( true ); Group3Pnts->LineEdit3->setReadOnly( true ); + GroupCenter2Pnts = new DlgRef_3Sel_QTD(this, "GroupCenter2Pnts"); + GroupCenter2Pnts->GroupBox1->setTitle(tr("GEOM_CENTER_2POINTS")); + GroupCenter2Pnts->TextLabel1->setText(tr("GEOM_CENTER_POINT")); + GroupCenter2Pnts->TextLabel2->setText(tr("GEOM_POINT1")); + GroupCenter2Pnts->TextLabel3->setText(tr("GEOM_POINT2")); + GroupCenter2Pnts->PushButton1->setPixmap(image1); + GroupCenter2Pnts->PushButton2->setPixmap(image1); + GroupCenter2Pnts->PushButton3->setPixmap(image1); + + GroupCenter2Pnts->LineEdit1->setReadOnly( true ); + GroupCenter2Pnts->LineEdit2->setReadOnly( true ); + GroupCenter2Pnts->LineEdit3->setReadOnly( true ); + Layout1->addWidget( GroupPntVecR, 2, 0 ); Layout1->addWidget( Group3Pnts, 2, 0 ); + Layout1->addWidget( GroupCenter2Pnts, 2, 0 ); /***************************************************************/ setHelpFileName("circle.htm"); @@ -143,6 +160,10 @@ void BasicGUI_CircleDlg::Init() connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupCenter2Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupCenter2Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupCenter2Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPntVecR->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); @@ -155,6 +176,7 @@ void BasicGUI_CircleDlg::Init() initName( tr( "GEOM_CIRCLE" ) ); Group3Pnts->hide(); + GroupCenter2Pnts->hide(); ConstructorsClicked( 0 ); } @@ -172,6 +194,7 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) case 0: { Group3Pnts->hide(); + GroupCenter2Pnts->hide(); resize(0, 0); GroupPntVecR->show(); @@ -183,6 +206,7 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) case 1: { GroupPntVecR->hide(); + GroupCenter2Pnts->hide(); resize( 0, 0 ); Group3Pnts->show(); @@ -192,6 +216,19 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) 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; + } } myEditCurrentArgument->setFocus(); @@ -248,6 +285,9 @@ void BasicGUI_CircleDlg::SelectionIntoArgument() 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; } @@ -255,15 +295,18 @@ void BasicGUI_CircleDlg::SelectionIntoArgument() 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; } - displayPreview(); } @@ -281,6 +324,9 @@ void BasicGUI_CircleDlg::SetEditCurrentArgument() else if ( send == Group3Pnts->PushButton1 ) myEditCurrentArgument = Group3Pnts->LineEdit1; else if ( send == Group3Pnts->PushButton2 ) myEditCurrentArgument = Group3Pnts->LineEdit2; else if ( send == Group3Pnts->PushButton3 ) myEditCurrentArgument = Group3Pnts->LineEdit3; + 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(); @@ -302,7 +348,10 @@ void BasicGUI_CircleDlg::LineEditReturnPressed() send == GroupPntVecR->LineEdit2 || send == Group3Pnts->LineEdit1 || send == Group3Pnts->LineEdit2 || - send == Group3Pnts->LineEdit3 ) + send == Group3Pnts->LineEdit3 || + send == GroupCenter2Pnts->LineEdit1 || + send == GroupCenter2Pnts->LineEdit2 || + send == GroupCenter2Pnts->LineEdit3 ) { myEditCurrentArgument = send; GEOMBase_Skeleton::LineEditReturnPressed(); @@ -362,7 +411,11 @@ void BasicGUI_CircleDlg::ValueChangedInSpinBox() //================================================================================= double BasicGUI_CircleDlg::getRadius() const { - return GroupPntVecR->SpinBox_DX->GetValue(); + switch ( getConstructorId() ) + { + case 0 : + return GroupPntVecR->SpinBox_DX->GetValue(); + } } //================================================================================= @@ -395,6 +448,9 @@ bool BasicGUI_CircleDlg::isValid( QString& msg ) else if ( id == 1 ) return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() && !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ); + else if ( id == 2 ) + return !myPoint4->_is_nil() && !myPoint5->_is_nil() && !myPoint6->_is_nil() && + !isEqual( myPoint4, myPoint5 ) && !isEqual( myPoint5, myPoint6 ) && !isEqual( myPoint4, myPoint6 ); return false; } @@ -410,6 +466,7 @@ bool BasicGUI_CircleDlg::execute( ObjectList& objects ) switch ( getConstructorId() ) { + cout << "constructior ID = " << getConstructorId() << endl; case 0 : anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCirclePntVecR( myPoint, myDir, getRadius() ); res = true; @@ -418,10 +475,15 @@ bool BasicGUI_CircleDlg::execute( ObjectList& objects ) 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 ); + res = true; + break; } if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); + else cout << "Execute Object is NULL!" << endl; return res; } diff --git a/src/BasicGUI/BasicGUI_CircleDlg.h b/src/BasicGUI/BasicGUI_CircleDlg.h index dae862b04..c97ab51ed 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.h +++ b/src/BasicGUI/BasicGUI_CircleDlg.h @@ -68,10 +68,12 @@ private: void enterEvent(QEvent* e); double getRadius() const; - GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3; + GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3, myPoint4, myPoint5, myPoint6; + CORBA::Double myRadius; DlgRef_2Sel1Spin* GroupPntVecR; DlgRef_3Sel_QTD* Group3Pnts; + DlgRef_3Sel_QTD* GroupCenter2Pnts; private slots: void ClickOnOk(); diff --git a/src/DlgRef/DlgRef_2Sel3Spin2Rb.cxx b/src/DlgRef/DlgRef_2Sel3Spin2Rb.cxx new file mode 100755 index 000000000..a17d55e41 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel3Spin2Rb.cxx @@ -0,0 +1,41 @@ +// File : DlgRef_2Sel2Spin.cxx +// Author : Dmitry MATVEITCHEV +// Module : GEOM +// $Header: + +#include "DlgRef_2Sel3Spin2Rb.h" +#include + +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel3Spin2Rb which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_2Sel3Spin2Rb::DlgRef_2Sel3Spin2Rb(QWidget* parent, const char* name, WFlags fl) + :DlgRef_2Sel3Spin2Rb_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); + RadioButton1->setChecked(true); + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addMultiCellWidget(SpinBox_DX, 0, 0, 2, 4); + SpinBox_DY = new DlgRef_SpinBox(GroupBox1, "SpinBox_DY"); + Layout2->addWidget(SpinBox_DY, 1, 2); + SpinBox_DZ = new DlgRef_SpinBox(GroupBox1, "SpinBox_DZ"); + Layout2->addWidget(SpinBox_DZ, 1, 4); + SpinBox_DY->setEnabled(false); + SpinBox_DZ->setEnabled(false); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel3Spin2Rb::~DlgRef_2Sel3Spin2Rb() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_2Sel3Spin2Rb.h b/src/DlgRef/DlgRef_2Sel3Spin2Rb.h new file mode 100755 index 000000000..e651662f7 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel3Spin2Rb.h @@ -0,0 +1,34 @@ +// File : DlgRef_2Sel3Spin2Rb.h +// Author : Dmitry MATVEITCHEV +// Module : GEOM +// $Header: + +#ifndef DLGREF_2SEL3SPIN2RB_H +#define DLGREF_2SEL3SPIN2RB_H + +#include "DlgRef_2Sel3Spin2Rb_QTD.h" +#include "DlgRef_SpinBox.h" +//#if defined WNT +//#include +//#else +//#define SALOME_WNT_EXPORT +//#endif +#if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS +#define DLGREF_WNT_EXPORT __declspec( dllexport ) +#else +#define DLGREF_WNT_EXPORT +#endif +class DLGREF_WNT_EXPORT DlgRef_2Sel3Spin2Rb : public DlgRef_2Sel3Spin2Rb_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel3Spin2Rb(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_2Sel3Spin2Rb(); + + DlgRef_SpinBox* SpinBox_DX; + DlgRef_SpinBox* SpinBox_DY; + DlgRef_SpinBox* SpinBox_DZ; +}; + +#endif // DLGREF_2SEL3SPIN2RB_H diff --git a/src/DlgRef/DlgRef_2Sel3Spin2Rb_QTD.cxx b/src/DlgRef/DlgRef_2Sel3Spin2Rb_QTD.cxx new file mode 100755 index 000000000..bcbd3d658 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel3Spin2Rb_QTD.cxx @@ -0,0 +1,129 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_2Sel3Spin2Rb_QTD.ui' +** +** Created: Tue Oct 9 15:16:54 2007 +** by: The User Interface Compiler ($Id$) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +#include "DlgRef_2Sel3Spin2Rb_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel3Spin2Rb_QTD as a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_2Sel3Spin2Rb_QTD::DlgRef_2Sel3Spin2Rb_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_2Sel3Spin2Rb_QTD" ); + DlgRef_2Sel3Spin2Rb_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel3Spin2Rb_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( TextLabel5, 1, 3 ); + + RadioButton2 = new QRadioButton( GroupBox1, "RadioButton2" ); + + Layout2->addWidget( RadioButton2, 1, 0 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( TextLabel3, 0, 1 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addMultiCellWidget( SpinBox1, 0, 0, 2, 4 ); + + RadioButton1 = new QRadioButton( GroupBox1, "RadioButton1" ); + + Layout2->addWidget( RadioButton1, 0, 0 ); + + SpinBox3 = new QSpinBox( GroupBox1, "SpinBox3" ); + SpinBox3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox3->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox3, 1, 4 ); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox2, 1, 2 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( TextLabel4, 1, 1 ); + + Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + Spacer5 = new QSpacerItem( 0, 207, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( Spacer5, 3, 2 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_2Sel3Spin2Rb_QTDLayout->addWidget( GroupBox1, 0, 0 ); + resize( QSize(439, 340).expandedTo(minimumSizeHint()) ); + clearWState( WState_Polished ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel3Spin2Rb_QTD::~DlgRef_2Sel3Spin2Rb_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_2Sel3Spin2Rb_QTD.h b/src/DlgRef/DlgRef_2Sel3Spin2Rb_QTD.h new file mode 100755 index 000000000..89f145aff --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel3Spin2Rb_QTD.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_2Sel3Spin2Rb_QTD.ui' +** +** Created: Tue Oct 9 15:16:54 2007 +** by: The User Interface Compiler ($Id$) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +#ifndef DLGREF_2SEL3SPIN2RB_QTD_H +#define DLGREF_2SEL3SPIN2RB_QTD_H + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QSpacerItem; +class QGroupBox; +class QPushButton; +class QLineEdit; +class QLabel; +class QRadioButton; +class QSpinBox; + +class DlgRef_2Sel3Spin2Rb_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_2Sel3Spin2Rb_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Sel3Spin2Rb_QTD(); + + QGroupBox* GroupBox1; + QPushButton* PushButton1; + QLineEdit* LineEdit1; + QLabel* TextLabel2; + QLabel* TextLabel5; + QRadioButton* RadioButton2; + QLabel* TextLabel3; + QSpinBox* SpinBox1; + QRadioButton* RadioButton1; + QSpinBox* SpinBox3; + QSpinBox* SpinBox2; + QLabel* TextLabel4; + QPushButton* PushButton2; + QLineEdit* LineEdit2; + QLabel* TextLabel1; + +protected: + QGridLayout* DlgRef_2Sel3Spin2Rb_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QSpacerItem* Spacer5; + QGridLayout* Layout2; + +}; + +#endif // DLGREF_2SEL3SPIN2RB_QTD_H diff --git a/src/DlgRef/Makefile.in b/src/DlgRef/Makefile.in index 0c25761d9..1bda3ef87 100644 --- a/src/DlgRef/Makefile.in +++ b/src/DlgRef/Makefile.in @@ -77,6 +77,8 @@ LIB_SRC = DlgRef_Skeleton_QTD.cxx \ DlgRef_2Sel1Spin.cxx \ DlgRef_2Sel2Spin.cxx \ DlgRef_2Sel3Spin.cxx \ + DlgRef_2Sel3Spin2Rb_QTD.cxx \ + DlgRef_2Sel3Spin2Rb.cxx \ DlgRef_1Sel1Spin1Check.cxx \ DlgRef_2Sel1Spin2Check.cxx \ DlgRef_2Sel2Spin1Check.cxx \ @@ -108,6 +110,8 @@ LIB_MOC = \ DlgRef_1Sel5Spin_QTD.h \ DlgRef_2Sel1Spin_QTD.h \ DlgRef_2Sel2Spin_QTD.h \ + DlgRef_2Sel3Spin2Rb_QTD.h \ + DlgRef_2Sel3Spin2Rb.h \ DlgRef_2Sel3Spin_QTD.h \ DlgRef_1Sel1Spin1Check_QTD.h \ DlgRef_2Sel1Spin2Check_QTD.h \ diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel3Spin2Rb_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel3Spin2Rb_QTD.ui new file mode 100644 index 000000000..ca4821cc0 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_2Sel3Spin2Rb_QTD.ui @@ -0,0 +1,279 @@ + +DlgRef_2Sel3Spin2Rb_QTD + + + DlgRef_2Sel3Spin2Rb_QTD + + + + 0 + 0 + 439 + 340 + + + + DlgRef_2Sel3Spin2Rb_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + LineEdit1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel5 + + + + 0 + 0 + 0 + 0 + + + + TL5 + + + + + RadioButton2 + + + + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + RadioButton1 + + + + + + + + SpinBox3 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 207 + + + + + + LineEdit2 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + + + + + + RadioButton_Clicked() + + + diff --git a/src/DlgRef/UIFiles/ui_to_cxx b/src/DlgRef/UIFiles/ui_to_cxx index bd1f907c1..6165851a8 100755 --- a/src/DlgRef/UIFiles/ui_to_cxx +++ b/src/DlgRef/UIFiles/ui_to_cxx @@ -102,5 +102,8 @@ #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_2Sel3Spin2Rb_QTD.h DlgRef_2Sel3Spin2Rb_QTD.ui +uic -o DlgRef_2Sel3Spin2Rb_QTD.cxx -impl DlgRef_2Sel3Spin2Rb_QTD.h DlgRef_2Sel3Spin2Rb_QTD.ui \ No newline at end of file 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/GEOMContext/GEOM_icons.po b/src/GEOMContext/GEOM_icons.po index 82eaeadd2..2af178b9c 100644 --- a/src/GEOMContext/GEOM_icons.po +++ b/src/GEOMContext/GEOM_icons.po @@ -129,6 +129,11 @@ msgstr "linepointvector.png" msgid "ICON_DLG_CIRCLE_PV" msgstr "circlepointvector.png" +#CircleDlg +msgid "ICON_DLG_CIRCLE_C2P" +msgstr "circlecenter2pnts.png" + + #VectorDlg msgid "ICON_DLG_VECTOR_2P" msgstr "vector2points.png" diff --git a/src/GEOMContext/GEOM_msg_en.po b/src/GEOMContext/GEOM_msg_en.po index 7dc8d22ea..9d956d722 100644 --- a/src/GEOMContext/GEOM_msg_en.po +++ b/src/GEOMContext/GEOM_msg_en.po @@ -322,6 +322,18 @@ msgstr "Center" msgid "GEOM_RADIUS" msgstr "Radius :" +#Radius +msgid "GEOM_CONSTANT_RADIUS" +msgstr "Radius :" + +#Radius +msgid "GEOM_R1" +msgstr "R1 :" + +#Radius +msgid "GEOM_R2" +msgstr "R2 :" + #Radius i msgid "GEOM_RADIUS_I" msgstr "Radius %1 :" diff --git a/src/GEOMGUI/GEOM_images.po b/src/GEOMGUI/GEOM_images.po index e555f35ef..f968ecac8 100644 --- a/src/GEOMGUI/GEOM_images.po +++ b/src/GEOMGUI/GEOM_images.po @@ -133,6 +133,10 @@ msgstr "linepointvector.png" msgid "ICON_DLG_CIRCLE_PV" msgstr "circlepointvector.png" +#CircleDlg +msgid "ICON_DLG_CIRCLE_C2P" +msgstr "circlecenter2pnts.png" + #VectorDlg msgid "ICON_DLG_VECTOR_2P" msgstr "vector2points.png" @@ -370,6 +374,11 @@ msgstr "filletedge.png" msgid "ICON_DLG_CHAMFER_EDGE" msgstr "chamferedge.png" +#ChamferDlg +msgid "ICON_DLG_CHAMFER_EDGE_FROM_FACE" +msgstr "chamferedgefromface.png" + + #FilletDlg msgid "ICON_DLG_FILLET_FACE" msgstr "filletface.png" diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index 6489e4de0..958384b10 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -313,6 +313,18 @@ msgstr "Center" msgid "GEOM_RADIUS" msgstr "Radius :" +#Radius +msgid "GEOM_CONSTANT_RADIUS" +msgstr "Radius :" + +#Radius +msgid "GEOM_R1" +msgstr "R1 :" + +#Radius +msgid "GEOM_R2" +msgstr "R2 :" + #Radius i msgid "GEOM_RADIUS_I" msgstr "Radius %1 :" @@ -782,6 +794,10 @@ msgstr "D1 :" msgid "GEOM_D2" msgstr "D2 :" +#D +msgid "GEOM_D" +msgstr "D :" + # #============================================================================== # @@ -826,6 +842,14 @@ msgstr "Chamfer On Whole Shape" msgid "GEOM_CHAMFER_EDGES" msgstr "Chamfer On Edges From Shape" +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_EDGE" +msgstr "Chamfer On Selected Edges" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "SELECTED_EDGE" +msgstr "Selected Edges" + #: GeometryGUI_ChamferDlg.cxx:58 msgid "GEOM_CHAMFER_FACES" msgstr "Chamfer On Faces From Shape" @@ -1485,6 +1509,9 @@ msgstr "Chamfer can't be computed with %1 and %2" msgid "GEOM_3_POINTS" msgstr "3 points" +msgid "GEOM_CENTER_2POINTS" +msgstr "Center and two points" + msgid "GEOM_POINT1" msgstr "Point 1" @@ -2857,13 +2884,13 @@ msgid "STB_ERASE_ALL" msgstr "Erase all" msgid "TOP_DISPLAY" -msgstr "Display" +msgstr "Show" msgid "MEN_DISPLAY" -msgstr "Display" +msgstr "Show" msgid "STB_DISPLAY" -msgstr "Display" +msgstr "Show object(s)" msgid "TOP_DISPLAY_ONLY" msgstr "Display only" @@ -2875,13 +2902,13 @@ msgid "STB_DISPLAY_ONLY" msgstr "Display only" msgid "TOP_ERASE" -msgstr "Erase" +msgstr "Hide" msgid "MEN_ERASE" -msgstr "Erase" +msgstr "Hide" msgid "STB_ERASE" -msgstr "Erase" +msgstr "Hide object(s)" msgid "TOP_POP_RENAME" msgstr "Rename" diff --git a/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx b/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx index 57cc91748..61a812b55 100644 --- a/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx @@ -132,37 +132,50 @@ Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const M.FindFromIndex(i).Extent() == 2) fill.Add(aD, E, F); } - } else if (aType == CHAMFER_SHAPE_EDGE) { + }else if (aType == CHAMFER_SHAPE_EDGE || aType == CHAMFER_SHAPE_EDGE_AD) { // chamfer on edges, common to two faces, with D1 on the first face - double aD1 = aCI.GetD1(); - double aD2 = aCI.GetD2(); + TopoDS_Shape aFace1, aFace2; if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace1(), aFace1) && - GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace2(), aFace2)) { - TopoDS_Face F = TopoDS::Face(aFace1); - - // fill map of edges of the second face - TopTools_MapOfShape aMap; - TopExp_Explorer Exp2 (aFace2, TopAbs_EDGE); - for (; Exp2.More(); Exp2.Next()) { - aMap.Add(Exp2.Current()); + GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace2(), aFace2)) + { + TopoDS_Face F = TopoDS::Face(aFace1); + + // fill map of edges of the second face + TopTools_MapOfShape aMap; + TopExp_Explorer Exp2 (aFace2, TopAbs_EDGE); + for (; Exp2.More(); Exp2.Next()) { + aMap.Add(Exp2.Current()); + } + + // find edges of the first face, common with the second face + TopExp_Explorer Exp (aFace1, TopAbs_EDGE); + for (; Exp.More(); Exp.Next()) { + if (aMap.Contains(Exp.Current())) { + TopoDS_Edge E = TopoDS::Edge(Exp.Current()); + if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E)) + { + if ( aType == CHAMFER_SHAPE_EDGE ) + { + double aD1 = aCI.GetD1(); + double aD2 = aCI.GetD2(); + fill.Add(aD1, aD2, E, F); + } + else + { + double aD = aCI.GetD(); + double anAngle = aCI.GetAngle(); + fill.AddDA(aD, anAngle, E, F); + } + } + } + } } - - // find edges of the first face, common with the second face - TopExp_Explorer Exp (aFace1, TopAbs_EDGE); - for (; Exp.More(); Exp.Next()) { - if (aMap.Contains(Exp.Current())) { - TopoDS_Edge E = TopoDS::Edge(Exp.Current()); - if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E)) - fill.Add(aD1, aD2, E, F); - } - } - } - } else if (aType == CHAMFER_SHAPE_FACES) { + } + else if (aType == CHAMFER_SHAPE_FACES || aType == CHAMFER_SHAPE_FACES_AD) { // chamfer on all edges of the selected faces, with D1 on the selected face // (on first selected face, if the edge belongs to two selected faces) - double aD1 = aCI.GetD1(); - double aD2 = aCI.GetD2(); + int aLen = aCI.GetLength(); int ind = 1; TopTools_MapOfShape aMap; @@ -171,22 +184,67 @@ Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const for (; ind <= aLen; ind++) { TopoDS_Shape aShapeFace; - if (GEOMImpl_ILocalOperations::GetSubShape - (aShapeBase, aCI.GetFace(ind), aShapeFace)) { - TopoDS_Face F = TopoDS::Face(aShapeFace); - TopExp_Explorer Exp (F, TopAbs_EDGE); - for (; Exp.More(); Exp.Next()) { - if (!aMap.Contains(Exp.Current())) { - TopoDS_Edge E = TopoDS::Edge(Exp.Current()); - if (!BRepTools::IsReallyClosed(E, F) && - !BRep_Tool::Degenerated(E) && - M.FindFromKey(E).Extent() == 2) - fill.Add(aD1, aD2, E, F); - } - } - } + if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace(ind), aShapeFace)) + { + TopoDS_Face F = TopoDS::Face(aShapeFace); + TopExp_Explorer Exp (F, TopAbs_EDGE); + for (; Exp.More(); Exp.Next()) { + if (!aMap.Contains(Exp.Current())) + { + TopoDS_Edge E = TopoDS::Edge(Exp.Current()); + if (!BRepTools::IsReallyClosed(E, F) && + !BRep_Tool::Degenerated(E) && + M.FindFromKey(E).Extent() == 2) + if (aType == CHAMFER_SHAPE_FACES) + { + double aD1 = aCI.GetD1(); + double aD2 = aCI.GetD2(); + fill.Add(aD1, aD2, E, F); + } + else + { + double aD = aCI.GetD(); + double anAngle = aCI.GetAngle(); + fill.AddDA(aD, anAngle, E, F); + } + } + } + } } - } else { + } +else if (aType == CHAMFER_SHAPE_EDGES || aType == CHAMFER_SHAPE_EDGES_AD) + { + // chamfer on selected edges with lenght param D1 & D2. + + int aLen = aCI.GetLength(); + int ind = 1; + TopTools_MapOfShape aMap; + TopTools_IndexedDataMapOfShapeListOfShape M; + GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M); + for (; ind <= aLen; ind++) + { + TopoDS_Shape aShapeEdge; + if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetEdge(ind), aShapeEdge)) + { + TopoDS_Edge E = TopoDS::Edge(aShapeEdge); + const TopTools_ListOfShape& aFacesList = M.FindFromKey(E); + TopoDS_Face F = TopoDS::Face( aFacesList.First() ); + if (aType == CHAMFER_SHAPE_EDGES) + { + double aD1 = aCI.GetD1(); + double aD2 = aCI.GetD2(); + fill.Add(aD1, aD2, E, F); + } + else + { + double aD = aCI.GetD(); + double anAngle = aCI.GetAngle(); + fill.AddDA(aD, anAngle, E, F); + } + } + } + } + else { } fill.Build(); diff --git a/src/GEOMImpl/GEOMImpl_CircleDriver.cxx b/src/GEOMImpl/GEOMImpl_CircleDriver.cxx index 7d3343366..79184422b 100644 --- a/src/GEOMImpl/GEOMImpl_CircleDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_CircleDriver.cxx @@ -95,6 +95,48 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const } } } + else if (aType == CIRCLE_CENTER_TWO_PNT) { + Handle(GEOM_Function) aRefPoint1 = aCI.GetPoint1(); + Handle(GEOM_Function) aRefPoint2 = aCI.GetPoint2(); + Handle(GEOM_Function) aRefPoint3 = aCI.GetPoint3(); + TopoDS_Shape aShapePnt1 = aRefPoint1->GetValue(); + TopoDS_Shape aShapePnt2 = aRefPoint2->GetValue(); + TopoDS_Shape aShapePnt3 = aRefPoint3->GetValue(); + if (aShapePnt1.ShapeType() == TopAbs_VERTEX && aShapePnt2.ShapeType() == TopAbs_VERTEX && + aShapePnt3.ShapeType() == TopAbs_VERTEX) + { + gp_Pnt aP1 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt1)); + gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt2)); + gp_Pnt aP3 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt3)); + + if (aP1.Distance(aP2) < gp::Resolution() || + aP1.Distance(aP3) < gp::Resolution() || + aP2.Distance(aP3) < gp::Resolution()) + Standard_ConstructionError::Raise("Circle creation aborted: coincident points given"); + if (gp_Vec(aP1, aP2).IsParallel(gp_Vec(aP1, aP3), Precision::Angular())) + Standard_ConstructionError::Raise("Circle creation aborted: points lay on one line"); + double x, y, z, x1, y1, z1, x2, y2, z2, dx, dy, dz, dx2, dy2, dz2, dx3, dy3, dz3, aRadius; + //Calculations for Radius + x = aP1.X(); y = aP1.Y(); z = aP1.Z(); + x1 = aP2.X(); y1 = aP2.Y(); z1 = aP2.Z(); + dx = x1 - x; + dy = y1 - y; + dz = z1 - z; + aRadius = sqrt(dx*dx + dy*dy + dz*dz); + //Calculations for Plane Vector + x2 = aP3.X(); y2 = aP3.Y(); z2 = aP3.Z(); + dx2 = x2 - x; dy2 = y2 - y; dz2 = z2 - z; + dx3 = ((dy*dz2) - (dy2*dz))/100; + dy3 = ((dx2*dz) - (dx*dz2))/100; + dz3 = ((dx*dy2) - (dx2*dy))/100; + //Make Plane Vector + gp_Dir aDir ( dx3, dy3, dz3 ); + //Make Circle + gp_Ax2 anAxes (aP1, aDir); + gp_Circ aCirc (anAxes, aRadius); + aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge(); + } + } else if (aType == CIRCLE_THREE_PNT) { Handle(GEOM_Function) aRefPoint1 = aCI.GetPoint1(); Handle(GEOM_Function) aRefPoint2 = aCI.GetPoint2(); @@ -116,9 +158,9 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const Standard_ConstructionError::Raise("Circle creation aborted: points lay on one line"); Handle(Geom_Circle) aCirc = GC_MakeCircle(aP1, aP2, aP3).Value(); aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge(); - } + } } - else { + else { } if (aShape.IsNull()) return 0; diff --git a/src/GEOMImpl/GEOMImpl_FilletDriver.cxx b/src/GEOMImpl/GEOMImpl_FilletDriver.cxx index 3114733df..e662d4cac 100644 --- a/src/GEOMImpl/GEOMImpl_FilletDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FilletDriver.cxx @@ -83,17 +83,17 @@ Standard_Integer GEOMImpl_FilletDriver::Execute(TFunction_Logbook& log) const TopoDS_Edge E = TopoDS::Edge(Exp.Current()); fill.Add(E); } - } else if (aType == FILLET_SHAPE_EDGES) { + } else if (aType == FILLET_SHAPE_EDGES || aType == FILLET_SHAPE_EDGES_2R) { int aLen = aCI.GetLength(); int ind = 1; for (; ind <= aLen; ind++) { TopoDS_Shape aShapeEdge; if (GEOMImpl_ILocalOperations::GetSubShape (aShapeBase, aCI.GetEdge(ind), aShapeEdge)) { - fill.Add(TopoDS::Edge(aShapeEdge)); + fill.Add(TopoDS::Edge(aShapeEdge)); } } - } else if (aType == FILLET_SHAPE_FACES) { + } else if (aType == FILLET_SHAPE_FACES || aType == FILLET_SHAPE_FACES_2R) { int aLen = aCI.GetLength(); int ind = 1; for (; ind <= aLen; ind++) { @@ -108,10 +108,15 @@ Standard_Integer GEOMImpl_FilletDriver::Execute(TFunction_Logbook& log) const } } else { } + if (aType == FILLET_SHAPE_FACES || aType == FILLET_SHAPE_EDGES || aType == FILLET_SHAPE_ALL) + for (int i = 1; i <= fill.NbContours(); i++) + fill.SetRadius(aCI.GetR(), i, 1); + else if (aType == FILLET_SHAPE_FACES_2R || aType == FILLET_SHAPE_EDGES_2R) + for (int i = 1; i <= fill.NbContours(); i++) + { + fill.SetRadius(aCI.GetR1(), aCI.GetR2(), i, 1); + } - for (int i = 1; i <= fill.NbContours(); i++) { - fill.SetRadius(aCI.GetR(), i, 1); - } fill.Build(); if (!fill.IsDone()) { StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius"); diff --git a/src/GEOMImpl/GEOMImpl_IChamfer.hxx b/src/GEOMImpl/GEOMImpl_IChamfer.hxx index 6c12fd184..17f7e5afc 100644 --- a/src/GEOMImpl/GEOMImpl_IChamfer.hxx +++ b/src/GEOMImpl/GEOMImpl_IChamfer.hxx @@ -22,11 +22,12 @@ #include "GEOM_Function.hxx" -#define CHAM_ARG_SH 1 -#define CHAM_ARG_D1 2 -#define CHAM_ARG_D2 3 -#define CHAM_ARG_LENG 4 -#define CHAM_ARG_LAST 4 +#define CHAM_ARG_SH 1 +#define CHAM_ARG_D1 2 +#define CHAM_ARG_D2 3 +#define CHAM_ARG_ANGLE 3 +#define CHAM_ARG_LENG 4 +#define CHAM_ARG_LAST 4 class GEOMImpl_IChamfer { @@ -41,10 +42,12 @@ class GEOMImpl_IChamfer void SetD (double theD) { _func->SetReal(CHAM_ARG_D1, theD); } void SetD1(double theD) { _func->SetReal(CHAM_ARG_D1, theD); } void SetD2(double theD) { _func->SetReal(CHAM_ARG_D2, theD); } + void SetAngle(double theAngle) { _func->SetReal(CHAM_ARG_ANGLE, theAngle); } double GetD () { return _func->GetReal(CHAM_ARG_D1); } double GetD1() { return _func->GetReal(CHAM_ARG_D1); } double GetD2() { return _func->GetReal(CHAM_ARG_D2); } + double GetAngle() { return _func->GetReal(CHAM_ARG_ANGLE); } void SetLength(int theLen) { _func->SetInteger(CHAM_ARG_LENG, theLen); } @@ -56,10 +59,13 @@ class GEOMImpl_IChamfer { _func->SetInteger(CHAM_ARG_LAST + 1, theFace); } void SetFace2(int theFace) { _func->SetInteger(CHAM_ARG_LAST + 2, theFace); } + void SetEdge(int theInd, int theEdge) + { _func->SetInteger(CHAM_ARG_LAST + theInd, theEdge); } int GetFace(int theInd) { return _func->GetInteger(CHAM_ARG_LAST + theInd); } int GetFace1() { return _func->GetInteger(CHAM_ARG_LAST + 1); } int GetFace2() { return _func->GetInteger(CHAM_ARG_LAST + 2); } + int GetEdge(int theInd) { return _func->GetInteger(CHAM_ARG_LAST + theInd); } private: diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index 3643e6f39..d6628ca43 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -196,6 +196,66 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_ return aCircle; } +//============================================================================= +/*! + * MakeCircleCenter2Pnt + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Circle object + Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE); + + //Add a new Circle function for creation a circle relatively to center and 2 points + Handle(GEOM_Function) aFunction = + aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_CENTER_TWO_PNT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL; + + GEOMImpl_ICircle aCI (aFunction); + + Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction(); + + if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL; + + aCI.SetPoint1(aRefPnt1); + aCI.SetPoint2(aRefPnt2); + aCI.SetPoint3(aRefPnt3); + + //Compute the Circle value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Circle 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) << aCircle << " = geompy.MakeCircleCenter2Pnt(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")"; + + SetErrorCode(OK); + return aCircle; +} + //============================================================================= /*! * MakeCirclePntVecR diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx index b0aa3cd39..34bb01148 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx @@ -41,6 +41,9 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeCircleThreePnt (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2, Handle(GEOM_Object) thePnt3); + Standard_EXPORT Handle(GEOM_Object) MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3); Standard_EXPORT Handle(GEOM_Object) MakeCirclePntVecR (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR); diff --git a/src/GEOMImpl/GEOMImpl_IFillet.hxx b/src/GEOMImpl/GEOMImpl_IFillet.hxx index 703c0f74f..f9deb9b86 100644 --- a/src/GEOMImpl/GEOMImpl_IFillet.hxx +++ b/src/GEOMImpl/GEOMImpl_IFillet.hxx @@ -24,6 +24,8 @@ #define FILLET_ARG_SH 1 #define FILLET_ARG_R 2 +#define FILLET_ARG_R1 4 +#define FILLET_ARG_R2 5 #define FILLET_ARG_LENG 3 #define FILLET_ARG_LAST 3 @@ -38,8 +40,12 @@ class GEOMImpl_IFillet Handle(GEOM_Function) GetShape() { return _func->GetReference(FILLET_ARG_SH); } void SetR(double theR) { _func->SetReal(FILLET_ARG_R, theR); } + void SetR1(double theR1) { _func->SetReal(FILLET_ARG_R1, theR1); } + void SetR2(double theR2) { _func->SetReal(FILLET_ARG_R2, theR2); } double GetR() { return _func->GetReal(FILLET_ARG_R); } + double GetR1() { return _func->GetReal(FILLET_ARG_R1); } + double GetR2() { return _func->GetReal(FILLET_ARG_R2); } void SetLength(int theLen) { _func->SetInteger(FILLET_ARG_LENG, theLen); } diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx index 63e0126b0..3dcf6e9af 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx @@ -198,6 +198,77 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges return aFillet; } +//============================================================================= +/*! + * MakeFilletEdges R1 R2 + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2 + (Handle(GEOM_Object) theShape, double theR1, double theR2, list theEdges) +{ + SetErrorCode(KO); + + //Add a new Fillet object + Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET); + + //Add a new Fillet function + Handle(GEOM_Function) aFunction = + aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL; + + GEOMImpl_IFillet aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetR1(theR1); + aCI.SetR2(theR2); + int aLen = theEdges.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theEdges.begin(); + for (; it != theEdges.end(); it++, ind++) { + aCI.SetEdge(ind, (*it)); + } + + //Compute the Fillet value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Fillet 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 pd (aFunction); + pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape + << ", " << theR1 << ", " < theFaces) +{ + SetErrorCode(KO); + + //Add a new Fillet object + Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET); + + //Add a new Fillet function + Handle(GEOM_Function) aFunction = + aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL; + + GEOMImpl_IFillet aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetR1(theR1); + aCI.SetR2(theR2); + int aLen = theFaces.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theFaces.begin(); + for (; it != theFaces.end(); it++, ind++) { + aCI.SetFace(ind, (*it)); + } + + //Compute the Fillet value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Fillet 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 pd (aFunction); + pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape + << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], ["; + + it = theFaces.begin(); + pd << (*it++); + while (it != theFaces.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aFillet; +} + //============================================================================= /*! * MakeChamferAll @@ -377,6 +518,64 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge return aChamfer; } +//============================================================================= +/*! + * MakeChamferEdgeAD + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD + (Handle(GEOM_Object) theShape, double theD, double theAngle, + int theFace1, int theFace2) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL; + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetD(theD); + aCI.SetAngle(theAngle); + aCI.SetFace1(theFace1); + aCI.SetFace2(theFace2); + + //Compute the Chamfer value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer 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) << aChamfer + << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD + << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")"; + cout << "ANGLE = " << theAngle << endl; + SetErrorCode(OK); + return aChamfer; +} + //============================================================================= /*! * MakeChamferFaces @@ -448,6 +647,221 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces return aChamfer; } +//============================================================================= +/*! + * MakeChamferFacesAD + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD + (Handle(GEOM_Object) theShape, double theD, double theAngle, + list theFaces) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL; + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetD(theD); + aCI.SetAngle(theAngle); + int aLen = theFaces.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theFaces.begin(); + for (; it != theFaces.end(); it++, ind++) { + aCI.SetFace(ind, (*it)); + } + + //Compute the Chamfer value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer 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 pd (aFunction); + pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape + << ", " << theD << ", " << theAngle << ", ["; + + it = theFaces.begin(); + pd << (*it++); + while (it != theFaces.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aChamfer; +} + +//============================================================================= +/*! + * MakeChamferEdges + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges + (Handle(GEOM_Object) theShape, double theD1, double theD2, + list theEdges) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES); + if (aFunction.IsNull()) { return NULL; cout << "Edges Function is NULL!!!" << endl; } + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) + { return NULL; cout << "Chamfer Driver is NULL!!!" << endl; } + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) { return NULL; cout << "Shape is NULL!!!" << endl; } + + aCI.SetShape(aRefShape); + aCI.SetD1(theD1); + aCI.SetD2(theD2); + int aLen = theEdges.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theEdges.begin(); + for (; it != theEdges.end(); it++, ind++) { + aCI.SetEdge(ind, (*it)); + } + + //Compute the Chamfer value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer 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 pd (aFunction); + pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape + << ", " << theD1 << ", " << theD2 << ", ["; + + it = theEdges.begin(); + pd << (*it++); + while (it != theEdges.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aChamfer; +} + +//============================================================================= +/*! + * MakeChamferEdgesAD + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD + (Handle(GEOM_Object) theShape, double theD, double theAngle, + list theEdges) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD); + if (aFunction.IsNull()) { return NULL; cout << "Edges Function is NULL!!!" << endl; } + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) + { return NULL; cout << "Chamfer Driver is NULL!!!" << endl; } + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) { return NULL; cout << "Shape is NULL!!!" << endl; } + + aCI.SetShape(aRefShape); + aCI.SetD(theD); + aCI.SetAngle(theAngle); + int aLen = theEdges.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theEdges.begin(); + for (; it != theEdges.end(); it++, ind++) { + aCI.SetEdge(ind, (*it)); + } + + //Compute the Chamfer value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer 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 pd (aFunction); + pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape + << ", " << theD << ", " << theAngle << ", ["; + + it = theEdges.begin(); + pd << (*it++); + while (it != theEdges.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aChamfer; +} + //============================================================================= /*! * Archimede diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx index a079bc569..479d1dc8b 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx @@ -37,17 +37,34 @@ class GEOMImpl_ILocalOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeFilletAll (Handle(GEOM_Object) theShape, double theR); Standard_EXPORT Handle(GEOM_Object) MakeFilletEdges (Handle(GEOM_Object) theShape, double theR, list theEdges); + Standard_EXPORT Handle(GEOM_Object) MakeFilletEdgesR1R2 (Handle(GEOM_Object) theShape, + double theR1, double theR2, + list theEdges); Standard_EXPORT Handle(GEOM_Object) MakeFilletFaces (Handle(GEOM_Object) theShape, double theR, list theFaces); + Standard_EXPORT Handle(GEOM_Object) MakeFilletFacesR1R2 (Handle(GEOM_Object) theShape, + double theR1, double theR2, + list theFaces); Standard_EXPORT Handle(GEOM_Object) MakeChamferAll (Handle(GEOM_Object) theShape, double theD); Standard_EXPORT Handle(GEOM_Object) MakeChamferEdge (Handle(GEOM_Object) theShape, double theD1, double theD2, int theFace1, int theFace2); + Standard_EXPORT Handle(GEOM_Object) MakeChamferEdgeAD (Handle(GEOM_Object) theShape, + double theD, double theAngle, + int theFace1, int theFace2); Standard_EXPORT Handle(GEOM_Object) MakeChamferFaces (Handle(GEOM_Object) theShape, double theD1, double theD2, list theFaces); - + Standard_EXPORT Handle(GEOM_Object) MakeChamferFacesAD (Handle(GEOM_Object) theShape, + double theD, double theAngle, + list theFaces); + Standard_EXPORT Handle(GEOM_Object) MakeChamferEdges (Handle(GEOM_Object) theShape, + double theD1, double theD2, + list theEdges); + Standard_EXPORT Handle(GEOM_Object) MakeChamferEdgesAD (Handle(GEOM_Object) theShape, + double theD, double theAngle, + list theEdges); Standard_EXPORT Handle(GEOM_Object) MakeArchimede (Handle(GEOM_Object) theShape, double theWeight, double theWaterDensity, double theMeshingDeflection); diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index a68294174..23b93efd5 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -181,6 +181,7 @@ #define CIRCLE_THREE_PNT 1 #define CIRCLE_PNT_VEC_R 2 +#define CIRCLE_CENTER_TWO_PNT 3 #define SPLINE_BEZIER 1 #define SPLINE_INTERPOLATION 2 @@ -190,13 +191,19 @@ #define CIRC_ARC_THREE_PNT 1 #define CIRC_ARC_CENTER 2 -#define FILLET_SHAPE_ALL 1 -#define FILLET_SHAPE_EDGES 2 -#define FILLET_SHAPE_FACES 3 - -#define CHAMFER_SHAPE_ALL 1 -#define CHAMFER_SHAPE_EDGE 2 -#define CHAMFER_SHAPE_FACES 3 +#define FILLET_SHAPE_ALL 1 +#define FILLET_SHAPE_EDGES 2 +#define FILLET_SHAPE_FACES 3 +#define FILLET_SHAPE_EDGES_2R 4 +#define FILLET_SHAPE_FACES_2R 5 + +#define CHAMFER_SHAPE_ALL 1 +#define CHAMFER_SHAPE_EDGE 2 +#define CHAMFER_SHAPE_FACES 3 +#define CHAMFER_SHAPE_EDGES 4 +#define CHAMFER_SHAPE_EDGE_AD 5 +#define CHAMFER_SHAPE_FACES_AD 6 +#define CHAMFER_SHAPE_EDGES_AD 7 #define WIRE_EDGES 1 #define FACE_WIRE 2 diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.cc b/src/GEOM_I/GEOM_ICurvesOperations_i.cc index ea89b3709..3a15afb1b 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.cc +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.cc @@ -119,6 +119,40 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleThreePnt return GetObject(anObject); } +//============================================================================= +/*! + * MakeCircleCenter2Pnt + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleCenter2Pnt + (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject + (thePnt3->GetStudyID(), thePnt3->GetEntry()); + + if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn(); + + // Make Circle + Handle(GEOM_Object) anObject = GetOperations()->MakeCircleCenter2Pnt(aPnt1, aPnt2, aPnt3); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeEllipse diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.hh b/src/GEOM_I/GEOM_ICurvesOperations_i.hh index 300f6ae33..e536c537e 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.hh +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.hh @@ -47,6 +47,10 @@ class GEOM_ICurvesOperations_i : GEOM::GEOM_Object_ptr thePnt2, GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr MakeCircleCenter2Pnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr MakeEllipse (GEOM::GEOM_Object_ptr theCenter, GEOM::GEOM_Object_ptr theVector, double theRMajor, double theRMinor); diff --git a/src/GEOM_I/GEOM_ILocalOperations_i.cc b/src/GEOM_I/GEOM_ILocalOperations_i.cc index 5b2430e9f..a9ec1fc6d 100644 --- a/src/GEOM_I/GEOM_ILocalOperations_i.cc +++ b/src/GEOM_I/GEOM_ILocalOperations_i.cc @@ -114,6 +114,41 @@ GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges return GetObject(anObject); } +//============================================================================= +/*! + * MakeFilletEdges R1 R2 + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdgesR1R2 + (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1, + CORBA::Double theR2, const GEOM::ListOfLong& theEdges) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference edges + int ind = 0; + int aLen = theEdges.length(); + list anEdges; + for (; ind < aLen; ind++) { + anEdges.push_back(theEdges[ind]); + } + + //Create the Fillet + Handle(GEOM_Object) anObject = + GetOperations()->MakeFilletEdgesR1R2(aShapeRef, theR1, theR2, anEdges); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeFilletFaces @@ -149,6 +184,41 @@ GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces return GetObject(anObject); } +//============================================================================= +/*! + * MakeFilletFaces R1 R2 + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2 + (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1, + CORBA::Double theR2, const GEOM::ListOfLong& theFaces) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference faces + int ind = 0; + int aLen = theFaces.length(); + list aFaces; + for (; ind < aLen; ind++) { + aFaces.push_back(theFaces[ind]); + } + + //Create the Fillet + Handle(GEOM_Object) anObject = + GetOperations()->MakeFilletFacesR1R2(aShapeRef, theR1, theR2, aFaces); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeChamferAll @@ -203,6 +273,33 @@ GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge return GetObject(anObject); } +//============================================================================= +/*! + * MakeChamferEdgeAD + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgeAD + (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + CORBA::Long theFace1, CORBA::Long theFace2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Create the Chamfer + Handle(GEOM_Object) anObject = + GetOperations()->MakeChamferEdgeAD(aShapeRef, theD, theAngle, theFace1, theFace2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} //============================================================================= /*! @@ -239,6 +336,113 @@ GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces return GetObject(anObject); } +//============================================================================= +/*! + * MakeChamferFacesAD + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFacesAD + (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + const GEOM::ListOfLong& theFaces) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference faces + int ind = 0; + int aLen = theFaces.length(); + list aFaces; + for (; ind < aLen; ind++) { + aFaces.push_back(theFaces[ind]); + } + + //Create the Chamfer + Handle(GEOM_Object) anObject = + GetOperations()->MakeChamferFacesAD(aShapeRef, theD, theAngle, aFaces); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeChamferEdges + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdges + (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + const GEOM::ListOfLong& theEdges) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference edges + int ind = 0; + int aLen = theEdges.length(); + list aEdges; + for (; ind < aLen; ind++) { + aEdges.push_back(theEdges[ind]); + } + + //Create the Chamfer + Handle(GEOM_Object) anObject = + GetOperations()->MakeChamferEdges(aShapeRef, theD1, theD2, aEdges); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeChamferEdgesAD + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgesAD + (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + const GEOM::ListOfLong& theEdges) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference edges + int ind = 0; + int aLen = theEdges.length(); + list aEdges; + for (; ind < aLen; ind++) { + aEdges.push_back(theEdges[ind]); + } + + //Create the Chamfer + Handle(GEOM_Object) anObject = + GetOperations()->MakeChamferEdgesAD(aShapeRef, theD, theAngle, aEdges); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} //============================================================================= /*! diff --git a/src/GEOM_I/GEOM_ILocalOperations_i.hh b/src/GEOM_I/GEOM_ILocalOperations_i.hh index 709c75b12..61666721d 100644 --- a/src/GEOM_I/GEOM_ILocalOperations_i.hh +++ b/src/GEOM_I/GEOM_ILocalOperations_i.hh @@ -41,19 +41,49 @@ class GEOM_ILocalOperations_i : GEOM::GEOM_Object_ptr MakeFilletAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR); + GEOM::GEOM_Object_ptr MakeFilletEdges (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, const GEOM::ListOfLong& theEdges); + + GEOM::GEOM_Object_ptr MakeFilletEdgesR1R2 (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR1, + CORBA::Double theR2, + const GEOM::ListOfLong& theEdges); + GEOM::GEOM_Object_ptr MakeFilletFaces (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, const GEOM::ListOfLong& theFaces); + GEOM::GEOM_Object_ptr MakeFilletFacesR1R2 (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR1, + CORBA::Double theR2, + const GEOM::ListOfLong& theFaces); + GEOM::GEOM_Object_ptr MakeChamferAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD); + GEOM::GEOM_Object_ptr MakeChamferEdge (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD1, CORBA::Double theD2, CORBA::Long theFace1, CORBA::Long theFace2); + + GEOM::GEOM_Object_ptr MakeChamferEdgeAD (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + CORBA::Long theFace1, CORBA::Long theFace2); + GEOM::GEOM_Object_ptr MakeChamferFaces (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD1, CORBA::Double theD2, const GEOM::ListOfLong& theFaces); + GEOM::GEOM_Object_ptr MakeChamferFacesAD (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + const GEOM::ListOfLong& theFaces); + + GEOM::GEOM_Object_ptr MakeChamferEdges (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + const GEOM::ListOfLong& theEdges); + + GEOM::GEOM_Object_ptr MakeChamferEdgesAD (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + const GEOM::ListOfLong& theEdges); + GEOM::GEOM_Object_ptr MakeArchimede (GEOM::GEOM_Object_ptr theShape, CORBA::Double theWeight, CORBA::Double theWaterDensity, diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 1a4706b16..5694df6da 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -2183,6 +2183,20 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCircleThreePnt (GEOM::GEOM_Object_ptr t endService( " GEOM_Superv_i::MakeCircleThreePnt" ); return anObj; } +//============================================================================= +// MakeCircleCenter2Pnt: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCircleCenter2Pnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + beginService( " GEOM_Superv_i::MakeCircleCenter2Pnt" ); + MESSAGE("GEOM_Superv_i::MakeCircleCenter2Pnt"); + getCurvesOp(); + GEOM::GEOM_Object_ptr anObj = myCurvesOp->MakeCircleCenter2Pnt(thePnt1, thePnt2, thePnt3); + endService( " GEOM_Superv_i::MakeCircleCenter2Pnt" ); + return anObj; +} //============================================================================= // MakeEllipse: @@ -2339,6 +2353,28 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilletEdges (GEOM::GEOM_Object_ptr theS return NULL; } +//============================================================================= +// MakeFilletEdges R1 R2: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilletEdgesR1R2 (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR1, + CORBA::Double theR2, + GEOM::GEOM_List_ptr theEdges) +{ + beginService( " GEOM_Superv_i::MakeFilletEdgesR1R2" ); + MESSAGE("GEOM_Superv_i::MakeFilletEdgesR1R2"); + if (GEOM_List_i* aListImplE = + dynamic_cast*>(GetServant(theEdges, myPOA).in())) { + getLocalOp(); + GEOM::GEOM_Object_ptr anObj = myLocalOp->MakeFilletEdgesR1R2(theShape, theR1, + theR2, aListImplE->GetList()); + endService( " GEOM_Superv_i::MakeFilletEdgesR1R2" ); + return anObj; + } + endService( " GEOM_Superv_i::MakeFilletEdgesR1R2" ); + return NULL; +} + //============================================================================= // MakeFilletFaces: //============================================================================= @@ -2359,6 +2395,28 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilletFaces (GEOM::GEOM_Object_ptr theS return NULL; } +//============================================================================= +// MakeFilletFaces R1 R2: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilletFacesR1R2 (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR1, + CORBA::Double theR2, + GEOM::GEOM_List_ptr theFaces) +{ + beginService( " GEOM_Superv_i::MakeFilletFacesR1R2" ); + MESSAGE("GEOM_Superv_i::MakeFilletFacesR1R2"); + if (GEOM_List_i* aListImplF = + dynamic_cast*>(GetServant(theFaces, myPOA).in())) { + getLocalOp(); + GEOM::GEOM_Object_ptr anObj = myLocalOp->MakeFilletFacesR1R2(theShape, theR1, theR2, + aListImplF->GetList()); + endService( " GEOM_Superv_i::MakeFilletFacesR1R2" ); + return anObj; + } + endService( " GEOM_Superv_i::MakeFilletFacesR1R2" ); + return NULL; +} + //============================================================================= // MakeChamferAll: //============================================================================= @@ -2387,6 +2445,21 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeChamferEdge (GEOM::GEOM_Object_ptr theS return anObj; } +//============================================================================= +// MakeChamferEdgeAD: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeChamferEdgeAD (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + CORBA::Long theFace1, CORBA::Long theFace2) +{ + beginService( " GEOM_Superv_i::MakeChamferEdgeAD" ); + MESSAGE("GEOM_Superv_i::MakeChamferEdgeAD"); + getLocalOp(); + GEOM::GEOM_Object_ptr anObj = myLocalOp->MakeChamferEdgeAD(theShape, theD, theAngle, theFace1, theFace2); + endService( " GEOM_Superv_i::MakeChamferEdgeAD" ); + return anObj; +} + //============================================================================= // MakeChamferFaces: //============================================================================= @@ -2407,6 +2480,66 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeChamferFaces (GEOM::GEOM_Object_ptr the return NULL; } +//============================================================================= +// MakeChamferFacesAD: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeChamferFacesAD (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + GEOM::GEOM_List_ptr theFaces) +{ + beginService( " GEOM_Superv_i::MakeChamferFacesAD" ); + MESSAGE("GEOM_Superv_i::MakeChamferFacesAD"); + if (GEOM_List_i* aListImplF = + dynamic_cast*>(GetServant(theFaces, myPOA).in())) { + getLocalOp(); + GEOM::GEOM_Object_ptr anObj = myLocalOp->MakeChamferFacesAD(theShape, theD, theAngle, aListImplF->GetList()); + endService( " GEOM_Superv_i::MakeChamferFacesAD" ); + return anObj; + } + endService( " GEOM_Superv_i::MakeChamferFacesAD" ); + return NULL; +} + +//============================================================================= +// MakeChamferEdges: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeChamferEdges (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + GEOM::GEOM_List_ptr theEdges) +{ + beginService( " GEOM_Superv_i::MakeChamferEdges" ); + MESSAGE("GEOM_Superv_i::MakeChamferEdges"); + if (GEOM_List_i* aListImplF = + dynamic_cast*>(GetServant(theEdges, myPOA).in())) { + getLocalOp(); + GEOM::GEOM_Object_ptr anObj = myLocalOp->MakeChamferEdges(theShape, theD1, theD2, aListImplF->GetList()); + endService( " GEOM_Superv_i::MakeChamferEdges" ); + return anObj; + } + endService( " GEOM_Superv_i::MakeChamferEdges" ); + return NULL; +} + +//============================================================================= +// MakeChamferEdgesAD: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeChamferEdgesAD (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + GEOM::GEOM_List_ptr theEdges) +{ + beginService( " GEOM_Superv_i::MakeChamferEdgesAD" ); + MESSAGE("GEOM_Superv_i::MakeChamferEdgesAD"); + if (GEOM_List_i* aListImplF = + dynamic_cast*>(GetServant(theEdges, myPOA).in())) { + getLocalOp(); + GEOM::GEOM_Object_ptr anObj = myLocalOp->MakeChamferEdgesAD(theShape, theD, theAngle, aListImplF->GetList()); + endService( " GEOM_Superv_i::MakeChamferEdgesAD" ); + return anObj; + } + endService( " GEOM_Superv_i::MakeChamferEdgesAD" ); + return NULL; +} + //============================================================================= // MakeArchimede: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 01ed56829..da8451222 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -480,6 +480,9 @@ public: GEOM::GEOM_Object_ptr MakeCircleThreePnt (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr MakeCircleCenter2Pnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); GEOM::GEOM_Object_ptr MakeEllipse (GEOM::GEOM_Object_ptr theCenter, GEOM::GEOM_Object_ptr theVector, CORBA::Double theRMajor, CORBA::Double theRMinor); @@ -503,15 +506,31 @@ public: CORBA::Double theR); GEOM::GEOM_Object_ptr MakeFilletEdges (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, GEOM::GEOM_List_ptr theEdges); + GEOM::GEOM_Object_ptr MakeFilletEdgesR1R2 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1, + CORBA::Double theR2, GEOM::GEOM_List_ptr theEdges); GEOM::GEOM_Object_ptr MakeFilletFaces (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, GEOM::GEOM_List_ptr theFaces); + GEOM::GEOM_Object_ptr MakeFilletFacesR1R2 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1, + CORBA::Double theR2, GEOM::GEOM_List_ptr theFaces); GEOM::GEOM_Object_ptr MakeChamferAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD); GEOM::GEOM_Object_ptr MakeChamferEdge (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD1, CORBA::Double theD2, CORBA::Long theFace1, CORBA::Long theFace2); + GEOM::GEOM_Object_ptr MakeChamferEdgeAD (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + CORBA::Long theFace1, CORBA::Long theFace2); GEOM::GEOM_Object_ptr MakeChamferFaces (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD1, CORBA::Double theD2, GEOM::GEOM_List_ptr theFaces); + GEOM::GEOM_Object_ptr MakeChamferFacesAD (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + GEOM::GEOM_List_ptr theFaces); + GEOM::GEOM_Object_ptr MakeChamferEdges (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + GEOM::GEOM_List_ptr theEdges); + GEOM::GEOM_Object_ptr MakeChamferEdgesAD (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD, CORBA::Double theAngle, + GEOM::GEOM_List_ptr theEdges); GEOM::GEOM_Object_ptr MakeArchimede (GEOM::GEOM_Object_ptr theShape, CORBA::Double theWeight, CORBA::Double theWaterDensity, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index a044befec..58cfebe8f 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -87,6 +87,7 @@ def TestAll (geompy, math): Arc2 = geompy.MakeArcCenter(py, pz, px,0) #(3 GEOM_Object_ptr,Boolean)->GEOM_Object_ptr Circle = geompy.MakeCircle(p0, vz, radius1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr Circle1 = geompy.MakeCircleThreePnt(p0, pxyz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr + Circle2 = geompy.MakeCircleCenter2Pnt(p0, pxyz, py) #(3 GEOM_Object_ptr)->GEOM_Object_ptr Ellipse = geompy.MakeEllipse(p0, vy, radius2, radius1) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr Polyline = geompy.MakePolyline([p0, pz, py, p200]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr Bezier = geompy.MakeBezier([p0, pz, p200, px]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr @@ -195,10 +196,16 @@ def TestAll (geompy, math): #Local operations Fillet = geompy.MakeFillet (Prism, radius, ShapeTypeEdge, IDlist_e) #(GEOM_Object_ptr, Double, Short, ListOfLong)->GEOM_Object_ptr + Fillet2 = geompy.MakeFilletR1R2 (Prism, radius1, radius2, ShapeTypeEdge, + IDlist_e) #(GEOM_Object_ptr, Double, Double, Short, ListOfLong)->GEOM_Object_ptr Chamfer = geompy.MakeChamferEdge(Prism, d1, d2, f_ind_1, f_ind_2) #(GEOM_Object_ptr, 2 Doubles, 2 Long)->GEOM_Object_ptr Chamfer2 = geompy.MakeChamferFaces(Prism, d1, d2, 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, d, angle, + IDlist_f) #(GEOM_Object_ptr, 2 Doubles, ListOfLong)->GEOM_Object_ptr #Create Patterns MultiTrans1D = geompy.MakeMultiTranslation1D(Fillet, vz, step1, nbtimes1) @@ -244,6 +251,7 @@ def TestAll (geompy, math): id_Arc = geompy.addToStudy(Arc, "Arc") id_Circle = geompy.addToStudy(Circle, "Circle") id_Circle1 = geompy.addToStudy(Circle1, "Circle by 3 points") + id_Circle2 = geompy.addToStudy(Circle2, "Circle by center and 2 points") id_Ellipse = geompy.addToStudy(Ellipse, "Ellipse") id_Polyline = geompy.addToStudy(Polyline, "Polyline") id_Bezier = geompy.addToStudy(Bezier, "Bezier") @@ -304,8 +312,11 @@ def TestAll (geompy, math): id_Orientation = geompy.addToStudy(Orientation, "Orientation") id_Fillet = geompy.addToStudy(Fillet, "Fillet") + id_Fillet2 = geompy.addToStudy(Fillet2, "FilletR1R2") id_Chamfer = geompy.addToStudy(Chamfer, "Chamfer on Edge") id_Chamfer2 = geompy.addToStudy(Chamfer2, "Chamfer on Faces") + id_Chamfer3 = geompy.addToStudy(Chamfer3, "Chamfer on Edges") + id_Chamfer4 = geompy.addToStudy(Chamfer4, "Chamfer on Faces with params D Angle") id_MultiTrans1D = geompy.addToStudy(MultiTrans1D, "MultiTrans1D") id_MultiTrans2D = geompy.addToStudy(MultiTrans2D, "MultiTrans2D") diff --git a/src/GEOM_SWIG/GEOM_example6.py b/src/GEOM_SWIG/GEOM_example6.py new file mode 100755 index 000000000..91c373981 --- /dev/null +++ b/src/GEOM_SWIG/GEOM_example6.py @@ -0,0 +1,60 @@ +# GEOM GEOM_SWIG : binding of C++ omplementaion with Python +# +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# +# File : GEOM_example6.py +# Author : Dmitry MATVEITCHEV +# Module : GEOM +# $Header$ + + +import salome +import geompy + +ind = 1 +circlelist = [] +while ind < 6: + x1 = 0. + (10. * ind) + y1 = 0. + z1 = 0. + x2 = 10. + (10. * ind) + y2 = 20. * (ind+1) + z2 = 30. * (ind+1) + x3 = 50. + (10. * ind) + y3 = 0. * (ind+1) + z3 = -10. * (ind+1) + + print x1, y1, z1, x2, y2, z2, x3, y3, z3 + + point1 = geompy.MakeVertex(x1, y1, z1) + name1 = "point1_%d"%(ind) + id_pt1 = geompy.addToStudy(point1, name1) + point2 = geompy.MakeVertex(x2, y2, z2) + name2 = "point2_%d"%(ind) + id_pt2 = geompy.addToStudy(point2, name2) + point3 = geompy.MakeVertex(x3, y3, z3) + name3 = "point3_%d"%(ind) + id_pt3 = geompy.addToStudy(point3, name3) + + name = "circle%d"%(ind) + circle = geompy.MakeCircleCenter2Pnt(point1, point2, point3) + id_circle = geompy.addToStudy(circle, name) + circlelist.append(circle) + ind = ind + 1 diff --git a/src/GEOM_SWIG/Makefile.in b/src/GEOM_SWIG/Makefile.in index 978e86c99..becddefac 100644 --- a/src/GEOM_SWIG/Makefile.in +++ b/src/GEOM_SWIG/Makefile.in @@ -49,6 +49,7 @@ EXPORT_PYSCRIPTS = \ GEOM_example3.py \ GEOM_example4.py \ GEOM_example5.py \ + GEOM_example6.py \ GEOM_moteur.py \ GEOM_TestAll.py \ GEOM_TestOthers.py \ diff --git a/src/GEOM_SWIG/batchmode_geompy.py b/src/GEOM_SWIG/batchmode_geompy.py index 42e9ec5c2..145f962fb 100644 --- a/src/GEOM_SWIG/batchmode_geompy.py +++ b/src/GEOM_SWIG/batchmode_geompy.py @@ -249,6 +249,12 @@ def MakeCircleThreePnt(p1,p2,p3): print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode() return anObj +def MakeCircleCenter2Pnt(p1,p2,p3): + anObj = CurvesOp.MakeCircleCenter2Pnt(p1,p2,p3) + if CurvesOp.IsDone() == 0: + print "MakeCircleCenter2Pnt : ", CurvesOp.GetErrorCode() + return anObj + def MakeEllipse(p1,v1,radiusMaj,radiusMin): anObj = CurvesOp.MakeEllipse(p1,v1,radiusMaj, radiusMin) if CurvesOp.IsDone() == 0: @@ -852,6 +858,16 @@ def MakeFillet(aShape,radius,aShapeType,ListShape): print "MakeFillet : ", LocalOp.GetErrorCode() return anObj +def MakeFilletR1R2(aShape,radius1,radius2,aShapeType,ListShape): + anObj = None + if aShapeType == ShapeType["EDGE"]: + anObj = LocalOp.MakeFilletEdgesR1R2(aShape,radius1,radius2,ListShape) + else: + anObj = LocalOp.MakeFilletFacesR1R2(aShape,radius1,radius2,ListShape) + if LocalOp.IsDone() == 0: + print "MakeFilletR1R2 : ", LocalOp.GetErrorCode() + return anObj + def MakeChamferAll(aShape,d): anObj = LocalOp.MakeChamferAll(aShape,d) if LocalOp.IsDone() == 0: @@ -864,12 +880,36 @@ def MakeChamferEdge(aShape,d1,d2,face1,face2): print "MakeChamferEdge : ", LocalOp.GetErrorCode() return anObj +def MakeChamferEdgeAD(aShape,d,angle,face1,face2): + anObj = LocalOp.MakeChamferEdgeAD(aShape,d,angle,face1,face2) + if LocalOp.IsDone() == 0: + print "MakeChamferEdgeAD : ", LocalOp.GetErrorCode() + return anObj + def MakeChamferFaces(aShape,d1,d2,ListShape): anObj = LocalOp.MakeChamferFaces(aShape,d1,d2,ListShape) if LocalOp.IsDone() == 0: print "MakeChamferFaces : ", LocalOp.GetErrorCode() return anObj +def MakeChamferFacesAD(aShape,d,angle,ListShape): + anObj = LocalOp.MakeChamferFacesAD(aShape,d,angle,ListShape) + if LocalOp.IsDone() == 0: + print "MakeChamferFacesAD : ", LocalOp.GetErrorCode() + return anObj + +def MakeChamferEdges(aShape,d1,d2,ListShape): + anObj = LocalOp.MakeChamferEdges(aShape,d1,d2,ListShape) + if LocalOp.IsDone() == 0: + print "MakeChamferEdges : ", LocalOp.GetErrorCode() + return anObj + +def MakeChamferEdgesAD(aShape,d,angle,ListShape): + anObj = LocalOp.MakeChamferEdgesAD(aShape,d,angle,ListShape) + if LocalOp.IsDone() == 0: + print "MakeChamferEdgesAD : ", LocalOp.GetErrorCode() + return anObj + def MakeChamfer(aShape,d1,d2,aShapeType,ListShape): anObj = None if aShapeType == ShapeType["EDGE"]: diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index ba1cb7c27..24330c01e 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -387,6 +387,19 @@ def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3): print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode() return anObj +## Create a circle, with given point1 as center, +# passing through the point2 as radius and laying in the plane, +# defined by all three given points. +# @param thePnt1,thePnt2,thePnt3 Points, defining the circle. +# @return New GEOM_Object, containing the created circle. +# +# Example: see GEOM_example6.py +def MakeCircleCenter2Pnt(thePnt1, thePnt2, thePnt3): + anObj = CurvesOp.MakeCircleCenter2Pnt(thePnt1, thePnt2, thePnt3) + if CurvesOp.IsDone() == 0: + print "MakeCircleCenter2Pnt : ", CurvesOp.GetErrorCode() + return anObj + ## Create an ellipse with given center, normal vector and radiuses. # @param thePnt Ellipse center. # @param theVec Vector, normal to the plane of the ellipse. @@ -1899,6 +1912,16 @@ def MakeFillet(theShape, theR, theShapeType, theListShapes): if LocalOp.IsDone() == 0: print "MakeFillet : ", LocalOp.GetErrorCode() return anObj +## The same but with two Fillet Radius R1 and R2 +def MakeFilletR1R2(theShape, theR1, theR2, theShapeType, theListShapes): + anObj = None + if theShapeType == ShapeType["EDGE"]: + anObj = LocalOp.MakeFilletEdgesR1R2(theShape, theR1, theR2, theListShapes) + else: + anObj = LocalOp.MakeFilletFacesR1R2(theShape, theR1, theR2, theListShapes) + if LocalOp.IsDone() == 0: + print "MakeFilletR1R2 : ", LocalOp.GetErrorCode() + return anObj ## Perform a symmetric chamfer on all edges of the given shape. # @param theShape Shape, to perform chamfer on. @@ -1927,6 +1950,13 @@ def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2): if LocalOp.IsDone() == 0: print "MakeChamferEdge : ", LocalOp.GetErrorCode() return anObj +## The Same chamfer but with params theD is chamfer lenght and +# theAngle is Angle of chamfer +def MakeChamferEdgeAD(theShape, theD, theAngle, theFace1, theFace2): + anObj = LocalOp.MakeChamferEdgeAD(theShape, theD, theAngle, theFace1, theFace2) + if LocalOp.IsDone() == 0: + print "MakeChamferEdgeAD : ", LocalOp.GetErrorCode() + return anObj ## Perform a chamfer on all edges of the specified faces, # with distance D1 on the first specified face (if several for one edge) @@ -1945,6 +1975,34 @@ def MakeChamferFaces(theShape, theD1, theD2, theFaces): if LocalOp.IsDone() == 0: print "MakeChamferFaces : ", LocalOp.GetErrorCode() return anObj +## The Same chamfer but with params theD is chamfer lenght and +# theAngle is Angle of chamfer +def MakeChamferFacesAD(theShape, theD, theAngle, theFaces): + anObj = LocalOp.MakeChamferFacesAD(theShape, theD, theAngle, theFaces) + if LocalOp.IsDone() == 0: + print "MakeChamferFacesAD : ", LocalOp.GetErrorCode() + return anObj + +## Perform a chamfer on edges, +# with distance D1 on the first specified face (if several for one edge) +# @param theShape Shape, to perform chamfer on. +# @param theD1 and theD2 Chamfer size +# @param theEdges Sequence of edges of \a theShape. +# @return New GEOM_Object, containing the result shape. +# +# Example: +def MakeChamferEdges(theShape, theD1, theD2, theEdges): + anObj = LocalOp.MakeChamferEdges(theShape, theD1, theD2, theEdges) + if LocalOp.IsDone() == 0: + print "MakeChamferEdges : ", LocalOp.GetErrorCode() + return anObj +## The Same chamfer but with params theD is chamfer lenght and +# theAngle is Angle of chamfer +def MakeChamferEdgesAD(theShape, theD, theAngle, theEdges): + anObj = LocalOp.MakeChamferEdgesAD(theShape, theD, theAngle, theEdges) + if LocalOp.IsDone() == 0: + print "MakeChamferEdgesAD : ", LocalOp.GetErrorCode() + return anObj ## Shortcut to MakeChamferEdge() and MakeChamferFaces() # diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.cxx b/src/OperationGUI/OperationGUI_ChamferDlg.cxx index 29ecc1795..a0a5d07ba 100644 --- a/src/OperationGUI/OperationGUI_ChamferDlg.cxx +++ b/src/OperationGUI/OperationGUI_ChamferDlg.cxx @@ -1,696 +1,895 @@ -// 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.cxx -// Author : Damien COQUERET -// Module : GEOM -// $Header$ - -#include "OperationGUI_ChamferDlg.h" -#include "DlgRef_SpinBox.h" - -#include "SUIT_Desktop.h" -#include "SUIT_Session.h" -#include "SalomeApp_Application.h" -#include "LightApp_SelectionMgr.h" -#include "OCCViewer_ViewModel.h" - -#include - -#include -#include "qpixmap.h" -#include - -#include "GEOMImpl_Types.hxx" - -//================================================================================= -// class : OperationGUI_ChamferDlg() -// purpose : Constructs a OperationGUI_ChamferDlg 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. -//================================================================================= -OperationGUI_ChamferDlg::OperationGUI_ChamferDlg(GeometryGUI* theGeometryGUI, QWidget* parent) - : GEOMBase_Skeleton(theGeometryGUI, parent, "ChamferDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) -{ - myConstructorId = -1; - - QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_ALL"))); - QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE"))); - QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_FACE"))); - QPixmap iconSelect(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); - - setCaption( tr( "GEOM_CHAMFER_TITLE" ) ); - - GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) ); - - RadioButton1->setPixmap( image1 ); - RadioButton2->setPixmap( image2 ); - RadioButton3->setPixmap( image3 ); - - // Create first group - - myGrp1 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_ALL" ), this ); - - QGroupBox* aSelGrp1 = new QGroupBox( 3, Qt::Horizontal, myGrp1 ); - aSelGrp1->setFrameStyle( QFrame::NoFrame ); - aSelGrp1->setInsideMargin( 0 ); - - createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp1, MainObj1 ); - - QGroupBox* aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp1 ); - aSpinGrp->setFrameStyle( QFrame::NoFrame ); - aSpinGrp->setInsideMargin( 0 ); - - new QLabel( tr( "D" ), aSpinGrp ); - mySpinBox[ SpinBox1 ] = new DlgRef_SpinBox( aSpinGrp ); - - ( new QFrame( myGrp1 ) )->setSizePolicy( - QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - - // Create second group - - myGrp2 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_EDGES" ), this ); - - QGroupBox* aSelGrp2 = new QGroupBox( 3, Qt::Horizontal, myGrp2 ); - aSelGrp2->setFrameStyle( QFrame::NoFrame ); - aSelGrp2->setInsideMargin( 0 ); - - createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp2, MainObj2 ); - createSelWg( tr( "FACE_1" ), iconSelect, aSelGrp2, Face1 ); - createSelWg( tr( "FACE_2" ), iconSelect, aSelGrp2, Face2 ); - - aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp2 ); - aSpinGrp->setFrameStyle( QFrame::NoFrame ); - aSpinGrp->setInsideMargin( 0 ); - - new QLabel( tr( "GEOM_D1" ), aSpinGrp ); - mySpinBox[ SpinBox21 ] = new DlgRef_SpinBox( aSpinGrp ); - - new QLabel( tr( "GEOM_D2" ), aSpinGrp ); - mySpinBox[ SpinBox22 ] = new DlgRef_SpinBox( aSpinGrp ); - - // Create third group - - myGrp3 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_FACES" ), this ); - - QGroupBox* aSelGrp3 = new QGroupBox( 3, Qt::Horizontal, myGrp3 ); - aSelGrp3->setFrameStyle( QFrame::NoFrame ); - aSelGrp3->setInsideMargin( 0 ); - - createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp3, MainObj3 ); - createSelWg( tr( "SELECTED_FACES" ), iconSelect, aSelGrp3, Faces ); - - aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp3 ); - aSpinGrp->setFrameStyle( QFrame::NoFrame ); - aSpinGrp->setInsideMargin( 0 ); - - new QLabel( tr( "GEOM_D1" ), aSpinGrp ); - mySpinBox[ SpinBox31 ] = new DlgRef_SpinBox( aSpinGrp ); - - new QLabel( tr( "GEOM_D2" ), aSpinGrp ); - mySpinBox[ SpinBox32 ] = new DlgRef_SpinBox( aSpinGrp ); - - ( new QLabel( myGrp3 ) )->setSizePolicy( - QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - - // Add groups to layout - - Layout1->addWidget( myGrp1, 2, 0 ); - Layout1->addWidget( myGrp2, 2, 0 ); - Layout1->addWidget( myGrp3, 2, 0 ); - - // Set range of spinboxes - - double SpecificStep = 10.0; - QMap< int, DlgRef_SpinBox* >::iterator anIter; - for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) - anIter.data()->RangeStepAndValidator( 0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY ); - - setHelpFileName("chamfer.htm"); - - /* Initialisations */ - Init(); -} - - -//================================================================================= -// function : ~OperationGUI_ChamferDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg() -{ -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::Init() -{ - myConstructorId = -1; - reset(); - RadioButton1->setChecked( true ); - myEditCurrentArgument = mySelName[ MainObj1 ]; - - /* signals and slots connections */ - - // main buttons - connect( buttonOk , SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - - // group box - connect( GroupConstructors, SIGNAL( clicked( int ) ), - this, SLOT( ConstructorsClicked( int ) ) ); - - // push buttons - QMap< int, QPushButton* >::iterator anIterBtn; - for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn ) - connect( anIterBtn.data(), SIGNAL( clicked() ), - this, SLOT( SetEditCurrentArgument() ) ); - - // line edits - QMap< int, QLineEdit* >::iterator anIterLE2; - for ( anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2 ) - connect( anIterLE2.data(), SIGNAL( returnPressed() ), - this, SLOT( LineEditReturnPressed() ) ); - - // spin boxes - QMap< int, DlgRef_SpinBox* >::iterator anIterSpin; - for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin ) - connect( anIterSpin.data(), SIGNAL( valueChanged( double ) ), - this, SLOT( ValueChangedInSpinBox( double ) ) ); - - // selection - connect(myGeomGUI->getApp()->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - initName( tr( "GEOM_CHAMFER" ) ); - - myGrp2->hide(); - myGrp3->hide(); - myGrp1->show(); -} - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId ) -{ - // Activate next widget - if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType() - != OCCViewer_Viewer::Type()) - { - RadioButton1->setChecked( true ); - return; - } - - if (myConstructorId == constructorId) - return; - - // Get values from previous widget - double D1 = 5, D2 = 5; - if ( myConstructorId == 0 ) - D1 = D2 = mySpinBox[ SpinBox1 ]->GetValue(); - else if ( myConstructorId == 1 ) - { - D1 = mySpinBox[ SpinBox21 ]->GetValue(); - D2 = mySpinBox[ SpinBox22 ]->GetValue(); - } - else if ( myConstructorId == 2 ) - { - D1 = mySpinBox[ SpinBox31 ]->GetValue(); - D2 = mySpinBox[ SpinBox32 ]->GetValue(); - } - - myConstructorId = constructorId; - - switch ( constructorId ) - { - case 0: - myGrp1->show(); - myGrp2->hide(); - myGrp3->hide(); - mySpinBox[ SpinBox1 ]->SetValue( D1 ); - break; - case 1: - myGrp1->hide(); - myGrp2->show(); - myGrp3->hide(); - mySpinBox[ SpinBox21 ]->SetValue( D1 ); - mySpinBox[ SpinBox22 ]->SetValue( D2 ); - break; - case 2: - myGrp1->hide(); - myGrp2->hide(); - myGrp3->show(); - mySpinBox[ SpinBox31 ]->SetValue( D1 ); - mySpinBox[ SpinBox32 ]->SetValue( D2 ); - break; - default: - break; - } - - if ( constructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ]; - else if ( constructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ]; - else myEditCurrentArgument = mySelName[ MainObj3 ]; - - activateSelection(); - enableWidgets(); - - if ( !myShape->_is_nil() ) - { - myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) ); - GEOMBase_Skeleton::LineEditReturnPressed(); - } - else - myEditCurrentArgument->setText( "" ); - - displayPreview(); -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::ClickOnOk() -{ - if ( ClickOnApply() ) - ClickOnCancel(); -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -bool OperationGUI_ChamferDlg::ClickOnApply() -{ - if ( !onAccept() ) - return false; - - initName(); - return true; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed -//================================================================================= -void OperationGUI_ChamferDlg::SelectionIntoArgument() -{ - erasePreview(); - myEditCurrentArgument->setText( "" ); - - // Get index of current selection focus - int aCurrFocus = -1; - QMap< int, QLineEdit* >::iterator anIter; - for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter ) - if ( myEditCurrentArgument == anIter.data() ) - { - aCurrFocus = anIter.key(); - break; - } - - // If selection of main object is activated - if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 ) - { - if ( IObjectCount() == 1 ) - { - Standard_Boolean aResult = Standard_False; - GEOM::GEOM_Object_var anObj = - GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult ); - - if ( aResult && !anObj->_is_nil() ) - { - myShape = anObj; - mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) ); - displayPreview(); - enableWidgets(); - return; - } - } - - myShape = GEOM::GEOM_Object::_nil(); - enableWidgets(); - } - // If face selection of second tab is activated - else if ( aCurrFocus == Face1 || aCurrFocus == Face2 ) - { - if ( IObjectCount() == 1 ) - { - Standard_Boolean aResult = Standard_False; - GEOM::GEOM_Object_var anObj = - GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult ); - - if ( aResult && !anObj->_is_nil() ) - { - TColStd_IndexedMapOfInteger anIndexes; - ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes ); - - if ( anIndexes.Extent() == 1 ) - { - int anIndex = anIndexes( 1 ); - QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1"; - myEditCurrentArgument->setText( aFaceName.arg( anIndex ) ); - myFace[ aCurrFocus ] = anIndex; - displayPreview(); - return; - } - } - } - - myFace[ aCurrFocus ] = -1; - } - // If face selection of third tab is activated - else if ( aCurrFocus == Faces ) - { - if ( IObjectCount() == 1 ) - { - Standard_Boolean aResult = Standard_False; - GEOM::GEOM_Object_var anObj = - GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult ); - - if ( aResult && !anObj->_is_nil() ) - { - TColStd_IndexedMapOfInteger anIndexes; - ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes ); - - if ( anIndexes.Extent() > 0 ) - { - QString aFaceName; - if ( anIndexes.Extent() == 1 ) - { - int anIndex = anIndexes( 1 ); - - aFaceName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex ); - } - else - aFaceName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() ); - - myEditCurrentArgument->setText( aFaceName ); - myFaces = anIndexes; - displayPreview(); - return; - } - } - } - myFaces.Clear(); - } -} - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::LineEditReturnPressed() -{ - QLineEdit* aSender = ( QLineEdit* )sender(); - - QMap< int, QLineEdit* >::iterator anIterLE; - for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE ) - if ( anIterLE.data() == aSender ) - myEditCurrentArgument = anIterLE.data(); - - GEOMBase_Skeleton::LineEditReturnPressed(); -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::SetEditCurrentArgument() -{ - QPushButton* aSender = ( QPushButton* )sender(); - - QMap< int, QPushButton* >::iterator anIter; - for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) - if ( anIter.data() == aSender ) - { - mySelName[ anIter.key() ]->setFocus(); - myEditCurrentArgument = mySelName[ anIter.key() ]; - } - - activateSelection(); -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); - - connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT( SelectionIntoArgument() ) ); - - activateSelection(); - displayPreview(); -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::enterEvent(QEvent* e) -{ - if ( !GroupConstructors->isEnabled() ) - this->ActivateThisDialog(); -} - - -//================================================================================= -// function : ValueChangedInSpinBox() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double newValue ) -{ - displayPreview(); -} - - -//================================================================================= -// function : createSelWg() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl, - QPixmap& thePix, - QWidget* theParent, - const int theId ) -{ - new QLabel( theLbl, theParent ); - mySelBtn[ theId ] = new QPushButton( theParent ); - mySelBtn[ theId ]->setPixmap( thePix ); - mySelName[ theId ] = new QLineEdit( theParent ); - mySelName[ theId ]->setReadOnly( true ); -} - -//================================================================================= -// function : reset() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::reset() -{ - // Set Initial values of spinboxes - QMap< int, DlgRef_SpinBox* >::iterator anIter; - for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) - anIter.data()->SetValue( 5 ); - - // clear line edits - QMap< int, QLineEdit* >::iterator anIterLE; - for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE ) - anIterLE.data()->setText( "" ); - - // constructor id - int aConstructorId = getConstructorId(); - - if ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ]; - else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ]; - else myEditCurrentArgument = mySelName[ MainObj3 ]; - - myShape = GEOM::GEOM_Object::_nil(); - - myFaces.Clear(); - myFace[ Face1 ] = -1; - myFace[ Face2 ] = -1; - - erasePreview( true ); - - activateSelection(); - - enableWidgets(); -} - -//================================================================================= -// function : getConstructorId() -// purpose : -//================================================================================= -int OperationGUI_ChamferDlg::getConstructorId() const -{ - return GroupConstructors->id( GroupConstructors->selected() ); -} - -//================================================================================= -// function : activateSelection -// purpose : Activate selection in accordance with myEditCurrentArgument -//================================================================================= -void OperationGUI_ChamferDlg::activateSelection() -{ - if ( !myShape->_is_nil() && - ( myEditCurrentArgument == mySelName[ Face1 ] || - myEditCurrentArgument == mySelName[ Face2 ] || - myEditCurrentArgument == mySelName[ Faces ] ) ) - localSelection( myShape, TopAbs_FACE ); - else - { - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_SHELL ); - aMap.Add( GEOM_SOLID ); - aMap.Add( GEOM_COMPOUND ); - globalSelection( aMap ); - } - - SelectionIntoArgument(); -} - -//================================================================================= -// function : enableWidgets -// purpose : Enable widgets of faces in accordance with value of main object -//================================================================================= -void OperationGUI_ChamferDlg::enableWidgets() -{ - int anId = getConstructorId(); - - bool toEnable = !myShape->_is_nil(); - - if ( anId == 1 ) - { - mySelName[ Face1 ]->setEnabled( toEnable ); - mySelName[ Face2 ]->setEnabled( toEnable ); - mySelBtn[ Face1 ]->setEnabled( toEnable ); - mySelBtn[ Face2 ]->setEnabled( toEnable ); - - if ( !toEnable ) - { - mySelName[ Face1 ]->setText( "" ); - mySelName[ Face2 ]->setText( "" ); - myFace[ Face1 ] = -1; - myFace[ Face2 ] = -1; - } - } - else if ( anId == 2 ) - { - mySelName[ Faces ]->setEnabled( toEnable ); - - if ( !toEnable ) - myFaces.Clear(); - } -} - -//================================================================================= -// function : createOperation -// purpose : -//================================================================================= -GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation() -{ - return getGeomEngine()->GetILocalOperations( getStudyId() ); -} - -//================================================================================= -// function : ClickOnApply() -// purpose : Verify validity of input data -//================================================================================= -bool OperationGUI_ChamferDlg::isValid( QString& ) -{ - switch ( getConstructorId() ) - { - case 0: return !myShape->_is_nil(); - case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0; - case 2: return !myShape->_is_nil() && myFaces.Extent() > 0; - default: return false; - } -} - -//================================================================================= -// function : execute -// purpose : -//================================================================================= -bool OperationGUI_ChamferDlg::execute( ObjectList& objects ) -{ - GEOM::GEOM_Object_var anObj; - - int anId = getConstructorId(); - if ( anId == 0 ) - anObj = GEOM::GEOM_ILocalOperations::_narrow( - getOperation() )->MakeChamferAll( myShape, - mySpinBox[ SpinBox1 ]->GetValue() ); - else if ( anId == 1 ) - anObj = GEOM::GEOM_ILocalOperations::_narrow( - getOperation() )->MakeChamferEdge( myShape, - mySpinBox[ SpinBox21 ]->GetValue(), - mySpinBox[ SpinBox22 ]->GetValue(), - myFace[ Face1 ], - myFace[ Face2 ] ); - else if ( anId == 2 ) - { - - int i = 0; - 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 ); - - anObj = GEOM::GEOM_ILocalOperations::_narrow( - getOperation() )->MakeChamferFaces( myShape, - mySpinBox[ SpinBox31 ]->GetValue(), - mySpinBox[ SpinBox32 ]->GetValue(), - anArray ); - } - - - if ( !anObj->_is_nil() ) - objects.push_back( anObj._retn() ); - - return true; -} - - - - - - - - - +// 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.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +#include "OperationGUI_ChamferDlg.h" +#include "DlgRef_SpinBox.h" + +#include "SUIT_Desktop.h" +#include "SUIT_Session.h" +#include "SalomeApp_Application.h" +#include "LightApp_SelectionMgr.h" +#include "OCCViewer_ViewModel.h" + +#include + +#include +#include "qpixmap.h" +#include + +#include "GEOMImpl_Types.hxx" + +//================================================================================= +// class : OperationGUI_ChamferDlg() +// purpose : Constructs a OperationGUI_ChamferDlg 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. +//================================================================================= +OperationGUI_ChamferDlg::OperationGUI_ChamferDlg(GeometryGUI* theGeometryGUI, QWidget* parent) + : GEOMBase_Skeleton(theGeometryGUI, parent, "ChamferDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + myConstructorId = -1; + + QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_ALL"))); + QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE_FROM_FACE"))); + QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_FACE"))); + QPixmap image4(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE"))); + QPixmap iconSelect(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption( tr( "GEOM_CHAMFER_TITLE" ) ); + + GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) ); + + RadioButton1->setPixmap( image1 ); + RadioButton2->setPixmap( image2 ); + RadioButton3->setPixmap( image3 ); + RadioButton4->show(); + RadioButton4->setPixmap( image4 ); + + // Create first group + + myGrp1 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_ALL" ), this ); + + QGroupBox* aSelGrp1 = new QGroupBox( 3, Qt::Horizontal, myGrp1 ); + aSelGrp1->setFrameStyle( QFrame::NoFrame ); + aSelGrp1->setInsideMargin( 0 ); + + createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp1, MainObj1 ); + + QGroupBox* aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp1 ); + aSpinGrp->setFrameStyle( QFrame::NoFrame ); + aSpinGrp->setInsideMargin( 0 ); + + new QLabel( tr( "D" ), aSpinGrp ); + mySpinBox[ SpinBox1 ] = new DlgRef_SpinBox( aSpinGrp ); + + ( new QFrame( myGrp1 ) )->setSizePolicy( + QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + // Create second group + + myGrp2 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_EDGES" ), this ); + + QGroupBox* aSelGrp2 = new QGroupBox( 3, Qt::Horizontal, myGrp2 ); + aSelGrp2->setFrameStyle( QFrame::NoFrame ); + aSelGrp2->setInsideMargin( 0 ); + + createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp2, MainObj2 ); + createSelWg( tr( "FACE_1" ), iconSelect, aSelGrp2, Face1 ); + createSelWg( tr( "FACE_2" ), iconSelect, aSelGrp2, Face2 ); + + QGroupBox* aSpinGrp1 = new QGroupBox( 1, Qt::Vertical, myGrp2 ); + aSpinGrp1->setFrameStyle( QFrame::NoFrame ); + aSpinGrp1->setInsideMargin( 0 ); + + myRadioButton[ RadioButton21] = new QRadioButton( aSpinGrp1 ); + + new QLabel( tr( "GEOM_D1" ), aSpinGrp1 ); + mySpinBox[ SpinBox21 ] = new DlgRef_SpinBox( aSpinGrp1 ); + + new QLabel( tr( "GEOM_D2" ), aSpinGrp1 ); + mySpinBox[ SpinBox22 ] = new DlgRef_SpinBox( aSpinGrp1 ); + + QGroupBox* aSpinGrp2 = new QGroupBox( 1, Qt::Vertical, myGrp2 ); + aSpinGrp2->setFrameStyle( QFrame::NoFrame ); + aSpinGrp2->setInsideMargin( 0 ); + + myRadioButton[ RadioButton22] = new QRadioButton( aSpinGrp2 ); + + new QLabel( tr( "GEOM_D" ), aSpinGrp2 ); + mySpinBox[ SpinBox23 ] = new DlgRef_SpinBox( aSpinGrp2 ); + + new QLabel( tr( "GEOM_ANGLE" ), aSpinGrp2 ); + mySpinBox[ SpinBox24 ] = new DlgRef_SpinBox( aSpinGrp2 ); + + ( new QLabel( myGrp2 ) )->setSizePolicy( + QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + // Create third group + + myGrp3 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_FACES" ), this ); + + QGroupBox* aSelGrp3 = new QGroupBox( 3, Qt::Horizontal, myGrp3 ); + aSelGrp3->setFrameStyle( QFrame::NoFrame ); + aSelGrp3->setInsideMargin( 0 ); + + createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp3, MainObj3 ); + createSelWg( tr( "SELECTED_FACES" ), iconSelect, aSelGrp3, Faces ); + + aSpinGrp1 = new QGroupBox( 1, Qt::Vertical, myGrp3 ); + aSpinGrp1->setFrameStyle( QFrame::NoFrame ); + aSpinGrp1->setInsideMargin( 0 ); + + myRadioButton[ RadioButton31] = new QRadioButton( aSpinGrp1 ); + + new QLabel( tr( "GEOM_D1" ), aSpinGrp1 ); + mySpinBox[ SpinBox31 ] = new DlgRef_SpinBox( aSpinGrp1 ); + + new QLabel( tr( "GEOM_D2" ), aSpinGrp1 ); + mySpinBox[ SpinBox32 ] = new DlgRef_SpinBox( aSpinGrp1 ); + + aSpinGrp2 = new QGroupBox( 1, Qt::Vertical, myGrp3 ); + aSpinGrp2->setFrameStyle( QFrame::NoFrame ); + aSpinGrp2->setInsideMargin( 0 ); + + myRadioButton[ RadioButton32] = new QRadioButton( aSpinGrp2 ); + + new QLabel( tr( "GEOM_D" ), aSpinGrp2 ); + mySpinBox[ SpinBox33 ] = new DlgRef_SpinBox( aSpinGrp2 ); + + new QLabel( tr( "GEOM_ANGLE" ), aSpinGrp2 ); + mySpinBox[ SpinBox34 ] = new DlgRef_SpinBox( aSpinGrp2 ); + + ( new QLabel( myGrp3 ) )->setSizePolicy( + QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + // Create fourth group + + myGrp4 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_EDGE" ), this ); + + QGroupBox* aSelGrp4 = new QGroupBox( 3, Qt::Horizontal, myGrp4 ); + aSelGrp4->setFrameStyle( QFrame::NoFrame ); + aSelGrp4->setInsideMargin( 0 ); + + createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp4, MainObj4 ); + createSelWg( tr( "SELECTED_EDGE" ), iconSelect, aSelGrp4, Edges ); + + aSpinGrp1 = new QGroupBox( 1, Qt::Vertical, myGrp4 ); + aSpinGrp1->setFrameStyle( QFrame::NoFrame ); + aSpinGrp1->setInsideMargin( 0 ); + + myRadioButton[ RadioButton41] = new QRadioButton( aSpinGrp1 ); + + new QLabel( tr( "GEOM_D1" ), aSpinGrp1 ); + mySpinBox[ SpinBox41 ] = new DlgRef_SpinBox( aSpinGrp1 ); + + new QLabel( tr( "GEOM_D2" ), aSpinGrp1 ); + mySpinBox[ SpinBox42 ] = new DlgRef_SpinBox( aSpinGrp1 ); + + aSpinGrp2 = new QGroupBox( 1, Qt::Vertical, myGrp4 ); + aSpinGrp2->setFrameStyle( QFrame::NoFrame ); + aSpinGrp2->setInsideMargin( 0 ); + + myRadioButton[ RadioButton42] = new QRadioButton( aSpinGrp2 ); + + new QLabel( tr( "GEOM_D" ), aSpinGrp2 ); + mySpinBox[ SpinBox43 ] = new DlgRef_SpinBox( aSpinGrp2 ); + + new QLabel( tr( "GEOM_ANGLE" ), aSpinGrp2 ); + mySpinBox[ SpinBox44 ] = new DlgRef_SpinBox( aSpinGrp2 ); + + ( new QLabel( myGrp4 ) )->setSizePolicy( + QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + // Add groups to layout + + Layout1->addWidget( myGrp1, 2, 0 ); + Layout1->addWidget( myGrp2, 2, 0 ); + Layout1->addWidget( myGrp3, 2, 0 ); + Layout1->addWidget( myGrp4, 2, 0 ); + + // Set range of spinboxes + + double SpecificStep = 10.0; + QMap< int, DlgRef_SpinBox* >::iterator anIter; + for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) + { + anIter.data()->RangeStepAndValidator( 0.001, COORD_MAX, SpecificStep, 3 ); + if ( anIter.key() == SpinBox44 || anIter.key() == SpinBox34 || anIter.key() == SpinBox24 ) + anIter.data()->RangeStepAndValidator( 0, 90, 5, 0 ); + } + + setHelpFileName("chamfer.htm"); + + /* Initialisations */ + RadioButtonPressed(); + Init(); +} + + +//================================================================================= +// function : ~OperationGUI_ChamferDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::Init() +{ + myConstructorId = -1; + reset(); + RadioButton1->setChecked( true ); + myEditCurrentArgument = mySelName[ MainObj1 ]; + + /* signals and slots connections */ + + // main buttons + connect( buttonOk , SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + + // group box + connect( GroupConstructors, SIGNAL( clicked( int ) ), + this, SLOT( ConstructorsClicked( int ) ) ); + + // push buttons + QMap< int, QPushButton* >::iterator anIterBtn; + for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn ) + connect( anIterBtn.data(), SIGNAL( clicked() ), + this, SLOT( SetEditCurrentArgument() ) ); + + // line edits + QMap< int, QLineEdit* >::iterator anIterLE2; + for ( anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2 ) + connect( anIterLE2.data(), SIGNAL( returnPressed() ), + this, SLOT( LineEditReturnPressed() ) ); + + // spin boxes + QMap< int, DlgRef_SpinBox* >::iterator anIterSpin; + for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin ) + connect( anIterSpin.data(), SIGNAL( valueChanged( double ) ), + this, SLOT( ValueChangedInSpinBox( double ) ) ); + + // radio buttons + QMap< int, QRadioButton* >::iterator anIterRadio; + for ( anIterRadio = myRadioButton.begin(); anIterRadio != myRadioButton.end(); ++anIterRadio ) + connect( anIterRadio.data(), SIGNAL( clicked() ), + this, SLOT( RadioButtonPressed() ) ); + + // selection + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName( tr( "GEOM_CHAMFER" ) ); + + myGrp4->hide(); + myGrp3->hide(); + myGrp2->hide(); + myGrp1->show(); +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId ) +{ + // Activate next widget + if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType() + != OCCViewer_Viewer::Type()) + { + RadioButton1->setChecked( true ); + return; + } + + if (myConstructorId == constructorId) + return; + + // Get values from previous widget + double D1 = 5, D2 = 5, D = 5, Angle = 5; + if ( myConstructorId == 0 ) + D1 = D2 = mySpinBox[ SpinBox1 ]->GetValue(); + else if ( myConstructorId == 1 ) + { + D1 = mySpinBox[ SpinBox21 ]->GetValue(); + D2 = mySpinBox[ SpinBox22 ]->GetValue(); + D = mySpinBox[ SpinBox23 ]->GetValue(); + Angle = mySpinBox[ SpinBox24 ]->GetValue(); + } + else if ( myConstructorId == 2 ) + { + D1 = mySpinBox[ SpinBox31 ]->GetValue(); + D2 = mySpinBox[ SpinBox32 ]->GetValue(); + D = mySpinBox[ SpinBox33 ]->GetValue(); + Angle = mySpinBox[ SpinBox34 ]->GetValue(); + } + else if ( myConstructorId == 3 ) + { + D1 = mySpinBox[ SpinBox41 ]->GetValue(); + D2 = mySpinBox[ SpinBox42 ]->GetValue(); + D = mySpinBox[ SpinBox43 ]->GetValue(); + Angle = mySpinBox[ SpinBox44 ]->GetValue(); + } + + myConstructorId = constructorId; + + switch ( constructorId ) + { + case 0: + myGrp1->show(); + myGrp2->hide(); + myGrp3->hide(); + myGrp4->hide(); + mySpinBox[ SpinBox1 ]->SetValue( D1 ); + break; + case 1: + myGrp1->hide(); + myGrp2->show(); + myGrp3->hide(); + myGrp4->hide(); + mySpinBox[ SpinBox21 ]->SetValue( D1 ); + mySpinBox[ SpinBox22 ]->SetValue( D2 ); + mySpinBox[ SpinBox23 ]->SetValue( D ); + mySpinBox[ SpinBox24 ]->SetValue( Angle ); + break; + case 2: + myGrp1->hide(); + myGrp2->hide(); + myGrp3->show(); + myGrp4->hide(); + mySpinBox[ SpinBox31 ]->SetValue( D1 ); + mySpinBox[ SpinBox32 ]->SetValue( D2 ); + mySpinBox[ SpinBox33 ]->SetValue( D ); + mySpinBox[ SpinBox34 ]->SetValue( Angle ); + break; + case 3: + myGrp1->hide(); + myGrp2->hide(); + myGrp3->hide(); + myGrp4->show(); + mySpinBox[ SpinBox41 ]->SetValue( D1 ); + mySpinBox[ SpinBox42 ]->SetValue( D2 ); + mySpinBox[ SpinBox43 ]->SetValue( D ); + mySpinBox[ SpinBox44 ]->SetValue( Angle ); + break; + default: + break; + } + + if ( constructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ]; + else if ( constructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ]; + else if ( constructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ]; + else myEditCurrentArgument = mySelName[ MainObj4 ]; + + activateSelection(); + enableWidgets(); + + if ( !myShape->_is_nil() ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) ); + GEOMBase_Skeleton::LineEditReturnPressed(); + } + else + myEditCurrentArgument->setText( "" ); + + displayPreview(); +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool OperationGUI_ChamferDlg::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void OperationGUI_ChamferDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->setText( "" ); + + // Get index of current selection focus + int aCurrFocus = -1; + QMap< int, QLineEdit* >::iterator anIter; + for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter ) + if ( myEditCurrentArgument == anIter.data() ) + { + aCurrFocus = anIter.key(); + break; + } + + // If selection of main object is activated + if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 || aCurrFocus == MainObj4) + { + if ( IObjectCount() == 1 ) + { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) + { + myShape = anObj; + mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) ); + displayPreview(); + enableWidgets(); + return; + } + } + + myShape = GEOM::GEOM_Object::_nil(); + enableWidgets(); + } + // If face selection of second tab is activated + else if ( aCurrFocus == Face1 || aCurrFocus == Face2 ) + { + if ( IObjectCount() == 1 ) + { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) + { + TColStd_IndexedMapOfInteger anIndexes; + ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes ); + + if ( anIndexes.Extent() == 1 ) + { + int anIndex = anIndexes( 1 ); + QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1"; + myEditCurrentArgument->setText( aFaceName.arg( anIndex ) ); + myFace[ aCurrFocus ] = anIndex; + displayPreview(); + return; + } + } + } + + myFace[ aCurrFocus ] = -1; + } + // If face selection of third or fourth tab is activated + else if ( aCurrFocus == Faces || aCurrFocus == Edges ) + { + if ( IObjectCount() == 1 ) + { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) + { + TColStd_IndexedMapOfInteger anIndexes; + ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes ); + + if ( anIndexes.Extent() > 0 ) + { + QString aName; + if ( anIndexes.Extent() == 1 ) + { + int anIndex = anIndexes( 1 ); + + aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex ); + } + else + aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() ); + + myEditCurrentArgument->setText( aName ); + int aConstructorId = getConstructorId(); + if ( aConstructorId == 2) + myFaces = anIndexes; + else if (aConstructorId == 3) + myEdges = anIndexes; + + displayPreview(); + return; + } + } + } + myFaces.Clear(); + myEdges.Clear(); + } +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::LineEditReturnPressed() +{ + QLineEdit* aSender = ( QLineEdit* )sender(); + + QMap< int, QLineEdit* >::iterator anIterLE; + for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE ) + if ( anIterLE.data() == aSender ) + myEditCurrentArgument = anIterLE.data(); + + GEOMBase_Skeleton::LineEditReturnPressed(); +} + +//================================================================================= +// function : RadioButtonPressed() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::RadioButtonPressed() +{ + bool flag; + flag = ( myRadioButton[ RadioButton21 ]->isChecked() && + myRadioButton[ RadioButton31 ]->isChecked() && + myRadioButton[ RadioButton41 ]->isChecked() ); + + myRadioButton[ RadioButton21 ]->setChecked(!flag); + myRadioButton[ RadioButton31 ]->setChecked(!flag); + myRadioButton[ RadioButton41 ]->setChecked(!flag); + myRadioButton[ RadioButton22 ]->setChecked(flag); + myRadioButton[ RadioButton32 ]->setChecked(flag); + myRadioButton[ RadioButton42 ]->setChecked(flag); + mySpinBox[ SpinBox21 ]->setDisabled(flag); + mySpinBox[ SpinBox22 ]->setDisabled(flag); + mySpinBox[ SpinBox31 ]->setDisabled(flag); + mySpinBox[ SpinBox32 ]->setDisabled(flag); + mySpinBox[ SpinBox41 ]->setDisabled(flag); + mySpinBox[ SpinBox42 ]->setDisabled(flag); + mySpinBox[ SpinBox23 ]->setDisabled(!flag); + mySpinBox[ SpinBox24 ]->setDisabled(!flag); + mySpinBox[ SpinBox33 ]->setDisabled(!flag); + mySpinBox[ SpinBox34 ]->setDisabled(!flag); + mySpinBox[ SpinBox43 ]->setDisabled(!flag); + mySpinBox[ SpinBox44 ]->setDisabled(!flag); + displayPreview(); +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::SetEditCurrentArgument() +{ + QPushButton* aSender = ( QPushButton* )sender(); + + QMap< int, QPushButton* >::iterator anIter; + for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) + if ( anIter.data() == aSender ) + { + mySelName[ anIter.key() ]->setFocus(); + myEditCurrentArgument = mySelName[ anIter.key() ]; + } + + activateSelection(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + + connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT( SelectionIntoArgument() ) ); + + activateSelection(); + displayPreview(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + this->ActivateThisDialog(); +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double newValue ) +{ + displayPreview(); +} + + +//================================================================================= +// function : createSelWg() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl, + QPixmap& thePix, + QWidget* theParent, + const int theId ) +{ + new QLabel( theLbl, theParent ); + mySelBtn[ theId ] = new QPushButton( theParent ); + mySelBtn[ theId ]->setPixmap( thePix ); + mySelName[ theId ] = new QLineEdit( theParent ); + mySelName[ theId ]->setReadOnly( true ); +} + +//================================================================================= +// function : reset() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::reset() +{ + // Set Initial values of spinboxes + QMap< int, DlgRef_SpinBox* >::iterator anIter; + for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) + anIter.data()->SetValue( 5 ); + + // clear line edits + QMap< int, QLineEdit* >::iterator anIterLE; + for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE ) + anIterLE.data()->setText( "" ); + + // constructor id + int aConstructorId = getConstructorId(); + + if ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ]; + else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ]; + else if ( aConstructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ]; + else myEditCurrentArgument = mySelName[ MainObj4 ]; + + myShape = GEOM::GEOM_Object::_nil(); + + myFaces.Clear(); + myEdges.Clear(); + myFace[ Face1 ] = -1; + myFace[ Face2 ] = -1; + + erasePreview( true ); + + activateSelection(); + + enableWidgets(); +} + +//================================================================================= +// function : getConstructorId() +// purpose : +//================================================================================= +int OperationGUI_ChamferDlg::getConstructorId() const +{ + return GroupConstructors->id( GroupConstructors->selected() ); +} + +//================================================================================= +// function : activateSelection +// purpose : Activate selection in accordance with myEditCurrentArgument +//================================================================================= +void OperationGUI_ChamferDlg::activateSelection() +{ + if ( !myShape->_is_nil() && + ( myEditCurrentArgument == mySelName[ Face1 ] || + myEditCurrentArgument == mySelName[ Face2 ] || + myEditCurrentArgument == mySelName[ Faces ] ) ) + localSelection( myShape, TopAbs_FACE ); + else if (!myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ] ) + localSelection( myShape, TopAbs_EDGE ); + else + { + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SHELL ); + aMap.Add( GEOM_SOLID ); + aMap.Add( GEOM_COMPOUND ); + globalSelection( aMap ); + } + + SelectionIntoArgument(); +} + +//================================================================================= +// function : enableWidgets +// purpose : Enable widgets of faces in accordance with value of main object +//================================================================================= +void OperationGUI_ChamferDlg::enableWidgets() +{ + int anId = getConstructorId(); + + bool toEnable = !myShape->_is_nil(); + + if ( anId == 1 ) + { + mySelName[ Face1 ]->setEnabled( toEnable ); + mySelName[ Face2 ]->setEnabled( toEnable ); + mySelBtn[ Face1 ]->setEnabled( toEnable ); + mySelBtn[ Face2 ]->setEnabled( toEnable ); + + if ( !toEnable ) + { + mySelName[ Face1 ]->setText( "" ); + mySelName[ Face2 ]->setText( "" ); + myFace[ Face1 ] = -1; + myFace[ Face2 ] = -1; + } + } + else if ( anId == 2 ) + { + mySelName[ Faces ]->setEnabled( toEnable ); + + if ( !toEnable ) + { + mySelName[ Faces ]->setText( "" ); + myFaces = -1; + } + } + else if ( anId == 3 ) + { + mySelName[ Edges ]->setEnabled( toEnable ); + + if ( !toEnable ) + { + mySelName[ Edges ]->setText( "" ); + myEdges = -1; + } + } +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation() +{ + return getGeomEngine()->GetILocalOperations( getStudyId() ); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : Verify validity of input data +//================================================================================= +bool OperationGUI_ChamferDlg::isValid( QString& ) +{ + switch ( getConstructorId() ) + { + case 0: return !myShape->_is_nil(); + case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0; + case 2: return !myShape->_is_nil() && myFaces.Extent() > 0; + case 3: return !myShape->_is_nil() && myEdges.Extent() > 0; + default: return false; + } +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool OperationGUI_ChamferDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + bool flag = ( myRadioButton[ RadioButton21 ]->isChecked() && + myRadioButton[ RadioButton31 ]->isChecked() && + myRadioButton[ RadioButton41 ]->isChecked() ); + + int anId = getConstructorId(); + if ( anId == 0 ) + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferAll( myShape, + mySpinBox[ SpinBox1 ]->GetValue() ); + else if ( anId == 1 ) + { + if ( flag ) + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferEdge( myShape, + mySpinBox[ SpinBox21 ]->GetValue(), + mySpinBox[ SpinBox22 ]->GetValue(), + myFace[ Face1 ], + myFace[ Face2 ] ); + else + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferEdgeAD( myShape, + mySpinBox[ SpinBox23 ]->GetValue(), + mySpinBox[ SpinBox24 ]->GetValue() * PI180, + myFace[ Face1 ], + myFace[ Face2 ] ); + } + else if ( anId == 2 ) + { + 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 ); + if ( flag ) + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferFaces( myShape, + mySpinBox[ SpinBox31 ]->GetValue(), + mySpinBox[ SpinBox32 ]->GetValue(), + anArray ); + else + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferFacesAD( myShape, + mySpinBox[ SpinBox33 ]->GetValue(), + mySpinBox[ SpinBox34 ]->GetValue() * PI180, + anArray ); + } + else if ( anId == 3 ) + { + 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 ); + if ( flag ) + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferEdges( myShape, mySpinBox[ SpinBox41 ]->GetValue(), + mySpinBox[ SpinBox42 ]->GetValue(), anArray ); + else + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferEdgesAD( myShape, mySpinBox[ SpinBox43 ]->GetValue(), + mySpinBox[ SpinBox44 ]->GetValue() * PI180, anArray ); + } + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; +} + + + + + + + + + diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.h b/src/OperationGUI/OperationGUI_ChamferDlg.h index 664e718be..76f06f594 100644 --- a/src/OperationGUI/OperationGUI_ChamferDlg.h +++ b/src/OperationGUI/OperationGUI_ChamferDlg.h @@ -1,92 +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 }; - enum { SpinBox1, SpinBox21, SpinBox22, SpinBox31, SpinBox32 }; - -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 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 ) - - QFrame* myGrp1; - QFrame* myGrp2; - QFrame* myGrp3; - - QMap< int, QPushButton* > mySelBtn; - QMap< int, QLineEdit* > mySelName; - QMap< int, DlgRef_SpinBox* > mySpinBox; -}; - -#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/OperationGUI/OperationGUI_FilletDlg.cxx b/src/OperationGUI/OperationGUI_FilletDlg.cxx index e4808de4e..76aae8dc0 100644 --- a/src/OperationGUI/OperationGUI_FilletDlg.cxx +++ b/src/OperationGUI/OperationGUI_FilletDlg.cxx @@ -28,7 +28,7 @@ #include "OperationGUI_FilletDlg.h" #include "DlgRef_1Sel1Spin.h" -#include "DlgRef_2Sel1Spin.h" +#include "DlgRef_2Sel3Spin2Rb.h" #include "SUIT_Desktop.h" #include "SUIT_Session.h" @@ -79,21 +79,25 @@ OperationGUI_FilletDlg::OperationGUI_FilletDlg(GeometryGUI* theGeometryGUI, QWid Group1->PushButton1->setPixmap( iconSelect ); Group1->LineEdit1->setReadOnly( true ); - Group2 = new DlgRef_2Sel1Spin( this, "Group2" ); + Group2 = new DlgRef_2Sel3Spin2Rb( this, "Group2" ); Group2->GroupBox1->setTitle( tr( "GEOM_FILLET_EDGES" ) ); Group2->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); Group2->TextLabel2->setText( tr( "SELECTED_EDGES" ) ); Group2->TextLabel3->setText( tr( "GEOM_RADIUS" ) ); + Group2->TextLabel4->setText( tr( "GEOM_R1" ) ); + Group2->TextLabel5->setText( tr( "GEOM_R2" ) ); Group2->PushButton1->setPixmap( iconSelect ); Group2->PushButton2->setPixmap( iconSelect ); Group2->LineEdit1->setReadOnly( true ); Group2->LineEdit2->setReadOnly( true ); - Group3 = new DlgRef_2Sel1Spin( this, "Group3" ); + Group3 = new DlgRef_2Sel3Spin2Rb( this, "Group3" ); Group3->GroupBox1->setTitle(tr( "GEOM_FILLET_FACES" ) ); Group3->TextLabel1->setText(tr( "GEOM_MAIN_OBJECT" ) ); Group3->TextLabel2->setText(tr( "SELECTED_FACES" ) ); Group3->TextLabel3->setText(tr( "GEOM_RADIUS" ) ); + Group3->TextLabel4->setText(tr( "GEOM_R1" ) ); + Group3->TextLabel5->setText(tr( "GEOM_R2" ) ); Group3->PushButton1->setPixmap( iconSelect ); Group3->PushButton2->setPixmap( iconSelect ); Group3->LineEdit1->setReadOnly( true ); @@ -107,7 +111,11 @@ OperationGUI_FilletDlg::OperationGUI_FilletDlg(GeometryGUI* theGeometryGUI, QWid double SpecificStep = 10.0; Group1->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY); Group2->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY); + Group2->SpinBox_DY->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY); + Group2->SpinBox_DZ->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY); Group3->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY); + Group3->SpinBox_DY->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY); + Group3->SpinBox_DZ->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY); setHelpFileName("fillet.htm"); @@ -158,7 +166,17 @@ void OperationGUI_FilletDlg::Init() // spin boxes connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(Group2->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(Group2->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(Group2->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(Group3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(Group3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(Group3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + //RadioButtons + connect( Group2->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButton_Clicked() ) ); + connect( Group2->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButton_Clicked() ) ); + connect( Group3->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButton_Clicked() ) ); + connect( Group3->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButton_Clicked() ) ); // selection connect(myGeomGUI->getApp()->selectionMgr(), @@ -189,10 +207,18 @@ void OperationGUI_FilletDlg::ConstructorsClicked( int constructorId ) return; // Get radius from previous widget - double R = 5; + double R = 5, R1 = 5, R2 = 5; if ( myConstructorId == 0 ) R = Group1->SpinBox_DX->GetValue(); - else if ( myConstructorId == 1 ) R = Group2->SpinBox_DX->GetValue(); - else R = Group3->SpinBox_DX->GetValue(); + else if ( myConstructorId == 1 ) { + R = Group2->SpinBox_DX->GetValue(); + R1 = Group2->SpinBox_DY->GetValue(); + R2 = Group2->SpinBox_DZ->GetValue(); + } + else { + R = Group3->SpinBox_DX->GetValue(); + R1 = Group3->SpinBox_DY->GetValue(); + R2 = Group3->SpinBox_DZ->GetValue(); + } myConstructorId = constructorId; @@ -209,12 +235,16 @@ void OperationGUI_FilletDlg::ConstructorsClicked( int constructorId ) Group2->show(); Group3->hide(); Group2->SpinBox_DX->SetValue( R ); + Group2->SpinBox_DY->SetValue( R1 ); + Group2->SpinBox_DZ->SetValue( R2 ); break; case 2: Group1->hide(); Group2->hide(); Group3->show(); Group3->SpinBox_DX->SetValue( R ); + Group3->SpinBox_DY->SetValue( R1 ); + Group3->SpinBox_DZ->SetValue( R2 ); break; default: break; @@ -444,7 +474,11 @@ void OperationGUI_FilletDlg::reset() // Set Initial values of spinboxes Group1->SpinBox_DX->SetValue( 5 ); Group2->SpinBox_DX->SetValue( 5 ); + Group2->SpinBox_DY->SetValue( 5 ); + Group2->SpinBox_DZ->SetValue( 5 ); Group3->SpinBox_DX->SetValue( 5 ); + Group3->SpinBox_DY->SetValue( 5 ); + Group3->SpinBox_DZ->SetValue( 5 ); Group1->LineEdit1->setText( "" ); Group2->LineEdit1->setText( "" ); @@ -572,8 +606,7 @@ bool OperationGUI_FilletDlg::execute( ObjectList& objects ) int anId = getConstructorId(); if ( anId == 0 ) anObj = GEOM::GEOM_ILocalOperations::_narrow( - getOperation() )->MakeFilletAll( myShape, - getRadius() ); + getOperation() )->MakeFilletAll( myShape, getRadius() ); else if ( anId == 1 ) { GEOM::ListOfLong_var aList = new GEOM::ListOfLong; @@ -581,9 +614,14 @@ bool OperationGUI_FilletDlg::execute( ObjectList& objects ) for ( int i = 1, n = myEdges.Extent(); i <= n; i++ ) aList[ i - 1 ] = myEdges( i ); - - anObj = GEOM::GEOM_ILocalOperations::_narrow( - getOperation() )->MakeFilletEdges( myShape, getRadius(), aList ); + if ( Group2->RadioButton1->isChecked() ) + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeFilletEdges( myShape, getRadius(), aList ); + else + anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->MakeFilletEdgesR1R2( myShape, + (Group2->SpinBox_DY->GetValue()), + (Group2->SpinBox_DZ->GetValue()), + aList ); } else if ( anId == 2 ) { @@ -593,9 +631,13 @@ bool OperationGUI_FilletDlg::execute( ObjectList& objects ) for ( int i = 1, n = myFaces.Extent(); i <= n; i++ ) aList[ i - 1 ] = myFaces( i ); - - anObj = GEOM::GEOM_ILocalOperations::_narrow( - getOperation() )->MakeFilletFaces( myShape, getRadius(), aList ); + if ( Group3->RadioButton1->isChecked() ) + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeFilletFaces( myShape, getRadius(), aList ); + else + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeFilletFacesR1R2( myShape, (Group3->SpinBox_DY->GetValue()), + (Group3->SpinBox_DZ->GetValue()), aList ); } if ( !anObj->_is_nil() ) @@ -615,3 +657,26 @@ double OperationGUI_FilletDlg::getRadius() const else if ( anId == 1 ) return Group2->SpinBox_DX->GetValue(); else return Group3->SpinBox_DX->GetValue(); } + +//================================================================================= +// function : RadiobuttonClicked +// purpose : +//================================================================================= + +void OperationGUI_FilletDlg::RadioButton_Clicked() +{ + bool flag = ( (Group2->RadioButton1->isChecked()) && (Group3->RadioButton1->isChecked()) ); + flag = !flag; + + Group2->SpinBox_DX->setEnabled(flag); + Group2->SpinBox_DY->setEnabled(!flag); + Group2->SpinBox_DZ->setEnabled(!flag); + Group2->RadioButton1->setChecked(flag); + Group2->RadioButton2->setChecked(!flag); + Group3->SpinBox_DX->setEnabled(flag); + Group3->SpinBox_DY->setEnabled(!flag); + Group3->SpinBox_DZ->setEnabled(!flag); + Group3->RadioButton1->setChecked(flag); + Group3->RadioButton2->setChecked(!flag); + displayPreview(); +} diff --git a/src/OperationGUI/OperationGUI_FilletDlg.h b/src/OperationGUI/OperationGUI_FilletDlg.h index ab55f1469..c89491baf 100644 --- a/src/OperationGUI/OperationGUI_FilletDlg.h +++ b/src/OperationGUI/OperationGUI_FilletDlg.h @@ -33,7 +33,7 @@ #include class DlgRef_1Sel1Spin; -class DlgRef_2Sel1Spin; +class DlgRef_2Sel3Spin2Rb; //================================================================================= // class : OperationGUI_FilletDlg @@ -62,6 +62,7 @@ private slots: void SetEditCurrentArgument(); void ValueChangedInSpinBox( double newValue ); void ConstructorsClicked( int constructorId ); + void RadioButton_Clicked(); private: void Init(); @@ -80,8 +81,8 @@ private: TColStd_IndexedMapOfInteger myFaces; DlgRef_1Sel1Spin* Group1; - DlgRef_2Sel1Spin* Group2; - DlgRef_2Sel1Spin* Group3; + DlgRef_2Sel3Spin2Rb* Group2; + DlgRef_2Sel3Spin2Rb* Group3; }; #endif // DIALOGBOX_FILLET_H