From: vsr Date: Wed, 13 Aug 2014 13:34:03 +0000 (+0400) Subject: 0022667: EDF 7375 GEOM: Add angle argument to « Create cylinder » function. X-Git-Tag: V7_5_0a1~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ccf1c3dfbc834b67c3c955c8a0aeaeb226aa3a3d;p=modules%2Fgeom.git 0022667: EDF 7375 GEOM: Add angle argument to « Create cylinder » function. Minor corrections to initial implementation. --- diff --git a/doc/salome/examples/primitives_ex02.py b/doc/salome/examples/primitives_ex02.py index a0e73ff5f..82cf5e449 100644 --- a/doc/salome/examples/primitives_ex02.py +++ b/doc/salome/examples/primitives_ex02.py @@ -1,46 +1,49 @@ # Creation of a Cylinder +import math + import salome salome.salome_init() import GEOM from salome.geom import geomBuilder geompy = geomBuilder.New(salome.myStudy) -import math gg = salome.ImportComponentGUI("GEOM") # create a vertex and a vector p1 = geompy.MakeVertex(25, 35, 45) p2 = geompy.MakeVertex(70, 70, 70) -v = geompy.MakeVector(p1, p2) +v = geompy.MakeVector(p1, p2) # create cylinders -height = 40 - +height = 40 radius1 = 15 +radius2 = 30 +angle1 = 45. * math.pi / 180. +angle2 = 210. * math.pi / 180. + cylinder1 = geompy.MakeCylinder(p1, v, radius1, height) -angle1 = 45.*math.pi / 180. -cylinder1a = geompy.MakeCylinderA(p1, v, radius1, height, angle1) -geompy.TranslateDXDYDZ(cylinder1a,80.,0.,0.) -radius2 = 30 cylinder2 = geompy.MakeCylinderRH(radius2, height) -angle2 = 210.*math.pi / 180. -cylinder2a = geompy.MakeCylinderRHA(radius2, height, angle2) -geompy.TranslateDXDYDZ(cylinder2a,80.,0.,0.) + +cylinder3 = geompy.MakeCylinderA(p1, v, radius1, height, angle1) +geompy.TranslateDXDYDZ(cylinder3, 80., 0., 0.) + +cylinder4 = geompy.MakeCylinderRHA(radius2, height, angle2) +geompy.TranslateDXDYDZ(cylinder4, 80., 0., 0.) # add objects in the study id_cylinder1 = geompy.addToStudy(cylinder1,"Cylinder1") id_cylinder2 = geompy.addToStudy(cylinder2,"Cylinder2") -id_cylinder1a = geompy.addToStudy(cylinder1a,"Cylinder1a") -id_cylinder2a = geompy.addToStudy(cylinder2a,"Cylinder2a") +id_cylinder3 = geompy.addToStudy(cylinder3,"Cylinder3") +id_cylinder4 = geompy.addToStudy(cylinder4,"Cylinder4") # display the cylinders gg.createAndDisplayGO(id_cylinder1) gg.setDisplayMode(id_cylinder1,1) gg.createAndDisplayGO(id_cylinder2) gg.setDisplayMode(id_cylinder2,1) -gg.createAndDisplayGO(id_cylinder1a) -gg.setDisplayMode(id_cylinder1a,1) -gg.createAndDisplayGO(id_cylinder2a) -gg.setDisplayMode(id_cylinder2a,1) +gg.createAndDisplayGO(id_cylinder3) +gg.setDisplayMode(id_cylinder3,1) +gg.createAndDisplayGO(id_cylinder4) +gg.setDisplayMode(id_cylinder4,1) diff --git a/doc/salome/gui/GEOM/input/creating_cylinder.doc b/doc/salome/gui/GEOM/input/creating_cylinder.doc index 49f19bf64..d2c9f78e3 100644 --- a/doc/salome/gui/GEOM/input/creating_cylinder.doc +++ b/doc/salome/gui/GEOM/input/creating_cylinder.doc @@ -10,29 +10,32 @@ Entity - > Primitives - > Cylinder \n Firstly, you can define a \b Cylinder by the Base Point (the central point of the cylinder base), the \b Vector (the axis of the cylinder), -and its dimensions: the Radius and the Height. +and its dimensions: the \b Radius and the \b Height. Also, you can optionally specify +the \b Angle in order to create a portion of cylinder. + \n TUI Command: geompy.MakeCylinder(Point, Axis, Radius, Height) \n Arguments: Name + 1 vertex + 1 vector + 2 values (Dimensions: radius and height). -\n \b Angle checkbox and field allow defining an angle to create a portion of cylinder. \n TUI Command: geompy.MakeCylinderA(Point, Axis, Radius, Height, Angle) \n Arguments: Name + 1 vertex + 1 vector + 3 values (Dimensions: radius, height and angle). \image html cylinder1.png -\n Secondly, you can define a \b Cylinder by the given radius and the -height at the origin of coordinate system. The axis of the cylinder -will be collinear to the OZ axis of the coordinate system. +\n Secondly, you can define a \b Cylinder by the given \b Radius and +\b Height at the origin of coordinate system. The axis of the cylinder +will be collinear to the OZ axis of the coordinate system. +Similarly to first constructor, you can optionally specify the \b Angle +in order to create a portion of cylinder. + \n TUI Command: geompy.MakeCylinderRH(Radius, Height) \n Arguments: Name + 2 values (Dimensions at origin: radius and height). -\n \b Angle checkbox and field allow defining an angle to create a portion of cylinder at the origin of coordinate system. \n TUI Command: geompy.MakeCylinderRHA(Radius, Height, Angle) \n Arguments: Name + 3 values -(Dimensions at origin : radius, height and angle). +(Dimensions at origin: radius, height and angle). \image html cylinder2.png diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index c1e4b2c5c..86b959374 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1,4 +1,4 @@ -// // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -1494,7 +1494,7 @@ module GEOM GEOM_Object MakeCylinderRHA (in double theR, in double theH, in double theA); /*! - * \brief Create a cylinder with given base point, axis, radius, height and angle. + * \brief Create a cylinder with given base point, axis, radius and height. * \param thePnt Central point of cylinder base. * \param theAxis Cylinder axis. * \param theR Cylinder radius. @@ -1518,7 +1518,7 @@ module GEOM in GEOM_Object theAxis, in double theR, in double theH, - in double theA); + 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 3c5972437..7787ff4cc 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -162,13 +162,13 @@ module GEOM GEOM_Object MakeCylinderRH (in double theR, in double theH) ; GEOM_Object MakeCylinderPntVecRHA (in GEOM_Object thePnt, - in GEOM_Object theAxis, - in double theRadius, - in double theHeight, - in double theAngle) ; + in GEOM_Object theAxis, + in double theRadius, + in double theHeight, + in double theAngle) ; GEOM_Object MakeCylinderRHA (in double theR, - in double theH, - in double theA) ; + 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 db3ec4288..7ac41f313 100644 --- a/resources/GEOMCatalog.xml.in +++ b/resources/GEOMCatalog.xml.in @@ -1372,7 +1372,7 @@ - + MakeCylinderPntVecRHA @@ -1399,7 +1399,7 @@ double unknown - + theAngle double unknown @@ -1431,7 +1431,7 @@ double unknown - + theA double unknown diff --git a/src/DlgRef/DlgRef_2Sel3Spin1Check_QTD.ui b/src/DlgRef/DlgRef_2Sel3Spin1Check_QTD.ui index d652b9a90..07489104b 100644 --- a/src/DlgRef/DlgRef_2Sel3Spin1Check_QTD.ui +++ b/src/DlgRef/DlgRef_2Sel3Spin1Check_QTD.ui @@ -180,6 +180,9 @@ PushButton2 LineEdit2 SpinBox_DX + SpinBox_DY + SpinBox_DZ + checkBox diff --git a/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui b/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui index 1747f8d5c..7307c920b 100644 --- a/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui +++ b/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui @@ -117,6 +117,7 @@ SpinBox_DX SpinBox_DY SpinBox_DZ + checkBox diff --git a/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx index 42dd86b7c..3c91625b3 100644 --- a/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx @@ -109,37 +109,36 @@ Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const if (aCI.GetH() < 0.0) aV.Reverse(); gp_Ax2 anAxes (aP, aV); - bool switchAngleVar; - if(aType == CYLINDER_R_H || aType == CYLINDER_PNT_VEC_R_H) switchAngleVar = false; - else if(aType == CYLINDER_R_H_A || aType == CYLINDER_PNT_VEC_R_H_A) switchAngleVar = true; - else return 0; + TopoDS_Shape aShape; - switch (switchAngleVar) { - case false: - { - 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"); + switch (aType) { + case CYLINDER_R_H: + case CYLINDER_PNT_VEC_R_H: + { + 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"); + } + aShape = MC.Shape(); + break; } - aShape = MC.Shape(); - break; - } - case true: - { - BRepPrimAPI_MakeCylinder MCA (anAxes, aCI.GetR(), Abs(aCI.GetH()), aCI.GetA()); - MCA.Build(); - if (!MCA.IsDone()) { - StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters. Failure."); - return 0; + case CYLINDER_R_H_A: + case CYLINDER_PNT_VEC_R_H_A: + { + BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH()), aCI.GetA()); + MC.Build(); + if (!MC.IsDone()) { + StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters. Failure."); + } + aShape = MC.Shape(); + break; } - aShape = MCA.Shape(); - break; - } default: - return 0; + break; } + if (aShape.IsNull()) return 0; aFunction->SetValue(aShape); diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index f3f33f969..037b33560 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -646,8 +646,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO */ //============================================================================= Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, double theH, double theA) + Handle(GEOM_Object) theVec, + double theR, double theH, double theA) { SetErrorCode(KO); diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index 84a643afc..de227452e 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -50,17 +50,17 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { 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) MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, double theH); + Handle(GEOM_Object) theVec, + double theR, double theH); Standard_EXPORT Handle(GEOM_Object) MakeCylinderRHA (double theR, double theH, double theA); Standard_EXPORT Handle(GEOM_Object) MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, double theH, double theA); + Handle(GEOM_Object) theVec, + 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, - Handle(GEOM_Object) theVec, - double theR1, double theR2, double theH); + Handle(GEOM_Object) theVec, + double theR1, double theR2, double theH); Standard_EXPORT Handle(GEOM_Object) MakeSphereR (double theR); Standard_EXPORT Handle(GEOM_Object) MakeSpherePntR (Handle(GEOM_Object) thePnt, double theR); @@ -68,8 +68,8 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeTorusRR (double theRMajor, double theRMinor); Standard_EXPORT Handle(GEOM_Object) MakeTorusPntVecRR (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theRMajor, double theRMinor); + Handle(GEOM_Object) theVec, + double theRMajor, double theRMinor); Standard_EXPORT Handle(GEOM_Object) MakePrismVecH (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theVec, diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index 5f01b7c91..ef874e824 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -267,8 +267,8 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double th */ //============================================================================= GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRHA (CORBA::Double theR, - CORBA::Double theH, - CORBA::Double theA) + CORBA::Double theH, + CORBA::Double theA) { GEOM::GEOM_Object_var aGEOMObject; diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index f78e1c089..56c1cbc7b 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -77,14 +77,14 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : CORBA::Double theH); GEOM::GEOM_Object_ptr MakeCylinderRHA (CORBA::Double theR, - CORBA::Double theH, - CORBA::Double theA); + CORBA::Double theH, + CORBA::Double theA); GEOM::GEOM_Object_ptr MakeCylinderPntVecRHA (GEOM::GEOM_Object_ptr thePnt, - GEOM::GEOM_Object_ptr theVec, - CORBA::Double theR, - CORBA::Double theH, - CORBA::Double theA); + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR, + CORBA::Double theH, + CORBA::Double theA); GEOM::GEOM_Object_ptr MakeConeR1R2H (CORBA::Double theR1, CORBA::Double theR2, diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 801ea5e70..de9ef8b3d 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -1077,10 +1077,10 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderRH (CORBA::Double theR, // MakeCylinderPntVecRHA: //============================================================================= GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderPntVecRHA (GEOM::GEOM_Object_ptr thePnt, - GEOM::GEOM_Object_ptr theAxis, - CORBA::Double theRadius, - CORBA::Double theHeight, - CORBA::Double theAngle) + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theRadius, + CORBA::Double theHeight, + CORBA::Double theAngle) { beginService( " GEOM_Superv_i::MakeCylinderPntVecRHA" ); MESSAGE("GEOM_Superv_i::MakeCylinderPntVecRHA"); @@ -1094,8 +1094,8 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderPntVecRHA (GEOM::GEOM_Object_pt // MakeCylinderRHA: //============================================================================= GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderRHA (CORBA::Double theR, - CORBA::Double theH, - CORBA::Double theA) + CORBA::Double theH, + CORBA::Double theA) { beginService( " GEOM_Superv_i::MakeCylinderRHA" ); MESSAGE("GEOM_Superv_i::MakeCylinderRHA"); diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 4d827589e..708a0dab6 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -247,13 +247,13 @@ public: GEOM::GEOM_Object_ptr MakeCylinderRH (CORBA::Double theR, CORBA::Double theH); GEOM::GEOM_Object_ptr MakeCylinderPntVecRHA (GEOM::GEOM_Object_ptr thePnt, - GEOM::GEOM_Object_ptr theAxis, - CORBA::Double theRadius, - CORBA::Double theHeight, - CORBA::Double theAngle); + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theRadius, + CORBA::Double theHeight, + CORBA::Double theAngle); GEOM::GEOM_Object_ptr MakeCylinderRHA (CORBA::Double theR, - CORBA::Double theH, - CORBA::Double theA); + 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/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 62eec35c8..b644c196b 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -147,20 +147,20 @@ def TestAll (geompy, math): tan_on_face = geompy.MakeTangentPlaneOnFace(tan_extrusion, 0.7, 0.5, 150) #Create base geometry 3D - Box = geompy.MakeBoxTwoPnt(p0, p200) #(2 GEOM_Object)->GEOM_Object - Box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) #(3 Doubles)->GEOM_Object - Box2 = geompy.MakeBox(10,20,30, 15,25,35) #(6 Doubles)->GEOM_Object - Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(2 GEOM_Object, 2 Doubles)->GEOM_Object - Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object - Cylinder1= geompy.MakeCylinderA(p0, vz, radius1, height,angle1) #(2 GEOM_Object, 2 Doubles)->GEOM_Object - Cyl2 = geompy.MakeCylinderRHA(radius2, height,angle2) #(2 Doubles)->GEOM_Object - Sphere = geompy.MakeSpherePntR(p0, radius1) #(GEOM_Object, Double)->GEOM_Object - Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object - Sphere2 = geompy.MakeSphere(50, 70, 30, radius) #(4 Doubles)->GEOM_Object - Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(2 GEOM_Object, 3 Doubles)->GEOM_Object - Cone1 = geompy.MakeConeR1R2H(radius1, radius, height) #(3 Doubles)->GEOM_Object - Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(2 GEOM_Object, 2 Doubles)->GEOM_Object - Torus1 = geompy.MakeTorusRR(radius2, radius1) #(2 Doubles)->GEOM_Object + Box = geompy.MakeBoxTwoPnt(p0, p200) #(2 GEOM_Object)->GEOM_Object + Box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) #(3 Doubles)->GEOM_Object + Box2 = geompy.MakeBox(10,20,30, 15,25,35) #(6 Doubles)->GEOM_Object + Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(2 GEOM_Object, 2 Doubles)->GEOM_Object + Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object + Cylinder1= geompy.MakeCylinderA(p0, vz, radius1, height, angle1) #(2 GEOM_Object, 3 Doubles)->GEOM_Object + Cyl2 = geompy.MakeCylinderRHA(radius2, height, angle2) #(3 Doubles)->GEOM_Object + Sphere = geompy.MakeSpherePntR(p0, radius1) #(GEOM_Object, Double)->GEOM_Object + Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object + Sphere2 = geompy.MakeSphere(50, 70, 30, radius) #(4 Doubles)->GEOM_Object + Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(2 GEOM_Object, 3 Doubles)->GEOM_Object + Cone1 = geompy.MakeConeR1R2H(radius1, radius, height) #(3 Doubles)->GEOM_Object + Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(2 GEOM_Object, 2 Doubles)->GEOM_Object + Torus1 = geompy.MakeTorusRR(radius2, radius1) #(2 Doubles)->GEOM_Object #Boolean (Common, Cut, Fuse, Section) Common = geompy.MakeBoolean(Box, Sphere, 1) #(2 GEOM_Object, Short)->GEOM_Object diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index 73e7c03fa..66333aa24 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -166,7 +166,7 @@ void PrimitiveGUI_CylinderDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); - connect(GroupPoints->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle())); + connect(GroupPoints->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle())); connect(GroupDimensions->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle())); initName(tr("GEOM_CYLINDER")); @@ -399,9 +399,10 @@ 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() ) && + ( !GroupPoints->checkBox->isChecked() || GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) ) && myPoint && myDir; - if(GroupPoints->SpinBox_DZ->value()<=0. || GroupPoints->SpinBox_DZ->value()>=360.) { + if ( GroupPoints->checkBox->isChecked() && + ( GroupPoints->SpinBox_DZ->value() <= 0. || GroupPoints->SpinBox_DZ->value() >= 360. ) ) { msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n"; ok = false; } @@ -410,10 +411,11 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg) { ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && - GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ); - if(GroupDimensions->SpinBox_DZ->value()<=0. || GroupDimensions->SpinBox_DZ->value()>=360.) { - msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n"; - ok = false; + ( GroupDimensions->checkBox->isChecked() || GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) ); + if ( GroupDimensions->checkBox->isChecked() && + ( GroupDimensions->SpinBox_DZ->value() <= 0. || GroupDimensions->SpinBox_DZ->value() >= 360. ) ) { + msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n"; + ok = false; } } ok = qAbs( getHeight() ) > Precision::Confusion() && ok; @@ -428,7 +430,6 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg) bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects) { bool res = false; - bool BAngle = false; GEOM::GEOM_Object_var anObj; @@ -436,27 +437,26 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: - BAngle = GroupPoints->checkBox->isChecked(); if ( myPoint && myDir ) { - if(!BAngle){ - anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight()); + if ( GroupPoints->checkBox->isChecked() ) { + anObj = anOper->MakeCylinderPntVecRHA(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()*M_PI/180.); 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; } - else if(BAngle){ - anObj = anOper->MakeCylinderPntVecRHA(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()*M_PI/180.); + else { + anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight()); 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; @@ -464,26 +464,25 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects) } break; case 1: - BAngle = GroupDimensions->checkBox->isChecked(); - if(!BAngle){ - anObj = anOper->MakeCylinderRH(getRadius(), getHeight()); + if ( GroupDimensions->checkBox->isChecked() ) { + anObj = anOper->MakeCylinderRHA(getRadius(), getHeight(), getAngle()*M_PI/180.); 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; } - else if(BAngle){ - anObj = anOper->MakeCylinderRHA(getRadius(), getHeight(), getAngle()*M_PI/180.); + else { + anObj = anOper->MakeCylinderRH(getRadius(), getHeight()); 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; diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h index b79316ba9..1a5ccc46b 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h @@ -77,7 +77,7 @@ private slots: void ConstructorsClicked( int ); void ValueChangedInSpinBox(); void SetDoubleSpinBoxStep( double ); - void ActivateAngle(); + void ActivateAngle(); }; #endif // PRIMITIVEGUI_CYLINDERDLG_H