Salome HOME
Issue #1961: Filter not acceptable shapes and objects
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 29 Dec 2016 14:46:30 +0000 (17:46 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 29 Dec 2016 14:46:46 +0000 (17:46 +0300)
src/CollectionPlugin/CollectionPlugin_WidgetField.cpp
src/CollectionPlugin/CollectionPlugin_WidgetField.h

index 55b8066127e6f911fffde266df517c4a958f860f..509789ad971fb05a6372521cff867e4b90c88750 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IModule.h>
 #include <ModuleBase_ISelection.h>
 #include <ModuleBase_IPropertyPanel.h>
 
@@ -782,21 +783,25 @@ bool CollectionPlugin_WidgetField::
 }
 
 //**********************************************************************************
-void CollectionPlugin_WidgetField::onSelectionChanged()
+bool CollectionPlugin_WidgetField::
+  setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues, const bool theToValidate)
 {
-  //if (isEditingMode())
-  //  return;
-
   if (myActivation) {
     myActivation = false;
-    return;
+    return false;
   }
   // Ignore selection for Parts mode
   if (myShapeTypeCombo->currentIndex() == 5)
-    return;
-
-  QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
-
+    return false;
+
+  QList<ModuleBase_ViewerPrsPtr> aSelected;
+  QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt;
+  for (anIt = theValues.begin(); anIt != theValues.end(); anIt++) {
+    ModuleBase_ViewerPrsPtr aValue = *anIt;
+    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
+    if (theToValidate && aRes.get() && acceptSubShape(aValue->shape(), aRes))
+      aSelected.append(aValue);
+  }
   AttributeSelectionListPtr aSelList =
     myFeature->data()->selectionList(CollectionPlugin_Field::SELECTED_ID());
   aSelList->setSelectionType(getSelectionType(myShapeTypeCombo->currentIndex()));
@@ -859,7 +864,7 @@ void CollectionPlugin_WidgetField::onSelectionChanged()
       }
     }
   }
-  emit valuesChanged();
+  return true;
 }
 
 //**********************************************************************************
index 3bd98f95c7c4f5aeb38187905a35243fa3eb0c94..e0084fcb335dd765b93a21a84df72df85ec7fbb1 100644 (file)
@@ -82,6 +82,13 @@ public:
   /// The methiod called when widget is deactivated
   virtual void deactivate();
 
+  /// Set the given wrapped value to the current widget
+  /// This value should be processed in the widget according to the needs
+  /// \param theValues the wrapped selection values
+  /// \param theToValidate a validation of the values flag
+  virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
+                            const bool theToValidate);
+
 protected:
   /// Saves the internal parameters to the given feature
   /// \return True in success
@@ -106,10 +113,6 @@ protected:
   /// a shape. If the attribute do not uses the shape, it is empty
   virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
 
-protected slots:
-  /// Slot which is called on selection event
-  virtual void onSelectionChanged();
-
 private slots:
   /// Slot called on number of component changed
   /// \param theVal - a new components number