From d024af4f1ab972bfcddbd5766b9a9d99a72a9e38 Mon Sep 17 00:00:00 2001 From: spo Date: Thu, 16 Jun 2016 12:36:03 +0300 Subject: [PATCH] Add Translation --- src/SketchAPI/CMakeLists.txt | 2 + src/SketchAPI/SketchAPI.i | 2 + src/SketchAPI/SketchAPI_Mirror.h | 2 +- src/SketchAPI/SketchAPI_Sketch.cpp | 13 ++++++ src/SketchAPI/SketchAPI_Sketch.h | 11 +++++ src/SketchAPI/SketchAPI_Translation.cpp | 45 ++++++++++++++++++ src/SketchAPI/SketchAPI_Translation.h | 62 +++++++++++++++++++++++++ src/SketchAPI/SketchAPI_swig.h | 1 + 8 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 src/SketchAPI/SketchAPI_Translation.cpp create mode 100644 src/SketchAPI/SketchAPI_Translation.h diff --git a/src/SketchAPI/CMakeLists.txt b/src/SketchAPI/CMakeLists.txt index 9d6ded27c..bfaacf314 100644 --- a/src/SketchAPI/CMakeLists.txt +++ b/src/SketchAPI/CMakeLists.txt @@ -11,6 +11,7 @@ SET(PROJECT_HEADERS SketchAPI_Sketch.h SketchAPI_SketchEntity.h SketchAPI_Point.h + SketchAPI_Translation.h ) SET(PROJECT_SOURCES @@ -21,6 +22,7 @@ SET(PROJECT_SOURCES SketchAPI_Sketch.cpp SketchAPI_SketchEntity.cpp SketchAPI_Point.cpp + SketchAPI_Translation.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/SketchAPI/SketchAPI.i b/src/SketchAPI/SketchAPI.i index 7359f1d9a..9c3310935 100644 --- a/src/SketchAPI/SketchAPI.i +++ b/src/SketchAPI/SketchAPI.i @@ -27,6 +27,7 @@ %shared_ptr(SketchAPI_Sketch) %shared_ptr(SketchAPI_SketchEntity) %shared_ptr(SketchAPI_Point) +%shared_ptr(SketchAPI_Translation) // TODO(spo): move typemaps into ModelHighAPI package @@ -102,4 +103,5 @@ %include "SketchAPI_Circle.h" %include "SketchAPI_Arc.h" %include "SketchAPI_Mirror.h" +%include "SketchAPI_Translation.h" %include "SketchAPI_Sketch.h" diff --git a/src/SketchAPI/SketchAPI_Mirror.h b/src/SketchAPI/SketchAPI_Mirror.h index 9f3848d39..9cd2d5488 100644 --- a/src/SketchAPI/SketchAPI_Mirror.h +++ b/src/SketchAPI/SketchAPI_Mirror.h @@ -41,7 +41,7 @@ public: INTERFACE_4(SketchPlugin_ConstraintMirror::ID(), mirrorLine, SketchPlugin_ConstraintMirror::ENTITY_A(), ModelAPI_AttributeRefAttr, /** Mirror line */, mirrorList, SketchPlugin_ConstraintMirror::MIRROR_LIST_ID(), ModelAPI_AttributeRefList, /** Mirror list */, - sourceObjects, SketchPlugin_ConstraintMirror::ENTITY_B(), ModelAPI_AttributeRefList, /** Source objects */, + referenceObjects, SketchPlugin_ConstraintMirror::ENTITY_B(), ModelAPI_AttributeRefList, /** Reference objects */, mirroredObjects, SketchPlugin_ConstraintMirror::ENTITY_C(), ModelAPI_AttributeRefList, /** Mirrored objects */ ) diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index ab58eec60..00807ac44 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -36,6 +36,7 @@ #include "SketchAPI_Line.h" #include "SketchAPI_Mirror.h" #include "SketchAPI_Point.h" +#include "SketchAPI_Translation.h" //-------------------------------------------------------------------------------------- SketchAPI_Sketch::SketchAPI_Sketch( const std::shared_ptr & theFeature) @@ -323,6 +324,18 @@ std::shared_ptr SketchAPI_Sketch::addMirror( return MirrorPtr(new SketchAPI_Mirror(aFeature, theMirrorLine, theObjects)); } +//-------------------------------------------------------------------------------------- +std::shared_ptr SketchAPI_Sketch::addTranslation( + const std::list > & theObjects, + const ModelHighAPI_RefAttr & thePoint1, + const ModelHighAPI_RefAttr & thePoint2, + const ModelHighAPI_Integer & theNumberOfObjects, + bool theFullValue) +{ + std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_MultiTranslation::ID()); + return TranslationPtr(new SketchAPI_Translation(aFeature, theObjects, thePoint1, thePoint2, theNumberOfObjects, theFullValue)); +} + //-------------------------------------------------------------------------------------- std::shared_ptr SketchAPI_Sketch::setAngle( const ModelHighAPI_RefAttr & theLine1, diff --git a/src/SketchAPI/SketchAPI_Sketch.h b/src/SketchAPI/SketchAPI_Sketch.h index 8525b4388..fb0278806 100644 --- a/src/SketchAPI/SketchAPI_Sketch.h +++ b/src/SketchAPI/SketchAPI_Sketch.h @@ -21,6 +21,7 @@ class ModelAPI_CompositeFeature; class ModelAPI_Object; class ModelHighAPI_Double; +class ModelHighAPI_Integer; class ModelHighAPI_RefAttr; class ModelHighAPI_Selection; class SketchAPI_Arc; @@ -28,6 +29,7 @@ class SketchAPI_Circle; class SketchAPI_Line; class SketchAPI_Mirror; class SketchAPI_Point; +class SketchAPI_Translation; //-------------------------------------------------------------------------------------- /**\class SketchAPI_Sketch * \ingroup CPPHighAPI @@ -189,6 +191,15 @@ public: const ModelHighAPI_RefAttr & theMirrorLine, const std::list > & theObjects); + /// Add translation + SKETCHAPI_EXPORT + std::shared_ptr addTranslation( + const std::list > & theObjects, + const ModelHighAPI_RefAttr & thePoint1, + const ModelHighAPI_RefAttr & thePoint2, + const ModelHighAPI_Integer & theNumberOfObjects, + bool theFullValue = false); + /// Set angle SKETCHAPI_EXPORT std::shared_ptr setAngle( diff --git a/src/SketchAPI/SketchAPI_Translation.cpp b/src/SketchAPI/SketchAPI_Translation.cpp new file mode 100644 index 000000000..0ba3e3b3f --- /dev/null +++ b/src/SketchAPI/SketchAPI_Translation.cpp @@ -0,0 +1,45 @@ +// Name : SketchAPI_Translation.cpp +// Purpose: +// +// History: +// 16/06/16 - Sergey POKHODENKO - Creation of the file + +//-------------------------------------------------------------------------------------- +#include "SketchAPI_Translation.h" +//-------------------------------------------------------------------------------------- +#include +//-------------------------------------------------------------------------------------- +SketchAPI_Translation::SketchAPI_Translation( + const std::shared_ptr & theFeature) +: SketchAPI_SketchEntity(theFeature) +{ + initialize(); +} + +SketchAPI_Translation::SketchAPI_Translation( + const std::shared_ptr & theFeature, + const std::list > & theObjects, + const ModelHighAPI_RefAttr & thePoint1, + const ModelHighAPI_RefAttr & thePoint2, + const ModelHighAPI_Integer & theNumberOfObjects, + bool theFullValue) +: SketchAPI_SketchEntity(theFeature) +{ + if (initialize()) { + fillAttribute(theObjects, translationList()); + fillAttribute(thePoint1, startPoint()); + fillAttribute(thePoint2, endPoint()); + fillAttribute(theNumberOfObjects, numberOfObjects()); + if (theFullValue) + fillAttribute("SingleValue", valueType()); + + execute(); + } +} + +SketchAPI_Translation::~SketchAPI_Translation() +{ + +} + +//-------------------------------------------------------------------------------------- diff --git a/src/SketchAPI/SketchAPI_Translation.h b/src/SketchAPI/SketchAPI_Translation.h new file mode 100644 index 000000000..7b6da8f5e --- /dev/null +++ b/src/SketchAPI/SketchAPI_Translation.h @@ -0,0 +1,62 @@ +// Name : SketchAPI_Translation.h +// Purpose: +// +// History: +// 16/06/16 - Sergey POKHODENKO - Creation of the file + +#ifndef SRC_SKETCHAPI_SKETCHAPI_TRANSLATION_H_ +#define SRC_SKETCHAPI_SKETCHAPI_TRANSLATION_H_ + +//-------------------------------------------------------------------------------------- +#include "SketchAPI.h" + +#include + +#include + +#include "SketchAPI_SketchEntity.h" +//-------------------------------------------------------------------------------------- +class ModelAPI_Object; +class ModelHighAPI_Integer; +class ModelHighAPI_RefAttr; +//-------------------------------------------------------------------------------------- +/**\class SketchAPI_Translation + * \ingroup CPPHighAPI + * \brief Interface for Translation feature + */ +class SketchAPI_Translation : public SketchAPI_SketchEntity +{ +public: + /// Constructor without values + SKETCHAPI_EXPORT + explicit SketchAPI_Translation(const std::shared_ptr & theFeature); + /// Constructor with values + SKETCHAPI_EXPORT + SketchAPI_Translation(const std::shared_ptr & theFeature, + const std::list > & theObjects, + const ModelHighAPI_RefAttr & thePoint1, + const ModelHighAPI_RefAttr & thePoint2, + const ModelHighAPI_Integer & theNumberOfObjects, + bool theFullValue = false); + /// Destructor + SKETCHAPI_EXPORT + virtual ~SketchAPI_Translation(); + + INTERFACE_7(SketchPlugin_MultiTranslation::ID(), + translationList, SketchPlugin_MultiTranslation::TRANSLATION_LIST_ID(), ModelAPI_AttributeRefList, /** Translation list */, + startPoint, SketchPlugin_MultiTranslation::START_POINT_ID(), ModelAPI_AttributeRefAttr, /** Start point */, + endPoint, SketchPlugin_MultiTranslation::END_POINT_ID(), ModelAPI_AttributeRefAttr, /** Start point */, + numberOfObjects, SketchPlugin_MultiTranslation::NUMBER_OF_OBJECTS_ID(), ModelAPI_AttributeInteger, /** Number of objects */, + valueType, SketchPlugin_MultiTranslation::VALUE_TYPE(), ModelAPI_AttributeString, /** Value type */, + referenceObjects, SketchPlugin_MultiTranslation::ENTITY_A(), ModelAPI_AttributeRefList, /** Reference objects */, + translatedObjects, SketchPlugin_MultiTranslation::ENTITY_B(), ModelAPI_AttributeRefList, /** Translationed objects */ + ) + +}; + +//! Pointer on Translation object +typedef std::shared_ptr TranslationPtr; + +//-------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------- +#endif /* SRC_SKETCHAPI_SKETCHAPI_TRANSLATION_H_ */ diff --git a/src/SketchAPI/SketchAPI_swig.h b/src/SketchAPI/SketchAPI_swig.h index c65c853f2..d418dd2cc 100644 --- a/src/SketchAPI/SketchAPI_swig.h +++ b/src/SketchAPI/SketchAPI_swig.h @@ -17,5 +17,6 @@ #include "SketchAPI_Sketch.h" #include "SketchAPI_SketchEntity.h" #include "SketchAPI_Point.h" + #include "SketchAPI_Translation.h" #endif /* SRC_SKETCHAPI_SKETCHAPI_SWIG_H_ */ -- 2.30.2