From 1c109c614957e7b090a0556b37d2cde412f7d75a Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 7 Jul 2014 18:30:13 +0400 Subject: [PATCH] Features plug-in created with Extrusion operation. --- CMakeLists.txt | 1 + src/Config/plugins.xml | 1 + src/ConstructionPlugin/CMakeLists.txt | 3 -- .../ConstructionPlugin_Plugin.cpp | 3 -- .../plugin-Construction.xml | 3 -- src/FeaturesPlugin/CMakeLists.txt | 30 +++++++++++++++++++ src/FeaturesPlugin/FeaturesPlugin.h | 18 +++++++++++ .../FeaturesPlugin_Extrusion.cpp} | 10 +++---- .../FeaturesPlugin_Extrusion.h} | 26 ++++++++-------- src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp | 25 ++++++++++++++++ src/FeaturesPlugin/FeaturesPlugin_Plugin.h | 24 +++++++++++++++ .../extrusion_widget.xml | 0 src/FeaturesPlugin/plugin-Features.xml | 9 ++++++ 13 files changed, 126 insertions(+), 27 deletions(-) create mode 100644 src/FeaturesPlugin/CMakeLists.txt create mode 100644 src/FeaturesPlugin/FeaturesPlugin.h rename src/{ConstructionPlugin/ConstructionPlugin_Extrusion.cpp => FeaturesPlugin/FeaturesPlugin_Extrusion.cpp} (82%) rename src/{ConstructionPlugin/ConstructionPlugin_Extrusion.h => FeaturesPlugin/FeaturesPlugin_Extrusion.h} (51%) create mode 100644 src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp create mode 100644 src/FeaturesPlugin/FeaturesPlugin_Plugin.h rename src/{ConstructionPlugin => FeaturesPlugin}/extrusion_widget.xml (100%) create mode 100644 src/FeaturesPlugin/plugin-Features.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f70d821c..7a276cea1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ ADD_SUBDIRECTORY (src/GeomData) ADD_SUBDIRECTORY (src/GeomDataAPI) ADD_SUBDIRECTORY (src/PartSetPlugin) ADD_SUBDIRECTORY (src/ConstructionPlugin) +ADD_SUBDIRECTORY (src/FeaturesPlugin) ADD_SUBDIRECTORY (src/SketchPlugin) ADD_SUBDIRECTORY (src/SketchSolver) ADD_SUBDIRECTORY (src/ModuleBase) diff --git a/src/Config/plugins.xml b/src/Config/plugins.xml index e54794df6..a4d1dbdae 100644 --- a/src/Config/plugins.xml +++ b/src/Config/plugins.xml @@ -2,6 +2,7 @@ + diff --git a/src/ConstructionPlugin/CMakeLists.txt b/src/ConstructionPlugin/CMakeLists.txt index dc32be987..1c81b62aa 100644 --- a/src/ConstructionPlugin/CMakeLists.txt +++ b/src/ConstructionPlugin/CMakeLists.txt @@ -4,13 +4,11 @@ SET(PROJECT_HEADERS ConstructionPlugin.h ConstructionPlugin_Plugin.h ConstructionPlugin_Point.h - ConstructionPlugin_Extrusion.h ) SET(PROJECT_SOURCES ConstructionPlugin_Plugin.cpp ConstructionPlugin_Point.cpp - ConstructionPlugin_Extrusion.cpp ) ADD_DEFINITIONS(-DCONSTRUCTIONPLUGIN_EXPORTS ${BOOST_DEFINITIONS}) @@ -26,7 +24,6 @@ INCLUDE_DIRECTORIES( SET(XML_RESOURCES plugin-Construction.xml point_widget.xml - extrusion_widget.xml ) INSTALL(TARGETS ConstructionPlugin DESTINATION plugins) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp index d420b2110..6b0d729a4 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp @@ -1,6 +1,5 @@ #include "ConstructionPlugin_Plugin.h" #include "ConstructionPlugin_Point.h" -#include "ConstructionPlugin_Extrusion.h" #include #include @@ -20,8 +19,6 @@ FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID) { if (theFeatureID == CONSTRUCTION_POINT_KIND) { return FeaturePtr(new ConstructionPlugin_Point); - } else if (theFeatureID == CONSTRUCTION_EXTRUSION_KIND) { - return FeaturePtr(new ConstructionPlugin_Extrusion); } // feature of such kind is not found return FeaturePtr(); diff --git a/src/ConstructionPlugin/plugin-Construction.xml b/src/ConstructionPlugin/plugin-Construction.xml index 4736d36cf..b3fdc4608 100644 --- a/src/ConstructionPlugin/plugin-Construction.xml +++ b/src/ConstructionPlugin/plugin-Construction.xml @@ -6,9 +6,6 @@ - - - diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt new file mode 100644 index 000000000..29e08785f --- /dev/null +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -0,0 +1,30 @@ +INCLUDE(Common) + +SET(PROJECT_HEADERS + FeaturesPlugin.h + FeaturesPlugin_Plugin.h + FeaturesPlugin_Extrusion.h +) + +SET(PROJECT_SOURCES + FeaturesPlugin_Plugin.cpp + FeaturesPlugin_Extrusion.cpp +) + +ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS ${BOOST_DEFINITIONS}) +ADD_LIBRARY(FeaturesPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(FeaturesPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI) + +INCLUDE_DIRECTORIES( + ../ModelAPI + ../GeomAPI + ../GeomAlgoAPI +) + +SET(XML_RESOURCES + plugin-Features.xml + extrusion_widget.xml +) + +INSTALL(TARGETS FeaturesPlugin DESTINATION plugins) +INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins) diff --git a/src/FeaturesPlugin/FeaturesPlugin.h b/src/FeaturesPlugin/FeaturesPlugin.h new file mode 100644 index 000000000..2e931e293 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin.h @@ -0,0 +1,18 @@ +#ifndef FEATURESPLUGIN_H +#define FEATURESPLUGIN_H + +#if defined FEATURESPLUGIN_EXPORTS +#if defined WIN32 +#define FEATURESPLUGIN_EXPORT __declspec( dllexport ) +#else +#define FEATURESPLUGIN_EXPORT +#endif +#else +#if defined WIN32 +#define FEATURESPLUGIN_EXPORT __declspec( dllimport ) +#else +#define FEATURESPLUGIN_EXPORT +#endif +#endif + +#endif diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp similarity index 82% rename from src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp rename to src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index 0af9cad3b..328dde5f0 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -1,8 +1,8 @@ -// File: ConstructionPlugin_Extrusion.cpp +// File: FeaturesPlugin_Extrusion.cpp // Created: 30 May 2014 // Author: Vitaly SMETANNIKOV -#include "ConstructionPlugin_Extrusion.h" +#include "FeaturesPlugin_Extrusion.h" #include #include #include @@ -14,18 +14,18 @@ using namespace std; -ConstructionPlugin_Extrusion::ConstructionPlugin_Extrusion() +FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion() { } -void ConstructionPlugin_Extrusion::initAttributes() +void FeaturesPlugin_Extrusion::initAttributes() { data()->addAttribute(EXTRUSION_FACE, ModelAPI_AttributeReference::type()); data()->addAttribute(EXTRUSION_SIZE, ModelAPI_AttributeDouble::type()); data()->addAttribute(EXTRUSION_REVERSE, ModelAPI_AttributeBoolean::type()); } -void ConstructionPlugin_Extrusion::execute() +void FeaturesPlugin_Extrusion::execute() { boost::shared_ptr aFaceRef = boost::dynamic_pointer_cast(data()->attribute(EXTRUSION_FACE)); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h similarity index 51% rename from src/ConstructionPlugin/ConstructionPlugin_Extrusion.h rename to src/FeaturesPlugin/FeaturesPlugin_Extrusion.h index 5933929b8..95c8f98ae 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h @@ -1,15 +1,15 @@ -// File: ConstructionPlugin_Extrusion.h +// File: FeaturesPlugin_Extrusion.h // Created: 30 May 2014 // Author: Vitaly SMETANNIKOV -#ifndef ConstructionPlugin_Extrusion_HeaderFile -#define ConstructionPlugin_Extrusion_HeaderFile +#ifndef FeaturesPlugin_Extrusion_HeaderFile +#define FeaturesPlugin_Extrusion_HeaderFile -#include "ConstructionPlugin.h" +#include "FeaturesPlugin.h" #include /// Extrusion kind -const std::string CONSTRUCTION_EXTRUSION_KIND("Extrusion"); +const std::string FEATURES_EXTRUSION_KIND("Extrusion"); /// attribute name of referenced face const std::string EXTRUSION_FACE = "extrusion_face"; @@ -17,29 +17,29 @@ const std::string EXTRUSION_FACE = "extrusion_face"; /// attribute name of extrusion size const std::string EXTRUSION_SIZE = "extrusion_size"; -/// attribute name of reverce direction +/// attribute name of reverse direction const std::string EXTRUSION_REVERSE = "extrusion_reverse"; -class ConstructionPlugin_Extrusion: public ModelAPI_Feature +class FeaturesPlugin_Extrusion: public ModelAPI_Feature { public: /// Returns the kind of a feature - CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() - { static std::string MY_KIND = CONSTRUCTION_EXTRUSION_KIND; return MY_KIND; } + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { static std::string MY_KIND = FEATURES_EXTRUSION_KIND; return MY_KIND; } /// Returns to which group in the document must be added feature - CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() + FEATURESPLUGIN_EXPORT virtual const std::string& getGroup() { static std::string MY_GROUP = "Construction"; return MY_GROUP; } /// Creates a new part document if needed - CONSTRUCTIONPLUGIN_EXPORT virtual void execute(); + FEATURESPLUGIN_EXPORT virtual void execute(); /// Request for initialization of data model of the feature: adding all attributes - CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes(); + FEATURESPLUGIN_EXPORT virtual void initAttributes(); /// Use plugin manager for features creation - ConstructionPlugin_Extrusion(); + FeaturesPlugin_Extrusion(); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp new file mode 100644 index 000000000..1c9273d5f --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -0,0 +1,25 @@ +#include "FeaturesPlugin_Plugin.h" +#include "FeaturesPlugin_Extrusion.h" + +#include +#include + +using namespace std; + +// the only created instance of this plugin +static FeaturesPlugin_Plugin* MY_INSTANCE = new FeaturesPlugin_Plugin(); + +FeaturesPlugin_Plugin::FeaturesPlugin_Plugin() +{ + // register this plugin + ModelAPI_PluginManager::get()->registerPlugin(this); +} + +FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID) +{ + if (theFeatureID == FEATURES_EXTRUSION_KIND) { + return FeaturePtr(new FeaturesPlugin_Extrusion); + } + // feature of such kind is not found + return FeaturePtr(); +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.h b/src/FeaturesPlugin/FeaturesPlugin_Plugin.h new file mode 100644 index 000000000..3ec8c1239 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.h @@ -0,0 +1,24 @@ +// File: FeaturesPlugin_Plugin.hxx +// Created: 07 July 2014 +// Author: Vitaly SMETANNIKOV + +#ifndef FeaturesPlugin_Plugin_HeaderFile +#define FeaturesPlugin_Plugin_HeaderFile + + +#include "FeaturesPlugin.h" +#include +#include + +class FEATURESPLUGIN_EXPORT FeaturesPlugin_Plugin: public ModelAPI_Plugin +{ +public: + /// Creates the feature object of this plugin by the feature string ID + virtual FeaturePtr createFeature(std::string theFeatureID); + +public: + /// Is needed for python wrapping by swig + FeaturesPlugin_Plugin(); +}; + +#endif diff --git a/src/ConstructionPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml similarity index 100% rename from src/ConstructionPlugin/extrusion_widget.xml rename to src/FeaturesPlugin/extrusion_widget.xml diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml new file mode 100644 index 000000000..783d373fa --- /dev/null +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -0,0 +1,9 @@ + + + + + + + + + -- 2.39.2