From bb33eafebde37578d5d85f0e36223a3131a67adc Mon Sep 17 00:00:00 2001 From: dmv Date: Fri, 8 Aug 2008 13:43:36 +0000 Subject: [PATCH] 0016757: EDF 546 GEOM : Add Face and Disc in geom primitives --- idl/GEOM_Gen.idl | 2 +- idl/GEOM_Superv.idl | 2 +- src/DlgRef/DlgRef.cxx | 14 +++ src/DlgRef/DlgRef.h | 18 ++++ src/DlgRef/Makefile.am | 1 + src/GEOMGUI/GEOM_images.ts | 2 +- src/GEOMGUI/GEOM_msg_en.ts | 8 ++ src/GEOMImpl/GEOMImpl_FaceDriver.cxx | 16 ++- src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx | 14 +-- src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx | 2 +- src/GEOMImpl/GEOMImpl_Types.hxx | 2 +- src/GEOM_I/GEOM_I3DPrimOperations_i.cc | 16 +-- src/GEOM_I/GEOM_I3DPrimOperations_i.hh | 6 +- src/GEOM_I_Superv/GEOM_Superv_i.cc | 12 +-- src/GEOM_I_Superv/GEOM_Superv_i.hh | 2 +- src/GEOM_SWIG/GEOM_TestAll.py | 2 +- src/GEOM_SWIG/geompyDC.py | 9 +- src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx | 51 ++++----- src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h | 4 +- src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx | 112 +++++++++++++++----- src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h | 7 +- 21 files changed, 206 insertions(+), 96 deletions(-) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 06cf8084a..6220952c2 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -839,7 +839,7 @@ module GEOM * \param theW horisontal size (width). * \return New GEOM_Object, containing the created face. */ - GEOM_Object MakeFaceVecHW (in GEOM_Object theVec, in double theH, in double theW); + GEOM_Object MakeFaceObjHW (in GEOM_Object theObj, in double theH, in double theW); /*! * Create a Disk (circular face) with given center, normal vector and radius. * \param thePnt disk center. diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 1b01d8dc7..0c1b2252d 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -129,7 +129,7 @@ module GEOM GEOM_Object MakeFaceHW (in double theH, in double theW, in short theOrientation) ; - GEOM_Object MakeFaceVecHW (in GEOM_Object theVec, + GEOM_Object MakeFaceObjHW (in GEOM_Object theObj, in double theH, in double theW) ; GEOM_Object MakeDiskPntVecR (in GEOM_Object thePnt, diff --git a/src/DlgRef/DlgRef.cxx b/src/DlgRef/DlgRef.cxx index b29fdee59..f93df1ac2 100644 --- a/src/DlgRef/DlgRef.cxx +++ b/src/DlgRef/DlgRef.cxx @@ -471,6 +471,20 @@ DlgRef_3Check::~DlgRef_3Check() { } +////////////////////////////////////////// +// DlgRef_3Radio +////////////////////////////////////////// + +DlgRef_3Radio::DlgRef_3Radio( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); +} + +DlgRef_3Radio::~DlgRef_3Radio() +{ +} + ////////////////////////////////////////// // DlgRef_3Sel1Check ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.h b/src/DlgRef/DlgRef.h index 9ff6b6869..4e677a321 100644 --- a/src/DlgRef/DlgRef.h +++ b/src/DlgRef/DlgRef.h @@ -194,6 +194,8 @@ public: ~DlgRef_1Sel3Check(); }; + + ////////////////////////////////////////// // DlgRef_1Sel3Spin ////////////////////////////////////////// @@ -546,6 +548,22 @@ public: ~DlgRef_3Check(); }; +////////////////////////////////////////// +// DlgRef_1Sel3Radio +////////////////////////////////////////// + +#include "ui_DlgRef_3Radio_QTD.h" + +class DLGREF_EXPORT DlgRef_3Radio : public QWidget, + public Ui::DlgRef_3Radio_QTD +{ + Q_OBJECT + +public: + DlgRef_3Radio( QWidget* = 0, Qt::WindowFlags = 0 ); + ~DlgRef_3Radio(); +}; + ////////////////////////////////////////// // DlgRef_3Sel1Check ////////////////////////////////////////// diff --git a/src/DlgRef/Makefile.am b/src/DlgRef/Makefile.am index ed593f335..bd8407d3d 100644 --- a/src/DlgRef/Makefile.am +++ b/src/DlgRef/Makefile.am @@ -70,6 +70,7 @@ UIC_FILES = \ ui_DlgRef_2SelExt_QTD.h \ ui_DlgRef_2Spin_QTD.h \ ui_DlgRef_3Check_QTD.h \ + ui_DlgRef_3Radio_QTD.h \ ui_DlgRef_3Sel1Check_QTD.h \ ui_DlgRef_3Sel1Spin_QTD.h \ ui_DlgRef_3Sel3Spin1Check_QTD.h \ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 3442ba160..8f5801fd1 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -91,7 +91,7 @@ face_hw.png - ICON_DLG_FACE_VEC_HW + ICON_DLG_FACE_OBJ_HW face_vechw.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 8188a2b31..b1b0753c9 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -420,6 +420,10 @@ Please, select face, shell or solid and try again GEOM_DISK Disk + + GEOM_DISK_TITLE + Create A Disk + GEOM_DIMENSIONS Dimensions @@ -924,6 +928,10 @@ Please, select face, shell or solid and try again GEOM_OBJECT Object + + GEOM_OBJECT_TYPE + Object Type + GEOM_OBJECTS Objects diff --git a/src/GEOMImpl/GEOMImpl_FaceDriver.cxx b/src/GEOMImpl/GEOMImpl_FaceDriver.cxx index 9d8deefef..f1a325c2c 100755 --- a/src/GEOMImpl/GEOMImpl_FaceDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FaceDriver.cxx @@ -74,11 +74,11 @@ Standard_Integer GEOMImpl_FaceDriver::Execute(TFunction_Logbook& log) const TopoDS_Shape aShape; - 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); + if (aType == FACE_OBJ_H_W) { + Handle(GEOM_Function) aRefFunct = aFI.GetRef1(); + TopoDS_Shape aRefShape = aRefFunct->GetValue(); + if (aRefShape.ShapeType() == TopAbs_EDGE) { + TopoDS_Edge anEdge = TopoDS::Edge(aRefShape); double aH = aFI.GetH() / 2.0; double aW = aFI.GetW() / 2.0; TopoDS_Vertex V1, V2; @@ -87,6 +87,12 @@ Standard_Integer GEOMImpl_FaceDriver::Execute(TFunction_Logbook& log) const 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 (aRefShape.ShapeType() == TopAbs_FACE) { + double aH = aFI.GetH() / 2.0; + double aW = aFI.GetW() / 2.0; + gp_Ax3 anAx = GEOMImpl_IMeasureOperations::GetPosition(aRefShape); + gp_Pln aPln (anAx); + aShape = BRepBuilderAPI_MakeFace(aPln, -aH, +aH, -aW, +aW).Shape(); } } else if (aType == FACE_H_W) { diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 37fafba5c..983974343 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -249,21 +249,21 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double //============================================================================= /*! - * MakeFaceVecHW + * MakeFaceObjHW */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceVecHW (Handle(GEOM_Object) theVec, +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj, double theH, double theW) { SetErrorCode(KO); - if (theVec.IsNull()) return NULL; + if (theObj.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_VEC_H_W); + Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly @@ -271,7 +271,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceVecHW (Handle(GEOM_Objec GEOMImpl_IFace aFI (aFunction); - Handle(GEOM_Function) aRefFunction1 = theVec->GetLastFunction(); + Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction(); if (aRefFunction1.IsNull()) return aFace; @@ -297,8 +297,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceVecHW (Handle(GEOM_Objec } //Make a Python command - GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceVecHW(" - << theVec << ", " << theH << ", " << theW << ")"; + GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW(" + << theObj << ", " << theH << ", " << theW << ")"; SetErrorCode(OK); return aFace; diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index ba2a0fbda..5099605fc 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -37,7 +37,7 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2); Standard_EXPORT Handle(GEOM_Object) MakeFaceHW (double theH, double theW, int theOrientation); - Standard_EXPORT Handle(GEOM_Object) MakeFaceVecHW (Handle(GEOM_Object) theVec, + Standard_EXPORT Handle(GEOM_Object) MakeFaceObjHW (Handle(GEOM_Object) theObj, double theH, double theW); Standard_EXPORT Handle(GEOM_Object) MakeDiskThreePnt (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2, diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index b2f3c58d1..4220d7488 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -158,7 +158,7 @@ #define BOX_DX_DY_DZ 1 #define BOX_TWO_PNT 2 -#define FACE_VEC_H_W 1 +#define FACE_OBJ_H_W 1 #define FACE_H_W 2 #define DISK_PNT_VEC_R 1 diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index 7bd3eaa69..6e6a4b8be 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -130,11 +130,11 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceHW (CORBA::Double theH, //============================================================================= /*! - * MakeFaceVecHW + * MakeFaceObjHW */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceVecHW - (GEOM::GEOM_Object_ptr theVec, +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceObjHW + (GEOM::GEOM_Object_ptr theObj, CORBA::Double theH, CORBA::Double theW) { @@ -143,18 +143,18 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceVecHW //Set a not done flag GetOperations()->SetNotDone(); - if (theVec == NULL || theH == 0 || theW == 0) + if (theObj == NULL || theH == 0 || theW == 0) return aGEOMObject._retn(); //Get the reference points - Handle(GEOM_Object) aFace = GetOperations()->GetEngine()->GetObject - (theVec->GetStudyID(), theVec->GetEntry()); + Handle(GEOM_Object) anObj = GetOperations()->GetEngine()->GetObject + (theObj->GetStudyID(), theObj->GetEntry()); - if (aFace.IsNull()) + if (anObj.IsNull()) return aGEOMObject._retn(); //Create the Face - Handle(GEOM_Object) anObject = GetOperations()->MakeFaceVecHW(aFace, theH, theW); + Handle(GEOM_Object) anObject = GetOperations()->MakeFaceObjHW(anObj, theH, theW); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index 737c61305..0f5641eae 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -51,9 +51,9 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : 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 MakeFaceObjHW (GEOM::GEOM_Object_ptr theObj, + CORBA::Double theH, + CORBA::Double theW); GEOM::GEOM_Object_ptr MakeDiskPntVecR (GEOM::GEOM_Object_ptr theCenter, GEOM::GEOM_Object_ptr theVector, diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 6f46ba2ea..97d7f17af 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -787,17 +787,17 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFaceHW (CORBA::Double theH, } //============================================================================= -// MakeFaceVecHW: +// MakeFaceObjHW: //============================================================================= -GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFaceVecHW (GEOM::GEOM_Object_ptr theVec, +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFaceObjHW (GEOM::GEOM_Object_ptr theObj, CORBA::Double theH, CORBA::Double theW) { - beginService( " GEOM_Superv_i::MakeFaceVecHW" ); - MESSAGE("GEOM_Superv_i::MakeFaceVecHW"); + beginService( " GEOM_Superv_i::MakeFaceObjHW" ); + MESSAGE("GEOM_Superv_i::MakeFaceObjHW"); get3DPrimOp(); - GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFaceVecHW(theVec, theH, theW); - endService( " GEOM_Superv_i::MakeFaceVecHW" ); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFaceObjHW(theObj, theH, theW); + endService( " GEOM_Superv_i::MakeFaceObjHW" ); return anObj; } diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 39051115e..75a66523e 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -190,7 +190,7 @@ public: GEOM::GEOM_Object_ptr MakeFaceHW (CORBA::Double theH, CORBA::Double theW, CORBA::Short theOrientation); - GEOM::GEOM_Object_ptr MakeFaceVecHW (GEOM::GEOM_Object_ptr theFace, + GEOM::GEOM_Object_ptr MakeFaceObjHW (GEOM::GEOM_Object_ptr theObj, CORBA::Double theH, CORBA::Double theW); GEOM::GEOM_Object_ptr MakeDiskPntVecR (GEOM::GEOM_Object_ptr theCenter, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 49427ae28..ca727edcb 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -139,7 +139,7 @@ def TestAll (geompy, math): WantPlanarFace) #(List of GEOM_Object_ptr, Boolean)->GEOM_Object_ptr Face2 = geompy.MakeFace(Sketcher, WantPlanarFace) 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 + Face4 = geompy.MakeFaceObjHW (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 diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 907a0ee23..d4f38a78b 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -696,16 +696,17 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Create a face from another plane and two sizes, # vertical size and horisontal size. - # @param theVec Normale vector to the creating face. + # @param theObj Normale vector to the creating face or + # the face object. # @param theH Height (vertical size). # @param theW Width (horisontal size). # @return New GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" - def MakeFaceVecHW(self, theVec, theH, theW): + def MakeFaceObjHW(self, theObj, theH, theW): # Example: see GEOM_TestAll.py - anObj = self.PrimOp.MakeFaceVecHW(theVec, theH, theW) - RaiseIfFailed("MakeFaceVecHW", self.PrimOp) + anObj = self.PrimOp.MakeFaceObjHW(theObj, theH, theW) + RaiseIfFailed("MakeFaceObjHW", self.PrimOp) return anObj ## Create a disk with given center, normal vector and radius. diff --git a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx index daf7b78e7..20f9ef21a 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.cxx @@ -62,9 +62,9 @@ PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg( GeometryGUI* theGeometryGUI, QWidget /***************************************************************/ mainFrame()->GroupConstructors->setTitle( tr( "GEOM_DISK" ) ); - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setIcon( image2 ); - mainFrame()->RadioButton3->setIcon( image3 ); + mainFrame()->RadioButton1->setIcon( image3 ); + mainFrame()->RadioButton2->setIcon( image0 ); + mainFrame()->RadioButton3->setIcon( image2 ); GroupPntVecR = new DlgRef_2Sel1Spin( centralWidget() ); GroupPntVecR->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); @@ -92,7 +92,7 @@ PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg( GeometryGUI* theGeometryGUI, QWidget GroupDimensions->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); GroupDimensions->TextLabel1->setText( tr( "GEOM_RADIUS" ) ); - GroupOrientation = new DlgRef_3Check( centralWidget() ); + GroupOrientation = new DlgRef_3Radio( centralWidget() ); GroupOrientation->GroupBox1->setTitle( tr( "GEOM_ORIENTATION" ) ); GroupOrientation->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) ); GroupOrientation->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) ); @@ -216,6 +216,16 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId ) switch ( constructorId ) { case 0: + { + GroupPntVecR->hide(); + Group3Pnts->hide(); + GroupDimensions->show(); + GroupOrientation->show(); + GroupOrientation->RadioButton1->setChecked( true ); + myOrientationType = 1; + break; + } + case 1: { Group3Pnts->hide(); GroupPntVecR->show(); @@ -226,7 +236,7 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId ) GroupPntVecR->LineEdit2->setText( "" ); break; } - case 1: + case 2: { GroupPntVecR->hide(); Group3Pnts->show(); @@ -238,15 +248,6 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId ) Group3Pnts->LineEdit3->setText( "" ); break; } - case 2: - { - GroupPntVecR->hide(); - Group3Pnts->hide(); - GroupDimensions->show(); - GroupOrientation->show(); - GroupOrientation->RadioButton1->setChecked( true ); - myOrientationType = 1; - } } qApp->processEvents(); @@ -292,7 +293,7 @@ bool PrimitiveGUI_DiskDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_DiskDlg::SelectionIntoArgument() { - if (getConstructorId() == 2) { + if (getConstructorId() == 0) { displayPreview(); return; } @@ -467,9 +468,9 @@ double PrimitiveGUI_DiskDlg::getRadius() const double r = 0.; switch ( getConstructorId() ) { case 0: - r = GroupPntVecR->SpinBox_DX->value(); break; - case 2: r = GroupDimensions->SpinBox_DX->value(); break; + case 1: + r = GroupPntVecR->SpinBox_DX->value(); break; } return r; } @@ -500,12 +501,12 @@ bool PrimitiveGUI_DiskDlg::isValid( QString& msg ) { const int id = getConstructorId(); if ( id == 0 ) - return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0; + return true; else if ( id == 1 ) + return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0; + else if ( id == 2 ) 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; } @@ -521,15 +522,15 @@ bool PrimitiveGUI_DiskDlg::execute( ObjectList& objects ) switch ( getConstructorId() ) { case 0 : - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskPntVecR( myPoint, myDir, getRadius() ); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskR( getRadius(), myOrientationType ); res = true; break; case 1 : - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskThreePnt( myPoint1, myPoint2, myPoint3 ); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskPntVecR( myPoint, myDir, getRadius() ); res = true; break; case 2 : - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskR( getRadius(), myOrientationType ); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskThreePnt( myPoint1, myPoint2, myPoint3 ); res = true; break; } @@ -552,11 +553,11 @@ void PrimitiveGUI_DiskDlg::addSubshapesToStudy() QMap objMap; switch ( getConstructorId() ) { - case 0: + case 1: objMap[GroupPntVecR->LineEdit1->text()] = myPoint; objMap[GroupPntVecR->LineEdit2->text()] = myDir; break; - case 1: + case 2: objMap[Group3Pnts->LineEdit1->text()] = myPoint1; objMap[Group3Pnts->LineEdit2->text()] = myPoint2; objMap[Group3Pnts->LineEdit3->text()] = myPoint3; diff --git a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h index fb9413ebf..da2630b31 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_DiskDlg.h @@ -31,7 +31,7 @@ class DlgRef_3Sel; class DlgRef_2Sel1Spin; class DlgRef_1Spin; -class DlgRef_3Check; +class DlgRef_3Radio; //================================================================================= // class : PrimitiveGUI_DiskDlg @@ -65,7 +65,7 @@ private: DlgRef_2Sel1Spin* GroupPntVecR; DlgRef_3Sel* Group3Pnts; DlgRef_1Spin* GroupDimensions; - DlgRef_3Check* GroupOrientation; + DlgRef_3Radio* GroupOrientation; private slots: void ClickOnOk(); diff --git a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx index 93a5036aa..011ceb53b 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_VEC_HW" ) ) ); + QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FACE_OBJ_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" ) ) ); @@ -61,8 +61,8 @@ PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget /***************************************************************/ mainFrame()->GroupConstructors->setTitle( tr( "GEOM_FACE" ) ); - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setIcon( image2 ); + mainFrame()->RadioButton1->setIcon( image2 ); + mainFrame()->RadioButton2->setIcon( image0 ); mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->close(); @@ -74,12 +74,19 @@ PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget GroupPlane->PushButton1->setIcon( image1 ); GroupPlane->LineEdit1->setReadOnly( true ); + GroupType = new DlgRef_3Radio( centralWidget() ); + GroupType->GroupBox1->setTitle( tr( "GEOM_OBJECT_TYPE" ) ); + GroupType->RadioButton1->setText( tr( "GEOM_EDGE" ) ); + GroupType->RadioButton2->setText( tr( "GEOM_FACE" ) ); + GroupType->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); + GroupType->RadioButton3->close(); + GroupDimensions = new DlgRef_2Spin( centralWidget() ); GroupDimensions->GroupBox1->setTitle( tr( "GEOM_BOX_OBJ" ) ); GroupDimensions->TextLabel1->setText( tr( "GEOM_HEIGHT" ) ); GroupDimensions->TextLabel2->setText( tr( "GEOM_WIDTH" ) ); - GroupOrientation = new DlgRef_3Check( centralWidget() ); + GroupOrientation = new DlgRef_3Radio( centralWidget() ); GroupOrientation->GroupBox1->setTitle( tr( "GEOM_ORIENTATION" ) ); GroupOrientation->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) ); @@ -88,6 +95,7 @@ PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); + layout->addWidget( GroupType ); layout->addWidget( GroupPlane ); layout->addWidget( GroupDimensions ); layout->addWidget( GroupOrientation ); @@ -117,9 +125,11 @@ void PrimitiveGUI_FaceDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPlane->LineEdit1; + GroupType->RadioButton1->setChecked(true); myEdge = GEOM::GEOM_Object::_nil(); + myFace = GEOM::GEOM_Object::_nil(); globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + // localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); myOrientationType = 1; @@ -162,6 +172,9 @@ void PrimitiveGUI_FaceDlg::Init() connect( GroupOrientation->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); connect( GroupOrientation->RadioButton3, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); + connect( GroupType->RadioButton1, SIGNAL( clicked() ), this, SLOT( TypeButtonClicked() ) ); + connect( GroupType->RadioButton2, SIGNAL( clicked() ), this, SLOT( TypeButtonClicked() ) ); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -204,6 +217,24 @@ void PrimitiveGUI_FaceDlg::RadioButtonClicked() displayPreview(); } +//================================================================================= +// function : TypeBittonClicked() +// purpose : Radio button management +//================================================================================= +void PrimitiveGUI_FaceDlg::TypeButtonClicked() +{ + if ( GroupType->RadioButton1->isChecked() ) { + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + GroupPlane->TextLabel1->setText( tr( "GEOM_EDGE" ) ); + } + else if ( GroupType->RadioButton2->isChecked() ) { + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + GroupPlane->TextLabel1->setText( tr( "GEOM_FACE" ) ); + } +} + //================================================================================= // function : ClickOnOk() // purpose : @@ -239,28 +270,32 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId ) { switch ( constructorId ) { case 0: + { + globalSelection(); // close local contexts, if any + GroupPlane->hide(); + GroupDimensions->show(); + GroupOrientation->show(); + GroupType->hide(); + GroupOrientation->RadioButton1->setChecked( true ); + myOrientationType = 1; + break; + } + case 1: { globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); - myEditCurrentArgument = GroupPlane->LineEdit1; myEditCurrentArgument->setText(""); myEdge = GEOM::GEOM_Object::_nil(); + myFace = GEOM::GEOM_Object::_nil(); + GroupType->RadioButton1->setChecked( true ); + TypeButtonClicked(); GroupDimensions->hide(); GroupOrientation->hide(); + GroupType->show(); GroupPlane->show(); break; } - case 1: - { - globalSelection(); // close local contexts, if any - GroupPlane->hide(); - GroupDimensions->show(); - GroupOrientation->show(); - GroupOrientation->RadioButton1->setChecked( true ); - myOrientationType = 1; - break; - } } qApp->processEvents(); @@ -276,7 +311,7 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId ) //================================================================================= void PrimitiveGUI_FaceDlg::SelectionIntoArgument() { - if (getConstructorId() != 0) { + if (getConstructorId() == 0) { displayPreview(); return; } @@ -290,18 +325,25 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() // nbSel == 1 Standard_Boolean aRes = Standard_False; + TopAbs_ShapeEnum aNeedType = TopAbs_EDGE; GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); if ( !CORBA::is_nil( aSelectedObject ) && aRes ) { QString aName = GEOMBase::GetName( aSelectedObject ); TopoDS_Shape aShape; if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + if (GroupType->RadioButton2->isChecked()) + aNeedType = TopAbs_FACE; + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); TColStd_IndexedMapOfInteger aMap; aSelMgr->GetIndexes( firstIObject(), aMap ); if ( aMap.Extent() == 1 ) { // Local Selection int anIndex = aMap( 1 ); - aName += QString( ":edge_%1" ).arg( anIndex ); + if ( aNeedType == TopAbs_EDGE ) + aName += QString( ":edge_%1" ).arg( anIndex ); + else + aName += QString( ":face_%1" ).arg( anIndex ); //Find SubShape Object in Father GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); @@ -314,7 +356,7 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() aSelectedObject = aFindedObject; // get Object from study } else { // Global Selection - if ( aShape.ShapeType() != TopAbs_EDGE ) { + if ( aShape.ShapeType() != aNeedType ) { aSelectedObject = GEOM::GEOM_Object::_nil(); aName = ""; } @@ -322,7 +364,10 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() } myEditCurrentArgument->setText( aName ); - if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge = aSelectedObject; + if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_EDGE ) + myEdge = aSelectedObject; + else if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_FACE ) + myFace = aSelectedObject; } displayPreview(); } @@ -339,7 +384,10 @@ void PrimitiveGUI_FaceDlg::SetEditCurrentArgument() globalSelection(); // close previous local contexts if ( send == GroupPlane->PushButton1 ) { myEditCurrentArgument = GroupPlane->LineEdit1; - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + if (GroupType->RadioButton1->isChecked()) + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + else if (GroupType->RadioButton1->isChecked()) + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); } myEditCurrentArgument->setFocus(); @@ -409,9 +457,13 @@ bool PrimitiveGUI_FaceDlg::isValid( QString& msg ) { const int id = getConstructorId(); if ( id == 0 ) - return !myEdge->_is_nil(); - else if ( id == 1 ) return true; + else if ( id == 1 ) { + if (GroupType->RadioButton1->isChecked()) + return !myEdge->_is_nil(); + else if (GroupType->RadioButton2->isChecked()) + return !myFace->_is_nil(); + } return false; } @@ -425,11 +477,14 @@ bool PrimitiveGUI_FaceDlg::execute( ObjectList& objects ) GEOM::GEOM_Object_var anObj; switch ( getConstructorId() ) { case 0 : - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceVecHW( myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value() ); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceHW( GroupDimensions->SpinBox_DX->value(), GroupDimensions->SpinBox_DY->value(), myOrientationType ); res = true; break; case 1 : - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceHW( GroupDimensions->SpinBox_DX->value(), GroupDimensions->SpinBox_DY->value(), myOrientationType ); + if ( GroupType->RadioButton1->isChecked() ) + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceObjHW( myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value() ); + else if (GroupType->RadioButton2->isChecked()) + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceObjHW( myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value() ); res = true; break; } @@ -448,8 +503,11 @@ void PrimitiveGUI_FaceDlg::addSubshapesToStudy() { QMap objMap; switch ( getConstructorId() ) { - case 0 : - objMap[GroupPlane->LineEdit1->text()] = myEdge; + case 1 : + if ( GroupType->RadioButton1->isChecked() ) + objMap[GroupPlane->LineEdit1->text()] = myEdge; + if ( GroupType->RadioButton2->isChecked() ) + objMap[GroupPlane->LineEdit1->text()] = myFace; break; } addSubshapesToFather( objMap ); diff --git a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h index 79676748d..c9e59f7ae 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.h @@ -30,7 +30,7 @@ class DlgRef_2Spin; class DlgRef_1Sel2Spin; -class DlgRef_3Check; +class DlgRef_3Radio; //================================================================================= // class : PrimitiveGUI_FaceDlg @@ -60,12 +60,14 @@ private: GEOM::GEOM_Object_var myPoint2; GEOM::GEOM_Object_var myVector; GEOM::GEOM_Object_var myEdge; + GEOM::GEOM_Object_var myFace; int myOrientationType; DlgRef_2Spin* GroupDimensions; DlgRef_1Sel2Spin* GroupPlane; - DlgRef_3Check* GroupOrientation; + DlgRef_3Radio* GroupOrientation; + DlgRef_3Radio* GroupType; private slots: void ClickOnOk(); @@ -81,6 +83,7 @@ private slots: void ValueChangedInSpinBox( double ); void SetDoubleSpinBoxStep( double ); void RadioButtonClicked(); + void TypeButtonClicked(); }; #endif // BASICGUI_FACEDLG_H -- 2.39.2