From: eap Date: Thu, 22 Jan 2009 13:39:09 +0000 (+0000) Subject: Merge from BR_V5_IMP_P8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=10bf139e7d68631bd457d90bccd0c42c78683975;p=modules%2Fgeom.git Merge from BR_V5_IMP_P8 --- diff --git a/doc/salome/gui/GEOM/images/3dsketch1.png b/doc/salome/gui/GEOM/images/3dsketch1.png new file mode 100755 index 000000000..087ea15dc Binary files /dev/null and b/doc/salome/gui/GEOM/images/3dsketch1.png differ diff --git a/doc/salome/gui/GEOM/images/3dsketch2.png b/doc/salome/gui/GEOM/images/3dsketch2.png new file mode 100755 index 000000000..51f171d9f Binary files /dev/null and b/doc/salome/gui/GEOM/images/3dsketch2.png differ diff --git a/doc/salome/gui/GEOM/images/3dsketch3.png b/doc/salome/gui/GEOM/images/3dsketch3.png new file mode 100755 index 000000000..feb56e7cb Binary files /dev/null and b/doc/salome/gui/GEOM/images/3dsketch3.png differ diff --git a/doc/salome/gui/GEOM/images/arc.png b/doc/salome/gui/GEOM/images/arc.png index a53247fb2..b7ef8777f 100755 Binary files a/doc/salome/gui/GEOM/images/arc.png and b/doc/salome/gui/GEOM/images/arc.png differ diff --git a/doc/salome/gui/GEOM/images/arc2.png b/doc/salome/gui/GEOM/images/arc2.png index ed3de7be2..6305cac1e 100644 Binary files a/doc/salome/gui/GEOM/images/arc2.png and b/doc/salome/gui/GEOM/images/arc2.png differ diff --git a/doc/salome/gui/GEOM/images/arcofellipse1.png b/doc/salome/gui/GEOM/images/arcofellipse1.png new file mode 100644 index 000000000..cd50fff1c Binary files /dev/null and b/doc/salome/gui/GEOM/images/arcofellipse1.png differ diff --git a/doc/salome/gui/GEOM/images/arcofellipse2.png b/doc/salome/gui/GEOM/images/arcofellipse2.png new file mode 100644 index 000000000..24172dfae Binary files /dev/null and b/doc/salome/gui/GEOM/images/arcofellipse2.png differ diff --git a/doc/salome/gui/GEOM/images/fillet2d_1.png b/doc/salome/gui/GEOM/images/fillet2d_1.png new file mode 100755 index 000000000..859796aae Binary files /dev/null and b/doc/salome/gui/GEOM/images/fillet2d_1.png differ diff --git a/doc/salome/gui/GEOM/images/fillet2d_2.png b/doc/salome/gui/GEOM/images/fillet2d_2.png new file mode 100755 index 000000000..58579c47d Binary files /dev/null and b/doc/salome/gui/GEOM/images/fillet2d_2.png differ diff --git a/doc/salome/gui/GEOM/images/transformation12.png b/doc/salome/gui/GEOM/images/transformation12.png new file mode 100644 index 000000000..66ea98415 Binary files /dev/null and b/doc/salome/gui/GEOM/images/transformation12.png differ diff --git a/doc/salome/gui/GEOM/images/transformation13.png b/doc/salome/gui/GEOM/images/transformation13.png new file mode 100644 index 000000000..1ae0170df Binary files /dev/null and b/doc/salome/gui/GEOM/images/transformation13.png differ diff --git a/doc/salome/gui/GEOM/images/transformation14.png b/doc/salome/gui/GEOM/images/transformation14.png new file mode 100644 index 000000000..ba31ef99b Binary files /dev/null and b/doc/salome/gui/GEOM/images/transformation14.png differ diff --git a/doc/salome/gui/GEOM/images/transformation5.png b/doc/salome/gui/GEOM/images/transformation5.png index 81813504c..48b632622 100755 Binary files a/doc/salome/gui/GEOM/images/transformation5.png and b/doc/salome/gui/GEOM/images/transformation5.png differ diff --git a/doc/salome/gui/GEOM/images/transformation6.png b/doc/salome/gui/GEOM/images/transformation6.png index 2060c935e..b77c7450f 100755 Binary files a/doc/salome/gui/GEOM/images/transformation6.png and b/doc/salome/gui/GEOM/images/transformation6.png differ diff --git a/doc/salome/gui/GEOM/input/creating_3dsketcher.doc b/doc/salome/gui/GEOM/input/creating_3dsketcher.doc new file mode 100755 index 000000000..bb914ea55 --- /dev/null +++ b/doc/salome/gui/GEOM/input/creating_3dsketcher.doc @@ -0,0 +1,31 @@ +/*! + +\page create_3dsketcher_page 3D Sketcher + +3D Sketcher allows creating a closed or unclosed 3D wire from a list of points. + +To create a 3D Sketch, select in the main menu New Entity -> 3D Sketch. + +\image html 3dsketch2.png + +The position of each coordinates can be defined by absolute coordinates X, Y, Z or +by relative coordinates DX, DY, DZ with respect to the previous Applied point. +Type of coordinates can be selected by the Coordinates Type radio buttons. +\n "Sketch Validation" button applies the wire, only red part will be built by "Sketch Validation". +\n "Sketch Closure" will close the Sketch by straight line from last red part and apply it. +To make a closed wire using the TUI command, the first and the last point shoul +have the same coordinates. + +The Result of the operation will be a \b GEOM_Object. + +TUI Command: geompy.Make3DSketcher( [ PointsList ] ) +This algorithm creates a wire, from the list of real values which define XYZ +coordinates of points. + +Example: + +\image html 3dsketch1.png + +Our TUI Scripts provide you with useful examples of the use of +\ref tui_3dsketcher_page "3D Sketcher". +*/ diff --git a/doc/salome/gui/GEOM/input/creating_arc.doc b/doc/salome/gui/GEOM/input/creating_arc.doc index 8ee49ca23..4537a8a0f 100644 --- a/doc/salome/gui/GEOM/input/creating_arc.doc +++ b/doc/salome/gui/GEOM/input/creating_arc.doc @@ -29,6 +29,17 @@ Point, End Point, boolean Sense) \image html arc2.png +Finally, it is possible to create an Arc of Ellipse, which is also done by three points: +the Arguments Point 1, Point 2 and the Center Point. The arc is built on the Ellipse that +lies in the plane defined by the three points, with the center in the Center point. +The major radius of the Ellipse is defined by the distance between the Center Point and +the most remote Argument point. The minor radius is defined by the shortest distance between the +other Argument point and the major radius. +\n TUI Command: geompy.MakeArcOfEllipse(Center Point, First Point, Second Point) +\n Arguments: Name + 3 vertices. + +\image html arcofellipse2.png + \n Examples: \image html arcsn.png @@ -40,4 +51,10 @@ Point, End Point, boolean Sense) \image html arcsn2.png
Reversed arc.
+\image html arcofellipse1.png +
Arc Of Ellipse.
+ +Our TUI Scripts provide you with useful examples of creation of +\ref tui_creation_arc "Basic Geometric Objects". */ + diff --git a/doc/salome/gui/GEOM/input/creating_geom_objects.doc b/doc/salome/gui/GEOM/input/creating_geom_objects.doc index 3bf780994..ae5dfb8c7 100644 --- a/doc/salome/gui/GEOM/input/creating_geom_objects.doc +++ b/doc/salome/gui/GEOM/input/creating_geom_objects.doc @@ -15,7 +15,10 @@ extrusion, rotation, interpolation of other objects. lower dimension, which belong to the objects of higher dimension.
  • \subpage build_by_blocks_page "Build by blocks" faces from edges and solids from faces.
  • -
  • create line segments and arcs using \subpage create_sketcher_page "Sketcher".
  • +
  • create line segments and arcs using \subpage create_sketcher_page +"Sketcher".
  • +
  • create a closed or unclosed 3D wire from a list of points using +\subpage create_3dsketcher_page "3D Sketcher".
  • \subpage create_explode_page "Explode" objects of higher dimension into sub-objects of lower dimension.
  • create \subpage create_adv_obj_page "Advanced geometrical objects" - edges, wires, shells...
  • diff --git a/doc/salome/gui/GEOM/input/creating_sketcher.doc b/doc/salome/gui/GEOM/input/creating_sketcher.doc index 52c85df09..ce1a6e78d 100644 --- a/doc/salome/gui/GEOM/input/creating_sketcher.doc +++ b/doc/salome/gui/GEOM/input/creating_sketcher.doc @@ -52,6 +52,11 @@ is predefined and is equal to 90 degrees);
  • Parameters of an element (for segment : length or target X or Y coordinate value, for arc : radius and angle).
  • +\b Buttons: + +"Sketch Validation" button applies the wire, only red part will be built by "Sketch Validation". +\n "Sketch Closure" will close the Sketch by straight line from last red part and apply it. + \n Dialog Box: \image html neo-scetcher1.png diff --git a/doc/salome/gui/GEOM/input/fillet2d_operation.doc b/doc/salome/gui/GEOM/input/fillet2d_operation.doc new file mode 100755 index 000000000..43701ed90 --- /dev/null +++ b/doc/salome/gui/GEOM/input/fillet2d_operation.doc @@ -0,0 +1,27 @@ +/*! + +\page fillet2d_operation_page Fillet 2D + +This operation creates fillets on the corners of a 2D Planar Face. + +\image html fillet2d_2.png + +To produce a \b Fillet 2D in the Main Menu select +Operations - > Transformation - > Fillet 2D + +Define the Planar Face to create a fillet on, select the necessary +vertexes on this face in the OCC Viewer and define the \b Radius of the Fillet. + +\b Note: This Operation Works for the Planar 2D Faces Only. + +TUI Command: geompy.MakeFillet(Shape, R, ListVertexes) +\n Arguments: Name + 1 shape + one or several vertexes + 1 value (Fillet radius). + +Examples: + +\image html fillet2d_1.png + +Our TUI Scripts provide you with useful examples of the use of +\ref tui_fillet2d "Transformation Operations". + +*/ diff --git a/doc/salome/gui/GEOM/input/index.doc b/doc/salome/gui/GEOM/input/index.doc index e0eb5cc8f..6ae767547 100644 --- a/doc/salome/gui/GEOM/input/index.doc +++ b/doc/salome/gui/GEOM/input/index.doc @@ -22,4 +22,4 @@ Almost all geometry module functionalities are accessible via \image html image3.jpg "Example of Geometry module usage for engineering tasks" -*/ \ No newline at end of file +*/ diff --git a/doc/salome/gui/GEOM/input/modify_location_operation.doc b/doc/salome/gui/GEOM/input/modify_location_operation.doc index 87c958845..9ce13b3f8 100644 --- a/doc/salome/gui/GEOM/input/modify_location_operation.doc +++ b/doc/salome/gui/GEOM/input/modify_location_operation.doc @@ -54,12 +54,31 @@ translated cube at the position (-100;0;0) \image html image4.gif +The third algorithm modifies the location of an object using the Path object (Wire or Edge) +and the Distance parameter (ranging from 0 to 1) defining how far the object will move along the path. +\n Create a copy checkbox allows to keep the initial object, +otherwise it will be removed. +\n Select Unpublished edges checkbox allows to select subshape edges on +the other objects. +\n Reverse Direction checkbox allows to REVERSE the direction of the object movement along its path. + +Arguments: Name + one or several objects + Translation path. +\n Advanced option: + \ref restore_presentation_parameters_page "Set presentation + parameters and subshapes from arguments". + +\image html transformation13.png + +\image html transformation12.png + +\image html transformation14.png + \n TUI Command: geompy.MakePosition(theObject, theStartLCS, theEndLCS), where \em theObject is a shape, location of which is modified, \em theStartLCS is a location to move the shape from, \em theEndLCS is a location to move the shape to. \n Our TUI Scripts provide you with useful examples of the use -of \ref tui_translation "Transformation Operations". +of \ref tui_modify_location "Transformation Operations". */ diff --git a/doc/salome/gui/GEOM/input/transformation_operations.doc b/doc/salome/gui/GEOM/input/transformation_operations.doc index 875bb9c7c..faa58dc93 100644 --- a/doc/salome/gui/GEOM/input/transformation_operations.doc +++ b/doc/salome/gui/GEOM/input/transformation_operations.doc @@ -20,6 +20,7 @@ factors.
  • Create a simultaneous \subpage multi_rotation_operation_page
  • "Rotation in several directions".
  • Produce a \subpage fillet_operation_page "Fillet" on the selected edges of the object.
  • +
  • Produce a \subpage fillet2d_operation_page "2D Fillet" on the corners of a Planar Face.
  • Produce a \subpage chamfer_operation_page "Chamfer" on the selected edges of the object.
  • diff --git a/doc/salome/gui/GEOM/input/tui_3dsketcher.doc b/doc/salome/gui/GEOM/input/tui_3dsketcher.doc new file mode 100755 index 000000000..c9760fbcf --- /dev/null +++ b/doc/salome/gui/GEOM/input/tui_3dsketcher.doc @@ -0,0 +1,20 @@ +/*! + +\page tui_3dsketcher_page 3D Sketcher + +\code +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a 3D sketcher (wire) of the given points coordinates +sketcher1 = geompy.Make3DSketcher([ 0,0,0, 50,50,50, 0,50,0, 50,0,50, 10,20,100, 0,0,0 ]) + +# add object in the study +id_sketcher1 = geompy.addToStudy(sketcher1,"Sketcher1") + +# display the sketcher +gg.createAndDisplayGO(id_sketcher1) +\endcode + +*/ \ No newline at end of file diff --git a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc index d9c30a23b..89baf140d 100644 --- a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc @@ -132,6 +132,39 @@ id_ellipse = geompy.addToStudy(ellipse,"Ellipse") gg.createAndDisplayGO(id_vector) gg.createAndDisplayGO(id_ellipse) \endcode + +\anchor tui_creation_arc +

    Creation of an Arc

    + +\code +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0., 0., 0.) +p1 = geompy.MakeVertex(100., 0., 0.) +p2 = geompy.MakeVertex(50., 0., 50.) + +# create an arc from a three points +arc1 = geompy.MakeArc(p0, p1, p2) + +# create an arc from a center point, a start point and end point +arc2 = geompy.MakeArcCenter(p0, p1, p2, 1) + +# create an arc from a center point, a major point and minor point +arc3 = geompy.MakeArcOfEllipse(p0, p1, p2) + +# add objects in the study +id_arc1 = geompy.addToStudy(arc1, "Arc 1") +id_arc2 = geompy.addToStudy(arc2, "Arc 2") +id_arc3 = geompy.addToStudy(arc3, "Arc 3") + +# display the arcs +gg.createAndDisplayGO(id_arc1) +gg.createAndDisplayGO(id_arc2) +gg.createAndDisplayGO(id_arc3) +\endcode \anchor tui_creation_curve

    Creation of a Curve

    diff --git a/doc/salome/gui/GEOM/input/tui_transformation_operations.doc b/doc/salome/gui/GEOM/input/tui_transformation_operations.doc index a4863b537..7fd356e7c 100644 --- a/doc/salome/gui/GEOM/input/tui_transformation_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_transformation_operations.doc @@ -115,6 +115,7 @@ v = geompy.MakeVector(p1, p2) height = 35 radius1 = 20 cylinder = geompy.MakeCylinder(p1, v, radius1, height) +circle = geompy.MakeCircle(p2, v, radius1) # create local coordinate systems cs1 = geompy.MakeMarker( 0, 0, 0, 1,0,0, 0,1,0) @@ -122,18 +123,25 @@ cs2 = geompy.MakeMarker(30,40,40, 1,0,0, 0,1,0) # modify the location of the given object position = geompy.MakePosition(cylinder, cs1, cs2) +position2 = geompy.PositionAlongPath(position, circle, 0.75, 1, 1) # add objects in the study id_cs1 = geompy.addToStudy(cs1, "Coordinate system 1") id_cs2 = geompy.addToStudy(cs2, "Coordinate system 2") id_cylinder = geompy.addToStudy(cylinder, "Cylinder") +id_circle = geompy.addToStudy(circle, "Circle") id_position = geompy.addToStudy(position, "Position") +id_position2 = geompy.addToStudy(position2, "PositionAlongPath") # display the results gg.createAndDisplayGO(id_cylinder) gg.setDisplayMode(id_cylinder,1) gg.createAndDisplayGO(id_position) gg.setDisplayMode(id_position,1) +gg.createAndDisplayGO(id_circle) +gg.setDisplayMode(id_circle,1) +gg.createAndDisplayGO(id_position2) +gg.setDisplayMode(id_position2,1) \endcode \anchor tui_mirror @@ -341,6 +349,27 @@ gg.createAndDisplayGO(id_rot2d) gg.setDisplayMode(id_rot2d,1) \endcode +\anchor tui_fillet2d +

    Fillet 2D

    + +\code +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a face in OXY plane +face = geompy.MakeFaceHW(100, 100, 1) +fillet2d = geompy.MakeFillet2D(face, 30, [7, 9]) + +# add objects in the study +id_face = geompy.addToStudy(face,"Face_1") +id_fillet2d = geompy.addToStudy(fillet2d,"Fillet 2D_1") + +# display disks +gg.createAndDisplayGO(id_face) +gg.createAndDisplayGO(id_fillet2d) +\endcode + \anchor tui_fillet

    Fillet

    diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 06d72325d..25e732748 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -795,6 +795,22 @@ module GEOM in GEOM_Object theStartLCS, in GEOM_Object theEndLCS); + /*! + * Modify the Location of the given object by Path, + * \param theObject The object to be displaced. + * \param thePath Wire or Edge along that the object will be translated. + * \param theDistance progress of Path (0 = actual location, 1 = end of path location). + * \param theCopy is a true or false parameter. true is to create a copy, false to move the object. + * \param theCopy is a true or false parameter. true is to reverse direction, false is to move normal direction. + * \return New GEOM_Object, containing the displaced shape. + */ + + GEOM_Object PositionAlongPath (in GEOM_Object theObject, + in GEOM_Object thePath, + in double theDistance, + in boolean theCopy, + in boolean theReverse); + /*! * Recompute the shape from its arguments. * \param theObject The object to be recomputed. @@ -2097,6 +2113,17 @@ module GEOM in GEOM_Object thePnt1, in GEOM_Object thePnt2, in boolean theSense); + + /*! + * Create an arc of ellipse of center C and two points P1 P2. + * \param theCenter Center point of the arc. + * \param thePnt1 Major radius is distance from center to Pnt1. + * \param thePnt2 define a plane and Minor radius as a shortest distance from Pnt2 to vector Center->Pnt1. + * \return New GEOM_Object, containing the created arc. + */ + GEOM_Object MakeArcOfEllipse (in GEOM_Object theCenter, + in GEOM_Object thePnt1, + in GEOM_Object thePnt2); /*! @@ -2155,6 +2182,16 @@ module GEOM * \return New GEOM_Object, containing the created wire. */ GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane); + + /*! + * Create a 3D sketcher, following the numerical description, + * passed through points created by \a theCoordinates argument. \n + * Format of the description string have to be the following: + * + * "Make3DSketcher[x1, y1, z1, x2, y2, z2, ..., xN, yN, zN]" + */ + + GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates); /*! * Create a sketcher (wire or face), following the textual description, @@ -2211,10 +2248,24 @@ module GEOM GEOM_Object MakeFilletFaces (in GEOM_Object theShape, in double theR, in ListOfLong theFaces); + GEOM_Object MakeFilletFacesR1R2 (in GEOM_Object theShape, in double theR1, in double theR2, in ListOfLong theFaces); + + /*! + * Perform a fillet on face of the specified vertexes of the given shape. + * \param theShape Shape, to perform fillet on. + * \param theR Fillet radius. + * \param theVertexes Global indices of vertexes to perform fillet on. + * \note Global index of sub-shape can be obtained, using method + * GEOM_IShapesOperations.GetSubShapeIndex(). + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeFillet2D (in GEOM_Object theShape, + in double theR, + in ListOfLong theVertexes); /*! * Perform a symmetric chamfer on all edges of the given shape. diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index fd54d2bde..4690e7e7e 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -343,6 +343,11 @@ module GEOM GEOM_Object PositionShapeCopy (in GEOM_Object theObject, in GEOM_Object theStartLCS, in GEOM_Object theEndLCS) ; + GEOM_Object PositionAlongPath (in GEOM_Object theObject, + in GEOM_Object thePath, + in double theDistance, + in boolean theCopy, + in boolean theReverse); //-----------------------------------------------------------// // ShapesOperations // @@ -480,6 +485,9 @@ module GEOM in GEOM_Object thePnt1, in GEOM_Object thePnt2, in boolean theSense) ; + GEOM_Object MakeArcOfEllipse (in GEOM_Object theCenter, + in GEOM_Object thePnt1, + in GEOM_Object thePnt2) ; GEOM_Object MakePolyline (in GEOM_List thePoints) ; GEOM_Object MakeSplineBezier (in GEOM_List thePoints) ; GEOM_Object MakeSplineInterpolation (in GEOM_List thePoints) ; @@ -505,6 +513,9 @@ module GEOM in double theR1, in double theR2, in GEOM_List theFaces) ; + GEOM_Object MakeFillet2D (in GEOM_Object theShape, + in double theR, + in GEOM_List theVertexes) ; GEOM_Object MakeChamferAll (in GEOM_Object theShape, in double theD) ; GEOM_Object MakeChamferEdge (in GEOM_Object theShape, diff --git a/resources/3dsketch.png b/resources/3dsketch.png new file mode 100755 index 000000000..f34ec0516 Binary files /dev/null and b/resources/3dsketch.png differ diff --git a/resources/GEOMCatalog.xml.in b/resources/GEOMCatalog.xml.in index 9747c4e20..7bf6f0297 100644 --- a/resources/GEOMCatalog.xml.in +++ b/resources/GEOMCatalog.xml.in @@ -4247,6 +4247,38 @@ + + MakeArcOfEllipse + + + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + thePnt3 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + MakePolyline diff --git a/resources/GEOM_en.xml b/resources/GEOM_en.xml index fd2e4054e..eda6f84a0 100644 --- a/resources/GEOM_en.xml +++ b/resources/GEOM_en.xml @@ -104,6 +104,7 @@ + diff --git a/resources/GEOM_fr.xml b/resources/GEOM_fr.xml index 866184523..66a33d5f7 100644 --- a/resources/GEOM_fr.xml +++ b/resources/GEOM_fr.xml @@ -94,6 +94,7 @@ + diff --git a/resources/Makefile.am b/resources/Makefile.am index 27dbdf8b6..4dd5020f5 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -22,8 +22,7 @@ # -* Makefile *- # Author : Patrick GOLDBRONN (CEA) # Date : 28/06/2001 -# Modified by : Alexander BORODIN (OCN) - autotools usage -# $Header$ +# Modified by : Alexander BORODIN (OCN) - autotools usage # include $(top_srcdir)/adm_local/unix/make_common_starter.am @@ -36,8 +35,11 @@ Plugin \ GEOMDS_Resources \ ImportExport \ ShHealing \ +3dsketch.png \ angle.png \ arc.png \ +arccenter.png \ +arcofellipse.png \ archimede.png \ axisinertia.png \ basicproperties.png \ @@ -84,6 +86,7 @@ eraseall.png \ face_hw.png \ face_vechw.png \ fillet.png \ +fillet2d.png \ filletall.png \ filletedge.png \ filletface.png \ @@ -182,6 +185,7 @@ marker2.png \ marker3.png \ position.png \ position2.png \ +position3.png \ free_bound.png \ point_coord.png \ point3.png \ @@ -203,7 +207,6 @@ free_faces.png \ propagate.png \ redo.png \ undo.png \ -arccenter.png \ glue2.png \ remove_extra_edges.png \ coordsys.png \ diff --git a/resources/arcofellipse.png b/resources/arcofellipse.png new file mode 100755 index 000000000..3f15b6ef9 Binary files /dev/null and b/resources/arcofellipse.png differ diff --git a/resources/fillet2d.png b/resources/fillet2d.png new file mode 100755 index 000000000..a17cef65b Binary files /dev/null and b/resources/fillet2d.png differ diff --git a/resources/position3.png b/resources/position3.png new file mode 100644 index 000000000..301a3bf09 Binary files /dev/null and b/resources/position3.png differ diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index 0bf358452..b2f18c3cd 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -58,6 +58,7 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg( GeometryGUI* theGeometryGUI, QWidget* parent, QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) ); QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC_CENTER" ) ) ); QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC_OF_ELLIPSE" ) ) ); setWindowTitle( tr( "GEOM_ARC_TITLE" ) ); @@ -65,8 +66,7 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg( GeometryGUI* theGeometryGUI, QWidget* parent, mainFrame()->GroupConstructors->setTitle( tr( "GEOM_ARC" ) ); mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton2->setIcon( image1 ); - mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); - mainFrame()->RadioButton3->close(); + mainFrame()->RadioButton3->setIcon( image3 ); Group3Pnts = new DlgRef_3Sel( centralWidget() ); @@ -109,10 +109,30 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg( GeometryGUI* theGeometryGUI, QWidget* parent, Group3Pnts2->CheckButton1->setText( tr( "GEOM_REVERSE" ) ); + Group3Pnts3 = new DlgRef_3Sel( centralWidget() ); + + Group3Pnts3->GroupBox1->setTitle( tr( "GEOM_POINTS" ) ); + Group3Pnts3->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) ); + Group3Pnts3->TextLabel2->setText( tr( "GEOM_POINT_I" ).arg( 1 ) ); + Group3Pnts3->TextLabel3->setText( tr( "GEOM_POINT_I" ).arg( 2 ) ); + + Group3Pnts3->LineEdit1->setReadOnly( true ); + Group3Pnts3->LineEdit2->setReadOnly( true ); + Group3Pnts3->LineEdit3->setReadOnly( true ); + + Group3Pnts3->LineEdit1->setEnabled(true); + Group3Pnts3->LineEdit2->setEnabled(false); + Group3Pnts3->LineEdit3->setEnabled(false); + + Group3Pnts3->PushButton1->setIcon(image2); + Group3Pnts3->PushButton2->setIcon(image2); + Group3Pnts3->PushButton3->setIcon(image2); + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( Group3Pnts ); layout->addWidget( Group3Pnts2 ); + layout->addWidget( Group3Pnts3 ); setHelpFileName( "create_arc_page.html" ); @@ -166,9 +186,17 @@ void BasicGUI_ArcDlg::Init() connect( Group3Pnts2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( Group3Pnts2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( Group3Pnts2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - + connect( Group3Pnts2->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( ReverseSense() ) ); + connect( Group3Pnts3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( Group3Pnts3->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( Group3Pnts3->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + + connect( Group3Pnts3->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( Group3Pnts3->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( Group3Pnts3->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -211,9 +239,6 @@ bool BasicGUI_ArcDlg::ClickOnApply() //================================================================================= void BasicGUI_ArcDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 && getConstructorId() != 1 ) - return; - myEditCurrentArgument->setText( "" ); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); @@ -234,6 +259,12 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); return; break; + case 2: + if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); + return; + break; } } // nbSel == 1 @@ -314,6 +345,23 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() Group3Pnts2->PushButton1->click(); } break; + case 2: + if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) { + myPoint1 = aSelectedObject; + if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) + Group3Pnts3->PushButton2->click(); + } + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) { + myPoint2 = aSelectedObject; + if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) + Group3Pnts3->PushButton3->click(); + } + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) { + myPoint3 = aSelectedObject; + if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) + Group3Pnts3->PushButton1->click(); + } + break; } } @@ -384,6 +432,32 @@ void BasicGUI_ArcDlg::SetEditCurrentArgument() Group3Pnts2->LineEdit3->setEnabled(true); } break; + case 2: + if ( send == Group3Pnts3->PushButton1 ) { + myEditCurrentArgument = Group3Pnts3->LineEdit1; + Group3Pnts3->PushButton2->setDown(false); + Group3Pnts3->PushButton3->setDown(false); + Group3Pnts3->LineEdit1->setEnabled(true); + Group3Pnts3->LineEdit2->setEnabled(false); + Group3Pnts3->LineEdit3->setEnabled(false); + } + else if ( send == Group3Pnts3->PushButton2 ) { + myEditCurrentArgument = Group3Pnts3->LineEdit2; + Group3Pnts3->PushButton1->setDown(false); + Group3Pnts3->PushButton3->setDown(false); + Group3Pnts3->LineEdit1->setEnabled(false); + Group3Pnts3->LineEdit2->setEnabled(true); + Group3Pnts3->LineEdit3->setEnabled(false); + } + else if ( send == Group3Pnts3->PushButton3 ) { + myEditCurrentArgument = Group3Pnts3->LineEdit3; + Group3Pnts3->PushButton1->setDown(false); + Group3Pnts3->PushButton2->setDown(false); + Group3Pnts3->LineEdit1->setEnabled(false); + Group3Pnts3->LineEdit2->setEnabled(false); + Group3Pnts3->LineEdit3->setEnabled(true); + } + break; } myEditCurrentArgument->setFocus(); // SelectionIntoArgument(); @@ -400,7 +474,8 @@ void BasicGUI_ArcDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); if ( send == Group3Pnts->LineEdit1 || send == Group3Pnts->LineEdit2 || send == Group3Pnts->LineEdit3 || - send == Group3Pnts2->LineEdit1 || send == Group3Pnts2->LineEdit2 || send == Group3Pnts2->LineEdit3 ) { + send == Group3Pnts2->LineEdit1 || send == Group3Pnts2->LineEdit2 || send == Group3Pnts2->LineEdit3 || + send == Group3Pnts3->LineEdit1 || send == Group3Pnts3->LineEdit2 || send == Group3Pnts3->LineEdit3 ) { myEditCurrentArgument = send; GEOMBase_Skeleton::LineEditReturnPressed(); } @@ -474,6 +549,14 @@ bool BasicGUI_ArcDlg::isValid( QString& msg ) return false; break; } + case 2: + { + if (Group3Pnts3->LineEdit1->text().trimmed().isEmpty() || + Group3Pnts3->LineEdit2->text().trimmed().isEmpty() || + Group3Pnts3->LineEdit3->text().trimmed().isEmpty()) + return false; + break; + } } return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() && !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ); @@ -506,6 +589,14 @@ bool BasicGUI_ArcDlg::execute( ObjectList& objects ) } break; } + case 2: + { + if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) { + anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeArcOfEllipse( myPoint1, myPoint2, myPoint3 ); + res = true; + } + break; + } } if ( !anObj->_is_nil() ) { objects.push_back( anObj._retn() ); @@ -527,8 +618,9 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes - Group3Pnts2->hide(); Group3Pnts->show(); + Group3Pnts2->hide(); + Group3Pnts3->hide(); Group3Pnts->PushButton1->setDown(true); Group3Pnts->PushButton2->setDown(false); Group3Pnts->PushButton3->setDown(false); @@ -550,6 +642,7 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) Group3Pnts->hide(); Group3Pnts2->show(); + Group3Pnts3->hide(); Group3Pnts2->PushButton1->setDown(true); Group3Pnts2->PushButton2->setDown(false); Group3Pnts2->PushButton3->setDown(false); @@ -564,6 +657,28 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) myEditCurrentArgument = Group3Pnts2->LineEdit1; break; } + case 2: + { + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes + + Group3Pnts->hide(); + Group3Pnts2->hide(); + Group3Pnts3->show(); + Group3Pnts3->PushButton1->setDown(true); + Group3Pnts3->PushButton2->setDown(false); + Group3Pnts3->PushButton3->setDown(false); + Group3Pnts3->LineEdit1->setText( "" ); + Group3Pnts3->LineEdit2->setText( "" ); + Group3Pnts3->LineEdit3->setText( "" ); + Group3Pnts3->LineEdit1->setEnabled(true); + Group3Pnts3->LineEdit2->setEnabled(false); + Group3Pnts3->LineEdit3->setEnabled(false); + myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); + + myEditCurrentArgument = Group3Pnts3->LineEdit1; + break; + } } qApp->processEvents(); @@ -608,6 +723,11 @@ void BasicGUI_ArcDlg::addSubshapesToStudy() objMap[Group3Pnts2->LineEdit2->text()] = myPoint2; objMap[Group3Pnts2->LineEdit3->text()] = myPoint3; break; + case 2: + objMap[Group3Pnts3->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts3->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts3->LineEdit3->text()] = myPoint3; + break; } addSubshapesToFather( objMap ); } diff --git a/src/BasicGUI/BasicGUI_ArcDlg.h b/src/BasicGUI/BasicGUI_ArcDlg.h index 3100b2a61..49828b720 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.h +++ b/src/BasicGUI/BasicGUI_ArcDlg.h @@ -59,6 +59,7 @@ private: DlgRef_3Sel* Group3Pnts; DlgRef_3Sel1Check* Group3Pnts2; + DlgRef_3Sel* Group3Pnts3; private slots: void ClickOnOk(); diff --git a/src/DlgRef/DlgRef.cxx b/src/DlgRef/DlgRef.cxx index e4e078c98..42bb09e08 100644 --- a/src/DlgRef/DlgRef.cxx +++ b/src/DlgRef/DlgRef.cxx @@ -702,6 +702,20 @@ void DlgRef_4Sel1Spin2Check::ShowRows( int fromRow, int toRow, bool toShow ) } } +////////////////////////////////////////// +// DlgRef_4Sel1Spin3Check +////////////////////////////////////////// + +DlgRef_4Sel1Spin3Check::DlgRef_4Sel1Spin3Check( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); +} + +DlgRef_4Sel1Spin3Check::~DlgRef_4Sel1Spin3Check() +{ +} + ////////////////////////////////////////// // DlgRef_6Sel ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.h b/src/DlgRef/DlgRef.h index 005ff9427..d786fe841 100644 --- a/src/DlgRef/DlgRef.h +++ b/src/DlgRef/DlgRef.h @@ -763,6 +763,22 @@ public: void ShowRows( int, int, bool = true ); }; +////////////////////////////////////////// +// DlgRef_4Sel1Spin2Check +////////////////////////////////////////// + +#include "ui_DlgRef_4Sel1Spin3Check_QTD.h" + +class DLGREF_EXPORT DlgRef_4Sel1Spin3Check : public QWidget, + public Ui::DlgRef_4Sel1Spin3Check_QTD +{ + Q_OBJECT + +public: + DlgRef_4Sel1Spin3Check( QWidget* = 0, Qt::WindowFlags = 0 ); + ~DlgRef_4Sel1Spin3Check(); +}; + ////////////////////////////////////////// // DlgRef_6Sel ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.pro b/src/DlgRef/DlgRef.pro index 3a8def56f..1abf89059 100644 --- a/src/DlgRef/DlgRef.pro +++ b/src/DlgRef/DlgRef.pro @@ -78,6 +78,7 @@ HEADERS += DlgRef_3Spin_QTD.h HEADERS += DlgRef_3Spin1Check_QTD.h HEADERS += DlgRef_3Sel3Spin1Check_QTD.h HEADERS += DlgRef_4Sel1Spin2Check_QTD.h +HEADERS += DlgRef_4Sel1Spin3Check_QTD.h HEADERS += DlgRef_SpinBox.h HEADERS += DlgRef_1Sel1Spin.h HEADERS += DlgRef_1Sel2Spin.h diff --git a/src/DlgRef/DlgRef_4Sel1Spin2Check_QTD.ui b/src/DlgRef/DlgRef_4Sel1Spin2Check_QTD.ui index 43217034f..131736af7 100644 --- a/src/DlgRef/DlgRef_4Sel1Spin2Check_QTD.ui +++ b/src/DlgRef/DlgRef_4Sel1Spin2Check_QTD.ui @@ -5,30 +5,18 @@ 0 0 - 131 - 196 + 225 + 306 - + 0 - - 0 - - - 0 - - - 0 - - - 6 - - + 6 @@ -37,44 +25,12 @@ - - 9 - - - 9 - - - 9 - - + 9 - - 6 - - + 6 - - - - - - - - - - - - 0 - 0 - - - - - - - @@ -229,7 +185,43 @@ + + + + + + + + + + + + 0 + 0 + + + + + + + + SpinBox_DX + TextLabel3 + TextLabel5 + TextLabel4 + TextLabel2 + TextLabel1 + PushButton2 + LineEdit5 + LineEdit1 + PushButton5 + PushButton4 + PushButton1 + LineEdit4 + LineEdit2 + CheckButton1 + CheckButton2 @@ -253,7 +245,6 @@ PushButton5 LineEdit5 SpinBox_DX - CheckButton2 CheckButton1 diff --git a/src/DlgRef/DlgRef_4Sel1Spin3Check_QTD.ui b/src/DlgRef/DlgRef_4Sel1Spin3Check_QTD.ui new file mode 100755 index 000000000..4e6e09c64 --- /dev/null +++ b/src/DlgRef/DlgRef_4Sel1Spin3Check_QTD.ui @@ -0,0 +1,265 @@ + + DlgRef_4Sel1Spin3Check_QTD + + + + 0 + 0 + 225 + 306 + + + + + + + + 0 + + + 6 + + + + + + + + + 9 + + + 6 + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + TL3 + + + false + + + + + + + + 0 + 0 + + + + TL5 + + + false + + + + + + + + 0 + 0 + + + + TL4 + + + false + + + + + + + + 0 + 0 + + + + TL2 + + + false + + + + + + + + 0 + 0 + + + + TL1 + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + + + + + + SpinBox_DX + TextLabel3 + TextLabel5 + TextLabel4 + TextLabel2 + TextLabel1 + PushButton2 + LineEdit5 + LineEdit1 + PushButton5 + PushButton4 + PushButton1 + LineEdit4 + LineEdit2 + CheckButton1 + CheckButton2 + + + + + + qPixmapFromMimeSource + + + QtxDoubleSpinBox + QDoubleSpinBox +
    QtxDoubleSpinBox.h
    +
    +
    + + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + PushButton4 + LineEdit4 + PushButton5 + LineEdit5 + SpinBox_DX + CheckButton1 + + + +
    diff --git a/src/DlgRef/Makefile.am b/src/DlgRef/Makefile.am index ca035ed28..3a4606f02 100644 --- a/src/DlgRef/Makefile.am +++ b/src/DlgRef/Makefile.am @@ -83,6 +83,7 @@ UIC_FILES = \ ui_DlgRef_4Sel1List1Check_QTD.h \ ui_DlgRef_4Sel1List_QTD.h \ ui_DlgRef_4Sel1Spin2Check_QTD.h \ + ui_DlgRef_4Sel1Spin3Check_QTD.h \ ui_DlgRef_6Sel_QTD.h \ ui_DlgRef_Skeleton_QTD.h diff --git a/src/EntityGUI/EntityGUI.cxx b/src/EntityGUI/EntityGUI.cxx index 626569ed7..25e0103f6 100644 --- a/src/EntityGUI/EntityGUI.cxx +++ b/src/EntityGUI/EntityGUI.cxx @@ -37,6 +37,7 @@ #include #include "EntityGUI_SketcherDlg.h" // Sketcher +#include "EntityGUI_3DSketcherDlg.h" // Sketcher #include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE //======================================================================= @@ -75,6 +76,9 @@ bool EntityGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) getGeometryGUI()->ActiveWorkingPlane(); aDlg = new EntityGUI_SketcherDlg( getGeometryGUI(), parent ); break; + case 405: // 3D SKETCHER + aDlg = new EntityGUI_3DSketcherDlg( getGeometryGUI(), parent ); + break; case 407: // EXPLODE : use ic aDlg = new EntityGUI_SubShapeDlg( getGeometryGUI(), parent ); break; diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx new file mode 100755 index 000000000..134cbd3cf --- /dev/null +++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx @@ -0,0 +1,629 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : EntityGUI_3DSketcherDlg.cxx +// Author : DMV, OCN +// + +#include "EntityGUI_3DSketcherDlg.h" +#include "EntityGUI_Widgets.h" +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +class Locker +{ +public: + Locker( bool& l ) : myLock( l ) { myLock = true; } + ~Locker() { myLock = false; } +private: + bool& myLock; +}; + +//================================================================================= +// class : EntityGUI_3DSketcherDlg() +// purpose : Constructs a EntityGUI_3DSketcherDlg 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. +//================================================================================= +EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, QWidget* parent, + bool modal, Qt::WindowFlags fl, + const double lineWidth ) + : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ), + myGeometryGUI( theGeometryGUI ), + myLineWidth( lineWidth ) +{ + QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) ); + QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) ); + QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_3DSKETCH" ) ) ); + + setWindowTitle( tr( "GEOM_3DSKETCHER_TITLE" ) ); + + /***************************************************************/ + + mainFrame()->GroupConstructors->setTitle( tr( "GEOM_3DSKETCHER" ) ); + mainFrame()->RadioButton1->setIcon( image3 );; + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->close(); + + GroupType = new DlgRef_3Radio(centralWidget()); + GroupType->GroupBox1->setTitle(tr("GEOM_COORDINATES_TYPE")); + GroupType->RadioButton1->setText(tr("GEOM_SKETCHER_ABS")); + GroupType->RadioButton2->setText(tr("GEOM_SKETCHER_REL")); + GroupType->RadioButton3->close(); + + Group3Spin = new EntityGUI_3Spin( centralWidget() ); + Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) ); + Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) ); + Group3Spin->buttonUndo->setIcon( image1 ); + Group3Spin->buttonRedo->setIcon( image2 ); + Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) ); + Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) ); + Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Z2" ) ); + + buttonOk()->setText( tr( "GEOM_BUT_END_SKETCH" ) ); + buttonApply()->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) ); + + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); + layout->setMargin( 0 ); layout->setSpacing( 6 ); + layout->addWidget( GroupType ); + layout->addWidget( Group3Spin ); + + setHelpFileName( "create_3dsketcher_page.html" ); + + resize(0,0); + Init(); +} + + + +//================================================================================= +// function : ~EntityGUI_3DSketcherDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +EntityGUI_3DSketcherDlg::~EntityGUI_3DSketcherDlg() +{ + myGeomGUI->SetActiveDialogBox( 0 ); +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void EntityGUI_3DSketcherDlg::Init() +{ + myOK = false; + + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + + /* Get setting of step value from file configuration */ + double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 ); + + /* min, max, step and decimals for spin boxes */ + initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY + initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY + initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY + + /* signals and slots connections */ + connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( PointClicked( int ) ) ); + + connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnAddPoint() ) ); + connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) ); + connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ; + + connect( GroupType->RadioButton1, SIGNAL( clicked() ), this, SLOT( TypeClicked() ) ); + connect( GroupType->RadioButton2, SIGNAL( clicked() ), this, SLOT( TypeClicked() ) ); + + connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + + connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); + + connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); + connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + + initName( tr( "GEOM_3DSKETCHER" ) ); + + UpdateButtonsState(); + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); +} + +//================================================================================= +// function : TypeClicked() +// purpose : Radio button management +//================================================================================= +void EntityGUI_3DSketcherDlg::TypeClicked() +{ + bool blocked = Group3Spin->SpinBox_DX->signalsBlocked(); + Group3Spin->SpinBox_DX->blockSignals(true); + Group3Spin->SpinBox_DY->blockSignals(true); + Group3Spin->SpinBox_DZ->blockSignals(true); + // Get setting of step value from file configuration + double x, y, z; + GetLastPoints(x, y, z); + if ( GroupType->RadioButton1->isChecked() ) { // XY + Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) ); + Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) ); + Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Z2" ) ); + Group3Spin->SpinBox_DX->setValue( x + Group3Spin->SpinBox_DX->value() ); + Group3Spin->SpinBox_DY->setValue( y + Group3Spin->SpinBox_DY->value() ); + Group3Spin->SpinBox_DZ->setValue( z + Group3Spin->SpinBox_DZ->value() ); + Group3Spin->buttonApply->setFocus(); + } else if ( GroupType->RadioButton2->isChecked() ) { // DXDY + Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) ); + Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) ); + Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DZ2" ) ); + Group3Spin->SpinBox_DX->setValue( Group3Spin->SpinBox_DX->value() - x ); + Group3Spin->SpinBox_DY->setValue( Group3Spin->SpinBox_DY->value() - y ); + Group3Spin->SpinBox_DZ->setValue( Group3Spin->SpinBox_DZ->value() - z ); + Group3Spin->buttonApply->setFocus(); + } + Group3Spin->SpinBox_DX->blockSignals(blocked); + Group3Spin->SpinBox_DY->blockSignals(blocked); + Group3Spin->SpinBox_DZ->blockSignals(blocked); +} + +//================================================================================= +// function : ClickOnAddPoint() +// purpose : called when the point coordinates is Applyed +//================================================================================= +void EntityGUI_3DSketcherDlg::ClickOnAddPoint() +{ + Locker lock( myOK ); + + double x, y, z; + GetCurrentPoints(x, y, z); + myPointsList.append(x); + myPointsList.append(y); + myPointsList.append(z); + + myRedoList.clear(); + + if ( GroupType->RadioButton2->isChecked() ) { + Group3Spin->SpinBox_DX->setValue( 0.0 ); + Group3Spin->SpinBox_DY->setValue( 0.0 ); + Group3Spin->SpinBox_DZ->setValue( 0.0 ); + } + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); + UpdateButtonsState(); +} + +//================================================================================= +// function : UpdateButtonsState() +// purpose : +//================================================================================= +void EntityGUI_3DSketcherDlg::UpdateButtonsState() +{ + if ( !myPointsList.count() ) + GroupType->RadioButton1->setChecked( true ); + GroupType->RadioButton2->setEnabled( myPointsList.count() > 2 ); + Group3Spin->buttonUndo->setEnabled( myPointsList.count() > 2 ); + Group3Spin->buttonRedo->setEnabled( myRedoList.count() > 2 ); +} + +//================================================================================= +// function : ClickOnUndo() +// purpose : +//================================================================================= +void EntityGUI_3DSketcherDlg::ClickOnUndo() +{ + if (myPointsList.count() > 2) { + double x, y, z; + GetLastPoints(x, y, z); + myRedoList.append(x); + myRedoList.append(y); + myRedoList.append(z); + myPointsList.removeLast(); + myPointsList.removeLast(); + myPointsList.removeLast(); + + UpdateButtonsState(); + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); + } +} + +//================================================================================= +// function : ClickOnRedo() +// purpose : +//================================================================================= +void EntityGUI_3DSketcherDlg::ClickOnRedo() +{ + int count = myRedoList.count(); + if ( count > 2 ) { + myPointsList.append( myRedoList[count-3] ); + myPointsList.append( myRedoList[count-2] ); + myPointsList.append( myRedoList[count-1] ); + myRedoList.removeLast(); + myRedoList.removeLast(); + myRedoList.removeLast(); + + UpdateButtonsState(); + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); + } +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed +//================================================================================= +void EntityGUI_3DSketcherDlg::SelectionIntoArgument() +{ + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + int nbSel = aSelList.Extent(); + if ( nbSel == 1 ) { + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE)) { // Explore the shape if its a local selection + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(aSelList.First(), aMap); + if (aMap.Extent() == 1) + { + int anIndex = aMap(1); + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + } + bool isOk = true; + if ( aShape.ShapeType() != TopAbs_VERTEX ) + isOk = GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX); + if (isOk) { + gp_Pnt aPnt; + if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { + // set coordinates to the Spin Boxes + double aX, aY, aZ; + aX = aPnt.X(); + aY = aPnt.Y(); + aZ = aPnt.Z(); + bool blocked = Group3Spin->SpinBox_DX->signalsBlocked(); + Group3Spin->SpinBox_DX->blockSignals(true); + Group3Spin->SpinBox_DY->blockSignals(true); + Group3Spin->SpinBox_DZ->blockSignals(true); + if ( GroupType->RadioButton1->isChecked() ) { + Group3Spin->SpinBox_DX->setValue( aX ); + Group3Spin->SpinBox_DY->setValue( aY ); + Group3Spin->SpinBox_DZ->setValue( aZ ); + } else if ( GroupType->RadioButton2->isChecked() ) { + double x, y, z; + GetLastPoints(x, y, z); + Group3Spin->SpinBox_DX->setValue( aX - x ); + Group3Spin->SpinBox_DY->setValue( aY - y ); + Group3Spin->SpinBox_DZ->setValue( aZ - z ); + } + Group3Spin->SpinBox_DX->blockSignals(blocked); + Group3Spin->SpinBox_DY->blockSignals(blocked); + Group3Spin->SpinBox_DZ->blockSignals(blocked); + } + } + } + } + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void EntityGUI_3DSketcherDlg::DeactivateActiveDialog() +{ + setEnabled( false ); + globalSelection(); + disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); + myGeomGUI->SetActiveDialogBox( 0 ); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void EntityGUI_3DSketcherDlg::ActivateThisDialog() +{ + myGeomGUI->EmitSignalDeactivateDialog(); + setEnabled( true ); + myGeomGUI->SetActiveDialogBox( this ); + + connect( myGeomGUI->getApp()->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue ) +{ + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void EntityGUI_3DSketcherDlg::enterEvent( QEvent* ) +{ + if ( !mainFrame()->GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr EntityGUI_3DSketcherDlg::createOperation() +{ + return getGeomEngine()->GetICurvesOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool EntityGUI_3DSketcherDlg::isValid( QString& msg ) +{ + return true; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects ) +{ + GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble; + if (!myOK || myPointsList.size() == 0) + aCoordsArray->length(myPointsList.size()+3); + else + aCoordsArray->length(myPointsList.size()); + + int i = 0; + QList::const_iterator it; + for(it = myPointsList.begin(); it != myPointsList.end(); ++it ) { + aCoordsArray[i] = *it; + i++; + } + + if (!myOK || myPointsList.size() == 0) { + double x, y, z; + GetCurrentPoints(x, y, z); + aCoordsArray[i] = x; + aCoordsArray[i+1] = y; + aCoordsArray[i+2] = z; + } + + GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->Make3DSketcher( aCoordsArray ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; +} + +//================================================================================= +// function : initSpinBox() +// purpose : +//================================================================================= + +void EntityGUI_3DSketcherDlg::initSpinBox( QDoubleSpinBox* spinBox, + double min, double max, + double step, int decimals ) +{ + spinBox->setDecimals( decimals ); + spinBox->setRange( min, max ); + spinBox->setSingleStep( step ); +} + +//================================================================================= +// function : SetDoubleSpinBoxStep() +// purpose : Double spin box management +//================================================================================= +void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep( double step ) +{ + Group3Spin->SpinBox_DX->setSingleStep(step); + Group3Spin->SpinBox_DY->setSingleStep(step); + Group3Spin->SpinBox_DZ->setSingleStep(step); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void EntityGUI_3DSketcherDlg::ClickOnOk() +{ + Locker lock( myOK ); + + if ( !onAccept() ) + return; + + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool EntityGUI_3DSketcherDlg::ClickOnApply() +{ + if (myPointsList.count() > 3) { + myPointsList.append(myPointsList[0]); + myPointsList.append(myPointsList[1]); + myPointsList.append(myPointsList[2]); + } + + Locker lock( myOK ); + + if ( !onAccept() ) + return false; + + ClickOnCancel(); + return true; +} + +//================================================================================= +// function : GetLastPoints() +// purpose : return last points from list +//================================================================================= +void EntityGUI_3DSketcherDlg::GetLastPoints(double& x, double& y, double& z) +{ + int count = myPointsList.count(); + x = count > 2 ? myPointsList[count-3] : 0.0; + y = count > 2 ? myPointsList[count-2] : 0.0; + z = count > 2 ? myPointsList[count-1] : 0.0; +} + +//================================================================================= +// function : GetCurrentPoints() +// purpose : returns current points +//================================================================================= +void EntityGUI_3DSketcherDlg::GetCurrentPoints(double& x, double& y, double& z) +{ + if ( GroupType->RadioButton1->isChecked() ) { + x = Group3Spin->SpinBox_DX->value(); + y = Group3Spin->SpinBox_DY->value(); + z = Group3Spin->SpinBox_DZ->value(); + } else { // if (GroupType->RadioButton2->isChecked()) + GetLastPoints(x, y, z); + x += Group3Spin->SpinBox_DX->value(); + y += Group3Spin->SpinBox_DY->value(); + z += Group3Spin->SpinBox_DZ->value(); + } +} + +//================================================================ +// Function : displayPreview +// Purpose : Method for displaying preview of resulting shape +// Redefined from GEOMBase_Helper. +//================================================================ +void EntityGUI_3DSketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object, + const bool append, + const bool activate, + const bool update, + const double lineWidth, + const int displayMode, + const int color ) +{ + // Set color for preview shape + getDisplayer()->SetColor( Quantity_NOC_RED ); + + // set width of displayed shape + getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth ); + + // Disable activation of selection + getDisplayer()->SetToActivate( activate ); + + // Make a reference to GEOM_Object + CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object ); + getDisplayer()->SetName( objStr.in() ); + + // Create wire from applayed object + TopoDS_Shape anApplyedWire, aLastSegment; + if ( !createShapes( object, anApplyedWire, aLastSegment ) ) + return; + + // Build prs + SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire ); + if ( aPrs != 0 && !aPrs->IsNull() ) + GEOMBase_Helper::displayPreview( aPrs, append, update ); + + getDisplayer()->SetColor( Quantity_NOC_VIOLET ); + aPrs = getDisplayer()->BuildPrs( aLastSegment ); + if ( aPrs != 0 && !aPrs->IsNull() ) + GEOMBase_Helper::displayPreview( aPrs, append, update ); + + getDisplayer()->UnsetName(); + + // Enable activation of displayed objects + getDisplayer()->SetToActivate( true ); +} + +//================================================================ +// Function : createShapes +// Purpose : Create applyed wire, and last segment from entry object +//================================================================ +bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject, + TopoDS_Shape& theApplyedWire, + TopoDS_Shape& theLastSegment ) +{ + TopoDS_Shape aShape; + if ( !GEOMBase::GetShape( theObject, aShape ) || + aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) + return false; + + if ( myOK ) { + theApplyedWire = aShape; + return true; + } + + BRepBuilderAPI_MakeWire aBuilder; + TopExp_Explorer anExp( aShape, TopAbs_EDGE ); + while ( 1 ) { + TopoDS_Shape anEdge = anExp.Current(); + anExp.Next(); + if ( anExp.More() ) // i.e. non-last edge + aBuilder.Add( TopoDS::Edge( anEdge ) ); + else { + theLastSegment = anEdge; + break; + } + } + + if ( aBuilder.IsDone() ) + theApplyedWire = aBuilder.Shape(); + + return true; +} diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.h b/src/EntityGUI/EntityGUI_3DSketcherDlg.h new file mode 100755 index 000000000..19cdb327d --- /dev/null +++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.h @@ -0,0 +1,111 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : EntityGUI_3DSketcherDlg.h +// Author : DMV, OCN +// + +#ifndef ENTITYGUI_3DSKETCHERDLG_H +#define ENTITYGUI_3DSKETCHERDLG_H + +#include + +class QDoubleSpinBox; +class EntityGUI_3Spin; +class DlgRef_3Radio; + +#ifndef COORD_MIN +# define COORD_MIN -1e+15 +# define COORD_MAX +1e+15 +# define MAX_NUMBER 100000 +# define DBL_DIGITS_DISPLAY 16 +#endif // COORD_MIN + +//================================================================================= +// class : EntityGUI_Dlg +// purpose : +//================================================================================= +class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2. ); + ~EntityGUI_3DSketcherDlg(); + +protected: + void initSpinBox( QDoubleSpinBox*, + double, double, double = 0.1, + int = 3 ); + + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& ); + +private: + void Init(); + void enterEvent( QEvent* ); + + virtual void displayPreview( GEOM::GEOM_Object_ptr, + const bool = false, + const bool = false, + const bool = true, + const double = -1, + const int = -1, + const int = -1); + + bool createShapes( GEOM::GEOM_Object_ptr, + TopoDS_Shape&, + TopoDS_Shape& ); + +private: + QList myPointsList; + QList myRedoList; + + EntityGUI_3Spin* Group3Spin; + DlgRef_3Radio* GroupType; + + bool myOK; + double myLineWidth; + GeometryGUI* myGeometryGUI; + +private slots: + void ClickOnOk(); + void ClickOnAddPoint(); + bool ClickOnApply(); + // bool isSameAsPrevious(); + void UpdateButtonsState(); + void GetLastPoints(double&, double&, double&); + void GetCurrentPoints(double&, double&, double&); + + void ClickOnUndo(); + void ClickOnRedo(); + + void SelectionIntoArgument(); + void DeactivateActiveDialog(); + void ActivateThisDialog(); + void TypeClicked(); + void ValueChangedInSpinBox( double ); + void SetDoubleSpinBoxStep( double ); +}; + +#endif // ENTITYGUI_SKETCHERDLG_H diff --git a/src/EntityGUI/Makefile.am b/src/EntityGUI/Makefile.am index a949edea6..f54555614 100644 --- a/src/EntityGUI/Makefile.am +++ b/src/EntityGUI/Makefile.am @@ -34,17 +34,20 @@ salomeinclude_HEADERS = \ EntityGUI.h \ EntityGUI_Widgets.h \ EntityGUI_SketcherDlg.h \ + EntityGUI_3DSketcherDlg.h \ EntityGUI_SubShapeDlg.h dist_libEntityGUI_la_SOURCES = \ EntityGUI.cxx \ EntityGUI_Widgets.cxx \ EntityGUI_SketcherDlg.cxx \ + EntityGUI_3DSketcherDlg.cxx \ EntityGUI_SubShapeDlg.cxx MOC_FILES = \ EntityGUI_Widgets_moc.cxx \ EntityGUI_SketcherDlg_moc.cxx \ + EntityGUI_3DSketcherDlg_moc.cxx \ EntityGUI_SubShapeDlg_moc.cxx nodist_libEntityGUI_la_SOURCES = \ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index e724f8b7c..a4c96d025 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -41,6 +41,10 @@ ICON_DLG_ARC_CENTER arccenter.png + + ICON_DLG_ARC_OF_ELLIPSE + arcofellipse.png + ICON_DLG_BASICPROPERTIES basicproperties.png @@ -221,6 +225,10 @@ ICON_DLG_FILLET fillet.png + + ICON_DLG_FILLET_2D + fillet2d.png + ICON_DLG_FILLET_ALL filletall.png @@ -381,6 +389,10 @@ ICON_DLG_POSITION2 position2.png + + ICON_DLG_POSITION3 + position3.png + ICON_DLG_PRISM prism.png @@ -753,6 +765,10 @@ ICO_FILLET fillet.png + + ICO_FILLET_2D + fillet2d.png + ICO_FILLING filling.png @@ -909,6 +925,10 @@ ICO_SKETCH sketch.png + + ICO_3DSKETCH + 3dsketch.png + ICO_SOLID build_solid.png diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index 02bab1ae8..74caf6b0e 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -684,6 +684,10 @@ msgstr "Edge" msgid "GEOM_FACE" msgstr "Face" +#Face +msgid "GEOM_PLANAR_FACE" +msgstr "Planar Face" + #Faces msgid "GEOM_FACES" msgstr "Faces" diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index df22e5db2..7c625e86f 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -611,6 +611,10 @@ Please, select face, shell or solid and try again GEOM_FILLET Fillet + + GEOM_FILLET_2D + Fillet 2D + GEOM_FILLET_ABORT Fillet can't be computed with radius %1 @@ -627,10 +631,18 @@ Please, select face, shell or solid and try again GEOM_FILLET_FACES Fillet On Faces From Shape + + GEOM_FILLET_VERTEXES + Fillet On Vertexes From Face + GEOM_FILLET_TITLE Fillet Construction + + GEOM_FILLET_2D_TITLE + 2D Fillet Construction + GEOM_FILLING Filling @@ -1327,6 +1339,10 @@ Please, select face, shell or solid and try again GEOM_REVERSE Reverse + + GEOM_REVERSE_DIRECTION + Reverse Direction + GEOM_REVERSE_PLANE Reverse the plane normal @@ -1467,6 +1483,10 @@ Please, select face, shell or solid and try again GEOM_SKETCHER_DY2 DY : + + GEOM_SKETCHER_DZ2 + DZ : + GEOM_SKETCHER_EL Element Type @@ -1515,6 +1535,10 @@ Please, select face, shell or solid and try again GEOM_SKETCHER_TITLE Sketch Construction + + GEOM_3DSKETCHER_TITLE + 3D Sketch Construction + GEOM_SKETCHER_TYPE Type @@ -1563,6 +1587,18 @@ Please, select face, shell or solid and try again GEOM_SKETCHER_Y3 Abs. Y : + + GEOM_SKETCHER_Z2 + Z : + + + GEOM_3DSKETCHER + 3D Sketcher + + + GEOM_COORDINATES_TYPE + Coordinates Type + GEOM_SOLID Solid @@ -1599,6 +1635,10 @@ Please, select face, shell or solid and try again GEOM_START_LCS Start LCS + + SELECT_UNPUBLISHED_EDGES + Select unpublished edges + GEOM_STEP Step : @@ -1823,6 +1863,10 @@ Please, select face, shell or solid and try again GEOM_VERTEX Vertex + + GEOM_VERTEXES + Vertexes + GEOM_WATER_DENSITY Water Density : @@ -2131,6 +2175,10 @@ Please, select face, shell or solid and try again MEN_FILLET Fillet + + MEN_FILLET_2D + Fillet 2D + MEN_FILLING Filling @@ -2355,6 +2403,10 @@ Please, select face, shell or solid and try again MEN_SKETCH Sketch + + MEN_3DSKETCH + 3D Sketch + MEN_SOLID Solid @@ -3597,7 +3649,7 @@ Please, select face, shell or solid and try again GEOM_PLANAR_FACE - Planar face + Planar Face GEOM_POLYGON diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 69446fee3..8c1114274 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -441,6 +441,7 @@ void GeometryGUI::OnGUIEvent( int id ) #endif } else if( id == 404 || // MENU ENTITY - SKETCHER + id == 405 || // MENU ENTITY - 3D SKETCHER id == 407 ) { // MENU ENTITY - EXPLODE #ifndef WNT library = getLibrary( "libEntityGUI.so" ); @@ -490,7 +491,8 @@ void GeometryGUI::OnGUIEvent( int id ) id == 505 || // MENU OPERATION - FILLET id == 506 || // MENU OPERATION - CHAMFER id == 507 || // MENU OPERATION - CLIPPING RANGE - id == 508 ) { // MENU OPERATION - GET SHAPES ON SHAPE + id == 508 || // MENU OPERATION - GET SHAPES ON SHAPE + id == 509 ) { // MENU OPERATION - FILLET 2D #ifndef WNT library = getLibrary( "libOperationGUI.so" ); #else @@ -797,6 +799,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 9999, "HEX_SOLID" ); createGeomAction( 404, "SKETCH" ); + createGeomAction( 405, "3DSKETCH" ); createGeomAction( 407, "EXPLODE" ); createGeomAction( 4081, "EDGE" ); @@ -826,6 +829,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 506, "CHAMFER" ); //createGeomAction( 507, "CLIPPING" ); createGeomAction( 508, "GET_SHAPES_ON_SHAPES" ); + createGeomAction( 509, "FILLET_2D" ); createGeomAction( 9998, "MUL_TRANSFORM" ); createGeomAction( 9995, "EXPLODE_BLOCKS" ); @@ -945,6 +949,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( separator(), newEntId, -1 ); createMenu( 404, newEntId, -1 ); + createMenu( 405, newEntId, -1 ); createMenu( separator(), newEntId, -1 ); createMenu( 407, newEntId, -1 ); @@ -979,6 +984,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( 504, operId, -1 ); createMenu( 508, operId, -1 ); createMenu( separator(), operId, -1 ); + createMenu( 509, transId, -1 ); createMenu( 505, transId, -1 ); createMenu( 506, transId, -1 ); //createMenu( 507, transId, -1 ); diff --git a/src/GEOMImpl/GEOMImpl.pro b/src/GEOMImpl/GEOMImpl.pro index 03b27a4b7..87d10eaee 100644 --- a/src/GEOMImpl/GEOMImpl.pro +++ b/src/GEOMImpl/GEOMImpl.pro @@ -108,6 +108,7 @@ SOURCES += GEOMImpl_ArcDriver.cxx SOURCES += GEOMImpl_SplineDriver.cxx SOURCES += GEOMImpl_SketcherDriver.cxx SOURCES += GEOMImpl_FilletDriver.cxx +SOURCES += GEOMImpl_Fillet2dDriver.cxx SOURCES += GEOMImpl_ChamferDriver.cxx SOURCES += GEOMImpl_BooleanDriver.cxx SOURCES += GEOMImpl_PartitionDriver.cxx diff --git a/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx b/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx new file mode 100755 index 000000000..ccf53fdfb --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx @@ -0,0 +1,145 @@ +// Copyright (C) 2005 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 +// + +#include + +#include +#include +#include +#include + +#include + +// OCCT Includes +#include +#include +#include +#include +#include +#include + +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_3DSketcherDriver::GetID() +{ + static Standard_GUID a3DSketcherDriver("FF2BBB54-5D24-4df3-210B-3A678263EA26"); + return a3DSketcherDriver; +} + + +//======================================================================= +//function : GEOMImpl_3DSketcherDriver +//purpose : +//======================================================================= +GEOMImpl_3DSketcherDriver::GEOMImpl_3DSketcherDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_I3DSketcher aCI (aFunction); + + TopoDS_Shape aShape; + + Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates(); + + BRepBuilderAPI_MakePolygon aMakePoly; + int anArrayLength = aCoordsArray->Length(); + double x, y, z; + gp_Pnt aPnt; + for (int i = 0; i <=(anArrayLength - 3); i+=3) { + x = aCoordsArray->Value(i+1); + y = aCoordsArray->Value(i+2); + z = aCoordsArray->Value(i+3); + aPnt = gp_Pnt(x, y, z); + aMakePoly.Add(aPnt); + } + if ( anArrayLength == 3) { // Only Start Point + BRepBuilderAPI_MakeVertex mkVertex (aPnt); + aShape = mkVertex.Shape(); + } + else { // Make Wire + if (aCoordsArray->Value(1) == x && aCoordsArray->Value(2) == y && aCoordsArray->Value(3) == z) + aMakePoly.Close(); + + if (aMakePoly.IsDone()) + aShape = aMakePoly.Wire(); + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + log.SetTouched(Label()); + return 1; +} + + +//======================================================================= +//function : GEOMImpl_3DSketcherDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_3DSketcherDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_3DSketcherDriver", + sizeof(GEOMImpl_3DSketcherDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_3DSketcherDriver) Handle(GEOMImpl_3DSketcherDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_3DSketcherDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_3DSketcherDriver))) { + _anOtherObject = Handle(GEOMImpl_3DSketcherDriver)((Handle(GEOMImpl_3DSketcherDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_3DSketcherDriver.hxx b/src/GEOMImpl/GEOMImpl_3DSketcherDriver.hxx new file mode 100755 index 000000000..f0f2476f8 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_3DSketcherDriver.hxx @@ -0,0 +1,158 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : GEOMImpl_3DSketcherDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_3DSketcherDriver_HeaderFile +#define _GEOMImpl_3DSketcherDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_3DSketcherDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_3DSketcherDriver); + +class Handle(GEOMImpl_3DSketcherDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_3DSketcherDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_3DSketcherDriver)(const Handle(GEOMImpl_3DSketcherDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_3DSketcherDriver)(const GEOMImpl_3DSketcherDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_3DSketcherDriver)& operator=(const Handle(GEOMImpl_3DSketcherDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_3DSketcherDriver)& operator=(const GEOMImpl_3DSketcherDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_3DSketcherDriver* operator->() + { + return (GEOMImpl_3DSketcherDriver *)ControlAccess(); + } + + GEOMImpl_3DSketcherDriver* operator->() const + { + return (GEOMImpl_3DSketcherDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_3DSketcherDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_3DSketcherDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_3DSketcherDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_3DSketcherDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_3DSketcherDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_3DSketcherDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_3DSketcherDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_3DSketcherDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ArcDriver.cxx b/src/GEOMImpl/GEOMImpl_ArcDriver.cxx index d8789a7ef..ad099022f 100644 --- a/src/GEOMImpl/GEOMImpl_ArcDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ArcDriver.cxx @@ -37,12 +37,16 @@ #include #include +#include +#include #include #include #include #include #include +#include #include +#include #include "utilities.h" @@ -78,7 +82,7 @@ Standard_Integer GEOMImpl_ArcDriver::Execute(TFunction_Logbook& log) const Standard_Integer aType = aFunction->GetType(); TopoDS_Shape aShape; - if ((aType == CIRC_ARC_THREE_PNT) || (aType == CIRC_ARC_CENTER)) + if ((aType == CIRC_ARC_THREE_PNT) || (aType == CIRC_ARC_CENTER) || (aType == ELLIPSE_ARC_CENTER_TWO_PNT)) { Handle(GEOM_Function) aRefPoint1 = aCI.GetPoint1(); Handle(GEOM_Function) aRefPoint2 = aCI.GetPoint2(); @@ -108,9 +112,7 @@ Standard_Integer GEOMImpl_ArcDriver::Execute(TFunction_Logbook& log) const { GC_MakeArcOfCircle arc (aP1, aP2, aP3); aShape = BRepBuilderAPI_MakeEdge(arc).Edge(); - } - else // CIRC_ARC_CENTER - { + } else if ( aType == CIRC_ARC_CENTER ) { // CIRC_ARC_CENTER Standard_Boolean sense = aCI.GetSense(); Standard_Real aRad = aP1.Distance(aP2); @@ -126,9 +128,29 @@ Standard_Integer GEOMImpl_ArcDriver::Execute(TFunction_Logbook& log) const GC_MakeArcOfCircle arc (aGeomCirc->Circ(), aP2, aP3, Standard_True); aShape = BRepBuilderAPI_MakeEdge(arc).Edge(); + } else if ( aType == ELLIPSE_ARC_CENTER_TWO_PNT ) { // ELLIPSE_ARC_CENTER_TWO_PNT + if ( aP1.Distance(aP2) <= aP1.Distance(aP3) ) { + // Standard_ConstructionError::Raise("Arc creation aborted: the distance from Center Point to Point 1 needs to be bigger than the distance from Center Point to Point 2"); + cout << "aP1.Distance(aP2) <= aP1.Distance(aP3)" << endl; + gp_Pnt aTmpP = aP2; + aP2 = aP3; + aP3 = aTmpP; + } + + GC_MakeEllipse ellipse (aP2, aP3, aP1); + Handle(Geom_Ellipse) aGeomEllipse = ellipse.Value(); + + gp_Vec aV1 (aP1, aP2); + gp_Vec aV2 (aP1, aP3); + + double alpha = fabs(aV1.Angle(aV2)); + + GC_MakeArcOfEllipse arc (aGeomEllipse->Elips(), aP2, aP3, Standard_True); + aShape = BRepBuilderAPI_MakeEdge(arc).Edge(); } } - } else { + } + else { } if (aShape.IsNull()) return 0; diff --git a/src/GEOMImpl/GEOMImpl_Fillet2dDriver.cxx b/src/GEOMImpl/GEOMImpl_Fillet2dDriver.cxx new file mode 100755 index 000000000..f7f2050ae --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Fillet2dDriver.cxx @@ -0,0 +1,152 @@ +// Copyright (C) 2005 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 +// + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_Fillet2dDriver::GetID() +{ + static Standard_GUID aFillet2dDriver("FF1AAB41-2A14-4df2-581B-3A568163BA46"); + return aFillet2dDriver; +} + + +//======================================================================= +//function : GEOMImpl_Fillet2dDriver +//purpose : +//======================================================================= +GEOMImpl_Fillet2dDriver::GEOMImpl_Fillet2dDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Fillet2dDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IFillet2d aCI (aFunction); + + TopoDS_Shape aShape; + + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + TopoDS_Face aFaceShape = TopoDS::Face(aRefShape->GetValue()); + + if (aFaceShape.ShapeType() != TopAbs_FACE) + Standard_ConstructionError::Raise("Wrong arguments: two faces must be given"); + + BRepFilletAPI_MakeFillet2d fillet2d (aFaceShape); + + int aLen = aCI.GetLength(); + int ind = 1; + double rad = aCI.GetR(); + for (; ind <= aLen; ind++) { + TopoDS_Shape aShapeVertex; + if (GEOMImpl_ILocalOperations::GetSubShape + (aFaceShape, aCI.GetVertex(ind), aShapeVertex)) { + fillet2d.AddFillet(TopoDS::Vertex(aShapeVertex), rad); + } + } + + fillet2d.Build(); + if (!fillet2d.IsDone()) { + StdFail_NotDone::Raise("2D Fillet can't be computed on the given shape with the given radius"); + } + aShape = fillet2d.Shape(); + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_Fillet2dDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_Fillet2dDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_Fillet2dDriver", + sizeof(GEOMImpl_Fillet2dDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_Fillet2dDriver) Handle(GEOMImpl_Fillet2dDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_Fillet2dDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_Fillet2dDriver))) { + _anOtherObject = Handle(GEOMImpl_Fillet2dDriver)((Handle(GEOMImpl_Fillet2dDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_Fillet2dDriver.hxx b/src/GEOMImpl/GEOMImpl_Fillet2dDriver.hxx new file mode 100755 index 000000000..a5448db66 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Fillet2dDriver.hxx @@ -0,0 +1,158 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : GEOMImpl_Fillet2dDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_Fillet2dDriver_HeaderFile +#define _GEOMImpl_Fillet2dDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_Fillet2dDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_Fillet2dDriver); + +class Handle(GEOMImpl_Fillet2dDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_Fillet2dDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_Fillet2dDriver)(const Handle(GEOMImpl_Fillet2dDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_Fillet2dDriver)(const GEOMImpl_Fillet2dDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_Fillet2dDriver)& operator=(const Handle(GEOMImpl_Fillet2dDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_Fillet2dDriver)& operator=(const GEOMImpl_Fillet2dDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_Fillet2dDriver* operator->() + { + return (GEOMImpl_Fillet2dDriver *)ControlAccess(); + } + + GEOMImpl_Fillet2dDriver* operator->() const + { + return (GEOMImpl_Fillet2dDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_Fillet2dDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_Fillet2dDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_Fillet2dDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_Fillet2dDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_Fillet2dDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_Fillet2dDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_Fillet2dDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_Fillet2dDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_Gen.cxx b/src/GEOMImpl/GEOMImpl_Gen.cxx index 6e3dd0111..b01b3f88a 100644 --- a/src/GEOMImpl/GEOMImpl_Gen.cxx +++ b/src/GEOMImpl/GEOMImpl_Gen.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -102,6 +104,7 @@ GEOMImpl_Gen::GEOMImpl_Gen() TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PolylineDriver::GetID(), new GEOMImpl_PolylineDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SplineDriver::GetID(), new GEOMImpl_SplineDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SketcherDriver::GetID(), new GEOMImpl_SketcherDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_3DSketcherDriver::GetID(), new GEOMImpl_3DSketcherDriver()); // 3D Primitives TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BoxDriver::GetID(), new GEOMImpl_BoxDriver()); @@ -131,6 +134,7 @@ GEOMImpl_Gen::GEOMImpl_Gen() // Local Operations TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ChamferDriver::GetID(), new GEOMImpl_ChamferDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FilletDriver::GetID(), new GEOMImpl_FilletDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_Fillet2dDriver::GetID(), new GEOMImpl_Fillet2dDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArchimedeDriver::GetID(), new GEOMImpl_ArchimedeDriver()); // Geometrical Transformations, Offset, Scale diff --git a/src/GEOMImpl/GEOMImpl_I3DSketcher.hxx b/src/GEOMImpl/GEOMImpl_I3DSketcher.hxx new file mode 100755 index 000000000..dc4ea30f6 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_I3DSketcher.hxx @@ -0,0 +1,43 @@ +// Copyright (C) 2005 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 +// +//NOTE: This is an interface to a function for the Sketcher creation. + + +#include "GEOM_Function.hxx" + +#include + +#define SKETCH_ARG_COORDS 1 + +class GEOMImpl_I3DSketcher +{ + public: + + GEOMImpl_I3DSketcher(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetCoordinates(const Handle(TColStd_HArray1OfReal)& theValue) + { _func->SetRealArray(SKETCH_ARG_COORDS, theValue); } + + Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SKETCH_ARG_COORDS); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index 8d71452a5..6a6b8f9ef 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -23,6 +23,8 @@ #include +#include + #include #include @@ -34,6 +36,7 @@ #include #include #include +#include #include #include @@ -41,6 +44,7 @@ #include #include #include +#include #include "utilities.h" @@ -511,6 +515,67 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Objec return anArc; } +//============================================================================= +/*! + * MakeArcOfEllipse + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Circle Arc object + Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC); + + //Add a new Circle Arc function + Handle(GEOM_Function) aFunction = + anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL; + GEOMImpl_IArc aCI (aFunction); + + Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction(); + + + if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL; + + aCI.SetPoint1(aRefPnt1); + aCI.SetPoint2(aRefPnt2); + aCI.SetPoint3(aRefPnt3); + + //Compute the Arc value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Arc driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")"; + + SetErrorCode(OK); + return anArc; +} + //============================================================================= /*! * MakeSplineBezier @@ -709,6 +774,73 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom return aSketcher; } +//============================================================================= +/*! + * Make3DSketcher + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (list theCoordinates) +{ + SetErrorCode(KO); + + //Add a new Sketcher object + Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER); + + //Add a new Sketcher function + Handle(GEOM_Function) aFunction = + a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL; + + GEOMImpl_I3DSketcher aCI (aFunction); + + int nbOfCoords = 0; + list::iterator it = theCoordinates.begin(); + for (; it != theCoordinates.end(); it++) + nbOfCoords++; + + Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords); + + it = theCoordinates.begin(); + int ind = 1; + for (; it != theCoordinates.end(); it++, ind++) + aCoordsArray->SetValue(ind, *it); + + aCI.SetCoordinates(aCoordsArray); + + //Compute the Sketcher value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("3D Sketcher driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump pd (aFunction); + pd << a3DSketcher << " = geompy.Make3DSketcher(["; + + it = theCoordinates.begin(); + pd << (*it++); + while (it != theCoordinates.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return a3DSketcher; +} + //============================================================================= /*! * MakeSketcherOnPlane diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx index 104418ec4..7380a0977 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx @@ -62,11 +62,16 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { Handle(GEOM_Object) thePnt3, bool theSense); + Standard_EXPORT Handle(GEOM_Object) MakeArcOfEllipse (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3); + Standard_EXPORT Handle(GEOM_Object) MakeSplineBezier (list thePoints); Standard_EXPORT Handle(GEOM_Object) MakeSplineInterpolation (list thePoints); Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand, list theWorkingPlane); + Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (list theCoordinates); Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand, Handle(GEOM_Object) theWorkingPlane); }; diff --git a/src/GEOMImpl/GEOMImpl_IFillet2d.hxx b/src/GEOMImpl/GEOMImpl_IFillet2d.hxx new file mode 100755 index 000000000..ba67a6a18 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IFillet2d.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2005 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 +// +//NOTE: This is an interface to a function for the Fillet2d and creation. + + +#include "GEOM_Function.hxx" + +#define FILLET2D_ARG_SH 1 +#define FILLET2D_ARG_R 2 +#define FILLET2D_ARG_LENG 3 +#define FILLET2D_ARG_LAST 4 + +class GEOMImpl_IFillet2d +{ + public: + + GEOMImpl_IFillet2d(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShape(Handle(GEOM_Function) theRef) { _func->SetReference(FILLET2D_ARG_SH, theRef); } + Handle(GEOM_Function) GetShape() { return _func->GetReference(FILLET2D_ARG_SH); } + + void SetR(double theR) { _func->SetReal(FILLET2D_ARG_R, theR); } + void SetLength(int theLen) { _func->SetInteger(FILLET2D_ARG_LENG, theLen); } + void SetVertex(int theInd, int theVertex) + { _func->SetInteger(FILLET2D_ARG_LAST + theInd, theVertex); } + + double GetR() { return _func->GetReal(FILLET2D_ARG_R); } + int GetLength() { return _func->GetInteger(FILLET2D_ARG_LENG); } + int GetVertex(int theInd) { return _func->GetInteger(FILLET2D_ARG_LAST + theInd); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx index 36109f527..9e552229a 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx @@ -29,9 +29,11 @@ #include #include +#include #include #include +#include #include #include @@ -410,6 +412,75 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2 return aFillet; } +//============================================================================= +/*! + * MakeFillet2D + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D + (Handle(GEOM_Object) theShape, double theR, std::list theVertexes) +{ + SetErrorCode(KO); + + //Add a new Fillet object + Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D); + + //Add a new Fillet function + Handle(GEOM_Function) aFunction = + aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL; + + GEOMImpl_IFillet2d aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetR(theR); + int aLen = theVertexes.size(); + aCI.SetLength(aLen); + + int ind = 1; + std::list::iterator it = theVertexes.begin(); + for (; it != theVertexes.end(); it++, ind++) { + aCI.SetVertex(ind, (*it)); + } + + //Compute the Fillet value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("2D Fillet driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump pd (aFunction); + pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape + << ", " << theR << ", ["; + + it = theVertexes.begin(); + pd << (*it++); + while (it != theVertexes.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aFillet2D; +} + //============================================================================= /*! * MakeChamferAll diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx index b973caa04..15acc6eaf 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx @@ -46,6 +46,8 @@ class GEOMImpl_ILocalOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeFilletFacesR1R2 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list theFaces); + Standard_EXPORT Handle(GEOM_Object) MakeFillet2D (Handle(GEOM_Object) theShape, double theR, + std::list theVertexes); Standard_EXPORT Handle(GEOM_Object) MakeChamferAll (Handle(GEOM_Object) theShape, double theD); Standard_EXPORT Handle(GEOM_Object) MakeChamferEdge (Handle(GEOM_Object) theShape, diff --git a/src/GEOMImpl/GEOMImpl_IPosition.hxx b/src/GEOMImpl/GEOMImpl_IPosition.hxx index b2aafe56c..5d42d5d92 100644 --- a/src/GEOMImpl/GEOMImpl_IPosition.hxx +++ b/src/GEOMImpl/GEOMImpl_IPosition.hxx @@ -23,9 +23,12 @@ // #include "GEOM_Function.hxx" -#define POSITION_ARG_SHAPE 1 +#define POSITION_ARG_SHAPE 1 #define POSITION_ARG_START_LCS 2 -#define POSITION_ARG_END_LCS 3 +#define POSITION_ARG_END_LCS 3 +#define POSITION_ARG_PATH 5 +#define POSITION_ARG_DISTANCE 6 +#define POSITION_ARG_REVERSE 7 class GEOMImpl_IPosition { @@ -47,6 +50,17 @@ class GEOMImpl_IPosition Handle(GEOM_Function) GetEndLCS() { return _func->GetReference(POSITION_ARG_END_LCS); } + void SetPath(Handle(GEOM_Function) thePath) { _func->SetReference(POSITION_ARG_PATH, thePath); } + + Handle(GEOM_Function) GetPath() { return _func->GetReference(POSITION_ARG_PATH); } + + void SetDistance(double theDistance) { _func->SetReal(POSITION_ARG_DISTANCE, theDistance); } + + double GetDistance() { return _func->GetReal(POSITION_ARG_DISTANCE); } + + void SetReverse(bool theReverse) { _func->SetReal(POSITION_ARG_REVERSE, theReverse); } + bool GetReverse() { return _func->GetReal(POSITION_ARG_REVERSE); } + private: Handle(GEOM_Function) _func; diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index 673b1fb0d..dd08ea611 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -1336,6 +1336,75 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy return aCopy; } +//============================================================================= +/*! + * PositionAlongPath + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath, + double theDistance, bool theCopy, bool theReverse) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePath.IsNull()) return NULL; + + Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); + if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position + + //Add a position function + Handle(GEOM_Function) aFunction; + Handle(GEOM_Object) aCopy; + + if (theCopy) { + aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH); + } + else + aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL; + + GEOMImpl_IPosition aTI (aFunction); + aTI.SetShape(anOriginal); + aTI.SetPath(thePath->GetLastFunction()); + aTI.SetDistance(theDistance); + aTI.SetReverse(theReverse); + + //Compute the position + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Position driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + if (theCopy) { + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.PositionAlongPath(" + << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")"; + SetErrorCode(OK); + return aCopy; + } + + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionAlongPath(" + << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")"; + + SetErrorCode(OK); + return theObject; +} + //============================================================================= /*! * Rotate diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx index 0cde70037..99c52595e 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx @@ -119,6 +119,12 @@ class GEOMImpl_ITransformOperations : public GEOM_IOperations Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS); + Standard_EXPORT Handle(GEOM_Object) PositionAlongPath (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePath, + double theDistance, + bool theCopy, + bool theReverse); + Standard_EXPORT Handle(GEOM_Object) Rotate (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle); diff --git a/src/GEOMImpl/GEOMImpl_PositionDriver.cxx b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx index a6688c07b..2bdec65f3 100644 --- a/src/GEOMImpl/GEOMImpl_PositionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx @@ -30,19 +30,33 @@ // OCCT Includes #include +#include +#include #include +#include +#include #include #include #include +#include +#include #include #include +#include #include #include +#include #include #include +#include +#include +#include +#include #include #include +#include +#include //======================================================================= //function : GetID @@ -131,6 +145,183 @@ Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False); aShape = aBRepTrsf.Shape(); } + else if (aType == POSITION_ALONG_PATH) { + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + Handle(GEOM_Function) aPathShape = aCI.GetPath(); + double aValue = aCI.GetDistance(); + bool aReversed = aCI.GetReverse(); + + TopoDS_Shape aShapeBase = aRefShape->GetValue(); + TopoDS_Shape aPath = aPathShape->GetValue(); + + if (aShapeBase.IsNull() || aPath.IsNull()) + return 0; + + //Get a Center Of Mass Of Base Object + GProp_GProps aSystem; + gp_Pnt aCenterMass; + if (aShapeBase.ShapeType() == TopAbs_VERTEX) { + aCenterMass = BRep_Tool::Pnt(TopoDS::Vertex(aShapeBase)); + } else if (aShapeBase.ShapeType() == TopAbs_EDGE || aShapeBase.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties(aShapeBase, aSystem); + aCenterMass = aSystem.CentreOfMass(); + } else if (aShapeBase.ShapeType() == TopAbs_FACE || aShapeBase.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(aShapeBase, aSystem); + aCenterMass = aSystem.CentreOfMass(); + } else { + BRepGProp::VolumeProperties(aShapeBase, aSystem); + aCenterMass = aSystem.CentreOfMass(); + } + + TopoDS_Shape aTrimmedPath; + gp_Trsf aTrsf; + Handle(Geom_Curve) aCurve; + Standard_Real aFirst =0.,aLast=0.; + Standard_Real aParam = 0.; + Standard_Real aLength = 0.; + + gp_Pnt aPFirst, aPLast; + + if ( aPath.ShapeType() == TopAbs_EDGE ) { // The Path is Edge + TopoDS_Edge anEdge = TopoDS::Edge(aPath); + + BRep_Tool::Range(anEdge,aFirst,aLast); + aCurve = BRep_Tool::Curve(anEdge,aFirst,aLast); + if (aReversed) + aCurve = aCurve->Reversed(); + + aCurve->D0(aFirst, aPFirst); + aCurve->D0(aLast, aPLast); + + // Translate a CenterMass of Base Shape to the start of the path + if ( !aPFirst.IsEqual(aCenterMass, gp::Resolution()) ) { + gp_Trsf aCurTrsf; + aCurTrsf.SetTranslation(aCenterMass, aPFirst); + aTrsf.PreMultiply(aCurTrsf); + } + aParam = aFirst + aValue*(aLast - aFirst); // Calculate parameter + } else if ( aPath.ShapeType() == TopAbs_WIRE ) { // The path Shape is Wire + TopoDS_Wire aWire = TopoDS::Wire(aPath); + + // fix edges order + Handle(ShapeFix_Wire) aFixWire = new ShapeFix_Wire; + aFixWire->Load(aWire); + aFixWire->FixReorder(); + aWire = aFixWire->Wire(); + + TopExp_Explorer ex; + TopTools_SequenceOfShape Edges; + Standard_Real nbEdges = 0.; + BRepTools_WireExplorer aWE (aWire); + for (; aWE.More(); aWE.Next(), nbEdges++) // Explore a Wire on Edges + Edges.Append(aWE.Current()); + + Standard_Real aSummOfLen =0.; + Standard_Real aCurLen =0.; + GeomAdaptor_Curve aAdC; + + for(int i=1; i<=Edges.Length(); i++) { // Calculate summary Lenght of edges + TopoDS_Edge anEdge = TopoDS::Edge(Edges.Value(i)); + BRep_Tool::Range(anEdge,aFirst,aLast); + aCurve = BRep_Tool::Curve(anEdge,aFirst,aLast); + aAdC.Load(aCurve,aFirst,aLast); + aCurLen = GCPnts_AbscissaPoint::Length(aAdC,aFirst,aLast); + aSummOfLen += aCurLen; + } + + // Move BaseShape to the Start Of the Curve + TopoDS_Edge anEdge; + if (!aReversed) + anEdge = TopoDS::Edge(Edges.Value(1)); + else + anEdge = TopoDS::Edge(Edges.Value(Edges.Length())); + + BRep_Tool::Range(anEdge,aFirst,aLast); + aCurve = BRep_Tool::Curve(anEdge,aFirst,aLast); + aCurve->D0(aFirst, aPFirst); + aCurve->D0(aLast, aPLast); + if ( !aPFirst.IsEqual(aCenterMass, gp::Resolution()) ) { + gp_Trsf aCurTrsf; + if (aReversed && anEdge.Orientation() == TopAbs_FORWARD) + aPFirst = aPLast; + + aCurTrsf.SetTranslation(aCenterMass, aPFirst); + aTrsf.PreMultiply(aCurTrsf); + } + + Standard_Real aWireLen = aSummOfLen*aValue; + aSummOfLen = 0; + for(int i=1; i<=Edges.Length(); i++) { + TopoDS_Edge anEdge; + if (!aReversed) + anEdge = TopoDS::Edge(Edges.Value(i)); + else + anEdge = TopoDS::Edge(Edges.Value(Edges.Length() - i + 1)); + + aCurve = BRep_Tool::Curve(anEdge,aFirst,aLast); + BRep_Tool::Range(anEdge,aFirst,aLast); + + if (!aReversed && anEdge.Orientation() == TopAbs_REVERSED) + aCurve = aCurve->Reversed(); + + if (aReversed && anEdge.Orientation() == TopAbs_FORWARD) + aCurve = aCurve->Reversed(); + + aAdC.Load(aCurve,aFirst,aLast); + aCurLen = GCPnts_AbscissaPoint::Length(aAdC,aFirst,aLast); + + if ( aWireLen > (aSummOfLen + aCurLen) ) { // Transform a Base object along this Edge + aSummOfLen += aCurLen; + gp_Pnt aP1, aP2; + gp_Vec aStartVec1, aStartVec2, aDestVec1, aDestVec2; + aCurve->D2(aFirst, aP1, aStartVec1, aStartVec2 ); + aCurve->D2(aLast, aP2, aDestVec1, aDestVec2 ); + gp_Trsf aCurTrsf; + if (aStartVec2.Magnitude() > gp::Resolution() && aDestVec2.Magnitude() > gp::Resolution()) { + gp_Ax3 aStartAx3(aP1, aStartVec1, aStartVec2); + gp_Ax3 aDestAx3(aP2, aDestVec1, aDestVec2); + aCurTrsf.SetDisplacement(aStartAx3, aDestAx3); + } else + aCurTrsf.SetTranslation(aP1, aP2); + + aTrsf.PreMultiply(aCurTrsf); + } + else { + aLength = aWireLen - aSummOfLen; + GCPnts_AbscissaPoint anAbsc(aAdC,aLength,aFirst); + if(anAbsc.IsDone()) + aParam = anAbsc.Parameter(); + break; + } + } + } else + return 0; // Unknown Type + + gp_Trsf aCurTrsf; + gp_Pnt aP1, aP2; + gp_Vec aStartVec1, aStartVec2, aDestVec1, aDestVec2; + aCurve->D2(aFirst, aP1, aStartVec1, aStartVec2 ); + aCurve->D2(aParam, aP2, aDestVec1, aDestVec2 ); + + if (aStartVec2.Magnitude() > gp::Resolution() && aDestVec2.Magnitude() > gp::Resolution()) { + gp_Ax3 aStartAx3(aP1, aStartVec1, aStartVec2); + gp_Ax3 aDestAx3(aP2, aDestVec1, aDestVec2); + aCurTrsf.SetDisplacement(aStartAx3, aDestAx3); + } else + aCurTrsf.SetTranslation(aP1, aP2); + + aTrsf.PreMultiply(aCurTrsf); + + if ( !aPFirst.IsEqual(aCenterMass, gp::Resolution()) ) { + gp_Trsf aCurTrsf; + aCurTrsf.SetTranslation(aPFirst, aCenterMass); + aTrsf.PreMultiply(aCurTrsf); + } + + // Perform transformation + BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False); + aShape = aBRepTrsf.Shape(); + } else return 0; diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 0c5f1d577..49cf5542f 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -47,8 +47,9 @@ #define GEOM_ELLIPSE 18 #define GEOM_CIRC_ARC 19 -#define GEOM_FILLET 20 -#define GEOM_CHAMFER 21 +#define GEOM_FILLET 20 +#define GEOM_FILLET_2D 45 +#define GEOM_CHAMFER 21 #define GEOM_EDGE 22 #define GEOM_WIRE 23 @@ -87,6 +88,9 @@ #define GEOM_SHAPES_ON_SHAPE 42 +#define GEOM_ELLIPSE_ARC 43 + +#define GEOM_3DSKETCHER 44 //GEOM_Function types @@ -153,6 +157,7 @@ #define POSITION_SHAPE_COPY 2 #define POSITION_SHAPE_FROM_GLOBAL 3 #define POSITION_SHAPE_FROM_GLOBAL_COPY 4 +#define POSITION_ALONG_PATH 5 #define TORUS_RR 1 #define TORUS_PNT_VEC_RR 2 @@ -215,8 +220,9 @@ #define ELLIPSE_PNT_VEC_RR 1 -#define CIRC_ARC_THREE_PNT 1 -#define CIRC_ARC_CENTER 2 +#define CIRC_ARC_THREE_PNT 1 +#define CIRC_ARC_CENTER 2 +#define ELLIPSE_ARC_CENTER_TWO_PNT 3 #define FILLET_SHAPE_ALL 1 #define FILLET_SHAPE_EDGES 2 @@ -224,6 +230,8 @@ #define FILLET_SHAPE_EDGES_2R 4 #define FILLET_SHAPE_FACES_2R 5 +#define FILLET_2D_SHAPE_VERTEXES 1 + #define CHAMFER_SHAPE_ALL 1 #define CHAMFER_SHAPE_EDGE 2 #define CHAMFER_SHAPE_FACES 3 diff --git a/src/GEOMImpl/Makefile.am b/src/GEOMImpl/Makefile.am index 91224152a..eb02b2929 100644 --- a/src/GEOMImpl/Makefile.am +++ b/src/GEOMImpl/Makefile.am @@ -56,11 +56,13 @@ salomeinclude_HEADERS = \ GEOMImpl_ISpline.hxx \ GEOMImpl_IEllipse.hxx \ GEOMImpl_IFillet.hxx \ + GEOMImpl_IFillet2d.hxx \ GEOMImpl_IChamfer.hxx \ GEOMImpl_ICopy.hxx \ GEOMImpl_IArchimede.hxx \ GEOMImpl_IArc.hxx \ GEOMImpl_ISketcher.hxx \ + GEOMImpl_I3DSketcher.hxx \ GEOMImpl_IVector.hxx \ GEOMImpl_IDisk.hxx \ GEOMImpl_IFace.hxx \ @@ -124,7 +126,9 @@ salomeinclude_HEADERS = \ GEOMImpl_ArcDriver.hxx \ GEOMImpl_SplineDriver.hxx \ GEOMImpl_SketcherDriver.hxx \ + GEOMImpl_3DSketcherDriver.hxx \ GEOMImpl_FilletDriver.hxx \ + GEOMImpl_Fillet2dDriver.hxx \ GEOMImpl_ChamferDriver.hxx \ GEOMImpl_BooleanDriver.hxx \ GEOMImpl_PartitionDriver.hxx \ @@ -185,7 +189,9 @@ dist_libGEOMimpl_la_SOURCES = \ GEOMImpl_ArcDriver.cxx \ GEOMImpl_SplineDriver.cxx \ GEOMImpl_SketcherDriver.cxx \ + GEOMImpl_3DSketcherDriver.cxx \ GEOMImpl_FilletDriver.cxx \ + GEOMImpl_Fillet2dDriver.cxx \ GEOMImpl_ChamferDriver.cxx \ GEOMImpl_BooleanDriver.cxx \ GEOMImpl_PartitionDriver.cxx \ diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 39bd1c8fe..9743e8614 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -161,7 +161,6 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, Unexpect aCatch(SALOME_SalomeException); SALOMEDS::SObject_var aResultSO; if(CORBA::is_nil(theObject) || theStudy->_is_nil()) return aResultSO; - GEOM::GEOM_Object_var aShape = GEOM::GEOM_Object::_narrow(theObject); if(aShape->_is_nil()) return aResultSO; @@ -1308,6 +1307,157 @@ GEOM::GEOM_Object_ptr GEOM_Gen_i::GetObject (CORBA::Long theStudyID, const char* return obj._retn(); } +//================================================================================= +// function : hasObjectInfo() +// purpose : shows if module provides information for its objects +//================================================================================= +bool GEOM_Gen_i::hasObjectInfo() +{ + return true; +} + +//================================================================================= +// function : getObjectInfo() +// purpose : returns an information for a given object by its entry +//================================================================================= +char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry) +{ + GEOM::GEOM_Object_var aGeomObject; + + CORBA::Object_var aSMObject = name_service->Resolve( "/myStudyManager" ); + SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject ); + SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId ); + SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( entry ); + SALOMEDS::SObject_var aResultSObj; + if (aSObj->ReferencedObject(aResultSObj)) + aSObj = aResultSObj; + + SALOMEDS::GenericAttribute_var anAttr; + if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var aVal = anIOR->Value(); + CORBA::Object_var anObject = aStudy->ConvertIORToObject(aVal); + aGeomObject = GEOM::GEOM_Object::_narrow(anObject); + } + + char* aTypeInfo = "Object"; + if ( !aGeomObject->_is_nil() ) { + GEOM::GEOM_IKindOfShape::shape_kind aKind; + GEOM::ListOfLong_var anInts; + GEOM::ListOfDouble_var aDbls; + + GEOM::GEOM_IMeasureOperations_var anOp = GetIMeasureOperations( studyId ); + aKind = anOp->KindOfShape( aGeomObject, anInts, aDbls ); + + if ( anOp->IsDone() ) { + switch ( aKind ) { + case GEOM::GEOM_IKindOfShape::COMPOUND: + aTypeInfo = "Compound"; + break; + case GEOM::GEOM_IKindOfShape::COMPSOLID: + aTypeInfo = "CompSolid"; + break; + case GEOM::GEOM_IKindOfShape::SHELL: + aTypeInfo = "Shell"; + break; + case GEOM::GEOM_IKindOfShape::WIRE: + if ( anInts[0] == 1 ) + aTypeInfo = "Closed Wire"; + else if ( anInts[0] == 2 ) + aTypeInfo = "Opened Wire"; + else + aTypeInfo = "Wire"; + break; + // SOLIDs + case GEOM::GEOM_IKindOfShape::SPHERE: + aTypeInfo = "Sphere"; + break; + case GEOM::GEOM_IKindOfShape::CYLINDER: + aTypeInfo = "Cylinder"; + break; + case GEOM::GEOM_IKindOfShape::BOX: + case GEOM::GEOM_IKindOfShape::ROTATED_BOX: + aTypeInfo = "Box"; + break; + case GEOM::GEOM_IKindOfShape::TORUS: + aTypeInfo = "Torus"; + break; + case GEOM::GEOM_IKindOfShape::CONE: + aTypeInfo = "Cone"; + break; + case GEOM::GEOM_IKindOfShape::POLYHEDRON: + aTypeInfo = "Polyhedron"; + break; + case GEOM::GEOM_IKindOfShape::SOLID: + aTypeInfo = "Solid"; + break; + // FACEs + case GEOM::GEOM_IKindOfShape::SPHERE2D: + aTypeInfo = "Spherical Face"; + break; + case GEOM::GEOM_IKindOfShape::CYLINDER2D: + aTypeInfo = "Cylindrical Face"; + break; + case GEOM::GEOM_IKindOfShape::TORUS2D: + aTypeInfo = "Toroidal Face"; + break; + case GEOM::GEOM_IKindOfShape::CONE2D: + aTypeInfo = "Conical Face"; + break; + case GEOM::GEOM_IKindOfShape::DISK_CIRCLE: + aTypeInfo = "Disk"; + break; + case GEOM::GEOM_IKindOfShape::DISK_ELLIPSE: + aTypeInfo = "Elliptical Face"; + break; + case GEOM::GEOM_IKindOfShape::POLYGON: + aTypeInfo = "Polygon"; + break; + case GEOM::GEOM_IKindOfShape::PLANE: + aTypeInfo = "Plane"; + break; + case GEOM::GEOM_IKindOfShape::PLANAR: + aTypeInfo = "Planar Face"; + break; + case GEOM::GEOM_IKindOfShape::FACE: + aTypeInfo = "Face"; + break; + // EDGEs + case GEOM::GEOM_IKindOfShape::CIRCLE: + aTypeInfo = "Circle"; + break; + case GEOM::GEOM_IKindOfShape::ARC_CIRCLE: + aTypeInfo = "Ark"; + break; + case GEOM::GEOM_IKindOfShape::ELLIPSE: + aTypeInfo = "Ellipse"; + break; + case GEOM::GEOM_IKindOfShape::ARC_ELLIPSE: + aTypeInfo = "Arc Ellipse"; + break; + case GEOM::GEOM_IKindOfShape::LINE: + aTypeInfo = "Line"; + break; + case GEOM::GEOM_IKindOfShape::SEGMENT: + aTypeInfo = "Segment"; + break; + case GEOM::GEOM_IKindOfShape::EDGE: + aTypeInfo = "Edge"; + break; + case GEOM::GEOM_IKindOfShape::VERTEX: + aTypeInfo = "Vertex"; + break; + default: + break; + } + } + } + + char anInfo [strlen("Module ") + strlen(ComponentDataType()) + strlen(", ") + strlen(aTypeInfo)]; + sprintf(anInfo, "Module %s, %s", ComponentDataType(), aTypeInfo); + + return CORBA::string_dup(anInfo); +} //===================================================================================== // EXPORTED METHODS diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh index cf594f49e..aba3b6aa6 100644 --- a/src/GEOM_I/GEOM_Gen_i.hh +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -232,7 +232,11 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi char* GetDumpName (const char* theStudyEntry); GEOM::string_array* GetAllDumpNames(); - + + // Object information + virtual bool hasObjectInfo(); + virtual char* getObjectInfo(CORBA::Long studyId, const char* entry); + //-----------------------------------------------------------------------// // Internal methods // //-----------------------------------------------------------------------// diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.cc b/src/GEOM_I/GEOM_ICurvesOperations_i.cc index 661b4898d..2b15af49f 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.cc +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.cc @@ -275,6 +275,43 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter return GetObject(anObject); } + +//============================================================================= +/*! + * MakeArc + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcOfEllipse + (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject + (thePnt3->GetStudyID(), thePnt3->GetEntry()); + + if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn(); + + // Make Arc + Handle(GEOM_Object) anObject = + GetOperations()->MakeArcOfEllipse(aPnt1, aPnt2, aPnt3); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakePolyline @@ -409,6 +446,31 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher return GetObject(anObject); } +//============================================================================= +/*! + * Make3DSketcher + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher + (const GEOM::ListOfDouble& theCoordinates) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + int ind = 0; + int aLen = theCoordinates.length(); + list aCoords; + for (; ind < aLen; ind++) + aCoords.push_back(theCoordinates[ind]); + + // Make Sketcher + Handle(GEOM_Object) anObject = + GetOperations()->Make3DSketcher(aCoords); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return GEOM::GEOM_Object::_nil(); + + return GetObject(anObject); +} //============================================================================= /*! diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.hh b/src/GEOM_I/GEOM_ICurvesOperations_i.hh index f26eef628..24179fc1f 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.hh +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.hh @@ -65,6 +65,10 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i : GEOM::GEOM_Object_ptr thePnt2, GEOM::GEOM_Object_ptr thePnt3, bool theSense); + + GEOM::GEOM_Object_ptr MakeArcOfEllipse (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); GEOM::GEOM_Object_ptr MakePolyline (const GEOM::ListOfGO& thePoints); @@ -73,6 +77,8 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i : GEOM::GEOM_Object_ptr MakeSplineInterpolation (const GEOM::ListOfGO& thePoints); GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane); + + GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates); GEOM::GEOM_Object_ptr MakeSketcherOnPlane (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane); diff --git a/src/GEOM_I/GEOM_ILocalOperations_i.cc b/src/GEOM_I/GEOM_ILocalOperations_i.cc index d7c5f74d8..c71a24780 100644 --- a/src/GEOM_I/GEOM_ILocalOperations_i.cc +++ b/src/GEOM_I/GEOM_ILocalOperations_i.cc @@ -221,6 +221,41 @@ GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2 return GetObject(anObject); } +//============================================================================= +/*! + * MakeFillet2D + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet2D + (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theVertexes) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference vertex + int ind = 0; + int aLen = theVertexes.length(); + list aVertexes; + for (; ind < aLen; ind++) { + aVertexes.push_back(theVertexes[ind]); + } + + //Create the Fillet + Handle(GEOM_Object) anObject = + GetOperations()->MakeFillet2D(aShapeRef, theR, aVertexes); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeChamferAll diff --git a/src/GEOM_I/GEOM_ILocalOperations_i.hh b/src/GEOM_I/GEOM_ILocalOperations_i.hh index eaf73c6b5..e13d37f49 100644 --- a/src/GEOM_I/GEOM_ILocalOperations_i.hh +++ b/src/GEOM_I/GEOM_ILocalOperations_i.hh @@ -59,6 +59,9 @@ class GEOM_I_EXPORT GEOM_ILocalOperations_i : CORBA::Double theR1, CORBA::Double theR2, const GEOM::ListOfLong& theFaces); + + GEOM::GEOM_Object_ptr MakeFillet2D (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theVertexes); GEOM::GEOM_Object_ptr MakeChamferAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD); diff --git a/src/GEOM_I/GEOM_ITransformOperations_i.cc b/src/GEOM_I/GEOM_ITransformOperations_i.cc index 0985505c7..ac359856d 100644 --- a/src/GEOM_I/GEOM_ITransformOperations_i.cc +++ b/src/GEOM_I/GEOM_ITransformOperations_i.cc @@ -989,6 +989,47 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy return GetObject(anObject); } +//============================================================================= +/*! + * PositionAlongPath + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionAlongPath + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePath, + CORBA::Double theDistance, + CORBA::Boolean theCopy, + CORBA::Boolean theReverse) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || thePath == NULL) + return aGEOMObject._retn(); + + //Get the basic object + CORBA::String_var anEntry = theObject->GetEntry(); + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), anEntry); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the path object + CORBA::String_var aPathEntry = thePath->GetEntry(); + Handle(GEOM_Object) aPathObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), aPathEntry); + if (aPathObject.IsNull()) return aGEOMObject._retn(); + + //Perform the position + Handle(GEOM_Object) anObject = + GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MultiTranslate1D diff --git a/src/GEOM_I/GEOM_ITransformOperations_i.hh b/src/GEOM_I/GEOM_ITransformOperations_i.hh index b250f0a91..e46758e01 100644 --- a/src/GEOM_I/GEOM_ITransformOperations_i.hh +++ b/src/GEOM_I/GEOM_ITransformOperations_i.hh @@ -142,6 +142,12 @@ class GEOM_I_EXPORT GEOM_ITransformOperations_i : GEOM::GEOM_Object_ptr theStartLCS, GEOM::GEOM_Object_ptr theEndLCS); + GEOM::GEOM_Object_ptr PositionAlongPath (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePath, + CORBA::Double theDistance, + CORBA::Boolean theCopy, + CORBA::Boolean theReverse); + GEOM::GEOM_Object_ptr RotateThreePoints (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theCentPoint, GEOM::GEOM_Object_ptr thePoint1, diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 6bbfeb988..159bb6f49 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -1821,6 +1821,23 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::PositionShapeCopy (GEOM::GEOM_Object_ptr th return anObj; } +//============================================================================= +// PositionAlongPath: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::PositionAlongPath (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePath, + CORBA::Double theDistance, + CORBA::Boolean theCopy, + CORBA::Boolean theReverse) +{ + beginService( " GEOM_Superv_i::PositionAlongPath" ); + MESSAGE("GEOM_Superv_i::PositionAlongPath"); + getTransfOp(); + GEOM::GEOM_Object_ptr anObj = myTransfOp->PositionAlongPath(theObject, thePath, theDistance, theCopy, theReverse); + endService( " GEOM_Superv_i::PositionAlongPath" ); + return anObj; +} + //=============================== ShapesOperations ============================ //============================================================================= // Make: @@ -2546,6 +2563,21 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeArcCenter (GEOM::GEOM_Object_ptr theCen return anObj; } +//============================================================================= +// MakeArcOfEllipse: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeArcOfEllipse (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + beginService( " GEOM_Superv_i::MakeArcOfEllipse" ); + MESSAGE("GEOM_Superv_i::MakeArcOfEllipse"); + getCurvesOp(); + GEOM::GEOM_Object_ptr anObj = myCurvesOp->MakeArcOfEllipse(thePnt1, thePnt2, thePnt3); + endService( " GEOM_Superv_i::MakeArcOfEllipse" ); + return anObj; +} + //============================================================================= // MakePolyline: //============================================================================= @@ -2619,6 +2651,24 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSketcher (const char* theCommand, return NULL; } +//============================================================================= +// Make3DSketcher: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::Make3DSketcher ( GEOM::GEOM_List_ptr theCoordinates) +{ + beginService( " GEOM_Superv_i::Make3DSketcher" ); + MESSAGE("GEOM_Superv_i::Make3DSketcher"); + if (GEOM_List_i* aListImpl = + dynamic_cast*>(GetServant(theCoordinates, myPOA).in())) { + getCurvesOp(); + GEOM::GEOM_Object_ptr anObj = myCurvesOp->Make3DSketcher(aListImpl->GetList()); + endService( " GEOM_Superv_i::Make3DSketcher" ); + return anObj; + } + endService( " GEOM_Superv_i::Make3DSketcher" ); + return NULL; +} + //=============================== LocalOperations ============================= //============================================================================= // MakeFilletAll: @@ -2718,6 +2768,26 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilletFacesR1R2 (GEOM::GEOM_Object_ptr return NULL; } +//============================================================================= +// MakeFillet2D: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFillet2D (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR, + GEOM::GEOM_List_ptr theVertexes) +{ + beginService( " GEOM_Superv_i::MakeFillet2D" ); + MESSAGE("GEOM_Superv_i::MakeFillet2D"); + if (GEOM_List_i* aListImplV = + dynamic_cast*>(GetServant(theVertexes, myPOA).in())) { + getLocalOp(); + GEOM::GEOM_Object_ptr anObj = myLocalOp->MakeFillet2D(theShape, theR, aListImplV->GetList()); + endService( " GEOM_Superv_i::MakeFillet2D" ); + return anObj; + } + endService( " GEOM_Superv_i::MakeFillet2D" ); + return NULL; +} + //============================================================================= // MakeChamferAll: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index a061ce3ba..b34c13214 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -421,6 +421,11 @@ public: GEOM::GEOM_Object_ptr PositionShapeCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theStartLCS, GEOM::GEOM_Object_ptr theEndLCS); + GEOM::GEOM_Object_ptr PositionAlongPath (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePath, + CORBA::Double theDistance, + CORBA::Boolean theCopy, + CORBA::Boolean theReverse); //-----------------------------------------------------------// // ShapesOperations // @@ -559,11 +564,15 @@ public: GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, CORBA::Boolean theSense); + GEOM::GEOM_Object_ptr MakeArcOfEllipse (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); GEOM::GEOM_Object_ptr MakePolyline (GEOM::GEOM_List_ptr thePoints); GEOM::GEOM_Object_ptr MakeSplineBezier (GEOM::GEOM_List_ptr thePoints); GEOM::GEOM_Object_ptr MakeSplineInterpolation (GEOM::GEOM_List_ptr thePoints); GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, GEOM::GEOM_List_ptr theWorkingPlane); + GEOM::GEOM_Object_ptr Make3DSketcher (GEOM::GEOM_List_ptr theCoordinates); //-----------------------------------------------------------// // LocalOperations // @@ -578,6 +587,8 @@ public: GEOM::GEOM_List_ptr theFaces); GEOM::GEOM_Object_ptr MakeFilletFacesR1R2 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1, CORBA::Double theR2, GEOM::GEOM_List_ptr theFaces); + GEOM::GEOM_Object_ptr MakeFillet2D (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + GEOM::GEOM_List_ptr theVertexes); GEOM::GEOM_Object_ptr MakeChamferAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD); GEOM::GEOM_Object_ptr MakeChamferEdge (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD1, CORBA::Double theD2, diff --git a/src/GEOM_SWIG/GEOM_ObjectInfo.py b/src/GEOM_SWIG/GEOM_ObjectInfo.py new file mode 100644 index 000000000..a5c57e9e0 --- /dev/null +++ b/src/GEOM_SWIG/GEOM_ObjectInfo.py @@ -0,0 +1,60 @@ +# GEOM GEOM_SWIG : binding of C++ omplementaion with Python +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# +# +# File : GEOM_ObjectInfo.py +# Author : Michael ZORIN +# Module : GEOM +# $Header: + +import salome +import geompy + +geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") + +# Create several objects +obj1 = geompy.MakeVertex(0.,0.,0.) +obj2 = geompy.MakeCircleR(150.) +obj3 = geompy.MakeBoxDXDYDZ(300.,400.,500.) +obj4 = geompy.MakeCylinderRH(100.,200.) +ShapeListCompound = [] +ShapeListCompound.append(obj3) +ShapeListCompound.append(obj4) +obj5 = geompy.MakeCompound(ShapeListCompound) + +obj1_entry = geompy.addToStudy(obj1, "Object1") +obj2_entry = geompy.addToStudy(obj2, "Object2") +obj3_entry = geompy.addToStudy(obj3, "Object3") +obj4_entry = geompy.addToStudy(obj4, "Object4") +obj5_entry = geompy.addToStudy(obj5, "Object5") + +# Get information about objects +hasInfo = geom.hasObjectInfo() +print "Check if GEOM module provides information about its objects: ", hasInfo +if hasInfo == True: + print "Information about first object: ", geom.getObjectInfo(salome.myStudyId, obj1_entry) + print "Information about second object: ", geom.getObjectInfo(salome.myStudyId, obj2_entry) + print "Information about third object: ", geom.getObjectInfo(salome.myStudyId, obj3_entry) + print "Information about fourth object: ", geom.getObjectInfo(salome.myStudyId, obj4_entry) + print "Information about fifth object: ", geom.getObjectInfo(salome.myStudyId, obj5_entry) + +salome.sg.updateObjBrowser(1) diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 60b2b0e32..317f1dc40 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -23,7 +23,7 @@ # File : GEOM_usinggeom.py # Author : Damien COQUERET, Open CASCADE # Module : GEOM -# $Header$ +# # ! Please, if you edit this example file, update also # ! GEOM_SRC/doc/salome/gui/GEOM/input/tui_test_all.doc # ! as some sequences of symbols from this example are used during @@ -92,6 +92,7 @@ def TestAll (geompy, math): Arc = geompy.MakeArc(py, pz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr Arc2 = geompy.MakeArcCenter(py, pz, px,0) #(3 GEOM_Object_ptr,Boolean)->GEOM_Object_ptr + Arc3 = geompy.MakeArcOfEllipse(p0, px, pz) #(3 GEOM_Object_ptr,Boolean)->GEOM_Object_ptr Circle = geompy.MakeCircle(p0, vz, radius1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr Circle1 = geompy.MakeCircleThreePnt(p0, pxyz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr Circle2 = geompy.MakeCircleCenter2Pnt(p0, pxyz, py) #(3 GEOM_Object_ptr)->GEOM_Object_ptr @@ -101,6 +102,7 @@ def TestAll (geompy, math): Interpol = geompy.MakeInterpol([px, py, p200, pxyz]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr Sketcher = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW", [100,0,0, 1,1,1, -1,1,0]) #(String, List of Doubles)->GEOM_Object_ptr + Sketcher3d = geompy.Make3DSketcher([0,0,0, 50,50,50, 0,50,50, 10,0,0]) #Test point on curve creation p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr @@ -205,6 +207,7 @@ def TestAll (geompy, math): MirrorAxis = geompy.MakeMirrorByAxis(Box, Line1) # MirrorPnt = geompy.MakeMirrorByPoint(Box, p200) # Position = geompy.MakePosition(Box, cs1, cs2) #(3 GEOM_Object_ptr)->GEOM_Object_ptr + Position2 = geompy.PositionAlongPath(Box, Arc, 0.5, 1, 0) #(2 GEOM_Object_ptr, 1 Double, 2 Bool)->GEOM_Object_ptr Offset = geompy.MakeOffset(Box, 10.) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr Orientation = geompy.ChangeOrientation(Box) @@ -232,6 +235,7 @@ def TestAll (geompy, math): IDlist_f = [f_ind_1, f_ind_2] #Local operations + Fillet2d = geompy.MakeFillet2D(Face3, radius, [4, 7, 9]) #(GEOM_Object_ptr, Double, ListOfLong)->GEOM_Object_ptr Fillet = geompy.MakeFillet (Prism, radius, ShapeTypeEdge, IDlist_e) #(GEOM_Object_ptr, Double, Short, ListOfLong)->GEOM_Object_ptr Fillet2 = geompy.MakeFilletR1R2 (Prism, 7., 13., ShapeTypeEdge, @@ -292,6 +296,8 @@ def TestAll (geompy, math): id_Plane1 = geompy.addToStudy(Plane1, "Plane by 3 points") id_Arc = geompy.addToStudy(Arc, "Arc") + id_Arc2 = geompy.addToStudy(Arc2, "Arc2") + id_Arc3 = geompy.addToStudy(Arc3, "Arc3") id_Circle = geompy.addToStudy(Circle, "Circle") id_Circle1 = geompy.addToStudy(Circle1, "Circle by 3 points") id_Circle2 = geompy.addToStudy(Circle2, "Circle by center and 2 points") @@ -300,6 +306,7 @@ def TestAll (geompy, math): id_Bezier = geompy.addToStudy(Bezier, "Bezier") id_Interpol = geompy.addToStudy(Interpol, "Interpol") id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher") + id_Sketcher3d = geompy.addToStudy(Sketcher3d, "Sketcher 3D") id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc (0.25)") id_p_on_l1l2 = geompy.addToStudy(p_on_l1l2, "Vertex on Lines Intersection") @@ -369,11 +376,13 @@ def TestAll (geompy, math): id_MirrorAxis = geompy.addToStudy(MirrorAxis, "Mirror by Axis") id_MirrorPnt = geompy.addToStudy(MirrorPnt, "Mirror by Point") id_Position = geompy.addToStudy(Position, "Positioned box") + id_Position2 = geompy.addToStudy(Position2, "Positioned box along path") id_Offset = geompy.addToStudy(Offset, "Offset") id_Orientation = geompy.addToStudy(Orientation, "Orientation") id_Fillet = geompy.addToStudy(Fillet, "Fillet") id_Fillet2 = geompy.addToStudy(Fillet2, "Fillet2") + id_Fillet2d = geompy.addToStudy(Fillet2d, "Fillet2D") id_Chamfer = geompy.addToStudy(Chamfer, "Chamfer on Edge") id_Chamfer2 = geompy.addToStudy(Chamfer2, "Chamfer on Faces") diff --git a/src/GEOM_SWIG/Makefile.am b/src/GEOM_SWIG/Makefile.am index 17cc3288d..3b7c921fb 100644 --- a/src/GEOM_SWIG/Makefile.am +++ b/src/GEOM_SWIG/Makefile.am @@ -24,7 +24,8 @@ # Author : Nicolas REJNERI, Paul RASCLE # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ + + # Libraries targets # include $(top_srcdir)/adm_local/unix/make_common_starter.am @@ -64,6 +65,7 @@ dist_salomescript_DATA = \ GEOM_tube_geom_gg2.py \ GEOM_Nut.py \ GEOM_Sketcher.py \ + GEOM_ObjectInfo.py \ PAL_MESH_019_020_geometry.py \ PAL_MESH_028_geometry.py \ PAL_MESH_030_geometry.py \ diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 4603c1af7..787ccc005 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -23,8 +23,7 @@ # File : geompy.py # Author : Paul RASCLE, EDF # Module : GEOM -# $Header$ -# + """ \namespace geompy \brief Module geompy @@ -491,6 +490,19 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.CurvesOp.MakeArcCenter(thePnt1, thePnt2, thePnt3, theSense) RaiseIfFailed("MakeArcCenter", self.CurvesOp) return anObj + + ## Create an arc of ellipse, of center and two points. + # @param theCenter Center of the arc. + # @param thePnt1 defines major radius of the arc by distance from Pnt1 to Pnt2. + # @param thePnt2 defines plane of ellipse and minor radius as distance from Pnt3 to line from Pnt1 to Pnt2. + # @return New GEOM_Object, containing the created arc. + # + # @ref swig_MakeArc "Example" + def MakeArcOfEllipse(self,theCenter, thePnt1, thePnt2): + # Example: see GEOM_TestAll.py + anObj = self.CurvesOp.MakeArcOfEllipse(theCenter, thePnt1, thePnt2) + RaiseIfFailed("MakeArcOfEllipse", self.CurvesOp) + return anObj ## Create a circle with given center, normal vector and radius. # @param thePnt Circle center. @@ -656,6 +668,18 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane) RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp) return anObj + + ## Create a sketcher wire, following the numerical description, + # passed through theCoordinates argument. \n + # @param theCoordinates double values, defining points to create a wire, + # passing from it. + # @return New GEOM_Object, containing the created wire. + # + # @ref tui_sketcher_page "Example" + def Make3DSketcher(self, theCoordinates): + anObj = self.CurvesOp.Make3DSketcher(theCoordinates) + RaiseIfFailed("Make3DSketcher", self.CurvesOp) + return anObj # end of l3_sketcher ## @} @@ -2217,6 +2241,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("PositionShapeCopy", self.TrsfOp) return anObj + ## Modify the Location of the given object by Path, + # @param theObject The object to be displaced. + # @param thePath Wire or Edge along that the object will be translated. + # @param theDistance progress of Path (0 = start location, 1 = end of path location). + # @param theCopy is to create a copy objects if true. + # @param theReverse - 0 for usual direction, 1 to reverse path direction. + # @return New GEOM_Object, containing the displaced shape. + # + # @ref tui_modify_location "Example" + def PositionAlongPath(self,theObject, thePath, theDistance, theCopy, theReverse): + # Example: see GEOM_TestAll.py + anObj = self.TrsfOp.PositionAlongPath(theObject, thePath, theDistance, theCopy, theReverse) + RaiseIfFailed("PositionAlongPath", self.TrsfOp) + return anObj + ## Create new object as offset of the given one. # @param theObject The base object for the offset. # @param theOffset Offset value. @@ -2369,6 +2408,20 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeFilletFacesR1R2(theShape, theR1, theR2, theListShapes) RaiseIfFailed("MakeFilletFacesR1R2", self.LocalOp) return anObj + + ## Perform a fillet on the specified edges/faces of the given shape + # @param theShape - Face Shape to perform fillet on. + # @param theR - Fillet radius. + # @param theListOfVertexes Global indices of vertexes to perform fillet on. + # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID(). + # @return New GEOM_Object, containing the result shape. + # + # @ref tui_fillet2d "Example" + def MakeFillet2D(self,theShape, theR, theListOfVertexes): + # Example: see GEOM_TestAll.py + anObj = self.LocalOp.MakeFillet2D(theShape, theR, theListOfVertexes) + RaiseIfFailed("MakeFillet2D", self.LocalOp) + return anObj ## Perform a symmetric chamfer on all edges of the given shape. # @param theShape Shape, to perform chamfer on. diff --git a/src/GroupGUI/GroupGUI_GroupDlg.cxx b/src/GroupGUI/GroupGUI_GroupDlg.cxx index a4867effc..e17b859aa 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.cxx +++ b/src/GroupGUI/GroupGUI_GroupDlg.cxx @@ -48,7 +48,7 @@ #include #include -enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2 }; +enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2, SUBSHAPES_OF_INVISIBLE_SHAPE2 }; GroupGUI_GroupDlg::GroupGUI_GroupDlg( Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent ) : GEOMBase_Skeleton( theGeometryGUI, parent, false ), @@ -383,7 +383,10 @@ void GroupGUI_GroupDlg::onGetInPlace() setInPlaceObj( aGetInPlaceObj ); } else { - setInPlaceObj( anObj ); + bool isVisible = true; + if ( SALOME_View* view = GEOM_Displayer::GetActiveView() ) + isVisible = view->isVisible( aSelList.First() ); + setInPlaceObj( anObj, isVisible ); } myEditCurrentArgument = 0; //myBusy = true; // just activate but do not select in the list @@ -398,14 +401,16 @@ void GroupGUI_GroupDlg::onGetInPlace() //purpose : temporarily add an object to study and remove old InPlaceObj //======================================================================= -void GroupGUI_GroupDlg::setInPlaceObj( GEOM::GEOM_Object_var theObj ) +void GroupGUI_GroupDlg::setInPlaceObj( GEOM::GEOM_Object_var theObj, const bool isVisible ) { if ( ! myInPlaceObj->_is_equivalent( theObj ) ) { const char* tmpName = "__InPlaceObj__"; // remove old InPlaceObj if ( !myInPlaceObj->_is_nil() ) { - if ( myInPlaceObjSelectWay == GET_IN_PLACE ) { // hide temporary object + if ( myInPlaceObjSelectState == GET_IN_PLACE || + myInPlaceObjSelectState == SUBSHAPES_OF_INVISIBLE_SHAPE2 ) { + // hide temporary object or initially invisible shape 2 (issue 0014047) GEOM_Displayer aDisplayer(getStudy()); aDisplayer.Erase( myInPlaceObj, true ); } @@ -437,7 +442,9 @@ void GroupGUI_GroupDlg::setInPlaceObj( GEOM::GEOM_Object_var theObj ) myMain2InPlaceIndices.Bind( aMainIndex, aPlaceIndex ); } } - myInPlaceObjSelectWay = subSelectionWay(); + myInPlaceObjSelectState = subSelectionWay(); + if ( myInPlaceObjSelectState == SUBSHAPES_OF_SHAPE2 && !isVisible ) + myInPlaceObjSelectState = SUBSHAPES_OF_INVISIBLE_SHAPE2; } //================================================================================= diff --git a/src/GroupGUI/GroupGUI_GroupDlg.h b/src/GroupGUI/GroupGUI_GroupDlg.h index 59da63d49..5edccedcd 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.h +++ b/src/GroupGUI/GroupGUI_GroupDlg.h @@ -86,7 +86,7 @@ private: void updateState(); void highlightSubShapes(); void onGetInPlace(); - void setInPlaceObj( GEOM::GEOM_Object_var ); + void setInPlaceObj( GEOM::GEOM_Object_var, const bool isVisible=1); private: Mode myMode; @@ -94,7 +94,7 @@ private: GEOM::GEOM_Object_var myMainObj; GEOM::GEOM_Object_var myGroup; GEOM::GEOM_Object_var myInPlaceObj; - int myInPlaceObjSelectWay; + int myInPlaceObjSelectState; TColStd_DataMapOfIntegerInteger myMain2InPlaceIndices; QPushButton* mySelBtn; diff --git a/src/OperationGUI/Makefile.am b/src/OperationGUI/Makefile.am index 8111cc81b..3afc05013 100644 --- a/src/OperationGUI/Makefile.am +++ b/src/OperationGUI/Makefile.am @@ -32,6 +32,7 @@ salomeinclude_HEADERS = \ OperationGUI_ArchimedeDlg.h \ OperationGUI_PartitionDlg.h \ OperationGUI_FilletDlg.h \ + OperationGUI_Fillet2dDlg.h \ OperationGUI_ChamferDlg.h \ OperationGUI_GetShapesOnShapeDlg.h \ OperationGUI_ClippingDlg.h @@ -45,6 +46,7 @@ dist_libOperationGUI_la_SOURCES = \ OperationGUI_PartitionDlg.cxx \ OperationGUI_GetShapesOnShapeDlg.cxx \ OperationGUI_FilletDlg.cxx \ + OperationGUI_Fillet2dDlg.cxx \ OperationGUI_ChamferDlg.cxx \ OperationGUI_ClippingDlg.cxx @@ -53,6 +55,7 @@ MOC_FILES = \ OperationGUI_PartitionDlg_moc.cxx \ OperationGUI_GetShapesOnShapeDlg_moc.cxx\ OperationGUI_FilletDlg_moc.cxx \ + OperationGUI_Fillet2dDlg_moc.cxx \ OperationGUI_ChamferDlg_moc.cxx \ OperationGUI_ClippingDlg_moc.cxx diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index 70dd8f444..ebc81748d 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -38,6 +38,7 @@ #include "OperationGUI_PartitionDlg.h" // Method PARTITION #include "OperationGUI_ArchimedeDlg.h" // Method ARCHIMEDE #include "OperationGUI_FilletDlg.h" // Method FILLET +#include "OperationGUI_Fillet2dDlg.h" // Method FILLET 2D #include "OperationGUI_ChamferDlg.h" // Method CHAMFER #include "OperationGUI_ClippingDlg.h" // Clipping dialog box #include "OperationGUI_GetShapesOnShapeDlg.h" @@ -78,6 +79,7 @@ bool OperationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case 506: ( new OperationGUI_ChamferDlg ( getGeometryGUI(), parent ) )->show(); break; case 507: ( new OperationGUI_ClippingDlg ( getGeometryGUI(), parent ) )->show(); break; case 508: ( new OperationGUI_GetShapesOnShapeDlg( getGeometryGUI(), parent ) )->show(); break; + case 509: ( new OperationGUI_Fillet2dDlg ( getGeometryGUI(), parent ) )->show(); break; default: app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); } diff --git a/src/OperationGUI/OperationGUI_Fillet2dDlg.cxx b/src/OperationGUI/OperationGUI_Fillet2dDlg.cxx new file mode 100755 index 000000000..b33cfc3ee --- /dev/null +++ b/src/OperationGUI/OperationGUI_Fillet2dDlg.cxx @@ -0,0 +1,400 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : OperationGUI_Fillet2dDlg.cxx +// Author : DMV, OCN. +// + +#include "OperationGUI_Fillet2dDlg.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// OCCT Includes +#include +#include + +#include + +//================================================================================= +// class : OperationGUI_Fillet2dDlg() +// purpose : Constructs a OperationGUI_Fillet2dDlg 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_Fillet2dDlg::OperationGUI_Fillet2dDlg (GeometryGUI* theGeometryGUI, QWidget* parent) + : GEOMBase_Skeleton(theGeometryGUI, parent, false) +{ + SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); + QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_2D"))); + QPixmap iconSelect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("GEOM_FILLET_2D_TITLE")); + + /***************************************************************/ + mainFrame()->GroupConstructors->setTitle(tr("GEOM_FILLET_2D")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->close(); + + GroupVertexes = new DlgRef_2Sel1Spin(centralWidget()); + GroupVertexes->GroupBox1->setTitle(tr("GEOM_FILLET_2D")); + GroupVertexes->TextLabel1->setText(tr("GEOM_PLANAR_FACE")); + GroupVertexes->TextLabel2->setText(tr("GEOM_VERTEXES")); + GroupVertexes->TextLabel3->setText(tr("GEOM_RADIUS")); + GroupVertexes->PushButton1->setIcon(iconSelect); + GroupVertexes->PushButton2->setIcon(iconSelect); + GroupVertexes->LineEdit1->setReadOnly(true); + GroupVertexes->LineEdit2->setReadOnly(true); + + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(GroupVertexes); + + /***************************************************************/ + + // Set range of spinboxes + double SpecificStep = 10.0; + initSpinBox(GroupVertexes->SpinBox_DX, 0.00001, COORD_MAX, SpecificStep, 5); // VSR: TODO: DBL_DIGITS_DISPLAY + + setHelpFileName("fillet2d_operation_page.html"); + + // Initialisation + Init(); + resize(0,0); +} + +//================================================================================= +// function : ~OperationGUI_Fillet2dDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_Fillet2dDlg::~OperationGUI_Fillet2dDlg() +{ +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::Init() +{ + // Set Initial values of spinboxes + GroupVertexes->SpinBox_DX->setValue(5); + + // Clear line edits + GroupVertexes->LineEdit1->setText(""); + GroupVertexes->LineEdit2->setText(""); + + myShape = GEOM::GEOM_Object::_nil(); + + myVertexes.Clear(); + + // 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(GroupVertexes->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupVertexes->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupVertexes->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupVertexes->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupVertexes->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + initName(tr("GEOM_FILLET_2D")); + GroupVertexes->PushButton1->click(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::ClickOnOk() +{ + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool OperationGUI_Fillet2dDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(); + // Reset dialog state + GroupVertexes->LineEdit1->setText(""); + GroupVertexes->LineEdit2->setText(""); + myShape = GEOM::GEOM_Object::_nil(); + myVertexes.Clear(); + GroupVertexes->PushButton1->click(); + + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection is changed or on dialog initialization or activation +//================================================================================= +void OperationGUI_Fillet2dDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->setText(""); + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + // If selection of main object is activated + if (myEditCurrentArgument == GroupVertexes->LineEdit1) { + myShape = GEOM::GEOM_Object::_nil(); + if (aSelList.Extent() == 1) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult); + + if (aResult && !anObj->_is_nil()) { + QString aName = GEOMBase::GetName( anObj ); + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( anObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(aSelList.First(), aMap); + if ( aMap.Extent() == 1 ) { // Local Selection + int anIndex = aMap( 1 ); + aName += QString( ":face_%1" ).arg( anIndex ); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( anObj, aName ); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); + anObj = aShapesOp->GetSubShape( anObj, anIndex ); + } + else + anObj = aFindedObject; // get Object from study + } + else { // Global Selection + if ( aShape.ShapeType() != TopAbs_FACE ) { + anObj = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + myShape = anObj; + myEditCurrentArgument->setText(aName +); + displayPreview(); + } + } + } else if (myEditCurrentArgument == GroupVertexes->LineEdit2) { + myVertexes.Clear(); + if (aSelList.Extent() == 1) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult); + + if (aResult && !anObj->_is_nil()) { + TColStd_IndexedMapOfInteger anIndexes; + aSelMgr->GetIndexes(aSelList.First(), anIndexes); + + if (anIndexes.Extent() > 0) { + QString aName; + if (anIndexes.Extent() == 1) { + int anIndex = anIndexes(1); + aName = QString(GEOMBase::GetName(anObj)) + QString(":vertex_%1").arg(anIndex); + } + else + aName = tr("GEOM_MEN_POPUP_NAME").arg(anIndexes.Extent()); + + myEditCurrentArgument->setText(aName); + myVertexes = anIndexes; + displayPreview(); + } + } + } + } + + if (myEditCurrentArgument == GroupVertexes->LineEdit1) { + if (!myShape->_is_nil() && myVertexes.Extent() == 0) + GroupVertexes->PushButton2->click(); + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if (send == GroupVertexes->PushButton1) { + myEditCurrentArgument = GroupVertexes->LineEdit1; + GroupVertexes->PushButton2->setDown(false); + GroupVertexes->LineEdit2->setEnabled(false); + } + else if (send == GroupVertexes->PushButton2) { + myEditCurrentArgument = GroupVertexes->LineEdit2; + GroupVertexes->PushButton1->setDown(false); + GroupVertexes->LineEdit1->setEnabled(false); + } + + // enable line edit + myEditCurrentArgument->setEnabled(true); + myEditCurrentArgument->setFocus(); + // after setFocus(), because it will be setDown(false) when loses focus + send->setDown(true); + + activateSelection(); + + // seems we need it only to avoid preview disappearing, caused by selection mode change + displayPreview(); +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + + if (send == GroupVertexes->LineEdit1) + myEditCurrentArgument = GroupVertexes->LineEdit1; + else if (send == GroupVertexes->LineEdit2) + myEditCurrentArgument = GroupVertexes->LineEdit2; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::enterEvent (QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + this->ActivateThisDialog(); +} + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::ValueChangedInSpinBox (double) +{ + displayPreview(); +} + +//================================================================================= +// function : activateSelection +// purpose : Activate selection in accordance with myEditCurrentArgument +//================================================================================= +void OperationGUI_Fillet2dDlg::activateSelection() +{ + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + globalSelection(); + if (myEditCurrentArgument == GroupVertexes->LineEdit1) + globalSelection( GEOM_FACE ); // localSelection(myShape, TopAbs_FACE); + else if (!myShape->_is_nil() && myEditCurrentArgument == GroupVertexes->LineEdit2) + localSelection(myShape, TopAbs_VERTEX); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_Fillet2dDlg::createOperation() +{ + return getGeomEngine()->GetILocalOperations(getStudyId()); +} + +//================================================================================= +// function : isValid() +// purpose : Verify validity of input data +//================================================================================= +bool OperationGUI_Fillet2dDlg::isValid (QString&) +{ + return !myShape->_is_nil() && myVertexes.Extent() > 0; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool OperationGUI_Fillet2dDlg::execute (ObjectList& objects) +{ + GEOM::GEOM_Object_var anObj; + + GEOM::ListOfLong_var aListOfIndexes = new GEOM::ListOfLong; + aListOfIndexes->length(myVertexes.Extent()); + + for (int i = 1, n = myVertexes.Extent(); i <= n; i++) + aListOfIndexes[ i - 1 ] = myVertexes(i); + + anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())-> + MakeFillet2D(myShape, getRadius(), aListOfIndexes); + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + + return true; +} + +//================================================================================= +// function : getRadius +// purpose : Get radius +//================================================================================= +double OperationGUI_Fillet2dDlg::getRadius() const +{ + return GroupVertexes ->SpinBox_DX->value(); +} diff --git a/src/OperationGUI/OperationGUI_Fillet2dDlg.h b/src/OperationGUI/OperationGUI_Fillet2dDlg.h new file mode 100755 index 000000000..523dbad04 --- /dev/null +++ b/src/OperationGUI/OperationGUI_Fillet2dDlg.h @@ -0,0 +1,75 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : OperationGUI_Fillet2dDlg.h +// Author : DMV, OCN +// + +#ifndef OPERATIONGUI_FILLET2DDLG_H +#define OPERATIONGUI_FILLET2DDLG_H + +#include + +#include + +class DlgRef_2Sel1Spin; + +//================================================================================= +// class : OperationGUI_Fillet2dDlg +// purpose : +//================================================================================= +class OperationGUI_Fillet2dDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + OperationGUI_Fillet2dDlg( GeometryGUI*, QWidget* ); + ~OperationGUI_Fillet2dDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& ); + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox( double ); + +private: + void Init(); + void enterEvent( QEvent* ); + void activateSelection(); + double getRadius() const; + +private: + GEOM::GEOM_Object_var myShape; + TColStd_IndexedMapOfInteger myVertexes; + + DlgRef_2Sel1Spin* GroupVertexes; +}; + +#endif // OPERATIONGUI_FILLET2DDLG_H diff --git a/src/TransformationGUI/TransformationGUI_PositionDlg.cxx b/src/TransformationGUI/TransformationGUI_PositionDlg.cxx index fd8452404..bbbd6b6be 100644 --- a/src/TransformationGUI/TransformationGUI_PositionDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_PositionDlg.cxx @@ -33,6 +33,7 @@ #include #include #include +#include // OCCT Includes #include @@ -54,6 +55,7 @@ TransformationGUI_PositionDlg::TransformationGUI_PositionDlg SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION"))); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION2"))); + QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION3"))); QPixmap imageselect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); setWindowTitle(tr("GEOM_POSITION_TITLE")); @@ -62,24 +64,22 @@ TransformationGUI_PositionDlg::TransformationGUI_PositionDlg mainFrame()->GroupConstructors->setTitle(tr("GEOM_POSITION")); mainFrame()->RadioButton1->setIcon(image0); mainFrame()->RadioButton2->setIcon(image1); - mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); - mainFrame()->RadioButton3->close(); - - Group1 = new DlgRef_3Sel3Spin1Check(centralWidget()); - Group1->SpinBox1->hide(); - Group1->SpinBox2->hide(); - Group1->SpinBox3->hide(); - Group1->TextLabel4->hide(); - Group1->TextLabel5->hide(); - Group1->TextLabel6->hide(); + mainFrame()->RadioButton3->setIcon(image2); + + Group1 = new DlgRef_4Sel1Spin3Check(centralWidget()); Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); Group1->TextLabel1->setText(tr("GEOM_OBJECTS")); Group1->TextLabel2->setText(tr("GEOM_START_LCS")); - Group1->TextLabel3->setText(tr("GEOM_END_LCS")); + Group1->TextLabel3->setText(tr("GEOM_DISTANCE")); + Group1->TextLabel4->setText(tr("GEOM_END_LCS")); + Group1->TextLabel5->setText(tr("GEOM_PATH_OBJECT")); Group1->PushButton1->setIcon(imageselect); Group1->PushButton2->setIcon(imageselect); - Group1->PushButton3->setIcon(imageselect); - Group1->CheckBox1->setText(tr("GEOM_CREATE_COPY")); + Group1->PushButton4->setIcon(imageselect); + Group1->PushButton5->setIcon(imageselect); + Group1->CheckButton1->setText(tr("GEOM_CREATE_COPY")); + Group1->CheckButton2->setText(tr("SELECT_UNPUBLISHED_EDGES")); + Group1->CheckButton3->setText(tr("GEOM_REVERSE_DIRECTION")); QVBoxLayout* layout = new QVBoxLayout(centralWidget()); layout->setMargin(0); layout->setSpacing(6); @@ -89,7 +89,8 @@ TransformationGUI_PositionDlg::TransformationGUI_PositionDlg setHelpFileName("modify_location_operation_page.html"); // Activate Create a Copy mode - Group1->CheckBox1->setChecked(true); + Group1->CheckButton1->setChecked(true); + Group1->CheckButton1->setChecked(false); CreateCopyModeChanged(true); Init(); @@ -113,11 +114,18 @@ void TransformationGUI_PositionDlg::Init() // init variables Group1->LineEdit1->setReadOnly(true); Group1->LineEdit2->setReadOnly(true); - Group1->LineEdit3->setReadOnly(true); + Group1->LineEdit4->setReadOnly(true); + Group1->LineEdit5->setReadOnly(true); Group1->LineEdit1->setText(""); Group1->LineEdit2->setText(""); - Group1->LineEdit3->setText(""); + Group1->LineEdit4->setText(""); + Group1->LineEdit5->setText(""); + + initSpinBox(Group1->SpinBox_DX, 0, 1, 0.05, 6); // VSR:TODO : DBL_DIGITS_DISPLAY + Group1->SpinBox_DX->setValue(0); + + Group1->CheckButton2->setEnabled(false); myStartLCS = myEndLCS = GEOM::GEOM_Object::_nil(); @@ -131,13 +139,19 @@ void TransformationGUI_PositionDlg::Init() connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group1->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(Group1->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group1->PushButton4, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group1->PushButton5, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group1->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group1->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group1->LineEdit4, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group1->LineEdit5, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group1->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); + connect(Group1->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); + connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + + connect(Group1->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(SelectionTypeButtonClicked())); + connect(Group1->CheckButton3, SIGNAL(toggled(bool)), this, SLOT(ValueChangedInSpinBox())); initName(tr("GEOM_POSITION")); @@ -153,9 +167,11 @@ void TransformationGUI_PositionDlg::ConstructorsClicked (int constructorId) disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); Group1->LineEdit2->clear(); - Group1->LineEdit3->clear(); + Group1->LineEdit4->clear(); + Group1->LineEdit5->clear(); myStartLCS = GEOM::GEOM_Object::_nil(); myEndLCS = GEOM::GEOM_Object::_nil(); + myPath = GEOM::GEOM_Object::_nil(); switch (constructorId) { case 0: @@ -164,7 +180,21 @@ void TransformationGUI_PositionDlg::ConstructorsClicked (int constructorId) Group1->TextLabel2->hide(); Group1->PushButton2->hide(); + Group1->LineEdit5->hide(); + Group1->TextLabel5->hide(); + Group1->PushButton5->hide(); + + Group1->SpinBox_DX->hide(); + Group1->TextLabel3->hide(); + + Group1->LineEdit4->show(); + Group1->TextLabel4->show(); + Group1->PushButton4->show(); + Group1->PushButton1->click(); + + Group1->CheckButton2->hide(); + Group1->CheckButton3->hide(); } break; case 1: @@ -173,7 +203,40 @@ void TransformationGUI_PositionDlg::ConstructorsClicked (int constructorId) Group1->TextLabel2->show(); Group1->PushButton2->show(); + Group1->LineEdit5->hide(); + Group1->TextLabel5->hide(); + Group1->PushButton5->hide(); + + Group1->SpinBox_DX->hide(); + Group1->TextLabel3->hide(); + + Group1->PushButton1->click(); + + Group1->CheckButton2->hide(); + Group1->CheckButton3->hide(); + } + break; + case 2: + { + Group1->LineEdit4->hide(); + Group1->TextLabel4->hide(); + Group1->PushButton4->hide(); + + Group1->LineEdit2->hide(); + Group1->TextLabel2->hide(); + Group1->PushButton2->hide(); + + Group1->LineEdit5->show(); + Group1->TextLabel5->show(); + Group1->PushButton5->show(); + + Group1->SpinBox_DX->show(); + Group1->TextLabel3->show(); + Group1->PushButton1->click(); + + Group1->CheckButton2->show(); + Group1->CheckButton3->show(); } break; } @@ -191,6 +254,31 @@ void TransformationGUI_PositionDlg::ConstructorsClicked (int constructorId) } } +//================================================================================= +// function : SelectionBittonClicked() +// purpose : Selection type Radio button management +//================================================================================= +void TransformationGUI_PositionDlg::SelectionTypeButtonClicked() +{ + if ( Group1->CheckButton2->isChecked() ) { + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + } else { + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_WIRE); + aMap.Add(GEOM_LINE); + globalSelection(aMap); + } +} + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void TransformationGUI_PositionDlg::ValueChangedInSpinBox() +{ + displayPreview(); +} + //================================================================================= // function : ClickOnOk() // purpose : @@ -207,7 +295,7 @@ void TransformationGUI_PositionDlg::ClickOnOk() //================================================================================= bool TransformationGUI_PositionDlg::ClickOnApply() { - if (!onAccept(Group1->CheckBox1->isChecked())) + if (!onAccept(Group1->CheckButton1->isChecked())) return false; initName(); @@ -229,8 +317,10 @@ void TransformationGUI_PositionDlg::SelectionIntoArgument() myObjects.length(0); else if (myEditCurrentArgument == Group1->LineEdit2) myStartLCS = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group1->LineEdit3) + else if (myEditCurrentArgument == Group1->LineEdit4) myEndLCS = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == Group1->LineEdit5) + myPath = GEOM::GEOM_Object::_nil(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); SALOME_ListIO aSelList; @@ -248,6 +338,9 @@ void TransformationGUI_PositionDlg::SelectionIntoArgument() return; else myEditCurrentArgument->setText(aName); + + if (getConstructorId() == 2) + Group1->PushButton5->click(); } else if (myEditCurrentArgument == Group1->LineEdit2) { if (aSelList.Extent() != 1) @@ -263,9 +356,9 @@ void TransformationGUI_PositionDlg::SelectionIntoArgument() myEditCurrentArgument->setText(aName); if (!myStartLCS->_is_nil() && myEndLCS->_is_nil()) - Group1->PushButton3->click(); + Group1->PushButton4->click(); } - else if (myEditCurrentArgument == Group1->LineEdit3) { + else if (myEditCurrentArgument == Group1->LineEdit4) { myEndLCS = GEOM::GEOM_Object::_nil(); if (aSelList.Extent() != 1) return; @@ -281,6 +374,55 @@ void TransformationGUI_PositionDlg::SelectionIntoArgument() if (!myEndLCS->_is_nil() && !myObjects.length()) Group1->PushButton1->click(); } + else if (myEditCurrentArgument == Group1->LineEdit5) { + myPath = GEOM::GEOM_Object::_nil(); + if (aSelList.Extent() != 1) + return; + + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); + if (!testResult || aSelectedObject->_is_nil()) + return; + + aName = GEOMBase::GetName(myPath); + // Local Selection + TopoDS_Shape S; + if (!GEOMBase::GetShape(aSelectedObject, S)) + return; + + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(aSelList.First(), aMap); + aName = GEOMBase::GetName(aSelectedObject); + if (aMap.Extent() == 1) { + int anIndex = aMap(1); + aName.append(":edge_" + QString::number(anIndex)); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); + + if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else { // get Object from study + aSelectedObject = aFindedObject; + } + } + else { + if (S.ShapeType() != TopAbs_EDGE && S.ShapeType() != TopAbs_WIRE) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + return; + } + } + + myEditCurrentArgument->setText(aName); + myPath = aSelectedObject; + + if (!myPath->_is_nil() && !myObjects.length()) + Group1->PushButton1->click(); + } // clear selection disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); @@ -306,9 +448,13 @@ void TransformationGUI_PositionDlg::SetEditCurrentArgument() globalSelection(); Group1->PushButton2->setDown(false); - Group1->PushButton3->setDown(false); + Group1->PushButton4->setDown(false); + Group1->PushButton5->setDown(false); Group1->LineEdit2->setEnabled(false); - Group1->LineEdit3->setEnabled(false); + Group1->LineEdit4->setEnabled(false); + Group1->LineEdit5->setEnabled(false); + + Group1->CheckButton2->setEnabled(false); } else if (send == Group1->PushButton2) { myEditCurrentArgument = Group1->LineEdit2; @@ -319,12 +465,16 @@ void TransformationGUI_PositionDlg::SetEditCurrentArgument() globalSelection(aMap); Group1->PushButton1->setDown(false); - Group1->PushButton3->setDown(false); + Group1->PushButton4->setDown(false); + Group1->PushButton5->setDown(false); Group1->LineEdit1->setEnabled(false); - Group1->LineEdit3->setEnabled(false); + Group1->LineEdit4->setEnabled(false); + Group1->LineEdit5->setEnabled(false); + + Group1->CheckButton2->setEnabled(false); } - else if (send == Group1->PushButton3) { - myEditCurrentArgument = Group1->LineEdit3; + else if (send == Group1->PushButton4) { + myEditCurrentArgument = Group1->LineEdit4; TColStd_MapOfInteger aMap; aMap.Add(GEOM_PLANE); @@ -333,8 +483,33 @@ void TransformationGUI_PositionDlg::SetEditCurrentArgument() Group1->PushButton1->setDown(false); Group1->PushButton2->setDown(false); + Group1->PushButton5->setDown(false); + Group1->LineEdit1->setEnabled(false); + Group1->LineEdit2->setEnabled(false); + Group1->LineEdit5->setEnabled(false); + + Group1->CheckButton2->setEnabled(false); + } + else if (send == Group1->PushButton5) { + myEditCurrentArgument = Group1->LineEdit5; + + Group1->CheckButton2->setEnabled(true); + + if ( Group1->CheckButton2->isChecked() ) { + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + } else { + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_WIRE); + aMap.Add(GEOM_LINE); + globalSelection(aMap); + } + + Group1->PushButton1->setDown(false); + Group1->PushButton2->setDown(false); + Group1->PushButton4->setDown(false); Group1->LineEdit1->setEnabled(false); Group1->LineEdit2->setEnabled(false); + Group1->LineEdit4->setEnabled(false); } connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); @@ -358,10 +533,16 @@ void TransformationGUI_PositionDlg::LineEditReturnPressed() QLineEdit* send = (QLineEdit*)sender(); if (send == Group1->LineEdit1 || send == Group1->LineEdit2 || - send == Group1->LineEdit3) { + send == Group1->LineEdit4 || + send == Group1->LineEdit5 ) { myEditCurrentArgument = send; GEOMBase_Skeleton::LineEditReturnPressed(); } + + if (send == Group1->LineEdit5) + Group1->CheckButton2->setEnabled(true); + else + Group1->CheckButton2->setEnabled(false); } //================================================================================= @@ -374,6 +555,9 @@ void TransformationGUI_PositionDlg::ActivateThisDialog() connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( SelectionIntoArgument() ) ); + ConstructorsClicked( getConstructorId() ); } @@ -405,8 +589,10 @@ bool TransformationGUI_PositionDlg::isValid (QString& /*msg*/) bool res; if (getConstructorId() == 0) res = !(myObjects.length() == 0 || myEndLCS->_is_nil()); - else + else if ( getConstructorId() == 1 ) res = !(myObjects.length() == 0 || myStartLCS->_is_nil() || myEndLCS->_is_nil()); + else if ( getConstructorId() == 2 ) + res = !(myObjects.length() == 0 || myPath->_is_nil()); return res; } @@ -418,7 +604,7 @@ bool TransformationGUI_PositionDlg::isValid (QString& /*msg*/) bool TransformationGUI_PositionDlg::execute (ObjectList& objects) { bool res = false; - bool toCreateCopy = IsPreview() || Group1->CheckBox1->isChecked(); + bool toCreateCopy = IsPreview() || Group1->CheckButton1->isChecked(); GEOM::GEOM_Object_var anObj; switch (getConstructorId()) { @@ -453,6 +639,19 @@ bool TransformationGUI_PositionDlg::execute (ObjectList& objects) res = true; break; } + case 2: + { + double aDistance = Group1->SpinBox_DX->value(); + bool toReverse = Group1->CheckButton3->isChecked(); + for (int i = 0; i < myObjects.length(); i++) { + anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> + PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy, toReverse); + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + } + res = true; + break; + } } return res; @@ -481,3 +680,16 @@ void TransformationGUI_PositionDlg::CreateCopyModeChanged (bool isCreateCopy) { mainFrame()->GroupBoxName->setEnabled(isCreateCopy); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_PositionDlg::addSubshapesToStudy() +{ + QMap objMap; + + objMap[Group1->LineEdit5->text()] = myPath; + + addSubshapesToFather(objMap); +} diff --git a/src/TransformationGUI/TransformationGUI_PositionDlg.h b/src/TransformationGUI/TransformationGUI_PositionDlg.h index 9a75d3ecc..a48959b92 100644 --- a/src/TransformationGUI/TransformationGUI_PositionDlg.h +++ b/src/TransformationGUI/TransformationGUI_PositionDlg.h @@ -28,7 +28,7 @@ #include -class DlgRef_3Sel3Spin1Check; +class DlgRef_4Sel1Spin3Check; //================================================================================= // class : TransformationGUI_PositionDlg @@ -49,6 +49,7 @@ protected: virtual bool isValid( QString& ); virtual bool execute( ObjectList& ); virtual void restoreSubShapes( SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr ); + virtual void addSubshapesToStudy(); private: void Init(); @@ -58,11 +59,12 @@ private: GEOM::GEOM_Object_var myStartLCS; GEOM::GEOM_Object_var myEndLCS; GEOM::ListOfGO myObjects; + GEOM::GEOM_Object_var myPath; // to initialize the first selection field with a selected object on the dialog creation bool myInitial; - - DlgRef_3Sel3Spin1Check* Group1; + + DlgRef_4Sel1Spin3Check* Group1; private slots: void ClickOnOk(); @@ -73,6 +75,8 @@ private slots: void SetEditCurrentArgument(); void ConstructorsClicked( int ); void CreateCopyModeChanged( bool ); + void ValueChangedInSpinBox(); + void SelectionTypeButtonClicked(); }; #endif // TRANSFORMATIONGUI_POSITIONDLG_H