From 06cf8f676b0830436fa5a6fb449276df8e3910f1 Mon Sep 17 00:00:00 2001 From: skl Date: Mon, 31 Mar 2008 12:05:05 +0000 Subject: [PATCH] Changes for bug NPAL14533 (improvement GetShapesOnShape()) --- idl/GEOM_Gen.idl | 39 ++ idl/GEOM_Superv.idl | 9 + resources/Makefile.am | 1 + resources/shapesonshape.png | Bin 0 -> 1230 bytes src/DlgRef/DlgRef_2Sel2List_QTD.cxx | 114 ++++++ src/DlgRef/DlgRef_2Sel2List_QTD.h | 55 +++ src/DlgRef/Makefile.am | 15 +- src/DlgRef/UIFiles/DlgRef_2Sel2List_QTD.ui | 154 ++++++++ src/GEOMGUI/GEOM_images.po | 4 + src/GEOMGUI/GEOM_msg_en.po | 36 ++ src/GEOMGUI/GEOM_msg_fr.po | 27 ++ src/GEOMGUI/GeometryGUI.cxx | 5 +- src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 233 +++++++++++- src/GEOMImpl/GEOMImpl_IShapesOperations.hxx | 127 +++++-- src/GEOMImpl/GEOMImpl_Types.hxx | 5 + src/GEOM_I/GEOM_IShapesOperations_i.cc | 127 +++++++ src/GEOM_I/GEOM_IShapesOperations_i.hh | 16 + src/GEOM_I_Superv/GEOM_Superv_i.cc | 41 +++ src/GEOM_I_Superv/GEOM_Superv_i.hh | 11 + src/GEOM_SWIG/geompyDC.py | 32 ++ src/OperationGUI/Makefile.am | 3 + src/OperationGUI/OperationGUI.cxx | 3 +- .../OperationGUI_GetShapesOnShapeDlg.cxx | 345 ++++++++++++++++++ .../OperationGUI_GetShapesOnShapeDlg.h | 77 ++++ 24 files changed, 1430 insertions(+), 49 deletions(-) create mode 100755 resources/shapesonshape.png create mode 100644 src/DlgRef/DlgRef_2Sel2List_QTD.cxx create mode 100644 src/DlgRef/DlgRef_2Sel2List_QTD.h create mode 100644 src/DlgRef/UIFiles/DlgRef_2Sel2List_QTD.ui create mode 100644 src/OperationGUI/OperationGUI_GetShapesOnShapeDlg.cxx create mode 100644 src/OperationGUI/OperationGUI_GetShapesOnShapeDlg.h diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index fcbded3e8..82d6094b6 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1382,6 +1382,45 @@ module GEOM in long theShapeType, in shape_state theState); + /*! + * \brief Find subshapes complying with given status + * \param theCheckShape - the shape to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \return List of IDs of all found sub-shapes. + */ + ListOfLong GetShapesOnShapeIDs (in GEOM_Object theCheckShape, + in GEOM_Object theShape, + in short theShapeType, + in shape_state theState); + + /*! + * \brief Find subshapes complying with given status + * \param theCheckShape - the shape to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \return List of all found sub-shapes. + */ + ListOfGO GetShapesOnShape (in GEOM_Object theCheckShape, + in GEOM_Object theShape, + in short theShapeType, + in shape_state theState); + + /*! + * \brief Find subshapes complying with given status + * \param theCheckShape - the shape to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \return compound includes all found sub-shapes. + */ + GEOM_Object GetShapesOnShapeAsCompound (in GEOM_Object theCheckShape, + in GEOM_Object theShape, + in short theShapeType, + in shape_state theState); + /*! * Get sub-shape(s) of \a theShapeWhere, which are * coincident with \a theShapeWhat or could be a part of it. diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index bb360ba27..a19c8cd9c 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -346,6 +346,15 @@ module GEOM long NumberOfEdges (in GEOM_Object theShape) ; GEOM_Object ChangeOrientation (in GEOM_Object theShape) ; + GEOM_List GetShapesOnShape (in GEOM_Object theCheckShape, + in GEOM_Object theShape, + in short theShapeType, + in shape_state theState); + GEOM_Object GetShapesOnShapeAsCompound (in GEOM_Object theCheckShape, + in GEOM_Object theShape, + in short theShapeType, + in shape_state theState); + //-----------------------------------------------------------// // BlocksOperations // //-----------------------------------------------------------// diff --git a/resources/Makefile.am b/resources/Makefile.am index 2fbc6564c..fdb978a29 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -130,6 +130,7 @@ section.png \ select1.png \ sewing.png \ shading.png \ +shapesonshape.png \ sketch.png \ sphere.png \ spheredxyz.png \ diff --git a/resources/shapesonshape.png b/resources/shapesonshape.png new file mode 100755 index 0000000000000000000000000000000000000000..05ac193523fc68e19b433f0b61d13db23d1fb4a7 GIT binary patch literal 1230 zcmW+$dr%X15dK{fjzBJkM`$imNz}?vMRI`=Dk?b?5PafWOOZqnoXUvR`WS)S9l;n8 zpG+l8oxt zg@H2z0RX~`^puT07Egl@`{L=7vxGhh*q^@RAOM1pX+Xcd)_QzRUP1EOWB?k@l(;uk z`D%G?`o^^Y9GeFKsRLk=_3Nc>uMiF%!DW3B`Rl0*9c1>1a7n|XkRAPGOVzTK(&yvoIPPb_#w$8ofZ`u z2Oe_tA4Wsbi0u2q^LYi_@P8$FQ9;aoZPO~H!bYU zb&ZeB>aM#bGh_UY49sB&z`ojR>va4xupVO=?-E^FQ51caFiTNZhgmJJya+LWEy^s@ zz4PPC(^k=yrT4?>fomhEw#CzCS>pbLivucqk5&B8VSly&jz4@@&pwF2{=9$aR5GnR zL!HVo+MTroVrH3K*XWRpewss|E$mc>V`4z2=Wg00Ei5cVlm04gcMQ=9aOBo}lOKS1 z@s1a|0z{=M&F%erKy&ZN#C%<2gMvOGlA%dj296(g%GCEDAv5V#SbNQgje@UFZi&O1 zmppb%z7)Xmvm@Zhoij|-|5hR_rfGM%^ys{D)L2s^<$bnA$}sMy4*xyqIkn5_mT^O^ z7+j}ejg;n>@hYm{DKbGs3+P$;DZ-K$Nq_?-Wnc@}Aj5slh@_%g`R@2#PMCqyz~_cm z^JxVfudijdqb**|F4xre6m{}+HFf-S6;%_~cex|%2FjGU+Z_W#>oJ*}w8VJ)zI`Lg z{Bp`uV_$%Iy{@U?zEri*o7=B(L92+$PNcGum9{jOb~>D0NAzY~GPYvwTZI*i+?pQ9 zyIu4zOA*9@xNlTsi4sUy-Jm&OZ_hP5(zV$ z+#tZ0n*_-_PS|DEH>|cSJ7ASX-bH5nO+*;s2O$R5ljman#dSy!-Ms@fF5cb>b9h0a zofa9+CA8jOdwY8=`%MW3yYuc@+(X$Ve8TUUZ1znzbl|l_pH-Y+CIpW@=ExbRAf&^$ zt;6;an*{@Y(cuERRz;xE3l~byJZi z*>q=p6M%PFCQW zZk7u0sG?d|KnCHWpTZt{IYGFZoBC2!a5Oynkz-`gU$2sxl^BOB6<;AJ_%aIrj>HeE zGA{&&I1^PV$@)WO%V!v5z9}^?74LLc;!T`bQd$uV-p86WcuBCF#IK9VZphG28U=<) p{A$Sgt6jx%EjJDkF9Hw@lIEu_Hr)B)XW#Du8L8`1ZZ21s{RhqP9ZCQI literal 0 HcmV?d00001 diff --git a/src/DlgRef/DlgRef_2Sel2List_QTD.cxx b/src/DlgRef/DlgRef_2Sel2List_QTD.cxx new file mode 100644 index 000000000..0deb7cddd --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel2List_QTD.cxx @@ -0,0 +1,114 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_2Sel2List_QTD.ui' +** +** Created: Thu Mar 27 16:38:25 2008 +** by: The User Interface Compiler ($Id$) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +#include "DlgRef_2Sel2List_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel2List_QTD as a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_2Sel2List_QTD::DlgRef_2Sel2List_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_2Sel2List_QTD" ); + DlgRef_2Sel2List_QTDLayout = new QVBoxLayout( this, 11, 6, "DlgRef_2Sel2List_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + GroupBox1Layout->addWidget( LineEdit2, 1, 2 ); + + ComboBox2 = new QComboBox( FALSE, GroupBox1, "ComboBox2" ); + + GroupBox1Layout->addMultiCellWidget( ComboBox2, 3, 3, 1, 2 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + + GroupBox1Layout->addWidget( TextLabel4, 3, 0 ); + + ComboBox1 = new QComboBox( FALSE, GroupBox1, "ComboBox1" ); + + GroupBox1Layout->addMultiCellWidget( ComboBox1, 2, 2, 1, 2 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + + GroupBox1Layout->addWidget( TextLabel3, 2, 0 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + GroupBox1Layout->addWidget( LineEdit1, 0, 2 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + + GroupBox1Layout->addWidget( TextLabel2, 1, 0 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + + GroupBox1Layout->addWidget( TextLabel1, 0, 0 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + + GroupBox1Layout->addWidget( PushButton1, 0, 1 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + + GroupBox1Layout->addWidget( PushButton2, 1, 1 ); + DlgRef_2Sel2List_QTDLayout->addWidget( GroupBox1 ); + languageChange(); + resize( QSize(187, 182).expandedTo(minimumSizeHint()) ); + clearWState( WState_Polished ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel2List_QTD::~DlgRef_2Sel2List_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * Sets the strings of the subwidgets using the current + * language. + */ +void DlgRef_2Sel2List_QTD::languageChange() +{ + setCaption( tr( "DlgRef_2Sel2List_QTD" ) ); + GroupBox1->setTitle( QString::null ); + TextLabel4->setText( tr( "TL4" ) ); + TextLabel3->setText( tr( "TL3" ) ); + TextLabel2->setText( tr( "TL2" ) ); + TextLabel1->setText( tr( "TL1" ) ); + PushButton1->setText( QString::null ); + PushButton2->setText( QString::null ); +} + diff --git a/src/DlgRef/DlgRef_2Sel2List_QTD.h b/src/DlgRef/DlgRef_2Sel2List_QTD.h new file mode 100644 index 000000000..b2ea00299 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel2List_QTD.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_2Sel2List_QTD.ui' +** +** Created: Thu Mar 27 16:38:25 2008 +** by: The User Interface Compiler ($Id$) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +#ifndef DLGREF_2SEL2LIST_QTD_H +#define DLGREF_2SEL2LIST_QTD_H + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QSpacerItem; +class QGroupBox; +class QLineEdit; +class QComboBox; +class QLabel; +class QPushButton; + +class DlgRef_2Sel2List_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_2Sel2List_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Sel2List_QTD(); + + QGroupBox* GroupBox1; + QLineEdit* LineEdit2; + QComboBox* ComboBox2; + QLabel* TextLabel4; + QComboBox* ComboBox1; + QLabel* TextLabel3; + QLineEdit* LineEdit1; + QLabel* TextLabel2; + QLabel* TextLabel1; + QPushButton* PushButton1; + QPushButton* PushButton2; + +protected: + QVBoxLayout* DlgRef_2Sel2List_QTDLayout; + QGridLayout* GroupBox1Layout; + +protected slots: + virtual void languageChange(); + +}; + +#endif // DLGREF_2SEL2LIST_QTD_H diff --git a/src/DlgRef/Makefile.am b/src/DlgRef/Makefile.am index 4568d53a9..290a7ee49 100644 --- a/src/DlgRef/Makefile.am +++ b/src/DlgRef/Makefile.am @@ -59,6 +59,7 @@ dist_libDlgRef_la_SOURCES = \ DlgRef_2Sel3Spin2Rb.cxx \ DlgRef_4Sel1List_QTD.cxx \ DlgRef_2Sel1List_QTD.cxx \ + DlgRef_2Sel2List_QTD.cxx \ DlgRef_2Sel1List1Check_QTD.cxx \ DlgRef_1List1Spin1Btn_QTD.cxx \ DlgRef_4Sel1List1Check_QTD.cxx \ @@ -67,7 +68,7 @@ dist_libDlgRef_la_SOURCES = \ DlgRef_3Spin_QTD.cxx \ DlgRef_3Spin1Check_QTD.cxx \ DlgRef_3Sel3Spin1Check_QTD.cxx \ - DlgRef_3Sel3Spin2Check_QTD.cxx \ + DlgRef_3Sel3Spin2Check_QTD.cxx \ DlgRef_4Sel1Spin2Check_QTD.cxx \ DlgRef_SpinBox.cxx \ DlgRef_1Sel1Spin.cxx \ @@ -85,7 +86,7 @@ dist_libDlgRef_la_SOURCES = \ DlgRef_2Sel4Spin1Check.cxx \ DlgRef_3Sel4Spin2Check.cxx \ DlgRef_3Sel3Spin1Check.cxx \ - DlgRef_3Sel3Spin2Check.cxx \ + DlgRef_3Sel3Spin2Check.cxx \ DlgRef_1Spin.cxx \ DlgRef_2Spin.cxx \ DlgRef_3Spin.cxx \ @@ -122,6 +123,7 @@ MOC_FILES = \ DlgRef_3Sel4Spin2Check_QTD_moc.cxx \ DlgRef_4Sel1List_QTD_moc.cxx \ DlgRef_2Sel1List_QTD_moc.cxx \ + DlgRef_2Sel2List_QTD_moc.cxx \ DlgRef_2Sel1List1Check_QTD_moc.cxx \ DlgRef_1List1Spin1Btn_QTD_moc.cxx \ DlgRef_4Sel1List1Check_QTD_moc.cxx \ @@ -130,7 +132,7 @@ MOC_FILES = \ DlgRef_3Spin_QTD_moc.cxx \ DlgRef_3Spin1Check_QTD_moc.cxx \ DlgRef_3Sel3Spin1Check_QTD_moc.cxx \ - DlgRef_3Sel3Spin2Check_QTD_moc.cxx \ + DlgRef_3Sel3Spin2Check_QTD_moc.cxx \ DlgRef_4Sel1Spin2Check_QTD_moc.cxx \ DlgRef_SpinBox_moc.cxx \ DlgRef_1Sel1Spin_moc.cxx \ @@ -148,7 +150,7 @@ MOC_FILES = \ DlgRef_2Sel4Spin1Check_moc.cxx \ DlgRef_3Sel4Spin2Check_moc.cxx \ DlgRef_3Sel3Spin1Check_moc.cxx \ - DlgRef_3Sel3Spin2Check_moc.cxx \ + DlgRef_3Sel3Spin2Check_moc.cxx \ DlgRef_1Spin_moc.cxx \ DlgRef_2Spin_moc.cxx \ DlgRef_3Spin_moc.cxx \ @@ -187,6 +189,7 @@ salomeinclude_HEADERS = \ DlgRef_2Sel3Spin2Rb.h \ DlgRef_4Sel1List_QTD.h \ DlgRef_2Sel1List_QTD.h \ + DlgRef_2Sel2List_QTD.h \ DlgRef_2Sel1List1Check_QTD.h \ DlgRef_1List1Spin1Btn_QTD.h \ DlgRef_4Sel1List1Check_QTD.h \ @@ -195,7 +198,7 @@ salomeinclude_HEADERS = \ DlgRef_3Spin_QTD.h \ DlgRef_3Spin1Check_QTD.h \ DlgRef_3Sel3Spin1Check_QTD.h \ - DlgRef_3Sel3Spin2Check_QTD.h \ + DlgRef_3Sel3Spin2Check_QTD.h \ DlgRef_4Sel1Spin2Check_QTD.h \ DlgRef_SpinBox.h \ DlgRef_1Sel1Spin.h \ @@ -213,7 +216,7 @@ salomeinclude_HEADERS = \ DlgRef_2Sel4Spin1Check.h \ DlgRef_3Sel4Spin2Check.h \ DlgRef_3Sel3Spin1Check.h \ - DlgRef_3Sel3Spin2Check.h \ + DlgRef_3Sel3Spin2Check.h \ DlgRef_1Spin.h \ DlgRef_2Spin.h \ DlgRef_3Spin.h \ diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel2List_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel2List_QTD.ui new file mode 100644 index 000000000..db1557d9d --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_2Sel2List_QTD.ui @@ -0,0 +1,154 @@ + +DlgRef_2Sel2List_QTD + + + DlgRef_2Sel2List_QTD + + + + 0 + 0 + 187 + 182 + + + + DlgRef_2Sel2List_QTD + + + + unnamed + + + + GroupBox1 + + + + + + + unnamed + + + + LineEdit2 + + + + + ComboBox2 + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + ComboBox1 + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + LineEdit1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + + + + diff --git a/src/GEOMGUI/GEOM_images.po b/src/GEOMGUI/GEOM_images.po index 01755c674..74a30836e 100644 --- a/src/GEOMGUI/GEOM_images.po +++ b/src/GEOMGUI/GEOM_images.po @@ -201,6 +201,10 @@ msgstr "arccenter.png" msgid "ICON_DLG_ARCHIMEDE" msgstr "archimede.png" +#GetShapesOnShapeDlg +msgid "ICON_DLG_SHAPES_ON_SHAPE" +msgstr "shapesonshape.png" + #PartitionDlg msgid "ICON_DLG_PARTITION" msgstr "partition.png" diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index ec1d79de1..d18ef12d5 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -465,6 +465,16 @@ msgstr "Step U :" #============================================================================== # +#ShapesOnShape +msgid "GEOM_SHAPES_ON_SHAPE" +msgstr "Shapes_on_shape" +msgid "GEOM_SHAPES_ON_SHAPE_ESHAPE" +msgstr "Shape for exploding" +msgid "GEOM_SHAPES_ON_SHAPE_CSHAPE" +msgstr "Shape for checking" +msgid "GEOM_SHAPES_ON_SHAPE_STATE" +msgstr "State" + #Partition msgid "GEOM_PARTITION" msgstr "Partition" @@ -1076,6 +1086,10 @@ msgstr "Change Orientation" msgid "GEOM_ORIENTATION_OPT" msgstr "Reverse orientation with normal vectors simulation" +#: GeometryGUI_GetShapesOnShapeDlg.cxx +msgid "GEOM_SHAPES_ON_SHAPE_TITLE" +msgstr "Get shapes on shape" + #: GeometryGUI_PartitionDlg.cxx:45 msgid "GEOM_PARTITION_TITLE" msgstr "Partition Of Object With Tool" @@ -1430,6 +1444,19 @@ msgstr "Bezier" msgid "GEOM_INTERPOL" msgstr "Interpolation" +msgid "GEOM_STATE_IN" +msgstr "IN" +msgid "GEOM_STATE_OUT" +msgstr "OUT" +msgid "GEOM_STATE_ON" +msgstr "ON" +msgid "GEOM_STATE_ONIN" +msgstr "ONIN" +msgid "GEOM_STATE_ONOUT" +msgstr "ONOUT" +msgid "GEOM_STATE_INOUT" +msgstr "INOUT" + # #============================================================================== # @@ -2589,6 +2616,15 @@ msgstr "Partition" msgid "STB_PARTITION" msgstr "Partition" +msgid "TOP_GET_SHAPES_ON_SHAPES" +msgstr "Get shapes on shape" + +msgid "MEN_GET_SHAPES_ON_SHAPES" +msgstr "Get shapes on shape" + +msgid "STB_GET_SHAPES_ON_SHAPES" +msgstr "Get shapes on shape" + msgid "TOP_ARCHIMEDE" msgstr "Archimede" diff --git a/src/GEOMGUI/GEOM_msg_fr.po b/src/GEOMGUI/GEOM_msg_fr.po index d4efd381d..0c4df972c 100644 --- a/src/GEOMGUI/GEOM_msg_fr.po +++ b/src/GEOMGUI/GEOM_msg_fr.po @@ -435,6 +435,16 @@ msgstr "Pas U :" #============================================================================== # +#GetShapesOnShape +msgid "GEOM_SHAPES_ON_SHAPE" +msgstr "Get shapes on shape" +msgid "GEOM_SHAPES_ON_SHAPE_ESHAPE" +msgstr "Shape for exploding" +msgid "GEOM_SHAPES_ON_SHAPE_CSHAPE" +msgstr "Shape for checking" +msgid "GEOM_SHAPES_ON_SHAPE_STATE" +msgstr "State" + #Partition msgid "GEOM_PARTITION" msgstr "Partition" @@ -977,6 +987,10 @@ msgstr "Changer l'Orientation" msgid "GEOM_ORIENTATION_OPT" msgstr "Renverser l'orientation avec une simulation de vecteur normal" +#: GeometryGUI_GetShapesOnShapeDlg.cxx +msgid "GEOM_SHAPES_ON_SHAPE_TITLE" +msgstr "Get shapes on shape" + #: GeometryGUI_PartitionDlg.cxx:45 msgid "GEOM_PARTITION_TITLE" msgstr "Partition d'Objects Avec Outils" @@ -1274,6 +1288,19 @@ msgstr "Bezier" msgid "GEOM_INTERPOL" msgstr "Interpolation" +msgid "GEOM_STATE_IN" +msgstr "IN" +msgid "GEOM_STATE_OUT" +msgstr "OUT" +msgid "GEOM_STATE_ON" +msgstr "ON" +msgid "GEOM_STATE_ONIN" +msgstr "ONIN" +msgid "GEOM_STATE_ONOUT" +msgstr "ONOUT" +msgid "GEOM_STATE_INOUT" +msgstr "INOUT" + # #============================================================================== # diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 11d602f2c..76feffd2c 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -499,7 +499,8 @@ void GeometryGUI::OnGUIEvent( int id ) id == 504 || // MENU OPERATION - ARCHIMEDE id == 505 || // MENU OPERATION - FILLET id == 506 || // MENU OPERATION - CHAMFER - id == 507 ) { // MENU OPERATION - CLIPPING RANGE + id == 507 || // MENU OPERATION - CLIPPING RANGE + id == 508 ) { // MENU OPERATION - GET SHAPES ON SHAPE #ifndef WNT library = getLibrary( "libOperationGUI.so" ); #else @@ -830,6 +831,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 505, "FILLET" ); createGeomAction( 506, "CHAMFER" ); //createGeomAction( 507, "CLIPPING" ); + createGeomAction( 508, "GET_SHAPES_ON_SHAPES" ); createGeomAction( 9998, "MUL_TRANSFORM" ); createGeomAction( 9995, "EXPLODE_BLOCKS" ); @@ -981,6 +983,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( 503, operId, -1 ); createMenu( 504, operId, -1 ); + createMenu( 508, operId, -1 ); createMenu( separator(), operId, -1 ); createMenu( 505, transId, -1 ); createMenu( 506, transId, -1 ); diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 089072899..b94d8f569 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -50,6 +50,7 @@ using namespace std; #include "GEOMAlgo_FinderShapeOnQuad.hxx" #include "GEOMAlgo_FinderShapeOn2.hxx" #include "GEOMAlgo_ClsfBox.hxx" +#include "GEOMAlgo_ClsfSolid.hxx" #include "GEOMAlgo_Gluer1.hxx" #include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx" #include "GEOMAlgo_CoupleOfShapes.hxx" @@ -116,6 +117,7 @@ using namespace std; #include +#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -1554,7 +1556,7 @@ Handle(TColStd_HSequenceOfInteger) // Make a Python command GEOM::TPythonDump(aFunction) - << "listShapesOnBoxIDs = geompy.GetShapesOnQuadrangleIDs(" + << "listShapesOnBoxIDs = geompy.GetShapesOnBoxIDs(" << theBox << ", " << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ", " @@ -1612,6 +1614,235 @@ Handle(TColStd_HSequenceOfTransient) } +//======================================================================= +//function : getShapesOnShapeIDs +/*! + * \brief Find IDs of subshapes complying with given status about surface + * \param theCheckShape - the shape to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes + */ +//======================================================================= + +Handle(TColStd_HSequenceOfInteger) + GEOMImpl_IShapesOperations::getShapesOnShapeIDs + (const Handle(GEOM_Object)& theCheckShape, + const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState) +{ + Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; + + TopoDS_Shape aCheckShape = theCheckShape->GetValue(); + TopoDS_Shape aShape = theShape->GetValue(); + TopTools_ListOfShape res; + + // Check presence of triangulation, build if need + if (!CheckTriangulation(aShape)) { + SetErrorCode("Cannot build triangulation on the shape"); + return aSeqOfIDs; + } + + // Call algo + GEOMAlgo_FinderShapeOn2 aFinder; + Standard_Real aTol = 0.0001; // default value + + Handle(GEOMAlgo_ClsfSolid) aClsfSolid = new GEOMAlgo_ClsfSolid; + aClsfSolid->SetShape(aCheckShape); + + aFinder.SetShape(aShape); + aFinder.SetTolerance(aTol); + aFinder.SetClsf(aClsfSolid); + aFinder.SetShapeType( (TopAbs_ShapeEnum)theShapeType ); + aFinder.SetState(theState); + aFinder.Perform(); + + // Interprete results + Standard_Integer iErr = aFinder.ErrorStatus(); + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iErr) { + MESSAGE(" iErr : " << iErr); + TCollection_AsciiString aMsg (" iErr : "); + aMsg += TCollection_AsciiString(iErr); + SetErrorCode(aMsg); + return aSeqOfIDs; + } + Standard_Integer iWrn = aFinder.WarningStatus(); + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iWrn) { + MESSAGE(" *** iWrn : " << iWrn); + } + + const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result + + if (listSS.Extent() < 1) { + //SetErrorCode("Not a single sub-shape of the requested type found on the given surface"); + SetErrorCode(NOT_FOUND_ANY); // NPAL18017 + } + + // Fill sequence of object IDs + aSeqOfIDs = new TColStd_HSequenceOfInteger; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + + TopTools_ListIteratorOfListOfShape itSub (listSS); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + int id = anIndices.FindIndex(itSub.Value()); + aSeqOfIDs->Append(id); + } + + return aSeqOfIDs; +} + + +//======================================================================= +//function : GetShapesOnShapeIDs +/*! + * \brief Find subshapes complying with given status about surface + * \param theCheckShape - the shape to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes + */ +//======================================================================= + +Handle(TColStd_HSequenceOfInteger) + GEOMImpl_IShapesOperations::GetShapesOnShapeIDs + (const Handle(GEOM_Object)& theCheckShape, + const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState) +{ + Handle(TColStd_HSequenceOfInteger) aSeqOfIDs = + getShapesOnShapeIDs (theCheckShape, theShape, theShapeType, theState); + + if ( aSeqOfIDs.IsNull() || aSeqOfIDs->Length() == 0 ) + return NULL; + + // The GetShapesOnShape() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = + GEOM::GetCreatedLast(theShape,theCheckShape)->GetLastFunction(); + + // Make a Python command + GEOM::TPythonDump(aFunction) + << "listShapesOnBoxIDs = geompy.GetShapesOnShapeIDs(" + << theCheckShape << ", " + << theShape << ", " + << TopAbs_ShapeEnum(theShapeType) << ", " + << theState << ")"; + + SetErrorCode(OK); + return aSeqOfIDs; +} + + +//======================================================================= +//function : GetShapesOnShape +/*! + * \brief Find subshapes complying with given status about surface + * \param theCheckShape - the shape to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfTransient) - found subshapes + */ +//======================================================================= + +Handle(TColStd_HSequenceOfTransient) + GEOMImpl_IShapesOperations::GetShapesOnShape + (const Handle(GEOM_Object)& theCheckShape, + const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState) +{ + Handle(TColStd_HSequenceOfInteger) aSeqOfIDs = + getShapesOnShapeIDs (theCheckShape, theShape, theShapeType, theState); + if ( aSeqOfIDs.IsNull() || aSeqOfIDs->Length() == 0 ) + return NULL; + + // Find objects by indices + TCollection_AsciiString anAsciiList; + Handle(TColStd_HSequenceOfTransient) aSeq; + aSeq = getObjectsShapesOn( theShape, aSeqOfIDs, anAsciiList ); + + if ( aSeq.IsNull() || aSeq->IsEmpty() ) + return NULL; + + // Make a Python command + + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast( aSeq->Value( 1 )); + Handle(GEOM_Function) aFunction = anObj->GetLastFunction(); + + GEOM::TPythonDump(aFunction) + << "[" << anAsciiList.ToCString() << "] = geompy.GetShapesOnShape(" + << theCheckShape << ", " + << theShape << ", " + << TopAbs_ShapeEnum(theShapeType) << ", " + << theState << ")"; + + + SetErrorCode(OK); + return aSeq; +} + + +//======================================================================= +//function : GetShapesOnShapeAsCompound +//======================================================================= + +Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnShapeAsCompound + (const Handle(GEOM_Object)& theCheckShape, + const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState) +{ + Handle(TColStd_HSequenceOfInteger) aSeqOfIDs = + getShapesOnShapeIDs (theCheckShape, theShape, theShapeType, theState); + + if ( aSeqOfIDs.IsNull() || aSeqOfIDs->Length() == 0 ) + return NULL; + + // Find objects by indices + TCollection_AsciiString anAsciiList; + Handle(TColStd_HSequenceOfTransient) aSeq; + aSeq = getObjectsShapesOn( theShape, aSeqOfIDs, anAsciiList ); + + if ( aSeq.IsNull() || aSeq->IsEmpty() ) + return NULL; + + TopoDS_Compound aCompound; + BRep_Builder B; + B.MakeCompound(aCompound); + int i = 1; + for(; i<=aSeq->Length(); i++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(aSeq->Value(i)); + TopoDS_Shape aShape_i = anObj->GetValue(); + B.Add(aCompound,aShape_i); + } + + //Add a new result object + Handle(GEOM_Object) aRes = GetEngine()->AddObject(GetDocID(), GEOM_SHAPES_ON_SHAPE); + Handle(GEOM_Function) aFunction = + aRes->AddFunction(GEOMImpl_ShapeDriver::GetID(), SHAPES_ON_SHAPE); + aFunction->SetValue(aCompound); + + GEOM::TPythonDump(aFunction) + << aRes << " = geompy.GetShapesOnShapeAsCompound(" + << theCheckShape << ", " + << theShape << ", " + << TopAbs_ShapeEnum(theShapeType) << ", " + << theState << ")"; + + SetErrorCode(OK); + + return aRes; +} + + //======================================================================= //function : getShapesOnSurfaceIDs /*! diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index 6506de36e..5791ebce9 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -254,13 +254,46 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations * \param theShape - the shape to explore * \param theShapeType - type of subshape of theShape * \param theState - required state + * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects + */ + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + GetShapesOnBox(const Handle(GEOM_Object)& theBox, + const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState); + + /*! + * \brief Find IDs of subshapes complying with given status about surface + * \param theCheckShape - the shape to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes */ + Standard_EXPORT Handle(TColStd_HSequenceOfInteger) + GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape, + const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState); + + /*! + * \brief Find subshapes complying with given status about surface + * \param theCheckShape - the shape to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects + */ Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - GetShapesOnBox(const Handle(GEOM_Object)& theBox, - const Handle(GEOM_Object)& theShape, - const Standard_Integer theShapeType, - GEOMAlgo_State theState); + GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape, + const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState); + Standard_EXPORT Handle(GEOM_Object) + GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape, + const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState); public: /*! @@ -298,8 +331,8 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations /*! * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK - * \param theShapeType - the shape type to check - * \retval bool - result of the check + * \param theShapeType - the shape type to check + * \retval bool - result of the check */ bool checkTypeShapesOn(const Standard_Integer theShapeType); @@ -312,20 +345,20 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations /*! * \brief Creates Geom_CylindricalSurface - * \param theAx1 - edge defining cylinder axis - * \param theRadius - cylinder radius - * \retval Handle(Geom_Surface) - resulting surface + * \param theAx1 - edge defining cylinder axis + * \param theRadius - cylinder radius + * \retval Handle(Geom_Surface) - resulting surface */ Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1, const Standard_Real theRadius); /*! * \brief Find IDs of subshapes complying with given status about surface - * \param theSurface - the surface to check state of subshapes against - * \param theShape - the shape to explore - * \param theShapeType - type of subshape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes + * \param theSurface - the surface to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes */ Handle(TColStd_HSequenceOfInteger) getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, @@ -335,12 +368,12 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations /*! * \brief Find subshapes complying with given status about surface - * \param theSurface - the surface to check state of subshapes against - * \param theShape - the shape to explore - * \param theShapeType - type of subshape of theShape - * \param theState - required state - * \param theShapeEntries - outgoing entries like "entry1, entry2, ..." - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes + * \param theSurface - the surface to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \param theShapeEntries - outgoing entries like "entry1, entry2, ..." + * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects */ Handle(TColStd_HSequenceOfTransient) getShapesOnSurface(const Handle(Geom_Surface)& theSurface, @@ -351,14 +384,14 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations /*! * \brief Find IDs of subshapes complying with given status about quadrangle - * \param theShape - the shape to explore - * \param theShapeType - type of subshape of theShape - * \param theTopLeftPoint - top left quadrangle corner - * \param theTopRigthPoint - top right quadrangle corner - * \param theBottomLeftPoint - bottom left quadrangle corner - * \param theBottomRigthPoint - bottom right quadrangle corner - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theTopLeftPoint - top left quadrangle corner + * \param theTopRigthPoint - top right quadrangle corner + * \param theBottomLeftPoint - bottom left quadrangle corner + * \param theBottomRigthPoint - bottom right quadrangle corner + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes */ Handle(TColStd_HSequenceOfInteger) getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape, @@ -371,23 +404,37 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations /*! * \brief Find IDs of subshapes complying with given status about surface - * \param theBox - the box to check state of subshapes against - * \param theShape - the shape to explore - * \param theShapeType - type of subshape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes + * \param theBox - the box to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes */ Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox, const Handle(GEOM_Object)& theShape, const Standard_Integer theShapeType, GEOMAlgo_State theState); + /*! + * \brief Find IDs of subshapes complying with given status about surface + * \param theCheckShape - the shape to check state of subshapes against + * \param theShape - the shape to explore + * \param theShapeType - type of subshape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes + */ + Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs + (const Handle(GEOM_Object)& theCheckShape, + const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState); + /*! * \brief Find shape objects and their entries by their ids - * \param theShape - the main shape - * \param theShapeIDs - theShapeIDs - incoming shape ids - * \param theShapeEntries - outgoing entries like "entry1, entry2, ..." - * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects + * \param theShape - the main shape + * \param theShapeIDs - theShapeIDs - incoming shape ids + * \param theShapeEntries - outgoing entries like "entry1, entry2, ..." + * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects */ Handle(TColStd_HSequenceOfTransient) getObjectsShapesOn(const Handle(GEOM_Object)& theShape, @@ -396,9 +443,9 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations /*! * \brief Select the object created last - * \param theObj1 - Object 1 - * \param theObj2 - Object 2 - * \retval Handle(GEOM_Object) - selected object + * \param theObj1 - Object 1 + * \param theObj2 - Object 2 + * \retval Handle(GEOM_Object) - selected object */ static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1, const Handle(GEOM_Object)& theObj2); diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index df856b856..505eb37d5 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -83,6 +83,9 @@ #define GEOM_COMPOUNDFILTER 41 +#define GEOM_SHAPES_ON_SHAPE 42 + + //GEOM_Function types #define COPY_WITH_REF 1 @@ -249,6 +252,8 @@ #define GROUP_FUNCTION 1 +#define SHAPES_ON_SHAPE 1 + // Blocks #define BLOCK_FACE_FOUR_PNT 1 #define BLOCK_FACE_FOUR_EDGES 2 diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc index 6d9bf7fcc..a1430f88a 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.cc +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -1290,6 +1290,133 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs return aSeq._retn(); } + +//============================================================================= +/*! + * GetShapesOnShape + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape + (GEOM::GEOM_Object_ptr theCheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if ( theShape == NULL || theCheckShape == NULL ) + return aSeq._retn(); + + //Get the reference objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aCheckShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theCheckShape->GetEntry()); + + if (aShape.IsNull() || aCheckShape.IsNull() ) + return aSeq._retn(); + + //Get Shapes On Shape + Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape + (aCheckShape,aShape, theShapeType,ShapeState(theState)); + + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + + +//============================================================================= +/*! + * GetShapesOnShapeAsCompound + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound + (GEOM::GEOM_Object_ptr theCheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if ( theShape == NULL || theCheckShape == NULL ) + return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aCheckShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theCheckShape->GetEntry()); + + if (aShape.IsNull() || aCheckShape.IsNull() ) + return aGEOMObject._retn(); + + //Get Shapes On Shape + Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound + (aCheckShape,aShape, theShapeType,ShapeState(theState)); + + if (anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * GetShapesOnShapeIDs + */ +//============================================================================= +GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs + (GEOM::GEOM_Object_ptr theCheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState) +{ + GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if ( theShape == NULL || theCheckShape == NULL ) + return aSeq._retn(); + + //Get the reference objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aCheckShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theCheckShape->GetEntry()); + + if (aShape.IsNull() || aCheckShape.IsNull() ) + return aSeq._retn(); + + //Get Shapes On Shape + Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs + (aCheckShape,aShape, theShapeType,ShapeState(theState)); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = aHSeq->Value(i); + + return aSeq._retn(); +} + + //============================================================================= /*! * GetInPlace diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.hh b/src/GEOM_I/GEOM_IShapesOperations_i.hh index de1b24be1..f900148a9 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.hh +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -175,6 +175,22 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : CORBA::Long theShapeType, GEOM::shape_state theState); + GEOM::ListOfGO* GetShapesOnShape (GEOM::GEOM_Object_ptr theSheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState); + + GEOM::GEOM_Object_ptr GetShapesOnShapeAsCompound + (GEOM::GEOM_Object_ptr theSheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState); + + GEOM::ListOfLong* GetShapesOnShapeIDs (GEOM::GEOM_Object_ptr theCheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState); + GEOM::GEOM_Object_ptr GetInPlace (GEOM::GEOM_Object_ptr theShapeWhere, GEOM::GEOM_Object_ptr theShapeWhat); diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index f4b42c404..bd10a6707 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -1892,6 +1892,7 @@ CORBA::Long GEOM_Superv_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape) return aRes; } + //============================================================================= // ChangeOrientation: //============================================================================= @@ -1906,6 +1907,46 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::ChangeOrientation (GEOM::GEOM_Object_ptr th } +//============================================================================= +// GetShapesOnShape: +//============================================================================= +GEOM::GEOM_List_ptr GEOM_Superv_i::GetShapesOnShape + (GEOM::GEOM_Object_ptr theCheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState) +{ + beginService( " GEOM_Superv_i::GetShapesOnShape" ); + MESSAGE("GEOM_Superv_i::GetShapesOnShape"); + getShapesOp(); + GEOM::ListOfGO* aList = + myShapesOp->GetShapesOnShape(theCheckShape, theShape, theShapeType, theState); + GEOM_List_i* aListPtr = new GEOM_List_i(*(aList)); + MESSAGE(" List of "<GetList().length()<<" element(s)"); + endService( " GEOM_Superv_i::GetShapesOnShape" ); + return aListPtr->_this(); +} + + +//============================================================================= +// GetShapesOnShapeAsCompound: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetShapesOnShapeAsCompound + (GEOM::GEOM_Object_ptr theCheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState) +{ + beginService( " GEOM_Superv_i::GetShapesOnShapeAsCompound" ); + MESSAGE("GEOM_Superv_i::GetShapesOnShapeAsCompound"); + getShapesOp(); + GEOM::GEOM_Object_ptr anObj = + myShapesOp->GetShapesOnShapeAsCompound(theCheckShape, theShape, theShapeType, theState); + endService( " GEOM_Superv_i::GetShapesOnShapeAsCompound" ); + return anObj; +} + + //=============================== BlocksOperations ============================ //============================================================================= // MakeQuad4Vertices: diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index c38ff7f8c..4a49ebac9 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -414,6 +414,17 @@ public: CORBA::Long NumberOfEdges (GEOM::GEOM_Object_ptr theShape); GEOM::GEOM_Object_ptr ChangeOrientation (GEOM::GEOM_Object_ptr theShape); + GEOM::GEOM_List_ptr GetShapesOnShape (GEOM::GEOM_Object_ptr theCheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState); + GEOM::GEOM_Object_ptr GetShapesOnShapeAsCompound + (GEOM::GEOM_Object_ptr theCheckShape, + GEOM::GEOM_Object_ptr theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState); + + //-----------------------------------------------------------// // BlocksOperations // //-----------------------------------------------------------// diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index cfd7fdb20..d9160b6b7 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -1107,6 +1107,38 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("GetShapesOnBoxIDs", self.ShapesOp) return aList + ## Find in \a theShape all sub-shapes of type \a theShapeType, + # situated relatively the specified \a theCheckShape by the + # certain way, defined through \a theState parameter. + # @param theCheckShape Shape for relative comparing. + # @param theShape Shape to find sub-shapes of. + # @param theShapeType Type of sub-shapes to be retrieved. + # @param theState The state of the subshapes to find. It can be one of + # ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN. + # @return List of all found sub-shapes. + # + def GetShapesOnShape(self, theCheckShape, theShape, theShapeType, theState): + aList = self.ShapesOp.GetShapesOnShape(theCheckShape, theShape, + theShapeType, theState) + RaiseIfFailed("GetShapesOnShape", self.ShapesOp) + return aList + + ## Works like the above method, but returns result as compound + # + def GetShapesOnShapeAsCompound(self, theCheckShape, theShape, theShapeType, theState): + anObj = self.ShapesOp.GetShapesOnShapeAsCompound(theCheckShape, theShape, + theShapeType, theState) + RaiseIfFailed("GetShapesOnShapeAsCompound", self.ShapesOp) + return anObj + + ## Works like the above method, but returns list of sub-shapes indices + # + def GetShapesOnShapeIDs(self, theCheckShape, theShape, theShapeType, theState): + aList = self.ShapesOp.GetShapesOnShapeIDs(theCheckShape, theShape, + theShapeType, theState) + RaiseIfFailed("GetShapesOnShapeIDs", self.ShapesOp) + return aList + ## Get sub-shape(s) of theShapeWhere, which are # coincident with \a theShapeWhat or could be a part of it. # @param theShapeWhere Shape to find sub-shapes of. diff --git a/src/OperationGUI/Makefile.am b/src/OperationGUI/Makefile.am index e25d13348..af91396a7 100644 --- a/src/OperationGUI/Makefile.am +++ b/src/OperationGUI/Makefile.am @@ -39,6 +39,7 @@ dist_libOperationGUI_la_SOURCES = \ OperationGUI.cxx \ OperationGUI_ArchimedeDlg.cxx \ OperationGUI_PartitionDlg.cxx \ + OperationGUI_GetShapesOnShapeDlg.cxx \ OperationGUI_FilletDlg.cxx \ OperationGUI_ChamferDlg.cxx \ OperationGUI_ClippingDlg.cxx @@ -46,6 +47,7 @@ dist_libOperationGUI_la_SOURCES = \ MOC_FILES = \ OperationGUI_ArchimedeDlg_moc.cxx \ OperationGUI_PartitionDlg_moc.cxx \ + OperationGUI_GetShapesOnShapeDlg_moc.cxx \ OperationGUI_FilletDlg_moc.cxx \ OperationGUI_ChamferDlg_moc.cxx \ OperationGUI_ClippingDlg_moc.cxx @@ -75,6 +77,7 @@ libOperationGUI_la_CPPFLAGS = \ -I$(srcdir)/../OBJECT \ -I$(srcdir)/../GEOMClient \ -I$(srcdir)/../GEOMImpl \ + -I$(srcdir)/../GEOMAlgo \ -I$(top_builddir)/idl \ -I$(top_builddir)/salome_adm/unix diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index 1372e926d..63c6de0f1 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -40,8 +40,8 @@ #include "OperationGUI_ArchimedeDlg.h" // Method ARCHIMEDE #include "OperationGUI_FilletDlg.h" // Method FILLET #include "OperationGUI_ChamferDlg.h" // Method CHAMFER - #include "OperationGUI_ClippingDlg.h" +#include "OperationGUI_GetShapesOnShapeDlg.h" using namespace std; @@ -80,6 +80,7 @@ bool OperationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case 505: (new OperationGUI_FilletDlg (getGeometryGUI(), parent))->show(); break; case 506: (new OperationGUI_ChamferDlg (getGeometryGUI(), parent))->show(); break; case 507: (new OperationGUI_ClippingDlg (getGeometryGUI(), parent))->show(); break; + case 508: (new OperationGUI_GetShapesOnShapeDlg (getGeometryGUI(), parent))->show(); break; default: app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); } diff --git a/src/OperationGUI/OperationGUI_GetShapesOnShapeDlg.cxx b/src/OperationGUI/OperationGUI_GetShapesOnShapeDlg.cxx new file mode 100644 index 000000000..4a8600baf --- /dev/null +++ b/src/OperationGUI/OperationGUI_GetShapesOnShapeDlg.cxx @@ -0,0 +1,345 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 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 +// +// +// +// File : OperationGUI_GetShapesOnShapeDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM + +#include "OperationGUI_GetShapesOnShapeDlg.h" + +#include "SUIT_Session.h" +#include "SalomeApp_Application.h" +#include "LightApp_SelectionMgr.h" + +#include +#include + +//using namespace std; + +//============================================================================== +// class : OperationGUI_GetShapesOnShapeDlg() +// purpose : Constructs a OperationGUI_GetShapesOnShapeDlg 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_GetShapesOnShapeDlg::OperationGUI_GetShapesOnShapeDlg(GeometryGUI* theGeometryGUI, + QWidget* parent) + :GEOMBase_Skeleton(theGeometryGUI, parent, "OperationGUI_GetShapesOnShapeDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + + SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); + QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_SHAPES_ON_SHAPE"))); + QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setCaption(tr("GEOM_SHAPES_ON_SHAPE_TITLE")); + + GroupConstructors->setTitle(tr("GEOM_SHAPES_ON_SHAPE")); + + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel2List_QTD(this, "GroupPoints"); + //GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION")); + GroupPoints->GroupBox1->setTitle("Input data"); + GroupPoints->TextLabel1->setText(tr("GEOM_SHAPES_ON_SHAPE_ESHAPE")); + GroupPoints->TextLabel2->setText(tr("GEOM_SHAPES_ON_SHAPE_CSHAPE")); + GroupPoints->TextLabel3->setText(tr("GEOM_RECONSTRUCTION_LIMIT")); + GroupPoints->TextLabel4->setText(tr("GEOM_SHAPES_ON_SHAPE_STATE")); + GroupPoints->PushButton1->setPixmap(image2); + GroupPoints->PushButton2->setPixmap(image2); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + + Layout1->addWidget(GroupPoints, 2, 0); + + Init(); +} + + +//================================================================================= +// function : ~OperationGUI_GetShapesOnShapeDlg +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_GetShapesOnShapeDlg::~OperationGUI_GetShapesOnShapeDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_GetShapesOnShapeDlg::Init() +{ + /* type for sub shape selection */ + GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_SOLID")); + GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_SHELL")); + GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_FACE")); + GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_WIRE")); + GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_EDGE")); + GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX")); + + /* type for state selection */ + GroupPoints->ComboBox2->insertItem(tr("GEOM_STATE_IN")); + GroupPoints->ComboBox2->insertItem(tr("GEOM_STATE_OUT")); + GroupPoints->ComboBox2->insertItem(tr("GEOM_STATE_ON")); + GroupPoints->ComboBox2->insertItem(tr("GEOM_STATE_ONIN")); + GroupPoints->ComboBox2->insertItem(tr("GEOM_STATE_ONOUT")); + + GroupPoints->LineEdit1->clear(); + GroupPoints->LineEdit2->clear(); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged())); + connect(GroupPoints->ComboBox2, SIGNAL(activated(int)), this, SLOT(ComboTextChanged())); + + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + globalSelection( GEOM_ALLSHAPES ); + + initName( GroupConstructors->title() ); + + resize(0, 0); + GroupPoints->TextLabel3->show(); + GroupPoints->ComboBox1->show(); + GroupPoints->ComboBox1->setCurrentItem(0); + GroupPoints->ComboBox2->show(); + GroupPoints->ComboBox2->setCurrentItem(0); + + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setFocus(); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_GetShapesOnShapeDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool OperationGUI_GetShapesOnShapeDlg::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + return true; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void OperationGUI_GetShapesOnShapeDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText( "" ); + QString aString = ""; + + int nbSel = GEOMBase::GetNameOfSelectedIObjects( selectedIO(), aString, true ); + + if(nbSel>0) { + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes && GEOMBase::IsShape( aSelectedObject ) ) { + { + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myObject1 = aSelectedObject; + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myObject2 = aSelectedObject; + } + } + } + + myEditCurrentArgument->setText( aString ); +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_GetShapesOnShapeDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if ( send == GroupPoints->PushButton1 ) myEditCurrentArgument = GroupPoints->LineEdit1; + else if ( send == GroupPoints->PushButton2 ) myEditCurrentArgument = GroupPoints->LineEdit2; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_GetShapesOnShapeDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if ( send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_GetShapesOnShapeDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + globalSelection( GEOM_ALLSHAPES ); + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void OperationGUI_GetShapesOnShapeDlg::enterEvent(QEvent * e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_GetShapesOnShapeDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); +} + + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool OperationGUI_GetShapesOnShapeDlg::isValid( QString& msg ) +{ + Handle(SALOME_InteractiveObject) IO = firstIObject(); + Standard_Boolean testResult; + GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject( IO, testResult ); + if ( !testResult || anObject->_is_nil() ) + return false; + + return !CORBA::is_nil( myObject1 ) && !CORBA::is_nil( myObject2 ); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool OperationGUI_GetShapesOnShapeDlg::execute( ObjectList& objects ) +{ + int aLimit = GroupPoints->ComboBox1->currentItem(); + switch (aLimit) + { + case 0: aLimit = GEOM::SOLID ; break; + case 1: aLimit = GEOM::SHELL ; break; + case 2: aLimit = GEOM::FACE ; break; + case 3: aLimit = GEOM::WIRE ; break; + case 4: aLimit = GEOM::EDGE ; break; + case 5: aLimit = GEOM::VERTEX; break; + default: aLimit = GEOM::SHAPE ; + } + + GEOM::shape_state aState; + switch (GroupPoints->ComboBox2->currentItem()) + { + case 0: aState = GEOM::ST_IN; break; + case 1: aState = GEOM::ST_OUT; break; + case 2: aState = GEOM::ST_ON; break; + case 3: aState = GEOM::ST_ONIN; break; + case 4: aState = GEOM::ST_ONOUT; break; + default: break; + } + + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations:: + _narrow( getOperation() )->GetShapesOnShapeAsCompound(myObject2, myObject1, + (CORBA::Short) aLimit, + aState); + + if (!anObj->_is_nil()) + objects.push_back( anObj._retn() ); + + return objects.size(); +} + + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void OperationGUI_GetShapesOnShapeDlg::closeEvent( QCloseEvent* e ) +{ + GEOMBase_Skeleton::closeEvent( e ); +} + + +//======================================================================= +//function : ComboTextChanged +//purpose : +//======================================================================= +void OperationGUI_GetShapesOnShapeDlg::ComboTextChanged() +{ + bool IsEnabled = GroupPoints->ComboBox1->currentItem() < 3; +} + + diff --git a/src/OperationGUI/OperationGUI_GetShapesOnShapeDlg.h b/src/OperationGUI/OperationGUI_GetShapesOnShapeDlg.h new file mode 100644 index 000000000..f2e955e09 --- /dev/null +++ b/src/OperationGUI/OperationGUI_GetShapesOnShapeDlg.h @@ -0,0 +1,77 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 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 +// +// +// +// File : OperationGUI_GetShapesOnShapeDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM + +#ifndef DIALOGBOX_GETSHAPESONSHAPE_H +#define DIALOGBOX_GETSHAPESONSHAPE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel2List_QTD.h" +#include "GEOMAlgo_State.hxx" + + +//================================================================================= +// class : OperationGUI_GetShapesOnShapeDlg +// purpose : +//================================================================================= +class OperationGUI_GetShapesOnShapeDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + OperationGUI_GetShapesOnShapeDlg(GeometryGUI* theGeometryGUI, QWidget* parent = 0); + ~OperationGUI_GetShapesOnShapeDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + +private: + void Init(); + void enterEvent(QEvent * e); + + GEOM::GEOM_Object_var myObject1; + GEOM::GEOM_Object_var myObject2; + int myShapeType; + GEOMAlgo_State myState; + + DlgRef_2Sel2List_QTD* GroupPoints; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); + void ComboTextChanged(); +}; + +#endif // DIALOGBOX_GETSHAPESONSHAPE_H -- 2.39.2