aDocToAdd = this;
}
if (aFeature) {
- aDocToAdd->myObjs->addFeature(aFeature, aDocToAdd->currentFeature(false));
+ // searching for feature after which must be added the next feature: this is the current feature
+ // but also all sub-features of this feature
+ FeaturePtr aCurrent = aDocToAdd->currentFeature(false);
+ bool isModified = true;
+ for(CompositeFeaturePtr aComp = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCurrent);
+ aComp.get() && isModified;
+ aComp = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCurrent)) {
+ isModified = false;
+ int aSubs = aComp->numberOfSubs(false);
+ for(int a = 0; a < aSubs; a++) {
+ FeaturePtr aSub = aComp->subFeature(a, false);
+ if (myObjs->isLater(aSub, aCurrent)) {
+ isModified = true;
+ aCurrent = aSub;
+ }
+ }
+ }
+ aDocToAdd->myObjs->addFeature(aFeature, aCurrent);
if (!aFeature->isAction()) { // do not add action to the data model
if (theMakeCurrent) // after all this feature stays in the document, so make it current
aDocToAdd->setCurrentFeature(aFeature, false);
Handle(TDataStd_ReferenceArray) aRefs;
if (featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
for(int a = aRefs->Lower(); a <= aRefs->Upper(); a++) { // iterate all existing features
- if (aRefs->Value(a).IsEqual(aFeatureLabel)) {
+ TDF_Label aCurLab = aRefs->Value(a);
+ if (aCurLab.IsEqual(aFeatureLabel)) {
a += theReverse ? -1 : 1;
if (a >= aRefs->Lower() && a <= aRefs->Upper())
return feature(aRefs->Value(a));
return FeaturePtr(); // no features at all
}
+bool Model_Objects::isLater(FeaturePtr theLater, FeaturePtr theCurrent) const
+{
+ std::shared_ptr<Model_Data> aLaterD = std::static_pointer_cast<Model_Data>(theLater->data());
+ std::shared_ptr<Model_Data> aCurrentD = std::static_pointer_cast<Model_Data>(theCurrent->data());
+ if (aLaterD && aLaterD->isValid() && aCurrentD && aCurrentD->isValid()) {
+ TDF_Label aLaterL = aLaterD->label().Father();
+ TDF_Label aCurrentL = aCurrentD->label().Father();
+ int aLaterI = -1, aCurentI = -1; // not found yet state
+ Handle(TDataStd_ReferenceArray) aRefs;
+ if (featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
+ for(int a = aRefs->Lower(); a <= aRefs->Upper(); a++) { // iterate all existing features
+ TDF_Label aCurLab = aRefs->Value(a);
+ if (aCurLab.IsEqual(aLaterL)) {
+ aLaterI = a;
+ } else if (aCurLab.IsEqual(aCurrentL)) {
+ aCurentI = a;
+ } else continue;
+ if (aLaterI != -1 && aCurentI != -1) // both are found
+ return aLaterI > aCurentI;
+ }
+ }
+ }
+ return false; // not found, or something is wrong
+}
+
std::list<std::shared_ptr<ModelAPI_Feature> > Model_Objects::allFeatures()
{
std::list<std::shared_ptr<ModelAPI_Feature> > aResult;
FeaturePtr firstFeature();
/// Returns to the last (from the history point of view) feature, any: invisible or disabled
FeaturePtr lastFeature();
+ /// Returns true if theLater is in history of features creation later than theCurrent
+ bool isLater(FeaturePtr theLater, FeaturePtr theCurrent) const;
/// Returns the result group identifier of the given feature (for this at least one result must
/// be created before)