1 // Copyright (C) 2014-2024 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SRC_SKETCHAPI_SKETCHAPI_RECTANGLE_H_
21 #define SRC_SKETCHAPI_SKETCHAPI_RECTANGLE_H_
23 //--------------------------------------------------------------------------------------
24 #include "SketchAPI.h"
26 #include "SketchAPI_SketchEntity.h"
28 //--------------------------------------------------------------------------------------
29 class ModelHighAPI_Selection;
30 class SketchAPI_Point;
31 //--------------------------------------------------------------------------------------
32 /**\class SketchAPI_Rectangle
34 * \brief Interface for Rectangle feature
36 class SketchAPI_Rectangle : public SketchAPI_SketchEntity
39 /// Constructor without values
41 explicit SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature);
42 /// Constructor with values
44 SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature,
45 double theX1, double theY1,
46 double theX2, double theY2,
47 bool theCreateByCenterAndCorner = false);
48 /// Constructor with values
50 SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature,
51 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint1,
52 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint2,
53 bool theCreateByCenterAndCorner = false);
59 virtual ~SketchAPI_Rectangle() = default;
61 INTERFACE_7("SketchRectangle",
62 type, "RectangleType", ModelAPI_AttributeString,
63 /** Creation type of rectangle */,
64 startPoint, "RectStartPoint", GeomDataAPI_Point2D,
66 endPoint, "RectEndPoint", GeomDataAPI_Point2D,
68 centerPoint, "RectCenterPoint", GeomDataAPI_Point2D,
70 centerPointRef, "RectCenterPointRef", ModelAPI_AttributeRefAttr,
71 /** Reference to center point */,
72 cornerPoint, "RectCornerPoint", GeomDataAPI_Point2D,
74 linesList, "RectangleList", ModelAPI_AttributeRefList,
78 /// Set by coordinates
80 void setByCoordinates(double theX1, double theY1, double theX2, double theY2);
84 void setByPoints(const std::shared_ptr<GeomAPI_Pnt2d> & theFirstPoint,
85 const std::shared_ptr<GeomAPI_Pnt2d> & theSecondPoint);
87 /// Set by coordinates
89 void setByCenterAndCornerCoords(
90 double theCenterX, double theCenterY,
91 double theCornerX, double theCornerY
96 void setByCenterAndCornerPoints(
97 const std::shared_ptr<GeomAPI_Pnt2d> & theCenterPoint,
98 const std::shared_ptr<GeomAPI_Pnt2d> & theCornerPoint
101 /// List of lines composing rectangle
102 SKETCHAPI_EXPORT std::list<std::shared_ptr<SketchAPI_SketchEntity> > lines() const;
104 SKETCHAPI_EXPORT std::shared_ptr<SketchAPI_Point> centerSketchPoint() const;
107 //! Pointer on Rectangle object
108 typedef std::shared_ptr<SketchAPI_Rectangle> RectanglePtr;
110 //--------------------------------------------------------------------------------------
111 //--------------------------------------------------------------------------------------
112 #endif /* SRC_SKETCHAPI_SKETCHAPI_RECTANGLE_H_ */