std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theCurrentAttribute);
GeomShapePtr aShape = aSelectionAttribute->value();
+ ResultPtr aResultContext = aSelectionAttribute->context();
if (!aShape.get()) {
- ResultPtr aResult = aSelectionAttribute->context();
- if (aResult.get())
- aShape = aResult->shape();
+ if (aResultContext.get())
+ aShape = aResultContext->shape();
}
+ // whole feature selection
+ FeaturePtr aFeature = aSelectionAttribute->contextFeature();
std::string aCurrentAttributeId = theCurrentAttribute->id();
if (theAttributes.size() > 0 && aShape.get() != NULL) {
// the shape of the attribute should be not the same
if (aSelectionAttribute.get() != NULL) {
GeomShapePtr anAttrShape = aSelectionAttribute->value();
+ ResultPtr aResult = aSelectionAttribute->context();
if (!anAttrShape.get()) {
- ResultPtr aResult = aSelectionAttribute->context();
if (aResult.get())
anAttrShape = aResult->shape();
}
if (aShape->isEqual(anAttrShape)) {
return false;
}
+ if (aFeature.get()) {
+ if (aResult.get()) { // check result is in feature
+ if (aResult->document()->feature(aResult) == aFeature)
+ return false;
+ }
+ else { // check selection of the same features
+ if (aFeature == aSelectionAttribute->contextFeature())
+ return false;
+ }
+ }
+ else {
+ if (!aResult.get() && aResultContext.get()) {
+ FeaturePtr aSelectedFeature = aSelectionAttribute->contextFeature();
+ if (aResultContext->document()->feature(aResultContext) == aSelectedFeature)
+ return false;
+ }
+ }
}
}
}
//********************************************************************
void ModuleBase_WidgetValidated::filterCompSolids(QList<ModuleBase_ViewerPrsPtr>& theValues)
{
- std::set<ResultBodyPtr> aCompSolids;
+ std::set<ResultPtr> aFilterOut; // all objects that must be filtered out with their children
QList<ModuleBase_ViewerPrsPtr> aValidatedValues;
// Collect compsolids.
QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
- for (; anIt != aLast; anIt++) {
+ for(; anIt != aLast; anIt++) {
const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
ObjectPtr anObject = aViewerPrs->object();
ResultBodyPtr aResultCompSolid =
std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObject);
- if(aResultCompSolid.get() && aResultCompSolid->numberOfSubs() > 0) {
- aCompSolids.insert(aResultCompSolid);
+ if (aResultCompSolid.get()) {
+ for(int aSubIndex = 0; aSubIndex < aResultCompSolid->numberOfSubs(); aSubIndex++)
+ aFilterOut.insert(aResultCompSolid->subResult(aSubIndex));
+ } else { // it could be a whole feature selected, so, add all results of this feature
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+ if (aFeature.get()) {
+ std::list<ResultPtr>::const_iterator aRes = aFeature->results().cbegin();
+ for(; aRes != aFeature->results().cend(); aRes++)
+ aFilterOut.insert(*aRes);
+ }
}
}
// Filter sub-solids of compsolids.
anIt = theValues.begin();
- for (; anIt != aLast; anIt++) {
+ for(; anIt != aLast; anIt++) {
const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
ObjectPtr anObject = aViewerPrs->object();
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
- ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aResult);
- if(aResCompSolidPtr.get() && (aCompSolids.find(aResCompSolidPtr) != aCompSolids.end())) {
- // Skip sub-solid of compsolid.
- continue;
+ while(aResult.get()) {
+ if (aFilterOut.find(aResult) != aFilterOut.end()) // skip if parent is filtered out
+ break;
+ aResult = ModelAPI_Tools::bodyOwner(aResult); // iterate all parents
+ }
+ if (aResult.get()) {
+ continue; // skip
} else {
aValidatedValues.append(*anIt);
}
AttributeSelectionPtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
ResultPtr aContext = anAttr->context();
+ FeaturePtr aContextFeature = anAttr->contextFeature();
GeomShapePtr aShape = anAttr->value();
// Check selection attributes
return false;
}
}
+ // check the whole selected feature contains the result
+ if (aContextFeature.get()) {
+ if (aRef->contextFeature().get()) {
+ if (aContextFeature == aRef->contextFeature()) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(), aRef->id());
+ return false;
+ }
+ } else if (aRef->context().get() &&
+ aRef->context()->document()->feature(aRef->context()) == aContextFeature) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(), aRef->id());
+ return false;
+ }
+ } else if (aRef->contextFeature().get() && aContext.get()) {
+ if (aContext->document()->feature(aContext) == aRef->contextFeature()) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(), aRef->id());
+ return false;
+ }
+ }
}
}
}
for(int i = 0; i < aCurSelList->size(); i++) {
std::shared_ptr<ModelAPI_AttributeSelection> aCurSel = aCurSelList->value(i);
ResultPtr aCurSelContext = aCurSel->context();
+ FeaturePtr aCurSelFeature = aCurSel->contextFeature();
ResultBodyPtr aCurSelCompSolidPtr = ModelAPI_Tools::bodyOwner(aCurSelContext);
std::shared_ptr<GeomAPI_Shape> aCurSelCompSolid;
if(aCurSelCompSolidPtr.get()) {
for(int j = 0; j < aRefSelList->size(); j++) {
std::shared_ptr<ModelAPI_AttributeSelection> aRefSel = aRefSelList->value(j);
ResultPtr aRefSelContext = aRefSel->context();
+ FeaturePtr aRefSelFeature = aRefSel->contextFeature();
ResultBodyPtr aRefSelCompSolidPtr =
ModelAPI_Tools::bodyOwner(aRefSelContext);
std::shared_ptr<GeomAPI_Shape> aRefSelCompSolid;
- if(aRefSelCompSolidPtr.get()) {
+ if (aRefSelCompSolidPtr.get()) {
aRefSelCompSolid = aRefSelCompSolidPtr->shape();
}
if ((aCurSelCompSolid.get() && aCurSelCompSolid->isEqual(aRefSel->value()))
|| (aRefSelCompSolid.get() && aRefSelCompSolid->isEqual(aCurSel->value()))) {
- theError = errorMessage(EqualShapes, "", theAttribute->id(),
- aRefSel->id());
- return false;
+ theError = errorMessage(EqualShapes, "", theAttribute->id(),
+ aRefSel->id());
+ return false;
}
- if(aCurSelContext == aRefSelContext) {
+ if (aCurSelContext == aRefSelContext) {
if (aCurSel->value().get() == NULL || aRefSel->value().get() == NULL) {
- theError = errorMessage(EmptyShapes, "", theAttribute->id(),
- aRefSel->id());
+ theError = errorMessage(EmptyShapes, "", theAttribute->id(), aRefSel->id());
return false;
}
if (aCurSel->value()->isEqual(aRefSel->value())) {
- theError = errorMessage(EqualShapes, "", theAttribute->id(),
- aRefSel->id());
+ theError = errorMessage(EqualShapes, "", theAttribute->id(), aRefSel->id());
+ return false;
+ }
+ }
+
+ // check the whole selected feature contains the result
+ if (aCurSelFeature.get()) {
+ if (aRefSelFeature.get()) {
+ if (aCurSelFeature == aRefSelFeature) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(), aRefSel->id());
+ return false;
+ }
+ }
+ else if (aRefSelContext.get() &&
+ aRefSelContext->document()->feature(aRefSelContext) == aCurSelFeature) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(), aRefSel->id());
+ return false;
+ }
+ }
+ else if (aRefSelFeature.get() && aCurSelContext.get()) {
+ if (aCurSelContext->document()->feature(aCurSelContext) == aRefSelFeature) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(), aRefSel->id());
return false;
}
}