Salome HOME
[bos #35151][EDF](2023-T1) Centered rectangle.
[modules/shaper.git] / src / SketchAPI / SketchAPI_Rectangle.h
1 // Copyright (C) 2014-2024  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef SRC_SKETCHAPI_SKETCHAPI_RECTANGLE_H_
21 #define SRC_SKETCHAPI_SKETCHAPI_RECTANGLE_H_
22
23 //--------------------------------------------------------------------------------------
24 #include "SketchAPI.h"
25
26 #include "SketchAPI_SketchEntity.h"
27
28 //--------------------------------------------------------------------------------------
29 class ModelHighAPI_Selection;
30 //--------------------------------------------------------------------------------------
31 /**\class SketchAPI_Rectangle
32  * \ingroup CPPHighAPI
33  * \brief Interface for Rectangle feature
34  */
35 class SketchAPI_Rectangle : public SketchAPI_SketchEntity
36 {
37 public:
38   /// Constructor without values
39   SKETCHAPI_EXPORT
40   explicit SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature);
41   /// Constructor with values
42   SKETCHAPI_EXPORT
43   SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature,
44                       double theX1, double theY1, 
45                       double theX2, double theY2, 
46                       bool theCreateByCenterAndCorner = false);
47   /// Constructor with values
48   SKETCHAPI_EXPORT
49   SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature,
50                       const std::shared_ptr<GeomAPI_Pnt2d> & thePoint1,
51                       const std::shared_ptr<GeomAPI_Pnt2d> & thePoint2,
52                       bool theCreateByCenterAndCorner = false);
53
54   
55
56   /// Destructor
57   SKETCHAPI_EXPORT
58   virtual ~SketchAPI_Rectangle();
59
60   INTERFACE_7("SketchRectangle",
61               type, "RectangleType", ModelAPI_AttributeString,
62               /** Creation type of rectangle */,
63               startPoint, "RectStartPoint", GeomDataAPI_Point2D,
64               /** Start point */,
65               endPoint, "RectEndPoint", GeomDataAPI_Point2D,
66               /** End point */,
67               centerPoint, "RectCenterPoint", GeomDataAPI_Point2D,
68               /** Center point */,
69               centerPointRef, "RectCenterPointRef", ModelAPI_AttributeRefAttr,
70               /** Reference to center point */,
71               cornerPoint, "RectCornerPoint", GeomDataAPI_Point2D,
72               /** Corner point */,
73               linesList, "RectangleList", ModelAPI_AttributeRefList,
74               /** Lines list */
75   )
76
77   /// Set by coordinates
78   SKETCHAPI_EXPORT
79   void setByCoordinates(double theX1, double theY1, double theX2, double theY2);
80
81   /// Set by points
82   SKETCHAPI_EXPORT
83   void setByPoints(const std::shared_ptr<GeomAPI_Pnt2d> & theFirstPoint,
84                    const std::shared_ptr<GeomAPI_Pnt2d> & theSecondPoint);
85
86   /// Set by coordinates
87   SKETCHAPI_EXPORT
88   void setByCenterAndCornerCoords(
89     double theCenterX, double theCenterY, 
90     double theCornerX, double theCornerY
91   );
92
93   /// Set by points
94   SKETCHAPI_EXPORT
95   void setByCenterAndCornerPoints(
96     const std::shared_ptr<GeomAPI_Pnt2d> & theCenterPoint,
97     const std::shared_ptr<GeomAPI_Pnt2d> & theCornerPoint
98   );
99
100   /// List of lines composing rectangle
101   SKETCHAPI_EXPORT std::list<std::shared_ptr<SketchAPI_SketchEntity> > lines() const;
102 };
103
104 //! Pointer on Rectangle object
105 typedef std::shared_ptr<SketchAPI_Rectangle> RectanglePtr;
106
107 //--------------------------------------------------------------------------------------
108 //--------------------------------------------------------------------------------------
109 #endif /* SRC_SKETCHAPI_SKETCHAPI_RECTANGLE_H_ */