From 4ad0c5b28d44db6390e81870858b7b3f7285ae21 Mon Sep 17 00:00:00 2001 From: spo Date: Thu, 16 Jun 2016 14:38:17 +0300 Subject: [PATCH] Add Projection to SketchAPI_Sketch --- src/SketchAPI/CMakeLists.txt | 2 + src/SketchAPI/SketchAPI.i | 2 + src/SketchAPI/SketchAPI_Projection.cpp | 42 ++++++++++++++++++++ src/SketchAPI/SketchAPI_Projection.h | 53 ++++++++++++++++++++++++++ src/SketchAPI/SketchAPI_Sketch.cpp | 9 +++++ src/SketchAPI/SketchAPI_Sketch.h | 6 +++ src/SketchAPI/SketchAPI_swig.h | 1 + 7 files changed, 115 insertions(+) create mode 100644 src/SketchAPI/SketchAPI_Projection.cpp create mode 100644 src/SketchAPI/SketchAPI_Projection.h diff --git a/src/SketchAPI/CMakeLists.txt b/src/SketchAPI/CMakeLists.txt index a8b5cc284..e0ab0cfa2 100644 --- a/src/SketchAPI/CMakeLists.txt +++ b/src/SketchAPI/CMakeLists.txt @@ -12,6 +12,7 @@ SET(PROJECT_HEADERS SketchAPI_Sketch.h SketchAPI_SketchEntity.h SketchAPI_Point.h + SketchAPI_Projection.h SketchAPI_Rotation.h SketchAPI_Translation.h ) @@ -25,6 +26,7 @@ SET(PROJECT_SOURCES SketchAPI_Sketch.cpp SketchAPI_SketchEntity.cpp SketchAPI_Point.cpp + SketchAPI_Projection.cpp SketchAPI_Rotation.cpp SketchAPI_Translation.cpp ) diff --git a/src/SketchAPI/SketchAPI.i b/src/SketchAPI/SketchAPI.i index b6c25fee4..955249b70 100644 --- a/src/SketchAPI/SketchAPI.i +++ b/src/SketchAPI/SketchAPI.i @@ -28,6 +28,7 @@ %shared_ptr(SketchAPI_Sketch) %shared_ptr(SketchAPI_SketchEntity) %shared_ptr(SketchAPI_Point) +%shared_ptr(SketchAPI_Projection) %shared_ptr(SketchAPI_Rotation) %shared_ptr(SketchAPI_Translation) @@ -105,6 +106,7 @@ %include "SketchAPI_Line.h" %include "SketchAPI_Circle.h" %include "SketchAPI_Arc.h" +%include "SketchAPI_Projection.h" %include "SketchAPI_Mirror.h" %include "SketchAPI_Translation.h" %include "SketchAPI_Rotation.h" diff --git a/src/SketchAPI/SketchAPI_Projection.cpp b/src/SketchAPI/SketchAPI_Projection.cpp new file mode 100644 index 000000000..7ac33fc91 --- /dev/null +++ b/src/SketchAPI/SketchAPI_Projection.cpp @@ -0,0 +1,42 @@ +// Name : SketchAPI_Projection.cpp +// Purpose: +// +// History: +// 16/06/16 - Sergey POKHODENKO - Creation of the file + +//-------------------------------------------------------------------------------------- +#include "SketchAPI_Projection.h" +//-------------------------------------------------------------------------------------- +#include +//-------------------------------------------------------------------------------------- +SketchAPI_Projection::SketchAPI_Projection( + const std::shared_ptr & theFeature) +: SketchAPI_SketchEntity(theFeature) +{ + initialize(); +} + +SketchAPI_Projection::SketchAPI_Projection( + const std::shared_ptr & theFeature, + const ModelHighAPI_Selection & theExternalFeature ) +: SketchAPI_SketchEntity(theFeature) +{ + if (initialize()) { + setExternalFeature(theExternalFeature); + } +} + +SketchAPI_Projection::~SketchAPI_Projection() +{ + +} + +//-------------------------------------------------------------------------------------- +void SketchAPI_Projection::setExternalFeature(const ModelHighAPI_Selection & theExternalFeature) +{ + fillAttribute(theExternalFeature, externalFeature()); + + execute(); +} + +//-------------------------------------------------------------------------------------- diff --git a/src/SketchAPI/SketchAPI_Projection.h b/src/SketchAPI/SketchAPI_Projection.h new file mode 100644 index 000000000..cf18e20f3 --- /dev/null +++ b/src/SketchAPI/SketchAPI_Projection.h @@ -0,0 +1,53 @@ +// Name : SketchAPI_Projection.h +// Purpose: +// +// History: +// 16/06/16 - Sergey POKHODENKO - Creation of the file + +#ifndef SRC_SKETCHAPI_SKETCHAPI_PROJECTION_H_ +#define SRC_SKETCHAPI_SKETCHAPI_PROJECTION_H_ + +//-------------------------------------------------------------------------------------- +#include "SketchAPI.h" + +#include + +#include "SketchAPI_SketchEntity.h" +//-------------------------------------------------------------------------------------- +class ModelHighAPI_Selection; +//-------------------------------------------------------------------------------------- +/**\class SketchAPI_Projection + * \ingroup CPPHighAPI + * \brief Interface for Projection feature + */ +class SketchAPI_Projection : public SketchAPI_SketchEntity +{ +public: + /// Constructor without values + SKETCHAPI_EXPORT + explicit SketchAPI_Projection(const std::shared_ptr & theFeature); + /// Constructor with values + SKETCHAPI_EXPORT + SketchAPI_Projection(const std::shared_ptr & theFeature, + const ModelHighAPI_Selection & theExternalFeature); + /// Destructor + SKETCHAPI_EXPORT + virtual ~SketchAPI_Projection(); + + INTERFACE_3(SketchPlugin_Projection::ID(), + externalFeature, SketchPlugin_Projection::EXTERNAL_FEATURE_ID(), ModelAPI_AttributeSelection, /** External feature */, + projectedFeature, SketchPlugin_Projection::EXTERNAL_FEATURE_ID(), ModelAPI_AttributeRefAttr, /** Projected feature */, + external, SketchPlugin_Projection::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */ + ) + + /// Set external feature + SKETCHAPI_EXPORT + void setExternalFeature(const ModelHighAPI_Selection & theExternalLine); +}; + +//! Pointer on Projection object +typedef std::shared_ptr ProjectionPtr; + +//-------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------- +#endif /* SRC_SKETCHAPI_SKETCHAPI_PROJECTION_H_ */ diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index 4accfa347..bf97b9809 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -37,6 +37,7 @@ #include "SketchAPI_Line.h" #include "SketchAPI_Mirror.h" #include "SketchAPI_Point.h" +#include "SketchAPI_Projection.h" #include "SketchAPI_Rotation.h" #include "SketchAPI_Translation.h" //-------------------------------------------------------------------------------------- @@ -331,6 +332,14 @@ std::shared_ptr SketchAPI_Sketch::addArc(const std::string & theE return ArcPtr(new SketchAPI_Arc(aFeature, theExternalName)); } +//-------------------------------------------------------------------------------------- +std::shared_ptr SketchAPI_Sketch::addProjection( + const ModelHighAPI_Selection & theExternalFeature) +{ + std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_Projection::ID()); + return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalFeature)); +} + //-------------------------------------------------------------------------------------- std::shared_ptr SketchAPI_Sketch::addMirror( const ModelHighAPI_RefAttr & theMirrorLine, diff --git a/src/SketchAPI/SketchAPI_Sketch.h b/src/SketchAPI/SketchAPI_Sketch.h index 2f7694921..9fd874bc9 100644 --- a/src/SketchAPI/SketchAPI_Sketch.h +++ b/src/SketchAPI/SketchAPI_Sketch.h @@ -30,6 +30,7 @@ class SketchAPI_IntersectionPoint; class SketchAPI_Line; class SketchAPI_Mirror; class SketchAPI_Point; +class SketchAPI_Projection; class SketchAPI_Rotation; class SketchAPI_Translation; //-------------------------------------------------------------------------------------- @@ -194,6 +195,11 @@ public: SKETCHAPI_EXPORT std::shared_ptr addArc(const std::string & theExternalName); + /// Add projection + SKETCHAPI_EXPORT + std::shared_ptr addProjection( + const ModelHighAPI_Selection & theExternalFeature); + /// Add mirror SKETCHAPI_EXPORT std::shared_ptr addMirror( diff --git a/src/SketchAPI/SketchAPI_swig.h b/src/SketchAPI/SketchAPI_swig.h index 1280b96a6..a8b2bfbc5 100644 --- a/src/SketchAPI/SketchAPI_swig.h +++ b/src/SketchAPI/SketchAPI_swig.h @@ -18,6 +18,7 @@ #include "SketchAPI_Sketch.h" #include "SketchAPI_SketchEntity.h" #include "SketchAPI_Point.h" + #include "SketchAPI_Projection.h" #include "SketchAPI_Rotation.h" #include "SketchAPI_Translation.h" -- 2.30.2