-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
isDegeneratedEdge = BRep_Tool::Degenerated(TopoDS::Edge(aSubShape)) == Standard_True;
}
if (!theContext.get() || isDegeneratedEdge) {
- // to keep the reference attribute label
- TDF_Label aRefLab = myRef.myRef->Label();
aSelLab.ForgetAllAttributes(true);
myRef.myRef = TDF_Reference::Set(aSelLab.Father(), aSelLab.Father());
if (aToUnblock)
anUpdated = !aSelLab.IsAttribute(kELLIPSE_CENTER2);
TDataStd_UAttribute::Set(aSelLab, kELLIPSE_CENTER2);
break;
+ default: // [to avoid compilation warning]
+ break;
}
if (anUpdated)
owner()->data()->sendAttributeUpdated(this);
} else { // face with name is already in the data model, so try to take it by name
Handle(TDataStd_Name) aName;
if (aSelLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
- std::string aSubShapeName(TCollection_AsciiString(aName->Get()).ToCString());
- std::size_t aPartEnd = aSubShapeName.find('/');
- if (aPartEnd != std::string::npos && aPartEnd != aSubShapeName.rfind('/')) {
- std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1);
- int anIndex;
+ std::wstring aSubShapeName = Locale::Convert::toWString(aName->Get().ToExtString());
+ std::size_t aPartEnd = aSubShapeName.find(L'/');
+ if (aPartEnd != std::wstring::npos && aPartEnd != aSubShapeName.rfind(L'/')) {
+ std::wstring aNameInPart = aSubShapeName.substr(aPartEnd + 1);
+ int anInd;
std::string aType; // to reuse already existing selection the type is not needed
- return aPart->shapeInPart(Locale::Convert::toWString(aNameInPart), aType, anIndex);
+ return aPart->shapeInPart(aNameInPart, aType, anInd);
}
}
}
aSubSh->setImpl(new TopoDS_Shape(aSub.Value()));
setValue(theContext, aSubSh);
for(aSub.Next(); aSub.More(); aSub.Next()) {
- GeomShapePtr aSubSh(new GeomAPI_Shape);
+ aSubSh.reset(new GeomAPI_Shape);
aSubSh->setImpl(new TopoDS_Shape(aSub.Value()));
myParent->append(theContext, aSubSh);
}
centersMap().begin();
for(; aPrefixIter != centersMap().end(); aPrefixIter++) {
std::size_t aFound = theShapeName.find(aPrefixIter->second);
- if (aFound != std::string::npos &&
+ if (aFound != std::wstring::npos &&
aFound == theShapeName.size() - aPrefixIter->second.size()) {
theShapeName = theShapeName.substr(0, aFound);
return aPrefixIter->first;
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(owner()->document());
// check this is Part-name: 2 delimiters in the name
- std::size_t aPartEnd = aSubShapeName.find('/');
- if (aPartEnd != std::string::npos) {
+ std::size_t aPartEnd = aSubShapeName.find(L'/');
+ if (aPartEnd != std::wstring::npos) {
std::wstring aPartName = aSubShapeName.substr(0, aPartEnd);
DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
if (aPartName == Locale::Convert::toWString(aRootDoc->kind())) {
}
// the whole result selection check
- if (aSubShapeName.find('/') == std::string::npos) {
+ if (aSubShapeName.find(L'/') == std::wstring::npos) {
ObjectPtr aRes = aDoc->objectByName(ModelAPI_ResultConstruction::group(), aSubShapeName);
if (!aRes.get()) {
aRes = aDoc->objectByName(ModelAPI_ResultBody::group(), aSubShapeName);
NCollection_DataMap<TopoDS_Shape, TopTools_MapOfShape, TopTools_ShapeMapHasher> aSubs;
TopTools_DataMapOfShapeShape::Iterator aContIter(aNewToOld);
for(; aContIter.More(); aContIter.Next()) {
- TopExp_Explorer aSubExp(aContIter.Key(), aValType);
- for(; aSubExp.More(); aSubExp.Next()) {
+ for(aSubExp.Init(aContIter.Key(), aValType); aSubExp.More(); aSubExp.Next()) {
if (!aSubs.IsBound(aSubExp.Current())) {
aSubs.Bind(aSubExp.Current(), TopTools_MapOfShape());
}
void Model_AttributeSelection::concealedFeature(
const FeaturePtr theFeature, const FeaturePtr theStop, const bool theCheckCopy,
- std::list<FeaturePtr>& theConcealers, const ResultPtr theResultOfFeature)
+ std::list<FeaturePtr>& theConcealers, const ResultPtr theResultOfFeature,
+ const bool theCheckWholeFeature)
{
std::set<FeaturePtr> alreadyProcessed;
alreadyProcessed.insert(theFeature);
}
std::list<ResultPtr>::const_iterator aRootIter = aRootRes.cbegin();
for(; aRootIter != aRootRes.cend(); aRootIter++) {
- std::list<ResultPtr> allRes;
- allRes.push_back(*aRootIter);
+ std::list<DataPtr> allRes;
+ allRes.push_back((*aRootIter)->data());
ResultBodyPtr aRootBody = ModelAPI_Tools::bodyOwner(*aRootIter, true);
if (!aRootBody.get())
aRootBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRootIter);
if (aRootBody.get()) {
- ModelAPI_Tools::allSubs(aRootBody, allRes);
- }
- for(std::list<ResultPtr>::iterator aRIter = allRes.begin(); aRIter != allRes.end(); aRIter++) {
- const std::set<AttributePtr>& aRefs = (*aRIter)->data()->refsToMe();
+ std::list<ResultPtr> allSub;
+ ModelAPI_Tools::allSubs(aRootBody, allSub);
+ for(std::list<ResultPtr>::iterator anIt = allSub.begin(); anIt != allSub.end(); anIt++)
+ allRes.push_back((*anIt)->data());
+ }
+ if (theCheckWholeFeature)
+ allRes.push_back(theFeature->data());
+ for(std::list<DataPtr>::iterator aRIter = allRes.begin(); aRIter != allRes.end(); aRIter++) {
+ const std::set<AttributePtr>& aRefs = (*aRIter)->refsToMe();
std::set<AttributePtr>::const_iterator aRef = aRefs.cbegin();
for (; aRef != aRefs.cend(); aRef++) {
if (!aRef->get() || !(*aRef)->owner().get())
if (!aPairIter.More())
return;
TopoDS_Shape aNewCShape = aPairIter.NewShape();
- bool anIterate = true;
// trying to update also the sub-shape selected
GeomShapePtr aSubShape = value();
if (aSubShape.get() && aSubShape->isEqual(aContext->shape()))
TopTools_ListOfShape aValShapes;
if (searchNewContext(aDoc, aNewCShape, aContext, aValShape, aContLab, aNewContexts, aValShapes))
{
- std::set<ResultPtr> allContexts, aSkippedContext;
- std::list<ResultPtr>::iterator aNewContext = aNewContexts.begin();
- for(; aNewContext != aNewContexts.end(); aNewContext++)
- allContexts.insert(*aNewContext);
+ std::set<ResultPtr> allContexts(aNewContexts.begin(), aNewContexts.end());
+ std::set<ResultPtr> aSkippedContext;
// if there exist context composite and sub-result(s), leave only sub(s)
std::set<ResultPtr>::iterator aResIter = allContexts.begin();
// remove the sub-value part if exists
std::wstring aSubShapeName = aName;
- std::string::size_type n = aName.find('/');
- if (n != std::string::npos) {
+ std::wstring::size_type n = aName.find(L'/');
+ if (n != std::wstring::npos) {
aName = aName.substr(0, n);
}
// remove the document identifier from name if exists
aSubShapeName = theName.substr(aDoc->kind().size() + 1);
aName = aSubShapeName;
- std::string::size_type n = aName.find('/');
- if (n != std::string::npos) {
+ n = aName.find(L'/');
+ if (n != std::wstring::npos) {
aName = aName.substr(0, n);
}
}
// sketch sub-component shape and name is located in separated feature label, try the sub-name
if (theValue.IsNull() && aCont->groupName() == ModelAPI_ResultConstruction::group()) {
- std::string::size_type aSlash = aSubShapeName.rfind('/');
- if (aSlash != std::string::npos) {
+ std::wstring::size_type aSlash = aSubShapeName.rfind(L'/');
+ if (aSlash != std::wstring::npos) {
std::wstring aCompName = aSubShapeName.substr(aSlash + 1);
CompositeFeaturePtr aComposite =
std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aDoc->feature(aCont));
if (allRes.empty())
allRes.push_back(aResult);
+ bool aFoundReferernce = false;
for (std::list<ResultPtr>::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) {
ResultPtr aResCont = *aSub;
ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResCont);
for (; aResIter != aResults.end(); aResIter++) {
if (!aResIter->get() || !(*aResIter)->data()->isValid() || (*aResIter)->isDisabled())
continue;
+ aFoundReferernce = true;
GeomShapePtr aShape = (*aResIter)->shape();
if (aShape.get() && aShape->isSubShape(aSelectedShape, false)) {
aResult = *aResIter; // found new context (produced from this) with same subshape
}
}
}
+ if (aFoundReferernce && !aFindNewContext &&
+ aResult->groupName() != ModelAPI_ResultConstruction::group()) {
+ // #19019 : result is concealed by object that contains no such sub-shape
+ return theCurrent;
+ }
}
// if compsolid is context, try to take sub-solid as context: like in GUI and scripts
ResultBodyPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
}
}
}
- // in case sketch line was selected for wire, but wire was concealed and not such line anymore,
- // so, actually, the sketch element was selected (which is never concealed)
- if (aResult != theCurrent && aResult->isConcealed())
- aResult = theCurrent;
+ // in case sketch line was selected for wire, but wire was concealed and there is no such line
+ // anymore, so, actually, the sketch element was selected (which is never concealed)
+ if (aResult != theCurrent && theCurrent->groupName() == ModelAPI_ResultConstruction::group()) {
+ std::list<FeaturePtr> aConcealers;
+ FeaturePtr aResFeature = aDoc->feature(aResult);
+ FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ concealedFeature(aResFeature, aThisFeature, false, aConcealers, aResult, true);
+ if (aConcealers.size())
+ aResult = theCurrent;
+ }
return aResult;
}