From: Florian Brunet Date: Tue, 5 Aug 2014 12:42:10 +0000 (+0200) Subject: Add an Angle option in the cylinder primitive in order to build portion of cylinders... X-Git-Tag: V7_5_0a1~30^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8f2784ea72ee75d3f2574590031abee1db7565f1;p=modules%2Fgeom.git Add an Angle option in the cylinder primitive in order to build portion of cylinders in both constructors. --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index bbaafca6b..94fbc0acd 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1471,28 +1471,31 @@ module GEOM GEOM_Object MakeDiskR (in double theR, in short theOrientation); /*! - * \brief Create a cylinder with given radius and height at + * \brief Create a cylinder with given radius, height and angle (portion of cylinder) at * the origin of coordinate system. * * Axis of the cylinder will be collinear to the OZ axis of the coordinate system. * \param theR Cylinder radius. * \param theH Cylinder height. + * \param theA Cylinder angle. * \return New GEOM_Object, containing the created cylinder. */ - GEOM_Object MakeCylinderRH (in double theR, in double theH); + GEOM_Object MakeCylinderRH (in double theR, in double theH, in double theA); /*! - * \brief Create a cylinder with given base point, axis, radius and height. + * \brief Create a cylinder with given base point, axis, radius, height and angle (portion of cylinder). * \param thePnt Central point of cylinder base. * \param theAxis Cylinder axis. * \param theR Cylinder radius. * \param theH Cylinder height. + * \param theA Cylinder angle. * \return New GEOM_Object, containing the created cylinder. */ GEOM_Object MakeCylinderPntVecRH (in GEOM_Object thePnt, in GEOM_Object theAxis, in double theR, - in double theH); + in double theH, + in double theA); /*! * \brief Create a cone with given height and radiuses at diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 07f7fe92f..c56f0ca57 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -158,9 +158,11 @@ module GEOM GEOM_Object MakeCylinderPntVecRH (in GEOM_Object thePnt, in GEOM_Object theAxis, in double theRadius, - in double theHeight) ; + in double theHeight, + in double theAngle) ; GEOM_Object MakeCylinderRH (in double theR, - in double theH) ; + in double theH, + in double theA) ; GEOM_Object MakeSphere (in double theX, in double theY, in double theZ, diff --git a/resources/GEOMCatalog.xml.in b/resources/GEOMCatalog.xml.in index e9d665cd2..43438b5bd 100644 --- a/resources/GEOMCatalog.xml.in +++ b/resources/GEOMCatalog.xml.in @@ -1335,6 +1335,11 @@ double unknown + + theAngle + double + unknown + @@ -1362,6 +1367,11 @@ double unknown + + theAngle + double + unknown + diff --git a/src/DlgRef/CMakeLists.txt b/src/DlgRef/CMakeLists.txt index 3c365438f..632b2a328 100755 --- a/src/DlgRef/CMakeLists.txt +++ b/src/DlgRef/CMakeLists.txt @@ -75,6 +75,7 @@ SET(_uic_files DlgRef_2Sel2Spin2Push_QTD.ui DlgRef_2Sel2Spin3Check_QTD.ui DlgRef_2Sel2Spin_QTD.ui + DlgRef_2Sel3Spin1Check_QTD.ui DlgRef_2Sel3Spin2Rb_QTD.ui DlgRef_2Sel3Spin_QTD.ui DlgRef_2SelExt_QTD.ui @@ -92,6 +93,7 @@ SET(_uic_files DlgRef_3Sel4Spin2Check_QTD.ui DlgRef_3Sel_QTD.ui DlgRef_3Spin1Check_QTD.ui + DlgRef_3Spin1CheckCyl_QTD.ui DlgRef_3Spin_QTD.ui DlgRef_4Sel1List1Check_QTD.ui DlgRef_4Sel1List_QTD.ui diff --git a/src/DlgRef/DlgRef.cxx b/src/DlgRef/DlgRef.cxx index 9a6efd718..efeefa4c2 100644 --- a/src/DlgRef/DlgRef.cxx +++ b/src/DlgRef/DlgRef.cxx @@ -470,6 +470,20 @@ DlgRef_2Sel2Spin2Push::~DlgRef_2Sel2Spin2Push() { } +////////////////////////////////////////// +// DlgRef_2Sel3Spin1Check +////////////////////////////////////////// + +DlgRef_2Sel3Spin1Check::DlgRef_2Sel3Spin1Check( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); +} + +DlgRef_2Sel3Spin1Check::~DlgRef_2Sel3Spin1Check() +{ +} + ////////////////////////////////////////// // DlgRef_2Sel3Spin2Rb ////////////////////////////////////////// @@ -756,6 +770,20 @@ DlgRef_3Spin1Check::~DlgRef_3Spin1Check() { } +////////////////////////////////////////// +// DlgRef_3Spin1CheckCyl +////////////////////////////////////////// + +DlgRef_3Spin1CheckCyl::DlgRef_3Spin1CheckCyl( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); +} + +DlgRef_3Spin1CheckCyl::~DlgRef_3Spin1CheckCyl() +{ +} + ////////////////////////////////////////// // DlgRef_3Spin ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.h b/src/DlgRef/DlgRef.h index c68358d11..fb3c8e047 100644 --- a/src/DlgRef/DlgRef.h +++ b/src/DlgRef/DlgRef.h @@ -548,6 +548,22 @@ public: ~DlgRef_2Sel2Spin2Push(); }; +////////////////////////////////////////// +// DlgRef_2Sel3Spin1Check +////////////////////////////////////////// + +#include "ui_DlgRef_2Sel3Spin1Check_QTD.h" + +class DLGREF_EXPORT DlgRef_2Sel3Spin1Check : public QWidget, + public Ui::DlgRef_2Sel3Spin1Check_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel3Spin1Check( QWidget* = 0, Qt::WindowFlags = 0 ); + ~DlgRef_2Sel3Spin1Check(); +}; + ////////////////////////////////////////// // DlgRef_2Sel3Spin2Rb ////////////////////////////////////////// @@ -826,6 +842,22 @@ public: ~DlgRef_3Spin1Check(); }; +////////////////////////////////////////// +// DlgRef_3Spin1CheckCyl +////////////////////////////////////////// + +#include "ui_DlgRef_3Spin1CheckCyl_QTD.h" + +class DLGREF_EXPORT DlgRef_3Spin1CheckCyl : public QWidget, + public Ui::DlgRef_3Spin1CheckCyl_QTD +{ + Q_OBJECT + +public: + DlgRef_3Spin1CheckCyl( QWidget* = 0, Qt::WindowFlags = 0 ); + ~DlgRef_3Spin1CheckCyl(); +}; + ////////////////////////////////////////// // DlgRef_3Spin ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui b/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui new file mode 100644 index 000000000..1747f8d5c --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui @@ -0,0 +1,123 @@ + + + DlgRef_3Spin1CheckCyl_QTD + + + + 0 + 0 + 611 + 154 + + + + + + + + 0 + + + 0 + + + + + true + + + + + + + 9 + + + 6 + + + + + + 0 + 0 + + + + TL3 + + + false + + + + + + + + 0 + 0 + + + + TL2 + + + false + + + + + + + + 0 + 0 + + + + TL1 + + + false + + + + + + + + + + + + + + + + CB + + + + + + + + + + qPixmapFromMimeSource + + + SalomeApp_DoubleSpinBox + QDoubleSpinBox +
SalomeApp_DoubleSpinBox.h
+
+
+ + SpinBox_DX + SpinBox_DY + SpinBox_DZ + + + +
diff --git a/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx index 9f2d816ab..521d03678 100644 --- a/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx @@ -75,6 +75,8 @@ Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const gp_Pnt aP; gp_Vec aV; + + TopoDS_Shape aShape; if (aType == CYLINDER_R_H) { aP = gp::Origin(); @@ -109,14 +111,15 @@ Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const if (aCI.GetH() < 0.0) aV.Reverse(); gp_Ax2 anAxes (aP, aV); - - BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH())); - MC.Build(); - if (!MC.IsDone()) { - StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters"); - } - - TopoDS_Shape aShape = MC.Shape(); + aShape = BRepPrimAPI_MakeCylinder(anAxes, aCI.GetR(), Abs(aCI.GetH())).Shape(); + if(aCI.GetA() < 360. && aCI.GetA()> 0.){ + BRepPrimAPI_MakeCylinder MC(anAxes, aCI.GetR(), Abs(aCI.GetH()), aCI.GetA()*M_PI/180.); + MC.Build(); + if (!MC.IsDone()) { + StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters"); + } + aShape = MC.Shape(); + } if (aShape.IsNull()) return 0; aFunction->SetValue(aShape); diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 1e345fa04..f4139be06 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -488,7 +488,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theO * MakeCylinderRH */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH) +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH, double theA) { SetErrorCode(KO); @@ -506,6 +506,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, dou aCI.SetR(theR); aCI.SetH(theH); + aCI.SetA(theA); //Compute the Cylinder value try { @@ -525,7 +526,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, dou //Make a Python command GEOM::TPythonDump(aFunction) << aCylinder - << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")"; + << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ", " << theA << ")"; SetErrorCode(OK); return aCylinder; @@ -539,7 +540,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, dou //============================================================================= Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, - double theR, double theH) + double theR, double theH, double theA) { SetErrorCode(KO); @@ -567,6 +568,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO aCI.SetVector(aRefVec); aCI.SetR(theR); aCI.SetH(theH); + aCI.SetA(theA); //Compute the Cylinder value try { @@ -586,7 +588,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO //Make a Python command GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder(" - << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")"; + << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA << ")"; SetErrorCode(OK); return aCylinder; diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index 36d0ac6b2..d0ae75588 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -48,10 +48,10 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Handle(GEOM_Object) theVec, double theR); Standard_EXPORT Handle(GEOM_Object) MakeDiskR (double theR, int theOrientation); - Standard_EXPORT Handle(GEOM_Object) MakeCylinderRH (double theR, double theH); + Standard_EXPORT Handle(GEOM_Object) MakeCylinderRH (double theR, double theH, double theA); Standard_EXPORT Handle(GEOM_Object) MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, - double theR, double theH); + double theR, double theH, double theA); Standard_EXPORT Handle(GEOM_Object) MakeConeR1R2H (double theR1, double theR2, double theH); Standard_EXPORT Handle(GEOM_Object) MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt, diff --git a/src/GEOMImpl/GEOMImpl_ICylinder.hxx b/src/GEOMImpl/GEOMImpl_ICylinder.hxx index f13ac7760..0955df29c 100644 --- a/src/GEOMImpl/GEOMImpl_ICylinder.hxx +++ b/src/GEOMImpl/GEOMImpl_ICylinder.hxx @@ -24,10 +24,13 @@ // #include "GEOM_Function.hxx" -#define CYL_ARG_R 1 -#define CYL_ARG_H 2 -#define CYL_ARG_PNT 3 -#define CYL_ARG_VEC 4 +#define CYL_ARG_PNT 1 +#define CYL_ARG_VEC 2 +#define CYL_ARG_R 3 +#define CYL_ARG_H 4 +#define CYL_ARG_A 5 + + class GEOMImpl_ICylinder { @@ -42,6 +45,10 @@ class GEOMImpl_ICylinder void SetH(double theH) { _func->SetReal(CYL_ARG_H, theH); } double GetH() { return _func->GetReal(CYL_ARG_H); } + + void SetA(double theA) { _func->SetReal(CYL_ARG_A, theA); } + + double GetA() { return _func->GetReal(CYL_ARG_A); } void SetPoint(Handle(GEOM_Function) theRefPoint) { _func->SetReference(CYL_ARG_PNT, theRefPoint); } diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 4f4792448..57093b4e6 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -205,8 +205,8 @@ #define DISK_THREE_PNT 2 #define DISK_R 3 -#define CYLINDER_R_H 1 -#define CYLINDER_PNT_VEC_R_H 2 +#define CYLINDER_R_H 1 +#define CYLINDER_PNT_VEC_R_H 2 #define CONE_R1_R2_H 1 #define CONE_PNT_VEC_R1_R2_H 2 diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index 2d1960361..68dc79279 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -246,7 +246,8 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDiskR (CORBA::Double theR, */ //============================================================================= GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double theR, - CORBA::Double theH) + CORBA::Double theH, + CORBA::Double theA) { GEOM::GEOM_Object_var aGEOMObject; @@ -254,7 +255,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double th GetOperations()->SetNotDone(); //Create the Cylinder - Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderRH(theR, theH); + Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderRH(theR, theH, theA); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -268,7 +269,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double th //============================================================================= GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec, - CORBA::Double theR, CORBA::Double theH) + CORBA::Double theR, CORBA::Double theH, CORBA::Double theA) { GEOM::GEOM_Object_var aGEOMObject; @@ -282,7 +283,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); //Create the Cylinder - Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderPntVecRH(aPnt, aVec, theR, theH); + Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderPntVecRH(aPnt, aVec, theR, theH, theA); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index a47518821..63d5fa4be 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -69,13 +69,15 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : CORBA::Short theOrientation); GEOM::GEOM_Object_ptr MakeCylinderRH (CORBA::Double theR, - CORBA::Double theH); - + CORBA::Double theH, + CORBA::Double theA); + GEOM::GEOM_Object_ptr MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec, CORBA::Double theR, - CORBA::Double theH); - + CORBA::Double theH, + CORBA::Double theA); + GEOM::GEOM_Object_ptr MakeConeR1R2H (CORBA::Double theR1, CORBA::Double theR2, CORBA::Double theH); diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 792cbe5ae..d70656378 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -1049,12 +1049,13 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeDiskR (CORBA::Double theR, GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theAxis, CORBA::Double theRadius, - CORBA::Double theHeight) + CORBA::Double theHeight, + CORBA::Double theAngle) { beginService( " GEOM_Superv_i::MakeCylinderPntVecRH" ); MESSAGE("GEOM_Superv_i::MakeCylinderPntVecRH"); get3DPrimOp(); - GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeCylinderPntVecRH(thePnt, theAxis, theRadius, theHeight); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeCylinderPntVecRH(thePnt, theAxis, theRadius, theHeight, theAngle); endService( " GEOM_Superv_i::MakeCylinderPntVecRH" ); return anObj; } @@ -1063,12 +1064,13 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr // MakeCylinderRH: //============================================================================= GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderRH (CORBA::Double theR, - CORBA::Double theH) + CORBA::Double theH, + CORBA::Double theA) { beginService( " GEOM_Superv_i::MakeCylinderRH" ); MESSAGE("GEOM_Superv_i::MakeCylinderRH"); get3DPrimOp(); - GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeCylinderRH(theR, theH); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeCylinderRH(theR, theH, theA); endService( " GEOM_Superv_i::MakeCylinderRH" ); return anObj; } diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 8058cc132..627be4797 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -243,9 +243,11 @@ public: GEOM::GEOM_Object_ptr MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theAxis, CORBA::Double theRadius, - CORBA::Double theHeight); + CORBA::Double theHeight, + CORBA::Double theAngle); GEOM::GEOM_Object_ptr MakeCylinderRH (CORBA::Double theR, - CORBA::Double theH); + CORBA::Double theH, + CORBA::Double theA); GEOM::GEOM_Object_ptr MakeSphere (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ, diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 925e2d72e..3f6c012d8 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -2969,11 +2969,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(anObj, theName, "disk") return anObj - ## Create a cylinder with given base point, axis, radius and height. + ## Create a cylinder with given base point, axis, radius, height and angle (for a portion of cylinder). # @param thePnt Central point of cylinder base. # @param theAxis Cylinder axis. # @param theR Cylinder radius. # @param theH Cylinder height. + # @param theA Cylinder angle in radian. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. @@ -2982,15 +2983,16 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_creation_cylinder "Example" @ManageTransactions("PrimOp") - def MakeCylinder(self, thePnt, theAxis, theR, theH, theName=None): + def MakeCylinder(self, thePnt, theAxis, theR, theH, theA=2*math.pi, theName=None): """ - Create a cylinder with given base point, axis, radius and height. + Create a cylinder with given base point, axis, radius, height and angle (for a portion of cylinder). Parameters: thePnt Central point of cylinder base. theAxis Cylinder axis. theR Cylinder radius. theH Cylinder height. + theA Cylinder angle in radian. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. @@ -2999,18 +3001,20 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the created cylinder. """ # Example: see GEOM_TestAll.py - theR,theH,Parameters = ParseParameters(theR, theH) - anObj = self.PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH) + theR,theH,theA,Parameters = ParseParameters(theR, theH, theA) + anObj = self.PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH, theA) + RaiseIfFailed("MakeCylinderPntVecRH", self.PrimOp) anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "cylinder") return anObj - ## Create a cylinder with given radius and height at + ## Create a cylinder with given radius, height and angle (for a portion of cylinder) at # the origin of coordinate system. Axis of the cylinder # will be collinear to the OZ axis of the coordinate system. # @param theR Cylinder radius. # @param theH Cylinder height. + # @param theA Cylinder angle in radian. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. @@ -3019,15 +3023,16 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_creation_cylinder "Example" @ManageTransactions("PrimOp") - def MakeCylinderRH(self, theR, theH, theName=None): + def MakeCylinderRH(self, theR, theH, theA=2*math.pi, theName=None): """ - Create a cylinder with given radius and height at + Create a cylinder with given radius, height and angle (for a portion of cylinder)at the origin of coordinate system. Axis of the cylinder will be collinear to the OZ axis of the coordinate system. Parameters: theR Cylinder radius. theH Cylinder height. + theA Cylinder angle in radian. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. @@ -3036,8 +3041,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the created cylinder. """ # Example: see GEOM_TestAll.py - theR,theH,Parameters = ParseParameters(theR, theH) - anObj = self.PrimOp.MakeCylinderRH(theR, theH) + theR,theH,theA,Parameters = ParseParameters(theR, theH, theA) + anObj = self.PrimOp.MakeCylinderRH(theR, theH, theA) + RaiseIfFailed("MakeCylinderRH", self.PrimOp) anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "cylinder") diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index e27701c60..e12b35a35 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -70,20 +70,26 @@ PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg (GeometryGUI* theGeometryGUI, mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->close(); - GroupPoints = new DlgRef_2Sel2Spin(centralWidget()); + GroupPoints = new DlgRef_2Sel3Spin1Check(centralWidget()); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); GroupPoints->TextLabel1->setText(tr("GEOM_BASE_POINT")); GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS")); GroupPoints->TextLabel4->setText(tr("GEOM_HEIGHT")); + GroupPoints->TextLabel5->setText(tr("GEOM_ANGLE")); + GroupPoints->checkBox->setText(tr("")); GroupPoints->PushButton1->setIcon(image2); GroupPoints->PushButton2->setIcon(image2); + GroupPoints->SpinBox_DZ->setDisabled(true); - GroupDimensions = new DlgRef_2Spin(centralWidget()); + GroupDimensions = new DlgRef_3Spin1CheckCyl(centralWidget()); GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ")); GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS")); GroupDimensions->TextLabel2->setText(tr("GEOM_HEIGHT")); - + GroupDimensions->TextLabel3->setText(tr("GEOM_ANGLE")); + GroupDimensions->checkBox->setText(tr("")); + GroupDimensions->SpinBox_DZ->setDisabled(true); + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); layout->setMargin(0); layout->setSpacing(6); layout->addWidget(GroupPoints); @@ -117,8 +123,11 @@ void PrimitiveGUI_CylinderDlg::Init() // min, max, step and decimals for spin boxes & initial values initSpinBox(GroupPoints->SpinBox_DX, 0.00001, COORD_MAX, step, "length_precision" ); initSpinBox(GroupPoints->SpinBox_DY, 0.00001, COORD_MAX, step, "length_precision" ); + initSpinBox(GroupPoints->SpinBox_DZ, 0.00001, 360., step, "length_precision" ); initSpinBox(GroupDimensions->SpinBox_DX, 0.00001, COORD_MAX, step, "length_precision" ); initSpinBox(GroupDimensions->SpinBox_DY, 0.00001, COORD_MAX, step, "length_precision" ); + initSpinBox(GroupDimensions->SpinBox_DZ, 0.00001, 360., step, "length_precision" ); + // init variables myEditCurrentArgument = GroupPoints->LineEdit1; @@ -130,11 +139,13 @@ void PrimitiveGUI_CylinderDlg::Init() myPoint.nullify(); myDir.nullify(); - double aRadius(100.0), aHeight(300.0); + double aRadius(100.0), aHeight(300.0), aAngle(360.); GroupPoints->SpinBox_DX->setValue(aRadius); GroupPoints->SpinBox_DY->setValue(aHeight); + GroupPoints->SpinBox_DZ->setValue(aAngle); GroupDimensions->SpinBox_DX->setValue(aRadius); GroupDimensions->SpinBox_DY->setValue(aHeight); + GroupDimensions->SpinBox_DZ->setValue(aAngle); // signals and slots connections connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -147,10 +158,15 @@ void PrimitiveGUI_CylinderDlg::Init() connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); + + connect(GroupPoints->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle())); + connect(GroupDimensions->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle())); initName(tr("GEOM_CYLINDER")); @@ -166,8 +182,10 @@ void PrimitiveGUI_CylinderDlg::SetDoubleSpinBoxStep (double step) { GroupPoints->SpinBox_DX->setSingleStep(step); GroupPoints->SpinBox_DY->setSingleStep(step); + GroupPoints->SpinBox_DZ->setSingleStep(step); GroupDimensions->SpinBox_DX->setSingleStep(step); GroupDimensions->SpinBox_DY->setSingleStep(step); + GroupDimensions->SpinBox_DZ->setSingleStep(step); } //================================================================================= @@ -378,14 +396,17 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg) { ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) && myPoint && myDir; } else if( getConstructorId() == 1 ) { ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && - GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ); + GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ); } ok = qAbs( getHeight() ) > Precision::Confusion() && ok; + ok = qAbs( getRadius() ) > Precision::Confusion() && ok; return ok; } @@ -396,32 +417,38 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg) bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects) { bool res = false; - + bool BAngle = false; GEOM::GEOM_Object_var anObj; GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); switch (getConstructorId()) { case 0: + BAngle = GroupPoints->checkBox->isChecked(); if ( myPoint && myDir ) { - anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight()); + if(!BAngle) anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight(), 360.); + else anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()); if (!anObj->_is_nil() && !IsPreview()) { QStringList aParameters; aParameters << GroupPoints->SpinBox_DX->text(); aParameters << GroupPoints->SpinBox_DY->text(); + aParameters << GroupPoints->SpinBox_DZ->text(); anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } res = true; } break; case 1: - anObj = anOper->MakeCylinderRH(getRadius(), getHeight()); + BAngle = GroupDimensions->checkBox->isChecked(); + if(!BAngle)anObj = anOper->MakeCylinderRH(getRadius(), getHeight(), 360.); + else anObj = anOper->MakeCylinderRH(getRadius(), getHeight(), getAngle()); if (!anObj->_is_nil() && !IsPreview()) { QStringList aParameters; aParameters << GroupDimensions->SpinBox_DX->text(); aParameters << GroupDimensions->SpinBox_DY->text(); + aParameters << GroupDimensions->SpinBox_DZ->text(); anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } res = true; @@ -462,6 +489,20 @@ double PrimitiveGUI_CylinderDlg::getHeight() const return 0; } +//================================================================================= +// function : getAngle() +// purpose : +//================================================================================= +double PrimitiveGUI_CylinderDlg::getAngle() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DZ->value(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DZ->value(); + return 0; +} + //================================================================================= // function : addSubshapeToStudy // purpose : virtual method to add new SubObjects if local selection @@ -473,3 +514,20 @@ void PrimitiveGUI_CylinderDlg::addSubshapesToStudy() GEOMBase::PublishSubObject( myDir.get() ); } } + +//================================================================================= +// function : ActivateAngle() +// purpose : enable the +//================================================================================= +void PrimitiveGUI_CylinderDlg::ActivateAngle() +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0){ + GroupPoints->SpinBox_DZ->setEnabled( GroupPoints->checkBox->isChecked() ); + processPreview(); + } + else if (aConstructorId == 1){ + GroupDimensions->SpinBox_DZ->setEnabled( GroupDimensions->checkBox->isChecked() ); + processPreview(); + } +} \ No newline at end of file diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h index 6514d87a8..b79316ba9 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h @@ -30,8 +30,8 @@ #include "GEOMBase_Skeleton.h" #include "GEOM_GenericObjPtr.h" -class DlgRef_2Sel2Spin; -class DlgRef_2Spin; +class DlgRef_2Sel3Spin1Check; +class DlgRef_3Spin1CheckCyl; //================================================================================= // class : PrimitiveGUI_CylinderDlg @@ -57,6 +57,7 @@ private: void enterEvent( QEvent* ); double getRadius() const; double getHeight() const; + double getAngle() const; private: GEOM::GeomObjPtr myPoint, myDir; @@ -64,8 +65,8 @@ private: // to initialize the first selection field with a selected object on the dialog creation bool myInitial; - DlgRef_2Sel2Spin* GroupPoints; - DlgRef_2Spin* GroupDimensions; + DlgRef_2Sel3Spin1Check* GroupPoints; + DlgRef_3Spin1CheckCyl* GroupDimensions; private slots: void ClickOnOk(); @@ -76,6 +77,7 @@ private slots: void ConstructorsClicked( int ); void ValueChangedInSpinBox(); void SetDoubleSpinBoxStep( double ); + void ActivateAngle(); }; #endif // PRIMITIVEGUI_CYLINDERDLG_H