App: add ScaleVector property to Link

This is a normally hidden property for non-uniform scaling
This commit is contained in:
Zheng, Lei
2019-09-19 11:43:00 +08:00
committed by wmayer
parent c26081f7dc
commit c765ff8fa2
3 changed files with 33 additions and 4 deletions

View File

@@ -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());

View File

@@ -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)\

View File

@@ -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) {