Assembly: Use freecad_cast whenever possible
This commit is contained in:
committed by
Benjamin Nauck
parent
0e2fd36551
commit
ff99df4c4d
@@ -205,7 +205,7 @@ void AssemblyLink::synchronizeComponents()
|
||||
for (auto* obj2 : assemblyLinkGroup) {
|
||||
App::DocumentObject* linkedObj;
|
||||
|
||||
auto* subAsmLink = dynamic_cast<AssemblyLink*>(obj2);
|
||||
auto* subAsmLink = freecad_cast<AssemblyLink*>(obj2);
|
||||
auto* link2 = dynamic_cast<App::Link*>(obj2);
|
||||
if (subAsmLink) {
|
||||
linkedObj = subAsmLink->getLinkedObject2(false); // not recursive
|
||||
@@ -279,8 +279,8 @@ void copyPropertyIfDifferent(App::DocumentObject* source,
|
||||
App::DocumentObject* target,
|
||||
const char* propertyName)
|
||||
{
|
||||
auto sourceProp = dynamic_cast<T*>(source->getPropertyByName(propertyName));
|
||||
auto targetProp = dynamic_cast<T*>(target->getPropertyByName(propertyName));
|
||||
auto sourceProp = freecad_cast<T*>(source->getPropertyByName(propertyName));
|
||||
auto targetProp = freecad_cast<T*>(target->getPropertyByName(propertyName));
|
||||
if (sourceProp && targetProp && sourceProp->getValue() != targetProp->getValue()) {
|
||||
targetProp->setValue(sourceProp->getValue());
|
||||
}
|
||||
@@ -501,12 +501,12 @@ JointGroup* AssemblyLink::ensureJointGroup()
|
||||
App::DocumentObject* AssemblyLink::getLinkedObject2(bool recursive) const
|
||||
{
|
||||
auto* obj = LinkedObject.getValue();
|
||||
auto* assembly = dynamic_cast<AssemblyObject*>(obj);
|
||||
auto* assembly = freecad_cast<AssemblyObject*>(obj);
|
||||
if (assembly) {
|
||||
return assembly;
|
||||
}
|
||||
else {
|
||||
auto* assemblyLink = dynamic_cast<AssemblyLink*>(obj);
|
||||
auto* assemblyLink = freecad_cast<AssemblyLink*>(obj);
|
||||
if (assemblyLink) {
|
||||
if (recursive) {
|
||||
return assemblyLink->getLinkedObject2(recursive);
|
||||
@@ -522,14 +522,14 @@ App::DocumentObject* AssemblyLink::getLinkedObject2(bool recursive) const
|
||||
|
||||
AssemblyObject* AssemblyLink::getLinkedAssembly() const
|
||||
{
|
||||
return dynamic_cast<AssemblyObject*>(getLinkedObject2());
|
||||
return freecad_cast<AssemblyObject*>(getLinkedObject2());
|
||||
}
|
||||
|
||||
AssemblyObject* AssemblyLink::getParentAssembly() const
|
||||
{
|
||||
std::vector<App::DocumentObject*> inList = getInList();
|
||||
for (auto* obj : inList) {
|
||||
auto* assembly = dynamic_cast<AssemblyObject*>(obj);
|
||||
auto* assembly = freecad_cast<AssemblyObject*>(obj);
|
||||
if (assembly) {
|
||||
return assembly;
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ T* AssemblyObject::getGroup()
|
||||
}
|
||||
for (auto group : groups) {
|
||||
if (hasObject(group)) {
|
||||
return dynamic_cast<T*>(group);
|
||||
return freecad_cast<T*>(group);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -621,7 +621,7 @@ ViewGroup* AssemblyObject::getExplodedViewGroup() const
|
||||
}
|
||||
for (auto viewGroup : viewGroups) {
|
||||
if (hasObject(viewGroup)) {
|
||||
return dynamic_cast<ViewGroup*>(viewGroup);
|
||||
return freecad_cast<ViewGroup*>(viewGroup);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -1935,7 +1935,7 @@ std::vector<AssemblyLink*> AssemblyObject::getSubAssemblies()
|
||||
doc->getObjectsOfType(Assembly::AssemblyLink::getClassTypeId());
|
||||
for (auto assembly : assemblies) {
|
||||
if (hasObject(assembly)) {
|
||||
subAssemblies.push_back(dynamic_cast<AssemblyLink*>(assembly));
|
||||
subAssemblies.push_back(freecad_cast<AssemblyLink*>(assembly));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ JointGroup* getJointGroup(const App::Part* part)
|
||||
}
|
||||
for (auto jointGroup : jointGroups) {
|
||||
if (part->hasObject(jointGroup)) {
|
||||
return dynamic_cast<JointGroup*>(jointGroup);
|
||||
return freecad_cast<JointGroup*>(jointGroup);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -1064,7 +1064,7 @@ bool ViewProviderAssembly::canDelete(App::DocumentObject* objBeingDeleted) const
|
||||
addSubComponents = [&](AssemblyLink* asmLink, std::vector<App::DocumentObject*>& objs) {
|
||||
std::vector<App::DocumentObject*> assemblyLinkGroup = asmLink->Group.getValues();
|
||||
for (auto* obj : assemblyLinkGroup) {
|
||||
auto* subAsmLink = dynamic_cast<AssemblyLink*>(obj);
|
||||
auto* subAsmLink = freecad_cast<AssemblyLink*>(obj);
|
||||
auto* link = dynamic_cast<App::Link*>(obj);
|
||||
if (subAsmLink || link) {
|
||||
if (std::ranges::find(objs, obj) == objs.end()) {
|
||||
|
||||
@@ -86,7 +86,7 @@ bool ViewProviderAssemblyLink::setEdit(int mode)
|
||||
|
||||
bool ViewProviderAssemblyLink::doubleClicked()
|
||||
{
|
||||
auto* link = dynamic_cast<AssemblyLink*>(getObject());
|
||||
auto* link = freecad_cast<AssemblyLink*>(getObject());
|
||||
|
||||
if (!link) {
|
||||
return true;
|
||||
@@ -94,7 +94,7 @@ bool ViewProviderAssemblyLink::doubleClicked()
|
||||
auto* assembly = link->getLinkedAssembly();
|
||||
|
||||
auto* vpa =
|
||||
dynamic_cast<ViewProviderAssembly*>(Gui::Application::Instance->getViewProvider(assembly));
|
||||
freecad_cast<ViewProviderAssembly*>(Gui::Application::Instance->getViewProvider(assembly));
|
||||
if (!vpa) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user