From: dmv Date: Thu, 7 Aug 2008 06:55:53 +0000 (+0000) Subject: 0016757: EDF 546 GEOM : Add Face and Disc in geom primitives X-Git-Tag: V5_1_0a1~30 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=917ced834c4338e094440a4af95c4534ad556040;p=modules%2Fgeom.git 0016757: EDF 546 GEOM : Add Face and Disc in geom primitives --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 6f48f8d5a..06cf8084a 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -825,20 +825,21 @@ module GEOM * Create a face specified dimensions along OX-OY coordinate axes, * with edges parallel to the coordinate axes. * Center of the face will be at point (0, 0, 0). - * \param theH length of Face edge, parallel to OX axis. - * \param theW lenght of Face edge, patallel to OY axis. + * \param theH Height of the Face. + * \param theW Width of the Face. + * \param theOrientation Orientation belong axis OXY OYZ OZX * \return New GEOM_Object, containing the created face. */ - GEOM_Object MakeFaceHW (in double theH, in double theW); + GEOM_Object MakeFaceHW (in double theH, in double theW, in short theOrientation); /*! - * Create a face by another plane and two specified sizes, + * Create a face by normale vector or edge and two specified sizes, * vertical (H) and horisontal (W). - * \param theFace defines plane. + * \param theVec defines plane. * \param theH vertical size (height). * \param theW horisontal size (width). * \return New GEOM_Object, containing the created face. */ - GEOM_Object MakeFacePlaneHW (in GEOM_Object theFace, in double theH, in double theW); + GEOM_Object MakeFaceVecHW (in GEOM_Object theVec, in double theH, in double theW); /*! * Create a Disk (circular face) with given center, normal vector and radius. * \param thePnt disk center. @@ -857,6 +858,16 @@ module GEOM GEOM_Object MakeDiskThreePnt (in GEOM_Object thePnt1, in GEOM_Object thePnt2, in GEOM_Object thePnt3); + + /*! + * Create a disk specified dimensions along OX-OY coordinate axes, + * Center of the disk at point (0, 0, 0). + * \param theR of the Disk. + * \param theOrientation Orientation belong axis OXY OYZ OZX + * \return New GEOM_Object, containing the created disk. + */ + GEOM_Object MakeDiskR (in double theR, in short theOrientation); + /*! * Create a cylinder with given radius and height at * the origin of coordinate system. Axis of the cylinder diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 2b9cde49f..1b01d8dc7 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -127,16 +127,19 @@ module GEOM GEOM_Object MakeBoxTwoPnt (in GEOM_Object thePnt1, in GEOM_Object thePnt2) ; GEOM_Object MakeFaceHW (in double theH, - in double theW) ; - GEOM_Object MakeFacePlaneHW (in GEOM_Object theFace, - in double theH, - in double theW) ; + in double theW, + in short theOrientation) ; + GEOM_Object MakeFaceVecHW (in GEOM_Object theVec, + in double theH, + in double theW) ; GEOM_Object MakeDiskPntVecR (in GEOM_Object thePnt, in GEOM_Object theVec, in double theR) ; GEOM_Object MakeDiskThreePnt (in GEOM_Object thePnt1, in GEOM_Object thePnt2, in GEOM_Object thePnt3) ; + GEOM_Object MakeDiskR (in double theR, + in short theOrientation) ; GEOM_Object MakeCylinderPntVecRH (in GEOM_Object thePnt, in GEOM_Object theAxis, in double theRadius, diff --git a/resources/Makefile.am b/resources/Makefile.am index 18259d174..de56c79c3 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -75,13 +75,14 @@ delete.png \ disk.png \ disk3points.png \ disk_pntvecr.png \ +disk_r.png \ display.png \ displayonly.png \ displayall.png \ erase.png \ eraseall.png \ face_hw.png \ -face_planehw.png \ +face_vechw.png \ fillet.png \ filletall.png \ filletedge.png \ diff --git a/resources/disk_r.png b/resources/disk_r.png new file mode 100644 index 000000000..3d52a2d79 Binary files /dev/null and b/resources/disk_r.png differ diff --git a/resources/face_planehw.png b/resources/face_planehw.png deleted file mode 100644 index 86cefba39..000000000 Binary files a/resources/face_planehw.png and /dev/null differ diff --git a/resources/face_vechw.png b/resources/face_vechw.png new file mode 100644 index 000000000..d674d17c1 Binary files /dev/null and b/resources/face_vechw.png differ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index dc0c62334..3442ba160 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -74,6 +74,10 @@ ICON_DLG_DISK_THREE_POINTS disk3points.png + + ICON_DLG_DISK_R + disk_r.png + ICON_DLG_BUILD_EDGE build_edge.png @@ -87,8 +91,8 @@ face_hw.png - ICON_DLG_FACE_PLANE_HW - face_planehw.png + ICON_DLG_FACE_VEC_HW + face_vechw.png ICON_DLG_BUILD_SHELL diff --git a/src/GEOMImpl/GEOMImpl_DiskDriver.cxx b/src/GEOMImpl/GEOMImpl_DiskDriver.cxx index da1ac16c5..ce1c45b1b 100755 --- a/src/GEOMImpl/GEOMImpl_DiskDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_DiskDriver.cxx @@ -128,6 +128,25 @@ Standard_Integer GEOMImpl_DiskDriver::Execute(TFunction_Logbook& log) const BRepBuilderAPI_MakeFace MF (MW, Standard_False); aShape = MF.Shape(); } + } + else if (aType == DISK_R) { + int anOrient = aCI.GetOrientation(); + gp_Pnt aP = gp::Origin(); + gp_Vec aV; + if (anOrient == 1) + aV = gp::DZ(); + else if (anOrient == 2) + aV = gp::DX(); + else if (anOrient == 3) + aV = gp::DY(); + + gp_Ax2 anAxes (aP, aV); + gp_Circ aCirc (anAxes, aCI.GetRadius()); + TopoDS_Shape aCircle = BRepBuilderAPI_MakeEdge(aCirc).Edge(); + BRepBuilderAPI_MakeWire MW; + MW.Add(TopoDS::Edge(aCircle)); + BRepBuilderAPI_MakeFace MF (MW, Standard_False); + aShape = MF.Shape(); } else { } diff --git a/src/GEOMImpl/GEOMImpl_FaceDriver.cxx b/src/GEOMImpl/GEOMImpl_FaceDriver.cxx index f4af15da2..9d8deefef 100755 --- a/src/GEOMImpl/GEOMImpl_FaceDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FaceDriver.cxx @@ -74,21 +74,35 @@ Standard_Integer GEOMImpl_FaceDriver::Execute(TFunction_Logbook& log) const TopoDS_Shape aShape; - if (aType == FACE_PLANE_H_W) { - Handle(GEOM_Function) aRefPlane = aFI.GetRef1(); - TopoDS_Shape aShapePlane = aRefPlane->GetValue(); - double aH = aFI.GetH() / 2.0; - double aW = aFI.GetW() / 2.0; - gp_Ax3 anAx = GEOMImpl_IMeasureOperations::GetPosition(aShapePlane); - gp_Pln aPln (anAx); - aShape = BRepBuilderAPI_MakeFace(aPln, -aH, +aH, -aW, +aW).Shape(); + if (aType == FACE_VEC_H_W) { + Handle(GEOM_Function) aRefVec = aFI.GetRef1(); + TopoDS_Shape aShapeVec = aRefVec->GetValue(); + if (aShapeVec.ShapeType() == TopAbs_EDGE) { + TopoDS_Edge anEdge = TopoDS::Edge(aShapeVec); + double aH = aFI.GetH() / 2.0; + double aW = aFI.GetW() / 2.0; + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2, Standard_True); + gp_Pnt aP (BRep_Tool::Pnt(V1)); + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + gp_Pln aPlane (aP, aV); + aShape = BRepBuilderAPI_MakeFace(aPlane, -aH, +aH, -aW, +aW).Shape(); + } } else if (aType == FACE_H_W) { double aH = aFI.GetH() / 2.0; double aW = aFI.GetW() / 2.0; TopoDS_Vertex V1, V2; + int anOrient = aFI.GetOrientation(); gp_Pnt aP = gp::Origin(); - gp_Vec aV = gp::DZ(); + gp_Vec aV; + if (anOrient == 1) + aV = gp::DZ(); + else if (anOrient == 2) + aV = gp::DX(); + else if (anOrient == 3) + aV = gp::DY(); + gp_Pln aPlane (aP, aV); aShape = BRepBuilderAPI_MakeFace(aPlane, -aH, +aH, -aW, +aW).Shape(); } diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 8b8e2bf4e..37fafba5c 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -201,7 +201,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Objec * MakeFaceHW */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW) +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation) { SetErrorCode(KO); @@ -221,6 +221,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double aFI.SetH(theH); aFI.SetW(theW); + aFI.SetOrientation(theOrientation); //Compute the Face try { @@ -240,7 +241,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double //Make a Python command GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW(" - << theH << ", " << theW << ")"; + << theH << ", " << theW << ", " << theOrientation << ")"; SetErrorCode(OK); return aFace; @@ -248,21 +249,21 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double //============================================================================= /*! - * MakeFacePlaneHW + * MakeFaceVecHW */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFacePlaneHW (Handle(GEOM_Object) theFace, - double theH, double theW) +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceVecHW (Handle(GEOM_Object) theVec, + double theH, double theW) { SetErrorCode(KO); - if (theFace.IsNull()) return NULL; + if (theVec.IsNull()) return NULL; //Add a new Face object Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE); //Add a new Box function for creation a box relatively to two points - Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_PLANE_H_W); + Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_VEC_H_W); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly @@ -270,7 +271,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFacePlaneHW (Handle(GEOM_Obj GEOMImpl_IFace aFI (aFunction); - Handle(GEOM_Function) aRefFunction1 = theFace->GetLastFunction(); + Handle(GEOM_Function) aRefFunction1 = theVec->GetLastFunction(); if (aRefFunction1.IsNull()) return aFace; @@ -296,8 +297,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFacePlaneHW (Handle(GEOM_Obj } //Make a Python command - GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFacePlaneHW(" - << theFace << ", " << theH << ", " << theW << ")"; + GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceVecHW(" + << theVec << ", " << theH << ", " << theW << ")"; SetErrorCode(OK); return aFace; @@ -421,6 +422,56 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Ob return aDisk; } +//============================================================================= +/*! + * MakeDiskR + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation) +{ + SetErrorCode(KO); + + if (theR == 0 ) return NULL; + + //Add a new Disk object + Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Box function for creation a box relatively to two points + Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk; + + GEOMImpl_IDisk aDI (aFunction); + + aDI.SetRadius(theR); + aDI.SetOrientation(theOrientation); + + //Compute the Disk + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Disk driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR(" + << theR << ", " << theOrientation << ")"; + + SetErrorCode(OK); + return aDisk; +} + //============================================================================= /*! * MakeCylinderRH diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index 522fd9b87..ba2a0fbda 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -36,15 +36,16 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeBoxDXDYDZ (double theDX, double theDY, double theDZ); Standard_EXPORT Handle(GEOM_Object) MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2); - Standard_EXPORT Handle(GEOM_Object) MakeFaceHW (double theH, double theW); - Standard_EXPORT Handle(GEOM_Object) MakeFacePlaneHW (Handle(GEOM_Object) theFace, - double theH, double theW); + Standard_EXPORT Handle(GEOM_Object) MakeFaceHW (double theH, double theW, int theOrientation); + Standard_EXPORT Handle(GEOM_Object) MakeFaceVecHW (Handle(GEOM_Object) theVec, + double theH, double theW); Standard_EXPORT Handle(GEOM_Object) MakeDiskThreePnt (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2, Handle(GEOM_Object) thePnt3); Standard_EXPORT Handle(GEOM_Object) MakeDiskPntVecR (Handle(GEOM_Object) thePnt1, 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) MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, diff --git a/src/GEOMImpl/GEOMImpl_IDisk.hxx b/src/GEOMImpl/GEOMImpl_IDisk.hxx index 79651b593..423e99e1e 100755 --- a/src/GEOMImpl/GEOMImpl_IDisk.hxx +++ b/src/GEOMImpl/GEOMImpl_IDisk.hxx @@ -22,13 +22,15 @@ #include "GEOM_Function.hxx" -#define DISK_ARG_P1 1 -#define DISK_ARG_P2 2 -#define DISK_ARG_P3 3 +#define DISK_ARG_P1 1 +#define DISK_ARG_P2 2 +#define DISK_ARG_P3 3 -#define DISK_ARG_CC 4 -#define DISK_ARG_VV 5 -#define DISK_ARG_RR 6 +#define DISK_ARG_CC 4 +#define DISK_ARG_VV 5 +#define DISK_ARG_RR 6 + +#define DISK_ARG_ORIENT 7 class GEOMImpl_IDisk { @@ -44,6 +46,7 @@ class GEOMImpl_IDisk void SetVector(Handle(GEOM_Function) theV) { _func->SetReference(DISK_ARG_VV, theV); } void SetRadius(double theR) { _func->SetReal(DISK_ARG_RR, theR); } + void SetOrientation(double theO) { _func->SetReal(DISK_ARG_ORIENT, theO); } Handle(GEOM_Function) GetPoint1() { return _func->GetReference(DISK_ARG_P1); } Handle(GEOM_Function) GetPoint2() { return _func->GetReference(DISK_ARG_P2); } @@ -53,6 +56,7 @@ class GEOMImpl_IDisk Handle(GEOM_Function) GetVector() { return _func->GetReference(DISK_ARG_VV); } double GetRadius() { return _func->GetReal(DISK_ARG_RR); } + double GetOrientation() { return _func->GetReal(DISK_ARG_ORIENT); } private: diff --git a/src/GEOMImpl/GEOMImpl_IFace.hxx b/src/GEOMImpl/GEOMImpl_IFace.hxx index 55fe2eec9..dd6e869db 100755 --- a/src/GEOMImpl/GEOMImpl_IFace.hxx +++ b/src/GEOMImpl/GEOMImpl_IFace.hxx @@ -22,13 +22,12 @@ #include "GEOM_Function.hxx" -#define FACE_ARG_REF1 1 -#define FACE_ARG_REF2 2 -#define FACE_ARG_REF3 3 +#define FACE_ARG_REF1 1 +#define FACE_ARG_ORIENT 2 -#define FACE_ARG_PLANE 4 -#define FACE_ARG_H 5 -#define FACE_ARG_W 6 +#define FACE_ARG_PLANE 4 +#define FACE_ARG_H 5 +#define FACE_ARG_W 6 class GEOMImpl_IFace { @@ -39,11 +38,8 @@ class GEOMImpl_IFace void SetRef1(Handle(GEOM_Function) theRefPoint1) { _func->SetReference(FACE_ARG_REF1, theRefPoint1); } Handle(GEOM_Function) GetRef1() { return _func->GetReference(FACE_ARG_REF1); } - void SetRef2(Handle(GEOM_Function) theRefPoint2) { _func->SetReference(FACE_ARG_REF2, theRefPoint2); } - Handle(GEOM_Function) GetRef2() { return _func->GetReference(FACE_ARG_REF2); } - - void SetRef3(Handle(GEOM_Function) theRefVec) { _func->SetReference(FACE_ARG_REF3, theRefVec); } - Handle(GEOM_Function) GetRef3() { return _func->GetReference(FACE_ARG_REF3); } + void SetOrientation(int theOrientation) { _func->SetReal(FACE_ARG_ORIENT, theOrientation); } + int GetOrientation() { return _func->GetReal(FACE_ARG_ORIENT); } void SetH(double theH) { _func->SetReal(FACE_ARG_H, theH); } void SetW(double theW) { _func->SetReal(FACE_ARG_W, theW); } diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 2747a1e34..b2f3c58d1 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -158,11 +158,12 @@ #define BOX_DX_DY_DZ 1 #define BOX_TWO_PNT 2 -#define FACE_PLANE_H_W 1 +#define FACE_VEC_H_W 1 #define FACE_H_W 2 #define DISK_PNT_VEC_R 1 #define DISK_THREE_PNT 2 +#define DISK_R 3 #define CYLINDER_R_H 1 #define CYLINDER_PNT_VEC_R_H 2 diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index fbf4829f7..7bd3eaa69 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -109,7 +109,8 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxTwoPnt */ //============================================================================= GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceHW (CORBA::Double theH, - CORBA::Double theW) + CORBA::Double theW, + CORBA::Short theOrientation) { GEOM::GEOM_Object_var aGEOMObject; @@ -120,7 +121,7 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceHW (CORBA::Double theH, return aGEOMObject._retn(); //Create the Face - Handle(GEOM_Object) anObject = GetOperations()->MakeFaceHW(theH, theW); + Handle(GEOM_Object) anObject = GetOperations()->MakeFaceHW(theH, theW, theOrientation); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -129,11 +130,11 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceHW (CORBA::Double theH, //============================================================================= /*! - * MakeFacePlaneHW + * MakeFaceVecHW */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFacePlaneHW - (GEOM::GEOM_Object_ptr theFace, +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceVecHW + (GEOM::GEOM_Object_ptr theVec, CORBA::Double theH, CORBA::Double theW) { @@ -142,18 +143,18 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFacePlaneHW //Set a not done flag GetOperations()->SetNotDone(); - if (theFace == NULL || theH == 0 || theW == 0) + if (theVec == NULL || theH == 0 || theW == 0) return aGEOMObject._retn(); //Get the reference points Handle(GEOM_Object) aFace = GetOperations()->GetEngine()->GetObject - (theFace->GetStudyID(), theFace->GetEntry()); + (theVec->GetStudyID(), theVec->GetEntry()); if (aFace.IsNull()) return aGEOMObject._retn(); //Create the Face - Handle(GEOM_Object) anObject = GetOperations()->MakeFacePlaneHW(aFace, theH, theW); + Handle(GEOM_Object) anObject = GetOperations()->MakeFaceVecHW(aFace, theH, theW); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -228,6 +229,30 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDiskThreePnt return GetObject(anObject); } +//============================================================================= +/*! + * MakeDiskR + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDiskR (CORBA::Double theR, + CORBA::Short theOrientation) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theR == 0) + return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = GetOperations()->MakeDiskR(theR, theOrientation); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeCylinderRH diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index e4edeb0cf..737c61305 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -48,9 +48,10 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr thePnt2); GEOM::GEOM_Object_ptr MakeFaceHW (CORBA::Double theH, - CORBA::Double theW); + CORBA::Double theW, + CORBA::Short theOrientation); - GEOM::GEOM_Object_ptr MakeFacePlaneHW (GEOM::GEOM_Object_ptr theFace, + GEOM::GEOM_Object_ptr MakeFaceVecHW (GEOM::GEOM_Object_ptr theFace, CORBA::Double theH, CORBA::Double theW); @@ -62,6 +63,9 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr thePnt2, GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr MakeDiskR (CORBA::Double theR, + CORBA::Short theOrientation); + GEOM::GEOM_Object_ptr MakeCylinderRH (CORBA::Double theR, CORBA::Double theH); diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 3a37d3102..6f46ba2ea 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -775,28 +775,29 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeBoxTwoPnt (GEOM::GEOM_Object_ptr thePnt // MakeFaceHW: //============================================================================= GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFaceHW (CORBA::Double theH, - CORBA::Double theW) + CORBA::Double theW, + CORBA::Short theOrientation) { beginService( " GEOM_Superv_i::MakeFaceHW" ); MESSAGE("GEOM_Superv_i::MakeFaceHW"); get3DPrimOp(); - GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFaceHW(theH, theW); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFaceHW(theH, theW, theOrientation); endService( " GEOM_Superv_i::MakeFaceHW" ); return anObj; } //============================================================================= -// MakeFaceTwoPlaneHW: +// MakeFaceVecHW: //============================================================================= -GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFacePlaneHW (GEOM::GEOM_Object_ptr theFace, - CORBA::Double theH, - CORBA::Double theW) +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFaceVecHW (GEOM::GEOM_Object_ptr theVec, + CORBA::Double theH, + CORBA::Double theW) { - beginService( " GEOM_Superv_i::MakeFacePlaneHW" ); - MESSAGE("GEOM_Superv_i::MakeFacePlaneHW"); + beginService( " GEOM_Superv_i::MakeFaceVecHW" ); + MESSAGE("GEOM_Superv_i::MakeFaceVecHW"); get3DPrimOp(); - GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFacePlaneHW(theFace, theH, theW); - endService( " GEOM_Superv_i::MakeFacePlaneHW" ); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFaceVecHW(theVec, theH, theW); + endService( " GEOM_Superv_i::MakeFaceVecHW" ); return anObj; } @@ -830,6 +831,20 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeDiskThreePnt (GEOM::GEOM_Object_ptr the return anObj; } +//============================================================================= +// MakeDiskR: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeDiskR (CORBA::Double theR, + CORBA::Short theOrientation) +{ + beginService( " GEOM_Superv_i::MakeDiskR" ); + MESSAGE("GEOM_Superv_i::MakeDiskR"); + get3DPrimOp(); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeDiskR(theR, theOrientation); + endService( " GEOM_Superv_i::MakeDiskR" ); + return anObj; +} + //============================================================================= // MakeCylinderPntVecRH: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index deea12244..39051115e 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -188,16 +188,19 @@ public: GEOM::GEOM_Object_ptr MakeBoxTwoPnt (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2); GEOM::GEOM_Object_ptr MakeFaceHW (CORBA::Double theH, - CORBA::Double theW); - GEOM::GEOM_Object_ptr MakeFacePlaneHW (GEOM::GEOM_Object_ptr theFace, - CORBA::Double theH, - CORBA::Double theW); + CORBA::Double theW, + CORBA::Short theOrientation); + GEOM::GEOM_Object_ptr MakeFaceVecHW (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theH, + CORBA::Double theW); GEOM::GEOM_Object_ptr MakeDiskPntVecR (GEOM::GEOM_Object_ptr theCenter, GEOM::GEOM_Object_ptr theVector, CORBA::Double theR); GEOM::GEOM_Object_ptr MakeDiskThreePnt (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr MakeDiskR (CORBA::Double theR, + CORBA::Short theOrientation); GEOM::GEOM_Object_ptr MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theAxis, CORBA::Double theRadius, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 9760f4fff..49427ae28 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -138,10 +138,11 @@ def TestAll (geompy, math): Face1 = geompy.MakeFaceWires([Wire, Sketcher], WantPlanarFace) #(List of GEOM_Object_ptr, Boolean)->GEOM_Object_ptr Face2 = geompy.MakeFace(Sketcher, WantPlanarFace) - Face3 = geompy.MakeFaceHW (100., 200.) #(2 Doubles)->GEOM_Object_ptr - Face4 = geompy.MakeFacePlaneHW (Face, 200., 200.)#(1 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr + Face3 = geompy.MakeFaceHW (100., 200., 1) #(2 Doubles, 1 Int)->GEOM_Object_ptr + Face4 = geompy.MakeFaceVecHW (vz, 200., 100.) #(1 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr Disk = geompy.MakeDiskPntVecR (p0, vz, radius) #(2 GEOM_Object_ptr, 1 Double)->GEOM_Object_ptr Disk2 = geompy.MakeDiskThreePnt(p0, p200, pz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr + Disk3 = geompy.MakeDiskR(100., 1) #(1 Doubles, 1 Int)->GEOM_Object_ptr Shell = geompy.MakeShell([Face, Face1]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr Prism1 = geompy.MakePrism(Face2, p0, pxyz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr @@ -332,6 +333,7 @@ def TestAll (geompy, math): id_Face4 = geompy.addToStudy(Face4, "Face Plane_HW") id_Disk = geompy.addToStudy(Disk, "Disk PntVecR") id_Disk2 = geompy.addToStudy(Disk2, "Disk Three Points") + id_Disk3 = geompy.addToStudy(Disk3, "Disk OXY Radius") id_Shell = geompy.addToStudy(Shell, "Shell") id_p_on_face = geompy.addToStudy(p_on_face, "Vertex on Face (0.1, 0.8)") diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 8b1db20ef..907a0ee23 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -682,29 +682,30 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Create a face with specified dimensions along OX-OY coordinate axes, # with edges, parallel to this coordinate axes. - # @param theH length of Face edge, parallel to OX axis. - # @param theW length of Face edge, parallel to OY axis. + # @param theH height of Face. + # @param theW width of Face. + # @param theOrientation orientation belong axis OXY OYZ OZX # @return New GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" - def MakeFaceHW(self,theH, theW): + def MakeFaceHW(self,theH, theW, theOrientation): # Example: see GEOM_TestAll.py - anObj = self.PrimOp.MakeFaceHW(theH, theW) + anObj = self.PrimOp.MakeFaceHW(theH, theW, theOrientation) RaiseIfFailed("MakeFaceHW", self.PrimOp) return anObj ## Create a face from another plane and two sizes, # vertical size and horisontal size. - # @param thePlane Plane in that axis will be create new face. + # @param theVec Normale vector to the creating face. # @param theH Height (vertical size). # @param theW Width (horisontal size). # @return New GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" - def MakeFacePlaneHW(self, theFace, theH, theW): + def MakeFaceVecHW(self, theVec, theH, theW): # Example: see GEOM_TestAll.py - anObj = self.PrimOp.MakeFacePlaneHW(theFace, theH, theW) - RaiseIfFailed("MakeFacePlaneHW", self.PrimOp) + anObj = self.PrimOp.MakeFaceVecHW(theVec, theH, theW) + RaiseIfFailed("MakeFaceVecHW", self.PrimOp) return anObj ## Create a disk with given center, normal vector and radius. @@ -731,6 +732,18 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("MakeDiskThreePnt", self.PrimOp) return anObj + ## Create a disk with specified dimensions along OX-OY coordinate axes. + # @param theR Radius of Face. + # @param theOrientation set the orientation belong axis OXY or OYZ or OZX + # @return New GEOM_Object, containing the created disk. + # + # @ref tui_creation_face "Example" + def MakeDiskR(self,theR, theOrientation): + # Example: see GEOM_TestAll.py + anObj = self.PrimOp.MakeDiskR(theR, theOrientation) + RaiseIfFailed("MakeDiskR", self.PrimOp) + return anObj + ## Create a cylinder with given base point, axis, radius and height. # @param thePnt Central point of cylinder base. # @param theAxis Cylinder axis. diff --git a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx index 72463078f..daf7b78e7 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx @@ -56,6 +56,7 @@ PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg( GeometryGUI* theGeometryGUI, QWidget QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_PNT_VEC_R" ) ) ); QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_THREE_POINTS" ) ) ); + QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_R" ) ) ); setWindowTitle( tr( "GEOM_DISK_TITLE" ) ); @@ -63,39 +64,46 @@ PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg( GeometryGUI* theGeometryGUI, QWidget mainFrame()->GroupConstructors->setTitle( tr( "GEOM_DISK" ) ); mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton2->setIcon( image2 ); - mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); - mainFrame()->RadioButton3->close(); + mainFrame()->RadioButton3->setIcon( image3 ); GroupPntVecR = new DlgRef_2Sel1Spin( centralWidget() ); - GroupPntVecR->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); GroupPntVecR->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) ); GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) ); GroupPntVecR->TextLabel3->setText( tr( "GEOM_RADIUS" ) ); GroupPntVecR->PushButton1->setIcon( image1 ); GroupPntVecR->PushButton2->setIcon( image1 ); - GroupPntVecR->LineEdit1->setReadOnly( true ); GroupPntVecR->LineEdit2->setReadOnly( true ); Group3Pnts = new DlgRef_3Sel( centralWidget() ); - - Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) ); + Group3Pnts->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) ); Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) ); Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) ); Group3Pnts->PushButton1->setIcon( image1 ); Group3Pnts->PushButton2->setIcon( image1 ); Group3Pnts->PushButton3->setIcon( image1 ); - Group3Pnts->LineEdit1->setReadOnly( true ); Group3Pnts->LineEdit2->setReadOnly( true ); Group3Pnts->LineEdit3->setReadOnly( true ); + GroupDimensions = new DlgRef_1Spin( centralWidget() ); + GroupDimensions->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); + GroupDimensions->TextLabel1->setText( tr( "GEOM_RADIUS" ) ); + + GroupOrientation = new DlgRef_3Check( centralWidget() ); + GroupOrientation->GroupBox1->setTitle( tr( "GEOM_ORIENTATION" ) ); + GroupOrientation->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) ); + GroupOrientation->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) ); + GroupOrientation->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) ); + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( GroupPntVecR ); layout->addWidget( Group3Pnts ); + layout->addWidget( GroupDimensions ); + layout->addWidget( GroupOrientation ); /***************************************************************/ setHelpFileName( "create_disk_page.html" ); @@ -121,6 +129,7 @@ void PrimitiveGUI_DiskDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPntVecR->LineEdit1; + myOrientationType = 1; myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); @@ -131,6 +140,8 @@ void PrimitiveGUI_DiskDlg::Init() /* min, max, step and decimals for spin boxes & initial values */ initSpinBox( GroupPntVecR->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY GroupPntVecR->SpinBox_DX->setValue( 100 ); + initSpinBox( GroupDimensions->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + GroupDimensions->SpinBox_DX->setValue( 100 ); /* signals and slots connections */ connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); @@ -156,6 +167,11 @@ void PrimitiveGUI_DiskDlg::Init() connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) ); connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); + connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); + connect( GroupOrientation->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); + connect( GroupOrientation->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); + connect( GroupOrientation->RadioButton3, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -173,6 +189,21 @@ void PrimitiveGUI_DiskDlg::SetDoubleSpinBoxStep( double step ) GroupPntVecR->SpinBox_DX->setSingleStep(step); } +//================================================================================= +// function : RadioBittonClicked() +// purpose : Radio button management +//================================================================================= +void PrimitiveGUI_DiskDlg::RadioButtonClicked() +{ + if ( GroupOrientation->RadioButton1->isChecked() ) + myOrientationType = 1; + else if ( GroupOrientation->RadioButton2->isChecked() ) + myOrientationType = 2; + else if ( GroupOrientation->RadioButton3->isChecked() ) + myOrientationType = 3; + displayPreview(); +} + //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management @@ -188,7 +219,8 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId ) { Group3Pnts->hide(); GroupPntVecR->show(); - + GroupDimensions->hide(); + GroupOrientation->hide(); myEditCurrentArgument = GroupPntVecR->LineEdit1; GroupPntVecR->LineEdit1->setText( "" ); GroupPntVecR->LineEdit2->setText( "" ); @@ -198,13 +230,23 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId ) { GroupPntVecR->hide(); Group3Pnts->show(); - + GroupDimensions->hide(); + GroupOrientation->hide(); myEditCurrentArgument = Group3Pnts->LineEdit1; Group3Pnts->LineEdit1->setText( "" ); Group3Pnts->LineEdit2->setText( "" ); Group3Pnts->LineEdit3->setText( "" ); break; } + case 2: + { + GroupPntVecR->hide(); + Group3Pnts->hide(); + GroupDimensions->show(); + GroupOrientation->show(); + GroupOrientation->RadioButton1->setChecked( true ); + myOrientationType = 1; + } } qApp->processEvents(); @@ -217,6 +259,7 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId ) connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + displayPreview(); } //================================================================================= @@ -249,6 +292,11 @@ bool PrimitiveGUI_DiskDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_DiskDlg::SelectionIntoArgument() { + if (getConstructorId() == 2) { + displayPreview(); + return; + } + myEditCurrentArgument->setText( "" ); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); @@ -420,6 +468,8 @@ double PrimitiveGUI_DiskDlg::getRadius() const switch ( getConstructorId() ) { case 0: r = GroupPntVecR->SpinBox_DX->value(); break; + case 2: + r = GroupDimensions->SpinBox_DX->value(); break; } return r; } @@ -454,6 +504,8 @@ bool PrimitiveGUI_DiskDlg::isValid( QString& msg ) else if ( id == 1 ) return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() && !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ); + else if ( id == 2 ) + return true; return false; } @@ -476,6 +528,10 @@ bool PrimitiveGUI_DiskDlg::execute( ObjectList& objects ) anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskThreePnt( myPoint1, myPoint2, myPoint3 ); res = true; break; + case 2 : + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskR( getRadius(), myOrientationType ); + res = true; + break; } if ( !anObj->_is_nil() ) diff --git a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h index 34752589e..fb9413ebf 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h @@ -30,6 +30,8 @@ class DlgRef_3Sel; class DlgRef_2Sel1Spin; +class DlgRef_1Spin; +class DlgRef_3Check; //================================================================================= // class : PrimitiveGUI_DiskDlg @@ -55,12 +57,15 @@ private: void Init(); void enterEvent( QEvent* ); double getRadius() const; + int myOrientationType; private: GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3; DlgRef_2Sel1Spin* GroupPntVecR; DlgRef_3Sel* Group3Pnts; + DlgRef_1Spin* GroupDimensions; + DlgRef_3Check* GroupOrientation; private slots: void ClickOnOk(); @@ -76,6 +81,7 @@ private slots: void SetEditCurrentArgument(); void ValueChangedInSpinBox(); void SetDoubleSpinBoxStep( double ); + void RadioButtonClicked(); }; #endif // BASICGUI_DISKDLG_H diff --git a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx index a3f2b0c60..93a5036aa 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx @@ -53,7 +53,7 @@ PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget bool modal, Qt::WindowFlags fl ) : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FACE_PLANE_HW" ) ) ); + QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FACE_VEC_HW" ) ) ); QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FACE_HW" ) ) ); @@ -67,8 +67,8 @@ PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget mainFrame()->RadioButton3->close(); GroupPlane = new DlgRef_1Sel2Spin( centralWidget() ); - GroupPlane->GroupBox1->setTitle( tr( "GEOM_FACES" ) ); - GroupPlane->TextLabel1->setText( tr( "GEOM_FACE" ) ); + GroupPlane->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); + GroupPlane->TextLabel1->setText( tr( "GEOM_EDGE" ) ); GroupPlane->TextLabel2->setText( tr( "GEOM_HEIGHT" ) ); GroupPlane->TextLabel3->setText( tr( "GEOM_WIDTH" ) ); GroupPlane->PushButton1->setIcon( image1 ); @@ -79,10 +79,18 @@ PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget GroupDimensions->TextLabel1->setText( tr( "GEOM_HEIGHT" ) ); GroupDimensions->TextLabel2->setText( tr( "GEOM_WIDTH" ) ); + GroupOrientation = new DlgRef_3Check( centralWidget() ); + + GroupOrientation->GroupBox1->setTitle( tr( "GEOM_ORIENTATION" ) ); + GroupOrientation->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) ); + GroupOrientation->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) ); + GroupOrientation->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) ); + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( GroupPlane ); layout->addWidget( GroupDimensions ); + layout->addWidget( GroupOrientation ); /***************************************************************/ @@ -109,9 +117,11 @@ void PrimitiveGUI_FaceDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPlane->LineEdit1; - myFace = GEOM::GEOM_Object::_nil(); + myEdge = GEOM::GEOM_Object::_nil(); globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + + myOrientationType = 1; /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -148,6 +158,10 @@ void PrimitiveGUI_FaceDlg::Init() connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupDimensions->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( GroupOrientation->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); + connect( GroupOrientation->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); + connect( GroupOrientation->RadioButton3, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -175,6 +189,21 @@ void PrimitiveGUI_FaceDlg::ValueChangedInSpinBox( double newValue ) displayPreview(); } +//================================================================================= +// function : RadioBittonClicked() +// purpose : Radio button management +//================================================================================= +void PrimitiveGUI_FaceDlg::RadioButtonClicked() +{ + if ( GroupOrientation->RadioButton1->isChecked() ) + myOrientationType = 1; + else if ( GroupOrientation->RadioButton2->isChecked() ) + myOrientationType = 2; + else if ( GroupOrientation->RadioButton3->isChecked() ) + myOrientationType = 3; + displayPreview(); +} + //================================================================================= // function : ClickOnOk() // purpose : @@ -212,12 +241,13 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId ) case 0: { globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); myEditCurrentArgument = GroupPlane->LineEdit1; myEditCurrentArgument->setText(""); - myFace = GEOM::GEOM_Object::_nil(); + myEdge = GEOM::GEOM_Object::_nil(); GroupDimensions->hide(); + GroupOrientation->hide(); GroupPlane->show(); break; } @@ -226,6 +256,9 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId ) globalSelection(); // close local contexts, if any GroupPlane->hide(); GroupDimensions->show(); + GroupOrientation->show(); + GroupOrientation->RadioButton1->setChecked( true ); + myOrientationType = 1; break; } } @@ -234,6 +267,7 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId ) updateGeometry(); resize( minimumSize() ); SelectionIntoArgument(); + displayPreview(); } //================================================================================= @@ -250,7 +284,7 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() myEditCurrentArgument->setText( "" ); if ( IObjectCount() != 1 ) { - if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil(); + if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge = GEOM::GEOM_Object::_nil(); return; } @@ -267,7 +301,7 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { // Local Selection int anIndex = aMap( 1 ); - aName += QString( ":face_%1" ).arg( anIndex ); + aName += QString( ":edge_%1" ).arg( anIndex ); //Find SubShape Object in Father GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); @@ -280,7 +314,7 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() aSelectedObject = aFindedObject; // get Object from study } else { // Global Selection - if ( aShape.ShapeType() != TopAbs_FACE ) { + if ( aShape.ShapeType() != TopAbs_EDGE ) { aSelectedObject = GEOM::GEOM_Object::_nil(); aName = ""; } @@ -288,7 +322,7 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() } myEditCurrentArgument->setText( aName ); - if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myFace = aSelectedObject; + if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge = aSelectedObject; } displayPreview(); } @@ -305,7 +339,7 @@ void PrimitiveGUI_FaceDlg::SetEditCurrentArgument() globalSelection(); // close previous local contexts if ( send == GroupPlane->PushButton1 ) { myEditCurrentArgument = GroupPlane->LineEdit1; - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); @@ -375,7 +409,7 @@ bool PrimitiveGUI_FaceDlg::isValid( QString& msg ) { const int id = getConstructorId(); if ( id == 0 ) - return !myFace->_is_nil(); + return !myEdge->_is_nil(); else if ( id == 1 ) return true; return false; @@ -391,11 +425,11 @@ bool PrimitiveGUI_FaceDlg::execute( ObjectList& objects ) GEOM::GEOM_Object_var anObj; switch ( getConstructorId() ) { case 0 : - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFacePlaneHW( myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value() ); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceVecHW( myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value() ); res = true; break; case 1 : - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceHW( GroupDimensions->SpinBox_DX->value(), GroupDimensions->SpinBox_DY->value() ); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceHW( GroupDimensions->SpinBox_DX->value(), GroupDimensions->SpinBox_DY->value(), myOrientationType ); res = true; break; } @@ -415,7 +449,7 @@ void PrimitiveGUI_FaceDlg::addSubshapesToStudy() QMap objMap; switch ( getConstructorId() ) { case 0 : - objMap[GroupPlane->LineEdit1->text()] = myFace; + objMap[GroupPlane->LineEdit1->text()] = myEdge; break; } addSubshapesToFather( objMap ); diff --git a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h index 741afd22e..79676748d 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h @@ -30,6 +30,7 @@ class DlgRef_2Spin; class DlgRef_1Sel2Spin; +class DlgRef_3Check; //================================================================================= // class : PrimitiveGUI_FaceDlg @@ -58,10 +59,13 @@ private: GEOM::GEOM_Object_var myPoint1; GEOM::GEOM_Object_var myPoint2; GEOM::GEOM_Object_var myVector; - GEOM::GEOM_Object_var myFace; + GEOM::GEOM_Object_var myEdge; + + int myOrientationType; DlgRef_2Spin* GroupDimensions; DlgRef_1Sel2Spin* GroupPlane; + DlgRef_3Check* GroupOrientation; private slots: void ClickOnOk(); @@ -76,6 +80,7 @@ private slots: void SetEditCurrentArgument(); void ValueChangedInSpinBox( double ); void SetDoubleSpinBoxStep( double ); + void RadioButtonClicked(); }; #endif // BASICGUI_FACEDLG_H