From 2447da69cc9b8dac24f347a54e286a6648a56900 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 14 Aug 2024 01:26:42 +0100 Subject: [PATCH] [bos #40618] [CEA] Offset/Thickness Feature. --- .../transformation_operations_ex06.py | 3 + .../gui/GEOM/images/transformation11a.png | Bin 0 -> 13585 bytes .../gui/GEOM/input/offset_operation.doc | 34 ++- idl/GEOM_Gen.idl | 13 + resources/CMakeLists.txt | 1 + resources/offset_partial.png | Bin 0 -> 870 bytes src/GEOMBase/GEOMBase.cxx | 17 ++ src/GEOMBase/GEOMBase.h | 1 + src/GEOMGUI/GEOM_images.ts | 4 + src/GEOMImpl/GEOMImpl_ConformityDriver.cxx | 26 +- .../GEOMImpl_ITransformOperations.cxx | 40 ++- .../GEOMImpl_ITransformOperations.hxx | 8 +- src/GEOMImpl/GEOMImpl_OffsetDriver.cxx | 94 +++++-- src/GEOM_I/GEOM_IMeasureOperations_i.cc | 18 +- src/GEOM_I/GEOM_ITransformOperations_i.cc | 41 +++ src/GEOM_I/GEOM_ITransformOperations_i.hh | 4 + src/GEOM_SWIG/geomBuilder.py | 45 ++++ .../TransformationGUI_OffsetDlg.cxx | 250 +++++++++++++----- .../TransformationGUI_OffsetDlg.h | 18 +- 19 files changed, 479 insertions(+), 138 deletions(-) create mode 100644 doc/salome/gui/GEOM/images/transformation11a.png create mode 100644 resources/offset_partial.png diff --git a/doc/salome/examples/transformation_operations_ex06.py b/doc/salome/examples/transformation_operations_ex06.py index 16bff16e1..3fad9ed38 100644 --- a/doc/salome/examples/transformation_operations_ex06.py +++ b/doc/salome/examples/transformation_operations_ex06.py @@ -13,14 +13,17 @@ box = geompy.MakeBox(20, 20, 20, 200, 200, 200) # create a new object as offset of the given object offset = geompy.MakeOffset(box, 70.) offset2 = geompy.MakeOffsetIntersectionJoin(box, 70.) +offset3 = geompy.MakeOffsetPartial(box, [13, 33], 70.) # add objects in the study id_box = geompy.addToStudy(box, "Box") id_offset = geompy.addToStudy(offset, "Offset") id_offset2 = geompy.addToStudy(offset2, "Offset_intersection_join") +id_offset3 = geompy.addToStudy(offset3, "Offset_Partial") # display the results gg.createAndDisplayGO(id_box) gg.setDisplayMode(id_box,1) gg.createAndDisplayGO(id_offset) gg.createAndDisplayGO(id_offset2) +gg.createAndDisplayGO(id_offset3) diff --git a/doc/salome/gui/GEOM/images/transformation11a.png b/doc/salome/gui/GEOM/images/transformation11a.png new file mode 100644 index 0000000000000000000000000000000000000000..f9e555bcabf8cb8b98b9be35cad7acb14cde0aea GIT binary patch literal 13585 zcmW+-WmFVQ7hXa_LDmTB}BTr*`*s65b64S zzdtkgJ~Q_|Gk50PGiT;ZxTd-S;Zv%o004kcNl{iC0Kh;30GRZ6SpN`F;~)9|DhyX` z1!+L#=+9>o!^7R(z18J~<@xEE*}3*ML|Iu`a!OiIP{>!O zFRWj)4Gat=rDa&z*s-v%K8n8f1_1cOm1L!KJr)l?Mn-IKKjUwl>E|lAeynPX%v6{{ zYbAYSd`>%5%K*ik)ungR93g49T-Wyy4YZuexjx`2bCwZpuMG)eMT?zEKJ|=%8Hl=! zb7uH@JU%5nWB0XCbt`Hi)j@`rpu2UU>nj-efopw%oc8FhP>BKsS{UJ*CYj^B6ys=> zkIRv7UB6}IMhNt8gOyCjQ!gcx>otOU2p#Pqu3jVqb!qu9&OqN%CyIK7L~t+1y}fI6 zGt&#|5?*PY0IIomq*tToGlyWZK~KxbG}WEZw<)}3dH>BjgVy#u@Jlc7GRldS`Ih9inGJ8F0xHBrw6&-OY`%k zJl_q_+O-YJa~M|F@G8lXgGtXwDc01UEM;zxZNbpx5jd`5VmCQmXlx^2HIr&guKS%G znj@&f2x|Q4gGQRo$eBMGpBrq#eiCQMSn!3aUQN>9cC(h;PSOlh3^TgfEt9N83D{ zE-0g|`H?7gFZW~6QFx7LonSV_)C8g|j0fH;F%Kj1$78rJ03Rcn5|bcyfr=Zm|- zX8gqYxm(Wrpd(hwF@rSB)R25A^;6e^{7wqkv3yQR86>B2fAF_sDH~yl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KtYnX`DQFIhDVu)qkwUCLH$;3BLvGG7r^qrY2(UHKo3RJ}3=O)ZvkGTfa|- zwfm`0S%%O)!75mEsbZqY*))kiV3qwf#A}T(ajimrm=9KIvq*_-PTKt?KuxNwMzHEy zF@dSV(M8W}>(tQvx-nKxdymvYP2fx{UaNCa-P|Dcx4?tDR#St#rexyC;s`!BaE8R` zJ2!>|z^m9U4_IDP-q851-Hvrlf>Mh5NQ%_Ac1zu2nA&mX;X|alRq}flr){D#9A&sr zbxOU>(fP+I*-szu7!mrSqkL725@X;P51FHOf?XcO;$3_ivvA$A(-64$LhRpbAlISr z8WhexrH)xjGvsG+`EjayOx>2xRnU4Wzt`Zn@%gh01dbDJ2}mc}Zk%oMuH~8|t&OrvV_a_g?3|sVe+I%6O3y^XK{URko1Z_WV?KRy z0Ucwj{Bx7>6CdhlujA12&tNzGPyG;#UzBm|g&1Djld5^ z2=!sJ&WUp@0&1^UUeivGHQ1-t@Rmd^Ud8V+ z-QjX_<=)6$;neg7v0{Wsen3N0eP6Bp11A^T{z5xaK(2eozR;sIx6?Eg+>>+&pb>jx z661~vKF|I(<)G+Kha&Dt-(zAEWL^Am{^{IsmP*z3*$W>Pl&eq0Sn^kgoO631Yo3Pq z#S@WX6RPi@3Yp%AXNnmd`QGs0-^-DXnk@Tn^IR{J2(<`o%_Z-A7x}ApMK|z?uhi0I Tr25~tCV-Nhx@@KN=fM8~w?Osi literal 0 HcmV?d00001 diff --git a/doc/salome/gui/GEOM/input/offset_operation.doc b/doc/salome/gui/GEOM/input/offset_operation.doc index d3d1fd197..949f3cfb7 100644 --- a/doc/salome/gui/GEOM/input/offset_operation.doc +++ b/doc/salome/gui/GEOM/input/offset_operation.doc @@ -5,6 +5,10 @@ \n To produce an Offset Surface in the Main Menu select Operations - > Transformation - > Offset Surface +\n There are 2 algorithms for creation of an \b Offset. + +\n Firstly, you can offset all faces of selected shape(s) to the same value. + \n This operation translates each point of an \b Object (a set of Objects) along a local normal by a given \b Offset distance (signed number, negative value meaning inner offset). Gaps between translated @@ -13,12 +17,12 @@ adjacent surfaces are filled in either of two ways: - else the surfaces are extended and intersected, so that sharp edges are preserved. -\n \b Offset operation is applicable to faces, shells and solids. -\n \ref restore_presentation_parameters_page "Advanced options". - - \image html transformation11.png +\n Arguments: Name + Object(s) (face(s), shell(s), solid(s)) + Offset value. +\n The \b Result will be a \b GEOM_Object. +\n \ref restore_presentation_parameters_page "Advanced options". + \n Example: \image html offsetsn.png "The box and its offset surface (Join by pipes activated)" @@ -27,11 +31,27 @@ adjacent surfaces are filled in either of two ways: - Gaps filled by pipes: geompy.MakeOffset(Shape, Offset), - Gaps filled by intersection: geompy.MakeOffsetIntersectionJoin(Shape, Offset), -where Shape is a shape(s) which has to be an offset, Offset is a value of +where \b Shape is a shape(s) which has to be an offset, \b Offset is a value of the offset. -\n Arguments: Name + Object (face(s), shell(s), solid(s)) + -Offset value. + +\n Secondly, you can offset only selected faces of the shape to the given value, + other faces will stay at their initial places, + but could be extended to join with offset faces. + Gaps between adjacent surfaces are filled by intersection of extended surfaces. + +\image html transformation11a.png + +\n Arguments: Name + Object (shell or solid) + + Face(s) of the object + Offset value. \n The \b Result will be a \b GEOM_Object. +\n \ref restore_presentation_parameters_page "Advanced options". + +\n TUI Command: +- geompy.MakeOffsetPartial(Shape, ListOfFacesIDs, Offset), + +where \b Shape is a shape(s) which has to be an offset, + \b ListOfFacesIDs is a list of integer IDs of sub-faces and + \b Offset is a value of the offset. Our TUI Scripts provide you with useful examples of the use of \ref tui_offset "Transformation Operations". diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index d1428637a..d045dcd75 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1345,6 +1345,19 @@ module GEOM in double theOffset, in boolean theJoinByPipes); + /*! + * \brief Create new object as offset of the given one. + * Only indexed faces are offset, others keep they original location. + * \param theObject The base object for the offset. + * \param theFacesIDs The list of face IDs indicating faces to be offset. + * \param theOffset Offset value. + * \param theJoinByPipes To join offset surfaces by pipes or by intersection. + * \return New GEOM_Object, containing the offset object. + */ + GEOM_Object OffsetShapePartialCopy (in GEOM_Object theObject, + in ListOfLong theFacesIDs, + in double theOffset); + /*! * \brief Create new object as projection of the given one on a 2D surface. * \param theSource The source object for the projection. It can be a point, edge or wire. diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 76bb5fbd7..16985f969 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -132,6 +132,7 @@ SET( _res_files multitranslationsimple.png normale.png offset.png + offset_partial.png projection.png projection_on_edge.png projection_on_wire.png diff --git a/resources/offset_partial.png b/resources/offset_partial.png new file mode 100644 index 0000000000000000000000000000000000000000..ced1d32dfbce1d4587a717f7849e9e7df74b99f9 GIT binary patch literal 870 zcmV-s1DX7ZP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5dZ)S5dnW>Uy%R+0{clsK~y+Tt&~eh zR8bhm|1+Z~X~ow@g(JE!kEb4MH>MBoR1&V8KoyZ`fj-?=U+CDtzJFHTg=GGVPa!6x@O{aVN%|d1a!)sM%7lXQgPa{rl3x+JI*^x zQ&q04tdx0qd3=e$o*~t5?bE~R{@A)*=$<}@lfGsJ69luZ6h7SR6tdMEqojsp!KS<3}WCHe!vck3JMAm zHuYKf@EA=N@Q_=EC4YYBIm%I{7^w{G!D)WH%pFMqOGwm6EoTz&`{A&fd?ojT2dzY7=K%=%4J-V<>|d$nYF6 w1w*p2DvTow%*JY94(>IEE%Y2I2L=Ft0kR^coDSSZApigX07*qoM6N<$g0&Zp>;M1& literal 0 HcmV?d00001 diff --git a/src/GEOMBase/GEOMBase.cxx b/src/GEOMBase/GEOMBase.cxx index 7ab1fa152..98e71f79d 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -796,6 +796,23 @@ QString GEOMBase::GetName( GEOM::GEOM_Object_ptr object ) return name; } +//======================================================================= +// function : GetName() +// purpose : Get name of objects +//======================================================================= +QString GEOMBase::GetName( const QList& objects ) +{ + QString name; + + int nbSel = objects.count(); + if (nbSel == 1) + name = GEOMBase::GetName( objects[0].get() ); + else if (nbSel > 1) + name = QObject::tr("%1_objects").arg( nbSel ); + + return name; +} + //======================================================================= // function : IsShape() // purpose : Return TRUE if object is valid and has shape diff --git a/src/GEOMBase/GEOMBase.h b/src/GEOMBase/GEOMBase.h index 8d35354df..2089f0373 100644 --- a/src/GEOMBase/GEOMBase.h +++ b/src/GEOMBase/GEOMBase.h @@ -122,6 +122,7 @@ public : /* Gets name of object */ static QString GetName( GEOM::GEOM_Object_ptr object ); + static QString GetName( const QList& objects ); /* Check if object has shape */ static bool IsShape( GEOM::GEOM_Object_ptr object ); diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 03ffd98e9..88abb3e22 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -451,6 +451,10 @@ ICON_DLG_OFFSET offset.png + + ICON_DLG_OFFSET_PARTIAL + offset_partial.png + ICON_DLG_PROJECTION_ON_FACE projection.png diff --git a/src/GEOMImpl/GEOMImpl_ConformityDriver.cxx b/src/GEOMImpl/GEOMImpl_ConformityDriver.cxx index faed054d0..1ad7c6580 100644 --- a/src/GEOMImpl/GEOMImpl_ConformityDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ConformityDriver.cxx @@ -42,28 +42,6 @@ namespace { - //======================================================================= - //function : ConvertShapesToIndices - //purpose : Convert sub-shapes of shapes to sequence of indices - //======================================================================= - Handle(TColStd_HArray1OfInteger) ConvertShapesToIndices(const TopoDS_Shape& theShape, - const TopTools_ListOfShape& theShapes) - { - Handle(TColStd_HArray1OfInteger) aSeqOfIDs = new TColStd_HArray1OfInteger(1, theShapes.Size()); - - TopTools_IndexedMapOfShape anIndices; - TopExp::MapShapes(theShape, anIndices); - - TopTools_ListIteratorOfListOfShape itSub(theShapes); - for (int index = 1; itSub.More(); itSub.Next(), ++index) - { - int id = anIndices.FindIndex(itSub.Value()); - aSeqOfIDs->SetValue(index, id); - } - - return aSeqOfIDs; - } - //======================================================================= //function : ConvertShapesToIndices //purpose : Convert list of pair shapes to sequence of indices @@ -203,6 +181,8 @@ Standard_Real GEOMImpl_ConformityDriver::updateTolerance(const TopoDS_Shape& the case TopAbs_FACE: aCurTolerance = BRep_Tool::Tolerance(TopoDS::Face(anExp.Value())); break; + default: + break; } aTolerance = Min(aTolerance, aCurTolerance); } @@ -228,6 +208,8 @@ Standard_Real GEOMImpl_ConformityDriver::updateTolerance(const TopoDS_Shape& the case TopAbs_FACE: aCurTolerance = BRep_Tool::Tolerance(TopoDS::Face(anExp.Value())); break; + default: + break; } aResTol = Max(aResTol, aCurTolerance); } diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index 4ca0707de..6581d5224 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -1090,10 +1090,11 @@ GEOMImpl_ITransformOperations::OffsetShape (Handle(GEOM_Object) theObject, * OffsetShapeCopy */ //============================================================================= -Handle(GEOM_Object) -GEOMImpl_ITransformOperations::OffsetShapeCopy( Handle(GEOM_Object) theObject, - double theOffset, - bool theJoinByPipes) +Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy + (Handle(GEOM_Object) theObject, + double theOffset, + bool theJoinByPipes, + const Handle(TColStd_HArray1OfInteger)& theFacesIDs) { SetErrorCode(KO); @@ -1118,6 +1119,10 @@ GEOMImpl_ITransformOperations::OffsetShapeCopy( Handle(GEOM_Object) theObject, aTI.SetValue( theOffset ); aTI.SetJoinByPipes( theJoinByPipes ); + if (!theFacesIDs.IsNull()) { + aTI.SetFaceIDs(theFacesIDs); + } + //Compute the offset try { OCC_CATCH_SIGNALS; @@ -1132,18 +1137,31 @@ GEOMImpl_ITransformOperations::OffsetShapeCopy( Handle(GEOM_Object) theObject, } //Make a Python command - if (theJoinByPipes) - GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset(" - << theObject << ", " << theOffset << ")"; - else - GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffsetIntersectionJoin(" - << theObject << ", " << theOffset << ")"; + if (theFacesIDs.IsNull()) { + if (theJoinByPipes) + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset(" + << theObject << ", " << theOffset << ")"; + else + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffsetIntersectionJoin(" + << theObject << ", " << theOffset << ")"; + } + else { + GEOM::TPythonDump pd (aFunction); + pd << aCopy << " = geompy.MakeOffsetPartial(" + << theObject << ", ["; + + // Dump faces IDs. + for (Standard_Integer i = theFacesIDs->Lower(); i <= theFacesIDs->Upper(); ++i) { + pd << theFacesIDs->Value(i) << ((i == theFacesIDs->Upper()) ? "" : ", "); + } + + pd << "], " << theOffset << ")"; + } SetErrorCode(OK); return aCopy; } - //============================================================================= /*! * ProjectShapeCopy diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx index 25498ce00..aac62cfdd 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx @@ -108,9 +108,11 @@ class GEOMImpl_ITransformOperations : public GEOM_IOperations double theOffset, bool theJoinByPipes); - Standard_EXPORT Handle(GEOM_Object) OffsetShapeCopy (Handle(GEOM_Object) theObject, - double theOffset, - bool theJoinByPipes); + Standard_EXPORT Handle(GEOM_Object) OffsetShapeCopy + (Handle(GEOM_Object) theObject, + double theOffset, + bool theJoinByPipes, + const Handle(TColStd_HArray1OfInteger)& theFacesIDs = NULL); Standard_EXPORT Handle(GEOM_Object) ProjectShapeCopy (Handle(GEOM_Object) theSource, Handle(GEOM_Object) theTarget); diff --git a/src/GEOMImpl/GEOMImpl_OffsetDriver.cxx b/src/GEOMImpl/GEOMImpl_OffsetDriver.cxx index f33b86721..fb47d9e4e 100644 --- a/src/GEOMImpl/GEOMImpl_OffsetDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_OffsetDriver.cxx @@ -28,12 +28,13 @@ #include #include +#include #include #include -#include #include #include -#include +#include +#include #include #include #include @@ -88,24 +89,79 @@ Standard_Integer GEOMImpl_OffsetDriver::Execute(Handle(TFunction_Logbook)& log) if ( aType == OFFSET_SHAPE || aType == OFFSET_SHAPE_COPY ) { - BRepOffsetAPI_MakeOffsetShape MO; BRepOffset_Mode aMode = BRepOffset_Skin; - Standard_Boolean anIntersection = Standard_False, aSelfInter = Standard_False; - MO.PerformByJoin( aShapeBase, - aCI.GetValue(), - aTol, - aMode, - anIntersection, - aSelfInter, - aCI.GetJoinByPipes() ? GeomAbs_Arc : GeomAbs_Intersection ); + Standard_Boolean anIntersection = Standard_False; + Standard_Boolean aSelfInter = Standard_False; - if ( MO.IsDone() ) { - aShape = MO.Shape(); - if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) ) - Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result"); + Handle(TColStd_HArray1OfInteger) aFacesIDs = aCI.GetFaceIDs(); + if (aFacesIDs.IsNull() || aFacesIDs->Length() < 1) { + // Offset entire shape (all faces) with the same offset value + BRepOffsetAPI_MakeOffsetShape MO; + MO.PerformByJoin( aShapeBase, + anOffset, + aTol, + aMode, + anIntersection, + aSelfInter, + aCI.GetJoinByPipes() ? GeomAbs_Arc : GeomAbs_Intersection ); + + if ( MO.IsDone() ) { + aShape = MO.Shape(); + if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) ) + Standard_ConstructionError::Raise("Offset aborted : non valid shape result"); + } + else { + StdFail_NotDone::Raise("Offset construction failed"); + } } else { - StdFail_NotDone::Raise("Offset construction failed"); + // Offset selected faces of main shape by given value, other faces by 0 + BRepOffset_MakeOffset aMakeOffset; + aMakeOffset.Initialize(aShapeBase, + anOffset, // set offset on all faces to anOffset + aTol, + aMode, + anIntersection, + aSelfInter, + aCI.GetJoinByPipes() ? GeomAbs_Arc : GeomAbs_Intersection, + Standard_False); + + // put selected faces into a map + TopTools_MapOfShape aMapFaces; + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShapeBase, anIndices); + Standard_Integer aNbShapes = anIndices.Extent(); + for (Standard_Integer i = aFacesIDs->Lower(); i <= aFacesIDs->Upper(); ++i) { + const Standard_Integer anIndex = aFacesIDs->Value(i); + if (anIndex < 1 || anIndex > aNbShapes) { + Standard_ConstructionError::Raise("Offset aborted : Invalid face index given"); + } + const TopoDS_Shape &aFace = anIndices.FindKey(anIndex); + if (aFace.ShapeType() != TopAbs_FACE) { + Standard_ConstructionError::Raise("Offset aborted : Shape by index is not a face"); + } + aMapFaces.Add(aFace); + } + + // set offset on non-selected faces to zero + TopExp_Explorer anExp (aShapeBase, TopAbs_FACE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Shape &aFace = anExp.Current(); + if (!aMapFaces.Contains(aFace)) { + aMakeOffset.SetOffsetOnFace(TopoDS::Face(aFace), 0.0); + } + } + + // perform offset operation + aMakeOffset.MakeOffsetShape(); + if ( aMakeOffset.IsDone() ) { + aShape = aMakeOffset.Shape(); + if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) ) + Standard_ConstructionError::Raise("Offset aborted : non valid shape result"); + } + else { + StdFail_NotDone::Raise("Offset construction failed"); + } } } else if (aType == OFFSET_THICKENING || aType == OFFSET_THICKENING_COPY) @@ -216,6 +272,12 @@ GetCreationInformation(std::string& theOperationName, theOperationName = "OFFSET"; AddParam( theParams, "Object", aCI.GetShape() ); AddParam( theParams, "Offset", aCI.GetValue() ); + { + Handle(TColStd_HArray1OfInteger) aFacesIDs = aCI.GetFaceIDs(); + if (!aFacesIDs.IsNull()) { + AddParam(theParams, "Faces IDs", aFacesIDs); + } + } break; case OFFSET_THICKENING: case OFFSET_THICKENING_COPY: diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc index 3c7d6343f..0acbdb36c 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.cc +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -1366,8 +1366,8 @@ GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i: std::list::iterator anIter(aSelfInters.begin()); for (Standard_Integer i = 0; i < aLength; i++, ++anIter) { - aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first)); - aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second)); + aSeq[i].first = GetObject((*anIter).first); + aSeq[i].second = GetObject((*anIter).second); } return aSeq._retn(); @@ -1404,8 +1404,8 @@ GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i: std::list::iterator anIter(aSelfInterf.begin()); for (Standard_Integer i = 0; i < aLength; i++, ++anIter) { - aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first)); - aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second)); + aSeq[i].first = GetObject((*anIter).first); + aSeq[i].second = GetObject((*anIter).second); } return aSeq._retn(); @@ -1471,8 +1471,8 @@ GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i: std::list::iterator anIter(aDistantS.begin()); for (Standard_Integer i = 0; i < aLength; i++, ++anIter) { - aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first)); - aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second)); + aSeq[i].first = GetObject((*anIter).first); + aSeq[i].second = GetObject((*anIter).second); } return aSeq._retn(); @@ -1502,8 +1502,8 @@ GEOM::GEOM_IMeasureOperations::CheckResults* GEOM_IMeasureOperations_i::CheckCon for (Standard_Integer i = 0; i < aLength; i++, ++anIntIt) { aRes[i].type = (*anIntIt).TypeOfCheck; - aRes[i].failedShapes.first = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.first)); - aRes[i].failedShapes.second = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.second)); + aRes[i].failedShapes.first = GetObject((*anIntIt).FailedShapes.first); + aRes[i].failedShapes.second = GetObject((*anIntIt).FailedShapes.second); } return aRes._retn(); @@ -1530,7 +1530,7 @@ CORBA::Double GEOM_IMeasureOperations_i::UpdateTolerance(GEOM::GEOM_Object_ptr t void GEOM_IMeasureOperations_i::ConvertToList(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts, std::list& theListOfResults) { - for (Standard_Integer i = 0; i < theResuts.length(); ++i) + for (size_t i = 0; i < theResuts.length(); ++i) { GEOMImpl_IMeasureOperations::FailedChecks aCheck; aCheck.TypeOfCheck = theResuts[i].type; diff --git a/src/GEOM_I/GEOM_ITransformOperations_i.cc b/src/GEOM_I/GEOM_ITransformOperations_i.cc index 8f866ca41..9e8b0b034 100644 --- a/src/GEOM_I/GEOM_ITransformOperations_i.cc +++ b/src/GEOM_I/GEOM_ITransformOperations_i.cc @@ -668,6 +668,47 @@ GEOM_ITransformOperations_i::OffsetShapeCopy (GEOM::GEOM_Object_ptr theObject, return GetObject(anObject); } +//============================================================================= +/*! + * OffsetShapePartialCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr +GEOM_ITransformOperations_i::OffsetShapePartialCopy (GEOM::GEOM_Object_ptr theObject, + const GEOM::ListOfLong& theFacesIDs, + CORBA::Double theOffset) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the basic object + Handle(::GEOM_Object) aBasicObject = GetObjectImpl(theObject); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + // Get faces IDs. + Handle(TColStd_HArray1OfInteger) aFaceIDs; + Standard_Integer aNbIDs = theFacesIDs.length(); + if (aNbIDs > 0) { + aFaceIDs = new TColStd_HArray1OfInteger (1, aNbIDs); + for (Standard_Integer i = 0; i < aNbIDs; i++) { + aFaceIDs->SetValue(i + 1, theFacesIDs[i]); + } + } + + // join by pipes mode is not supported in combination with partial offset + bool aJoinByPipes = false; + + //Create the offset shape + Handle(::GEOM_Object) anObject = + GetOperations()->OffsetShapeCopy(aBasicObject, theOffset, aJoinByPipes, aFaceIDs); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * ProjectShapeCopy diff --git a/src/GEOM_I/GEOM_ITransformOperations_i.hh b/src/GEOM_I/GEOM_ITransformOperations_i.hh index d4ad3f00f..ccadb550c 100644 --- a/src/GEOM_I/GEOM_ITransformOperations_i.hh +++ b/src/GEOM_I/GEOM_ITransformOperations_i.hh @@ -142,6 +142,10 @@ class GEOM_I_EXPORT GEOM_ITransformOperations_i : CORBA::Double theOffset, CORBA::Boolean theJoinByPipes); + GEOM::GEOM_Object_ptr OffsetShapePartialCopy (GEOM::GEOM_Object_ptr theObject, + const GEOM::ListOfLong& theFacesIDs, + CORBA::Double theOffset); + GEOM::GEOM_Object_ptr ProjectShapeCopy (GEOM::GEOM_Object_ptr theSource, GEOM::GEOM_Object_ptr theTarget); diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 7cf3edc64..e442cf195 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -9623,6 +9623,51 @@ class geomBuilder(GEOM._objref_GEOM_Gen): self._autoPublish(anObj, theName, "offset") return anObj + ## Create new object as partial offset of the given one. + # Only indexed faces are offset, others keep they original location. + # Gap between adjacent offset surfaces is filled + # by extending and intersecting them. + # @param theObject The base object for the offset. + # @param theFacesIDs The list of face IDs indicating faces to be offset. + # @param theOffset Offset value. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return New GEOM.GEOM_Object, containing the offset object. + # + # @ref tui_offset "Example" + @ManageTransactions("TrsfOp") + def MakeOffsetPartial(self, theObject, theFacesIDs, theOffset, theName=None): + """ + Create new object as partial offset of the given one. + Only indexed faces are offset, others keep they original location. + Gap between adjacent offset surfaces is filled + by extending and intersecting them. + + Parameters: + theObject The base object for the offset. + theFacesIDs The list of face IDs indicating faces to be offset. + theOffset Offset value. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing the offset object. + + Example of usage: + box = geompy.MakeBox(20, 20, 20, 200, 200, 200) + # create a new object from the box, offsetting its top and front faces + offset = geompy.MakeOffsetPartial(box, [13, 33], 70.) + """ + theOffset, Parameters = ParseParameters(theOffset) + anObj = self.TrsfOp.OffsetShapePartialCopy(theObject, theFacesIDs, theOffset) + RaiseIfFailed("OffsetShapePartialCopy", self.TrsfOp) + anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "offset") + return anObj + ## Create new object as projection of the given one on another. # @param theSource The source object for the projection. It can be a point, edge or wire. # Edge and wire are acceptable if @a theTarget is a face. diff --git a/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx index 523c7b62f..16327d448 100644 --- a/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx @@ -35,6 +35,9 @@ #include #include +#include +#include + //================================================================================= // class : TransformationGUI_OffsetDlg() // purpose : Constructs a TransformationGUI_OffsetDlg which is a child of 'parent', with the @@ -42,31 +45,41 @@ // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_OffsetDlg::TransformationGUI_OffsetDlg( GeometryGUI* theGeometryGUI, QWidget* parent, - bool modal, Qt::WindowFlags fl ) - : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) +TransformationGUI_OffsetDlg::TransformationGUI_OffsetDlg + (GeometryGUI* theGeometryGUI, QWidget* parent, + bool modal, Qt::WindowFlags fl) + : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl) { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_OFFSET" ) ) ); - QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_OFFSET"))); + QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_OFFSET_PARTIAL"))); - setWindowTitle( tr( "GEOM_OFFSET_TITLE" ) ); + setWindowTitle(tr("GEOM_OFFSET_TITLE")); /***************************************************************/ - mainFrame()->GroupConstructors->setTitle( tr( "GEOM_OFFSET" ) ); - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); - mainFrame()->RadioButton2->close(); - mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->GroupConstructors->setTitle(tr("GEOM_OFFSET")); + mainFrame()->RadioButton1->setIcon(image1); + mainFrame()->RadioButton2->setIcon(image2); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->close(); + mainFrame()->RadioButton1->setChecked(true); + + GroupPoints = new DlgRef_2Sel1Spin2Check( centralWidget() ); - GroupPoints = new DlgRef_1Sel1Spin1Check( centralWidget() ); GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); + GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); - GroupPoints->TextLabel2->setText( tr( "GEOM_OFFSET" ) ); + GroupPoints->TextLabel2->setText( tr( "GEOM_FACES" ) ); + GroupPoints->TextLabel3->setText( tr( "GEOM_OFFSET" ) ); + + GroupPoints->PushButton1->setIcon( image0 ); + GroupPoints->PushButton2->setIcon( image0 ); + GroupPoints->CheckButton1->setText( tr( "GEOM_JOIN_BY_PIPES" ) ); GroupPoints->CheckButton1->setChecked( true ); - - GroupPoints->PushButton1->setIcon( image1 ); + GroupPoints->CheckButton2->setAttribute( Qt::WA_DeleteOnClose ); + GroupPoints->CheckButton2->close(); QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); @@ -99,33 +112,76 @@ void TransformationGUI_OffsetDlg::Init() /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); myObjects.clear(); - - /* Get setting of step value from file configuration */ - double step = 1; + myFaces.clear(); /* min, max, step and decimals for spin boxes & initial values */ + double step = 1; initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); GroupPoints->SpinBox_DX->setValue( 1e-05 ); mainFrame()->GroupBoxPublish->show(); /* signals and slots connections */ - connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(this, SIGNAL(constructorsClicked(int)), + this, SLOT(ConstructorsClicked(int))); - connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(GroupPoints->PushButton1, SIGNAL(clicked()), + this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), + this, SLOT(SetEditCurrentArgument())); - connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); - connect( GroupPoints->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( JoinModeChanged() ) ); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), + this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), + this, SLOT(JoinModeChanged())); - initName( tr( "GEOM_OFFSET" ) ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - globalSelection( GEOM_ALLSHAPES ); - resize(100,100); + initName(tr("GEOM_OFFSET")); + + ConstructorsClicked(0); +} + +//============================================================================== +// function : ConstructorsClicked() +// purpose : Radio button management +//============================================================================== +void TransformationGUI_OffsetDlg::ConstructorsClicked (int constructorId) +{ + switch (constructorId) { + case 0: + // disable faces selection + GroupPoints->TextLabel2->hide(); + GroupPoints->PushButton2->hide(); + GroupPoints->LineEdit2->hide(); + + // enable joint type + GroupPoints->CheckButton1->show(); + break; + case 1: + // enable faces selection + GroupPoints->TextLabel2->show(); + GroupPoints->PushButton2->show(); + GroupPoints->LineEdit2->show(); + + // disable joint type + GroupPoints->CheckButton1->hide(); + break; + default: + break; + } + + qApp->processEvents(); + updateGeometry(); + resize(minimumSizeHint()); + + GroupPoints->PushButton1->click(); SelectionIntoArgument(); } @@ -152,6 +208,10 @@ bool TransformationGUI_OffsetDlg::ClickOnApply() return false; initName(); + + // activate selection and connect selection manager + ConstructorsClicked(getConstructorId()); + return true; } @@ -162,13 +222,27 @@ bool TransformationGUI_OffsetDlg::ClickOnApply() //================================================================================= void TransformationGUI_OffsetDlg::SelectionIntoArgument() { - myObjects = getSelected( TopAbs_SHAPE, -1 ); - if ( !myObjects.isEmpty() ) { - QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() ); - myEditCurrentArgument->setText( aName ); + myEditCurrentArgument->setText(""); + + if (myEditCurrentArgument == GroupPoints->LineEdit1) { + if (getConstructorId() == 0) { + myObjects = getSelected( TopAbs_SHAPE, -1 ); + myEditCurrentArgument->setText(GEOMBase::GetName(myObjects)); + } + else if (getConstructorId() == 1) { + myFaces.clear(); + GroupPoints->LineEdit2->setText(""); + myObjects = getSelected(TopAbs_SHAPE, 1); // only one object allowed + if (!myObjects.isEmpty()) { + myEditCurrentArgument->setText(GEOMBase::GetName(myObjects[0].get())); + GroupPoints->PushButton2->click(); + } + } } - else { - myEditCurrentArgument->setText(""); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + myFaces.clear(); + myFaces = getSelected(TopAbs_FACE, -1); + myEditCurrentArgument->setText(GEOMBase::GetName(myFaces)); } processPreview(); @@ -184,11 +258,20 @@ void TransformationGUI_OffsetDlg::SetEditCurrentArgument() QPushButton* send = (QPushButton*)sender(); if ( send == GroupPoints->PushButton1 ) { - GroupPoints->PushButton1->setDown(true); + GroupPoints->PushButton2->setDown(false); myEditCurrentArgument = GroupPoints->LineEdit1; - myEditCurrentArgument->setFocus(); - SelectionIntoArgument(); + globalSelection(GEOM_ALLSHAPES); } + else if (send == GroupPoints->PushButton2) { + GroupPoints->PushButton1->setDown(false); + myEditCurrentArgument = GroupPoints->LineEdit2; + globalSelection(); // close local contexts, if any + if (myObjects.size() > 0) + localSelection(myObjects[0].get(), TopAbs_FACE); + } + + myEditCurrentArgument->setFocus(); + send->setDown(true); } @@ -210,11 +293,11 @@ void TransformationGUI_OffsetDlg::enterEvent( QEvent* ) void TransformationGUI_OffsetDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - globalSelection( GEOM_ALLSHAPES ); - myEditCurrentArgument = GroupPoints->LineEdit1; - myEditCurrentArgument->setFocus(); + + ConstructorsClicked(getConstructorId()); } @@ -243,14 +326,27 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_OffsetDlg::createOperation() //================================================================================= bool TransformationGUI_OffsetDlg::isValid( QString& msg ) { - bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && !myObjects.isEmpty(); - for ( int i = 0; i < myObjects.count() && ok; i++ ) { - GEOM::shape_type aType = myObjects[i]->GetShapeType(); - ok = aType == GEOM::FACE || aType == GEOM::SHELL || aType == GEOM::SOLID; - if ( !ok ) - msg = tr( "ERROR_SHAPE_TYPE" ); + bool isOk = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && !myObjects.isEmpty(); + + if (isOk) { + switch (getConstructorId()) { + case 0: + for ( int i = 0; i < myObjects.count() && isOk; i++ ) { + GEOM::shape_type aType = myObjects[i]->GetShapeType(); + isOk = aType == GEOM::FACE || aType == GEOM::SHELL || aType == GEOM::SOLID; + if ( !isOk ) + msg = tr( "ERROR_SHAPE_TYPE" ); + } + break; + case 1: + isOk = myObjects.size() == 1 && !myFaces.isEmpty(); + break; + default: + break; + } } - return ok; + + return isOk; } //================================================================================= @@ -263,28 +359,59 @@ bool TransformationGUI_OffsetDlg::execute( ObjectList& objects ) GEOM::GEOM_Object_var anObj; - GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); + GEOM::GEOM_ITransformOperations_var anOper = + GEOM::GEOM_ITransformOperations::_narrow(getOperation()); - if ( true /*GroupPoints->CheckButton1->isChecked() || IsPreview()*/ ) { - for ( int i = 0; i < myObjects.count(); i++ ) { - - anObj = anOper->OffsetShapeCopy( myObjects[i].get(), GetOffset(), GetIsJoinByPipes() ); - if ( !anObj->_is_nil() ) { - if(!IsPreview()) { + if (getConstructorId() == 0) { + for (int i = 0; i < myObjects.count(); i++) { + anObj = anOper->OffsetShapeCopy(myObjects[i].get(), GetOffset(), GetIsJoinByPipes()); + if (!anObj->_is_nil()) { + if (!IsPreview()) { anObj->SetParameters(GroupPoints->SpinBox_DX->text().toUtf8().constData()); } - objects.push_back( anObj._retn() ); + objects.push_back(anObj._retn()); + res = true; } } } - else { - for ( int i = 0; i < myObjects.count(); i++ ) { - anObj = anOper->OffsetShape( myObjects[i].get(), GetOffset(), GetIsJoinByPipes() ); - if ( !anObj->_is_nil() ) - objects.push_back( anObj._retn() ); + else if (getConstructorId() == 1) { + if (myObjects.count() == 1) { + TopoDS_Shape aShape; + if (GEOMBase::GetShape(myObjects[0].get(), aShape)) { + TopTools_IndexedMapOfShape aMainMap; + TopExp::MapShapes(aShape, aMainMap); + + QList aListIDs; + for (int i = 0; i < myFaces.count(); i++) { + TopoDS_Shape aFace; + if (GEOMBase::GetShape(myFaces[i].get(), aFace)) { + int anIndex = aMainMap.FindIndex(aFace); + if (anIndex >= 0) { + aListIDs << anIndex; + } + } + } + + GEOM::ListOfLong_var aFacesIDsList = new GEOM::ListOfLong(); + if (!aListIDs.empty()) { + aFacesIDsList->length(aListIDs.length()); + for (int i = 0; i < aListIDs.length(); i++) { + aFacesIDsList[i] = aListIDs[i]; + } + } + + anObj = anOper->OffsetShapePartialCopy + (myObjects[0].get(), aFacesIDsList, GetOffset()); + if (!anObj->_is_nil()) { + if (!IsPreview()) { + anObj->SetParameters(GroupPoints->SpinBox_DX->text().toUtf8().constData()); + } + objects.push_back(anObj._retn()); + res = true; + } + } } } - res = true; return res; } @@ -330,7 +457,6 @@ bool TransformationGUI_OffsetDlg::GetIsJoinByPipes() const void TransformationGUI_OffsetDlg::JoinModeChanged() { processPreview(); - //mainFrame()->GroupBoxName->setEnabled( GroupPoints->CheckButton1->isChecked() ); } //================================================================================= diff --git a/src/TransformationGUI/TransformationGUI_OffsetDlg.h b/src/TransformationGUI/TransformationGUI_OffsetDlg.h index b23938044..9407a3e78 100644 --- a/src/TransformationGUI/TransformationGUI_OffsetDlg.h +++ b/src/TransformationGUI/TransformationGUI_OffsetDlg.h @@ -30,14 +30,14 @@ #include "GEOMBase_Skeleton.h" #include "GEOM_GenericObjPtr.h" -class DlgRef_1Sel1Spin1Check; - +class DlgRef_2Sel1Spin2Check; + //================================================================================= // class : TransformationGUI_OffsetDlg // purpose : //================================================================================= class TransformationGUI_OffsetDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: @@ -52,24 +52,26 @@ protected: virtual bool execute( ObjectList& ); virtual void restoreSubShapes( SALOMEDS::SObject_ptr ); virtual QList getSourceObjects(); - + private: void Init(); void enterEvent( QEvent* ); double GetOffset() const; bool GetIsJoinByPipes() const; - + private: QList myObjects; - - DlgRef_1Sel1Spin1Check* GroupPoints; - + QList myFaces; + + DlgRef_2Sel1Spin2Check* GroupPoints; + private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); void SelectionIntoArgument(); void SetEditCurrentArgument(); + void ConstructorsClicked(int); void ValueChangedInSpinBox(); void JoinModeChanged(); };