[TD]property type changes

This commit is contained in:
wandererfan
2025-07-13 12:00:10 -04:00
parent 566fe8371a
commit df390b0c88
6 changed files with 30 additions and 28 deletions

View File

@@ -482,8 +482,8 @@ bool DrawViewDetail::debugDetail() const
void DrawViewDetail::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop)
{
if (prop == &AnchorPoint) {
// AnchorPoint was PropertyVector but is now PropertyPosition
App::PropertyVector tmp;
// AnchorPoint was PropertyVector, then briefly PropertyPosition, now back to PropertyVector
App::PropertyPosition tmp;
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
tmp.setContainer(this);
tmp.Restore(reader);
@@ -494,7 +494,7 @@ void DrawViewDetail::handleChangedPropertyType(Base::XMLReader &reader, const ch
}
if (prop == &Radius) {
// Radius was PropertyFloat but is now PropertyLength
// Radius was PropertyFloat, then briefly PropertyLength, now back to PropertyFloat
App::PropertyLength tmp;
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
tmp.setContainer(this);

View File

@@ -57,8 +57,8 @@ public:
~DrawViewDetail() override;
App::PropertyLink BaseView;
App::PropertyPosition AnchorPoint;
App::PropertyLength Radius;
App::PropertyVector AnchorPoint;
App::PropertyFloat Radius;
App::PropertyString Reference;
App::PropertyBool ShowMatting;

View File

@@ -1516,8 +1516,8 @@ void DrawViewPart::resetReferenceVerts()
void DrawViewPart::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop)
{
if (prop == &Direction) {
// Direction was PropertyVector but is now PropertyDirection
App::PropertyVector tmp;
// Direction was PropertyVector, then briefly PropertyDirection, now back to PropertyVector
App::PropertyDirection tmp;
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
tmp.setContainer(this);
tmp.Restore(reader);
@@ -1528,8 +1528,8 @@ void DrawViewPart::handleChangedPropertyType(Base::XMLReader &reader, const char
}
if (prop == &XDirection) {
// XDirection was PropertyFloat but is now PropertyLength
App::PropertyVector tmp;
// XDirection was PropertyVector, then briefly PropertyDirection, now back to PropertyVector
App::PropertyDirection tmp;
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
tmp.setContainer(this);
tmp.Restore(reader);

View File

@@ -115,8 +115,8 @@ public:
App::PropertyLinkList Source;
App::PropertyXLinkList XSource;
App::PropertyDirection Direction; // the projection direction
App::PropertyDirection XDirection;
App::PropertyVector Direction; // the projection direction. where you are looking from.
App::PropertyVector XDirection;
App::PropertyBool Perspective;
App::PropertyDistance Focus;

View File

@@ -164,7 +164,7 @@ DrawViewSection::DrawViewSection()
"2D View source for this Section");
BaseView.setScope(App::LinkScope::Global);
// default of (0, -1, 0) matches 'Front' direction in DVP
// default of (0, -1, 0) matches default 'Front' direction in DVP
ADD_PROPERTY_TYPE(SectionNormal,
(0, -1, 0),
sgroup,
@@ -182,6 +182,8 @@ DrawViewSection::DrawViewSection()
sgroup,
App::Prop_None,
"Orientation of this Section in the Base View");
SectionDirection.setStatus(App::Property::Hidden, true);
SectionDirection.setStatus(App::Property::ReadOnly, true);
// properties related to the cut operation
ADD_PROPERTY_TYPE(FuseBeforeCut,
@@ -259,8 +261,6 @@ DrawViewSection::DrawViewSection()
Direction.setStatus(App::Property::ReadOnly, true);
Direction.setValue(SectionNormal.getValue());
SectionDirection.setStatus(App::Property::Hidden, true);
SectionDirection.setStatus(App::Property::ReadOnly, true);
}
DrawViewSection::~DrawViewSection()
@@ -299,8 +299,7 @@ void DrawViewSection::onChanged(const App::Property* prop)
return;
}
if (prop == &SectionNormal ||
prop == &XDirection) {
if (prop == &SectionNormal) {
Direction.setValue(SectionNormal.getValue());
return;
}
@@ -568,7 +567,7 @@ void DrawViewSection::makeSectionCut(const TopoDS_Shape& baseShape)
//! position, scale and rotate shape for buildGeometryObject
//! save the cut shape for further processing
TopoDS_Shape DrawViewSection::prepareShape(const TopoDS_Shape& rawShape, double shapeSize)
TopoDS_Shape DrawViewSection::prepareShape(const TopoDS_Shape& uncenteredCutShape, double shapeSize)
{
(void)shapeSize;// shapeSize is not used in this base class, but is
// interesting for derived classes
@@ -578,11 +577,11 @@ TopoDS_Shape DrawViewSection::prepareShape(const TopoDS_Shape& rawShape, double
Base::Vector3d origin(0.0, 0.0, 0.0);
m_projectionCS = getProjectionCS(origin);
gp_Pnt inputCenter;
inputCenter = ShapeUtils::findCentroid(rawShape, m_projectionCS);
inputCenter = ShapeUtils::findCentroid(uncenteredCutShape, m_projectionCS);
Base::Vector3d centroid(inputCenter.X(), inputCenter.Y(), inputCenter.Z());
m_cutShapeRaw = rawShape;
preparedShape = ShapeUtils::moveShape(rawShape, centroid * -1.0);
m_cutShapeRaw = uncenteredCutShape;
preparedShape = ShapeUtils::moveShape(uncenteredCutShape, centroid * -1.0);
m_cutShape = preparedShape;
m_saveCentroid = centroid;
@@ -1067,7 +1066,7 @@ void DrawViewSection::setCSFromBase(const Base::Vector3d& localUnit)
Base::Vector3d vXDir(newSectionCS.XDirection().X(),
newSectionCS.XDirection().Y(),
newSectionCS.XDirection().Z());
XDirection.setValue(vXDir);// XDir is for projection
XDirection.setValue(vXDir);
}
// reset the section CS based on an XY vector in current section CS
@@ -1230,9 +1229,11 @@ void DrawViewSection::setupObject()
void DrawViewSection::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop)
{
DrawViewPart::handleChangedPropertyType(reader, TypeName, prop);
if (prop == &SectionOrigin) {
// SectionOrigin was PropertyVector but is now PropertyPosition
App::PropertyVector tmp;
// SectionOrigin was PropertyVector then briefly PropertyPosition, now back to PropertyVector
App::PropertyPosition tmp;
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
tmp.setContainer(this);
tmp.Restore(reader);
@@ -1243,13 +1244,14 @@ void DrawViewSection::handleChangedPropertyType(Base::XMLReader &reader, const c
}
if (prop == &SectionNormal) {
// Radius was PropertyVector but is now PropertyDirection
App::PropertyVector tmp;
// Radius was PropertyVector, then briefly PropertyDirection, then PropertyVector
App::PropertyDirection tmp;
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
tmp.setContainer(this);
tmp.Restore(reader);
auto tmpValue = tmp.getValue();
SectionNormal.setValue(tmpValue);
Direction.setValue(tmpValue);
}
return;
}

View File

@@ -87,8 +87,8 @@ public:
//NOLINTBEGIN
App::PropertyLink BaseView;
App::PropertyDirection SectionNormal;
App::PropertyPosition SectionOrigin;
App::PropertyVector SectionNormal;
App::PropertyVector SectionOrigin;
App::PropertyString SectionSymbol;
@@ -196,7 +196,7 @@ protected:
bool trimAfterCut() const;
TopoDS_Shape m_cutShape; // centered, scaled, rotated result of cut
TopoDS_Shape m_cutShapeRaw; // raw result of cut w/o center/scale/rotate
TopoDS_Shape m_cutShapeRaw; // copy of input to prepare shape
void onDocumentRestored() override;
void setupObject() override;