]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Result for parameters added
authorsbh <sergey.belash@opencascade.com>
Fri, 3 Apr 2015 17:11:09 +0000 (20:11 +0300)
committersbh <sergey.belash@opencascade.com>
Fri, 3 Apr 2015 17:11:09 +0000 (20:11 +0300)
src/Model/CMakeLists.txt
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_ResultParameter.cpp [new file with mode: 0644]
src/Model/Model_ResultParameter.h [new file with mode: 0644]
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI.i
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_ResultParameter.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_ResultParameters.h [deleted file]
src/XGUI/XGUI_PartDataModel.cpp

index ef4c82c12077d0ba4b2d4067fcf226634c746b2b..eef87c35f0ab499310e9e2537fa811087cd2ddce 100644 (file)
@@ -26,6 +26,7 @@ SET(PROJECT_HEADERS
     Model_ResultConstruction.h
     Model_ResultPart.h
     Model_ResultGroup.h
+    Model_ResultParameter.h
     Model_FeatureValidator.h
 )
 
@@ -52,6 +53,7 @@ SET(PROJECT_SOURCES
     Model_ResultConstruction.cpp
     Model_ResultPart.cpp
     Model_ResultGroup.cpp
+    Model_ResultParameter.cpp
     Model_FeatureValidator.cpp
 )
 
index 754138db905803368bf2264f8e24df9db7b330dc..0f335a5302a94eddb266c46129e3470425fde401 100644 (file)
@@ -15,6 +15,7 @@
 #include <Model_ResultGroup.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_CompositeFeature.h>
+
 #include <Events_Loop.h>
 #include <Events_Error.h>
 
@@ -1222,6 +1223,23 @@ std::shared_ptr<ModelAPI_ResultGroup> Model_Document::createGroup(
   return aResult;
 }
 
+std::shared_ptr<ModelAPI_ResultParameter> Model_Document::createParameter(
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+  TDF_Label aLab = resultLabel(theFeatureData, theIndex);
+  TDataStd_Comment::Set(aLab, ModelAPI_ResultParameter::group().c_str());
+  ObjectPtr anOldObject = object(aLab);
+  std::shared_ptr<ModelAPI_ResultParameter> aResult;
+  if (anOldObject) {
+    aResult = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(anOldObject);
+  }
+  if (!aResult) {
+    aResult = std::shared_ptr<ModelAPI_ResultParameter>(new ModelAPI_ResultParameter);
+    storeResult(theFeatureData, aResult, theIndex);
+  }
+  return aResult;
+}
+
 std::shared_ptr<ModelAPI_Feature> Model_Document::feature(
     const std::shared_ptr<ModelAPI_Result>& theResult)
 {
index 59631304e0ee4bf0bc51293e51d4212f5fedcca5..453422ffcf9900e7f3cf846c1dd3ece339a3f5e8 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Result.h>
+#include <ModelAPI_ResultParameter.h>
 
 #include <TDocStd_Document.hxx>
 #include <NCollection_DataMap.hxx>
@@ -142,6 +143,9 @@ class Model_Document : public ModelAPI_Document
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultGroup> createGroup(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
 
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultParameter> createParameter(
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+
   //! Returns a feature by result (owner of result)
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature>
     feature(const std::shared_ptr<ModelAPI_Result>& theResult);
diff --git a/src/Model/Model_ResultParameter.cpp b/src/Model/Model_ResultParameter.cpp
new file mode 100644 (file)
index 0000000..641155b
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_ResultParameter.h
+// Created:     02 Apr 2015
+// Author:      Sergey BELASH
+
+#ifndef MODEL_RESULTPARAMETER_H_
+#define MODEL_RESULTPARAMETER_H_
+
+#include "Model.h"
+#include <Model_Document.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_ResultParameter.h>
+
+/**\class Model_ResultParameter
+ * \ingroup DataModel
+ * \brief
+ */
+class Model_ResultParameter : public ModelAPI_ResultParameter
+{
+ public:
+  MODEL_EXPORT virtual ~Model_ResultParameter();
+  MODEL_EXPORT virtual void initAttributes();
+
+ protected:
+  Model_ResultParameter();
+
+  friend class Model_Document;
+};
+
+#endif
diff --git a/src/Model/Model_ResultParameter.h b/src/Model/Model_ResultParameter.h
new file mode 100644 (file)
index 0000000..08c3e2d
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_ResultParameter.cpp
+// Created:     02 Apr 2015
+// Author:      Sergey BELASH
+
+#include "Model_ResultParameter.h"
+
+Model_ResultParameter::~Model_ResultParameter()
+{
+
+}
+
+void Model_ResultParameter::initAttributes()
+{
+  data()->addAttribute(ModelAPI_ResultParameter::VALUE(),
+                       ModelAPI_AttributeDouble::typeId());
+}
+
+
+Model_ResultParameter::Model_ResultParameter()
+{
+  setIsConcealed(false);
+}
index d20cb1d0577efcce3100ed7fca8f90172b2c6b96..8d1dc9d98a5a441509d6f69e08e31b112892f7bb 100644 (file)
@@ -32,7 +32,7 @@ SET(PROJECT_HEADERS
     ModelAPI_ResultBody.h
     ModelAPI_ResultConstruction.h
     ModelAPI_ResultGroup.h
-    ModelAPI_ResultParameters.h
+    ModelAPI_ResultParameter.h
     ModelAPI_ResultPart.h
     ModelAPI_Session.h
     ModelAPI_Tools.h
index bd8cc724a39efec30c605993c166a9373e7bea5c..0c23dc012860884f10790dd1e0fa675ecdbbdd65 100644 (file)
@@ -35,7 +35,7 @@
   #include "ModelAPI_ResultConstruction.h"
   #include "ModelAPI_ResultBody.h"
   #include "ModelAPI_ResultPart.h"
-  #include "ModelAPI_ResultParameters.h"
+  #include "ModelAPI_ResultParameter.h"
   #include "ModelAPI_ResultGroup.h"
   #include "ModelAPI_Tools.h"
 
@@ -95,7 +95,7 @@
 %shared_ptr(ModelAPI_ResultBody)
 %shared_ptr(ModelAPI_ResultPart)
 %shared_ptr(ModelAPI_ResultGroup)
-%shared_ptr(ModelAPI_ResultParameters)
+%shared_ptr(ModelAPI_ResultParameter)
 
 // all supported interfaces
 %include "ModelAPI_Document.h"
 %include "ModelAPI_ResultBody.h"
 %include "ModelAPI_ResultPart.h"
 %include "ModelAPI_ResultGroup.h"
-%include "ModelAPI_ResultParameters.h"
+%include "ModelAPI_ResultParameter.h"
 %include "ModelAPI_Tools.h"
 
 // std::list -> [] 
index cbb1d5b01288ab45c130724502b9b8c8839544cb..8093123bd4ee523c3b2c9e5da27dd9150b952e91 100644 (file)
@@ -21,6 +21,7 @@ class ModelAPI_ResultConstruction;
 class ModelAPI_ResultBody;
 class ModelAPI_ResultPart;
 class ModelAPI_ResultGroup;
+class ModelAPI_ResultParameter;
 class ModelAPI_Data;
 
 /**\class ModelAPI_Document
@@ -98,6 +99,9 @@ public:
   virtual std::shared_ptr<ModelAPI_ResultGroup> createGroup(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
 
+  virtual std::shared_ptr<ModelAPI_ResultParameter> createParameter(
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+
   //! Returns a feature by result (owner of result)
   virtual std::shared_ptr<ModelAPI_Feature> feature(
       const std::shared_ptr<ModelAPI_Result>& theResult) = 0;
diff --git a/src/ModelAPI/ModelAPI_ResultParameter.h b/src/ModelAPI/ModelAPI_ResultParameter.h
new file mode 100644 (file)
index 0000000..9d87737
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_ResultParameter.h
+// Created:     07 Jul 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef MODELAPI_RESULTPARAMETER_H_
+#define MODELAPI_RESULTPARAMETER_H_
+
+#include "ModelAPI_Result.h"
+
+/**\class ModelAPI_ResultParameter
+ * \ingroup DataModel
+ * \brief The construction element result of a feature.
+ *
+ * Provides a shape that may be displayed in the viewer.
+ * Intermediate, light result that in many cases produces a result on the fly.
+ */
+class ModelAPI_ResultParameter : public ModelAPI_Result
+{
+ public:
+  /// Returns the group identifier of this result
+  virtual std::string groupName()
+  {
+    return group();
+  }
+
+  /// Returns the group identifier of this result
+  inline static std::string group()
+  {
+    static std::string MY_GROUP = "Parameters";
+    return MY_GROUP;
+  }
+
+  inline static const std::string& VALUE()
+  {
+    static const std::string MY_VALUE_ID("Value");
+    return MY_VALUE_ID;
+  }
+};
+
+//! Pointer on feature object
+typedef std::shared_ptr<ModelAPI_ResultParameter> ResultParameterPtr;
+
+#endif
diff --git a/src/ModelAPI/ModelAPI_ResultParameters.h b/src/ModelAPI/ModelAPI_ResultParameters.h
deleted file mode 100644 (file)
index aae2a15..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        ModelAPI_ResultParameters.h
-// Created:     07 Jul 2014
-// Author:      Vitaly SMETANNIKOV
-
-#ifndef MODELAPI_RESULTPARAMETERS_H_
-#define MODELAPI_RESULTPARAMETERS_H_
-
-#include "ModelAPI_Result.h"
-
-/**\class ModelAPI_ResultParameters
- * \ingroup DataModel
- * \brief The construction element result of a feature.
- *
- * Provides a shape that may be displayed in the viewer.
- * Intermediate, light result that in many cases produces a result on the fly.
- */
-class ModelAPI_ResultParameters : public ModelAPI_Result
-{
- public:
-  /// Returns the group identifier of this result
-  virtual std::string groupName()
-  {
-    return group();
-  }
-
-  /// Returns the group identifier of this result
-  inline static std::string group()
-  {
-    static std::string MY_GROUP = "Parameters";
-    return MY_GROUP;
-  }
-};
-
-//! Pointer on feature object
-typedef std::shared_ptr<ModelAPI_ResultParameters> ResultParametersPtr;
-
-#endif
index 567ad5677e050e0d4923001afdbc3a23f2a75709..3faa7bd6db81fdf1c8c3ae5d152879123e827ee8 100644 (file)
@@ -12,7 +12,7 @@
 #include <ModelAPI_Object.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_ResultParameters.h>
+#include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultGroup.h>
 
@@ -46,7 +46,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
           return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
         case ParamObject: {
           DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
-          ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
+          ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameter::group(), theIndex.row());
           if (aObject)
             return aObject->data()->name().c_str();
         }
@@ -112,7 +112,7 @@ int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const
 
   DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
   if (theParent.internalId() == ParamsFolder)
-    return aRootDoc->size(ModelAPI_ResultParameters::group());
+    return aRootDoc->size(ModelAPI_ResultParameter::group());
 
   if (theParent.internalId() == ConstructFolder)
     return aRootDoc->size(ModelAPI_ResultConstruction::group());
@@ -183,7 +183,7 @@ ObjectPtr XGUI_TopDataModel::object(const QModelIndex& theIndex) const
       return ObjectPtr();
     case ParamObject: {
       DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
-      return aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
+      return aRootDoc->object(ModelAPI_ResultParameter::group(), theIndex.row());
     }
     case ConstructObject: {
       DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
@@ -204,7 +204,7 @@ QModelIndex XGUI_TopDataModel::findParent(const ObjectPtr& theObject) const
 
 QModelIndex XGUI_TopDataModel::findGroup(const std::string& theGroup) const
 {
-  if (theGroup == ModelAPI_ResultParameters::group())
+  if (theGroup == ModelAPI_ResultParameter::group())
     return createIndex(0, 0, (qint32) ParamsFolder);
   if (theGroup == ModelAPI_ResultConstruction::group())
     return createIndex(1, 0, (qint32) ConstructFolder);
@@ -228,7 +228,7 @@ QModelIndex XGUI_TopDataModel::objectIndex(const ObjectPtr& theObject) const
       }
     }
     if (aRow != -1) {
-      if (aGroup == ModelAPI_ResultParameters::group())
+      if (aGroup == ModelAPI_ResultParameter::group())
         return createIndex(aRow, 0, (qint32) ParamObject);
       if (aGroup == ModelAPI_ResultConstruction::group())
         return createIndex(aRow, 0, (qint32) ConstructObject);
@@ -272,7 +272,7 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
         case GroupsFolder:
           return tr("Groups") + QString(" (%1)").arg(rowCount(theIndex));
         case ParamObject: {
-          ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameters::group(),
+          ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameter::group(),
                                                      theIndex.row());
           if (aObject)
             return std::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
@@ -369,7 +369,7 @@ int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const
           return 0;
       }
     case ParamsFolder:
-      return partDocument()->size(ModelAPI_ResultParameters::group());
+      return partDocument()->size(ModelAPI_ResultParameter::group());
     case ConstructFolder:
       return partDocument()->size(ModelAPI_ResultConstruction::group());
     case BodiesFolder:
@@ -476,7 +476,7 @@ ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const
       return ObjectPtr();
 
     case ParamObject:
-      return partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row());
+      return partDocument()->object(ModelAPI_ResultParameter::group(), theIndex.row());
     case ConstructObject:
       return partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
     case BodiesObject:
@@ -501,7 +501,7 @@ QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theObject) const
 
 QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
 {
-  if (theGroup == ModelAPI_ResultParameters::group())
+  if (theGroup == ModelAPI_ResultParameter::group())
     return createIndex(0, 0, (qint32) ParamsFolder);
   if (theGroup == ModelAPI_ResultConstruction::group())
     return createIndex(1, 0, (qint32) ConstructFolder);
@@ -538,7 +538,7 @@ QModelIndex XGUI_PartDataModel::objectIndex(const ObjectPtr& theObject) const
     }
     if (aRow == -1)
       return aIndex;
-    if (aGroup == ModelAPI_ResultParameters::group())
+    if (aGroup == ModelAPI_ResultParameter::group())
       return createIndex(aRow, 0, (qint32) ParamObject);
     else if (aGroup == ModelAPI_ResultConstruction::group())
       return createIndex(aRow, 0, (qint32) ConstructObject);