Salome HOME
The external feature should be executed manually in order to return first result.
[modules/shaper.git] / src / PartSet / PartSet_OperationPrs.cpp
index b4a5fb5a1636340eb50db3325d5a2bb74c082ce2..d20041e43aa7b97aca301a2f3868e09d78a65580 100755 (executable)
 #include "XGUI_ModuleConnector.h"
 #include "XGUI_Displayer.h"
 
+#include "ModuleBase_Tools.h"
+
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeRefList.h>
+
 
 #include <GeomValidators_Tools.h>
 
@@ -82,7 +86,11 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
     QList<GeomShapePtr>::const_iterator aShIt = aShapes.begin(), aShLast = aShapes.end();
     for (; aShIt != aShLast; aShIt++) {
       GeomShapePtr aGeomShape = *aShIt;
+      if (!aGeomShape.get())
+        continue;
       TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
+      // change deviation coefficient to provide more precise circle
+      ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
       StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
     }
   }
@@ -125,14 +133,25 @@ bool isSubObject(const ObjectPtr& theObject, const FeaturePtr& theFeature)
 }
 
 void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
+              const FeaturePtr& theFeature,
               QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
 {
-  if (theObjectShapes.contains(theObject))
-    theObjectShapes[theObject].append(theShape);
-  else {
-    QList<GeomShapePtr> aShapes;
-    aShapes.append(theShape);
-    theObjectShapes[theObject] = aShapes;
+  if (theObject.get()) {
+    GeomShapePtr aShape = theShape;
+    if (!aShape.get()) {
+      ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+      if (aResult.get())
+        aShape = aResult->shape();
+    }
+    if (!isSubObject(theObject, theFeature)) {
+      if (theObjectShapes.contains(theObject))
+        theObjectShapes[theObject].append(aShape);
+      else {
+        QList<GeomShapePtr> aShapes;
+        aShapes.append(aShape);
+        theObjectShapes[theObject] = aShapes;
+      }
+    }
   }
 }
 
@@ -158,10 +177,15 @@ void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr>
         std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
         ResultPtr aResult = aSelAttribute->context();
         GeomShapePtr aShape = aSelAttribute->value();
-        if (!aShape.get())
-          aShape = aResult->shape();
-        if (!isSubObject(aResult, myFeature))
-          addValue(aResult, aShape, theObjectShapes);
+        addValue(aResult, aShape, myFeature, theObjectShapes);
+      }
+    }
+    if (anAttrType == ModelAPI_AttributeRefList::typeId()) {
+      std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
+        std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
+      for (int i = 0; i < aCurSelList->size(); i++) {
+        GeomShapePtr aShape;
+        addValue(aCurSelList->object(i), aShape, myFeature, theObjectShapes);
       }
     }
     else {
@@ -190,16 +214,7 @@ void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr>
         AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(anAttribute);
         anObject = anAttr->value();
       }
-
-      if (anObject.get()) {
-        if (!aShape.get()) {
-          ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
-          if (aResult.get())
-            aShape = aResult->shape();
-        }
-        if (!isSubObject(anObject, myFeature))
-          addValue(anObject, aShape, theObjectShapes);
-      }
+      addValue(anObject, aShape, myFeature, theObjectShapes);
     }
   }
 }
@@ -209,6 +224,7 @@ bool PartSet_OperationPrs::isSelectionAttribute(const AttributePtr& theAttribute
   std::string anAttrType = theAttribute->attributeType();
 
   return anAttrType == ModelAPI_AttributeSelectionList::typeId() ||
+         anAttrType == ModelAPI_AttributeRefList::typeId() ||
          anAttrType == ModelAPI_AttributeRefAttr::typeId() ||
          anAttrType == ModelAPI_AttributeSelection::typeId() ||
          anAttrType == ModelAPI_AttributeReference::typeId();