From 8d072adad79dbd37e8010d597fc090ee68a4ab93 Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 18 Nov 2010 12:14:05 +0000 Subject: [PATCH] Mantis issues 0020939(GetSharedShapes) and 0020842(AllSorted meaning). --- .../gui/GEOM/input/creating_explode.doc | 20 +- .../gui/GEOM/input/transforming_geom_objs.doc | 2 + .../gui/GEOM/input/tui_advanced_geom_objs.doc | 4 +- .../gui/GEOM/input/tui_complex_objs.doc | 18 +- .../gui/GEOM/input/tui_measurement_tools.doc | 6 +- .../GEOM/input/tui_repairing_operations.doc | 10 +- doc/salome/gui/GEOM/input/tui_test_others.doc | 2 +- .../input/tui_transformation_operations.doc | 6 +- .../GEOM/input/tui_working_with_groups.doc | 8 +- idl/GEOM_Gen.idl | 39 +- resources/Makefile.am | 1 + resources/shared_shapes.png | Bin 0 -> 583 bytes src/EntityGUI/EntityGUI_SubShapeDlg.cxx | 5 +- src/GEOMGUI/GEOM_images.ts | 10 +- src/GEOMGUI/GEOM_msg_en.ts | 43 ++- src/GEOMGUI/GeometryGUI.cxx | 61 +-- src/GEOMGUI/GeometryGUI_Operations.h | 4 +- src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 159 +++++++- src/GEOMImpl/GEOMImpl_IShapesOperations.hxx | 60 +-- src/GEOM_I/GEOM_IShapesOperations_i.cc | 95 ++++- src/GEOM_I/GEOM_IShapesOperations_i.hh | 149 +++---- src/GEOM_SWIG/GEOM_Spanner.py | 4 +- src/GEOM_SWIG/GEOM_TestAll.py | 14 +- src/GEOM_SWIG/GEOM_TestHealing.py | 25 +- src/GEOM_SWIG/GEOM_TestMeasures.py | 2 +- src/GEOM_SWIG/GEOM_TestOthers.py | 24 +- src/GEOM_SWIG/geompyDC.py | 90 +++-- src/OperationGUI/Makefile.am | 6 +- src/OperationGUI/OperationGUI.cxx | 33 +- .../OperationGUI_GetSharedShapesDlg.cxx | 363 ++++++++++++++++++ .../OperationGUI_GetSharedShapesDlg.h | 73 ++++ .../OperationGUI_PartitionDlg.cxx | 298 +++++++------- src/OperationGUI/OperationGUI_PartitionDlg.h | 11 +- 33 files changed, 1223 insertions(+), 422 deletions(-) create mode 100644 resources/shared_shapes.png create mode 100644 src/OperationGUI/OperationGUI_GetSharedShapesDlg.cxx create mode 100644 src/OperationGUI/OperationGUI_GetSharedShapesDlg.h diff --git a/doc/salome/gui/GEOM/input/creating_explode.doc b/doc/salome/gui/GEOM/input/creating_explode.doc index 747aba637..3c93bcacb 100644 --- a/doc/salome/gui/GEOM/input/creating_explode.doc +++ b/doc/salome/gui/GEOM/input/creating_explode.doc @@ -20,20 +20,20 @@ subshapes of a given Type and returns a List of sub-shapes.
  • geompy.SubShapeAllIDs(Shape, Type) explodes a Shape on subshapes of a given Type and returns a List of IDs of sub-shapes.
  • -
  • geompy.SubShapeAllSorted(Shape, Type) xplodes a shape on -subshapes of a given type and sorts them by coordinates of their -gravity centers, returning a list of sub-shapes.
  • -
  • geompy.SubShapeAllSortedIDs(Shape, Type) explodes a shape -on subshapes of a given type and sorts them by coordinates of their -gravity centers, returning a List of IDs of sub-shapes.
  • +
  • geompy.SubShapeAllSortedCentres(Shape, Type) explodes a +shape on subshapes of a given type and sorts them by coordinates of +their gravity centers, returning a list of sub-shapes.
  • +
  • geompy.SubShapeAllSortedCentresIDs(Shape, Type) explodes +a shape on subshapes of a given type and sorts them by coordinates of +their gravity centers, returning a List of IDs of sub-shapes.
  • geompy.SubShape(Shape, Type, ListOfInd) allows to obtain a compound of sub-shapes of the Shape, selected by they indices in a list of all sub-shapes of the given Type. Each index is in the range [1, Nb_Sub-Shapes_Of_Given_Type].
  • -
  • geompy.SubShapeSorted(Shape, Type, ListOfInd) allows to -obtain a compound of sub-shapes of the Shape, selected by they indices -in sorted list of all sub-shapes of the given Type. Each index is in -the range [1, Nb_Sub-Shapes_Of_Given_Type]
  • +
  • geompy.SubShapeSortedCentres(Shape, Type, ListOfInd) +allows to obtain a compound of sub-shapes of the Shape, selected by +they indices in sorted list of all sub-shapes of the given Type. Each +index is in the range [1, Nb_Sub-Shapes_Of_Given_Type]
  • \n Arguments: 1 SHAPE + 1 type of SubShape. diff --git a/doc/salome/gui/GEOM/input/transforming_geom_objs.doc b/doc/salome/gui/GEOM/input/transforming_geom_objs.doc index cee84090a..c5643da2f 100644 --- a/doc/salome/gui/GEOM/input/transforming_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/transforming_geom_objs.doc @@ -18,6 +18,8 @@ plane corresponding to the modelled waterline of the object plunged into water.
  • \subpage shapesonshape_page "Get shapes on shape" operation, a special case of \b Explode operation.
  • +
  • \subpage shared_shapes_page "Get shared shapes" operation, a +special case of \b Explode operation.
  • Operations with \subpage blocks_operations_page "Blocks".
  • diff --git a/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc index f9f402a7e..1a76d9be8 100644 --- a/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc @@ -132,7 +132,7 @@ face = geompy.MakeFaces([sketcher1, sketcher2],isPlanarFace) prism = geompy.MakePrism(face, p0, pxyz) # explode the prism into faces -prism_faces = geompy.SubShapeAllSorted(prism, geompy.ShapeType["FACE"]) +prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"]) # create a shell from a set of faces shell = geompy.MakeShell([prism_faces[0], prism_faces[2], prism_faces[3], @@ -168,7 +168,7 @@ face = geompy.MakeFace(sketcher,1) prism = geompy.MakePrism(face, p0, pz) # explode the prism into faces -prism_faces = geompy.SubShapeAllSorted(prism, geompy.ShapeType["FACE"]) +prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"]) # create a shell from a set of faces shell = geompy.MakeShell([prism_faces[0], prism_faces[1], diff --git a/doc/salome/gui/GEOM/input/tui_complex_objs.doc b/doc/salome/gui/GEOM/input/tui_complex_objs.doc index 99024d243..7dcf151c1 100644 --- a/doc/salome/gui/GEOM/input/tui_complex_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_complex_objs.doc @@ -271,7 +271,7 @@ faces.append(f3) faces.append(f4) shell = geompy.MakeSewing(faces,1.e-6) shells.append(shell) -faces = geompy.SubShapeAllSorted(shell, geompy.ShapeType["FACE"]) +faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) subbases.append(faces[0]) # 2 section @@ -311,7 +311,7 @@ faces.append(f3) faces.append(f4) shell = geompy.MakeSewing(faces,1.e-6) shells.append(shell) -faces = geompy.SubShapeAllSorted(shell, geompy.ShapeType["FACE"]) +faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) subbases.append(faces[0]) # 3 section @@ -356,7 +356,7 @@ faces.append(f3) faces.append(f4) shell = geompy.MakeSewing(faces,1.e-6) shells.append(shell) -faces = geompy.SubShapeAllSorted(shell, geompy.ShapeType["FACE"]) +faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) subbases.append(faces[2]) # 4 section @@ -391,7 +391,7 @@ vp = geompy.MakeVertex(c3[0]-20,c3[1],c3[2]) ff = geompy.MakePlane(vp,vec,40) fs.append(ff) aPartition = geompy.MakePartition(shellsph,fs) -fs = geompy.SubShapeAllSorted(aPartition, geompy.ShapeType["FACE"]) +fs = geompy.SubShapeAllSortedCentres(aPartition, geompy.ShapeType["FACE"]) faces.append(fs[0]) faces.append(fs[1]) @@ -399,7 +399,7 @@ faces.append(fs[2]) faces.append(fs[3]) shell = geompy.MakeSewing(faces,1.e-6) shells.append(shell) -faces = geompy.SubShapeAllSorted(shell, geompy.ShapeType["FACE"]) +faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) #=========================================================== @@ -501,25 +501,25 @@ locs = [] # 1 section shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16) shells.append(shell) -vs1 = geompy.SubShapeAllSorted(shell,geompy.ShapeType["VERTEX"]) +vs1 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) locs.append(vs1[17]) # 2 section shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16) shells.append(shell) -vs2 = geompy.SubShapeAllSorted(shell,geompy.ShapeType["VERTEX"]) +vs2 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) locs.append(vs2[17]) # 3 section shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16) shells.append(shell) -vs3 = geompy.SubShapeAllSorted(shell,geompy.ShapeType["VERTEX"]) +vs3 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) locs.append(vs3[17]) # 4 section shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16) shells.append(shell) -vs4 = geompy.SubShapeAllSorted(shell,geompy.ShapeType["VERTEX"]) +vs4 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) locs.append(vs4[17]) diff --git a/doc/salome/gui/GEOM/input/tui_measurement_tools.doc b/doc/salome/gui/GEOM/input/tui_measurement_tools.doc index 7091e0d4b..0112bd0da 100644 --- a/doc/salome/gui/GEOM/input/tui_measurement_tools.doc +++ b/doc/salome/gui/GEOM/input/tui_measurement_tools.doc @@ -136,7 +136,7 @@ compound = geompy.MakeCompound([box1, box2]) ImportFromBREP = geompy.ImportBREP(os.getenv("DATA_DIR")+"/Shapes/Brep/flight_solid.brep") # get a face -faces = geompy.SubShapeAllSorted(ImportFromBREP, geompy.ShapeType["FACE"]) +faces = geompy.SubShapeAllSortedCentres(ImportFromBREP, geompy.ShapeType["FACE"]) # get the free boundary for face 32 Res = geompy.GetFreeBoundary(faces[32]) @@ -223,7 +223,7 @@ cut = geompy.MakeCut(cone, cylinder) # get faces as sub-shapes faces = [] -faces = geompy.SubShapeAllSorted(cut, geompy.ShapeType["FACE"]) +faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"]) f_2 = geompy.GetSubShapeID(cut, faces[0]) # remove one face from the shape @@ -234,7 +234,7 @@ result = geompy.GetFreeFacesIDs(cut_without_f_2) print "A number of free faces is ", len(result) # add objects in the study -all_faces = geompy.SubShapeAllSorted(cut_without_f_2, geompy.ShapeType["FACE"]) +all_faces = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["FACE"]) for face in all_faces : sub_shape_id = geompy.GetSubShapeID(cut_without_f_2, face) if result.count(sub_shape_id) > 0 : diff --git a/doc/salome/gui/GEOM/input/tui_repairing_operations.doc b/doc/salome/gui/GEOM/input/tui_repairing_operations.doc index 98dccc6f0..d55300562 100644 --- a/doc/salome/gui/GEOM/input/tui_repairing_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_repairing_operations.doc @@ -65,7 +65,7 @@ box = geompy.MakeBoxDXDYDZ(200, 200, 200) # The list of IDs (IDList) for suppress faces sup_faces = [] -sup_faces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"]) +sup_faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"]) # get indices of the sub-shape f1_id = geompy.GetSubShapeID(box, sup_faces[3]) @@ -182,7 +182,7 @@ cut = geompy.MakeCut(cone, cylinder) # get faces as sub-shapes faces = [] -faces = geompy.SubShapeAllSorted(cut, geompy.ShapeType["FACE"]) +faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"]) f_2 = geompy.GetSubShapeID(cut, faces[2]) # remove one face from the shape @@ -190,7 +190,7 @@ cut_without_f_2 = geompy.SuppressFaces(cut, [f_2]) # get wires as sub-shapes wires = [] -wires = geompy.SubShapeAllSorted(cut_without_f_2, geompy.ShapeType["WIRE"]) +wires = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["WIRE"]) w_0 = geompy.GetSubShapeID(cut_without_f_2, wires[0]) # suppress the selected wire @@ -308,12 +308,12 @@ divide = geompy.DivideEdge(edge, -1, 0.5, 0) # add objects in the study id_edge = geompy.addToStudy(edge, "Edge") -edge_points = geompy.SubShapeAllSorted(edge, geompy.ShapeType["VERTEX"]) +edge_points = geompy.SubShapeAllSortedCentres(edge, geompy.ShapeType["VERTEX"]) for point in edge_points: geompy.addToStudyInFather(edge, point, "Edge's point") id_divide = geompy.addToStudy(divide, "Divided edge") -edge_points = geompy.SubShapeAllSorted(divide, geompy.ShapeType["VERTEX"]) +edge_points = geompy.SubShapeAllSortedCentres(divide, geompy.ShapeType["VERTEX"]) for point in edge_points: geompy.addToStudyInFather(divide, point, "Edge's point after divide") diff --git a/doc/salome/gui/GEOM/input/tui_test_others.doc b/doc/salome/gui/GEOM/input/tui_test_others.doc index 443326fea..84779c467 100644 --- a/doc/salome/gui/GEOM/input/tui_test_others.doc +++ b/doc/salome/gui/GEOM/input/tui_test_others.doc @@ -88,7 +88,7 @@ \until "freeFacesWithoutExtra" \anchor swig_GetSharedShapes -\until "sharedFace" +\until "sharedEdge_" \anchor swig_CheckAndImprove \until "blocksComp" diff --git a/doc/salome/gui/GEOM/input/tui_transformation_operations.doc b/doc/salome/gui/GEOM/input/tui_transformation_operations.doc index 247568840..883dcb441 100644 --- a/doc/salome/gui/GEOM/input/tui_transformation_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_transformation_operations.doc @@ -381,7 +381,7 @@ gg = salome.ImportComponentGUI("GEOM") # create box Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) # take box edges to create custom complex wire -[Edge_1,Edge_2,Edge_3,Edge_4,Edge_5,Edge_6,Edge_7,Edge_8,Edge_9,Edge_10,Edge_11,Edge_12] = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["EDGE"]) +[Edge_1,Edge_2,Edge_3,Edge_4,Edge_5,Edge_6,Edge_7,Edge_8,Edge_9,Edge_10,Edge_11,Edge_12] = geompy.SubShapeAllSortedCentres(Box_1, geompy.ShapeType["EDGE"]) # create wire Wire_1 = geompy.MakeWire([Edge_12, Edge_7, Edge_11, Edge_6, Edge_1,Edge_4]) # make fillet at given wire vertices with giver radius @@ -424,7 +424,7 @@ face = geompy.MakeFace(wire, 1) prism = geompy.MakePrismVecH(face, vz, 100.0) # get the list of IDs (IDList) for the fillet -prism_edges = geompy.SubShapeAllSorted(prism, ShapeTypeEdge) +prism_edges = geompy.SubShapeAllSortedCentres(prism, ShapeTypeEdge) IDlist_e = [] IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[0])) IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[1])) @@ -482,7 +482,7 @@ face = geompy.MakeFace(wire, 1) prism = geompy.MakePrismVecH(face, vz, 100.0) # get the list of IDs (IDList) for the chamfer -prism_faces = geompy.SubShapeAllSorted(prism, ShapeTypeFace) +prism_faces = geompy.SubShapeAllSortedCentres(prism, ShapeTypeFace) f_ind_1 = geompy.GetSubShapeID(prism, prism_faces[0]) f_ind_2 = geompy.GetSubShapeID(prism, prism_faces[1]) IDlist_f = [f_ind_1, f_ind_2] diff --git a/doc/salome/gui/GEOM/input/tui_working_with_groups.doc b/doc/salome/gui/GEOM/input/tui_working_with_groups.doc index 786e81816..e608a0923 100644 --- a/doc/salome/gui/GEOM/input/tui_working_with_groups.doc +++ b/doc/salome/gui/GEOM/input/tui_working_with_groups.doc @@ -20,7 +20,7 @@ Box = geompy.MakeBoxTwoPnt(p0, p200) group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) # add objects to the group -SubFaceList = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) +SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) for i in [0, 3, 5] : FaceID = geompy.GetSubShapeID(Box, SubFaceList[i]) geompy.AddObject(group, FaceID) @@ -60,7 +60,7 @@ Box = geompy.MakeBoxTwoPnt(p0, p200) group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) # add objects to the group -SubFaceList = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) +SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) for i in [0, 3, 5] : FaceID = geompy.GetSubShapeID(Box, SubFaceList[i]) geompy.AddObject(group, FaceID) @@ -89,7 +89,7 @@ Box = geompy.MakeBoxTwoPnt(p0, p200) group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) # add objects to the group -SubFaceList = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) +SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) for i in [0, 3, 5] : FaceID = geompy.GetSubShapeID(Box, SubFaceList[i]) geompy.AddObject(group, FaceID) @@ -107,4 +107,4 @@ gg.createAndDisplayGO(id_group1) salome.sg.updateObjBrowser(1) \endcode -*/ \ No newline at end of file +*/ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 61aa8caeb..304b16a86 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1390,6 +1390,13 @@ module GEOM GEOM_Object MakeGlueFacesByList (in GEOM_Object theShape, in double theTolerance, in ListOfGO theFaces, in boolean doKeepNonSolids); + /*! + * Deprecated method. Use MakeAllSubShapes() instead. + */ + ListOfGO MakeExplode (in GEOM_Object theShape, + in long theShapeType, + in boolean isSorted); + /*! * Explode a shape on subshapes of a given type. * \param theShape Shape to be exploded. @@ -1398,23 +1405,30 @@ module GEOM * sorted by coordinates of their gravity centers. * \return List of sub-shapes of type theShapeType, contained in theShape. */ - ListOfGO MakeExplode (in GEOM_Object theShape, - in long theShapeType, - in boolean isSorted); + ListOfGO MakeAllSubShapes (in GEOM_Object theShape, + in long theShapeType, + in boolean isSorted); + + /*! + * Deprecated method. Use GetAllSubShapesIDs() instead. + */ + ListOfLong SubShapeAllIDs (in GEOM_Object theShape, + in long theShapeType, + in boolean isSorted); /*! * Explode a shape on subshapes of a given type. - * Does the same, as the above method, but returns IDs of sub-shapes, - * not GEOM_Objects. It works faster. + * Does the same, as MakeAllSubShapes, but returns IDs of + * sub-shapes, not GEOM_Objects. It works faster. * \param theShape Shape to be exploded. * \param theShapeType Type of sub-shapes to be retrieved. * \param isSorted If this parameter is TRUE, sub-shapes will be * sorted by coordinates of their gravity centers. * \return List of IDs of sub-shapes of type theShapeType, contained in theShape. */ - ListOfLong SubShapeAllIDs (in GEOM_Object theShape, - in long theShapeType, - in boolean isSorted); + ListOfLong GetAllSubShapesIDs (in GEOM_Object theShape, + in long theShapeType, + in boolean isSorted); /*! * Get a sub shape defined by its unique ID inside \a theMainShape @@ -1502,6 +1516,15 @@ module GEOM in GEOM_Object theShape2, in long theShapeType); + /*! + * Get all sub-shapes, shared by all shapes in the list \a theShapes. + * \param theShapes Shapes to find common sub-shapes of. + * \param theShapeType Type of sub-shapes to be retrieved. + * \return List of objects, that are sub-shapes of all given shapes. + */ + ListOfGO GetSharedShapesMulti (in ListOfGO theShapes, + in long theShapeType); + /*! * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively * the specified plane by the certain way, defined through \a theState parameter. diff --git a/resources/Makefile.am b/resources/Makefile.am index 5212a40b9..94b2eb825 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -140,6 +140,7 @@ select1.png \ sewing.png \ shading.png \ shapesonshape.png \ +shared_shapes.png \ sketch.png \ sphere.png \ spheredxyz.png \ diff --git a/resources/shared_shapes.png b/resources/shared_shapes.png new file mode 100644 index 0000000000000000000000000000000000000000..23f804802251319855cadf3afb9bdabb5182e900 GIT binary patch literal 583 zcmV-N0=WH&P)bgGWIS@MM7DVsg zT;{Y$DPd*+G)+U(G}Lv?dcEE@O|yle1kO1`q-skICn*>%Fqoz*B@Fc)W9X*W+AKNZWNCW(f&_Xpg5lBUL3vMMO}M17Qe(?qQFJ zKuXk2^K8;nXaPRFT`wFbH-CcQJrV+{Qf4+2UIQP;JLBg2&%e}7LseCzlt^Y+8tSX6 z?C<~Ky(4%}kT4_M1HX<0+-Ovi3dwBv&QxcF!FxmkDuSxa2zS6&=8L|S5QwUXN=YrR zV2p8SV$?E1Q^E(}_o7C5EXK4%LV0LrsK}r=C93N1S)8l= @@ -560,7 +559,7 @@ bool EntityGUI_SubShapeDlg::isValid (QString& msg) bool EntityGUI_SubShapeDlg::execute (ObjectList& objects) { GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation()); - GEOM::ListOfGO_var aList = anOper->MakeExplode(myObject, shapeType(), true); + GEOM::ListOfGO_var aList = anOper->MakeAllSubShapes(myObject, shapeType(), true); if (!aList->length()) return false; diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 96696220c..61a9e5362 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -1062,9 +1062,13 @@ planeWorking.png - ICO_GET_SHAPES_ON_SHAPES + ICO_GET_SHAPES_ON_SHAPE shapesonshape.png + + ICO_GET_SHARED_SHAPES + shared_shapes.png + ICON_DLG_POINT_FACE pointonface.png @@ -1073,6 +1077,10 @@ ICON_DLG_SHAPES_ON_SHAPE shapesonshape.png + + ICON_DLG_SHARED_SHAPES + shared_shapes.png + ICON_DLG_SCALE_ALONG_AXES scale_along_axes.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index ade11bc38..21d98dd46 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -1737,7 +1737,7 @@ Please, select face, shell or solid and try again GEOM_SUBSHAPE_TYPE - Sub Shapes Type : + Sub Shapes Type GEOM_SUB_SHAPE @@ -3992,17 +3992,29 @@ Please, select face, shell or solid and try again INOUT - TOP_GET_SHAPES_ON_SHAPES + TOP_GET_SHAPES_ON_SHAPE Get shapes on shape - MEN_GET_SHAPES_ON_SHAPES + MEN_GET_SHAPES_ON_SHAPE Get Shapes on Shape - STB_GET_SHAPES_ON_SHAPES + STB_GET_SHAPES_ON_SHAPE Get shapes on shape + + TOP_GET_SHARED_SHAPES + Get shared shapes + + + MEN_GET_SHARED_SHAPES + Get Shared Shapes + + + STB_GET_SHARED_SHAPES + Get shared shapes + GEOM_PUBLISH_RESULT_GRP Advanced options @@ -4513,6 +4525,29 @@ Would you like to continue? Load Texture + + OperationGUI_GetSharedShapesDlg + + GEOM_SHARED_SHAPES_TITLE + Get Shared Shapes + + + GEOM_GET_SHARED_SHAPES + Shared shapes + + + GEOM_SHARED_SHAPES_INPUT + Input data + + + MSG_SHARED_SHAPES_TOO_FEW_SHAPES + To few shapes selected. + + + GEOM_SHARED_SHAPE + Shared_%1 + + AdvancedGUI_PipeTShapeDlg diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 6f9d09bde..29b739209 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -19,11 +19,10 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - // GEOM GEOMGUI : GUI for Geometry component // File : GeometryGUI.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// + #include // E.A. must be included before Python.h to fix compilation on windows #include "Python.h" #include "GeometryGUI.h" @@ -342,12 +341,12 @@ void GeometryGUI::OnGUIEvent( int id ) // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example) QList NotViewerDependentCommands; NotViewerDependentCommands << GEOMOp::OpRename - << GEOMOp::OpDelete - << GEOMOp::OpShow - << GEOMOp::OpShowOnly - << GEOMOp::OpShowChildren - << GEOMOp::OpHideChildren - << GEOMOp::OpPointMarker; + << GEOMOp::OpDelete + << GEOMOp::OpShow + << GEOMOp::OpShowOnly + << GEOMOp::OpShowChildren + << GEOMOp::OpHideChildren + << GEOMOp::OpPointMarker; if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) ) return; @@ -460,6 +459,7 @@ void GeometryGUI::OnGUIEvent( int id ) case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D + case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES libName = "OperationGUI"; break; case GEOMOp::OpSewing: // MENU REPAIR - SEWING @@ -575,14 +575,14 @@ void GeometryGUI::createGeomAction( const int id, const QString& label, const QS QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false ) : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) ); createAction( id, - tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ), - icon, - tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ), - tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ), - accel, - application()->desktop(), - toggle, - this, SLOT( OnGUIEvent() ) ); + tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ), + icon, + tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ), + tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ), + accel, + application()->desktop(), + toggle, + this, SLOT( OnGUIEvent() ) ); } @@ -663,7 +663,8 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpFillet3d, "FILLET" ); createGeomAction( GEOMOp::OpChamfer, "CHAMFER" ); //createGeomAction( GEOMOp::OpClipping, "CLIPPING" ); - createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPES" ); + createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" ); + createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" ); createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" ); createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" ); @@ -732,7 +733,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" ); createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" ); createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" ); - + createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" ); // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// @@ -840,6 +841,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpPartition, operId, -1 ); createMenu( GEOMOp::OpArchimede, operId, -1 ); createMenu( GEOMOp::OpShapesOnShape, operId, -1 ); + createMenu( GEOMOp::OpSharedShapes, operId, -1 ); createMenu( separator(), operId, -1 ); @@ -970,6 +972,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpPartition, operTbId ); createTool( GEOMOp::OpArchimede, operTbId ); createTool( GEOMOp::OpShapesOnShape, operTbId ); + createTool( GEOMOp::OpSharedShapes, operTbId ); createTool( separator(), operTbId ); createTool( GEOMOp::OpFillet1d, operTbId ); createTool( GEOMOp::OpFillet2d, operTbId ); @@ -1174,7 +1177,7 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) SALOME_ListIO selected; sm->selectedObjects( selected ); sm->clearSelected(); - + // disable OCC selectors getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() ); QListIterator itOCCSel( myOCCSelectors ); @@ -1423,7 +1426,7 @@ void GeometryGUI::createPreferences() setPreferenceProperty( genGroup, "columns", 2 ); int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup, - LightApp_Preferences::Selector, + LightApp_Preferences::Selector, "Geometry", "display_mode" ); addPreference( tr( "PREF_SHADING_COLOR" ), genGroup, @@ -1449,36 +1452,36 @@ void GeometryGUI::createPreferences() int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup, LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" ); - + // Quantities with individual precision settings int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId ); setPreferenceProperty( precGroup, "columns", 2 ); - + const int nbQuantities = 8; int prec[nbQuantities], ii = 0; prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup, - LightApp_Preferences::IntSpin, "Geometry", "length_precision" ); + LightApp_Preferences::IntSpin, "Geometry", "length_precision" ); prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup, LightApp_Preferences::IntSpin, "Geometry", "angle_precision" ); prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup, LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" ); prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup, - LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" ); + LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" ); prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup, - LightApp_Preferences::IntSpin, "Geometry", "weight_precision" ); + LightApp_Preferences::IntSpin, "Geometry", "weight_precision" ); prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup, - LightApp_Preferences::IntSpin, "Geometry", "density_precision" ); + LightApp_Preferences::IntSpin, "Geometry", "density_precision" ); prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup, LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" ); prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup, - LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" ); - + LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" ); + // Set property for precision value for spinboxes for ( ii = 0; ii < nbQuantities; ii++ ){ setPreferenceProperty( prec[ii], "min", -14 ); setPreferenceProperty( prec[ii], "max", 14 ); setPreferenceProperty( prec[ii], "precision", 2 ); - } + } int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId ); setPreferenceProperty( VertexGroup, "columns", 2 ); diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index 5b0be0dfa..9c10e1f40 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -16,10 +16,9 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - // File : GeometryGUI_Operations.h // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// + #ifndef GEOMETRYGUI_OPERATIONS_H #define GEOMETRYGUI_OPERATIONS_H @@ -117,6 +116,7 @@ namespace GEOMOp { OpFillet2d = 3705, // MENU OPERATION - FILLET 2D OpFillet1d = 3706, // MENU OPERATION - FILLET 1D OpClipping = 3707, // MENU OPERATION - CLIPPING RANGE + OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES // RepairGUI -----------------//-------------------------------- OpSewing = 4000, // MENU REPAIR - SEWING OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 09677608a..2c5abaecb 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -19,13 +19,12 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - // File : GEOMImpl_IShapesOperations.cxx // Created : // Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007 // Project : SALOME // $Header$ -// + #include #include "GEOMImpl_IShapesOperations.hxx" @@ -811,7 +810,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode (Handle(GEOM_Object) theShape, const Standard_Integer theShapeType, - const Standard_Boolean isSorted) + const Standard_Boolean isSorted, + const Standard_Boolean isOldSorting) { SetErrorCode(KO); @@ -853,7 +853,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode } if (isSorted) - SortShapes(listShape); + SortShapes(listShape, isOldSorting); TopTools_IndexedMapOfShape anIndices; TopExp::MapShapes(aShape, anIndices); @@ -899,7 +899,10 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode GEOM::TPythonDump pd (aMainShape, /*append=*/true); pd << "[" << anAsciiList.ToCString(); - pd << "] = geompy.SubShapeAll" << (isSorted ? "Sorted(" : "("); + if (isSorted) + pd << "] = geompy.SubShapeAllSorted" << (isOldSorting ? "(" : "Centres("); + else + pd << "] = geompy.SubShapeAll("; pd << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")"; SetErrorCode(OK); @@ -915,7 +918,8 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs (Handle(GEOM_Object) theShape, const Standard_Integer theShapeType, - const Standard_Boolean isSorted) + const Standard_Boolean isSorted, + const Standard_Boolean isOldSorting) { SetErrorCode(KO); @@ -954,7 +958,7 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs } if (isSorted) - SortShapes(listShape); + SortShapes(listShape, isOldSorting); TopTools_IndexedMapOfShape anIndices; TopExp::MapShapes(aShape, anIndices); @@ -971,7 +975,10 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs //Make a Python command GEOM::TPythonDump pd (aFunction, /*append=*/true); pd << "listSubShapeIDs = geompy.SubShapeAll"; - pd << (isSorted ? "SortedIDs(" : "IDs("); + if (isSorted) + pd << "Sorted" << (isOldSorting ? "IDs(" : "CentresIDs("); + else + pd << "IDs("; pd << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")"; SetErrorCode(OK); @@ -1413,6 +1420,112 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes return aSeq; } +//======================================================================= +//function : GetSharedShapes +//purpose : +//======================================================================= +Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes + (std::list theShapes, + const Standard_Integer theShapeType) +{ + SetErrorCode(KO); + + int aLen = theShapes.size(); + if (aLen < 1) return NULL; + + int ind = 1; + std::list::iterator it = theShapes.begin(); + + Handle(GEOM_Object) aMainObj = (*it++); + Handle(GEOM_Function) aMainShape = aMainObj->GetLastFunction(); + if (aMainShape.IsNull()) { + SetErrorCode("NULL shape for GetSharedShapes"); + return NULL; + } + + TopoDS_Shape aShape1 = aMainShape->GetValue(); + if (aShape1.IsNull()) return NULL; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape1, anIndices); + + TopTools_IndexedMapOfShape mapSelected; + TopExp::MapShapes(aShape1, TopAbs_ShapeEnum(theShapeType), mapSelected); + + // Find shared shapes + BRep_Builder B; + TopoDS_Compound aCurrSelection; + + for (; it != theShapes.end(); it++, ind++) { + Handle(GEOM_Function) aRefShape = (*it)->GetLastFunction(); + if (aRefShape.IsNull()) { + SetErrorCode("NULL shape for GetSharedShapes"); + return NULL; + } + + TopoDS_Compound aCompound; + B.MakeCompound(aCompound); + + TopoDS_Shape aShape2 = aRefShape->GetValue(); + if (aShape2.IsNull()) return NULL; + + TopTools_MapOfShape mapShape2; + TopExp_Explorer exp (aShape2, TopAbs_ShapeEnum(theShapeType)); + for (; exp.More(); exp.Next()) { + TopoDS_Shape aSS = exp.Current(); + if (mapShape2.Add(aSS) && mapSelected.Contains(aSS)) { + B.Add(aCompound, aSS); + } + } + + mapSelected.Clear(); + TopExp::MapShapes(aCompound, TopAbs_ShapeEnum(theShapeType), mapSelected); + aCurrSelection = aCompound; + } + + // Create GEOM_Object for each found shared shape (collected in aCurrSelection) + Handle(GEOM_Object) anObj; + Handle(TColStd_HArray1OfInteger) anArray; + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + TCollection_AsciiString anAsciiList, anEntry; + + TopoDS_Iterator itSel (aCurrSelection, Standard_True, Standard_True); + for (; itSel.More(); itSel.Next()) { + anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(itSel.Value())); + anObj = GetEngine()->AddSubShape(aMainObj, anArray); + aSeq->Append(anObj); + + // for python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + anAsciiList += anEntry; + anAsciiList += ","; + } + + if (aSeq->IsEmpty()) { + SetErrorCode("The given shapes have no shared sub-shapes of the requested type"); + return aSeq; + } + + // Make a Python command + anAsciiList.Trunc(anAsciiList.Length() - 1); + + GEOM::TPythonDump pd (aMainShape, /*append=*/true); + pd << "[" << anAsciiList.ToCString() + << "] = geompy.GetSharedShapesMulti(["; + + it = theShapes.begin(); + pd << (*it++); + while (it != theShapes.end()) { + pd << ", " << (*it++); + } + + pd << "], " << TopAbs_ShapeEnum(theShapeType) << ")"; + + SetErrorCode(OK); + return aSeq; +} + //============================================================================= /*! * @@ -2576,7 +2689,7 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetShapesOnCylind aSeq = getShapesOnSurfaceIDs( aCylinder, aShape, aShapeType, theState ); // The GetShapesOnCylinder() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = + Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast(theShape, GEOM::GetCreatedLast(thePnt,theAxis))->GetLastFunction(); // Make a Python command @@ -3373,7 +3486,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory //function : SortShapes //purpose : //======================================================================= -void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL) +void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL, + const Standard_Boolean isOldSorting) { Standard_Integer MaxShapes = SL.Extent(); TopTools_Array1OfShape aShapes (1,MaxShapes); @@ -3392,16 +3506,29 @@ void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL) SL.Remove( it ); // == it.Next() aShapes(Index) = S; OrderInd.SetValue (Index, Index); - if (S.ShapeType() == TopAbs_VERTEX) - { + if (S.ShapeType() == TopAbs_VERTEX) { GPoint = BRep_Tool::Pnt( TopoDS::Vertex( S )); Length.SetValue( Index, (Standard_Real) S.Orientation()); } - else - { - BRepGProp::LinearProperties (S, GPr); + else { + // BEGIN: fix for Mantis issue 0020842 + if (isOldSorting) { + BRepGProp::LinearProperties (S, GPr); + } + else { + if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties (S, GPr); + } + else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(S, GPr); + } + else { + BRepGProp::VolumeProperties(S, GPr); + } + } + // END: fix for Mantis issue 0020842 GPoint = GPr.CentreOfMass(); - Length.SetValue( Index, GPr.Mass() ); + Length.SetValue(Index, GPr.Mass()); } MidXYZ.SetValue(Index, GPoint.X()*999 + GPoint.Y()*99 + GPoint.Z()*0.9); diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index ee9a83b02..1bb384486 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -18,16 +18,15 @@ // 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 : GEOMImpl_IShapesOperations.hxx -// Created : +// Created : // Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007 // Project : SALOME // $Header$ //============================================================================= -// + #ifndef _GEOMImpl_IShapesOperations_HXX_ #define _GEOMImpl_IShapesOperations_HXX_ @@ -55,7 +54,7 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations Standard_EXPORT ~GEOMImpl_IShapesOperations(); Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1, - Handle(GEOM_Object) thePoint2); + Handle(GEOM_Object) thePoint2); Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list theEdgesAndWires, const Standard_Real theTolerance); @@ -63,7 +62,7 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted); Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list theWires, - const bool isPlanarWanted); + const bool isPlanarWanted); Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list theShapes); @@ -85,13 +84,17 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations std::list theFaces, const Standard_Boolean doKeepNonSolids); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object) theShape, - const Standard_Integer theShapeType, - const Standard_Boolean isSorted); + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode + (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + const Standard_Boolean isSorted, + const Standard_Boolean isOldSorting = Standard_False); - Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object) theShape, - const Standard_Integer theShapeType, - const Standard_Boolean isSorted); + Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs + (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + const Standard_Boolean isSorted, + const Standard_Boolean isOldSorting = Standard_False); Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape, const Standard_Integer theID); @@ -111,14 +114,20 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object) theShape1, - Handle(GEOM_Object) theShape2, - const Standard_Integer theShapeType); + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + GetSharedShapes (Handle(GEOM_Object) theShape1, + Handle(GEOM_Object) theShape2, + const Standard_Integer theShapeType); + + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + GetSharedShapes (std::list theShapes, + const Standard_Integer theShapeType); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape, - const Standard_Integer theShapeType, - const Handle(GEOM_Object)& theAx1, - const GEOMAlgo_State theState); + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + GetShapesOnPlane (const Handle(GEOM_Object)& theShape, + const Standard_Integer theShapeType, + const Handle(GEOM_Object)& theAx1, + const GEOMAlgo_State theState); Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape, @@ -226,14 +235,14 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations const GEOMAlgo_State theState); Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape, - const Standard_Integer theShapeType, - Handle(GEOM_Object) theAxis, - const Standard_Real theRadius); + const Standard_Integer theShapeType, + Handle(GEOM_Object) theAxis, + const Standard_Real theRadius); Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape, - const Standard_Integer theShapeType, - Handle(GEOM_Object) theCenter, - const Standard_Real theRadius); + const Standard_Integer theShapeType, + Handle(GEOM_Object) theCenter, + const Standard_Real theRadius); void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt); @@ -318,7 +327,8 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations * \brief Sort shapes in the list by their coordinates. * \param SL The list of shapes to sort. */ - Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL); + Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL, + const Standard_Boolean isOldSorting = Standard_True); /*! * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND. diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc index 38238921e..5df05efd4 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.cc +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -411,7 +410,6 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList return GetObject(anObject); } - //============================================================================= /*! * MakeExplode @@ -427,7 +425,34 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr the if (aShape.IsNull()) return aSeq._retn(); Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakeExplode(aShape, theShapeType, isSorted); + GetOperations()->MakeExplode(aShape, theShapeType, isSorted, Standard_True); + 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(); +} + +//============================================================================= +/*! + * MakeAllSubShapes + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + const CORBA::Boolean isSorted) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + if (aShape.IsNull()) return aSeq._retn(); + + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakeExplode(aShape, theShapeType, isSorted, Standard_False); if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn(); @@ -454,7 +479,33 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_pt if (aShape.IsNull()) return aSeq._retn(); Handle(TColStd_HSequenceOfInteger) aHSeq = - GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted); + GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted, Standard_True); + 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(); +} + +//============================================================================= +/*! + * GetAllSubShapesIDs + */ +//============================================================================= +GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + const CORBA::Boolean isSorted) +{ + GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong; + + Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + if (aShape.IsNull()) return aSeq._retn(); + + Handle(TColStd_HSequenceOfInteger) aHSeq = + GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted, Standard_False); if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn(); Standard_Integer aLength = aHSeq->Length(); @@ -672,6 +723,42 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes return aSeq._retn(); } +//============================================================================= +/*! + * GetSharedShapesMulti + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti + (const GEOM::ListOfGO& theShapes, + const CORBA::Long theShapeType) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Get the shapes + std::list aShapes; + int aLen = theShapes.length(); + for (int ind = 0; ind < aLen; ind++) { + Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]); + if (aSh.IsNull()) return aSeq._retn(); + aShapes.push_back(aSh); + } + + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->GetSharedShapes(aShapes, theShapeType); + 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(); +} + static GEOMAlgo_State ShapeState (const GEOM::shape_state theState) { GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN; diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.hh b/src/GEOM_I/GEOM_IShapesOperations_i.hh index 5ae1ed2f0..da9da31cd 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.hh +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOM_IShapesOperations_i_HeaderFile #define _GEOM_IShapesOperations_i_HeaderFile @@ -39,21 +38,21 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : { public: GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA, - GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_IShapesOperations* theImpl); + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IShapesOperations* theImpl); ~GEOM_IShapesOperations_i(); GEOM::GEOM_Object_ptr MakeEdge (GEOM::GEOM_Object_ptr thePnt1, - GEOM::GEOM_Object_ptr thePnt2); + GEOM::GEOM_Object_ptr thePnt2); GEOM::GEOM_Object_ptr MakeWire (const GEOM::ListOfGO& theEdgesAndWires, const CORBA::Double theTolerance); GEOM::GEOM_Object_ptr MakeFace (GEOM::GEOM_Object_ptr theWire, - CORBA::Boolean isPlanarWanted); + CORBA::Boolean isPlanarWanted); GEOM::GEOM_Object_ptr MakeFaceWires (const GEOM::ListOfGO& theWires, - CORBA::Boolean isPlanarWanted); + CORBA::Boolean isPlanarWanted); GEOM::GEOM_Object_ptr MakeShell (const GEOM::ListOfGO& theFacesAndShells); @@ -64,34 +63,45 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : GEOM::GEOM_Object_ptr MakeCompound (const GEOM::ListOfGO& theShapes); GEOM::GEOM_Object_ptr MakeGlueFaces (GEOM::GEOM_Object_ptr theShape, - CORBA::Double theTolerance, + CORBA::Double theTolerance, CORBA::Boolean doKeepNonSolids); GEOM::ListOfGO* GetGlueFaces (GEOM::GEOM_Object_ptr theShape, - CORBA::Double theTolerance); + CORBA::Double theTolerance); GEOM::GEOM_Object_ptr MakeGlueFacesByList (GEOM::GEOM_Object_ptr theShape, - CORBA::Double theTolerance, - const GEOM::ListOfGO& theFaces, - CORBA::Boolean doKeepNonSolids); + CORBA::Double theTolerance, + const GEOM::ListOfGO& theFaces, + CORBA::Boolean doKeepNonSolids); + // For old SubShapeAll() + // Deprecated, use MakeAllSubShapes() instead GEOM::ListOfGO* MakeExplode (GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - CORBA::Boolean isSorted); + CORBA::Long theShapeType, + CORBA::Boolean isSorted); + + GEOM::ListOfGO* MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape, + CORBA::Long theShapeType, + CORBA::Boolean isSorted); + // Deprecated, use GetAllSubShapesIDs() instead GEOM::ListOfLong* SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - CORBA::Boolean isSorted); + CORBA::Long theShapeType, + CORBA::Boolean isSorted); + + GEOM::ListOfLong* GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape, + CORBA::Long theShapeType, + CORBA::Boolean isSorted); GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape, - CORBA::Long theID); + CORBA::Long theID); CORBA::Long GetSubShapeIndex (GEOM::GEOM_Object_ptr theMainShape, - GEOM::GEOM_Object_ptr theSubShape); + GEOM::GEOM_Object_ptr theSubShape); CORBA::Long GetTopologyIndex (GEOM::GEOM_Object_ptr theMainShape, - GEOM::GEOM_Object_ptr theSubShape); + GEOM::GEOM_Object_ptr theSubShape); char* GetShapeTypeString (GEOM::GEOM_Object_ptr theShape); @@ -105,25 +115,28 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : GEOM::ListOfLong* GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape); GEOM::ListOfGO* GetSharedShapes (GEOM::GEOM_Object_ptr theShape1, - GEOM::GEOM_Object_ptr theShape2, - CORBA::Long theShapeType); + GEOM::GEOM_Object_ptr theShape2, + CORBA::Long theShapeType); + + GEOM::ListOfGO* GetSharedShapesMulti (const GEOM::ListOfGO& theShapes, + CORBA::Long theShapeType); GEOM::ListOfGO* GetShapesOnPlane (GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::GEOM_Object_ptr theAx1, - GEOM::shape_state theState); + CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theAx1, + GEOM::shape_state theState); GEOM::ListOfGO* GetShapesOnPlaneWithLocation(GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::GEOM_Object_ptr theAx1, - GEOM::GEOM_Object_ptr thePnt, - GEOM::shape_state theState); + CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theAx1, + GEOM::GEOM_Object_ptr thePnt, + GEOM::shape_state theState); GEOM::ListOfGO* GetShapesOnCylinder (GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::GEOM_Object_ptr theAxis, - CORBA::Double theRadius, - GEOM::shape_state theState); + CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theRadius, + GEOM::shape_state theState); GEOM::ListOfGO* GetShapesOnCylinderWithLocation (GEOM::GEOM_Object_ptr theShape, CORBA::Long theShapeType, @@ -133,10 +146,10 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : GEOM::shape_state theState); GEOM::ListOfGO* GetShapesOnSphere (GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::GEOM_Object_ptr theCenter, - CORBA::Double theRadius, - GEOM::shape_state theState); + CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theCenter, + CORBA::Double theRadius, + GEOM::shape_state theState); GEOM::ListOfGO* GetShapesOnQuadrangle (GEOM::GEOM_Object_ptr theShape, CORBA::Long theShapeType, @@ -147,21 +160,21 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : GEOM::shape_state theState); GEOM::ListOfLong* GetShapesOnPlaneIDs (GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::GEOM_Object_ptr theAx1, - GEOM::shape_state theState); + CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theAx1, + GEOM::shape_state theState); GEOM::ListOfLong* GetShapesOnPlaneWithLocationIDs (GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::GEOM_Object_ptr theAx1, - GEOM::GEOM_Object_ptr thePnt, - GEOM::shape_state theState); + CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theAx1, + GEOM::GEOM_Object_ptr thePnt, + GEOM::shape_state theState); GEOM::ListOfLong* GetShapesOnCylinderIDs (GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::GEOM_Object_ptr theAxis, - CORBA::Double theRadius, - GEOM::shape_state theState); + CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theRadius, + GEOM::shape_state theState); GEOM::ListOfLong* GetShapesOnCylinderWithLocationIDs (GEOM::GEOM_Object_ptr theShape, CORBA::Long theShapeType, @@ -171,10 +184,10 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : GEOM::shape_state theState); GEOM::ListOfLong* GetShapesOnSphereIDs (GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::GEOM_Object_ptr theCenter, - CORBA::Double theRadius, - GEOM::shape_state theState); + CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theCenter, + CORBA::Double theRadius, + GEOM::shape_state theState); GEOM::ListOfLong* GetShapesOnQuadrangleIDs (GEOM::GEOM_Object_ptr theShape, CORBA::Long theShapeType, @@ -185,39 +198,39 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : GEOM::shape_state theState); GEOM::ListOfGO* GetShapesOnBox (GEOM::GEOM_Object_ptr theBox, - GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::shape_state theState); + GEOM::GEOM_Object_ptr theShape, + CORBA::Long theShapeType, + GEOM::shape_state theState); GEOM::ListOfLong* GetShapesOnBoxIDs (GEOM::GEOM_Object_ptr theBox, - GEOM::GEOM_Object_ptr theShape, - CORBA::Long theShapeType, - GEOM::shape_state theState); + GEOM::GEOM_Object_ptr theShape, + 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 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::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 theShape, + CORBA::Short theShapeType, + GEOM::shape_state theState); GEOM::GEOM_Object_ptr GetInPlace (GEOM::GEOM_Object_ptr theShapeWhere, - GEOM::GEOM_Object_ptr theShapeWhat); + GEOM::GEOM_Object_ptr theShapeWhat); GEOM::GEOM_Object_ptr GetInPlaceByHistory (GEOM::GEOM_Object_ptr theShapeWhere, - GEOM::GEOM_Object_ptr theShapeWhat); + GEOM::GEOM_Object_ptr theShapeWhat); GEOM::GEOM_Object_ptr GetSame (GEOM::GEOM_Object_ptr theShapeWhere, - GEOM::GEOM_Object_ptr theShapeWhat); + GEOM::GEOM_Object_ptr theShapeWhat); ::GEOMImpl_IShapesOperations* GetOperations() { return (::GEOMImpl_IShapesOperations*)GetImpl(); } diff --git a/src/GEOM_SWIG/GEOM_Spanner.py b/src/GEOM_SWIG/GEOM_Spanner.py index e1ee8f2aa..bf6be16d8 100644 --- a/src/GEOM_SWIG/GEOM_Spanner.py +++ b/src/GEOM_SWIG/GEOM_Spanner.py @@ -105,7 +105,7 @@ def MakeSpanner (geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None): else: print "Prism 1 is not a hexahedral solid" - Prism1_faces = geompy.SubShapeAllSorted(Prism1, geompy.ShapeType["FACE"]) + Prism1_faces = geompy.SubShapeAllSortedCentres(Prism1, geompy.ShapeType["FACE"]) ii = 1 for aFace in Prism1_faces: name = geompy.SubShapeName(aFace, Prism1) @@ -383,7 +383,7 @@ def MakeSpanner (geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None): # ---- add long edges of the top face in study - FaceTop_edges = geompy.SubShapeAllSorted(FaceTop, geompy.ShapeType["EDGE"]) + FaceTop_edges = geompy.SubShapeAllSortedCentres(FaceTop, geompy.ShapeType["EDGE"]) Edge1 = FaceTop_edges[0] Edge2 = FaceTop_edges[3] Id_Edge1 = geompy.addToStudyInFather(FaceTop, Edge1, "Edge 1") diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 9098f1207..63d2d0b69 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -165,7 +165,7 @@ def TestAll (geompy, math): Shell = geompy.MakeShell([Face, Face1]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr Prism1 = geompy.MakePrism(Face2, p0, pxyz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr - prism1_faces = geompy.SubShapeAllSorted(Prism1, ShapeTypeFace) + prism1_faces = geompy.SubShapeAllSortedCentres(Prism1, ShapeTypeFace) Shell1 = geompy.MakeShell([prism1_faces[0], prism1_faces[1], prism1_faces[3], prism1_faces[4], prism1_faces[5], prism1_faces[2]]) @@ -230,7 +230,7 @@ def TestAll (geompy, math): Orientation = geompy.ChangeOrientation(Box) #IDList for Fillet/Chamfer - prism_edges = geompy.SubShapeAllSorted(Prism, ShapeTypeEdge) + prism_edges = geompy.SubShapeAllSortedCentres(Prism, ShapeTypeEdge) for anEdge in prism_edges: eid = geompy.GetSubShapeID(Prism, anEdge) @@ -245,7 +245,7 @@ def TestAll (geompy, math): IDlist_e.append(geompy.GetSubShapeID(Prism, prism_edges[1])) IDlist_e.append(geompy.GetSubShapeID(Prism, prism_edges[2])) - prism_faces = geompy.SubShapeAllSorted(Prism, ShapeTypeFace) + prism_faces = geompy.SubShapeAllSortedCentres(Prism, ShapeTypeFace) f_ind_1 = geompy.GetSubShapeID(Prism, prism_faces[0]) f_ind_2 = geompy.GetSubShapeID(Prism, prism_faces[1]) @@ -432,8 +432,8 @@ def TestAll (geompy, math): name = geompy.SubShapeName(SubFace, Box) id_SubFace = geompy.addToStudyInFather(Box, SubFace, name) - # SubShapeSorted - SubFaceS = geompy.SubShapeSorted(Box, geompy.ShapeType["FACE"], [5]) + # SubShapeSortedCentres + SubFaceS = geompy.SubShapeSortedCentres(Box, geompy.ShapeType["FACE"], [5]) nameS = geompy.SubShapeName(SubFaceS, Box) id_SubFace = geompy.addToStudyInFather(Box, SubFaceS, nameS) @@ -451,8 +451,8 @@ def TestAll (geompy, math): geompy.UnionIDs(group, SubEdgeIDsList) geompy.addToStudyInFather(SubFace, group, "Group of all edges") - # SubShapeAllSortedIDs - SubEdgeIDsList = geompy.SubShapeAllSortedIDs(SubFace, geompy.ShapeType["EDGE"]) + # SubShapeAllSortedCentresIDs + SubEdgeIDsList = geompy.SubShapeAllSortedCentresIDs(SubFace, geompy.ShapeType["EDGE"]) print "IDs of edges of SubFace:", SubEdgeIDsList, "(sorted)" # GetSubShape and GetSubShapeID diff --git a/src/GEOM_SWIG/GEOM_TestHealing.py b/src/GEOM_SWIG/GEOM_TestHealing.py index c982e986e..70934fc79 100644 --- a/src/GEOM_SWIG/GEOM_TestHealing.py +++ b/src/GEOM_SWIG/GEOM_TestHealing.py @@ -86,7 +86,7 @@ def TestSuppressFaces (geompy): #IDList for SuppHole faces = [] - faces = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) + faces = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) f_glob_id = geompy.GetSubShapeID(Box, faces[5]) @@ -237,7 +237,7 @@ def TestSuppressHoles (geompy): #IDList for SuppressFaces faces = [] - faces = geompy.SubShapeAllSorted(Cut, geompy.ShapeType["FACE"]) + faces = geompy.SubShapeAllSortedCentres(Cut, geompy.ShapeType["FACE"]) ind = 0 for face in faces: f_name = "FACE %d"%(ind) @@ -249,9 +249,10 @@ def TestSuppressHoles (geompy): f_glob_id_0 = geompy.GetSubShapeID(Cut, faces[0]) cut_without_f_0 = geompy.SuppressFaces(Cut, [f_glob_id_0]) + geompy.addToStudy(cut_without_f_0, "Cut without face 0") faces1 = [] - faces1 = geompy.SubShapeAllSorted(cut_without_f_0, geompy.ShapeType["FACE"]) + faces1 = geompy.SubShapeAllSortedCentres(cut_without_f_0, geompy.ShapeType["FACE"]) ind = 0 for face in faces1: f_name = "FACE %d"%(ind) @@ -261,25 +262,25 @@ def TestSuppressHoles (geompy): print "face ", ind, " global index = ", f_glob_id ind = ind + 1 - f_glob_id_5 = geompy.GetSubShapeID(cut_without_f_0, faces1[5]) - cut_without_f_0_5 = geompy.SuppressFaces(cut_without_f_0, [f_glob_id_5]) - cut_without_f_0_5_id = geompy.addToStudy(cut_without_f_0_5, "Cut without faces 0 and 5") + f_glob_id_3 = geompy.GetSubShapeID(cut_without_f_0, faces1[3]) + cut_without_f_0_3 = geompy.SuppressFaces(cut_without_f_0, [f_glob_id_3]) + cut_without_f_0_3_id = geompy.addToStudy(cut_without_f_0_3, "Cut without faces 0 and 3") #IDList for SuppHole wires = [] - wires = geompy.SubShapeAllSorted(cut_without_f_0_5, geompy.ShapeType["WIRE"]) + wires = geompy.SubShapeAllSortedCentres(cut_without_f_0_3, geompy.ShapeType["WIRE"]) ind = 0 for wire in wires: w_name = "WIRE %d"%(ind) - w_id = geompy.addToStudyInFather(cut_without_f_0_5, wire, w_name) + w_id = geompy.addToStudyInFather(cut_without_f_0_3, wire, w_name) - w_glob_id = geompy.GetSubShapeID(cut_without_f_0_5, wire) + w_glob_id = geompy.GetSubShapeID(cut_without_f_0_3, wire) print "wire ", ind, " global index = ", w_glob_id ind = ind + 1 - w_3 = geompy.GetSubShapeID(cut_without_f_0_5, wires[3]) + w_3 = geompy.GetSubShapeID(cut_without_f_0_3, wires[3]) - SuppHole3 = geompy.SuppressHoles(cut_without_f_0_5, [w_3]) + SuppHole3 = geompy.SuppressHoles(cut_without_f_0_3, [w_3]) SuppHole3_id = geompy.addToStudy(SuppHole3, "Supp Hole 3") def TestMakeSewing (geompy, math): @@ -314,7 +315,7 @@ def TestDivideEdge (geompy): Box = geompy.MakeBoxDXDYDZ(200., 200., 200.) #Divide Edge - box_edges = geompy.SubShapeAllSorted(Box, geompy.ShapeType["EDGE"]) + box_edges = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["EDGE"]) edge_ind = geompy.GetSubShapeID(Box, box_edges[1]) Divide = geompy.DivideEdge(Box, edge_ind, 0.5, 1) # Obj, ind, param, is_curve_param diff --git a/src/GEOM_SWIG/GEOM_TestMeasures.py b/src/GEOM_SWIG/GEOM_TestMeasures.py index 368c3b047..3d7bcc844 100644 --- a/src/GEOM_SWIG/GEOM_TestMeasures.py +++ b/src/GEOM_SWIG/GEOM_TestMeasures.py @@ -115,7 +115,7 @@ def TestMeasureOperations (geompy, math): ####### GetNormal ####### - faces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"]) + faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"]) face0 = faces[0] vnorm = geompy.GetNormal(face0) if vnorm is None: diff --git a/src/GEOM_SWIG/GEOM_TestOthers.py b/src/GEOM_SWIG/GEOM_TestOthers.py index ca37dd30b..327eea930 100644 --- a/src/GEOM_SWIG/GEOM_TestOthers.py +++ b/src/GEOM_SWIG/GEOM_TestOthers.py @@ -20,17 +20,17 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # - # GEOM GEOM_SWIG : binding of C++ implementaion with Python # File : GEOM_TestOthers.py # Author : Julia DOROVSKIKH # Module : GEOM # $Header$ +# # ! Please, if you edit this example file, update also # ! GEOM_SRC/doc/salome/gui/GEOM/input/tui_test_others.doc # ! as some sequences of symbols from this example are used during # ! documentation generation to identify certain places of this file -# + import os def TestExportImport (geompy, shape): @@ -181,7 +181,7 @@ def TestOtherOperations (geompy, math): # MakeFilletAll radius_fillet = 10. - face5 = geompy.SubShapeSorted(Box, geompy.ShapeType["FACE"], [5]) + face5 = geompy.SubShapeSortedCentres(Box, geompy.ShapeType["FACE"], [5]) f_glob_id = geompy.GetSubShapeID(Box, face5) SuppFace = geompy.SuppressFaces(Box, [f_glob_id]) @@ -196,7 +196,7 @@ def TestOtherOperations (geompy, math): # MakeChamfer d1 = 13. d2 = 7. - box_faces = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) + box_faces = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) f_ind_1 = geompy.GetSubShapeID(Box, box_faces[0]) f_ind_2 = geompy.GetSubShapeID(Box, box_faces[1]) f_ind_3 = geompy.GetSubShapeID(Box, box_faces[2]) @@ -426,7 +426,7 @@ def TestOtherOperations (geompy, math): Partition_1 = geompy.MakePartition([Sphere], tools, [], [], geompy.ShapeType["SOLID"], 0, []) geompy.addToStudy(Partition_1, "Partition_1") - faces = geompy.SubShapeAllSorted(Partition_1, geompy.ShapeType["FACE"]) + faces = geompy.SubShapeAllSortedCentres(Partition_1, geompy.ShapeType["FACE"]) Face_1 = faces[0] Face_2 = faces[39] @@ -471,9 +471,19 @@ def TestOtherOperations (geompy, math): # GetSharedShapes sharedFaces = geompy.GetSharedShapes(part, freeFacesWithoutExtra, geompy.ShapeType["FACE"]) - + ind = 1 for shFace in sharedFaces: - geompy.addToStudy(shFace, "sharedFace") + geompy.addToStudy(shFace, "sharedFace_" + `ind`) + ind = ind + 1 + pass + + sharedEdges = geompy.GetSharedShapesMulti([part, freeFacesWithoutExtra], + geompy.ShapeType["EDGE"]) + ind = 1 + for shEdge in sharedEdges: + geompy.addToStudy(shEdge, "sharedEdge_" + `ind`) + ind = ind + 1 + pass # CheckAndImprove blocksComp = geompy.CheckAndImprove(part) diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index eaf571bef..ce18f9e69 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -51,6 +51,7 @@ ## @defgroup l3_advanced Creating Advanced Geometrical Objects ## @{ ## @defgroup l4_decompose Decompose objects +## @defgroup l4_decompose_d Decompose objects deprecated methods ## @defgroup l4_access Access to sub-shapes by their unique IDs inside the main shape ## @defgroup l4_obtain Access to subshapes by a criteria ## @defgroup l4_advanced Advanced objects creation functions @@ -1714,6 +1715,18 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("GetSharedShapes", self.ShapesOp) return aList + ## Get all sub-shapes, shared by all shapes in the list theShapes. + # @param theShapes Shapes to find common sub-shapes of. + # @param theShapeType Type of sub-shapes to be retrieved. + # @return List of objects, that are sub-shapes of all given shapes. + # + # @ref swig_GetSharedShapes "Example" + def GetSharedShapesMulti(self, theShapes, theShapeType): + # Example: see GEOM_TestOthers.py + aList = self.ShapesOp.GetSharedShapesMulti(theShapes, theShapeType) + RaiseIfFailed("GetSharedShapesMulti", self.ShapesOp) + return aList + ## Find in theShape all sub-shapes of type theShapeType, # situated relatively the specified plane by the certain way, # defined through theState parameter. @@ -2035,8 +2048,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @ref swig_all_decompose "Example" def SubShapeAll(self, aShape, aType): # Example: see GEOM_TestAll.py - ListObj = self.ShapesOp.MakeExplode(aShape,aType,0) - RaiseIfFailed("MakeExplode", self.ShapesOp) + ListObj = self.ShapesOp.MakeAllSubShapes(aShape, aType, False) + RaiseIfFailed("SubShapeAll", self.ShapesOp) return ListObj ## Explode a shape on subshapes of a given type. @@ -2046,10 +2059,24 @@ class geompyDC(GEOM._objref_GEOM_Gen): # # @ref swig_all_decompose "Example" def SubShapeAllIDs(self, aShape, aType): - ListObj = self.ShapesOp.SubShapeAllIDs(aShape,aType,0) + ListObj = self.ShapesOp.GetAllSubShapesIDs(aShape, aType, False) RaiseIfFailed("SubShapeAllIDs", self.ShapesOp) return ListObj + ## Obtain a compound of sub-shapes of aShape, + # selected by they indices in list of all sub-shapes of type aType. + # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type] + # + # @ref swig_all_decompose "Example" + def SubShape(self, aShape, aType, ListOfInd): + # Example: see GEOM_TestAll.py + ListOfIDs = [] + AllShapeIDsList = self.SubShapeAllIDs(aShape, aType) + for ind in ListOfInd: + ListOfIDs.append(AllShapeIDsList[ind - 1]) + anObj = self.GetSubShape(aShape, ListOfIDs) + return anObj + ## Explode a shape on subshapes of a given type. # Sub-shapes will be sorted by coordinates of their gravity centers. # @param aShape Shape to be exploded. @@ -2057,10 +2084,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return List of sub-shapes of type theShapeType, contained in theShape. # # @ref swig_SubShapeAllSorted "Example" - def SubShapeAllSorted(self, aShape, aType): + def SubShapeAllSortedCentres(self, aShape, aType): # Example: see GEOM_TestAll.py - ListObj = self.ShapesOp.MakeExplode(aShape,aType,1) - RaiseIfFailed("MakeExplode", self.ShapesOp) + ListObj = self.ShapesOp.MakeAllSubShapes(aShape, aType, True) + RaiseIfFailed("SubShapeAllSortedCentres", self.ShapesOp) return ListObj ## Explode a shape on subshapes of a given type. @@ -2070,40 +2097,59 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return List of IDs of sub-shapes. # # @ref swig_all_decompose "Example" - def SubShapeAllSortedIDs(self, aShape, aType): - ListIDs = self.ShapesOp.SubShapeAllIDs(aShape,aType,1) + def SubShapeAllSortedCentresIDs(self, aShape, aType): + ListIDs = self.ShapesOp.GetAllSubShapesIDs(aShape, aType, True) RaiseIfFailed("SubShapeAllIDs", self.ShapesOp) return ListIDs ## Obtain a compound of sub-shapes of aShape, - # selected by they indices in list of all sub-shapes of type aType. + # selected by they indices in sorted list of all sub-shapes of type aType. # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type] # # @ref swig_all_decompose "Example" - def SubShape(self, aShape, aType, ListOfInd): + def SubShapeSortedCentres(self, aShape, aType, ListOfInd): # Example: see GEOM_TestAll.py ListOfIDs = [] - AllShapeList = self.SubShapeAll(aShape, aType) + AllShapeIDsList = self.SubShapeAllSortedCentresIDs(aShape, aType) for ind in ListOfInd: - ListOfIDs.append(self.GetSubShapeID(aShape, AllShapeList[ind - 1])) + ListOfIDs.append(AllShapeIDsList[ind - 1]) anObj = self.GetSubShape(aShape, ListOfIDs) return anObj - ## Obtain a compound of sub-shapes of aShape, - # selected by they indices in sorted list of all sub-shapes of type aType. - # Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type] - # - # @ref swig_all_decompose "Example" - def SubShapeSorted(self,aShape, aType, ListOfInd): - # Example: see GEOM_TestAll.py + # end of l4_decompose + ## @} + + ## @addtogroup l4_decompose_d + ## @{ + + ## Deprecated method + # It works like SubShapeAllSortedCentres, but wrongly + # defines centres of faces, shells and solids. + def SubShapeAllSorted(self, aShape, aType): + ListObj = self.ShapesOp.MakeExplode(aShape, aType, True) + RaiseIfFailed("MakeExplode", self.ShapesOp) + return ListObj + + ## Deprecated method + # It works like SubShapeAllSortedCentresIDs, but wrongly + # defines centres of faces, shells and solids. + def SubShapeAllSortedIDs(self, aShape, aType): + ListIDs = self.ShapesOp.SubShapeAllIDs(aShape, aType, True) + RaiseIfFailed("SubShapeAllIDs", self.ShapesOp) + return ListIDs + + ## Deprecated method + # It works like SubShapeSortedCentres, but has a bug + # (wrongly defines centres of faces, shells and solids). + def SubShapeSorted(self, aShape, aType, ListOfInd): ListOfIDs = [] - AllShapeList = self.SubShapeAllSorted(aShape, aType) + AllShapeIDsList = self.SubShapeAllSortedIDs(aShape, aType) for ind in ListOfInd: - ListOfIDs.append(self.GetSubShapeID(aShape, AllShapeList[ind - 1])) + ListOfIDs.append(AllShapeIDsList[ind - 1]) anObj = self.GetSubShape(aShape, ListOfIDs) return anObj - # end of l4_decompose + # end of l4_decompose_d ## @} ## @addtogroup l3_healing diff --git a/src/OperationGUI/Makefile.am b/src/OperationGUI/Makefile.am index 9177920c7..bd8e41e87 100644 --- a/src/OperationGUI/Makefile.am +++ b/src/OperationGUI/Makefile.am @@ -16,12 +16,11 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # - # GEOM OPERATIONGUI : # File : Makefile.am # Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com) # Package : OperationGUI -# + include $(top_srcdir)/adm_local/unix/make_common_starter.am # header files @@ -33,6 +32,7 @@ salomeinclude_HEADERS = \ OperationGUI_Fillet1d2dDlg.h \ OperationGUI_ChamferDlg.h \ OperationGUI_GetShapesOnShapeDlg.h \ + OperationGUI_GetSharedShapesDlg.h \ OperationGUI_ClippingDlg.h # Libraries targets @@ -43,6 +43,7 @@ dist_libOperationGUI_la_SOURCES = \ OperationGUI_ArchimedeDlg.cxx \ OperationGUI_PartitionDlg.cxx \ OperationGUI_GetShapesOnShapeDlg.cxx \ + OperationGUI_GetSharedShapesDlg.cxx \ OperationGUI_FilletDlg.cxx \ OperationGUI_Fillet1d2dDlg.cxx \ OperationGUI_ChamferDlg.cxx \ @@ -52,6 +53,7 @@ MOC_FILES = \ OperationGUI_ArchimedeDlg_moc.cxx \ OperationGUI_PartitionDlg_moc.cxx \ OperationGUI_GetShapesOnShapeDlg_moc.cxx\ + OperationGUI_GetSharedShapesDlg_moc.cxx \ OperationGUI_FilletDlg_moc.cxx \ OperationGUI_Fillet1d2dDlg_moc.cxx \ OperationGUI_ChamferDlg_moc.cxx \ diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index d52dbb8b8..069e46df7 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -19,11 +19,10 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// GEOM GEOMGUI : GUI for Geometry component +// File : OperationGUI.cxx +// Author : Damien COQUERET, Open CASCADE S.A.S. -// GEOM GEOMGUI : GUI for Geometry component -// File : OperationGUI.cxx -// Author : Damien COQUERET, Open CASCADE S.A.S. -// #include "OperationGUI.h" #include @@ -44,6 +43,7 @@ #include "OperationGUI_ChamferDlg.h" // Method CHAMFER #include "OperationGUI_ClippingDlg.h" // Clipping dialog box #include "OperationGUI_GetShapesOnShapeDlg.h" +#include "OperationGUI_GetSharedShapesDlg.h" //======================================================================= // function : OperationGUI() @@ -67,24 +67,25 @@ OperationGUI::~OperationGUI() // function : OnGUIEvent() // purpose : //======================================================================= -bool OperationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent) { SalomeApp_Application* app = getGeometryGUI()->getApp(); - if ( !app ) return false; + if (!app) return false; getGeometryGUI()->EmitSignalDeactivateDialog(); - switch ( theCommandID ) { - case GEOMOp::OpPartition: ( new OperationGUI_PartitionDlg ( getGeometryGUI(), parent ) )->show(); break; - case GEOMOp::OpArchimede: ( new OperationGUI_ArchimedeDlg ( getGeometryGUI(), parent ) )->show(); break; - case GEOMOp::OpFillet3d: ( new OperationGUI_FilletDlg ( getGeometryGUI(), parent ) )->show(); break; - case GEOMOp::OpChamfer: ( new OperationGUI_ChamferDlg ( getGeometryGUI(), parent ) )->show(); break; - case GEOMOp::OpClipping: ( new OperationGUI_ClippingDlg ( getGeometryGUI(), parent ) )->show(); break; - case GEOMOp::OpShapesOnShape: ( new OperationGUI_GetShapesOnShapeDlg( getGeometryGUI(), parent ) )->show(); break; - case GEOMOp::OpFillet1d: ( new OperationGUI_Fillet1d2dDlg ( getGeometryGUI(), parent, true ) )->show(); break; - case GEOMOp::OpFillet2d: ( new OperationGUI_Fillet1d2dDlg ( getGeometryGUI(), parent, false ) )->show(); break; + switch (theCommandID) { + case GEOMOp::OpPartition: (new OperationGUI_PartitionDlg (getGeometryGUI(), parent))->show(); break; + case GEOMOp::OpArchimede: (new OperationGUI_ArchimedeDlg (getGeometryGUI(), parent))->show(); break; + case GEOMOp::OpFillet3d: (new OperationGUI_FilletDlg (getGeometryGUI(), parent))->show(); break; + case GEOMOp::OpChamfer: (new OperationGUI_ChamferDlg (getGeometryGUI(), parent))->show(); break; + case GEOMOp::OpClipping: (new OperationGUI_ClippingDlg (getGeometryGUI(), parent))->show(); break; + case GEOMOp::OpShapesOnShape: (new OperationGUI_GetShapesOnShapeDlg(getGeometryGUI(), parent))->show(); break; + case GEOMOp::OpSharedShapes: (new OperationGUI_GetSharedShapesDlg (getGeometryGUI(), parent))->show(); break; + case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break; + case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break; default: - app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); + app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); } return true; diff --git a/src/OperationGUI/OperationGUI_GetSharedShapesDlg.cxx b/src/OperationGUI/OperationGUI_GetSharedShapesDlg.cxx new file mode 100644 index 000000000..e4910dff1 --- /dev/null +++ b/src/OperationGUI/OperationGUI_GetSharedShapesDlg.cxx @@ -0,0 +1,363 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// GEOM GEOMGUI : GUI for Geometry component +// File : OperationGUI_GetSharedShapesDlg.cxx +// Author : Lucien PIGNOLONI, Open CASCADE S.A.S. + +#include "OperationGUI_GetSharedShapesDlg.h" + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +//================================================================================= +// class : OperationGUI_GetSharedShapesDlg() +// purpose : Constructs a OperationGUI_GetSharedShapesDlg 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_GetSharedShapesDlg::OperationGUI_GetSharedShapesDlg +(GeometryGUI* theGeometryGUI, QWidget* parent) + : GEOMBase_Skeleton(theGeometryGUI, parent, false) +{ + SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); + QPixmap image0(aResMgr->loadPixmap("GEOM", tr("ICON_DLG_SHARED_SHAPES"))); + QPixmap image2(aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("GEOM_SHARED_SHAPES_TITLE")); + + /***************************************************************/ + mainFrame()->GroupConstructors->setTitle(tr("GEOM_GET_SHARED_SHAPES")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); + + GroupPoints = new DlgRef_2Sel1List1Check(centralWidget()); + GroupPoints->GroupBox1->setTitle(tr("GEOM_SHARED_SHAPES_INPUT")); + GroupPoints->TextLabel1->setText(tr("GEOM_SHAPES")); + GroupPoints->TextLabel2->hide(); + GroupPoints->TextLabel3->setText(tr("GEOM_SUBSHAPE_TYPE")); + GroupPoints->PushButton1->setIcon(image2); + GroupPoints->PushButton2->hide(); + GroupPoints->LineEdit1->setReadOnly(true); + GroupPoints->LineEdit2->hide(); + GroupPoints->LineEdit1->setEnabled(true); + GroupPoints->CheckButton1->hide(); + + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(GroupPoints); + + /***************************************************************/ + + setHelpFileName("shared_shapes_page.html"); + + Init(); +} + +//================================================================================= +// function : ~OperationGUI_GetSharedShapesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_GetSharedShapesDlg::~OperationGUI_GetSharedShapesDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_GetSharedShapesDlg::Init() +{ + /* type for sub shape selection */ + GroupPoints->ComboBox1->addItem(tr("GEOM_SOLID")); + GroupPoints->ComboBox1->addItem(tr("GEOM_SHELL")); + GroupPoints->ComboBox1->addItem(tr("GEOM_FACE")); + GroupPoints->ComboBox1->addItem(tr("GEOM_WIRE")); + GroupPoints->ComboBox1->addItem(tr("GEOM_EDGE")); + GroupPoints->ComboBox1->addItem(tr("GEOM_VERTEX")); + + GroupPoints->ComboBox1->setCurrentIndex(0); + + /* signals and slots connections */ + 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(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged())); + + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName(getNewObjectName()); + + ConstructorsClicked(0); + GroupPoints->PushButton1->click(); +} + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void OperationGUI_GetSharedShapesDlg::ConstructorsClicked (int constructorId) +{ + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + globalSelection(); + + myListShapes.length(0); + + GroupPoints->ComboBox1->setCurrentIndex(0); + GroupPoints->PushButton1->setDown(true); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->clear(); + + qApp->processEvents(); + updateGeometry(); + resize(minimumSizeHint()); + + myEditCurrentArgument->setFocus(); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_GetSharedShapesDlg::ClickOnOk() +{ + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool OperationGUI_GetSharedShapesDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(getNewObjectName()); + + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void OperationGUI_GetSharedShapesDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); + + if (nbSel < 1) { + myListShapes.length(0); + } + + GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true); + if (!myListShapes.length()) + return; + + myEditCurrentArgument->setText(aString); +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_GetSharedShapesDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if (send == GroupPoints->PushButton1) { + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setEnabled(true); + } + + globalSelection(GEOM_ALLSHAPES); + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); + send->setDown(true); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_GetSharedShapesDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + ConstructorsClicked(getConstructorId()); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_GetSharedShapesDlg::enterEvent(QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + this->ActivateThisDialog(); +} + +//======================================================================= +//function : ComboTextChanged +//purpose : +//======================================================================= +void OperationGUI_GetSharedShapesDlg::ComboTextChanged() +{ + initName(getNewObjectName()); +} + +//================================================================================= +// function : GetType() +// purpose : +//================================================================================= +int OperationGUI_GetSharedShapesDlg::GetType() const +{ + int aLimit = GroupPoints->ComboBox1->currentIndex(); + + 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 ; + } + + return aLimit; +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_GetSharedShapesDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations(getStudyId()); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool OperationGUI_GetSharedShapesDlg::isValid (QString& msg) +{ + if (myListShapes.length() < 2) { + //msg = "Too few shapes selected"; + msg = "MSG_SHARED_SHAPES_TOO_FEW_SHAPES"; + return false; + } + return true; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool OperationGUI_GetSharedShapesDlg::execute (ObjectList& objects) +{ + GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation()); + GEOM::ListOfGO_var aList = anOper->GetSharedShapesMulti(myListShapes, GetType()); + + if (!aList->length()) + return false; + + for (int i = 0, n = aList->length(); i < n; i++) + objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); + + return objects.size(); +} + +//================================================================ +// Function : getFather +// Purpose : Get father object for object to be added in study +// ( called with addInStudy method ) +//================================================================ +GEOM::GEOM_Object_ptr OperationGUI_GetSharedShapesDlg::getFather (GEOM::GEOM_Object_ptr) +{ + if (myListShapes.length() > 0) + //return myListShapes[0]._retn(); + return myListShapes[0]; + return NULL; +} + +//================================================================ +// Function : getNewObjectName +// Purpose : +//================================================================ +QString OperationGUI_GetSharedShapesDlg::getNewObjectName() const +{ + int aLimit = GroupPoints->ComboBox1->currentIndex(); + //QString aName = tr("GEOM_SHARED_SHAPE"); + QString aName; + + switch (aLimit) { + case 0: aName = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_SOLID")) ; break; + case 1: aName = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_SHELL")) ; break; + case 2: aName = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_FACE")) ; break; + case 3: aName = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_WIRE")) ; break; + case 4: aName = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_EDGE")) ; break; + case 5: aName = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_VERTEX")); break; + default: aName = tr("GEOM_SHARED_SHAPE").arg(tr("GEOM_SHAPE")) ; + } + + return aName; +} diff --git a/src/OperationGUI/OperationGUI_GetSharedShapesDlg.h b/src/OperationGUI/OperationGUI_GetSharedShapesDlg.h new file mode 100644 index 000000000..4ac5f07b4 --- /dev/null +++ b/src/OperationGUI/OperationGUI_GetSharedShapesDlg.h @@ -0,0 +1,73 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// GEOM GEOMGUI : GUI for Geometry component +// File : OperationGUI_GetSharedShapesDlg.h +// Author : Julia DOROVSKIKH, Open CASCADE S.A.S. + +#ifndef OPERATIONGUI_GETSHAREDSHAPESDLG_H +#define OPERATIONGUI_GETSHAREDSHAPESDLG_H + +#include + +class DlgRef_2Sel1List1Check; + +//================================================================================= +// class : OperationGUI_GetSharedShapesDlg +// purpose : +//================================================================================= +class OperationGUI_GetSharedShapesDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + OperationGUI_GetSharedShapesDlg (GeometryGUI*, QWidget* = 0); + ~OperationGUI_GetSharedShapesDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); + virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr); + virtual QString getNewObjectName() const; + +private: + void Init(); + void enterEvent (QEvent*); + int GetType() const; + +private: + GEOM::ListOfGO myListShapes; + + DlgRef_2Sel1List1Check* GroupPoints; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked (int); + void ComboTextChanged(); +}; + +#endif // OPERATIONGUI_GETSHAREDSHAPESDLG_H diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx index b6fac51c7..ef7fc756a 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -19,11 +19,10 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// GEOM GEOMGUI : GUI for Geometry component +// File : OperationGUI_PartitionDlg.cxx +// Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// GEOM GEOMGUI : GUI for Geometry component -// File : OperationGUI_PartitionDlg.cxx -// Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// #include "OperationGUI_PartitionDlg.h" #include @@ -44,50 +43,50 @@ //================================================================================= // class : OperationGUI_PartitionDlg() -// purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the +// purpose : Constructs a OperationGUI_PartitionDlg 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_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGUI, QWidget* parent ) - : GEOMBase_Skeleton( theGeometryGUI, parent, false ) +OperationGUI_PartitionDlg::OperationGUI_PartitionDlg(GeometryGUI* theGeometryGUI, QWidget* parent) + : GEOMBase_Skeleton(theGeometryGUI, parent, false) { SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); - QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PARTITION" ) ) ); - QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PARTITION_PLANE" ) ) ); - QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image0(aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PARTITION"))); + QPixmap image1(aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PARTITION_PLANE"))); + QPixmap image2(aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); - setWindowTitle( tr( "GEOM_PARTITION_TITLE" ) ); + setWindowTitle(tr("GEOM_PARTITION_TITLE")); /***************************************************************/ - mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PARTITION" ) ); - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setIcon( image1 ); - mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->GroupConstructors->setTitle(tr("GEOM_PARTITION")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setIcon(image1); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->close(); // Full partition (contains half-space partition) - GroupPoints = new DlgRef_2Sel1List1Check( centralWidget() ); - GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) ); - GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); - GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) ); - GroupPoints->TextLabel3->setText( tr( "GEOM_RECONSTRUCTION_LIMIT" ) ); - GroupPoints->PushButton1->setIcon( image2 ); - GroupPoints->PushButton2->setIcon( image2 ); - GroupPoints->LineEdit1->setReadOnly( true ); - GroupPoints->LineEdit2->setReadOnly( true ); + GroupPoints = new DlgRef_2Sel1List1Check(centralWidget()); + GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); + GroupPoints->TextLabel2->setText(tr("GEOM_TOOL_OBJECTS")); + GroupPoints->TextLabel3->setText(tr("GEOM_RECONSTRUCTION_LIMIT")); + GroupPoints->PushButton1->setIcon(image2); + GroupPoints->PushButton2->setIcon(image2); + GroupPoints->LineEdit1->setReadOnly(true); + GroupPoints->LineEdit2->setReadOnly(true); GroupPoints->LineEdit1->setEnabled(true); GroupPoints->LineEdit2->setEnabled(false); - GroupPoints->CheckButton1->setText( tr( "GEOM_KEEP_NONLIMIT_SHAPES" ) ); + GroupPoints->CheckButton1->setText(tr("GEOM_KEEP_NONLIMIT_SHAPES")); - QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); - layout->setMargin( 0 ); layout->setSpacing( 6 ); - layout->addWidget( GroupPoints ); + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(GroupPoints); /***************************************************************/ - setHelpFileName( "partition_page.html" ); - + setHelpFileName("partition_page.html"); + Init(); } @@ -101,14 +100,14 @@ OperationGUI_PartitionDlg::~OperationGUI_PartitionDlg() // no need to delete child widgets, Qt does it all for us } -void OperationGUI_PartitionDlg::SetListMaterials( GEOM::ListOfLong ListMaterials ) +void OperationGUI_PartitionDlg::SetListMaterials(GEOM::ListOfLong ListMaterials) { - myListMaterials = ListMaterials; + myListMaterials = ListMaterials; } - + GEOM::ListOfLong OperationGUI_PartitionDlg::GetListMaterials() -{ - return myListMaterials; +{ + return myListMaterials; } //================================================================================= @@ -118,36 +117,36 @@ GEOM::ListOfLong OperationGUI_PartitionDlg::GetListMaterials() void OperationGUI_PartitionDlg::Init() { /* type for sub shape selection */ - GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SOLID" ) ); - GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SHELL" ) ); - GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_FACE" ) ); - GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_WIRE" ) ); - GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_EDGE" ) ); - GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) ); - GroupPoints->CheckButton1->setChecked( false ); - + GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_SOLID")); + GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_SHELL")); + GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_FACE")); + GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_WIRE")); + GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_EDGE")); + GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX")); + GroupPoints->CheckButton1->setChecked(false); + mainFrame()->GroupBoxPublish->show(); /* signals and slots connections */ - 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( 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( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - - initName( tr( "GEOM_PARTITION" ) ); - - ConstructorsClicked( 0 ); + 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(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(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName(tr("GEOM_PARTITION")); + + ConstructorsClicked(0); GroupPoints->PushButton1->click(); } @@ -156,40 +155,40 @@ void OperationGUI_PartitionDlg::Init() // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) +void OperationGUI_PartitionDlg::ConstructorsClicked(int constructorId) { - disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); globalSelection(); - - myListShapes.length( 0 ); - myListTools.length( 0 ); - myListKeepInside.length( 0 ); - myListRemoveInside.length( 0 ); - myListMaterials.length( 0 ); - - switch ( constructorId ) { + + myListShapes.length(0); + myListTools.length(0); + myListKeepInside.length(0); + myListRemoveInside.length(0); + myListMaterials.length(0); + + switch (constructorId) { case 0: /*Full partition */ - GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) ); - GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) ); + GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION")); + GroupPoints->TextLabel2->setText(tr("GEOM_TOOL_OBJECTS")); GroupPoints->TextLabel3->show(); GroupPoints->ComboBox1->show(); - GroupPoints->ComboBox1->setCurrentIndex( 0 ); + GroupPoints->ComboBox1->setCurrentIndex(0); GroupPoints->CheckButton1->show(); - GroupPoints->PushButton1->setDown( true ); - GroupPoints->PushButton2->setDown( false ); + GroupPoints->PushButton1->setDown(true); + GroupPoints->PushButton2->setDown(false); GroupPoints->LineEdit1->setEnabled(true); GroupPoints->LineEdit2->setEnabled(false); break; case 1: /*Half-space partition */ - GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION_HALFSPACE" ) ); + GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION_HALFSPACE")); GroupPoints->TextLabel3->hide(); GroupPoints->ComboBox1->hide(); - GroupPoints->TextLabel2->setText( tr( "GEOM_PLANE" ) ); + GroupPoints->TextLabel2->setText(tr("GEOM_PLANE")); GroupPoints->CheckButton1->hide(); - GroupPoints->PushButton1->setDown( true ); + GroupPoints->PushButton1->setDown(true); GroupPoints->LineEdit1->setEnabled(true); break; - } + } myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->clear(); @@ -197,11 +196,11 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) qApp->processEvents(); updateGeometry(); - resize( minimumSizeHint() ); + resize(minimumSizeHint()); myEditCurrentArgument->setFocus(); - connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); SelectionIntoArgument(); } @@ -212,7 +211,7 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) //================================================================================= void OperationGUI_PartitionDlg::ClickOnOk() { - if ( ClickOnApply() ) + if (ClickOnApply()) ClickOnCancel(); } @@ -223,13 +222,12 @@ void OperationGUI_PartitionDlg::ClickOnOk() //================================================================================= bool OperationGUI_PartitionDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; - initName(); - // 0020854: EDF 1398 GEOM: Ergonomy of Partition GUI window - // ConstructorsClicked( getConstructorId() ); + // 0020854: EDF 1398 GEOM: Ergonomy of Partition GUI window + // ConstructorsClicked(getConstructorId()); return true; } @@ -240,46 +238,46 @@ bool OperationGUI_PartitionDlg::ClickOnApply() //================================================================================= void OperationGUI_PartitionDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText( "" ); + myEditCurrentArgument->setText(""); QString aString = ""; - + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); SALOME_ListIO aSelList; aSelMgr->selectedObjects(aSelList); int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); - - if ( nbSel < 1 ) { - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { - myListShapes.length( 0 ); - myListMaterials.length( 0 ); + + if (nbSel < 1) { + if (myEditCurrentArgument == GroupPoints->LineEdit1) { + myListShapes.length(0); + myListMaterials.length(0); } - else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) - myListTools.length( 0 ); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myListTools.length(0); } - + // One and only one plane can be selected - - if ( getConstructorId() == 1 && - myEditCurrentArgument == GroupPoints->LineEdit2 && - nbSel != 1 ) { - myListTools.length( 0 ); + + if (getConstructorId() == 1 && + myEditCurrentArgument == GroupPoints->LineEdit2 && + nbSel != 1) { + myListTools.length(0); return; } - - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { + + if (myEditCurrentArgument == GroupPoints->LineEdit1) { GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true); - myListMaterials.length( 0 ); - if ( !myListShapes.length() ) + myListMaterials.length(0); + if (!myListShapes.length()) return; } - else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListTools, true); - if ( !myListTools.length() ) + if (!myListTools.length()) return; } - - myEditCurrentArgument->setText( aString ); + + myEditCurrentArgument->setText(aString); } @@ -290,25 +288,25 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() void OperationGUI_PartitionDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - if ( send == GroupPoints->PushButton1 ) { + + if (send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton2->setDown(false); GroupPoints->LineEdit1->setEnabled(true); GroupPoints->LineEdit2->setEnabled(false); } - else if ( send == GroupPoints->PushButton2 ) { + else if (send == GroupPoints->PushButton2) { myGeomGUI->getApp()->selectionMgr()->clearSelected(); //clear prewious selection myEditCurrentArgument = GroupPoints->LineEdit2; GroupPoints->PushButton1->setDown(false); GroupPoints->LineEdit1->setEnabled(false); GroupPoints->LineEdit2->setEnabled(true); - if ( getConstructorId() == 1 ) - globalSelection( GEOM_PLANE ); + if (getConstructorId() == 1) + globalSelection(GEOM_PLANE); } - - globalSelection( GEOM_ALLSHAPES ); - + + globalSelection(GEOM_ALLSHAPES); + myEditCurrentArgument->setFocus(); SelectionIntoArgument(); send->setDown(true); @@ -323,8 +321,8 @@ void OperationGUI_PartitionDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2 ) { + if (send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) { myEditCurrentArgument = send; GEOMBase_Skeleton::LineEditReturnPressed(); } @@ -338,10 +336,10 @@ void OperationGUI_PartitionDlg::LineEditReturnPressed() void OperationGUI_PartitionDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } @@ -349,9 +347,9 @@ void OperationGUI_PartitionDlg::ActivateThisDialog() // function : enterEvent() // purpose : //================================================================================= -void OperationGUI_PartitionDlg::enterEvent( QEvent* ) +void OperationGUI_PartitionDlg::enterEvent(QEvent*) { - if ( !mainFrame()->GroupConstructors->isEnabled() ) + if (!mainFrame()->GroupConstructors->isEnabled()) this->ActivateThisDialog(); } @@ -362,7 +360,7 @@ void OperationGUI_PartitionDlg::enterEvent( QEvent* ) //================================================================================= GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation() { - return getGeomEngine()->GetIBooleanOperations( getStudyId() ); + return getGeomEngine()->GetIBooleanOperations(getStudyId()); } @@ -370,10 +368,10 @@ GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation() // function : isValid // purpose : //================================================================================= -bool OperationGUI_PartitionDlg::isValid( QString& ) +bool OperationGUI_PartitionDlg::isValid(QString&) { - return ( myListShapes.length() || myListTools.length() || - myListKeepInside.length() || myListRemoveInside.length() ); + return (myListShapes.length() || myListTools.length() || + myListKeepInside.length() || myListRemoveInside.length()); } @@ -381,7 +379,7 @@ bool OperationGUI_PartitionDlg::isValid( QString& ) // function : execute // purpose : //================================================================================= -bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) +bool OperationGUI_PartitionDlg::execute(ObjectList& objects) { bool res = false; @@ -392,11 +390,11 @@ bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) int aConstructorId = getConstructorId(); int aKeepNonlimitShapes = 0; - if ( aConstructorId == 1 ) { + if (aConstructorId == 1) { aLimit = GEOM::SHAPE; } else { - if ( GroupPoints->CheckButton1->isChecked() ) { + if (GroupPoints->CheckButton1->isChecked()) { aKeepNonlimitShapes = 1; } else { @@ -404,15 +402,15 @@ bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) } } - if ( isValid( msg ) ) { + if (isValid(msg)) { GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation()); - anObj = anOper->MakePartition( myListShapes, myListTools, - myListKeepInside, myListRemoveInside, - aLimit, false, myListMaterials, aKeepNonlimitShapes ); + anObj = anOper->MakePartition(myListShapes, myListTools, + myListKeepInside, myListRemoveInside, + aLimit, false, myListMaterials, aKeepNonlimitShapes); res = true; } - if ( !anObj->_is_nil() ) { + if (!anObj->_is_nil()) { TopoDS_Shape aShape; GEOMBase::GetShape(anObj, aShape, TopAbs_SHAPE); TopoDS_Iterator It (aShape, Standard_True, Standard_True); @@ -421,7 +419,7 @@ bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) nbSubshapes++; if (nbSubshapes) - objects.push_back( anObj._retn() ); + objects.push_back(anObj._retn()); else SUIT_MessageBox::warning(this, QObject::tr("GEOM_ERROR"), @@ -435,21 +433,21 @@ bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) // function : restoreSubShapes // purpose : //================================================================================= -void OperationGUI_PartitionDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy, - SALOMEDS::SObject_ptr theSObject ) +void OperationGUI_PartitionDlg::restoreSubShapes(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) { - if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) { + if (mainFrame()->CheckBoxRestoreSS->isChecked()) { // empty list of arguments means that all arguments should be restored - getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(), - /*theFindMethod=*/GEOM::FSM_GetInPlaceByHistory, - /*theInheritFirstArg=*/myListShapes.length() == 1, - mainFrame()->CheckBoxAddPrefix->isChecked() ); // ? false + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), + /*theFindMethod=*/GEOM::FSM_GetInPlaceByHistory, + /*theInheritFirstArg=*/myListShapes.length() == 1, + mainFrame()->CheckBoxAddPrefix->isChecked()); // ? false } } //======================================================================= //function : ComboTextChanged -//purpose : +//purpose : //======================================================================= void OperationGUI_PartitionDlg::ComboTextChanged() { @@ -464,13 +462,13 @@ void OperationGUI_PartitionDlg::ComboTextChanged() //================================================================================= // function : GetLimit() -// purpose : +// purpose : //================================================================================= int OperationGUI_PartitionDlg::GetLimit() const { int aLimit = GroupPoints->ComboBox1->currentIndex(); - switch ( aLimit ) { + switch (aLimit) { case 0: aLimit = GEOM::SOLID ; break; case 1: aLimit = GEOM::SHELL ; break; case 2: aLimit = GEOM::FACE ; break; diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.h b/src/OperationGUI/OperationGUI_PartitionDlg.h index f179659a5..0acf131b2 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.h +++ b/src/OperationGUI/OperationGUI_PartitionDlg.h @@ -19,11 +19,10 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// GEOM GEOMGUI : GUI for Geometry component +// File : OperationGUI_PartitionDlg.h +// Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// GEOM GEOMGUI : GUI for Geometry component -// File : OperationGUI_PartitionDlg.h -// Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// #ifndef OPERATIONGUI_PARTITIONDLG_H #define OPERATIONGUI_PARTITIONDLG_H @@ -36,13 +35,13 @@ class DlgRef_2Sel1List1Check; // purpose : //================================================================================= class OperationGUI_PartitionDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: OperationGUI_PartitionDlg( GeometryGUI*, QWidget* = 0 ); ~OperationGUI_PartitionDlg(); - + void SetListMaterials( GEOM::ListOfLong ); GEOM::ListOfLong GetListMaterials(); -- 2.39.2