]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Bug #1045: Group not exported in GEOM
authordbv <dbv@opencascade.com>
Mon, 21 Dec 2015 14:20:46 +0000 (17:20 +0300)
committerdbv <dbv@opencascade.com>
Mon, 21 Dec 2015 14:21:01 +0000 (17:21 +0300)
src/FeaturesPlugin/group_widget.xml
src/GeomValidators/CMakeLists.txt
src/GeomValidators/GeomValidators_BodyShapes.cpp [new file with mode: 0644]
src/GeomValidators/GeomValidators_BodyShapes.h [new file with mode: 0644]
src/GeomValidators/GeomValidators_Plugin.cpp

index 1b1825329df41ef62ca2d60134d503eeaf788bb2..a39b7ac96287da1f5fc60e96072b9f92d45e81e2 100644 (file)
@@ -1,7 +1,9 @@
 <!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 
 <source>
-  <multi_selector id="group_list" 
-    tooltip="Select a set of objects" 
-    type_choice="Vertices Edges Faces Solids" /> 
+  <multi_selector id="group_list"
+    tooltip="Select a set of objects"
+    type_choice="Vertices Edges Faces Solids">
+    <validator id="GeomValidators_BodyShapes" parameters="Sketch"/>
+  </multi_selector>
 </source>
\ No newline at end of file
index c9768eb39f606c33e5a82ccacd2673ad947869c6..4ac409c81a7a93ebc9e2d7d107198a562913978e 100644 (file)
@@ -4,6 +4,7 @@ INCLUDE(Common)
 
 SET(PROJECT_HEADERS
     GeomValidators.h
+    GeomValidators_BodyShapes.h
     GeomValidators_BooleanArguments.h
     GeomValidators_ConstructionComposite.h
     GeomValidators_DifferentShapes.h
@@ -19,6 +20,7 @@ SET(PROJECT_HEADERS
 )
 
 SET(PROJECT_SOURCES
+    GeomValidators_BodyShapes.cpp
     GeomValidators_BooleanArguments.cpp
     GeomValidators_ConstructionComposite.cpp
     GeomValidators_DifferentShapes.cpp
@@ -34,7 +36,7 @@ SET(PROJECT_SOURCES
 )
 
 SET(PROJECT_LIBRARIES
-    ModelAPI 
+    ModelAPI
     Events
     GeomAPI
 )
diff --git a/src/GeomValidators/GeomValidators_BodyShapes.cpp b/src/GeomValidators/GeomValidators_BodyShapes.cpp
new file mode 100644 (file)
index 0000000..734938e
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomValidators_BodyShapes.cpp
+// Created:     21 December 2015
+// Author:      Dmitry Bobylev
+
+#include "GeomValidators_BodyShapes.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Object.h>
+
+bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute,
+                                      const std::list<std::string>& theArguments,
+                                      std::string& theError) const
+{
+  std::string anAttributeType = theAttribute->attributeType();
+  if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectionListAttr = 
+                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+    // all context objects should not be sketch entities
+    for(int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) {
+      AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
+      ObjectPtr anObject = aSelectAttr->context();
+      if (!anObject.get())
+        return false;
+      else {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+        std::string aFeatureKind = aFeature->getKind();
+        if(aFeatureKind == "Sketch") {
+          return false;
+        }
+      }
+    }
+  }
+
+  return true;
+}
diff --git a/src/GeomValidators/GeomValidators_BodyShapes.h b/src/GeomValidators/GeomValidators_BodyShapes.h
new file mode 100644 (file)
index 0000000..19fe81f
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomValidators_BodyShapes.h
+// Created:     21 December 2015
+// Author:      Dmitry Bobylev
+
+#ifndef GeomValidators_BodyShapes_H
+#define GeomValidators_BodyShapes_H
+
+#include <ModelAPI.h>
+
+#include <ModelAPI_AttributeValidator.h>
+#include <ModelAPI_Attribute.h>
+
+/**
+ * Generic validator for any attribute of a feature.
+ */
+class GeomValidators_BodyShapes : public ModelAPI_AttributeValidator
+{
+public:
+  /// \return True if the attribute is valid. It checks whether the shape is a
+  /// body subshape. Does not allow select construction shapes.
+  /// \param[in] theAttribute an attribute to check
+  /// \param[in] theArguments a filter parameters
+  /// \param[out] theError error message.
+  MODELAPI_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
+                                       const std::list<std::string>& theArguments,
+                                       std::string& theError) const;
+};
+
+#endif
index e8f8574a162e4a5d209c14c7adfd67ac6df45740..43d997084e133bd6983851d4306f09836179e430 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <GeomValidators_Plugin.h>
 
+#include <GeomValidators_BodyShapes.h>
 #include <GeomValidators_BooleanArguments.h>
 #include <GeomValidators_ConstructionComposite.h>
 #include <GeomValidators_Different.h>
@@ -24,6 +25,7 @@ GeomValidators_Plugin::GeomValidators_Plugin()
   SessionPtr aMgr = ModelAPI_Session::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
 
+  aFactory->registerValidator("GeomValidators_BodyShapes", new GeomValidators_BodyShapes);
   aFactory->registerValidator("GeomValidators_BooleanArguments", new GeomValidators_BooleanArguments);
   aFactory->registerValidator("GeomValidators_ConstructionComposite", new GeomValidators_ConstructionComposite);
   aFactory->registerValidator("GeomValidators_Different", new GeomValidators_Different);