From c765ff8fa2919ae9427ff0843c9476795ac6daec Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Thu, 19 Sep 2019 11:43:00 +0800 Subject: [PATCH] App: add ScaleVector property to Link This is a normally hidden property for non-uniform scaling --- src/App/Link.cpp | 25 +++++++++++++++++++++++++ src/App/Link.h | 4 +++- src/Gui/ViewProviderLink.cpp | 8 +++++--- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/App/Link.cpp b/src/App/Link.cpp index dc1b3a396a..7ce1dac21e 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -777,6 +777,24 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop dst->setValue(src->getValue()); dst->setStatus(Property::User3,false); } + }else if(prop == getScaleProperty()) { + if(!prop->testStatus(Property::User3) && getScaleVectorProperty()) { + auto s = getScaleValue(); + auto p = getScaleVectorProperty(); + p->setStatus(Property::User3,true); + p->setValue(s,s,s); + p->setStatus(Property::User3,false); + } + }else if(prop == getScaleVectorProperty()) { + if(!prop->testStatus(Property::User3) && getScaleProperty()) { + const auto &v = getScaleVectorValue(); + if(v.x == v.y && v.x == v.z) { + auto p = getScaleProperty(); + p->setStatus(Property::User3,true); + p->setValue(v.x); + p->setStatus(Property::User3,false); + } + } }else if(prop == _getShowElementProperty()) { if(_getShowElementValue()) update(parent,_getElementCountProperty()); @@ -1109,6 +1127,13 @@ void LinkBaseExtension::onExtendedDocumentRestored() { xlink->setSubValues(std::move(subs)); } } + if(getScaleVectorProperty() && getScaleProperty()) { + // Scale vector is added later. The code here is for migration. + const auto &v = getScaleVectorValue(); + double s = getScaleValue(); + if(v.x == v.y && v.x == v.z && v.x != s) + getScaleVectorProperty()->setValue(s,s,s); + } update(parent,getVisibilityListProperty()); update(parent,getLinkedObjectProperty()); update(parent,getElementListProperty()); diff --git a/src/App/Link.h b/src/App/Link.h index 95c5bed0e7..3cffb22ed7 100644 --- a/src/App/Link.h +++ b/src/App/Link.h @@ -405,6 +405,7 @@ public: #define LINK_PARAMS_EXT \ LINK_PARAM_EXT(SCALE)\ + LINK_PARAM_EXT_ATYPE(SCALE_VECTOR,App::Prop_Hidden)\ LINK_PARAM_EXT(SCALES)\ LINK_PARAM_EXT(VISIBILITIES)\ LINK_PARAM_EXT(PLACEMENTS)\ @@ -441,7 +442,7 @@ public: LINK_PARAM_EXT(PLACEMENT)\ LINK_PARAM_EXT(SHOW_ELEMENT)\ LINK_PARAM_EXT_TYPE(COUNT,App::PropertyIntegerConstraint)\ - LINK_PARAM_EXT_ATYPE(COLORED_ELEMENTS,App::Prop_Hidden) + LINK_PARAM_EXT_ATYPE(COLORED_ELEMENTS,App::Prop_Hidden)\ LINK_PROPS_DEFINE(LINK_PARAMS_LINK) @@ -476,6 +477,7 @@ public: #define LINK_PARAMS_ELEMENT \ LINK_PARAM_EXT(SCALE)\ + LINK_PARAM_EXT_ATYPE(SCALE_VECTOR,App::Prop_Hidden)\ LINK_PARAM_EXT_TYPE(OBJECT, App::PropertyXLink)\ LINK_PARAM_EXT(TRANSFORM) \ LINK_PARAM_EXT(LINK_PLACEMENT)\ diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index cbd66ef3a9..8fdcfbbaae 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -1808,9 +1808,11 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension *ext, const App: if(!prop->testStatus(App::Property::User3)) applyColors(); }else if(prop==ext->getScaleProperty() || prop==ext->getScaleVectorProperty()) { - const auto &v = ext->getScaleVector(); - pcTransform->scaleFactor.setValue(v.x,v.y,v.z); - linkView->renderDoubleSide(v.x*v.y*v.z < 0); + if(!prop->testStatus(App::Property::User3)) { + const auto &v = ext->getScaleVector(); + pcTransform->scaleFactor.setValue(v.x,v.y,v.z); + linkView->renderDoubleSide(v.x*v.y*v.z < 0); + } }else if(prop == ext->getPlacementProperty() || prop == ext->getLinkPlacementProperty()) { auto propLinkPlacement = ext->getLinkPlacementProperty(); if(!propLinkPlacement || propLinkPlacement == prop) {