SketchAPI_SketchEntity.h
SketchAPI_Point.h
SketchAPI_Projection.h
+ SketchAPI_Rectangle.h
SketchAPI_Rotation.h
SketchAPI_Translation.h
)
SketchAPI_SketchEntity.cpp
SketchAPI_Point.cpp
SketchAPI_Projection.cpp
+ SketchAPI_Rectangle.cpp
SketchAPI_Rotation.cpp
SketchAPI_Translation.cpp
)
%shared_ptr(SketchAPI_SketchEntity)
%shared_ptr(SketchAPI_Point)
%shared_ptr(SketchAPI_Projection)
+%shared_ptr(SketchAPI_Rectangle)
%shared_ptr(SketchAPI_Rotation)
%shared_ptr(SketchAPI_Translation)
%include "SketchAPI_Projection.h"
%include "SketchAPI_Mirror.h"
%include "SketchAPI_Translation.h"
+%include "SketchAPI_Rectangle.h"
%include "SketchAPI_Rotation.h"
%include "SketchAPI_Sketch.h"
--- /dev/null
+// Name : SketchAPI_Rectangle.cpp
+// Purpose:
+//
+// History:
+// 17/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI_Rectangle.h"
+//--------------------------------------------------------------------------------------
+#include <GeomAPI_Pnt2d.h>
+//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+//--------------------------------------------------------------------------------------
+SketchAPI_Rectangle::SketchAPI_Rectangle(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: SketchAPI_SketchEntity(theFeature)
+{
+ initialize();
+}
+
+SketchAPI_Rectangle::SketchAPI_Rectangle(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ double theX1, double theY1, double theX2, double theY2)
+: SketchAPI_SketchEntity(theFeature)
+{
+ if (initialize()) {
+ setByCoordinates(theX1, theY1, theX2, theY2);
+ }
+}
+
+SketchAPI_Rectangle::SketchAPI_Rectangle(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+: SketchAPI_SketchEntity(theFeature)
+{
+ if (initialize()) {
+ setByPoints(theStartPoint, theEndPoint);
+ }
+}
+
+SketchAPI_Rectangle::~SketchAPI_Rectangle()
+{
+}
+
+//--------------------------------------------------------------------------------------
+void SketchAPI_Rectangle::setByCoordinates(
+ double theX1, double theY1, double theX2, double theY2)
+{
+ fillAttribute(startPoint(), theX1, theY1);
+ fillAttribute(endPoint(), theX2, theY2);
+
+ execute();
+}
+
+void SketchAPI_Rectangle::setByPoints(
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+{
+ fillAttribute(theStartPoint, startPoint());
+ fillAttribute(theEndPoint, endPoint());
+
+ execute();
+}
+
+//--------------------------------------------------------------------------------------
+
--- /dev/null
+// Name : SketchAPI_Rectangle.h
+// Purpose:
+//
+// History:
+// 17/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_SKETCHAPI_SKETCHAPI_RECTANGLE_H_
+#define SRC_SKETCHAPI_SKETCHAPI_RECTANGLE_H_
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI.h"
+
+#include "SketchAPI_SketchEntity.h"
+//--------------------------------------------------------------------------------------
+class ModelHighAPI_Selection;
+//--------------------------------------------------------------------------------------
+/**\class SketchAPI_Rectangle
+ * \ingroup CPPHighAPI
+ * \brief Interface for Rectangle feature
+ */
+class SketchAPI_Rectangle : public SketchAPI_SketchEntity
+{
+public:
+ /// Constructor without values
+ SKETCHAPI_EXPORT
+ explicit SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+ /// Constructor with values
+ SKETCHAPI_EXPORT
+ SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ double theX1, double theY1, double theX2, double theY2);
+ /// Constructor with values
+ SKETCHAPI_EXPORT
+ SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+ /// Destructor
+ SKETCHAPI_EXPORT
+ virtual ~SketchAPI_Rectangle();
+
+ INTERFACE_3("SketchRectangle",
+ startPoint, "RectStartPoint", GeomDataAPI_Point2D, /** Start point */,
+ endPoint, "RectEndPoint", GeomDataAPI_Point2D, /** End point */,
+ linesList, "RectangleList", ModelAPI_AttributeRefList, /** Lines list */
+ )
+
+ /// Set by coordinates
+ SKETCHAPI_EXPORT
+ void setByCoordinates(double theX1, double theY1, double theX2, double theY2);
+
+ /// Set by points
+ SKETCHAPI_EXPORT
+ void setByPoints(const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+};
+
+//! Pointer on Rectangle object
+typedef std::shared_ptr<SketchAPI_Rectangle> RectanglePtr;
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_SKETCHAPI_SKETCHAPI_RECTANGLE_H_ */
#include "SketchAPI_Mirror.h"
#include "SketchAPI_Point.h"
#include "SketchAPI_Projection.h"
+#include "SketchAPI_Rectangle.h"
#include "SketchAPI_Rotation.h"
#include "SketchAPI_Translation.h"
//--------------------------------------------------------------------------------------
return LinePtr(new SketchAPI_Line(aFeature, theExternalName));
}
+//--------------------------------------------------------------------------------------
+std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(double theX1, double theY1, double theX2, double theY2)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
+ return RectanglePtr(new SketchAPI_Rectangle(aFeature, theX1, theY1, theX2, theY2));
+}
+std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
+ return RectanglePtr(new SketchAPI_Rectangle(aFeature, theStartPoint, theEndPoint));
+}
+
//--------------------------------------------------------------------------------------
std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(double theCenterX,
double theCenterY,
class SketchAPI_Mirror;
class SketchAPI_Point;
class SketchAPI_Projection;
+class SketchAPI_Rectangle;
class SketchAPI_Rotation;
class SketchAPI_Translation;
//--------------------------------------------------------------------------------------
SKETCHAPI_EXPORT
std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
+ /// Add rectangle
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Rectangle> addRectangle(
+ double theX1, double theY1, double theX2, double theY2);
+ /// Add rectangle
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Rectangle> addRectangle(
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+
/// Add circle
SKETCHAPI_EXPORT
std::shared_ptr<SketchAPI_Circle> addCircle(
#include "SketchAPI_SketchEntity.h"
#include "SketchAPI_Point.h"
#include "SketchAPI_Projection.h"
+ #include "SketchAPI_Rectangle.h"
#include "SketchAPI_Rotation.h"
#include "SketchAPI_Translation.h"