]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Construction of vertices/edges/faces on the base of sketch: sketch attribute
authornds <nds@opencascade.com>
Fri, 4 Dec 2015 15:58:30 +0000 (18:58 +0300)
committerdbv <dbv@opencascade.com>
Tue, 8 Dec 2015 08:51:32 +0000 (11:51 +0300)
src/PartSet/PartSet_Validators.cpp
src/SketchShapePlugin/SketchShapePlugin_Feature.cpp
src/SketchShapePlugin/SketchShapePlugin_Feature.h
src/SketchShapePlugin/plugin-SketchShape.xml

index 9b4aa471db355d9369f04e6c83e2a6526a7b91be..acb34da8f2403f30cc883df4703c005011d764dc 100755 (executable)
@@ -550,6 +550,21 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
       }
     }
   }
+  if (anAttributeType == ModelAPI_AttributeSelection::typeId()) {
+    AttributeSelectionPtr aSelectAttr = 
+                      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+    ObjectPtr anObject = aSelectAttr->context();
+    // a context of the selection attribute is a feature result. It can be a case when the result
+    // of the feature is null, e.g. the feature is modified and has not been executed yet.
+    // The validator returns an invalid result here. The case is an extrusion built on a sketch
+    // feature. A new sketch element creation leads to an empty result.
+    if (!anObject.get())
+      isSketchEntities = false;
+    else {
+      FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+      isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+    }
+  }
   if (anAttributeType == ModelAPI_AttributeRefList::typeId()) {
     AttributeRefListPtr aRefListAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
index 0b45548c4d38841fc47cdbc5285d9b7134d6ca7b..71f918cd2b61523cee8152eda1720e93e59b0f8b 100755 (executable)
@@ -6,6 +6,7 @@
 
 #include "SketchShapePlugin_Feature.h"
 
+#include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeBoolean.h>
 
@@ -16,6 +17,7 @@ SketchShapePlugin_Feature::SketchShapePlugin_Feature()
 
 void SketchShapePlugin_Feature::initAttributes()
 {
+  data()->addAttribute(SKETCH_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(VERTEX_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(VERTEX_CHOICE_ID(), ModelAPI_AttributeBoolean::typeId());
 }
index 6e38662a278eb9ab179bcb8c41f3c089be99b3a4..9ed0150d471e60a1b0e15827426b40a136fa6cff 100755 (executable)
@@ -29,6 +29,13 @@ class SketchShapePlugin_Feature : public ModelAPI_Feature
     return MY_SKETCH_SHAPE_ID;
   }
 
+  /// Sketch feature
+  inline static const std::string& SKETCH_ID()
+  {
+    static const std::string MY_SKETCH_ID("Sketch");
+    return MY_SKETCH_ID;
+  }
+
   /// List of vertices to be extracted
   inline static const std::string& VERTEX_LIST_ID()
   {
index 016198101ff79d820bae9f98bead9cb507eb45b9..4a9b54ccbef021300b407e0f02f5ed677a65c4cb 100755 (executable)
@@ -4,6 +4,13 @@
   <workbench id="Sketch">
     <group id="Exchange">
       <feature id="SketchShape" title="Sketch vertices, edges and faces" tooltip="Construct vertices, edges and faces by sketch" icon=":icons/sketchshape.png">
+        <shape_selector id="Sketch"
+          label="Sketch"
+          icon=":icons/sketch.png"
+          tooltip="Select a sketch"
+          shape_types="objects">
+          <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
+        </shape_selector>
         <sketchshape_groupbox title="Direction">
           <boolvalue id="VertexChoice" label="VERTICES" default="true" tooltip="Vertices selection on sketch"/>
           <sketch_multi_selector id="VertexList"