From 7b1cee901954dabb2e9165caf72baff2393db266 Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 22 Apr 2014 17:39:05 +0400 Subject: [PATCH] Separation of Construction plugin from PartSet plugin. Each plugin package contains its config. --- CMakeLists.txt | 1 + src/Config/CMakeLists.txt | 1 - src/Config/plugins.xml | 1 + src/ConstructionPlugin/CMakeLists.txt | 27 +++++++++++++++++++ src/ConstructionPlugin/ConstructionPlugin.h | 18 +++++++++++++ .../ConstructionPlugin_Plugin.cxx | 24 +++++++++++++++++ .../ConstructionPlugin_Plugin.h | 23 ++++++++++++++++ .../ConstructionPlugin_Point.cxx} | 10 +++---- .../ConstructionPlugin_Point.h} | 22 +++++++-------- .../plugin-Construction.xml} | 7 ----- src/PartSetPlugin/CMakeLists.txt | 7 +++-- src/PartSetPlugin/PartSetPlugin_Plugin.cxx | 2 -- src/PartSetPlugin/plugin-PartSet.xml | 9 +++++++ 13 files changed, 124 insertions(+), 28 deletions(-) create mode 100644 src/ConstructionPlugin/CMakeLists.txt create mode 100644 src/ConstructionPlugin/ConstructionPlugin.h create mode 100644 src/ConstructionPlugin/ConstructionPlugin_Plugin.cxx create mode 100644 src/ConstructionPlugin/ConstructionPlugin_Plugin.h rename src/{PartSetPlugin/PartSetPlugin_Point.cxx => ConstructionPlugin/ConstructionPlugin_Point.cxx} (75%) rename src/{PartSetPlugin/PartSetPlugin_Point.h => ConstructionPlugin/ConstructionPlugin_Point.h} (61%) rename src/{Config/plugin-PartSet.xml => ConstructionPlugin/plugin-Construction.xml} (66%) create mode 100644 src/PartSetPlugin/plugin-PartSet.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index ed7aa098c..b5dd0ebd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ ADD_SUBDIRECTORY (src/ModelAPI) ADD_SUBDIRECTORY (src/ModuleBase) ADD_SUBDIRECTORY (src/PartSet) ADD_SUBDIRECTORY (src/PartSetPlugin) +ADD_SUBDIRECTORY (src/ConstructionPlugin) ADD_SUBDIRECTORY (src/PyConsole) ADD_SUBDIRECTORY (src/PyEvent) ADD_SUBDIRECTORY (src/PyInterp) diff --git a/src/Config/CMakeLists.txt b/src/Config/CMakeLists.txt index 660990d30..92aee7ca6 100644 --- a/src/Config/CMakeLists.txt +++ b/src/Config/CMakeLists.txt @@ -26,7 +26,6 @@ SET(PROJECT_SOURCES ) SET(XML_RESOURCES - plugin-PartSet.xml plugins.xml ) diff --git a/src/Config/plugins.xml b/src/Config/plugins.xml index 4af6b07db..fa22efe2a 100644 --- a/src/Config/plugins.xml +++ b/src/Config/plugins.xml @@ -1,3 +1,4 @@ + diff --git a/src/ConstructionPlugin/CMakeLists.txt b/src/ConstructionPlugin/CMakeLists.txt new file mode 100644 index 000000000..fff34c724 --- /dev/null +++ b/src/ConstructionPlugin/CMakeLists.txt @@ -0,0 +1,27 @@ +INCLUDE(Common) + +SET(PROJECT_HEADERS + ConstructionPlugin.h + ConstructionPlugin_Plugin.h + ConstructionPlugin_Point.h +) + +SET(PROJECT_SOURCES + ConstructionPlugin_Plugin.cxx + ConstructionPlugin_Point.cxx +) + +ADD_DEFINITIONS(-DCONSTRUCTIONPLUGIN_EXPORTS ${BOOST_DEFINITIONS}) +ADD_LIBRARY(ConstructionPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(ConstructionPlugin ${PROJECT_LIBRARIES} ModelAPI) + +INCLUDE_DIRECTORIES( + ../ModelAPI +) + +SET(XML_RESOURCES + plugin-Construction.xml +) + +INSTALL(TARGETS ConstructionPlugin DESTINATION plugins) +INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins) diff --git a/src/ConstructionPlugin/ConstructionPlugin.h b/src/ConstructionPlugin/ConstructionPlugin.h new file mode 100644 index 000000000..99bbf1fda --- /dev/null +++ b/src/ConstructionPlugin/ConstructionPlugin.h @@ -0,0 +1,18 @@ +#ifndef CONSTRUCTIONPLUGIN_H +#define CONSTRUCTIONPLUGIN_H + +#if defined CONSTRUCTIONPLUGIN_EXPORTS +#if defined WIN32 +#define CONSTRUCTIONPLUGIN_EXPORT __declspec( dllexport ) +#else +#define CONSTRUCTIONPLUGIN_EXPORT +#endif +#else +#if defined WIN32 +#define CONSTRUCTIONPLUGIN_EXPORT __declspec( dllimport ) +#else +#define CONSTRUCTIONPLUGIN_EXPORT +#endif +#endif + +#endif diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cxx b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cxx new file mode 100644 index 000000000..c433491f9 --- /dev/null +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cxx @@ -0,0 +1,24 @@ +#include "ConstructionPlugin_Plugin.h" +#include "ConstructionPlugin_Point.h" +#include +#include + +using namespace std; + +// the only created instance of this plugin +static ConstructionPlugin_Plugin* MY_INSTANCE = new ConstructionPlugin_Plugin(); + +ConstructionPlugin_Plugin::ConstructionPlugin_Plugin() +{ + // register this plugin + ModelAPI_PluginManager::get()->registerPlugin(this); +} + +shared_ptr ConstructionPlugin_Plugin::createFeature(string theFeatureID) +{ + if (theFeatureID == "Point") { + return shared_ptr(new ConstructionPlugin_Point); + } + // feature of such kind is not found + return shared_ptr(); +} diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.h b/src/ConstructionPlugin/ConstructionPlugin_Plugin.h new file mode 100644 index 000000000..91875f362 --- /dev/null +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.h @@ -0,0 +1,23 @@ +// File: ConstructionPlugin_Plugin.hxx +// Created: 31 Mar 2014 +// Author: Mikhail PONIKAROV + +#ifndef ConstructionPlugin_Plugin_HeaderFile +#define ConstructionPlugin_Plugin_HeaderFile + + +#include "ConstructionPlugin.h" +#include "ModelAPI_Plugin.h" + +class CONSTRUCTIONPLUGIN_EXPORT ConstructionPlugin_Plugin: public ModelAPI_Plugin +{ +public: + /// Creates the feature object of this plugin by the feature string ID + virtual std::shared_ptr createFeature(std::string theFeatureID); + +public: + /// Is needed for python wrapping by swig + ConstructionPlugin_Plugin(); +}; + +#endif diff --git a/src/PartSetPlugin/PartSetPlugin_Point.cxx b/src/ConstructionPlugin/ConstructionPlugin_Point.cxx similarity index 75% rename from src/PartSetPlugin/PartSetPlugin_Point.cxx rename to src/ConstructionPlugin/ConstructionPlugin_Point.cxx index e9b0d2fe2..ea613603b 100644 --- a/src/PartSetPlugin/PartSetPlugin_Point.cxx +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cxx @@ -1,8 +1,8 @@ -// File: PartSetPlugin_Point.cxx +// File: ConstructionPlugin_Point.cxx // Created: 27 Mar 2014 // Author: Mikhail PONIKAROV -#include "PartSetPlugin_Point.h" +#include "ConstructionPlugin_Point.h" #include "ModelAPI_PluginManager.h" #include "ModelAPI_Document.h" #include "ModelAPI_Data.h" @@ -10,11 +10,11 @@ using namespace std; -PartSetPlugin_Point::PartSetPlugin_Point() +ConstructionPlugin_Point::ConstructionPlugin_Point() { } -void PartSetPlugin_Point::initAttributes() +void ConstructionPlugin_Point::initAttributes() { data()->addAttribute(POINT_ATTR_X, ModelAPI_AttributeDouble::type()); data()->addAttribute(POINT_ATTR_Y, ModelAPI_AttributeDouble::type()); @@ -23,7 +23,7 @@ void PartSetPlugin_Point::initAttributes() // this is for debug only #include -void PartSetPlugin_Point::execute() +void ConstructionPlugin_Point::execute() { // TODO: create a real shape for the point using OCC layer cout<<"X="<real(POINT_ATTR_X)->value()<<" Y="<real(POINT_ATTR_Y)->value() diff --git a/src/PartSetPlugin/PartSetPlugin_Point.h b/src/ConstructionPlugin/ConstructionPlugin_Point.h similarity index 61% rename from src/PartSetPlugin/PartSetPlugin_Point.h rename to src/ConstructionPlugin/ConstructionPlugin_Point.h index 4a8766ae6..2b71b50fe 100644 --- a/src/PartSetPlugin/PartSetPlugin_Point.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.h @@ -1,11 +1,11 @@ -// File: PartSetPlugin_Point.h +// File: ConstructionPlugin_Point.h // Created: 3 Apr 2014 // Author: Mikhail PONIKAROV -#ifndef PartSetPlugin_Point_HeaderFile -#define PartSetPlugin_Point_HeaderFile +#ifndef ConstructionPlugin_Point_HeaderFile +#define ConstructionPlugin_Point_HeaderFile -#include "PartSetPlugin.h" +#include "ConstructionPlugin.h" #include /// attribute name for X coordinate @@ -15,29 +15,29 @@ const std::string POINT_ATTR_Y = "y"; /// attribute name for Z coordinate const std::string POINT_ATTR_Z = "z"; -/**\class PartSetPlugin_Point +/**\class ConstructionPlugin_Point * \ingroup DataModel * \brief Feature for creation of the new part in PartSet. */ -class PartSetPlugin_Point: public ModelAPI_Feature +class ConstructionPlugin_Point: public ModelAPI_Feature { public: /// Returns the kind of a feature - PARTSETPLUGIN_EXPORT virtual const std::string& getKind() + CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = "Point"; return MY_KIND;} /// Returns to which group in the document must be added feature - PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() + CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() {static std::string MY_GROUP = "Construction"; return MY_GROUP;} /// Creates a new part document if needed - PARTSETPLUGIN_EXPORT virtual void execute(); + CONSTRUCTIONPLUGIN_EXPORT virtual void execute(); /// Request for initialization of data model of the feature: adding all attributes - PARTSETPLUGIN_EXPORT virtual void initAttributes(); + CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes(); /// Use plugin manager for features creation - PartSetPlugin_Point(); + ConstructionPlugin_Point(); }; #endif diff --git a/src/Config/plugin-PartSet.xml b/src/ConstructionPlugin/plugin-Construction.xml similarity index 66% rename from src/Config/plugin-PartSet.xml rename to src/ConstructionPlugin/plugin-Construction.xml index 3cc8a1182..a5e402f06 100644 --- a/src/Config/plugin-PartSet.xml +++ b/src/ConstructionPlugin/plugin-Construction.xml @@ -1,11 +1,4 @@ - - - - - - - diff --git a/src/PartSetPlugin/CMakeLists.txt b/src/PartSetPlugin/CMakeLists.txt index c27034c10..1e52d1570 100644 --- a/src/PartSetPlugin/CMakeLists.txt +++ b/src/PartSetPlugin/CMakeLists.txt @@ -4,13 +4,11 @@ SET(PROJECT_HEADERS PartSetPlugin.h PartSetPlugin_Plugin.h PartSetPlugin_Part.h - PartSetPlugin_Point.h ) SET(PROJECT_SOURCES PartSetPlugin_Plugin.cxx PartSetPlugin_Part.cxx - PartSetPlugin_Point.cxx ) ADD_DEFINITIONS(-DPARTSETPLUGIN_EXPORTS ${BOOST_DEFINITIONS}) @@ -21,4 +19,9 @@ INCLUDE_DIRECTORIES( ../ModelAPI ) +SET(XML_RESOURCES + plugin-PartSet.xml +) + INSTALL(TARGETS PartSetPlugin DESTINATION plugins) +INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins) diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.cxx b/src/PartSetPlugin/PartSetPlugin_Plugin.cxx index 333239037..83e9bc421 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.cxx +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.cxx @@ -19,8 +19,6 @@ shared_ptr PartSetPlugin_Plugin::createFeature(string theFeatu { if (theFeatureID == "Part") { return shared_ptr(new PartSetPlugin_Part); - } else if (theFeatureID == "Point") { - return shared_ptr(new PartSetPlugin_Point); } // feature of such kind is not found return shared_ptr(); diff --git a/src/PartSetPlugin/plugin-PartSet.xml b/src/PartSetPlugin/plugin-PartSet.xml new file mode 100644 index 000000000..4b3391da8 --- /dev/null +++ b/src/PartSetPlugin/plugin-PartSet.xml @@ -0,0 +1,9 @@ + + + + + + + + + -- 2.30.2