Core: Add App::LocalCoordinateSystem.
Most of App::Origin is moved into this sub class of App::Origin. Add App::Point. Change graphics of the planes/axis. Remove scale-by-content behavior and make it fixed size on screen.
This commit is contained in:
@@ -121,7 +121,8 @@ App::DocumentObject* OriginGroupExtension::getGroupOfObject(const DocumentObject
|
||||
if (o->hasExtension(App::OriginGroupExtension::getExtensionClassTypeId())) {
|
||||
return o;
|
||||
}
|
||||
else if (isOriginFeature && o->isDerivedFrom(App::Origin::getClassTypeId())) {
|
||||
else if (isOriginFeature
|
||||
&& o->isDerivedFrom(App::LocalCoordinateSystem::getClassTypeId())) {
|
||||
auto result = getGroupOfObject(o);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -221,16 +222,24 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
|
||||
std::vector<App::DocumentObject*> result;
|
||||
std::vector<App::Property*> list;
|
||||
obj->getPropertyList(list);
|
||||
auto isOriginFeature = [](App::DocumentObject* obj) -> bool {
|
||||
// Check if the object is a DatumElement
|
||||
if (auto* datumElement = dynamic_cast<App::DatumElement*>(obj)) {
|
||||
// Check if the DatumElement is an origin
|
||||
return datumElement->isOriginFeature();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
for (App::Property* prop : list) {
|
||||
if (prop->isDerivedFrom<App::PropertyLink>()) {
|
||||
|
||||
auto p = static_cast<App::PropertyLink*>(prop);
|
||||
if (!p->getValue()
|
||||
|| !p->getValue()->isDerivedFrom(App::DatumElement::getClassTypeId())) {
|
||||
if (!p->getValue() || !isOriginFeature(p->getValue())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
p->setValue(getOrigin()->getOriginFeature(
|
||||
p->setValue(getOrigin()->getDatumElement(
|
||||
static_cast<DatumElement*>(p->getValue())->Role.getValue()));
|
||||
}
|
||||
else if (prop->isDerivedFrom<App::PropertyLinkList>()) {
|
||||
@@ -239,11 +248,11 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
|
||||
std::vector<App::DocumentObject*> result;
|
||||
bool changed = false;
|
||||
for (App::DocumentObject* o : vec) {
|
||||
if (!o || !o->isDerivedFrom(App::DatumElement::getClassTypeId())) {
|
||||
if (!isOriginFeature(o)) {
|
||||
result.push_back(o);
|
||||
}
|
||||
else {
|
||||
result.push_back(getOrigin()->getOriginFeature(
|
||||
result.push_back(getOrigin()->getDatumElement(
|
||||
static_cast<DatumElement*>(o)->Role.getValue()));
|
||||
changed = true;
|
||||
}
|
||||
@@ -254,13 +263,12 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
|
||||
}
|
||||
else if (prop->isDerivedFrom<App::PropertyLinkSub>()) {
|
||||
auto p = static_cast<App::PropertyLinkSub*>(prop);
|
||||
if (!p->getValue()
|
||||
|| !p->getValue()->isDerivedFrom(App::DatumElement::getClassTypeId())) {
|
||||
if (!p->getValue() || !isOriginFeature(p->getValue())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<std::string> subValues = p->getSubValues();
|
||||
p->setValue(getOrigin()->getOriginFeature(
|
||||
p->setValue(getOrigin()->getDatumElement(
|
||||
static_cast<DatumElement*>(p->getValue())->Role.getValue()),
|
||||
subValues);
|
||||
}
|
||||
@@ -269,8 +277,8 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
|
||||
auto vec = p->getSubListValues();
|
||||
bool changed = false;
|
||||
for (auto& v : vec) {
|
||||
if (v.first && v.first->isDerivedFrom(App::DatumElement::getClassTypeId())) {
|
||||
v.first = getOrigin()->getOriginFeature(
|
||||
if (isOriginFeature(v.first)) {
|
||||
v.first = getOrigin()->getDatumElement(
|
||||
static_cast<DatumElement*>(v.first)->Role.getValue());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user