]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task #3236: Generalization of extrusion
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 29 Jun 2020 21:09:03 +0000 (00:09 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 29 Jun 2020 21:09:03 +0000 (00:09 +0300)
Fix the validator to be able to select sketch vertices and edges for extrusion and revolution.

src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h
src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/FeaturesPlugin/extrusion_widget.xml

index 1a6767086da52f312287e1cf2fc74cab74fc31dc..b1f78b9fd5265a598cb7156b20350824dd9156a2 100644 (file)
@@ -50,6 +50,7 @@ void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int the
   // Initialize selection list.
   if(theInitFlags & InitBaseObjectsList) {
     data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
+    myCurrentSelectionType = selectionList(BASE_OBJECTS_ID())->selectionType();
   }
 }
 
@@ -288,3 +289,15 @@ void storeSubShape(
     }
   }
 }
+
+//=================================================================================================
+void FeaturesPlugin_CompositeSketch::attributeChanged(const std::string& theID)
+{
+  if (theID == BASE_OBJECTS_ID()) {
+    AttributeSelectionListPtr anObjects = selectionList(BASE_OBJECTS_ID());
+    if (anObjects->size() == 0 || anObjects->selectionType() != myCurrentSelectionType) {
+      myCurrentSelectionType = anObjects->selectionType();
+      removeResults(0); // clear the results
+    }
+  }
+}
index 67fde35a59fc0a08b508aad5419b2d7c653138c4..ef4ce06a03cab1059f96ab18e0615dd4bd619712 100644 (file)
@@ -66,6 +66,10 @@ public:
   /// structures of the owner (the remove from the document will be done outside just after).
   FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
 
+  /// On change of attribute of the result update presentation of this result:
+  /// for the current moment there are only presentation attributes assigned to results
+  FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
 protected:
   enum InitFlags {
     InitSketchLauncher   = 1 << 0,
@@ -99,6 +103,8 @@ protected:
                    const ListOfShape& theShapes,
                    const std::string theName);
 
+private:
+  std::string myCurrentSelectionType; //< type of selection (vertex, edge or face)
 };
 
 #endif
index f47f5ba79d1580b936fe78cb19afbdb5b703cc76..a47e06a67e62f09c994f82dac6a6b2e3e2431f2c 100644 (file)
@@ -440,14 +440,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
         if(aConstruction->facesNum() > 0) {
           return true;
         }
-      } else {
-        // Shape on construction selected. Check that it is a face or wire.
-        if(aShape->shapeType() == GeomAPI_Shape::WIRE ||
-           aShape->shapeType() == GeomAPI_Shape::FACE) {
-          return true;
-        }
       }
-      return false;
     }
 
     if(aContextShape.get() && !aShape->isEqual(aContextShape)) {
index 97e02b9c35ecf126ef2710d4657f6b18507607c0..94a9d4bc3a5d05302cc90b0974cf7a64fc4cb8df 100644 (file)
@@ -19,7 +19,7 @@
                   default_type = "2"
                   use_choice="true"
                   concealment="true">
-    <validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face"/>
+    <validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
   </multi_selector>
   <shape_selector id="direction_object"
                   icon="icons/Features/axis.png"