}
ResultPtr aContext = anAttrSelection->context();
if(!aContext.get()) {
- theError = "Error: Empty selection context.";
- return false;
+ FeaturePtr aContFeat = anAttrSelection->contextFeature();
+ if (!aContFeat.get()) {
+ theError = "Error: Empty selection context.";
+ return false;
+ }
}
ResultConstructionPtr aResultConstruction =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
}
}
std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
- GeomShapePtr aContextShape = aContext->shape();
if(!aShape.get()) {
+ GeomShapePtr aContextShape = aContext->shape();
aShape = aContextShape;
}
if(!aShape.get()) {
theError = "Error: Empty shape.";
return false;
}
- if(!aShape->isEqual(aContextShape)) {
+ if (aContext.get() && !aShape->isEqual(aContext->shape())) {
theError = "Error: Local selection not allowed.";
return false;
}
theError = "Error: empty attribute selection.";
return false;
}
+ FeaturePtr aFeature;
ResultPtr aContext = anAttrSelection->context();
if(!aContext.get()) {
- theError = "Error: empty selection context.";
- return false;
+ aFeature = anAttrSelection->contextFeature();
+ if (!aFeature.get()) {
+ theError = "Error: Empty selection context.";
+ return false;
+ }
+ } else {
+ aFeature = ModelAPI_Feature::feature(aContext);
}
- FeaturePtr aFeature = ModelAPI_Feature::feature(aContext);
+
if(!aFeature.get()) {
theError = "Error: empty feature.";
return false;
#include <Events_InfoMessage.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Vertex.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
#include <TNaming_Selector.hxx>
#include <TNaming_NamedShape.hxx>
// identifier of the selection of the second focus point of ellipse on edge
Standard_GUID kELLIPSE_CENTER2("1395ae73-8e02-4cf8-b204-06ff35873a32");
+// prefix for the whole feature context identification
+const static std::string kWHOLE_FEATURE = "all-in-";
+
// on this label is stored:
// TNaming_NamedShape - selected shape
// TNaming_Naming - topological selection information (for the body)
if (aConstr->isInfinite())
return aResult; // empty result
}
+ // whole feature
+ FeaturePtr aFeature = contextFeature();
+ if (aFeature.get()) {
+ std::list<GeomShapePtr> allShapes;
+ std::list<ResultPtr>::const_iterator aRes = aFeature->results().cbegin();
+ for (; aRes != aFeature->results().cend(); aRes++) {
+ if (aRes->get() && !(*aRes)->isDisabled()) {
+ GeomShapePtr aShape = (*aRes)->shape();
+ if (aShape.get() && !aShape->isNull()) {
+ allShapes.push_back(aShape);
+ }
+ }
+ }
+ return GeomAlgoAPI_CompoundBuilder::compound(allShapes);
+ }
+
Handle(TNaming_NamedShape) aSelection;
if (aSelLab.FindAttribute(TNaming_NamedShape::GetID(), aSelection)) {
TopoDS_Shape aSelShape = aSelection->Get();
return true;
}
}
+ // for the whole feature, a feature object
+ FeaturePtr aFeat = contextFeature();
+ if (aFeat.get())
+ return true;
}
}
}
std::shared_ptr<GeomAPI_Shape> aSubSh = internalValue(aCenterType);
ResultPtr aCont = context();
- if (!aCont.get()) // in case of selection of removed result
+ if (!aCont.get()) {
+ // selection of a full feature
+ FeaturePtr aFeatureCont = contextFeature();
+ if (aFeatureCont.get()) {
+ return kWHOLE_FEATURE + aFeatureCont->name();
+ }
+ // in case of selection of removed result
return "";
+ }
Model_SelectionNaming aSelNaming(selectionLabel());
std::string aResult = aSelNaming.namingName(
}
}
- Model_SelectionNaming aSelNaming(selectionLabel());
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(owner()->document());
+ // check this is a whole feature context
+ if (aSubShapeName.size() > kWHOLE_FEATURE.size() &&
+ aSubShapeName.substr(0, kWHOLE_FEATURE.size()) == kWHOLE_FEATURE) {
+ std::string aFeatureName = aSubShapeName.substr(kWHOLE_FEATURE.size());
+ ObjectPtr anObj = aDoc->objectByName(ModelAPI_Feature::group(), aFeatureName);
+ if (anObj.get()) {
+ static const GeomShapePtr anEmptyShape;
+ setValue(anObj, anEmptyShape);
+ return;
+ }
+ }
+
+ Model_SelectionNaming aSelNaming(selectionLabel());
std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected;
ResultPtr aCont;
if (aSelNaming.selectSubShape(aType, aSubShapeName, aDoc, aShapeToBeSelected, aCont)) {
void Model_Data::eraseBackReferences()
{
myRefsToMe.clear();
- std::shared_ptr<ModelAPI_Result> aRes =
- std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
- if (aRes)
+ std::shared_ptr<ModelAPI_Result> aRes = std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+ if (aRes) {
aRes->setIsConcealed(false);
+ }
}
void Model_Data::removeBackReference(ObjectPtr theObject, std::string theAttrID)
if (theApplyConcealment && theFeature->isStable() &&
ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
- std::shared_ptr<ModelAPI_Result> aRes =
- std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+ std::shared_ptr<ModelAPI_Result> aRes = std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
// the second condition is for history upper than concealment causer, so the feature result may
// be displayed and previewed; also for avoiding of quick show/hide on history
// moving deep down
if (aFeature.get() && !aFeature->isDisabled() && aFeature->isStable()) {
if (ModelAPI_Session::get()->validators()->isConcealed(
aFeature->getKind(), (*aRefsIter)->id())) {
- std::shared_ptr<ModelAPI_Result> aRes =
- std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+ std::shared_ptr<ModelAPI_Result> aRes = std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
if (aRes.get()) {
aRes->setIsConcealed(true); // set concealed
return;
}
} else if (aType == ModelAPI_AttributeRefList::typeId()) { // list of references
aReferenced = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttr)->list();
- } else if (aType == ModelAPI_AttributeSelection::typeId()) { // selection attribute
+ }
+ else if (aType == ModelAPI_AttributeSelection::typeId()) { // selection attribute
std::shared_ptr<ModelAPI_AttributeSelection> aRef = std::dynamic_pointer_cast<
- ModelAPI_AttributeSelection>(anAttr);
- aReferenced.push_back(aRef->context());
+ ModelAPI_AttributeSelection>(anAttr);
+ FeaturePtr aRefFeat = aRef->contextFeature();
+ if (aRefFeat.get()) { // reference to all results of the referenced feature
+ const std::list<ResultPtr>& allRes = aRefFeat->results();
+ std::list<ResultPtr>::const_iterator aRefRes = allRes.cbegin();
+ for(; aRefRes != allRes.cend(); aRefRes++) {
+ aReferenced.push_back(*aRefRes);
+ }
+ } else {
+ aReferenced.push_back(aRef->context());
+ }
} else if (aType == ModelAPI_AttributeSelectionList::typeId()) { // list of selection attributes
std::shared_ptr<ModelAPI_AttributeSelectionList> aRef = std::dynamic_pointer_cast<
ModelAPI_AttributeSelectionList>(anAttr);
for(int a = 0, aSize = aRef->size(); a < aSize; ++a) {
- aReferenced.push_back(aRef->value(a)->context());
+ FeaturePtr aRefFeat = aRef->value(a)->contextFeature();
+ if (aRefFeat.get()) { // reference to all results of the referenced feature
+ const std::list<ResultPtr>& allRes = aRefFeat->results();
+ std::list<ResultPtr>::const_iterator aRefRes = allRes.cbegin();
+ for (; aRefRes != allRes.cend(); aRefRes++) {
+ aReferenced.push_back(*aRefRes);
+ }
+ } else {
+ aReferenced.push_back(aRef->value(a)->context());
+ }
}
} else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
std::shared_ptr<ModelAPI_AttributeRefAttrList> aRefAttr = std::dynamic_pointer_cast<
{
// iterate in the structure of sub-results to the parent
ResultPtr aCurRes = theResult;
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
std::list<int> anIndices; // indexes of results in the parent result, starting from topmost
while(aCurRes.get()) {
ResultBodyPtr aParent = ModelAPI_Tools::bodyOwner(aCurRes);
if (aParent) {
anIndices.push_front(ModelAPI_Tools::bodyIndex(aCurRes));
+ } else { // index of the result in the feature
+ std::list<ResultPtr>::const_iterator aRes = aFeature->results().cbegin();
+ for(int anIndex = 0; aRes != aFeature->results().cend(); aRes++, anIndex++) {
+ if (*aRes == aCurRes) {
+ anIndices.push_front(anIndex);
+ break;
+ }
+ }
}
aCurRes = aParent;
}
- FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
myDumpBuffer << name(aFeature);
for (std::list<int>::iterator anI = anIndices.begin(); anI != anIndices.end(); anI++) {
if (anI == anIndices.begin()) {