PartDesign: Chamfer - migrate Size and Size2 for older files (#26137)

* PartDesign: Chamfer - migrate Size and Size2 for older files

* Apply suggestions from code review

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
Kacper Donat
2025-12-22 12:52:55 +01:00
committed by GitHub
parent 310419d45e
commit ffd4487f6d
2 changed files with 30 additions and 0 deletions

View File

@@ -41,6 +41,8 @@
#include "FeatureChamfer.h"
#include <Base/ProgramVersion.h>
using namespace PartDesign;
@@ -205,6 +207,8 @@ App::DocumentObjectExecReturn* Chamfer::execute()
void Chamfer::Restore(Base::XMLReader& reader)
{
DressUp::Restore(reader);
migrateFlippedProperties(reader);
}
void Chamfer::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, App::Property* prop)
@@ -220,6 +224,29 @@ void Chamfer::handleChangedPropertyType(Base::XMLReader& reader, const char* Typ
}
}
bool Chamfer::requiresSizeSwapping(const Base::XMLReader& reader) const
{
return Base::getVersion(reader.ProgramVersion) < Base::Version::v1_0
&& (ChamferType.getValue() == 1 || ChamferType.getValue() == 2);
}
void Chamfer::migrateFlippedProperties(const Base::XMLReader& reader)
{
if (!requiresSizeSwapping(reader)) {
return;
}
Base::Console().warning(
"The 'FlipDirection' property of the chamfer of %s is being adjusted to maintain"
"the same geometry in this FreeCAD version. If the re-saved file is later opened "
"in FreeCAD 0.21.x the chamfer result may differ due to the changed parameter "
"interpretation.\n",
getFullName()
);
FlipDirection.setValue(!FlipDirection.getValue());
}
void Chamfer::onChanged(const App::Property* prop)
{
if (prop == &ChamferType) {

View File

@@ -70,6 +70,9 @@ protected:
) override;
static const App::PropertyQuantityConstraint::Constraints floatSize;
static const App::PropertyAngle::Constraints floatAngle;
bool requiresSizeSwapping(const Base::XMLReader& reader) const;
void migrateFlippedProperties(const Base::XMLReader& reader);
};
} // namespace PartDesign