]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Features plug-in created with Extrusion operation.
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 7 Jul 2014 14:30:13 +0000 (18:30 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 7 Jul 2014 14:30:13 +0000 (18:30 +0400)
16 files changed:
CMakeLists.txt
src/Config/plugins.xml
src/ConstructionPlugin/CMakeLists.txt
src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp [deleted file]
src/ConstructionPlugin/ConstructionPlugin_Extrusion.h [deleted file]
src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp
src/ConstructionPlugin/extrusion_widget.xml [deleted file]
src/ConstructionPlugin/plugin-Construction.xml
src/FeaturesPlugin/CMakeLists.txt [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Plugin.h [new file with mode: 0644]
src/FeaturesPlugin/extrusion_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml [new file with mode: 0644]

index 4f70d821c7df0d7b6820462f9f0bcc72fad7611a..7a276cea134134a10a953b34b7f81d8f2f53736d 100644 (file)
@@ -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)
index e54794df6bcae5207337f07b5d70121752445c48..a4d1dbdae5e3f237a7e3f8088c232a7f9909908a 100644 (file)
@@ -2,6 +2,7 @@
   <plugin library="PartSetPlugin" configuration="plugin-PartSet.xml"/>
   <plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
   <plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
+  <plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
   <plugin library="SketchSolver"/>
   <plugin library="DFBrowser"/>
 </plugins>
index dc32be9876c22203738ac932552f1a2d68671448..1c81b62aaad584e2481476434ae9f4d9665d084f 100644 (file)
@@ -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_Extrusion.cpp b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp
deleted file mode 100644 (file)
index 0af9cad..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// File:        ConstructionPlugin_Extrusion.cpp
-// Created:     30 May 2014
-// Author:      Vitaly SMETANNIKOV
-
-#include "ConstructionPlugin_Extrusion.h"
-#include <ModelAPI_PluginManager.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeReference.h>
-#include <ModelAPI_AttributeBoolean.h>
-
-#include <GeomAlgoAPI_Extrusion.h>
-
-using namespace std;
-
-ConstructionPlugin_Extrusion::ConstructionPlugin_Extrusion()
-{
-}
-
-void ConstructionPlugin_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()
-{
-  boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(EXTRUSION_FACE));
-  if (!aFaceRef)
-    return;
-  FeaturePtr aFaceFeature = aFaceRef->value();
-  if (!aFaceFeature)
-    return;
-  boost::shared_ptr<GeomAPI_Shape> aFace = aFaceFeature->data()->shape();
-  if (!aFace)
-    return;
-
-  double aSize = data()->real(EXTRUSION_SIZE)->value();
-  if (data()->boolean(EXTRUSION_REVERSE)->value())
-    aSize = -aSize;
-  data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
-}
diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h
deleted file mode 100644 (file)
index 5933929..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// File:        ConstructionPlugin_Extrusion.h
-// Created:     30 May 2014
-// Author:      Vitaly SMETANNIKOV
-
-#ifndef ConstructionPlugin_Extrusion_HeaderFile
-#define ConstructionPlugin_Extrusion_HeaderFile
-
-#include "ConstructionPlugin.h"
-#include <ModelAPI_Feature.h>
-
-/// Extrusion kind
-const std::string CONSTRUCTION_EXTRUSION_KIND("Extrusion");
-
-/// attribute name of referenced face
-const std::string EXTRUSION_FACE = "extrusion_face";
-
-/// attribute name of extrusion size
-const std::string EXTRUSION_SIZE = "extrusion_size";
-
-/// attribute name of reverce direction
-const std::string EXTRUSION_REVERSE = "extrusion_reverse";
-
-
-class ConstructionPlugin_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; }
-
-  /// Returns to which group in the document must be added feature
-  CONSTRUCTIONPLUGIN_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();
-
-  /// Request for initialization of data model of the feature: adding all attributes
-  CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
-
-  /// Use plugin manager for features creation
-  ConstructionPlugin_Extrusion();
-};
-
-#endif
index d420b21104827a33f6e25cf279d0ba2cb77db4c5..6b0d729a44c68919eb1cdfe1fe29276cf9de4037 100644 (file)
@@ -1,6 +1,5 @@
 #include "ConstructionPlugin_Plugin.h"
 #include "ConstructionPlugin_Point.h"
-#include "ConstructionPlugin_Extrusion.h"
 
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
@@ -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/extrusion_widget.xml b/src/ConstructionPlugin/extrusion_widget.xml
deleted file mode 100644 (file)
index c0069ca..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<source>
-  <selector id="extrusion_face" 
-    label="Select a face" 
-    icon=":icons/sketch.png" 
-    tooltip="Select a face for extrusion"
-    activate="true"
-    shape_types="face"
-  />
-  <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set size of extrusion"/>
-  <boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
-</source>
index 4736d36cfa54344fbd11db2b318b8c8306917f41..b3fdc4608c6ae1054cff9a91c7201cdf2412605b 100644 (file)
@@ -6,9 +6,6 @@
       </feature>
       <feature id="Axis" title="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence="" internal="true"/>
       <feature id="Plane" title="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence="" internal="true"/>
-      <feature id="Extrusion" title="Extrusion" tooltip="Create a shape by extrusion of a contour" icon=":icons/extrusion.png">
-          <source path="extrusion_widget.xml"/>
-      </feature>
     </group>
 </workbench>  
 </plugin>
diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..29e0878
--- /dev/null
@@ -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 (file)
index 0000000..2e931e2
--- /dev/null
@@ -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/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
new file mode 100644 (file)
index 0000000..328dde5
--- /dev/null
@@ -0,0 +1,45 @@
+// File:        FeaturesPlugin_Extrusion.cpp
+// Created:     30 May 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "FeaturesPlugin_Extrusion.h"
+#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeBoolean.h>
+
+#include <GeomAlgoAPI_Extrusion.h>
+
+using namespace std;
+
+FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
+{
+}
+
+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 FeaturesPlugin_Extrusion::execute()
+{
+  boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef = 
+    boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(EXTRUSION_FACE));
+  if (!aFaceRef)
+    return;
+  FeaturePtr aFaceFeature = aFaceRef->value();
+  if (!aFaceFeature)
+    return;
+  boost::shared_ptr<GeomAPI_Shape> aFace = aFaceFeature->data()->shape();
+  if (!aFace)
+    return;
+
+  double aSize = data()->real(EXTRUSION_SIZE)->value();
+  if (data()->boolean(EXTRUSION_REVERSE)->value())
+    aSize = -aSize;
+  data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
new file mode 100644 (file)
index 0000000..95c8f98
--- /dev/null
@@ -0,0 +1,45 @@
+// File:        FeaturesPlugin_Extrusion.h
+// Created:     30 May 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef FeaturesPlugin_Extrusion_HeaderFile
+#define FeaturesPlugin_Extrusion_HeaderFile
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+
+/// Extrusion kind
+const std::string FEATURES_EXTRUSION_KIND("Extrusion");
+
+/// attribute name of referenced face
+const std::string EXTRUSION_FACE = "extrusion_face";
+
+/// attribute name of extrusion size
+const std::string EXTRUSION_SIZE = "extrusion_size";
+
+/// attribute name of reverse direction
+const std::string EXTRUSION_REVERSE = "extrusion_reverse";
+
+
+class FeaturesPlugin_Extrusion: public ModelAPI_Feature
+{
+public:
+  /// Returns the kind of a feature
+  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
+  FEATURESPLUGIN_EXPORT virtual const std::string& getGroup() 
+  { static std::string MY_GROUP = "Construction";  return MY_GROUP; }
+
+  /// Creates a new part document if needed
+  FEATURESPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Use plugin manager for features creation
+  FeaturesPlugin_Extrusion();
+};
+
+#endif
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
new file mode 100644 (file)
index 0000000..1c9273d
--- /dev/null
@@ -0,0 +1,25 @@
+#include "FeaturesPlugin_Plugin.h"
+#include "FeaturesPlugin_Extrusion.h"
+
+#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Document.h>
+
+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 (file)
index 0000000..3ec8c12
--- /dev/null
@@ -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 <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+
+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/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml
new file mode 100644 (file)
index 0000000..c0069ca
--- /dev/null
@@ -0,0 +1,11 @@
+<source>
+  <selector id="extrusion_face" 
+    label="Select a face" 
+    icon=":icons/sketch.png" 
+    tooltip="Select a face for extrusion"
+    activate="true"
+    shape_types="face"
+  />
+  <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set size of extrusion"/>
+  <boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
+</source>
diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml
new file mode 100644 (file)
index 0000000..783d373
--- /dev/null
@@ -0,0 +1,9 @@
+<plugin>
+  <workbench id="Features">
+    <group id="Basic">
+      <feature id="Extrusion" title="Extrusion" tooltip="Create a shape by extrusion of a contour" icon=":icons/extrusion.png">
+          <source path="extrusion_widget.xml"/>
+      </feature>
+    </group>
+</workbench>  
+</plugin>