From: dmv Date: Tue, 22 Jul 2008 07:20:59 +0000 (+0000) Subject: 0016756: EDF 545 GEOM : Extrusion, give the coordinates of the vector as input X-Git-Tag: V5_1_0a1~39 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2dbe613765884256942925d8a95293e3c473caec;p=modules%2Fgeom.git 0016756: EDF 545 GEOM : Extrusion, give the coordinates of the vector as input --- diff --git a/doc/salome/gui/GEOM/images/extrusion1.png b/doc/salome/gui/GEOM/images/extrusion1.png index c278fdf9e..4b0a70970 100755 Binary files a/doc/salome/gui/GEOM/images/extrusion1.png and b/doc/salome/gui/GEOM/images/extrusion1.png differ diff --git a/doc/salome/gui/GEOM/images/extrusion2.png b/doc/salome/gui/GEOM/images/extrusion2.png index f2037ffcd..404f1f357 100755 Binary files a/doc/salome/gui/GEOM/images/extrusion2.png and b/doc/salome/gui/GEOM/images/extrusion2.png differ diff --git a/doc/salome/gui/GEOM/images/extrusion3.png b/doc/salome/gui/GEOM/images/extrusion3.png new file mode 100644 index 000000000..26284b8dd Binary files /dev/null and b/doc/salome/gui/GEOM/images/extrusion3.png differ diff --git a/doc/salome/gui/GEOM/input/creating_extrusion.doc b/doc/salome/gui/GEOM/input/creating_extrusion.doc index 3f3435ca6..70cc6edb0 100644 --- a/doc/salome/gui/GEOM/input/creating_extrusion.doc +++ b/doc/salome/gui/GEOM/input/creating_extrusion.doc @@ -34,6 +34,16 @@ shell) serving as base object + 2 vertices. \image html extrusion2.png +\n Finally, you can define the \b Extrusion by the Base Shape +and the DX, DY, DZ Vector\n +Both Directions checkbox allows extruding the +source objects forward and backward also. +\n TUI Command: geompy.MakePrismDXDYDZ(Base, dx, dy, dz) +\n Arguments: Name + 1 shape (vertex, edge, planar wire, face or +shell) serving as base object + 3 axis directions. + +\image html extrusion3.png + Examples: \image html prisms_basessn.png diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 26a9368dc..311f9ea63 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -942,6 +942,18 @@ module GEOM GEOM_Object MakePrismTwoPnt2Ways (in GEOM_Object theBase, in GEOM_Object thePoint1, in GEOM_Object thePoint2); + + /*! + * Create a shape by extrusion of the base shape along a vector, defined by DX DY DZ. + * \param theBase Base shape to be extruded. + * \param DX, DY, DZ end of extrusion vector. + * \return New GEOM_Object, containing the created prism. + */ + GEOM_Object MakePrismDXDYDZ (in GEOM_Object theBase, + in double theDX, in double theDY, in double theDZ); + /* The same prism but in two directions forward&backward */ + GEOM_Object MakePrismDXDYDZ2Ways (in GEOM_Object theBase, + in double theDX, in double theDY, in double theDZ); /*! * Create a shape by extrusion of the base shape along diff --git a/resources/Makefile.am b/resources/Makefile.am index 5773224e3..bff974dee 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -119,6 +119,7 @@ point_line_intersection.png \ polyline.png \ prism.png \ prism2.png \ +prism3.png \ revol.png \ rotate.png \ rotatepnt.png \ diff --git a/src/DlgRef/DlgRef.cxx b/src/DlgRef/DlgRef.cxx index 434faf86e..b29fdee59 100644 --- a/src/DlgRef/DlgRef.cxx +++ b/src/DlgRef/DlgRef.cxx @@ -177,6 +177,20 @@ DlgRef_1Sel3Spin::~DlgRef_1Sel3Spin() { } +////////////////////////////////////////// +// DlgRef_1Sel3Spin1Check +////////////////////////////////////////// + +DlgRef_1Sel3Spin1Check::DlgRef_1Sel3Spin1Check( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); +} + +DlgRef_1Sel3Spin1Check::~DlgRef_1Sel3Spin1Check() +{ +} + ////////////////////////////////////////// // DlgRef_1Sel4Spin ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.h b/src/DlgRef/DlgRef.h index 0fe826fcb..b84bd55a3 100644 --- a/src/DlgRef/DlgRef.h +++ b/src/DlgRef/DlgRef.h @@ -210,6 +210,22 @@ public: ~DlgRef_1Sel3Spin(); }; +////////////////////////////////////////// +// DlgRef_1Sel3Spin1Check +////////////////////////////////////////// + +#include "ui_DlgRef_1Sel3Spin1Check_QTD.h" + +class DLGREF_EXPORT DlgRef_1Sel3Spin1Check : public QWidget, + public Ui::DlgRef_1Sel3Spin1Check_QTD +{ + Q_OBJECT + +public: + DlgRef_1Sel3Spin1Check( QWidget* = 0, Qt::WindowFlags = 0 ); + ~DlgRef_1Sel3Spin1Check(); +}; + ////////////////////////////////////////// // DlgRef_1Sel4Spin ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.pro b/src/DlgRef/DlgRef.pro index 8f0a5d198..f8f824056 100644 --- a/src/DlgRef/DlgRef.pro +++ b/src/DlgRef/DlgRef.pro @@ -42,6 +42,7 @@ HEADERS += DlgRef_2Sel1Spin_QTD.h HEADERS += DlgRef_2Sel2Spin_QTD.h HEADERS += DlgRef_2Sel3Spin_QTD.h HEADERS += DlgRef_1Sel1Spin1Check_QTD.h +HEADERS += DlgRef_1Sel3Spin1Check_QTD.h HEADERS += DlgRef_2Sel1Spin2Check_QTD.h HEADERS += DlgRef_2Sel2Spin1Check_QTD.h HEADERS += DlgRef_2Sel4Spin1Check_QTD.h @@ -66,6 +67,7 @@ HEADERS += DlgRef_2Sel1Spin.h HEADERS += DlgRef_2Sel2Spin.h HEADERS += DlgRef_2Sel3Spin.h HEADERS += DlgRef_1Sel1Spin1Check.h +HEADERS += DlgRef_1Sel3Spin1Check.h HEADERS += DlgRef_2Sel1Spin2Check.h HEADERS += DlgRef_2Sel2Spin1Check.h HEADERS += DlgRef_2Sel4Spin1Check.h @@ -93,6 +95,7 @@ SOURCES += DlgRef_2Sel1Spin.cxx SOURCES += DlgRef_2Sel2Spin.cxx SOURCES += DlgRef_2Sel3Spin.cxx SOURCES += DlgRef_1Sel1Spin1Check.cxx +SOURCES += DlgRef_1Sel3Spin1Check.cxx SOURCES += DlgRef_2Sel1Spin2Check.cxx SOURCES += DlgRef_2Sel2Spin1Check.cxx SOURCES += DlgRef_2Sel4Spin1Check.cxx diff --git a/src/DlgRef/DlgRef_1Sel3Spin1Check_QTD.ui b/src/DlgRef/DlgRef_1Sel3Spin1Check_QTD.ui new file mode 100644 index 000000000..f8501134c --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel3Spin1Check_QTD.ui @@ -0,0 +1,177 @@ + + DlgRef_1Sel3Spin1Check_QTD + + + + 0 + 0 + 156 + 120 + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 6 + + + 6 + + + + + + + + + 9 + + + 9 + + + 9 + + + 9 + + + 6 + + + 6 + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + TL2 + + + false + + + + + + + + 0 + 0 + + + + TL4 + + + false + + + + + + + + 0 + 0 + + + + TL3 + + + false + + + + + + + + + + + 0 + 0 + + + + TL1 + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + + + + qPixmapFromMimeSource + + + QtxDoubleSpinBox + QDoubleSpinBox +
QtxDoubleSpinBox.h
+
+
+ + PushButton1 + LineEdit1 + SpinBox_DX + SpinBox_DY + SpinBox_DZ + + + +
diff --git a/src/DlgRef/Makefile.am b/src/DlgRef/Makefile.am index a88a95ac4..ed593f335 100644 --- a/src/DlgRef/Makefile.am +++ b/src/DlgRef/Makefile.am @@ -49,6 +49,7 @@ UIC_FILES = \ ui_DlgRef_1Sel2Spin_QTD.h \ ui_DlgRef_1Sel3Check_QTD.h \ ui_DlgRef_1Sel3Spin_QTD.h \ + ui_DlgRef_1Sel3Spin1Check_QTD.h \ ui_DlgRef_1Sel4Spin_QTD.h \ ui_DlgRef_1Sel5Spin1Check_QTD.h \ ui_DlgRef_1Sel5Spin_QTD.h \ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 9e4d68621..caa1b974c 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -338,6 +338,10 @@ ICON_DLG_PRISM_2P prism2.png + + ICON_DLG_PRISM_DXDYDZ + prism3.png + ICON_DLG_PROPAGATE propagate.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 0aed9801d..2544d2a81 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -496,6 +496,10 @@ Please, select face, shell or solid and try again GEOM_EXTRUSION_BSV_2P Base Shape + 2 Points + + GEOM_EXTRUSION_DXDYDZ + Base Shape + DX DY DZ Vector + GEOM_EXTRUSION_TITLE Construction by Extrusion diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index a1c554544..e834e35bc 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -874,6 +874,121 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways return aPrism; } +//============================================================================= +/*! + * MakePrismDXDYDZ + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ + (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ) +{ + SetErrorCode(KO); + + if (theBase.IsNull()) return NULL; + + //Add a new Prism object + Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM); + + //Add a new Prism function for creation a Prism by DXDYDZ + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL; + + GEOMImpl_IPrism aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + + if (aRefBase.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetDX(theDX); + aCI.SetDY(theDY); + aCI.SetDZ(theDZ); + + //Compute the Prism value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Extrusion can not be created, check input data"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ(" + << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")"; + + SetErrorCode(OK); + return aPrism; +} + +//============================================================================= +/*! + * MakePrismDXDYDZ_2WAYS + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways + (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ) +{ + SetErrorCode(KO); + + if (theBase.IsNull()) return NULL; + + //Add a new Prism object + Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM); + + //Add a new Prism function for creation a Prism by DXDYDZ + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL; + + GEOMImpl_IPrism aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + + if (aRefBase.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetDX(theDX); + aCI.SetDY(theDY); + aCI.SetDZ(theDZ); + + //Compute the Prism value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Extrusion can not be created, check input data"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways(" + << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")"; + + SetErrorCode(OK); + return aPrism; +} //============================================================================= /*! diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index 5f1f52f36..707a0ca4e 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -70,6 +70,12 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2); + Standard_EXPORT Handle(GEOM_Object) MakePrismDXDYDZ (Handle(GEOM_Object) theBase, + double theDX, double theDY, double theDZ); + + Standard_EXPORT Handle(GEOM_Object) MakePrismDXDYDZ2Ways (Handle(GEOM_Object) theBase, + double theDX, double theDY, double theDZ); + Standard_EXPORT Handle(GEOM_Object) MakePipe (Handle(GEOM_Object) theBase, Handle(GEOM_Object) thePath); diff --git a/src/GEOMImpl/GEOMImpl_IPrism.hxx b/src/GEOMImpl/GEOMImpl_IPrism.hxx index 14c01864e..abe542b1a 100644 --- a/src/GEOMImpl/GEOMImpl_IPrism.hxx +++ b/src/GEOMImpl/GEOMImpl_IPrism.hxx @@ -27,6 +27,9 @@ #define PRISM_ARG_BASE 3 #define PRISM_ARG_PNT_F 4 #define PRISM_ARG_PNT_L 5 +#define PRISM_ARG_DX 6 +#define PRISM_ARG_DY 7 +#define PRISM_ARG_DZ 8 class GEOMImpl_IPrism { @@ -39,6 +42,14 @@ class GEOMImpl_IPrism void SetFirstPoint(Handle(GEOM_Function) thePoint) { _func->SetReference(PRISM_ARG_PNT_F, thePoint); } void SetLastPoint (Handle(GEOM_Function) thePoint) { _func->SetReference(PRISM_ARG_PNT_L, thePoint); } + void SetDX(double theDX) { _func->SetReal(PRISM_ARG_DX, theDX); } + void SetDY(double theDY) { _func->SetReal(PRISM_ARG_DY, theDY); } + void SetDZ(double theDZ) { _func->SetReal(PRISM_ARG_DZ, theDZ); } + + double GetDX() { return _func->GetReal(PRISM_ARG_DX); } + double GetDY() { return _func->GetReal(PRISM_ARG_DY); } + double GetDZ() { return _func->GetReal(PRISM_ARG_DZ); } + Handle(GEOM_Function) GetBase () { return _func->GetReference(PRISM_ARG_BASE); } Handle(GEOM_Function) GetVector() { return _func->GetReference(PRISM_ARG_VEC ); } Handle(GEOM_Function) GetFirstPoint() { return _func->GetReference(PRISM_ARG_PNT_F ); } diff --git a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx index 11bb15ad6..cc492ef14 100644 --- a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx @@ -129,7 +129,21 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const } } } - } else { + } else if (aType == PRISM_BASE_DXDYDZ || aType == PRISM_BASE_DXDYDZ_2WAYS) { + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + gp_Vec aV (aCI.GetDX(), aCI.GetDY(), aCI.GetDZ()); + if (aV.Magnitude() > gp::Resolution()) { + if (aType == PRISM_BASE_DXDYDZ_2WAYS) + { + gp_Trsf aTrsf; + aTrsf.SetTranslation(-aV); + BRepBuilderAPI_Transform aTransformation(aShapeBase, aTrsf, Standard_False); + aShapeBase = aTransformation.Shape(); + aV = aV * 2; + } + aShape = BRepPrimAPI_MakePrism(aShapeBase, aV, Standard_False).Shape(); + } } if (aShape.IsNull()) return 0; diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 54b156448..1a6ec8907 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -171,6 +171,8 @@ #define PRISM_BASE_TWO_PNT 2 #define PRISM_BASE_VEC_H_2WAYS 3 #define PRISM_BASE_TWO_PNT_2WAYS 4 +#define PRISM_BASE_DXDYDZ 5 +#define PRISM_BASE_DXDYDZ_2WAYS 6 #define REVOLUTION_BASE_AXIS_ANGLE 1 #define REVOLUTION_BASE_AXIS_ANGLE_2WAYS 2 diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index 081edeee6..781760a76 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -239,8 +239,8 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMapGetDependency(); - if( list->length() <= 1 ) - continue; // ??? why 1? + if( list->length() == 0 ) + continue; for( int i = 0; i < list->length(); i++ ) { bool depends = false; diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index 55160f0fb..6689cf345 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -459,6 +459,68 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPnt2Ways return GetObject(anObject); } +//============================================================================= +/*! + * MakePrismDXDYDZ + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismDXDYDZ + (GEOM::GEOM_Object_ptr theBase, CORBA::Double theDX, + CORBA::Double theDY, CORBA::Double theDZ) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBase == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject + (theBase->GetStudyID(), theBase->GetEntry()); + + if (aBase.IsNull()) return aGEOMObject._retn(); + + //Create the Prism + Handle(GEOM_Object) anObject = + GetOperations()->MakePrismDXDYDZ(aBase, theDX, theDY, theDZ); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePrismDXDYDZ2Ways + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismDXDYDZ2Ways + (GEOM::GEOM_Object_ptr theBase, CORBA::Double theDX, + CORBA::Double theDY, CORBA::Double theDZ) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBase == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject + (theBase->GetStudyID(), theBase->GetEntry()); + + if (aBase.IsNull()) return aGEOMObject._retn(); + + //Create the Prism + Handle(GEOM_Object) anObject = + GetOperations()->MakePrismDXDYDZ2Ways(aBase, theDX, theDY, theDZ); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakePipe diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index 330f4974b..d661684bd 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -94,6 +94,15 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr thePoint1, GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr MakePrismDXDYDZ (GEOM::GEOM_Object_ptr theBase, + CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); + GEOM::GEOM_Object_ptr MakePrismDXDYDZ2Ways (GEOM::GEOM_Object_ptr theBase, + CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); + GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePath); diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 461ef2d96..3df6f396f 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -967,6 +967,34 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismTwoPnt2Ways (GEOM::GEOM_Object_ptr return anObj; } +//============================================================================= +// MakePrismDXDYDZ: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismDXDYDZ (GEOM::GEOM_Object_ptr theBase, + CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ) +{ + beginService( " GEOM_Superv_i::MakePrismDXDYDZ" ); + MESSAGE("GEOM_Superv_i::MakePrismDXDYDZ"); + get3DPrimOp(); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakePrismDXDYDZ(theBase, theDX, theDY, theDZ); + endService( " GEOM_Superv_i::MakePrismDXDYDZ" ); + return anObj; +} + +//============================================================================= +// MakePrismDXDYDZ: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismDXDYDZ2Ways (GEOM::GEOM_Object_ptr theBase, + CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ) +{ + beginService( " GEOM_Superv_i::MakePrismDXDYDZ2Ways" ); + MESSAGE("GEOM_Superv_i::MakePrismDXDYDZ2Ways"); + get3DPrimOp(); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakePrismDXDYDZ2Ways(theBase, theDX, theDY, theDZ); + endService( " GEOM_Superv_i::MakePrismDXDYDZ2Ways" ); + return anObj; +} + //============================================================================= // MakePipe: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index bdeadb12d..d5e03edee 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -226,6 +226,14 @@ public: GEOM::GEOM_Object_ptr MakePrismTwoPnt2Ways (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePoint1, GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr MakePrismDXDYDZ (GEOM::GEOM_Object_ptr theBase, + CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); + GEOM::GEOM_Object_ptr MakePrismDXDYDZ2Ways (GEOM::GEOM_Object_ptr theBase, + CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePath); GEOM::GEOM_Object_ptr MakeRevolutionAxisAngle (GEOM::GEOM_Object_ptr theBase, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 46fb32260..17057005c 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -171,6 +171,8 @@ def TestAll (geompy, math): Copy = geompy.MakeCopy(Box) #(GEOM_Object_ptr)->GEOM_Object_ptr Prism = geompy.MakePrismVecH(Face, vz, 100.0) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr Prism2Ways = geompy.MakePrismVecH2Ways(Face, vz, 10.0) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr + PrismDXDYDZ= geompy.MakePrismDXDYDZ(Face2, 10, 20, 100)#(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr + PrismDXDYDZ2Ways= geompy.MakePrismDXDYDZ2Ways(Face, 30, -20, 200)#(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr Revolution = geompy.MakeRevolution(Face, vz, angle2) # Revolution2Ways = geompy.MakeRevolution(Face, vz, angle1) # Filling = geompy.MakeFilling(Compound, mindeg, maxdeg, @@ -336,6 +338,8 @@ def TestAll (geompy, math): id_Copy = geompy.addToStudy(Copy, "Copy") id_Prism = geompy.addToStudy(Prism, "Prism") id_Prism2Ways = geompy.addToStudy(Prism2Ways, "Prism2Ways") + id_PrismDXDYDZ= geompy.addToStudy(PrismDXDYDZ,"PrismDXDYDZ") + id_PrismDXDYDZ2Ways= geompy.addToStudy(PrismDXDYDZ2Ways,"PrismDXDYDZ2Ways") id_Revolution = geompy.addToStudy(Revolution, "Revolution") id_Revolution2Ways = geompy.addToStudy(Revolution2Ways, "Revolution2Ways") id_Filling = geompy.addToStudy(Filling, "Filling") diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 65fde5c8a..fcc2d4028 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -851,6 +851,32 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakePrismVecH2Ways(theBase, theVec, theH) RaiseIfFailed("MakePrismVecH2Ways", self.PrimOp) return anObj + + ## Create a shape by extrusion of the base shape along the dx, dy, dz direction + # @param theBase Base shape to be extruded. + # @param theDX, theDY, theDZ Directions of extrusion. + # @return New GEOM_Object, containing the created prism. + # + # @ref tui_creation_prism "Example" + def MakePrismDXDYDZ(self, theBase, theDX, theDY, theDZ): + # Example: see GEOM_TestAll.py + anObj = self.PrimOp.MakePrismDXDYDZ(theBase, theDX, theDY, theDZ) + RaiseIfFailed("MakePrismDXDYDZ", self.PrimOp) + return anObj + + ## Create a shape by extrusion of the base shape along the dx, dy, dz direction + # i.e. all the space, transfixed by the base shape during its translation + # along the vector on the given distance in 2 Ways (forward/backward) . + # @param theBase Base shape to be extruded. + # @param theDX, theDY, theDZ Directions of extrusion. + # @return New GEOM_Object, containing the created prism. + # + # @ref tui_creation_prism "Example" + def MakePrismDXDYDZ2Ways(self, theBase, theDX, theDY, theDZ): + # Example: see GEOM_TestAll.py + anObj = self.PrimOp.MakePrismDXDYDZ2Ways(theBase, theDX, theDY, theDZ) + RaiseIfFailed("MakePrismDXDYDZ2Ways", self.PrimOp) + return anObj ## Create a shape by revolution of the base shape around the axis # on the given angle, i.e. all the space, transfixed by the base diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx index 2149a7781..e64a13e6c 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx @@ -58,6 +58,7 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg( GeometryGUI* theGeometryGUI, QWi QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PRISM" ) ) ); QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PRISM_2P" ) ) ); + QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PRISM_DXDYDZ" ) ) ); setWindowTitle( tr( "GEOM_EXTRUSION_TITLE" ) ); @@ -65,11 +66,10 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg( GeometryGUI* theGeometryGUI, QWi mainFrame()->GroupConstructors->setTitle( tr( "GEOM_EXTRUSION" ) ); mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton2->setIcon( image2 ); - mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); - mainFrame()->RadioButton3->close(); + mainFrame()->RadioButton3->setIcon( image3 ); mainFrame()->RadioButton1->setChecked( true ); - myBothway = myBothway2 = false; + myBothway = myBothway2 = myBothway3 = false; GroupPoints = new DlgRef_2Sel1Spin2Check( centralWidget() ); GroupPoints->GroupBox1->setTitle( tr( "GEOM_EXTRUSION_BSV" ) ); @@ -85,7 +85,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg( GeometryGUI* theGeometryGUI, QWi GroupPoints->CheckButton2->setText( tr( "GEOM_REVERSE" ) ); GroupPoints2 = new DlgRef_3Sel1Check( centralWidget() ); - GroupPoints2->GroupBox1->setTitle( tr( "GEOM_EXTRUSION_BSV_2P" ) ); GroupPoints2->TextLabel1->setText( tr( "GEOM_BASE" ) ); GroupPoints2->TextLabel2->setText( tr( "GEOM_POINT_I" ).arg( 1 ) ); @@ -96,10 +95,21 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg( GeometryGUI* theGeometryGUI, QWi GroupPoints2->CheckButton1->setText( tr( "GEOM_BOTHWAY" ) ); GroupPoints2->CheckButton1->setChecked( myBothway2 ); + GroupPoints3 = new DlgRef_1Sel3Spin1Check( centralWidget() ); + GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ")); + GroupPoints3->TextLabel1->setText(tr("GEOM_BASE")); + GroupPoints3->PushButton1->setIcon(image1); + GroupPoints3->TextLabel2->setText(tr("GEOM_DX")); + GroupPoints3->TextLabel3->setText(tr("GEOM_DY")); + GroupPoints3->TextLabel4->setText(tr("GEOM_DZ")); + GroupPoints3->CheckButton1->setText( tr( "GEOM_BOTHWAY" ) ); + GroupPoints3->CheckButton1->setChecked( myBothway3 ); + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( GroupPoints ); layout->addWidget( GroupPoints2 ); + layout->addWidget( GroupPoints3); /***************************************************************/ setHelpFileName( "create_extrusion_page.html" ); @@ -133,6 +143,8 @@ void GenerationGUI_PrismDlg::Init() GroupPoints2->LineEdit2->setReadOnly( true ); GroupPoints2->LineEdit3->setReadOnly( true ); + GroupPoints3->LineEdit1->setReadOnly( true ); + myPoint1 = myPoint2 = myBase = myVec = GEOM::GEOM_Object::_nil(); myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false; @@ -141,6 +153,13 @@ void GenerationGUI_PrismDlg::Init() double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 ); /* min, max, step and decimals for spin boxes & initial values */ + initSpinBox( GroupPoints3->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + initSpinBox( GroupPoints3->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + initSpinBox( GroupPoints3->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + GroupPoints3->SpinBox_DX->setValue( 0.0 ); + GroupPoints3->SpinBox_DY->setValue( 0.0 ); + GroupPoints3->SpinBox_DZ->setValue( 0.0 ); + initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY GroupPoints->SpinBox_DX->setValue( 100.0 ); @@ -165,12 +184,18 @@ void GenerationGUI_PrismDlg::Init() connect( GroupPoints2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPoints2->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( onBothway2() ) ); + connect( GroupPoints2->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( onBothway() ) ); connect( GroupPoints2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupPoints2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupPoints2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( GroupPoints3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( GroupPoints3->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( GroupPoints3->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); + connect( GroupPoints3->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); + connect( GroupPoints3->SpinBox_DZ, SIGNAL( valueChanged ( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); + connect( GroupPoints3->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( onBothway() ) ); connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -187,6 +212,9 @@ void GenerationGUI_PrismDlg::Init() void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep( double step ) { GroupPoints->SpinBox_DX->setSingleStep(step); + GroupPoints3->SpinBox_DX->setSingleStep(step); + GroupPoints3->SpinBox_DY->setSingleStep(step); + GroupPoints3->SpinBox_DZ->setSingleStep(step); } @@ -205,6 +233,7 @@ void GenerationGUI_PrismDlg::ConstructorsClicked( int constructorId ) globalSelection( GEOM_ALLSHAPES ); GroupPoints2->hide(); + GroupPoints3->hide(); GroupPoints->show(); myEditCurrentArgument = GroupPoints->LineEdit1; @@ -221,6 +250,7 @@ void GenerationGUI_PrismDlg::ConstructorsClicked( int constructorId ) GroupPoints->hide(); GroupPoints2->show(); + GroupPoints3->hide(); myEditCurrentArgument = GroupPoints2->LineEdit1; GroupPoints2->LineEdit1->setText( GroupPoints->LineEdit1->text() ); // keep base @@ -231,6 +261,17 @@ void GenerationGUI_PrismDlg::ConstructorsClicked( int constructorId ) break; } + case 2: + { + globalSelection( GEOM_ALLSHAPES ); + + GroupPoints->hide(); + GroupPoints2->hide(); + GroupPoints3->show(); + + myEditCurrentArgument = GroupPoints3->LineEdit1; + GroupPoints3->LineEdit1->setText( GroupPoints->LineEdit1->text() ); // keep base + } } qApp->processEvents(); @@ -340,7 +381,7 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() } myEditCurrentArgument->setText( aName ); } - else { // getConstructorId()==1 - extrusion using 2 points + else if ( getConstructorId() == 1 ) { // getConstructorId()==1 - extrusion using 2 points if ( IObjectCount() != 1 ) { if ( myEditCurrentArgument == GroupPoints2->LineEdit1 ) myOkBase = false; @@ -410,6 +451,18 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() myPoint2 = aSelectedObject; } } + else if ( getConstructorId() == 2 ) { // extrusion using dx dy dz + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = + GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); + + if ( !testResult || CORBA::is_nil( aSelectedObject ) ) + return; + + QString aName = GEOMBase::GetName( aSelectedObject ); + myBase = aSelectedObject; + myEditCurrentArgument->setText( aName ); + } displayPreview(); } @@ -447,6 +500,10 @@ void GenerationGUI_PrismDlg::SetEditCurrentArgument() myEditCurrentArgument = GroupPoints2->LineEdit3; localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } + else if ( send == GroupPoints3->PushButton1 ) { + GroupPoints3->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints3->LineEdit1; + } myEditCurrentArgument->setFocus(); SelectionIntoArgument(); @@ -464,7 +521,8 @@ void GenerationGUI_PrismDlg::LineEditReturnPressed() send == GroupPoints->LineEdit2 || send == GroupPoints2->LineEdit1 || send == GroupPoints2->LineEdit2 || - send == GroupPoints2->LineEdit3 ) { + send == GroupPoints2->LineEdit3 || + send == GroupPoints3->LineEdit1) { myEditCurrentArgument = send; GEOMBase_Skeleton::LineEditReturnPressed(); } @@ -532,8 +590,10 @@ bool GenerationGUI_PrismDlg::isValid( QString& ) { if ( getConstructorId() == 0 ) return ( myOkBase && myOkVec ); // by vector and height - else + else if ( getConstructorId() == 1 ) return ( myOkBase && myOkPnt1 && myOkPnt2 ); // by two points + else if ( getConstructorId() == 2 ) + return true; } //================================================================================= @@ -565,6 +625,20 @@ bool GenerationGUI_PrismDlg::execute( ObjectList& objects ) MakePrismTwoPnt2Ways( myBase, myPoint1, myPoint2 ); } break; + case 2 : + double dx = GroupPoints3->SpinBox_DX->value(); + double dy = GroupPoints3->SpinBox_DY->value(); + double dz = GroupPoints3->SpinBox_DZ->value(); + + if ( !myBothway3 ) { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakePrismDXDYDZ( myBase, dx, dy, dz ); + } + else { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakePrismDXDYDZ2Ways( myBase, dx, dy, dz ); + } + break; } if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); @@ -589,17 +663,25 @@ void GenerationGUI_PrismDlg::onReverse() //================================================================================= void GenerationGUI_PrismDlg::onBothway() { - bool anOldValue = myBothway; - myBothway = !anOldValue; - GroupPoints->CheckButton2->setEnabled( !myBothway ); - displayPreview(); -} - -void GenerationGUI_PrismDlg::onBothway2() -{ - bool anOldValue = myBothway2; - myBothway2 = !anOldValue; - displayPreview(); + bool anOldValue; + switch ( getConstructorId() ) { + case 0: + anOldValue = myBothway; + myBothway = !anOldValue; + GroupPoints->CheckButton2->setEnabled( !myBothway ); + displayPreview(); + break; + case 1: + anOldValue = myBothway2; + myBothway2 = !anOldValue; + displayPreview(); + break; + case 2: + anOldValue = myBothway3; + myBothway3 = !anOldValue; + displayPreview(); + break; + } } //================================================================================= diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.h b/src/GenerationGUI/GenerationGUI_PrismDlg.h index c36047a50..78bf3453a 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.h +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.h @@ -30,6 +30,7 @@ class DlgRef_2Sel1Spin2Check; class DlgRef_3Sel1Check; +class DlgRef_1Sel3Spin1Check; //================================================================================= // class : GenerationGUI_PrismDlg @@ -66,9 +67,11 @@ private: bool myOkPnt2; bool myBothway; bool myBothway2; + bool myBothway3; DlgRef_2Sel1Spin2Check* GroupPoints; DlgRef_3Sel1Check* GroupPoints2; // for second layout for extrusion using 2 points + DlgRef_1Sel3Spin1Check* GroupPoints3; private slots: void ClickOnOk(); @@ -82,7 +85,6 @@ private slots: void SetDoubleSpinBoxStep( double ); void onReverse(); void onBothway(); - void onBothway2(); }; #endif // GENERATIONGUI_PRISMDLG_H