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:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user