}
}
+void Model_AttributeRefList::exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2)
+{
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
+ owner()->document());
+ if (aDoc) {
+ std::shared_ptr<Model_Data> aData1 = std::dynamic_pointer_cast<Model_Data>(theObject1->data());
+ if (aData1.get() && aData1->isValid()) {
+ TDF_Label aLab1 = aData1->label().Father();
+ if (theObject2.get() && theObject2->data()->isValid()) { // the new may be null
+ std::shared_ptr<Model_Data> aData2 =
+ std::dynamic_pointer_cast<Model_Data>(theObject2->data());
+ if (aData2.get() && aData2->isValid()) {
+ TDF_Label aLab2 = aData2->label().Father();
+ // do the substitution: use the temporary label, as usually in exchange
+ TDF_Label aTmpLab = aLab1.Root();
+ if (myRef->InsertAfter(aTmpLab, aLab1)) {
+ myRef->Remove(aLab1);
+ }
+ if (myRef->InsertAfter(aLab1, aLab2)) {
+ myRef->Remove(aLab2);
+ }
+ if (myRef->InsertAfter(aLab2, aTmpLab)) {
+ myRef->Remove(aTmpLab);
+ }
+ owner()->data()->sendAttributeUpdated(this);
+ }
+ }
+ }
+ }
+}
+
void Model_AttributeRefList::removeLast()
{
std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
/// Substitutes the feature by another one. Does nothing if such object is not found.
MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew);
+ /// Substitutes the object by another one and back. So, features wil become exchanged in the list
+ MODEL_EXPORT virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2);
+
/// Removes the last element in the list.
MODEL_EXPORT virtual void removeLast();
///\param theWithEmpty if it is false, counts the not-empty referenced objects only
virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const = 0;
- /// Substitutes the feature by another one. Does nothing if such object is not found.
+ /// Substitutes the object by another one. Does nothing if such object is not found.
virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew) = 0;
+ /// Substitutes the object by another one and back. So, features wil become exchanged in the list
+ virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2) = 0;
+
/// Removes the last element in the list.
virtual void removeLast() = 0;
{
}
+
+void ModelAPI_CompositeFeature::exchangeIDs(
+ std::shared_ptr<ModelAPI_Feature> theFeature1, std::shared_ptr<ModelAPI_Feature> theFeature2)
+{
+ // by default nothing is in the implementation
+}
/// This method to inform that sub-feature is removed and must be removed from the internal data
/// structures of the owner (the remove from the document will be done outside just after)
virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+
+ /// Exchanges IDs of two given features: needed for more correct naming in some cases (issue 769)
+ MODELAPI_EXPORT virtual void exchangeIDs(std::shared_ptr<ModelAPI_Feature> theFeature1,
+ std::shared_ptr<ModelAPI_Feature> theFeature2);
};
//! Pointer on the composite feature object
// Create Preview
std::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
std::shared_ptr<GeomAPI_Dir> aYZDir(new GeomAPI_Dir(1, 0, 0));
+ // -1, not 1 for correct internal sketch coords (issue 898)
std::shared_ptr<GeomAPI_Dir> aXZDir(new GeomAPI_Dir(0, -1, 0));
std::shared_ptr<GeomAPI_Dir> aXYDir(new GeomAPI_Dir(0, 0, 1));
myBaseObjects.clear();
myBaseObjects.push_back(aFeatureA);
myBaseObjects.push_back(aFeatureB);
+ // exchange the naming IDs of newly created and old line that become auxiliary
+ sketch()->exchangeIDs(aFeatureA, aNewFeatureA);
+ sketch()->exchangeIDs(aFeatureB, aNewFeatureB);
} else {
// Update radius value
int aNbSubs = sketch()->numberOfSubs();
return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir()));
}
+
+void SketchPlugin_Sketch::exchangeIDs(
+ std::shared_ptr<ModelAPI_Feature> theFeature1, std::shared_ptr<ModelAPI_Feature> theFeature2)
+{
+ reflist(SketchPlugin_Sketch::FEATURES_ID())->exchange(theFeature1, theFeature2);
+}
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+ /// Exchanges IDs of two given features: needed for fillet feature better naming (issue 769)
+ SKETCHPLUGIN_EXPORT virtual void exchangeIDs(std::shared_ptr<ModelAPI_Feature> theFeature1,
+ std::shared_ptr<ModelAPI_Feature> theFeature2);
+
+
/// \brief Create a result for the point in the attribute if the attribute is initialized
/// \param theAttributeID an attribute string
/// \param theIndex an index of the result