From: mpv Date: Thu, 24 Nov 2016 16:07:38 +0000 (+0300) Subject: Issue #1865 : support while part type in the result of the field X-Git-Tag: V_2.6.0~54 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=08203d89ebbd4b7d85b6fdfe6075cb4bfa9dc0d3;p=modules%2Fshaper.git Issue #1865 : support while part type in the result of the field --- diff --git a/src/CollectionPlugin/CollectionPlugin_Field.cpp b/src/CollectionPlugin/CollectionPlugin_Field.cpp index e1921c0b6..ddae4d042 100644 --- a/src/CollectionPlugin/CollectionPlugin_Field.cpp +++ b/src/CollectionPlugin/CollectionPlugin_Field.cpp @@ -8,12 +8,13 @@ #include #include -#include #include #include #include #include #include +#include +#include CollectionPlugin_Field::CollectionPlugin_Field() { @@ -22,6 +23,9 @@ CollectionPlugin_Field::CollectionPlugin_Field() void CollectionPlugin_Field::initAttributes() { data()->addAttribute(SELECTED_ID(), ModelAPI_AttributeSelectionList::typeId()); + // for the whole part result it is not obligatory + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SELECTED_ID()); + data()->addAttribute(COMPONENTS_NAMES_ID(), ModelAPI_AttributeStringArray::typeId()); data()->addAttribute(STAMPS_ID(), ModelAPI_AttributeIntArray::typeId()); data()->addAttribute(VALUES_ID(), ModelAPI_AttributeTables::typeId()); diff --git a/src/Model/Model_ResultField.cpp b/src/Model/Model_ResultField.cpp index 15509ef21..f10fe16af 100644 --- a/src/Model/Model_ResultField.cpp +++ b/src/Model/Model_ResultField.cpp @@ -6,6 +6,9 @@ #include #include +#include +#include +#include #include @@ -31,10 +34,36 @@ std::shared_ptr Model_ResultField::shape() AttributeSelectionListPtr aList = myOwnerData->selectionList("selected"); if (aList) { std::list > aSubs; - for(int a = aList->size() - 1; a >= 0; a--) { - std::shared_ptr aSelection = aList->value(a)->value(); - if (aSelection && !aSelection->isNull()) { - aSubs.push_back(aSelection); + if (aList->selectionType() == "part") { // all result bodies of the part + std::shared_ptr aDoc = + std::dynamic_pointer_cast(document()); + if (!aDoc.get()) + return aResult; + FeaturePtr aThisFeature = document()->feature( + std::dynamic_pointer_cast(data()->owner())); + int aResults = document()->size(ModelAPI_ResultBody::group()); + for(int a = 0; a < aResults; a++) { + ResultBodyPtr aBody = std::dynamic_pointer_cast( + document()->object(ModelAPI_ResultBody::group(), a)); + if (!aBody.get()) + continue; + // check that only results that were created before this field are used + FeaturePtr aResultFeature = document()->feature(aBody); + if (!aResultFeature.get()) + continue; + if (aDoc->isLater(aResultFeature, aThisFeature)) + continue; + GeomShapePtr aShape = aBody->shape(); + if (!aShape.get() || aShape->isNull()) + continue; + aSubs.push_back(aShape); + } + } else { + for(int a = aList->size() - 1; a >= 0; a--) { + std::shared_ptr aSelection = aList->value(a)->value(); + if (aSelection && !aSelection->isNull()) { + aSubs.push_back(aSelection); + } } } if (!aSubs.empty()) {