Salome HOME
Construction of vertices/edges/faces on the base of sketch: clear list attribute...
authornds <nds@opencascade.com>
Fri, 4 Dec 2015 17:31:25 +0000 (20:31 +0300)
committerdbv <dbv@opencascade.com>
Tue, 8 Dec 2015 08:51:43 +0000 (11:51 +0300)
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/SketchShapePlugin/SketchShapePlugin_Feature.cpp
src/SketchShapePlugin/SketchShapePlugin_Feature.h
src/SketchShapePlugin/plugin-SketchShape.xml

index d3dffd6a29e8c1cf33db354131fb94546e1985e8..0d8d976fa9cf1d0f8b7661800f0cbc4a3c364ade 100755 (executable)
@@ -61,7 +61,7 @@ public:
   /// Redefinition of virtual method
   virtual QSize        minimumSizeHint() const
   {
-    int aHeight = 2*QFontMetrics( font() ).height();
+    int aHeight = 4/*2*/*QFontMetrics( font() ).height();
     QSize aSize = QListWidget::minimumSizeHint();
     return QSize( aSize.width(), aHeight );
   }
index 71f918cd2b61523cee8152eda1720e93e59b0f8b..4de0c8de33f3a5e99516b8348288a5b06164e0f2 100755 (executable)
@@ -10,6 +10,9 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeBoolean.h>
 
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
 SketchShapePlugin_Feature::SketchShapePlugin_Feature()
 : ModelAPI_Feature()
 {
@@ -18,8 +21,18 @@ 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());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERTEX_CHOICE_ID());
+
+  data()->addAttribute(EDGE_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+  data()->addAttribute(EDGE_CHOICE_ID(), ModelAPI_AttributeBoolean::typeId());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EDGE_CHOICE_ID());
+
+  data()->addAttribute(FACE_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+  data()->addAttribute(FACE_CHOICE_ID(), ModelAPI_AttributeBoolean::typeId());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FACE_CHOICE_ID());
 }
 
 void SketchShapePlugin_Feature::execute()
@@ -28,5 +41,35 @@ void SketchShapePlugin_Feature::execute()
 
 void SketchShapePlugin_Feature::attributeChanged(const std::string& theID)
 {
+  if (theID == VERTEX_CHOICE_ID() ||
+      theID == EDGE_CHOICE_ID() ||
+      theID == FACE_CHOICE_ID()) {
+    std::string aListAttrId = theID == VERTEX_CHOICE_ID() ? VERTEX_LIST_ID() : (
+                              theID == EDGE_CHOICE_ID() ? EDGE_LIST_ID() :
+                              FACE_LIST_ID());
+
+    AttributeBooleanPtr aChoiceAttribute = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(
+                                           data()->attribute(theID));
+    if (!aChoiceAttribute->value()) {
+      AttributeSelectionListPtr aListAttribute =
+        std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->attribute(aListAttrId));
+      aListAttribute->clear();
+    }
+  }
+  else if (theID == VERTEX_LIST_ID() ||
+           theID == EDGE_LIST_ID() ||
+           theID == FACE_LIST_ID()) {
+    AttributeSelectionListPtr aSelectionListAttr = 
+                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->attribute(theID));
+    for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) {
+      AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
+      ObjectPtr anObject = aSelectAttr->context();
+      if (!anObject.get())
+        continue;
+      else {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+      }
+    }
+  }
 }
 
index 9ed0150d471e60a1b0e15827426b40a136fa6cff..0a59da95d1fffd31f42279bbd3e22dff76720ccb 100755 (executable)
@@ -36,6 +36,13 @@ class SketchShapePlugin_Feature : public ModelAPI_Feature
     return MY_SKETCH_ID;
   }
 
+  /// State whether the vertices are selectable
+  inline static const std::string& VERTEX_CHOICE_ID()
+  {
+    static const std::string MY_VERTEX_CHOICE_ID("VertexChoice");
+    return MY_VERTEX_CHOICE_ID;
+  }
+
   /// List of vertices to be extracted
   inline static const std::string& VERTEX_LIST_ID()
   {
@@ -43,11 +50,32 @@ class SketchShapePlugin_Feature : public ModelAPI_Feature
     return MY_VERTEX_LIST_ID;
   }
 
-  /// State whether the vertices are selectable
-  inline static const std::string& VERTEX_CHOICE_ID()
+    /// State whether the vertices are selectable
+  inline static const std::string& EDGE_CHOICE_ID()
   {
-    static const std::string MY_VERTEX_CHOICE_ID("VertexChoice");
-    return MY_VERTEX_CHOICE_ID;
+    static const std::string MY_EDGE_CHOICE_ID("EdgeChoice");
+    return MY_EDGE_CHOICE_ID;
+  }
+
+  /// List of vertices to be extracted
+  inline static const std::string& EDGE_LIST_ID()
+  {
+    static const std::string MY_EDGE_LIST_ID("EdgeList");
+    return MY_EDGE_LIST_ID;
+  }
+
+    /// State whether the vertices are selectable
+  inline static const std::string& FACE_CHOICE_ID()
+  {
+    static const std::string MY_FACE_CHOICE_ID("FaceChoice");
+    return MY_FACE_CHOICE_ID;
+  }
+
+  /// List of vertices to be extracted
+  inline static const std::string& FACE_LIST_ID()
+  {
+    static const std::string MY_FACE_LIST_ID("FaceList");
+    return MY_FACE_LIST_ID;
   }
 
   /// Returns the kind of a feature
index 4a9b54ccbef021300b407e0f02f5ed677a65c4cb..6f51667ca1c1f793eb77c668e18af605fd435077 100755 (executable)
           <boolvalue id="VertexChoice" label="VERTICES" default="true" tooltip="Vertices selection on sketch"/>
           <sketch_multi_selector id="VertexList"
             label=""
-            tooltip="Select list of mirroring objects"
-            type_choice="Vertices"
+            tooltip="Select list of vertices"
+            type_choice="Vertices Edges Faces"
+            use_external="false"
+            use_choice="false">
+            <validator id="SketchShapePlugin_FeatureValidator" />
+          </sketch_multi_selector>
+
+          <boolvalue id="EdgeChoice" label="EDGES" default="true" tooltip="Edges selection on sketch"/>
+          <sketch_multi_selector id="EdgeList"
+            label=""
+            tooltip="Select list of edges"
+            type_choice="Vertices Edges Faces"
+            use_external="false"
+            use_choice="false">
+            <validator id="SketchShapePlugin_FeatureValidator" />
+          </sketch_multi_selector>
+
+          <boolvalue id="FaceChoice" label="FACES" default="true" tooltip="Faces selection on sketch"/>
+          <sketch_multi_selector id="FaceList"
+            label=""
+            tooltip="Select list of faces"
+            type_choice="Vertices Edges Faces"
             use_external="false"
             use_choice="false">
             <validator id="SketchShapePlugin_FeatureValidator" />