Add an Angle option in the cylinder primitive in order to build portion of cylinders in both constructors.

This commit is contained in:
Florian Brunet 2014-08-05 14:42:10 +02:00
parent 8325f0f6ba
commit 8f2784ea72
19 changed files with 347 additions and 62 deletions

View File

@ -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

View File

@ -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,

View File

@ -1335,6 +1335,11 @@
<inParameter-type>double</inParameter-type>
<inParameter-comment>unknown</inParameter-comment>
</inParameter>
<inParameter>
<inParameter-name>theAngle</inParameter-name>
<inParameter-type>double</inParameter-type>
<inParameter-comment>unknown</inParameter-comment>
</inParameter>
</inParameter-list>
<outParameter-list>
<outParameter>
@ -1362,6 +1367,11 @@
<inParameter-type>double</inParameter-type>
<inParameter-comment>unknown</inParameter-comment>
</inParameter>
<inParameter>
<inParameter-name>theAngle</inParameter-name>
<inParameter-type>double</inParameter-type>
<inParameter-comment>unknown</inParameter-comment>
</inParameter>
</inParameter-list>
<outParameter-list>
<outParameter>

View File

@ -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

View File

@ -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
//////////////////////////////////////////

View File

@ -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
//////////////////////////////////////////

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgRef_3Spin1CheckCyl_QTD</class>
<widget class="QWidget" name="DlgRef_3Spin1CheckCyl_QTD">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<height>154</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="GroupBox1">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string/>
</property>
<layout class="QGridLayout" columnstretch="0,0,0,0" columnminimumwidth="0,0,0,280">
<property name="margin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="2" column="1">
<widget class="QLabel" name="TextLabel3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TL3</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="TextLabel2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TL2</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="TextLabel1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TL1</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX"/>
</item>
<item row="1" column="3">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DY"/>
</item>
<item row="2" column="3">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DZ"/>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>CB</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>SalomeApp_DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global">SalomeApp_DoubleSpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>SpinBox_DX</tabstop>
<tabstop>SpinBox_DY</tabstop>
<tabstop>SpinBox_DZ</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -76,6 +76,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();
aV = gp::DZ();
@ -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()));
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");
}
TopoDS_Shape aShape = MC.Shape();
aShape = MC.Shape();
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);

View File

@ -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;

View File

@ -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,

View File

@ -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
{
@ -43,6 +46,10 @@ class GEOMImpl_ICylinder
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); }
Handle(GEOM_Function) GetPoint() { return _func->GetReference(CYL_ARG_PNT); }

View File

@ -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();

View File

@ -69,12 +69,14 @@ 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,

View File

@ -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;
}

View File

@ -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,

View File

@ -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")

View File

@ -70,19 +70,25 @@ 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);
@ -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,11 +158,16 @@ 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"));
setConstructorId(1); // simplest constructor
@ -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();
}
}

View File

@ -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