From: spo Date: Thu, 16 Jun 2016 09:51:34 +0000 (+0300) Subject: Add Rotation X-Git-Tag: V_2.4.0~91^2~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=84fc5a28f68ca5301b9466f92b511ccf411de0fc;p=modules%2Fshaper.git Add Rotation --- diff --git a/src/SketchAPI/CMakeLists.txt b/src/SketchAPI/CMakeLists.txt index bfaacf314..af4603438 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_Rotation.h SketchAPI_Translation.h ) @@ -22,6 +23,7 @@ SET(PROJECT_SOURCES SketchAPI_Sketch.cpp SketchAPI_SketchEntity.cpp SketchAPI_Point.cpp + SketchAPI_Rotation.cpp SketchAPI_Translation.cpp ) diff --git a/src/SketchAPI/SketchAPI.i b/src/SketchAPI/SketchAPI.i index 9c3310935..c3b13cba1 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_Rotation) %shared_ptr(SketchAPI_Translation) // TODO(spo): move typemaps into ModelHighAPI package @@ -104,4 +105,5 @@ %include "SketchAPI_Arc.h" %include "SketchAPI_Mirror.h" %include "SketchAPI_Translation.h" +%include "SketchAPI_Rotation.h" %include "SketchAPI_Sketch.h" diff --git a/src/SketchAPI/SketchAPI_Rotation.cpp b/src/SketchAPI/SketchAPI_Rotation.cpp new file mode 100644 index 000000000..b7b5c546b --- /dev/null +++ b/src/SketchAPI/SketchAPI_Rotation.cpp @@ -0,0 +1,45 @@ +// Name : SketchAPI_Rotation.cpp +// Purpose: +// +// History: +// 16/06/16 - Sergey POKHODENKO - Creation of the file + +//-------------------------------------------------------------------------------------- +#include "SketchAPI_Rotation.h" +//-------------------------------------------------------------------------------------- +#include +//-------------------------------------------------------------------------------------- +SketchAPI_Rotation::SketchAPI_Rotation( + const std::shared_ptr & theFeature) +: SketchAPI_SketchEntity(theFeature) +{ + initialize(); +} + +SketchAPI_Rotation::SketchAPI_Rotation( + const std::shared_ptr & theFeature, + const std::list > & theObjects, + const ModelHighAPI_RefAttr & theCenter, + const ModelHighAPI_Double & theAngle, + const ModelHighAPI_Integer & theNumberOfObjects, + bool theFullValue) +: SketchAPI_SketchEntity(theFeature) +{ + if (initialize()) { + fillAttribute(theObjects, rotationList()); + fillAttribute(theCenter, center()); + fillAttribute(theAngle, angle()); + fillAttribute(theNumberOfObjects, numberOfObjects()); + if (theFullValue) + fillAttribute("SingleAngle", valueType()); + + execute(); + } +} + +SketchAPI_Rotation::~SketchAPI_Rotation() +{ + +} + +//-------------------------------------------------------------------------------------- diff --git a/src/SketchAPI/SketchAPI_Rotation.h b/src/SketchAPI/SketchAPI_Rotation.h new file mode 100644 index 000000000..e5a3281b4 --- /dev/null +++ b/src/SketchAPI/SketchAPI_Rotation.h @@ -0,0 +1,63 @@ +// Name : SketchAPI_Rotation.h +// Purpose: +// +// History: +// 16/06/16 - Sergey POKHODENKO - Creation of the file + +#ifndef SRC_SKETCHAPI_SKETCHAPI_ROTATION_H_ +#define SRC_SKETCHAPI_SKETCHAPI_ROTATION_H_ + +//-------------------------------------------------------------------------------------- +#include "SketchAPI.h" + +#include + +#include + +#include "SketchAPI_SketchEntity.h" +//-------------------------------------------------------------------------------------- +class ModelAPI_Object; +class ModelHighAPI_Double; +class ModelHighAPI_Integer; +class ModelHighAPI_RefAttr; +//-------------------------------------------------------------------------------------- +/**\class SketchAPI_Rotation + * \ingroup CPPHighAPI + * \brief Interface for Rotation feature + */ +class SketchAPI_Rotation : public SketchAPI_SketchEntity +{ +public: + /// Constructor without values + SKETCHAPI_EXPORT + explicit SketchAPI_Rotation(const std::shared_ptr & theFeature); + /// Constructor with values + SKETCHAPI_EXPORT + SketchAPI_Rotation(const std::shared_ptr & theFeature, + const std::list > & theObjects, + const ModelHighAPI_RefAttr & theCenter, + const ModelHighAPI_Double & theAngle, + const ModelHighAPI_Integer & theNumberOfObjects, + bool theFullValue = false); + /// Destructor + SKETCHAPI_EXPORT + virtual ~SketchAPI_Rotation(); + + INTERFACE_7(SketchPlugin_MultiRotation::ID(), + rotationList, SketchPlugin_MultiRotation::ROTATION_LIST_ID(), ModelAPI_AttributeRefList, /** Rotation list */, + center, SketchPlugin_MultiRotation::CENTER_ID(), ModelAPI_AttributeRefAttr, /** Center */, + angle, SketchPlugin_MultiRotation::ANGLE_ID(), ModelAPI_AttributeDouble, /** Angle */, + numberOfObjects, SketchPlugin_MultiRotation::NUMBER_OF_OBJECTS_ID(), ModelAPI_AttributeInteger, /** Number of objects */, + valueType, SketchPlugin_MultiRotation::ANGLE_TYPE(), ModelAPI_AttributeString, /** Value type */, + referenceObjects, SketchPlugin_MultiRotation::ENTITY_A(), ModelAPI_AttributeRefList, /** Reference objects */, + rotatedObjects, SketchPlugin_MultiRotation::ENTITY_B(), ModelAPI_AttributeRefList, /** Rotated objects */ + ) + +}; + +//! Pointer on Rotation object +typedef std::shared_ptr RotationPtr; + +//-------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------- +#endif /* SRC_SKETCHAPI_SKETCHAPI_ROTATION_H_ */ diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index 00807ac44..5f51c2592 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_Rotation.h" #include "SketchAPI_Translation.h" //-------------------------------------------------------------------------------------- SketchAPI_Sketch::SketchAPI_Sketch( @@ -336,6 +337,18 @@ std::shared_ptr SketchAPI_Sketch::addTranslation( return TranslationPtr(new SketchAPI_Translation(aFeature, theObjects, thePoint1, thePoint2, theNumberOfObjects, theFullValue)); } +//-------------------------------------------------------------------------------------- +std::shared_ptr SketchAPI_Sketch::addRotation( + const std::list > & theObjects, + const ModelHighAPI_RefAttr & theCenter, + const ModelHighAPI_Double & theAngle, + const ModelHighAPI_Integer & theNumberOfObjects, + bool theFullValue) +{ + std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_MultiRotation::ID()); + return RotationPtr(new SketchAPI_Rotation(aFeature, theObjects, theCenter, theAngle, 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 fb0278806..3e77725be 100644 --- a/src/SketchAPI/SketchAPI_Sketch.h +++ b/src/SketchAPI/SketchAPI_Sketch.h @@ -29,6 +29,7 @@ class SketchAPI_Circle; class SketchAPI_Line; class SketchAPI_Mirror; class SketchAPI_Point; +class SketchAPI_Rotation; class SketchAPI_Translation; //-------------------------------------------------------------------------------------- /**\class SketchAPI_Sketch @@ -200,6 +201,15 @@ public: const ModelHighAPI_Integer & theNumberOfObjects, bool theFullValue = false); + /// Add rotation + SKETCHAPI_EXPORT + std::shared_ptr addRotation( + const std::list > & theObjects, + const ModelHighAPI_RefAttr & theCenter, + const ModelHighAPI_Double & theAngle, + const ModelHighAPI_Integer & theNumberOfObjects, + bool theFullValue = false); + /// Set angle SKETCHAPI_EXPORT std::shared_ptr setAngle( @@ -289,7 +299,7 @@ public: std::shared_ptr setVertical( const ModelHighAPI_RefAttr & theLine); - // TODO(spo): addRectagle, projection, Translation, Rotation + // TODO(spo): addRectagle, projection /// Set constraint value SKETCHAPI_EXPORT diff --git a/src/SketchAPI/SketchAPI_swig.h b/src/SketchAPI/SketchAPI_swig.h index d418dd2cc..bddb075b1 100644 --- a/src/SketchAPI/SketchAPI_swig.h +++ b/src/SketchAPI/SketchAPI_swig.h @@ -17,6 +17,7 @@ #include "SketchAPI_Sketch.h" #include "SketchAPI_SketchEntity.h" #include "SketchAPI_Point.h" + #include "SketchAPI_Rotation.h" #include "SketchAPI_Translation.h" #endif /* SRC_SKETCHAPI_SKETCHAPI_SWIG_H_ */