From cb32f89e648187ff92eacc3addecc551b25b25df Mon Sep 17 00:00:00 2001 From: rnc Date: Thu, 1 Mar 2012 14:35:25 +0000 Subject: [PATCH] Added 2 new operations: - Extruded cut, allows to add material an existing shape by extrusion of a profile - Extruded boss, allows to remove material from an existing shape by extrusion od a profile Modified the sketcher dialog in order to use MakeSketcherOnPLane API instead of MakeSketcher. It is now possible to make a skecth directly on the face of a shape without creating a local coordinate system. Code refactoring in the sketcher dialog --- idl/GEOM_Gen.idl | 17 + resources/Makefile.am | 3 + resources/draft.png | Bin 0 -> 669 bytes resources/extruded_boss.png | Bin 0 -> 839 bytes resources/extruded_cut.png | Bin 0 -> 778 bytes src/DlgRef/DlgRef.cxx | 14 + src/DlgRef/DlgRef.h | 16 + src/DlgRef/DlgRef.pro | 1 + src/DlgRef/DlgRef_2Sel2Spin1Push_QTD.ui | 149 +++++ src/DlgRef/Makefile.am | 1 + src/EntityGUI/EntityGUI_SketcherDlg.cxx | 524 ++++++++++-------- src/EntityGUI/EntityGUI_SketcherDlg.h | 16 +- src/GEOMGUI/GEOM_images.ts | 18 +- src/GEOMGUI/GEOM_msg_en.ts | 33 ++ src/GEOMGUI/GEOM_msg_fr.ts | 4 + src/GEOMGUI/GeometryGUI.cxx | 103 ++-- src/GEOMGUI/GeometryGUI_Operations.h | 2 + src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx | 82 +++ src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx | 5 +- src/GEOMImpl/GEOMImpl_IPrism.hxx | 49 +- src/GEOMImpl/GEOMImpl_PrismDriver.cxx | 143 ++++- src/GEOMImpl/GEOMImpl_Types.hxx | 5 + src/GEOM_I/GEOM_I3DPrimOperations_i.cc | 31 ++ src/GEOM_I/GEOM_I3DPrimOperations_i.hh | 8 +- src/GEOM_SWIG/geompyDC.py | 60 +- src/OperationGUI/Makefile.am | 4 + src/OperationGUI/OperationGUI.cxx | 3 + src/OperationGUI/OperationGUI.h | 2 + .../OperationGUI_ExtrudedFeatureDlg.cxx | 382 +++++++++++++ .../OperationGUI_ExtrudedFeatureDlg.h | 88 +++ 30 files changed, 1453 insertions(+), 310 deletions(-) create mode 100644 resources/draft.png create mode 100644 resources/extruded_boss.png create mode 100644 resources/extruded_cut.png create mode 100644 src/DlgRef/DlgRef_2Sel2Spin1Push_QTD.ui create mode 100644 src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.cxx create mode 100644 src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.h diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 919daa260..1792e88e2 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1311,6 +1311,23 @@ module GEOM in double theDX, in double theDY, in double theDZ, in double theScaleFactor); + + /*! + * \brief Add / Remove material to / from a solid by extrusion of the base shape on the given distance. + * \param theInitShape Initial shape on which to perform the feature.It has to be a solid or + * a compound made of a single solid + * \param theBase Edge or wire defining the base shape to be extruded. + * \param theHeight Prism dimension along the normal of the face. + * \param theAngle Draft angel in degrees + * \param theFuse If true material is added else material is removed + * \return New GEOM_Object, containing the modified shape + */ + GEOM_Object MakeDraftPrism (in GEOM_Object theInitShape, + in GEOM_Object theBase, + in double theHeight, + in double theAngle, + in boolean theFuse); + /*! * \brief Create a shape by extrusion of the base shape along * the path shape. The path shape can be a wire or an edge. diff --git a/resources/Makefile.am b/resources/Makefile.am index 8938d374e..9719dd063 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -78,8 +78,11 @@ disk_r.png \ display.png \ displayonly.png \ displayall.png \ +draft.png \ erase.png \ eraseall.png \ +extruded_boss.png \ +extruded_cut.png \ face_hw.png \ face_vechw.png \ feature_detect.png \ diff --git a/resources/draft.png b/resources/draft.png new file mode 100644 index 0000000000000000000000000000000000000000..d99c8a60530ad2d015655d1470a956f3ffb1aa98 GIT binary patch literal 669 zcmV;O0%HA%P)eSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00H$$ zL_t(I%gvO(ZWBQehrc^tA}k6hP$(#9o3A?RVeo&JO(VQFVN)JLb9~00GfnR81xmML>ij1tFmj z5-6NdAO#AQIRz&tZ|?zLf!wr!buWTf2M2#wiqLpAuj>%NBj6oyR<{k8ihqH{cs8%6 z!vRYP;0|yDsD1;g{IN3>;p5r7nvRA@qAI|RMbp~9pHKJpI$K?GC<=!ArMHxPgq z7ZOZibt4JQ_wsRC329ysmT)I1Mj(Is< zcgO7NKGk)_`T6;Du{e7Jd;u1~dtk8(>;ZRy$H0AHzg3F1de-p+_zau@-`3rxY87@L zxDDL=LqF8&Hm%cJ0^e8QWoJKJEvh@3X!|{O?=iqHWPqy(`wq+v00000NkvXXu0mjf DPIVCE literal 0 HcmV?d00001 diff --git a/resources/extruded_boss.png b/resources/extruded_boss.png new file mode 100644 index 0000000000000000000000000000000000000000..fca4e90d8807d8098b51c338435bbc47a9efc29b GIT binary patch literal 839 zcmV-N1GxN&P)nu~K~y-)t&~k`T~!o@pA)Z8H3+3rsvWjEa1u!oM+$aQaS|)k zK@c&Rf#An)s1EL|oeQNS!Sn}Itb*QvvkuzMBh-;WlJ?wl_SxTSF9+wIo5UN$iW@c? z4rf2S?|Ro>m8$Z8t`R_0RYyK1yw~vaL!?^rD+=Kx@K>0kGig_Iq>hW za~D6M8a+c2MWi4_klk}HDrVAP4 zGdA>q&L@mdv^H^je3{ixza6f>1Du&FTwh<;^OwFP=7I|uc`6g4kfb1@6jc-uQC!S? zKYowbKl_g4%z!u#ERO)z*4ET}&)u!Bh%sWVrEOcft|P`s&Y4mQ05L|4F}(5l7RecM z=oUi>A+Ykn*N7BCE==o3r0Q9G5>hU`x>+-1Df~2km+TEWT5_<9K<_<%X3xjW(?u zb+i=TfA|p78k)9cdvz6K`XsevRMOnCB>xYVQz7NV){8HZPMyM8%Z2T2jAuyW-pX76_-_5fS|fuwMJ4coTG zxJ+G7=P>Im!G}3)bYdAqU;wC6QSsX^HvuL`6gEvm@`h^|@VaDNW` z52J4Z26V%4cn$b?cK+M706RPn4Y2cs3U`5D55oWk%g+I4faNDtxO*4|@E878ElNl@ RT66#a002ovPDHLkV1iJ)a0LJW literal 0 HcmV?d00001 diff --git a/resources/extruded_cut.png b/resources/extruded_cut.png new file mode 100644 index 0000000000000000000000000000000000000000..21ae1cf2b99c7e7c1f1f759be1922302631ac784 GIT binary patch literal 778 zcmV+l1NHogP)U>df%x~d;9{z6RBUJ4l-GR9|` z&;qPa7@rt7iLLdUeD>r0$@Lq+rB30>%8FiDyiLpn7c%leCPX1gK}0F4C?KM^nAu+c znlFBOKyqe+xB|@104y&rtM{HK4}T@bNYgZo$78Iu#2CprQ%V6K#)vV7FMobWa)umi zzbGLDKDqT9B889(|JTQ)>O*`IQZB8!)5nmdu(SRZ*&A|f$f4;2z4!Pi{Qdg|Ap~6G zaNg0lrd>PNRrcEL&9*oxP*SAi_;Q6Y3n?WwFJA`Wo5MrQ)gLN2Q@6XZq|k0u3t9v% z(g(&EiMe2{MPsA_PL7YcFa_&Cr@2(g6iGdW1Av?}QWR?}gouX7{=xn^*krAeI?Iy$ zYb>XNZ7doC00#$$Jlk06{mbOrs%AeXM~5We2O49rAz_R~Ltt)uo0Elw-ann&*}?wz z4**U5FOotphXa7|c#LrwYt1WRT}%L~R8;)+_#VI?=M;`cBa$~*Yda;cisVLZ4x?l5 z3}%2KU@BFmsw(~b+dB*fGvr{ANiu<3qifW5a=I0XKjh5<}0e*|0tX5Uiba2f{i9FnpDrJVrnfdBvi07*qo IM6N<$f*Ai#ng9R* literal 0 HcmV?d00001 diff --git a/src/DlgRef/DlgRef.cxx b/src/DlgRef/DlgRef.cxx index 5af5142e2..8c21e214d 100644 --- a/src/DlgRef/DlgRef.cxx +++ b/src/DlgRef/DlgRef.cxx @@ -428,6 +428,20 @@ DlgRef_2Sel2Spin::~DlgRef_2Sel2Spin() { } +////////////////////////////////////////// +// DlgRef_2Sel2Spin1Push +////////////////////////////////////////// + +DlgRef_2Sel2Spin1Push::DlgRef_2Sel2Spin1Push( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); +} + +DlgRef_2Sel2Spin1Push::~DlgRef_2Sel2Spin1Push() +{ +} + ////////////////////////////////////////// // DlgRef_2Sel3Spin2Rb ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.h b/src/DlgRef/DlgRef.h index 0436df09a..0673ad7dc 100644 --- a/src/DlgRef/DlgRef.h +++ b/src/DlgRef/DlgRef.h @@ -499,6 +499,22 @@ public: ~DlgRef_2Sel2Spin(); }; +////////////////////////////////////////// +// DlgRef_2Sel2Spin1Push +////////////////////////////////////////// + +#include "ui_DlgRef_2Sel2Spin1Push_QTD.h" + +class DLGREF_EXPORT DlgRef_2Sel2Spin1Push : public QWidget, + public Ui::DlgRef_2Sel2Spin1Push_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel2Spin1Push( QWidget* = 0, Qt::WindowFlags = 0 ); + ~DlgRef_2Sel2Spin1Push(); +}; + ////////////////////////////////////////// // DlgRef_2Sel3Spin2Rb ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.pro b/src/DlgRef/DlgRef.pro index aa4ead953..cea85d4a7 100644 --- a/src/DlgRef/DlgRef.pro +++ b/src/DlgRef/DlgRef.pro @@ -94,6 +94,7 @@ HEADERS += DlgRef_1Sel3Spin1Check.h HEADERS += DlgRef_1Sel4Spin2Check.h HEADERS += DlgRef_2Sel1Spin2Check.h HEADERS += DlgRef_2Sel2Spin1Check.h +HEADERS += DlgRef_2Sel2Spin1Push.h HEADERS += DlgRef_2Sel2Spin3Check.h HEADERS += DlgRef_2Sel4Spin1Check.h HEADERS += DlgRef_3Sel4Spin2Check.h diff --git a/src/DlgRef/DlgRef_2Sel2Spin1Push_QTD.ui b/src/DlgRef/DlgRef_2Sel2Spin1Push_QTD.ui new file mode 100644 index 000000000..4c3dbe5e8 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel2Spin1Push_QTD.ui @@ -0,0 +1,149 @@ + + + DlgRef_2Sel2Spin1Push_QTD + + + + 0 + 0 + 281 + 150 + + + + + + + + 0 + + + 0 + + + + + + + + + + + + 0 + 0 + + + + TL1 + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + 0 + 0 + + + + TL2 + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + 0 + 0 + + + + TL3 + + + false + + + + + + + + + + + + + + + + true + + + + + + + + + + qPixmapFromMimeSource + + + SalomeApp_DoubleSpinBox + QDoubleSpinBox +
SalomeApp_DoubleSpinBox.h
+
+
+ + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + SpinBox_DX + SpinBox_DY + + + +
diff --git a/src/DlgRef/Makefile.am b/src/DlgRef/Makefile.am index cea029eac..8566c14e1 100644 --- a/src/DlgRef/Makefile.am +++ b/src/DlgRef/Makefile.am @@ -65,6 +65,7 @@ UIC_FILES = \ ui_DlgRef_2Sel2Spin1Check_QTD.h \ ui_DlgRef_2Sel2Spin3Check_QTD.h \ ui_DlgRef_2Sel2Spin_QTD.h \ + ui_DlgRef_2Sel2Spin1Push_QTD.h \ ui_DlgRef_2Sel3Spin2Rb_QTD.h \ ui_DlgRef_2Sel3Spin_QTD.h \ ui_DlgRef_2Sel4Spin1Check_QTD.h \ diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.cxx b/src/EntityGUI/EntityGUI_SketcherDlg.cxx index db3663ce1..a9b37aa93 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_SketcherDlg.cxx @@ -100,6 +100,7 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent, QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) ); QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) ); QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) ); + QPixmap image5 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) ); @@ -116,19 +117,29 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent, /***************************************************************/ GroupBox1 = new QGroupBox(tr("GEOM_CS"), this); - QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1); + QGridLayout* planeLayout = new QGridLayout(GroupBox1); planeLayout->setSpacing(6); planeLayout->setMargin(11); ComboBox1 = new QComboBox(GroupBox1); - ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) ); - planeLayout->addWidget(ComboBox1); + //ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) ); + planeLayout->addWidget(ComboBox1,0,0,1,2); planeButton = new QPushButton (GroupBox1); - planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed)); + //planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed)); planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) ); - planeLayout->addWidget(planeButton); - + planeLayout->addWidget(planeButton,0,2); + + selButton = new QPushButton (GroupBox1); + selButton->setIcon(image5); + planeLayout->addWidget(selButton,1,0); + + WPlaneLineEdit = new QLineEdit (GroupBox1); + WPlaneLineEdit->setReadOnly(true); + planeLayout->addWidget(WPlaneLineEdit,1,1,1,2); + + planeLayout->setColumnStretch(1,1); + topLayout->addWidget(GroupBox1); topLayout->addWidget( MainWidget ); topLayout->setStretch( 1, 1); @@ -311,8 +322,9 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent, connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) ); connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) ); - connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) ); + connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ActivateLocalCS() ) ); connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) ); + connect( selButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); @@ -394,12 +406,14 @@ void EntityGUI_SketcherDlg::Init() { /* init variables */ autoApply = false; - myEditCurrentArgument = Group1Sel->LineEdit1; + + myEditCurrentArgument = WPlaneLineEdit; // Initiate the parameters selection with the first WPlaneLineEdit + myCommand.append( "Sketcher" ); myUndoCommand.append( "Sketcher" ); mySketchState = FIRST_POINT; - globalSelection( GEOM_POINT ); + globalSelection( GEOM_FACE ); myCheckFlag = 0; @@ -409,6 +423,13 @@ void EntityGUI_SketcherDlg::Init() myLastY2 = 0.0; myHelpFileName = "create_sketcher_page.html"; + + GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() ); + myGlobalCS = aBasicOp->MakeMarker( 0,0,0, + 0,0,1, + 1,0,0 ); + myWPlane = myGlobalCS; + myLCSList.push_back( WPlaneToLCS(myGlobalCS) ); /* Get setting of step value from file configuration */ double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 ); @@ -435,10 +456,15 @@ void EntityGUI_SketcherDlg::Init() MainWidget->RadioButton1->setChecked( true ); - TypeClicked( 0 ); - FindLocalCS(); + TypeClicked( 0 ); + // If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox + // that should be filled with the possibly selected face + SelectionIntoArgument(); + resize(100,100); + + setPrefix(tr("GEOM_SKETCH")); ActivateLocalCS(); GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); @@ -451,6 +477,7 @@ void EntityGUI_SketcherDlg::Init() //================================================================================= void EntityGUI_SketcherDlg::InitClick() { + MESSAGE("EntityGUI_SketcherDlg::InitClick()") disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 ); myCheckFlag = 0; @@ -1007,6 +1034,8 @@ bool EntityGUI_SketcherDlg::ClickOnApply() if ( sender() && sender()->inherits( "QPushButton" ) ) ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948) +// addSubshapesToStudy(); + QString aParameters; myCommand.append( GetNewCommand( aParameters ) ); mySketchState = NEXT_POINT; @@ -1168,210 +1197,163 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument() { MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument") myEditCurrentArgument->setText( "" ); - double tmpX = myX; - double tmpY = myY; - myX = myLastX1; - myY = myLastY1; - // printf ("\nmyX = %f myY = %f", myX, myY); - // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1); - // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2); - - if ( sender() == ComboBox1 ) - ActivateLocalCS(); LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr(); SALOME_ListIO aSelList; aSelMgr->selectedObjects(aSelList); - - int nbSel = aSelList.Extent(); - MESSAGE("NbSel = "<LineEdit1) { - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !CORBA::is_nil(aSelectedObject) ) { - TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) { - gp_Trsf aTrans; - gp_Ax3 aWPlane = GetActiveLocalCS(); - - aTrans.SetTransformation(aWPlane); - BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); - aShape = aTransformation.Shape(); - - gp_Pnt aPnt; - if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { - myX = aPnt.X(); - myY = aPnt.Y(); - Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); - if( Group2Spin->isVisible() && mySketchType == PT_ABS ) { - disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - Group2Spin->SpinBox_DX->setValue(myX); - Group2Spin->SpinBox_DY->setValue(myY); - connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) { - if ( myLastX1 && myLastY1 ) { - Group2Spin->SpinBox_DX->setValue(myX - myLastX1); - Group2Spin->SpinBox_DY->setValue(myY - myLastY1); - } else { - if ( mySketchState != FIRST_POINT ) { - Group2Spin->SpinBox_DX->setValue(myX - tmpX); - Group2Spin->SpinBox_DY->setValue(myY - tmpY); - } else { - Group2Spin->SpinBox_DX->setValue(myX); - Group2Spin->SpinBox_DY->setValue(myY); - } - } - } - } - } - } + + this->activateWindow(); + + if (aSelList.Extent() == 0) + { + selButton->setDown(false); + WPlaneLineEdit->setEnabled(false); + WPlaneLineEdit->setText(tr("GEOM_SKETCHER_WPLANE")); + return; } - - if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) { - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !CORBA::is_nil(aSelectedObject) ) { - TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) { - gp_Trsf aTrans; - gp_Ax3 aWPlane = GetActiveLocalCS(); - - aTrans.SetTransformation(aWPlane); - BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); - aShape = aTransformation.Shape(); - - gp_Pnt aPnt; - if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { - myX = aPnt.X(); - myY = aPnt.Y(); - Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); - if( Group3Spin->isVisible() && mySketchType == PT_ABS ) { + else if (aSelList.Extent() != 1) + return; + + double tmpX = myX; + double tmpY = myY; + myX = myLastX1; + myY = myLastY1; + + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == WPlaneLineEdit) + aNeedType = TopAbs_FACE; + + + GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); + TopoDS_Shape aShape; + + if(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) + && !aShape.IsNull()) + { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + myEditCurrentArgument->setText(aName); + if (myEditCurrentArgument==WPlaneLineEdit) + { + AddLocalCS(aSelectedObject.get()); + selButton->setDown(false); + WPlaneLineEdit->setEnabled(false); + TypeClicked( 0 ); + } + else + { + gp_Trsf aTrans; + gp_Ax3 aWPlane = GetActiveLocalCS(); + + aTrans.SetTransformation(aWPlane); + BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); + aShape = aTransformation.Shape(); + + gp_Pnt aPnt; + if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) + { + myX = aPnt.X(); + myY = aPnt.Y(); + double Xcoord = myX; + double Ycoord = myY; + + switch (mySketchType) + { + case PT_ABS: + disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + + Group2Spin->SpinBox_DX->setValue(Xcoord); + Group2Spin->SpinBox_DY->setValue(Ycoord); + + connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + break; + + case PT_RELATIVE: + if (myLastX1 && myLastY1) + { + Xcoord = myX - myLastX1; + Ycoord = myY - myLastY1; + } + else if (mySketchState != FIRST_POINT) + { + Xcoord = myX - tmpX; + Ycoord = myY - tmpY; + } + Group2Spin->SpinBox_DX->setValue(Xcoord); + Group2Spin->SpinBox_DY->setValue(Ycoord); + break; + + case PT_ABS_RADIUS: disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - Group3Spin->SpinBox_DX->setValue(myX); - Group3Spin->SpinBox_DY->setValue(myY); + + Group3Spin->SpinBox_DX->setValue(Xcoord); + Group3Spin->SpinBox_DY->setValue(Ycoord); + connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) { - if ( myLastX1 && myLastY1 ) { - Group3Spin->SpinBox_DX->setValue(myX - myLastX1); - Group3Spin->SpinBox_DY->setValue(myY - myLastY1); - } else { - if ( mySketchState != FIRST_POINT ) { - Group3Spin->SpinBox_DX->setValue(myX - tmpX); - Group3Spin->SpinBox_DY->setValue(myY - tmpY); - } else { - Group3Spin->SpinBox_DX->setValue(myX); - Group3Spin->SpinBox_DY->setValue(myY); - } + break; + + case PT_REL_RADIUS: + if (myLastX1 && myLastY1) + { + Xcoord = myX - myLastX1; + Ycoord = myY - myLastY1; } - } - } - } - } - } - - if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) { - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !CORBA::is_nil(aSelectedObject) ) { - TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) { - gp_Trsf aTrans; - gp_Ax3 aWPlane = GetActiveLocalCS(); - - aTrans.SetTransformation(aWPlane); - BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); - aShape = aTransformation.Shape(); - - gp_Pnt aPnt; - if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { - myXc = aPnt.X(); - myYc = aPnt.Y(); - Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); - if( Group4Spin->isVisible() && mySketchType == PT_ABS ) { + else if (mySketchState != FIRST_POINT) + { + Xcoord = myX - tmpX; + Ycoord = myY - tmpY; + } + Group3Spin->SpinBox_DX->setValue(Xcoord); + Group3Spin->SpinBox_DY->setValue(Ycoord); + break; + + case PT_ABS_CENTER: disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - Group4Spin->SpinBox_DX->setValue(myXc); - Group4Spin->SpinBox_DY->setValue(myYc); + + Group4Spin->SpinBox_DX->setValue(Xcoord); + Group4Spin->SpinBox_DY->setValue(Ycoord); + connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) { - if ( myLastX1 && myLastY1 ) { - Group4Spin->SpinBox_DX->setValue(myXc - myLastX1); - Group4Spin->SpinBox_DY->setValue(myYc - myLastY1); - } else { - if ( mySketchState != FIRST_POINT ) { - Group4Spin->SpinBox_DX->setValue(myXc - tmpX); - Group4Spin->SpinBox_DY->setValue(myYc - tmpY); - } else { - Group4Spin->SpinBox_DX->setValue(myXc); - Group4Spin->SpinBox_DY->setValue(myYc); - } + connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + break; + + case PT_REL_CENTER: + if (myLastX1 && myLastY1) + { + Xcoord = myXc - myLastX1; + Ycoord = myYc - myLastY1; } - } - } - } - } - } - - if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) { - if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified - myX=tmpX; // If yes keep the old values of X and Y - myY=tmpY; - } - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !CORBA::is_nil(aSelectedObject) ) { - TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) { - gp_Trsf aTrans; - gp_Ax3 aWPlane = GetActiveLocalCS(); - - aTrans.SetTransformation(aWPlane); - BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); - aShape = aTransformation.Shape(); - - gp_Pnt aPnt; - if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { - myX = aPnt.X(); - myY = aPnt.Y(); - Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) ); - if( Group4Spin->isVisible() && mySketchType == PT_ABS ) { - disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - Group4Spin->SpinBox_DZ->setValue(myX); - Group4Spin->SpinBox_DS->setValue(myY); - connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) { - if ( myLastX1 && myLastY1 ) { - Group4Spin->SpinBox_DZ->setValue(myX - myLastX1); - Group4Spin->SpinBox_DS->setValue(myY - myLastY1); - } else { - if ( mySketchState != FIRST_POINT ) { - Group4Spin->SpinBox_DZ->setValue(myX - tmpX); - Group4Spin->SpinBox_DS->setValue(myY - tmpY); - } else { - Group4Spin->SpinBox_DZ->setValue(myX); - Group4Spin->SpinBox_DS->setValue(myY); - } + else if (mySketchState != FIRST_POINT) + { + Xcoord = myXc - tmpX; + Ycoord = myYc - tmpY; + } + else + { + Xcoord = myXc; + Ycoord = myYc; } - } + + Group4Spin->SpinBox_DX->setValue(Xcoord); + Group4Spin->SpinBox_DY->setValue(Ycoord); + break; + } } } } - if (nbSel == 0){ // If no object selected - myX=tmpX; // Don't change the point coordinates - myY=tmpY; // and don't redisplay the preview - } - else if(!autoApply){ + + if(!autoApply){ GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); } - if ( autoApply ){ + else { ClickOnApply(); autoApply = false; } - this->activateWindow(); } @@ -1382,6 +1364,7 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument() //================================================================================= void EntityGUI_SketcherDlg::SetEditCurrentArgument() { + TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX; if ( sender() == Group1Sel->PushButton1 ) { myEditCurrentArgument = Group1Sel->LineEdit1; myEditCurrentArgument->setFocus(); @@ -1406,7 +1389,14 @@ void EntityGUI_SketcherDlg::SetEditCurrentArgument() Group2Sel->LineEdit2->setEnabled(true); // myEditCurrentArgument->setFocus(); } - SelectionIntoArgument(); + else if ( sender() == selButton ) { + myNeedType = TopAbs_FACE; + myEditCurrentArgument = WPlaneLineEdit; + WPlaneLineEdit->setEnabled(true); + selButton->setDown(true); + } + globalSelection(); // close local selection to clear it + localSelection(GEOM::GEOM_Object::_nil(), myNeedType); } @@ -1470,9 +1460,9 @@ void EntityGUI_SketcherDlg::ActivateThisDialog() SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); //myGeometryGUI->SetState( 0 ); - globalSelection( GEOM_POINT ); +// globalSelection( GEOM_POINT ); - myEditCurrentArgument = Group1Sel->LineEdit1; + myEditCurrentArgument = WPlaneLineEdit; myEditCurrentArgument->setFocus(); if ( sender() == Group1Sel->LineEdit1 ) { @@ -2235,24 +2225,14 @@ bool EntityGUI_SketcherDlg::execute( ObjectList& objects ) } } - gp_Ax3 myWPlane = GetActiveLocalCS(); - GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble; - WPlane->length( 9 ); - WPlane[0] = myWPlane.Location().X(); - WPlane[1] = myWPlane.Location().Y(); - WPlane[2] = myWPlane.Location().Z(); - - WPlane[3] = myWPlane.Direction().X(); - WPlane[4] = myWPlane.Direction().Y(); - WPlane[5] = myWPlane.Direction().Z(); - - WPlane[6] = myWPlane.XDirection().X(); - WPlane[7] = myWPlane.XDirection().Y(); - WPlane[8] = myWPlane.XDirection().Z(); - GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation()); - GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane ); - + GEOM::GEOM_Object_var anObj = NULL; + + int index = ComboBox1->currentIndex(); + if(index != -1 && !myWPlane->_is_nil()) // The combobox is not empty + { + anObj = anOper->MakeSketcherOnPlane( cmd.toLatin1().constData(), myWPlane ); + } if ( !anObj->_is_nil() ) { if( !IsPreview() ) { @@ -2325,7 +2305,7 @@ void EntityGUI_SketcherDlg::displayPntPreview(const double x, ) { // Get globalCS and working plane - gp_Ax3 globalCS = myLCSList.first(); //gp_Ax3(aOrigin, aDirZ, aDirX); + gp_Ax3 globalCS = WPlaneToLCS( myGlobalCS ); gp_Ax3 aWPlane = GetActiveLocalCS(); // Build point in localCS @@ -2392,6 +2372,16 @@ bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject, return true; } +//================================================================================= +// function : acceptMouseEvent() +// purpose : +//================================================================================= +bool EntityGUI_SketcherDlg::acceptMouseEvent() const +{ + return ( (getPnt1ConstructorId() == 1 || getPnt1ConstructorId() == 0) //accept mouse event only on absolute and relative selection mode + && !WPlaneLineEdit->isEnabled()); // called by EntityGUI::OnMousePress() +} + //================================================================================= // function : keyPressEvent() // purpose : @@ -2457,14 +2447,43 @@ void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step ) //Group4Spin->SpinBox_DS->setSingleStep(step); } +//================================================================================= +// function : AddLocalCS() +// purpose : Add All Coordinates systems in study +//================================================================================= +void EntityGUI_SketcherDlg::AddLocalCS(GEOM::GEOM_Object_var aSelectedObject) +{ + MESSAGE("EntityGUI_SketcherDlg::AddLocalCS") + QString aName = GEOMBase::GetName( aSelectedObject ); + + int index = ComboBox1->findText(aName, Qt::MatchExactly); + + if (index==-1) // If the working plane hasn't been added yet + { + myWPlaneList.push_back(aSelectedObject); + myWPlane = aSelectedObject; + addSubshapesToStudy(); + myLCSList.push_back(WPlaneToLCS(aSelectedObject)); + ComboBox1->addItem(aName); + index = ComboBox1->count(); + ComboBox1->setCurrentIndex(index-1); + } + else + { + ComboBox1->setCurrentIndex(index); + } + ActivateLocalCS(); +} + //================================================================================= // function : FindLocalCS() // purpose : Find All Coordinates systems in study //================================================================================= void EntityGUI_SketcherDlg::FindLocalCS() { + MESSAGE("EntityGUI_SketcherDlg::FindLocalCS") ComboBox1->clear(); - myLCSList.clear(); + myWPlaneList.clear(); SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); if ( !app ) @@ -2478,11 +2497,7 @@ void EntityGUI_SketcherDlg::FindLocalCS() //add Global CS ComboBox1->addItem(tr("GEOM_GCS")); - gp_Pnt aOrigin = gp_Pnt(0, 0, 0); - gp_Dir aDirZ = gp_Dir(0, 0, 1); - gp_Dir aDirX = gp_Dir(1, 0, 0); - gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX); - myLCSList.push_back(globalCS); + myWPlaneList.push_back(myGlobalCS); // get GEOM component CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() ); @@ -2497,31 +2512,55 @@ void EntityGUI_SketcherDlg::FindLocalCS() // browse through all GEOM data tree _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) ); - for ( it->InitEx( true ); it->More(); it->Next() ) { + for ( it->InitEx( true ); it->More(); it->Next() ) + { _PTR(SObject) child( it->Value() ); CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child ); GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj ); if( CORBA::is_nil( geomObj ) ) continue; - if (geomObj->GetType() == GEOM_MARKER) { + if (geomObj->GetType() == GEOM_MARKER) + { + myWPlaneList.push_back(geomObj); + myLCSList.push_back(WPlaneToLCS(geomObj)); ComboBox1->addItem(geomObj->GetName()); - TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj); - - gp_Ax3 aLCS; - aLCS.Transform(aShape.Location().Transformation()); - if (aShape.ShapeType() == TopAbs_FACE) { - Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape)); - if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { - Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS); - gp_Pln aPln = aGPlane->Pln(); - aLCS = aPln.Position(); - } - } - myLCSList.push_back(aLCS); + MESSAGE("ComboBox1->addItem() in EntityGUI_SketcherDlg::FindLocalCS()") + } + } +} + +//================================================================================= +// function : WPlaneToLCS ( aWPlane ) +// purpose : +//================================================================================= +gp_Ax3 EntityGUI_SketcherDlg::WPlaneToLCS( GEOM::GEOM_Object_var geomObj ) +{ + TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj); + + gp_Ax3 aLCS; + if (CORBA::is_nil( geomObj ) || aShape.IsNull()) + { + MESSAGE("CORBA::is_nil( geomObj ) || aShape.IsNull()") + } + aLCS.Transform(aShape.Location().Transformation()); + if (aShape.ShapeType() == TopAbs_FACE) + { + GEOM::GEOM_IMeasureOperations_ptr aMeasureOp = + myGeometryGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() ); + double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz; + aMeasureOp->GetPosition( geomObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz); + if ( aMeasureOp->IsDone() ) + { + gp_Pnt aPnt ( Ox, Oy, Oz ); + gp_Dir aDirN ( Zx, Zy, Zz ); + gp_Dir aDirX ( Xx, Xy, Xz ); + aLCS = gp_Ax3( aPnt, aDirN, aDirX ); } } + return aLCS; } + //================================================================================= // function : getPnt1ConstructorId() // purpose : @@ -2550,11 +2589,13 @@ int EntityGUI_SketcherDlg::getPnt2ConstructorId() const //================================================================================= gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS() { + MESSAGE("EntityGUI_SketcherDlg::GetActiveLocalCS()") int ind = ComboBox1->currentIndex(); if (ind == -1) return myGeometryGUI->GetWorkingPlane(); - + gp_Ax3 aLCS = myLCSList.at(ind); + myWPlane = myWPlaneList.at(ind); return aLCS; } @@ -2565,6 +2606,17 @@ gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS() //================================================================================= void EntityGUI_SketcherDlg::ActivateLocalCS() { - myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() ); - myGeometryGUI->ActiveWorkingPlane(); + MESSAGE("EntityGUI_SketcherDlg::ActivateLocalCS") + myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() ); + myGeometryGUI->ActiveWorkingPlane(); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void EntityGUI_SketcherDlg::addSubshapesToStudy() +{ + MESSAGE("EntityGUI_SketcherDlg::addSubshapesToStudy()") + GEOMBase::PublishSubObject(myWPlane); +} \ No newline at end of file diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.h b/src/EntityGUI/EntityGUI_SketcherDlg.h index fd36ce6a9..252127e1f 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.h +++ b/src/EntityGUI/EntityGUI_SketcherDlg.h @@ -73,9 +73,8 @@ public: bool eventFilter (QObject* object, QEvent* event); - bool acceptMouseEvent() const { return ( getPnt1ConstructorId() == 1 - || getPnt1ConstructorId() == 0 ); } //accept mouse event only on absolute and relative selection mode - void OnPointSelected( Qt::KeyboardModifiers, const gp_Pnt& ); // called by EntityGUI::OnMousePress() + bool acceptMouseEvent() const; // called by EntityGUI::OnMousePress() + void OnPointSelected( Qt::KeyboardModifiers, const gp_Pnt& ); protected: void initSpinBox( SalomeApp_DoubleSpinBox*, @@ -86,7 +85,8 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& ); - + virtual void addSubshapesToStudy(); + void closeEvent( QCloseEvent* ); void keyPressEvent( QKeyEvent* ); @@ -170,6 +170,9 @@ private: QGroupBox* GroupBox1; QComboBox* ComboBox1; QPushButton* planeButton; + QPushButton* selButton; + + QLineEdit* WPlaneLineEdit; GeometryGUI* myGeometryGUI; @@ -178,6 +181,9 @@ private: double myLineWidth; QList myLCSList; + GEOM::GEOM_Object_var myGlobalCS; + GEOM::GEOM_Object_var myWPlane; + QList< GEOM::GEOM_Object_var > myWPlaneList; int myCheckFlag; @@ -215,8 +221,10 @@ private slots: void CheckBoxClicked( int ); void ValueChangedInSpinBox( double ); void SetDoubleSpinBoxStep( double ); + void AddLocalCS( GEOM::GEOM_Object_var ); void FindLocalCS(); gp_Ax3 GetActiveLocalCS(); + gp_Ax3 WPlaneToLCS( GEOM::GEOM_Object_var ); void ActivateLocalCS(); }; diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 95cf241bf..489c064d8 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -779,7 +779,7 @@ ICO_DELETE delete.png - + ICO_DISK disk.png @@ -795,6 +795,14 @@ ICO_DISPLAY_ONLY displayonly.png + + ICO_DRAFT + draft.png + + + ICO_DISPLAY_ONLY + displayonly.png + ICO_EDGE build_edge.png @@ -822,6 +830,14 @@ ICO_EXPLODE_BLOCKS subshape.png + + + ICO_EXTRUDED_BOSS + extruded_boss.png + + + ICO_EXTRUDED_CUT + extruded_cut.png ICO_EXTRUSION diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index a993e8be3..25b1a30d4 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -585,6 +585,19 @@ Please, select face, shell or solid and try again GEOM_EXTRUSION Extrusion + + GEOM_EXTRUDED_CUT + Extruded cut + + + GEOM_EXTRUDED_BOSS + Extruded boss + + + GEOM_EXTRUSION + Extrusion + + GEOM_EXTRUSION_BSV Base Shapes + Vector @@ -806,6 +819,10 @@ Please, select face, shell or solid and try again GEOM_HOLES Holes + + GEOM_INIT_SHAPE + Initial shape + GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE Identical names : select by mouse ! @@ -1566,6 +1583,10 @@ Please, select face, shell or solid and try again GEOM_SHELL_TITLE Shell Construction + + GEOM_SKETCH + Sketch + GEOM_SKETCHER_ABS Absolute @@ -1726,6 +1747,10 @@ Please, select face, shell or solid and try again GEOM_SKETCHER_VXVY VX-VY + + GEOM_SKETCHER_WPLANE + Select a planar face or a plane + GEOM_SKETCHER_VY2 VY : @@ -2370,6 +2395,14 @@ Please, select face, shell or solid and try again MEN_EXTRUSION Extrusion + + MEN_EXTRUDED_CUT + Extruded cut + + + MEN_EXTRUDED_BOSS + Extruded boss + MEN_FACE Face diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index e037eb54e..11bfcf6f1 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -1717,6 +1717,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau GEOM_SKETCHER_VXVY VX-VY + + GEOM_SKETCHER_WPLANE + Sélectionnez une face plane ou un plan + GEOM_SKETCHER_VY2 VY : diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 674eb2869..eb4aa6d77 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -512,6 +512,8 @@ void GeometryGUI::OnGUIEvent( int id ) case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES + case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS + case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT libName = "OperationGUI"; break; case GEOMOp::OpSewing: // MENU REPAIR - SEWING @@ -785,6 +787,8 @@ void GeometryGUI::initialize( CAM_Application* app ) //createGeomAction( GEOMOp::OpClipping, "CLIPPING" ); createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" ); createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" ); + createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" ); + createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" ); createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" ); createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" ); @@ -1001,6 +1005,8 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpFillet2d, operId, -1 ); createMenu( GEOMOp::OpFillet3d, operId, -1 ); createMenu( GEOMOp::OpChamfer, operId, -1 ); + createMenu( GEOMOp::OpExtrudedBoss, operId, -1 ); + createMenu( GEOMOp::OpExtrudedCut, operId, -1 ); //createMenu( GEOMOp::OpClipping, operId, -1 ); int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 ); @@ -1076,40 +1082,50 @@ void GeometryGUI::initialize( CAM_Application* app ) */ // ---- create toolbars -------------------------- - + int basicTbId = createTool( tr( "TOOL_BASIC" ) ); - createTool( GEOMOp::OpPoint, basicTbId ); - createTool( GEOMOp::OpLine, basicTbId ); - createTool( GEOMOp::OpCircle, basicTbId ); - createTool( GEOMOp::OpEllipse, basicTbId ); - createTool( GEOMOp::OpArc, basicTbId ); - createTool( GEOMOp::OpCurve, basicTbId ); - createTool( GEOMOp::OpVector, basicTbId ); - createTool( GEOMOp::OpPlane, basicTbId ); - createTool( GEOMOp::OpLCS, basicTbId ); + createTool( GEOMOp::OpPoint, basicTbId ); + createTool( GEOMOp::OpLine, basicTbId ); + createTool( GEOMOp::OpCircle, basicTbId ); + createTool( GEOMOp::OpEllipse, basicTbId ); + createTool( GEOMOp::OpArc, basicTbId ); + createTool( GEOMOp::OpCurve, basicTbId ); + createTool( GEOMOp::OpVector, basicTbId ); + createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc + createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc + createTool( GEOMOp::OpPlane, basicTbId ); + createTool( GEOMOp::OpLCS, basicTbId ); createTool( GEOMOp::OpOriginAndVectors, basicTbId ); - + +// int sketchTbId = createTool( tr( "TOOL_SKETCH" ) ); +// createTool( GEOMOp::Op2dSketcher, sketchTbId ); +// createTool( GEOMOp::Op3dSketcher, sketchTbId ); + int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) ); - createTool( GEOMOp::OpBox, primTbId ); - createTool( GEOMOp::OpCylinder, primTbId ); - createTool( GEOMOp::OpSphere, primTbId ); - createTool( GEOMOp::OpTorus, primTbId ); - createTool( GEOMOp::OpCone, primTbId ); - createTool( GEOMOp::OpRectangle, primTbId ); - createTool( GEOMOp::OpDisk, primTbId ); - + createTool( GEOMOp::OpBox, primTbId ); + createTool( GEOMOp::OpCylinder, primTbId ); + createTool( GEOMOp::OpSphere, primTbId ); + createTool( GEOMOp::OpTorus, primTbId ); + createTool( GEOMOp::OpCone, primTbId ); + createTool( GEOMOp::OpRectangle, primTbId ); + createTool( GEOMOp::OpDisk, primTbId ); + createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc + +// int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc +// createTool( GEOMOp::OpPipeTShape, advancedTbId ); + int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) ); - createTool( GEOMOp::OpFuse, boolTbId ); - createTool( GEOMOp::OpCommon, boolTbId ); - createTool( GEOMOp::OpCut, boolTbId ); - createTool( GEOMOp::OpSection, boolTbId ); - - int genTbId = createTool( tr( "TOOL_GENERATION" ) ); + createTool( GEOMOp::OpFuse, boolTbId ); + createTool( GEOMOp::OpCommon, boolTbId ); + createTool( GEOMOp::OpCut, boolTbId ); + createTool( GEOMOp::OpSection, boolTbId ); + + int genTbId = createTool( tr( "TOOL_GENERATION" ) ); createTool( GEOMOp::OpPrism, genTbId ); createTool( GEOMOp::OpRevolution, genTbId ); createTool( GEOMOp::OpFilling, genTbId ); createTool( GEOMOp::OpPipe, genTbId ); - + int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) ); createTool( GEOMOp::OpTranslate, transTbId ); createTool( GEOMOp::OpRotate, transTbId ); @@ -1121,29 +1137,22 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( separator(), transTbId ); createTool( GEOMOp::OpMultiTranslate, transTbId ); createTool( GEOMOp::OpMultiRotate, transTbId ); - + int operTbId = createTool( tr( "TOOL_OPERATIONS" ) ); - createTool( GEOMOp::Op2dSketcher, operTbId ); - createTool( GEOMOp::Op3dSketcher, operTbId ); - createTool( separator(), operTbId ); createTool( GEOMOp::OpExplode, operTbId ); - createTool( separator(), operTbId ); -#ifdef WITH_OPENCV - createTool( GEOMOp::OpFeatureDetect, operTbId ); -#endif - createTool( GEOMOp::OpPictureImport, operTbId ); - createTool( separator(), operTbId ); - createTool( GEOMOp::OpPartition, operTbId ); createTool( GEOMOp::OpArchimede, operTbId ); createTool( GEOMOp::OpShapesOnShape, operTbId ); createTool( GEOMOp::OpSharedShapes, operTbId ); - createTool( separator(), operTbId ); - createTool( GEOMOp::OpFillet1d, operTbId ); - createTool( GEOMOp::OpFillet2d, operTbId ); - createTool( GEOMOp::OpFillet3d, operTbId ); - createTool( GEOMOp::OpChamfer, operTbId ); - + + int featTbId = createTool( tr( "TOOL_FEATURES" ) ); + createTool( GEOMOp::OpFillet1d, featTbId ); + createTool( GEOMOp::OpFillet2d, featTbId ); + createTool( GEOMOp::OpFillet3d, featTbId ); + createTool( GEOMOp::OpChamfer, featTbId ); + createTool( GEOMOp::OpExtrudedBoss, featTbId ); + createTool( GEOMOp::OpExtrudedCut, featTbId ); + int buildTbId = createTool( tr( "TOOL_BUILD" ) ); createTool( GEOMOp::OpEdge, buildTbId ); createTool( GEOMOp::OpWire, buildTbId ); @@ -1171,9 +1180,13 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpCheckShape, measureTbId ); createTool( GEOMOp::OpCheckCompound, measureTbId ); createTool( GEOMOp::OpCheckSelfInters, measureTbId ); + + int picturesTbId = createTool( tr( "TOOL_PICTURES" ) ); + createTool( GEOMOp::OpPictureImport, picturesTbId ); + #ifdef WITH_OPENCV + createTool( GEOMOp::OpFeatureDetect, picturesTbId ); + #endif - int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); - createTool( GEOMOp::OpPipeTShape, advancedTbId ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// // ---- create popup menus -------------------------- diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index 227c23283..a4ad5eadf 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -136,6 +136,8 @@ namespace GEOMOp { OpFillet1d = 3706, // MENU OPERATION - FILLET 1D OpClipping = 3707, // MENU OPERATION - CLIPPING RANGE OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES + OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS + OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT // RepairGUI -----------------//-------------------------------- OpSewing = 4000, // MENU REPAIR - SEWING OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 4a69c1be9..76962b988 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -1293,6 +1293,88 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways return aPrism; } +//============================================================================= +/*! + * MakeDraftPrism + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism + (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || theInitShape.IsNull()) return NULL; + + Handle(GEOM_Object) aPrism = NULL; + + if ( theFuse ) + { + //Add a new Extruded Boss object + aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS); + } + else + { + //Add a new Extruded Cut object + aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT); + } + + //Add a new Prism function for the creation of a Draft Prism feature + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE); + 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) aRefInit = theInitShape->GetLastFunction(); + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + + if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL; + + // Set parameters + aCI.SetBase(aRefBase); + aCI.SetInitShape(aRefInit); + aCI.SetH(theHeight); + aCI.SetDraftAngle(theAngle); + if ( theFuse ) + aCI.SetFuseFlag(1); + else + aCI.SetFuseFlag(0); + + //Compute the Draft Prism Feature value + try { +#if OCC_VERSION_LARGE > 0x06010000 + 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 + if(theFuse) + { + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss(" + << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")"; + } + else + { + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut(" + << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")"; + } + + SetErrorCode(OK); + return aPrism; +} + //============================================================================= /*! * MakePipe diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index b0818cbe1..dd066a215 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -89,7 +89,10 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakePrismDXDYDZ2Ways (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ); - + + Standard_EXPORT Handle(GEOM_Object) MakeDraftPrism (Handle(GEOM_Object) theInitShape, Handle(GEOM_Object) theBase, + double theHeight, double theAngle, bool theFuse); + 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 63319a1ec..fafa69514 100644 --- a/src/GEOMImpl/GEOMImpl_IPrism.hxx +++ b/src/GEOMImpl/GEOMImpl_IPrism.hxx @@ -23,16 +23,21 @@ //NOTE: This is an intreface to a function for the Prism creation. #include "GEOM_Function.hxx" +// #include TEST -#define PRISM_ARG_H 1 -#define PRISM_ARG_VEC 2 -#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 -#define PRISM_ARG_SCALE 9 +#define PRISM_ARG_H 1 +#define PRISM_ARG_VEC 2 +#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 +#define PRISM_ARG_SCALE 9 +#define PRISM_ARG_DRAFT 10 +#define PRISM_ARG_FUSE 11 +#define PRISM_ARG_INIT 12 +#define PRISM_ARG_MODE 13 class GEOMImpl_IPrism { @@ -40,15 +45,17 @@ class GEOMImpl_IPrism GEOMImpl_IPrism(Handle(GEOM_Function) theFunction): _func(theFunction) {} - void SetBase (Handle(GEOM_Function) theRefBase ) { _func->SetReference(PRISM_ARG_BASE, theRefBase); } - void SetVector(Handle(GEOM_Function) theRefVector) { _func->SetReference(PRISM_ARG_VEC , theRefVector); } - 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 SetBase (Handle(GEOM_Function) theRefBase ) { _func->SetReference(PRISM_ARG_BASE, theRefBase); } + void SetVector(Handle(GEOM_Function) theRefVector ) { _func->SetReference(PRISM_ARG_VEC , theRefVector); } + 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 SetInitShape (Handle(GEOM_Function) theInitShape) { _func->SetReference(PRISM_ARG_INIT, theInitShape); } 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 ); } Handle(GEOM_Function) GetLastPoint () { return _func->GetReference(PRISM_ARG_PNT_L ); } + Handle(GEOM_Function) GetInitShape () { return _func->GetReference(PRISM_ARG_INIT ); } void SetDX(double theDX) { _func->SetReal(PRISM_ARG_DX, theDX); } void SetDY(double theDY) { _func->SetReal(PRISM_ARG_DY, theDY); } @@ -58,13 +65,19 @@ class GEOMImpl_IPrism double GetDY() { return _func->GetReal(PRISM_ARG_DY); } double GetDZ() { return _func->GetReal(PRISM_ARG_DZ); } - void SetH(double theH) { _func->SetReal(PRISM_ARG_H, theH); } - - double GetH() { return _func->GetReal(PRISM_ARG_H); } - - void SetScale(double theH) { _func->SetReal(PRISM_ARG_SCALE, theH); } + void SetH (double theH ) { _func->SetReal(PRISM_ARG_H, theH); } + void SetScale (double theH ) { _func->SetReal(PRISM_ARG_SCALE, theH); } + void SetDraftAngle(double theAngle) { _func->SetReal(PRISM_ARG_DRAFT, theAngle); } + double GetH() { return _func->GetReal(PRISM_ARG_H); } double GetScale() { return _func->GetReal(PRISM_ARG_SCALE); } + double GetDraftAngle() { return _func->GetReal(PRISM_ARG_DRAFT); } + + void SetFuseFlag(int theFlag) { _func->SetInteger(PRISM_ARG_FUSE, theFlag); } +// void SetMode(GEOMImpl_Mode theMode) { _func->SetInteger(PRISM_ARG_MODE, theMode); } //TEST + + int GetFuseFlag() { return _func->GetInteger(PRISM_ARG_FUSE); } +// GEOMImpl_Mode GetMode() { return _func->GetInteger(PRISM_ARG_MODE); } //TEST private: diff --git a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx index a477dc2eb..6387f7df9 100644 --- a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx @@ -31,16 +31,19 @@ #include #include +#include #include #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -65,6 +68,8 @@ #include +#include "utilities.h" + //======================================================================= //function : GetID //purpose : @@ -180,11 +185,143 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const } } } + + else if (aType == DRAFT_PRISM_FEATURE) { + Handle(GEOM_Function) aRefInit = aCI.GetInitShape(); + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + TopoDS_Shape anInitShape = aRefInit->GetValue(); // Initial shape + TopoDS_Shape aSketch = aRefBase->GetValue(); + Standard_Real aHeight = aCI.GetH(); // Height of the extrusion + Standard_Real anAngle = aCI.GetDraftAngle(); // Draft angle + Standard_Boolean isProtrusion = (aCI.GetFuseFlag()==1); + // Flag to know wether the feature is a protrusion (fuse) or a depression (cut) + + if (anInitShape.ShapeType() == TopAbs_COMPOUND) + { + TopExp_Explorer anExp(anInitShape, TopAbs_SOLID); + int solidCount = 0; + for(;anExp.More();anExp.Next()) + { + solidCount++; + } + if (solidCount == 0) + { + Standard_ConstructionError::Raise("The input shape is a compound without any solid"); + } + else if (solidCount > 1) + { + Standard_ConstructionError::Raise("The input shape is a compound with more than one solid"); + } + } + + TopoDS_Wire aWire = TopoDS_Wire(); + + if (aSketch.ShapeType() == TopAbs_EDGE) + { + aWire = BRepBuilderAPI_MakeWire(TopoDS::Edge(aSketch)); + } + else if (aSketch.ShapeType() == TopAbs_WIRE) + { + aWire = TopoDS::Wire(aSketch); + } + else + { + Standard_ConstructionError::Raise("The input sketch is neither a wire nor an edge"); + } + + if (!aWire.Closed()) + Standard_ConstructionError::Raise("The wire has to be closed"); + + // history of the Base wire (RefBase) + Handle(GEOM_Object) aSuppObj; + TDF_LabelSequence aLabelSeq; + aRefBase->GetDependency(aLabelSeq); + + // If the base wire has only one dependency we use it + // to determine the right normal of the face which + // must be oriented towards outside of the solid (like the support face) + if (aLabelSeq.Length()==1) + { + TDF_Label anArgumentRefLabel = aLabelSeq.Value(1); + aSuppObj = GEOM_Object::GetReferencedObject(anArgumentRefLabel); + } + + // Construction of the face if the wire hasn't any support face + TopoDS_Face aFaceBase = BRepBuilderAPI_MakeFace(aWire); + + if(!aSuppObj.IsNull()) // If the wire has a support + { + TopoDS_Shape aSupport = aSuppObj->GetValue(); + if (aSupport.ShapeType() == TopAbs_FACE) + { + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aSupport)); + TopoDS_Face aTempFace = BRepBuilderAPI_MakeFace(aSurf, aWire); + + if(aTempFace.Orientation() != TopoDS::Face(aSupport).Orientation()) + { + aFaceBase=TopoDS::Face(aTempFace.Reversed()); + } + else + aFaceBase=aTempFace; + } + } + + // Invert height and angle if the operation is an extruded cut + bool invert = !isProtrusion; + + // If the face has a reverse orientation invert for extruded boss operations + if(aFaceBase.Orientation() == TopAbs_REVERSED) + invert = isProtrusion; + + if(invert) + { + anAngle = -anAngle; // Invert angle and height + aHeight = -aHeight; + } + + BRepFeat_MakeDPrism thePrism(anInitShape, aFaceBase, TopoDS_Face(), + anAngle*PI180, isProtrusion, Standard_True); + + thePrism.Perform(aHeight); + + aShape = thePrism.Shape(); + } if (aShape.IsNull()) return 0; - - TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape); - aFunction->SetValue(aRes); + + + if (aType == DRAFT_PRISM_FEATURE) + { + TopoDS_Shape aRes = aShape; + + // If the result is a compound with only one solid, + // return the solid + if (aShape.ShapeType() == TopAbs_COMPOUND) + { + TopExp_Explorer anExp(aShape, TopAbs_SOLID); + + int solidNb = 0; + TopoDS_Solid aSolid; + + for(;anExp.More();anExp.Next()) + { + aSolid = TopoDS::Solid(anExp.Current()); + solidNb++; + } + if (solidNb == 1) + { + aRes = aSolid; + } + } + + aFunction->SetValue(aRes); + } + else + { + TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape); + aFunction->SetValue(aRes); + } + log.SetTouched(Label()); diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 9359db7a3..6b61e8899 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -96,6 +96,10 @@ #define GEOM_PROJECTION 45 +#define GEOM_EXTRUDED_CUT 46 + +#define GEOM_EXTRUDED_BOSS 47 + //GEOM_Function types #define COPY_WITH_REF 1 @@ -198,6 +202,7 @@ #define PRISM_BASE_TWO_PNT_2WAYS 4 #define PRISM_BASE_DXDYDZ 5 #define PRISM_BASE_DXDYDZ_2WAYS 6 +#define DRAFT_PRISM_FEATURE 7 #define REVOLUTION_BASE_AXIS_ANGLE 1 #define REVOLUTION_BASE_AXIS_ANGLE_2WAYS 2 diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index d8fd0a7fa..2175cc50d 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -705,6 +705,37 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismDXDYDZWithScaling return GetObject(anObject); } +//============================================================================= +/*! + * MakeDraftPrism + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDraftPrism + (GEOM::GEOM_Object_ptr theInitShape, GEOM::GEOM_Object_ptr theBase, + CORBA::Double theHeight, + CORBA::Double theAngle, + CORBA::Boolean theFuse) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference objects + Handle(GEOM_Object) aInit = GetObjectImpl(theInitShape); + Handle(GEOM_Object) aBase = GetObjectImpl(theBase); + + if (aBase.IsNull() || aInit.IsNull()) return aGEOMObject._retn(); + + //Create the Prism + Handle(GEOM_Object) anObject = GetOperations()->MakeDraftPrism(aInit, aBase, theHeight, theAngle, theFuse); + + 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 0890e3de6..3b64361d8 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -138,7 +138,13 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : CORBA::Double theDY, CORBA::Double theDZ, CORBA::Double theScaleFactor); - + + GEOM::GEOM_Object_ptr MakeDraftPrism (GEOM::GEOM_Object_ptr theInitShape, + GEOM::GEOM_Object_ptr theBase, + CORBA::Double theHeight, + CORBA::Double theAngle, + CORBA::Boolean theFuse); + GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePath); diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 31cc24710..dbf18eb98 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -63,7 +63,7 @@ ## @defgroup l3_basic_op Basic Operations ## @defgroup l3_boolean Boolean Operations ## @defgroup l3_transform Transformation Operations -## @defgroup l3_local Local Operations (Fillet and Chamfer) +## @defgroup l3_local Local Operations (Fillet, Chamfer and other Features) ## @defgroup l3_blocks_op Blocks Operations ## @defgroup l3_healing Repairing Operations ## @defgroup l3_restore_ss Restore presentation parameters and a tree of sub-shapes @@ -6222,6 +6222,64 @@ class geompyDC(GEOM._objref_GEOM_Gen): else: anObj = self.MakeChamferFaces(aShape,d1,d2,ListShape) return anObj + + ## Remove material from a solid by extrusion of the base shape on the given distance. + # @param theInit Shape to remove material from. It must be a solid or + # a compound made of a single solid. + # @param theBase Closed edge or wire defining the base shape to be extruded. + # @param theH Prism dimension along the normal to theBase + # @param theAngle Draft angle in degrees. + # @return New GEOM.GEOM_Object, containing the initial shape with removed material + # + # @ref tui_creation_prism "Example" + def MakeExtrudedCut(self, theInit, theBase, theH, theAngle): + """ + Add material to a solid by extrusion of the base shape on the given distance. + + Parameters: + theInit Shape to remove material from. It must be a solid or a compound made of a single solid. + theBase Closed edge or wire defining the base shape to be extruded. + theH Prism dimension along the normal to theBase + theAngle Draft angle in degrees. + + Returns: + New GEOM.GEOM_Object, containing the initial shape with removed material. + """ + # Example: see GEOM_TestAll.py + #theH,Parameters = ParseParameters(theH) + anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, False) + RaiseIfFailed("MakeExtrudedBoss", self.PrimOp) + #anObj.SetParameters(Parameters) + return anObj + + ## Add material to a solid by extrusion of the base shape on the given distance. + # @param theInit Shape to add material to. It must be a solid or + # a compound made of a single solid. + # @param theBase Closed edge or wire defining the base shape to be extruded. + # @param theH Prism dimension along the normal to theBase + # @param theAngle Draft angle in degrees. + # @return New GEOM.GEOM_Object, containing the initial shape with added material + # + # @ref tui_creation_prism "Example" + def MakeExtrudedBoss(self, theInit, theBase, theH, theAngle): + """ + Add material to a solid by extrusion of the base shape on the given distance. + + Parameters: + theInit Shape to add material to. It must be a solid or a compound made of a single solid. + theBase Closed edge or wire defining the base shape to be extruded. + theH Prism dimension along the normal to theBase + theAngle Draft angle in degrees. + + Returns: + New GEOM.GEOM_Object, containing the initial shape with added material. + """ + # Example: see GEOM_TestAll.py + #theH,Parameters = ParseParameters(theH) + anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, True) + RaiseIfFailed("MakeExtrudedBoss", self.PrimOp) + #anObj.SetParameters(Parameters) + return anObj # end of l3_local ## @} diff --git a/src/OperationGUI/Makefile.am b/src/OperationGUI/Makefile.am index e5f3a27d8..a833735b0 100644 --- a/src/OperationGUI/Makefile.am +++ b/src/OperationGUI/Makefile.am @@ -32,6 +32,7 @@ salomeinclude_HEADERS = \ OperationGUI_ChamferDlg.h \ OperationGUI_GetShapesOnShapeDlg.h \ OperationGUI_GetSharedShapesDlg.h \ + OperationGUI_ExtrudedFeatureDlg.h \ OperationGUI_ClippingDlg.h # Libraries targets @@ -46,6 +47,7 @@ dist_libOperationGUI_la_SOURCES = \ OperationGUI_FilletDlg.cxx \ OperationGUI_Fillet1d2dDlg.cxx \ OperationGUI_ChamferDlg.cxx \ + OperationGUI_ExtrudedFeatureDlg.cxx \ OperationGUI_ClippingDlg.cxx MOC_FILES = \ @@ -56,6 +58,7 @@ MOC_FILES = \ OperationGUI_FilletDlg_moc.cxx \ OperationGUI_Fillet1d2dDlg_moc.cxx \ OperationGUI_ChamferDlg_moc.cxx \ + OperationGUI_ExtrudedFeatureDlg_moc.cxx \ OperationGUI_ClippingDlg_moc.cxx nodist_libOperationGUI_la_SOURCES = \ @@ -81,6 +84,7 @@ libOperationGUI_la_CPPFLAGS = \ -I$(srcdir)/../GEOMClient \ -I$(srcdir)/../GEOMImpl \ -I$(srcdir)/../GEOMAlgo \ + -I$(srcdir)/../GEOM \ -I$(top_builddir)/src/DlgRef \ -I$(top_builddir)/idl diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index d70e3b26d..7c8ed82de 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -43,6 +43,7 @@ #include "OperationGUI_ClippingDlg.h" // Clipping dialog box #include "OperationGUI_GetShapesOnShapeDlg.h" #include "OperationGUI_GetSharedShapesDlg.h" +#include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT //======================================================================= // function : OperationGUI() @@ -81,6 +82,8 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent) case GEOMOp::OpClipping: (new OperationGUI_ClippingDlg (getGeometryGUI(), parent))->show(); break; case GEOMOp::OpShapesOnShape: (new OperationGUI_GetShapesOnShapeDlg(getGeometryGUI(), parent))->show(); break; case GEOMOp::OpSharedShapes: (new OperationGUI_GetSharedShapesDlg (getGeometryGUI(), parent))->show(); break; + case GEOMOp::OpExtrudedBoss: (new OperationGUI_ExtrudedFeatureDlg (BOSS, getGeometryGUI(), parent))->show(); break; + case GEOMOp::OpExtrudedCut: (new OperationGUI_ExtrudedFeatureDlg (CUT, getGeometryGUI(), parent))->show(); break; case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break; case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break; default: diff --git a/src/OperationGUI/OperationGUI.h b/src/OperationGUI/OperationGUI.h index 311485da4..a35882e24 100644 --- a/src/OperationGUI/OperationGUI.h +++ b/src/OperationGUI/OperationGUI.h @@ -36,6 +36,8 @@ class OperationGUI : public GEOMGUI { public : + enum ExtrudedFeatOperation { CUT = 1, BOSS = 2 }; + OperationGUI( GeometryGUI* ); ~OperationGUI(); diff --git a/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.cxx b/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.cxx new file mode 100644 index 000000000..b9f0bb8f4 --- /dev/null +++ b/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.cxx @@ -0,0 +1,382 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// GEOM GEOMGUI : GUI for Geometry component +// File : OperationGUI_ExtrudedFeatureDlg.cxx +// Author : Renaud NEDELEC, Open CASCADE S.A.S. + +#include "OperationGUI.h" +#include "OperationGUI_ExtrudedFeatureDlg.h" + +#include +#include +#include +#include + +#include +#include + +#include +#include + +// OCCT Includes +// #include +// #include +// #include +// #include +// #include +// #include +// #include +#include + +#include + +//================================================================================= +// class : OperationGUI_ExtrudedFeatureDlg() +// purpose : Constructs a OperationGUI_ExtrudedCutDlg which is a child of 'parent', +// with the name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= + +OperationGUI_ExtrudedFeatureDlg::OperationGUI_ExtrudedFeatureDlg(const int theOperation, + GeometryGUI* theGeometryGUI, + QWidget* parent,bool modal, + Qt::WindowFlags fl) + : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl), + myOperation(theOperation) +{ + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QPixmap image0; + QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICO_DRAFT"))); + QString aTitle; + switch (myOperation) + { + case OperationGUI::BOSS: + image0 = QPixmap(aResMgr->loadPixmap("GEOM", tr("ICO_EXTRUDED_BOSS"))); + aTitle = tr("GEOM_EXTRUDED_BOSS"); + break; + case OperationGUI::CUT: + image0 = QPixmap( aResMgr->loadPixmap("GEOM", tr("ICO_EXTRUDED_CUT"))); + aTitle = tr("GEOM_EXTRUDED_CUT"); + break; + } + + setWindowTitle(aTitle); + mainFrame()->GroupConstructors->setTitle(aTitle); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); + + mainFrame()->RadioButton1->setChecked(true); + + myGroup = new DlgRef_2Sel2Spin1Push(centralWidget()); + myGroup->PushButton1->setIcon(image1); + myGroup->PushButton2->setIcon(image1); + myGroup->PushButton3->setIcon(image2); + myGroup->LineEdit1->setReadOnly(true); + myGroup->LineEdit2->setReadOnly(true); + myGroup->TextLabel1->setText(tr("GEOM_INIT_SHAPE")); + myGroup->TextLabel2->setText(tr("GEOM_SKETCH")); + myGroup->TextLabel3->setText(tr("GEOM_HEIGHT")); + + + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); + layout->setSpacing(6); + layout->addWidget(myGroup); + + Init(); + +} + +//================================================================================= +// function : ~OperationGUI_ExtrudedFeatureDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_ExtrudedFeatureDlg::~OperationGUI_ExtrudedFeatureDlg() +{ +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_ExtrudedFeatureDlg::Init() +{ + // init variables + myEditCurrentArgument = myGroup->LineEdit1; + + // Get setting of step value from file configuration + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); + + initSpinBox(myGroup->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox(myGroup->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); + + myGroup->LineEdit1->setText(""); + myGroup->LineEdit2->setText(""); + myGroup->SpinBox_DX->setValue(10.0); + myGroup->SpinBox_DY->setValue(10.0); + myGroup->SpinBox_DY->setEnabled(false); + myObject1.nullify(); + myObject2.nullify(); + + // signals and slots connections + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(myGroup->PushButton3, SIGNAL(clicked(bool)), this, SLOT(ButtonClicked(bool))); + connect(myGroup->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(myGroup->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + + + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName(mainFrame()->GroupConstructors->title()); + + mainFrame()->RadioButton1->setFocus(); + + globalSelection(GEOM_ALLSHAPES); //TODO à changer + + myGroup->PushButton1->click(); + SelectionIntoArgument(); + + resize(minimumSizeHint()); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_ExtrudedFeatureDlg::ClickOnOk() +{ + setIsApplyAndClose( true ); + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool OperationGUI_ExtrudedFeatureDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(); + // activate selection and connect selection manager + myGroup->PushButton1->click(); + return true; +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_ExtrudedFeatureDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if (send == myGroup->PushButton1) { + myEditCurrentArgument = myGroup->LineEdit1; + + myGroup->PushButton2->setDown(false); + myGroup->LineEdit2->setEnabled(false); + } + else if (send == myGroup->PushButton2) { + myEditCurrentArgument = myGroup->LineEdit2; + + myGroup->PushButton1->setDown(false); + myGroup->LineEdit1->setEnabled(false); + } + + // enable line edit + myEditCurrentArgument->setEnabled(true); + myEditCurrentArgument->setFocus(); + // after setFocus(), because it will be setDown(false) when loses focus + send->setDown(true); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection is changed or on dialog initialization or activation +//================================================================================= +void OperationGUI_ExtrudedFeatureDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + + QList types; + types<LineEdit1) + { + types.clear(); + types<LineEdit2) + { + types.clear(); + types << TopAbs_EDGE << TopAbs_WIRE; + } + + GEOM::GeomObjPtr aSelectedObject = getSelected( types ); + TopoDS_Shape aShape; + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + myEditCurrentArgument->setText( aName ); + + // clear selection + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + if (myEditCurrentArgument == myGroup->LineEdit1) { + myObject1 = aSelectedObject; + if (!myObject2) + myGroup->PushButton2->click(); + } + else if (myEditCurrentArgument == myGroup->LineEdit2) { + myObject2 = aSelectedObject; + if (!myObject1) + myGroup->PushButton1->click(); + } + + displayPreview(true); + } + else { + if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify(); + else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify(); + } +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_ExtrudedFeatureDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( SelectionIntoArgument() ) ); + processPreview(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void OperationGUI_ExtrudedFeatureDlg::enterEvent (QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void OperationGUI_ExtrudedFeatureDlg::ValueChangedInSpinBox() +{ + displayPreview(true); +} + +//================================================================================= +// function : ButtonClicked(bool checked) +// purpose : +//================================================================================= +void OperationGUI_ExtrudedFeatureDlg::ButtonClicked(bool checked) +{ + myGroup->SpinBox_DY->setEnabled(checked); + displayPreview(true); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_ExtrudedFeatureDlg::createOperation() +{ + return getGeomEngine()->GetI3DPrimOperations(getStudyId()); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool OperationGUI_ExtrudedFeatureDlg::isValid (QString&) +{ + return myObject1 && myObject2; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool OperationGUI_ExtrudedFeatureDlg::execute (ObjectList& objects) +{ +// GEOM::GEOM_Object_var anObj; + + GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); + + double angle=0.0; + if (myGroup->PushButton3->isChecked()) + angle=myGroup->SpinBox_DY->value(); + + bool isProtrusion = (myOperation == OperationGUI::BOSS); + + GEOM::GEOM_Object_var anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(), + myGroup->SpinBox_DX->value(), + angle, + isProtrusion); +// switch (myOperation) +// { +// case OperationGUI::BOSS: +// anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(),myGroup->SpinBox_DX->value(),angle, true); +// break; +// case OperationGUI::CUT: +// anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(),myGroup->SpinBox_DX->value(),angle, false); +// break; +// } + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + + return true; +} + + + + + + + \ No newline at end of file diff --git a/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.h b/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.h new file mode 100644 index 000000000..052c69020 --- /dev/null +++ b/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.h @@ -0,0 +1,88 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// GEOM GEOMGUI : GUI for Geometry component +// File : OperationGUI_ExtrudedFeatureDlg.h +// Author : Renaud NEDELEC, Open CASCADE S.A.S. + +#ifndef BASICGUI_EXTRUDEDFEATUREDLG_H +#define BASICGUI_EXTRUDEDFEATUREDLG_H + +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" +#include + +// class DlgRef_2Sel1Spin; +// class DlgRef_3Spin; +// class DlgRef_2Sel; +// class DlgRef_1Sel3Spin; +// class DlgRef_1Sel2Spin; +class DlgRef_2Sel2Spin1Push; + +// class QLineEdit; +// class QGroupBox; +// class QButtonGroup; +// class QMenu; +class QAction; + +//================================================================================= +// class : OperationGUI_ExtrudedFeatureDlg +// purpose : +//================================================================================= +class OperationGUI_ExtrudedFeatureDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + OperationGUI_ExtrudedFeatureDlg( const int, GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 ); + ~OperationGUI_ExtrudedFeatureDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& ); + +private: + void Init(); + void enterEvent( QEvent* ); + +private: + int myOperation; + + GEOM::GeomObjPtr myObject1; + GEOM::GeomObjPtr myObject2; + + DlgRef_2Sel2Spin1Push* myGroup; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void ValueChangedInSpinBox(); + void ButtonClicked(bool); + +}; + +#endif // BASICGUI_EXTRUDEDFEATUREDLG_H \ No newline at end of file -- 2.39.2