]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add ParametersAPI
authorspo <sergey.pokhodenko@opencascade.com>
Thu, 16 Jun 2016 13:28:38 +0000 (16:28 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:12 +0000 (14:41 +0300)
CMakeLists.txt
src/ParametersAPI/CMakeLists.txt [new file with mode: 0644]
src/ParametersAPI/ParametersAPI.h [new file with mode: 0644]
src/ParametersAPI/ParametersAPI.i [new file with mode: 0644]
src/ParametersAPI/ParametersAPI_Parameter.cpp [new file with mode: 0644]
src/ParametersAPI/ParametersAPI_Parameter.h [new file with mode: 0644]
src/ParametersAPI/ParametersAPI_swig.h [new file with mode: 0644]
src/PythonAPI/Test/TestFeatures.py
src/PythonAPI/model/parameter/__init__.py

index bbfe7510c8d88a67ead1fc8950910e76ae71f8fc..30b0198828c596566a1feb065dd1578c3eee1aa7 100644 (file)
@@ -99,6 +99,7 @@ ADD_SUBDIRECTORY (src/ModelHighAPI)
 ADD_SUBDIRECTORY (src/ConstructionAPI)
 ADD_SUBDIRECTORY (src/ExchangeAPI)
 ADD_SUBDIRECTORY (src/FeaturesAPI)
+ADD_SUBDIRECTORY (src/ParametersAPI)
 ADD_SUBDIRECTORY (src/PartSetAPI)
 ADD_SUBDIRECTORY (src/SketchAPI)
 
diff --git a/src/ParametersAPI/CMakeLists.txt b/src/ParametersAPI/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ee18966
--- /dev/null
@@ -0,0 +1,69 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+INCLUDE(Common)
+
+SET(PROJECT_HEADERS
+  ParametersAPI.h
+  ParametersAPI_Parameter.h
+)
+
+SET(PROJECT_SOURCES
+  ParametersAPI_Parameter.cpp
+)
+
+SET(PROJECT_LIBRARIES
+  ModelAPI
+  ModelHighAPI
+)
+
+INCLUDE_DIRECTORIES(
+  ${PROJECT_SOURCE_DIR}/src/Events
+  ${PROJECT_SOURCE_DIR}/src/ModelAPI
+  ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
+)
+
+# Plugin headers dependency
+INCLUDE_DIRECTORIES(
+  # TODO(spo): modify ParametersPlugin headers to remove dependency on GeomAPI headers
+  ${PROJECT_SOURCE_DIR}/src/GeomAPI
+  # TODO(spo): it is for *_swig.h files. Can we eliminate it?
+  ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+  ${PROJECT_SOURCE_DIR}/src/ParametersPlugin
+)
+
+#TODO(spo): is ${CAS_DEFINITIONS} necessary?
+ADD_DEFINITIONS(-DCONSTRUCTIONAPI_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(ParametersAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(ParametersAPI ${PROJECT_LIBRARIES})
+
+# SWIG wrapper
+
+INCLUDE(PythonAPI)
+
+SET_SOURCE_FILES_PROPERTIES(ParametersAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(ParametersAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
+#TODO(spo): is ModelAPI necessary or it could be received by INTERFACE_ (may require modern CMake)?
+SET(SWIG_LINK_LIBRARIES
+  ParametersAPI
+  ModelHighAPI
+  ModelAPI
+  ${PYTHON_LIBRARIES}
+)
+
+SET(SWIG_MODULE_ParametersAPI_EXTRA_DEPS ${SWIG_MODULE_ParametersAPI_EXTRA_DEPS}
+  ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i
+  doxyhelp.i
+  ${PROJECT_HEADERS}
+)
+
+SWIG_ADD_MODULE(ParametersAPI python ParametersAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(ParametersAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+  SET_TARGET_PROPERTIES(_ParametersAPI PROPERTIES DEBUG_OUTPUT_NAME _ParametersAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _ParametersAPI DESTINATION ${SHAPER_INSTALL_SWIG})
+INSTALL(TARGETS ParametersAPI DESTINATION ${SHAPER_INSTALL_BIN})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ParametersAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
diff --git a/src/ParametersAPI/ParametersAPI.h b/src/ParametersAPI/ParametersAPI.h
new file mode 100644 (file)
index 0000000..483dcce
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef PARAMETERSAPI_H
+#define PARAMETERSAPI_H
+
+#if defined PARAMETERSAPI_EXPORTS
+#if defined WIN32
+#define PARAMETERSAPI_EXPORT __declspec( dllexport )
+#else
+#define PARAMETERSAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define PARAMETERSAPI_EXPORT __declspec( dllimport )
+#else
+#define PARAMETERSAPI_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/ParametersAPI/ParametersAPI.i b/src/ParametersAPI/ParametersAPI.i
new file mode 100644 (file)
index 0000000..b7b72ec
--- /dev/null
@@ -0,0 +1,25 @@
+/* ParametersAPI.i */
+
+%module ParametersAPI
+
+%{
+  #include "ParametersAPI_swig.h"
+%}
+
+%include "doxyhelp.i"
+
+// import other modules
+%import "ModelHighAPI.i"
+
+// to avoid error on this
+#define PARAMETERSAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_shared_ptr.i"
+
+// shared pointers
+%shared_ptr(ParametersAPI_Parameter)
+
+// all supported interfaces
+%include "ParametersAPI_Parameter.h"
diff --git a/src/ParametersAPI/ParametersAPI_Parameter.cpp b/src/ParametersAPI/ParametersAPI_Parameter.cpp
new file mode 100644 (file)
index 0000000..8ea872d
--- /dev/null
@@ -0,0 +1,45 @@
+// Name   : ParametersAPI_Parameter.cpp
+// Purpose: 
+//
+// History:
+// 16/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "ParametersAPI_Parameter.h"
+//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Tools.h>
+//--------------------------------------------------------------------------------------
+ParametersAPI_Parameter::ParametersAPI_Parameter(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+ParametersAPI_Parameter::ParametersAPI_Parameter(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const std::string & theName,
+    const ModelHighAPI_Double & theExpression)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    fillAttribute(theName, name());
+    fillAttribute(theExpression, expression());
+
+    execute();
+  }
+}
+
+ParametersAPI_Parameter::~ParametersAPI_Parameter()
+{
+}
+
+//--------------------------------------------------------------------------------------
+ParameterPtr addParameter(const std::shared_ptr<ModelAPI_Document> & theParameter,
+                          const std::string & theName,
+                          const ModelHighAPI_Double & theExpression)
+{
+  // TODO(spo): check that theParameter is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = theParameter->addFeature(ParametersAPI_Parameter::ID());
+  return ParameterPtr(new ParametersAPI_Parameter(aFeature));
+}
diff --git a/src/ParametersAPI/ParametersAPI_Parameter.h b/src/ParametersAPI/ParametersAPI_Parameter.h
new file mode 100644 (file)
index 0000000..5a3023d
--- /dev/null
@@ -0,0 +1,59 @@
+// Name   : ParametersAPI_Parameter.h
+// Purpose: 
+//
+// History:
+// 16/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_PARAMETERSAPI_PARAMETERSAPI_PARAMETER_H_
+#define SRC_PARAMETERSAPI_PARAMETERSAPI_PARAMETER_H_
+
+//--------------------------------------------------------------------------------------
+#include "ParametersAPI.h"
+
+#include <ParametersPlugin_Parameter.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+class ModelHighAPI_Double;
+//--------------------------------------------------------------------------------------
+/**\class ParametersAPI_Parameter
+ * \ingroup CPPHighAPI
+ * \brief Interface for Parameter feature
+ */
+class ParametersAPI_Parameter : public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values
+  PARAMETERSAPI_EXPORT
+  explicit ParametersAPI_Parameter(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+  /// Constructor with values
+  PARAMETERSAPI_EXPORT
+  explicit ParametersAPI_Parameter(const  std::shared_ptr<ModelAPI_Feature> & theFeature,
+                                   const std::string & theName,
+                                   const ModelHighAPI_Double & theExpression);
+  /// Destructor
+  PARAMETERSAPI_EXPORT
+  virtual ~ParametersAPI_Parameter();
+
+  INTERFACE_2(ParametersPlugin_Parameter::ID(),
+              name, ParametersPlugin_Parameter::VARIABLE_ID(), ModelAPI_AttributeString, /** Name */,
+              expression, ParametersPlugin_Parameter::EXPRESSION_ID(), ModelAPI_AttributeDouble, /** Expression */
+  )
+
+};
+
+//! Pointer on Parameter object
+typedef std::shared_ptr<ParametersAPI_Parameter> ParameterPtr;
+
+/**\ingroup CPPHighAPI
+ * \brief Create Parameter feature
+ */
+PARAMETERSAPI_EXPORT
+ParameterPtr addParameter(const std::shared_ptr<ModelAPI_Document> & thePart,
+                          const std::string & theName,
+                          const ModelHighAPI_Double & theExpression);
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_PARAMETERSAPI_PARAMETERSAPI_PARAMETER_H_ */
diff --git a/src/ParametersAPI/ParametersAPI_swig.h b/src/ParametersAPI/ParametersAPI_swig.h
new file mode 100644 (file)
index 0000000..fc7bf16
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:    ParametersAPI_swig.h
+// Created: 16/06/16
+// Author:  Sergey POKHODENKO
+
+#ifndef SRC_PARAMETERSAPI_PARAMETERSAPI_SWIG_H_
+#define SRC_PARAMETERSAPI_PARAMETERSAPI_SWIG_H_
+
+  #include <ModelHighAPI_swig.h>
+
+  #include "ParametersAPI_Parameter.h"
+
+#endif /* SRC_PARAMETERSAPI_PARAMETERSAPI_SWIG_H_ */
index 8e4f43039f5c553257b7d7a60433261367d8fb3a..f4ef8e423fbfdd9931b540ca86fbaf5c330fc612 100644 (file)
@@ -74,7 +74,8 @@ class FeaturesTestCase(FeaturesFixture):
         FeaturesAPI.FeaturesAPI_Translation(self.part.addFeature("Translation"))
         FeaturesAPI.FeaturesAPI_Group(self.part.addFeature("Group"))
 
-        model.parameter.Parameter(self.part.addFeature("Parameter"))
+        import ParametersAPI
+        ParametersAPI.ParametersAPI_Parameter(self.part.addFeature("Parameter"))
 
 #-----------------------------------------------------------------------------
 
index 44bde3f350f437e54c3143157adcbce8e8842653..fb276792dfedfbdaf0d7c7b29dfa0ae377b056b8 100644 (file)
@@ -1,4 +1,4 @@
 """Package for Parameter plugin for the Parametric Geometry API of the Modeler.
 """
 
-from parameter import addParameter
\ No newline at end of file
+from ParametersAPI import addParameter
\ No newline at end of file