From b300c80b905ff5d55a5fc0ef1e961bf9774b97af Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Fri, 11 Apr 2025 16:11:33 +0200 Subject: [PATCH] Base: Use explicit pointer syntax for freecad_cast (#20694) * Base: Use explicit pointer syntax for freecad_cast This aligns our custom cast with other casts * All: Use explicit pointer syntax for freecad_cast --- src/App/Document.cpp | 8 +-- src/App/DocumentObject.cpp | 8 +-- src/App/DocumentObserver.h | 6 +-- src/App/Expression.cpp | 34 ++++++------ src/App/Expression.h | 2 +- src/App/GeoFeature.cpp | 4 +- src/App/GeoFeatureGroupExtension.cpp | 2 +- src/App/GroupExtension.cpp | 2 +- src/App/Link.cpp | 38 +++++++------- src/App/ObjectIdentifier.cpp | 12 ++--- src/App/PropertyContainerPyImp.cpp | 4 +- src/App/PropertyExpressionEngine.cpp | 10 ++-- src/App/PropertyGeo.cpp | 6 +-- src/App/PropertyLinks.cpp | 24 ++++----- src/Base/BaseClass.h | 30 +++++------ src/Gui/Application.cpp | 4 +- src/Gui/CommandLink.cpp | 6 +-- src/Gui/DAGView/DAGModel.cpp | 2 +- src/Gui/DemoMode.cpp | 2 +- src/Gui/Dialogs/DlgAddProperty.cpp | 6 +-- src/Gui/Dialogs/DlgExpressionInput.cpp | 4 +- src/Gui/Dialogs/DlgObjectSelection.cpp | 2 +- src/Gui/Dialogs/DlgPropertyLink.cpp | 8 +-- src/Gui/Document.cpp | 2 +- src/Gui/DocumentObserver.h | 4 +- src/Gui/InputField.cpp | 4 +- src/Gui/QuantitySpinBox.cpp | 2 +- src/Gui/SpinBox.cpp | 4 +- src/Gui/Tree.cpp | 16 +++--- src/Gui/ViewProviderDocumentObject.cpp | 6 +-- src/Gui/ViewProviderLink.cpp | 32 ++++++------ src/Gui/propertyeditor/PropertyEditor.cpp | 4 +- src/Gui/propertyeditor/PropertyItem.cpp | 6 +-- src/Mod/CAM/Gui/ViewProviderPath.cpp | 2 +- .../Drawing/App/FeatureViewSpreadsheet.cpp | 6 +-- src/Mod/Fem/App/FemPostFilter.cpp | 4 +- src/Mod/Fem/App/FemPostPipeline.cpp | 2 +- src/Mod/Fem/Gui/TaskPostBoxes.h | 4 +- .../Fem/Gui/ViewProviderFemPostPipeline.cpp | 4 +- src/Mod/Import/App/ImportOCAF2.cpp | 2 +- src/Mod/Measure/Gui/TaskMeasure.cpp | 2 +- .../Gui/ViewProviderMeasureDistance.cpp | 8 +-- src/Mod/Mesh/Gui/ViewProvider.cpp | 14 ++--- src/Mod/MeshPart/Gui/Tessellation.cpp | 4 +- src/Mod/Part/App/AttachExtension.cpp | 4 +- src/Mod/Part/App/Geometry.cpp | 6 +-- src/Mod/Part/App/PartFeature.cpp | 4 +- src/Mod/Part/App/PropertyGeometryList.cpp | 4 +- src/Mod/Part/App/PropertyTopoShape.cpp | 12 ++--- src/Mod/Part/Gui/CommandSimple.cpp | 4 +- src/Mod/PartDesign/App/Body.cpp | 2 +- src/Mod/PartDesign/App/Feature.cpp | 2 +- src/Mod/PartDesign/App/FeatureDressUp.cpp | 2 +- .../PartDesign/App/FeatureMultiTransform.cpp | 6 +-- src/Mod/PartDesign/App/FeatureScaled.cpp | 2 +- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 2 +- src/Mod/PartDesign/App/FeatureTransformed.cpp | 20 +++---- src/Mod/PartDesign/App/ShapeBinder.cpp | 2 +- src/Mod/PartDesign/Gui/Command.cpp | 4 +- src/Mod/PartDesign/Gui/TaskFeaturePick.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProvider.cpp | 2 +- .../Gui/ViewProviderShapeBinder.cpp | 2 +- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- src/Mod/Spreadsheet/App/Cell.cpp | 27 +++++----- src/Mod/Spreadsheet/App/PropertySheet.cpp | 10 ++-- src/Mod/Spreadsheet/App/Sheet.cpp | 30 +++++------ src/Mod/Spreadsheet/Gui/Command.cpp | 52 +++++++++---------- src/Mod/Spreadsheet/Gui/DlgBindSheet.cpp | 4 +- src/Mod/Spreadsheet/Gui/DlgSheetConf.cpp | 8 +-- .../Gui/ViewProviderSpreadsheet.cpp | 2 +- src/Mod/Spreadsheet/Gui/Workbench.cpp | 4 +- src/Mod/TechDraw/Gui/QGSPage.cpp | 30 +++++------ src/Tools/params_utils.py | 2 +- 73 files changed, 305 insertions(+), 304 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index ae3da65da5..56f3421805 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -1630,9 +1630,9 @@ std::vector Document::importObjects(Base::XMLReader& reade o->setStatus(App::ObjImporting, true); FC_LOG("importing " << o->getFullName()); if (auto propUUID = - freecad_cast(o->getPropertyByName("_ObjectUUID"))) { + freecad_cast(o->getPropertyByName("_ObjectUUID"))) { auto propSource = - freecad_cast(o->getPropertyByName("_SourceUUID")); + freecad_cast(o->getPropertyByName("_SourceUUID")); if (!propSource) { propSource = static_cast( o->addDynamicProperty("App::PropertyUUID", @@ -2439,7 +2439,7 @@ bool Document::afterRestore(const std::vector& objArray, bool c // refresh properties in case the object changes its property list obj->getPropertyList(props); for (auto prop : props) { - auto link = freecad_cast(prop); + auto link = freecad_cast(prop); int res; std::string errMsg; if (link && (res = link->checkRestore(&errMsg))) { @@ -3987,7 +3987,7 @@ Document::importLinks(const std::vector& objArray) propList.clear(); obj->getPropertyList(propList); for (auto prop : propList) { - auto linkProp = freecad_cast(prop); + auto linkProp = freecad_cast(prop); if (linkProp && !prop->testStatus(Property::Immutable) && !obj->isReadOnly(prop)) { auto copy = linkProp->CopyOnImportExternal(nameMap); if (copy) { diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index f513648573..295d491831 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -949,7 +949,7 @@ DocumentObject* DocumentObject::getSubObject(const char* subname, // objects (think of the claimed children of a Fusion). But I do think we // should change that. if (transform && mat) { - auto pla = freecad_cast(getPropertyByName("Placement")); + auto pla = freecad_cast(getPropertyByName("Placement")); if (pla) { *mat *= pla->getValue().toMatrix(); } @@ -1476,7 +1476,7 @@ bool DocumentObject::adjustRelativeLinks(const std::set& i std::vector props; getPropertyList(props); for (auto prop : props) { - auto linkProp = freecad_cast(prop); + auto linkProp = freecad_cast(prop); if (linkProp && linkProp->adjustLink(inList)) { touched = true; } @@ -1495,7 +1495,7 @@ bool DocumentObject::adjustRelativeLinks(const std::set& i std::string DocumentObject::getElementMapVersion(const App::Property* _prop, bool restored) const { - auto prop = freecad_cast(_prop); + auto prop = freecad_cast(_prop); if (!prop) { return std::string(); } @@ -1504,7 +1504,7 @@ std::string DocumentObject::getElementMapVersion(const App::Property* _prop, boo bool DocumentObject::checkElementMapVersion(const App::Property* _prop, const char* ver) const { - auto prop = freecad_cast(_prop); + auto prop = freecad_cast(_prop); if (!prop) { return false; } diff --git a/src/App/DocumentObserver.h b/src/App/DocumentObserver.h index 6933d3cc64..a93d1dc578 100644 --- a/src/App/DocumentObserver.h +++ b/src/App/DocumentObserver.h @@ -148,12 +148,12 @@ public: template inline T* getObjectAs() const { - return freecad_cast(getObject()); + return freecad_cast(getObject()); } template inline T* getPropertyAs() const { - return freecad_cast(getProperty()); + return freecad_cast(getProperty()); } private: @@ -409,7 +409,7 @@ public: template inline T* get() const noexcept { - return freecad_cast(_get()); + return freecad_cast(_get()); } private: diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index d825d2d81a..9e691c0f16 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -1478,7 +1478,7 @@ Expression *OperatorExpression::simplify() const Expression * v2 = right->simplify(); // Both arguments reduced to numerics? Then evaluate and return answer - if (freecad_cast(v1) && freecad_cast(v2)) { + if (freecad_cast(v1) && freecad_cast(v2)) { delete v1; delete v2; return eval(); @@ -1499,7 +1499,7 @@ void OperatorExpression::_toString(std::ostream &s, bool persistent,int) const Operator leftOperator(NONE), rightOperator(NONE); needsParens = false; - if (freecad_cast(left)) + if (freecad_cast(left)) leftOperator = static_cast(left)->op; if (left->priority() < priority()) // Check on operator priority first needsParens = true; @@ -1571,7 +1571,7 @@ void OperatorExpression::_toString(std::ostream &s, bool persistent,int) const } needsParens = false; - if (freecad_cast(right)) + if (freecad_cast(right)) rightOperator = static_cast(right)->op; if (right->priority() < priority()) // Check on operator priority first needsParens = true; @@ -2012,11 +2012,11 @@ Py::Object FunctionExpression::evalAggregate( if (!p) continue; - if ((qp = freecad_cast(p))) + if ((qp = freecad_cast(p))) c->collect(qp->getQuantityValue()); - else if ((fp = freecad_cast(p))) + else if ((fp = freecad_cast(p))) c->collect(Quantity(fp->getValue())); - else if ((ip = freecad_cast(p))) + else if ((ip = freecad_cast(p))) c->collect(Quantity(ip->getValue())); else _EXPR_THROW("Invalid property type for aggregate.", owner); @@ -2614,7 +2614,7 @@ Expression *FunctionExpression::simplify() const for (auto it : args) { Expression * v = it->simplify(); - if (freecad_cast(v)) + if (freecad_cast(v)) ++numerics; a.push_back(v); } @@ -2869,16 +2869,16 @@ void VariableExpression::addComponent(Component *c) { } long l1=0,l2=0,l3=1; if(c->e3) { - auto n3 = freecad_cast(c->e3); + auto n3 = freecad_cast(c->e3); if(!n3 || !essentiallyEqual(n3->getValue(),(double)l3)) break; } if(c->e1) { - auto n1 = freecad_cast(c->e1); + auto n1 = freecad_cast(c->e1); if(!n1) { if(c->e2 || c->e3) break; - auto s = freecad_cast(c->e1); + auto s = freecad_cast(c->e1); if(!s) break; var << ObjectIdentifier::MapComponent( @@ -2895,7 +2895,7 @@ void VariableExpression::addComponent(Component *c) { return; } } - auto n2 = freecad_cast(c->e2); + auto n2 = freecad_cast(c->e2); if(n2 && essentiallyInteger(n2->getValue(),l2)) { var << ObjectIdentifier::RangeComponent(l1,l2,l3); return; @@ -3195,7 +3195,7 @@ Py::Object ConditionalExpression::_getPyValue() const { Expression *ConditionalExpression::simplify() const { std::unique_ptr e(condition->simplify()); - NumberExpression * v = freecad_cast(e.get()); + NumberExpression * v = freecad_cast(e.get()); if (!v) return new ConditionalExpression(owner, condition->simplify(), trueExpr->simplify(), falseExpr->simplify()); @@ -3752,11 +3752,11 @@ UnitExpression * ExpressionParser::parseUnit(const App::DocumentObject *owner, c Expression * simplified = ScanResult->simplify(); if (!unitExpression) { - OperatorExpression * fraction = freecad_cast(ScanResult); + OperatorExpression * fraction = freecad_cast(ScanResult); if (fraction && fraction->getOperator() == OperatorExpression::DIV) { - NumberExpression * nom = freecad_cast(fraction->getLeft()); - UnitExpression * denom = freecad_cast(fraction->getRight()); + NumberExpression * nom = freecad_cast(fraction->getLeft()); + UnitExpression * denom = freecad_cast(fraction->getRight()); // If not initially a unit expression, but value is equal to 1, it means the expression is something like 1/unit if (denom && nom && essentiallyEqual(nom->getValue(), 1.0)) @@ -3766,13 +3766,13 @@ UnitExpression * ExpressionParser::parseUnit(const App::DocumentObject *owner, c delete ScanResult; if (unitExpression) { - NumberExpression * num = freecad_cast(simplified); + NumberExpression * num = freecad_cast(simplified); if (num) { simplified = new UnitExpression(num->getOwner(), num->getQuantity()); delete num; } - return freecad_cast(simplified); + return freecad_cast(simplified); } else { delete simplified; diff --git a/src/App/Expression.h b/src/App/Expression.h index a7971ba1f3..ed5ae74579 100644 --- a/src/App/Expression.h +++ b/src/App/Expression.h @@ -84,7 +84,7 @@ template class ExpressionModifier : public ExpressionVisitor { public: explicit ExpressionModifier(P & _prop) : prop(_prop) - , propLink(freecad_cast(&prop)) + , propLink(freecad_cast(&prop)) , signaller(_prop,false) {} diff --git a/src/App/GeoFeature.cpp b/src/App/GeoFeature.cpp index d94d9f1835..298d0cdb96 100644 --- a/src/App/GeoFeature.cpp +++ b/src/App/GeoFeature.cpp @@ -160,11 +160,11 @@ DocumentObject* GeoFeature::resolveElement(const DocumentObject* obj, return nullptr; } auto linked = sobj->getLinkedObject(true); - auto geo = freecad_cast(linked); + auto geo = freecad_cast(linked); if (!geo && linked) { auto ext = linked->getExtensionByType(true); if (ext) { - geo = freecad_cast(ext->getTrueLinkedObject(true)); + geo = freecad_cast(ext->getTrueLinkedObject(true)); } } if (geoFeature) { diff --git a/src/App/GeoFeatureGroupExtension.cpp b/src/App/GeoFeatureGroupExtension.cpp index 91571feb74..2828430ff4 100644 --- a/src/App/GeoFeatureGroupExtension.cpp +++ b/src/App/GeoFeatureGroupExtension.cpp @@ -285,7 +285,7 @@ std::vector GeoFeatureGroupExtension::getScopedObjectsFromLink( } std::vector result; - auto link = freecad_cast(prop); + auto link = freecad_cast(prop); if (link && link->getScope() == scope) { link->getLinks(result); } diff --git a/src/App/GroupExtension.cpp b/src/App/GroupExtension.cpp index 64405714fd..3eccb53232 100644 --- a/src/App/GroupExtension.cpp +++ b/src/App/GroupExtension.cpp @@ -414,7 +414,7 @@ bool GroupExtension::extensionGetSubObject(DocumentObject*& ret, { const char* dot; if (!subname || *subname == 0) { - auto obj = freecad_cast(getExtendedContainer()); + auto obj = freecad_cast(getExtendedContainer()); ret = const_cast(obj); return true; } diff --git a/src/App/Link.cpp b/src/App/Link.cpp index e9dc78fb99..36506e8259 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -286,7 +286,7 @@ void LinkBaseExtension::setProperty(int idx, Property* prop) } case PropLinkCopyOnChangeSource: case PropLinkCopyOnChangeGroup: - if (auto linkProp = freecad_cast(prop)) { + if (auto linkProp = freecad_cast(prop)) { linkProp->setScope(LinkScope::Global); } // fall through @@ -356,7 +356,7 @@ App::DocumentObjectExecReturn* LinkBaseExtension::extensionExecute() if (!linked) { std::ostringstream ss; ss << "Link broken!"; - auto xlink = freecad_cast(getLinkedObjectProperty()); + auto xlink = freecad_cast(getLinkedObjectProperty()); if (xlink) { const char* objname = xlink->getObjectName(); if (!Base::Tools::isNullOrEmpty(objname)) { @@ -389,7 +389,7 @@ App::DocumentObjectExecReturn* LinkBaseExtension::extensionExecute() || !container->getDocument()->getObjectByID(_LinkOwner.getValue()))) { // Check if this is an element link. Do not invoke appLinkExecute() // if so, because it will be called from the link array. - proxy = freecad_cast( + proxy = freecad_cast( linked->getPropertyByName("Proxy")); } if (proxy) { @@ -491,7 +491,7 @@ LinkBaseExtension::getOnChangeCopyObjects(std::vector* exc continue; } auto prop = - freecad_cast(obj->getPropertyByName("_CopyOnChangeControl")); + freecad_cast(obj->getPropertyByName("_CopyOnChangeControl")); static std::map dummy; const auto& map = prop && prop->getContainer() == obj ? prop->getValues() : dummy; const char* v = ""; @@ -526,7 +526,7 @@ void LinkBaseExtension::setOnChangeCopyObject(App::DocumentObject* obj, OnChange bool exclude = flags.testFlag(OnChangeCopyOptions::Exclude); bool external = parent->getDocument() != obj->getDocument(); auto prop = - freecad_cast(obj->getPropertyByName("_CopyOnChangeControl")); + freecad_cast(obj->getPropertyByName("_CopyOnChangeControl")); if (external == exclude && !prop) { return; @@ -583,7 +583,7 @@ void LinkBaseExtension::syncCopyOnChange() // dependencies. LinkGroup* copyOnChangeGroup = nullptr; if (auto prop = getLinkCopyOnChangeGroupProperty()) { - copyOnChangeGroup = freecad_cast(prop->getValue()); + copyOnChangeGroup = freecad_cast(prop->getValue()); if (!copyOnChangeGroup) { // Create the LinkGroup if not exist auto group = new LinkGroup; @@ -601,7 +601,7 @@ void LinkBaseExtension::syncCopyOnChange() continue; } auto prop = - freecad_cast(obj->getPropertyByName("_SourceUUID")); + freecad_cast(obj->getPropertyByName("_SourceUUID")); if (prop && prop->getContainer() == obj) { oldObjs.emplace_back(prop); } @@ -665,7 +665,7 @@ void LinkBaseExtension::syncCopyOnChange() std::map newObjs; for (auto obj : copiedObjs) { - auto prop = freecad_cast(obj->getPropertyByName("_SourceUUID")); + auto prop = freecad_cast(obj->getPropertyByName("_SourceUUID")); if (prop) { newObjs.insert(std::make_pair(prop->getValue(), obj)); } @@ -673,7 +673,7 @@ void LinkBaseExtension::syncCopyOnChange() std::vector> replacements; for (const auto& objT : oldObjs) { - auto prop = freecad_cast(objT.getProperty()); + auto prop = freecad_cast(objT.getProperty()); if (!prop) { continue; } @@ -707,7 +707,7 @@ void LinkBaseExtension::syncCopyOnChange() if (prop->getContainer() != o) { continue; } - auto linkProp = freecad_cast(prop); + auto linkProp = freecad_cast(prop); if (!linkProp) { continue; } @@ -1739,7 +1739,7 @@ void LinkBaseExtension::parseSubName() const bool hasSubElement = !mySubElements.empty(); mySubElements.clear(); mySubName.clear(); - auto xlink = freecad_cast(getLinkedObjectProperty()); + auto xlink = freecad_cast(getLinkedObjectProperty()); if (!xlink || xlink->getSubValues().empty()) { if (hasSubElement) { mySubElements.emplace_back(""); @@ -1896,7 +1896,7 @@ void LinkBaseExtension::update(App::DocumentObject* parent, const Property* prop std::vector scales; scales.reserve(objs.size()); for (auto obj : objs) { - auto element = freecad_cast(obj); + auto element = freecad_cast(obj); if (element) { placements.push_back(element->Placement.getValue()); scales.push_back(element->getScaleVector()); @@ -1990,7 +1990,7 @@ void LinkBaseExtension::update(App::DocumentObject* parent, const Property* prop // It is possible to have orphan LinkElement here due to, // for example, undo and redo. So we try to re-claim the // children element first. - auto obj = freecad_cast(doc->getObject(name.c_str())); + auto obj = freecad_cast(doc->getObject(name.c_str())); if (obj && (!obj->_LinkOwner.getValue() || obj->_LinkOwner.getValue() == ownerID)) { obj->Visibility.setValue(false); @@ -2034,7 +2034,7 @@ void LinkBaseExtension::update(App::DocumentObject* parent, const Property* prop auto owner = getContainer(); long ownerID = owner ? owner->getID() : 0; while (objs.size() > elementCount) { - auto element = freecad_cast(objs.back()); + auto element = freecad_cast(objs.back()); if (element && element->_LinkOwner.getValue() == ownerID) { tmpObjs.push_back(objs.back()); } @@ -2201,13 +2201,13 @@ void LinkBaseExtension::syncElementList() { auto transform = getLinkTransformProperty(); auto link = getLinkedObjectProperty(); - auto xlink = freecad_cast(link); + auto xlink = freecad_cast(link); auto owner = getContainer(); auto ownerID = owner ? owner->getID() : 0; auto elements = getElementListValue(); for (auto i : elements) { - auto element = freecad_cast(i); + auto element = freecad_cast(i); if (!element || (element->_LinkOwner.getValue() && element->_LinkOwner.getValue() != ownerID)) { continue; @@ -2251,7 +2251,7 @@ void LinkBaseExtension::onExtendedDocumentRestored() hasOldSubElement = false; // SubElements was stored as a PropertyStringList. It is now migrated to be // stored inside PropertyXLink. - auto xlink = freecad_cast(getLinkedObjectProperty()); + auto xlink = freecad_cast(getLinkedObjectProperty()); if (!xlink) { FC_ERR("Failed to restore SubElements for " << parent->getFullName()); } @@ -2393,7 +2393,7 @@ void LinkBaseExtension::setLink(int index, link->Label.setValue(linked->Label.getValue()); } auto pla = - freecad_cast(obj->getPropertyByName("Placement")); + freecad_cast(obj->getPropertyByName("Placement")); if (pla) { link->Placement.setValue(pla->getValue()); } @@ -2424,7 +2424,7 @@ void LinkBaseExtension::setLink(int index, // Here means we are assigning a Link - auto xlink = freecad_cast(linkProp); + auto xlink = freecad_cast(linkProp); if (obj) { if (!obj->isAttachedToDocument()) { LINK_THROW(Base::ValueError, "Invalid document object"); diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index 1d9b1e3988..8dc4797ed4 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -119,7 +119,7 @@ ObjectIdentifier::ObjectIdentifier(const App::PropertyContainer* _owner, , _hash(0) { if (_owner) { - const DocumentObject* docObj = freecad_cast(_owner); + const DocumentObject* docObj = freecad_cast(_owner); if (!docObj) { FC_THROWM(Base::RuntimeError, "Property must be owned by a document object."); } @@ -145,7 +145,7 @@ ObjectIdentifier::ObjectIdentifier(const App::PropertyContainer* _owner, bool lo , _hash(0) { if (_owner) { - const DocumentObject* docObj = freecad_cast(_owner); + const DocumentObject* docObj = freecad_cast(_owner); if (!docObj) { FC_THROWM(Base::RuntimeError, "Property must be owned by a document object."); } @@ -166,7 +166,7 @@ ObjectIdentifier::ObjectIdentifier(const Property& prop, int index) , localProperty(false) , _hash(0) { - DocumentObject* docObj = freecad_cast(prop.getContainer()); + DocumentObject* docObj = freecad_cast(prop.getContainer()); if (!docObj) { FC_THROWM(Base::TypeError, "Property must be owned by a document object."); @@ -1364,7 +1364,7 @@ ObjectIdentifier ObjectIdentifier::relativeTo(const ObjectIdentifier& other) con ObjectIdentifier ObjectIdentifier::parse(const DocumentObject* docObj, const std::string& str) { std::unique_ptr expr(ExpressionParser::parse(docObj, str.c_str())); - VariableExpression* v = freecad_cast(expr.get()); + VariableExpression* v = freecad_cast(expr.get()); if (v) { return v->getPath(); @@ -1853,12 +1853,12 @@ ObjectIdentifier::access(const ResolveResults& result, Py::Object* value, Depend } if (prop && prop->getContainer() != obj) { auto linkTouched = - freecad_cast(obj->getPropertyByName("_LinkTouched")); + freecad_cast(obj->getPropertyByName("_LinkTouched")); if (linkTouched) { propName = linkTouched->getName(); } else { - auto propOwner = freecad_cast(prop->getContainer()); + auto propOwner = freecad_cast(prop->getContainer()); if (propOwner) { obj = propOwner; } diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index 5da225589c..cb1604fd0b 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -247,7 +247,7 @@ PyObject* PropertyContainerPy::setPropertyStatus(PyObject* args) return nullptr; } - auto linkProp = freecad_cast(prop); + auto linkProp = freecad_cast(prop); std::bitset<32> status(prop->getStatus()); std::vector items; @@ -326,7 +326,7 @@ PyObject* PropertyContainerPy::getPropertyStatus(PyObject* args) return nullptr; } - auto linkProp = freecad_cast(prop); + auto linkProp = freecad_cast(prop); if (linkProp && linkProp->testFlag(App::PropertyLinkBase::LinkAllowPartial)) { ret.append(Py::String("AllowPartial")); } diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index 36c5c0d10a..0667061b58 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -408,7 +408,7 @@ void PropertyExpressionEngine::buildGraphStructures( ObjectIdentifier PropertyExpressionEngine::canonicalPath(const ObjectIdentifier& p) const { - DocumentObject* docObj = freecad_cast(getContainer()); + DocumentObject* docObj = freecad_cast(getContainer()); // Am I owned by a DocumentObject? if (!docObj) { @@ -448,7 +448,7 @@ size_t PropertyExpressionEngine::numExpressions() const void PropertyExpressionEngine::afterRestore() { - DocumentObject* docObj = freecad_cast(getContainer()); + DocumentObject* docObj = freecad_cast(getContainer()); if (restoredExpressions && docObj) { Base::FlagToggler flag(restoring); AtomicPropertyChange signaller(*this); @@ -669,7 +669,7 @@ PropertyExpressionEngine::computeEvaluationOrder(ExecuteOption option) DocumentObjectExecReturn* App::PropertyExpressionEngine::execute(ExecuteOption option, bool* touched) { - DocumentObject* docObj = freecad_cast(getContainer()); + DocumentObject* docObj = freecad_cast(getContainer()); if (!docObj) { throw Base::RuntimeError("PropertyExpressionEngine must be owned by a DocumentObject."); @@ -739,7 +739,7 @@ DocumentObjectExecReturn* App::PropertyExpressionEngine::execute(ExecuteOption o throw Base::RuntimeError("Path does not resolve to a property."); } - DocumentObject* parent = freecad_cast(prop->getContainer()); + DocumentObject* parent = freecad_cast(prop->getContainer()); /* Make sure property belongs to the same container as this PropertyExpressionEngine */ if (parent != docObj) { @@ -808,7 +808,7 @@ void PropertyExpressionEngine::getPathsToDocumentObject( DocumentObject* obj, std::vector& paths) const { - DocumentObject* owner = freecad_cast(getContainer()); + DocumentObject* owner = freecad_cast(getContainer()); if (!owner || owner == obj) { return; diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index 313881c469..e05a6eb7dd 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -1301,7 +1301,7 @@ std::string PropertyComplexGeoData::getElementMapVersion(bool) const if (!data) { return std::string(); } - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); std::ostringstream ss; if (owner && owner->getDocument() && owner->getDocument()->getStringHasher() == data->Hasher) { ss << "1."; @@ -1319,7 +1319,7 @@ bool PropertyComplexGeoData::checkElementMapVersion(const char* ver) const if (!data) { return false; } - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); std::ostringstream ss; const char* prefix; if (owner && owner->getDocument() && owner->getDocument()->getStringHasher() == data->Hasher) { @@ -1340,7 +1340,7 @@ void PropertyComplexGeoData::afterRestore() auto data = getComplexData(); if (data && data->isRestoreFailed()) { data->resetRestoreFailure(); - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if (owner && owner->getDocument() && !owner->getDocument()->testStatus(App::Document::PartialDoc)) { owner->getDocument()->addRecomputeObject(owner); diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index 39a8faa2a9..2901d72257 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -249,7 +249,7 @@ static std::string propertyName(const Property* prop) return {}; } if (!prop->getContainer() || !prop->hasName()) { - auto xlink = freecad_cast(prop); + auto xlink = freecad_cast(prop); if (xlink) { return propertyName(xlink->parent()); } @@ -976,7 +976,7 @@ void PropertyLinkList::setValues(const std::vector& value) return; } - auto parent = freecad_cast(getContainer()); + auto parent = freecad_cast(getContainer()); for (auto obj : value) { if (!obj || !obj->isAttachedToDocument()) { throw Base::ValueError("PropertyLinkList: invalid document object"); @@ -1321,7 +1321,7 @@ void PropertyLinkSub::setValue(App::DocumentObject* lValue, std::vector&& subs, std::vector&& shadows) { - auto parent = freecad_cast(getContainer()); + auto parent = freecad_cast(getContainer()); if (lValue) { if (!lValue->isAttachedToDocument()) { throw Base::ValueError("PropertyLinkSub: invalid document object"); @@ -2216,7 +2216,7 @@ int PropertyLinkSubList::getSize() const void PropertyLinkSubList::setValue(DocumentObject* lValue, const char* SubName) { - auto parent = freecad_cast(getContainer()); + auto parent = freecad_cast(getContainer()); verifyObject(lValue, parent); // maintain backlinks @@ -2255,7 +2255,7 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue, const char* SubName) void PropertyLinkSubList::setValues(const std::vector& lValue, const std::vector& lSubNames) { - auto parent = freecad_cast(getContainer()); + auto parent = freecad_cast(getContainer()); for (auto obj : lValue) { verifyObject(obj, parent); } @@ -2316,7 +2316,7 @@ void PropertyLinkSubList::setValues(std::vector&& lValue, std::vector&& lSubNames, std::vector&& ShadowSubList) { - auto parent = freecad_cast(getContainer()); + auto parent = freecad_cast(getContainer()); for (auto obj : lValue) { verifyObject(obj, parent); } @@ -2411,7 +2411,7 @@ void PropertyLinkSubList::addValue(App::DocumentObject* obj, const std::vector& subs, bool reset) { - auto parent = freecad_cast(getContainer()); + auto parent = freecad_cast(getContainer()); verifyObject(obj, parent); // maintain backlinks. @@ -2729,7 +2729,7 @@ void PropertyLinkSubList::updateElementReference(DocumentObject* feature, bool r unregisterElementReference(); } _ShadowSubList.resize(_lSubList.size()); - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if (owner && owner->isRestoring()) { return; } @@ -3370,7 +3370,7 @@ public: if (info->pcDoc) { // make sure to attach only external object - auto owner = freecad_cast(l->getContainer()); + auto owner = freecad_cast(l->getContainer()); if (owner && owner->getDocument() == info->pcDoc) { return info; } @@ -4332,7 +4332,7 @@ void PropertyXLink::Restore(Base::XMLReader& reader) Property* PropertyXLink::CopyOnImportExternal(const std::map& nameMap) const { - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if (!owner || !owner->getDocument() || !_pcLink || !_pcLink->isAttachedToDocument()) { return nullptr; } @@ -5735,7 +5735,7 @@ void PropertyXLinkContainer::Save(Base::Writer& writer) const writer.Stream() << writer.ind() << " docSet; - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if (owner && !owner->isExporting()) { // Document name and label can change on restore, we shall record the // current document name and label and pair it with the associated @@ -5878,7 +5878,7 @@ bool PropertyXLinkContainer::isLinkedToDocument(const App::Document& doc) const void PropertyXLinkContainer::updateDeps(std::map&& newDeps) { - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if (!owner || !owner->isAttachedToDocument()) { return; } diff --git a/src/Base/BaseClass.h b/src/Base/BaseClass.h index f6e204c8e5..4f6fdffb7d 100644 --- a/src/Base/BaseClass.h +++ b/src/Base/BaseClass.h @@ -184,30 +184,29 @@ public: template bool BaseClass::is() const { - static_assert(std::is_base_of::value, "T must be derived from Base::BaseClass"); + static_assert(std::is_base_of_v, "T must be derived from Base::BaseClass"); return getTypeId() == T::getClassTypeId(); } template bool BaseClass::isDerivedFrom() const { - static_assert(std::is_base_of::value, "T must be derived from Base::BaseClass"); + static_assert(std::is_base_of_v, "T must be derived from Base::BaseClass"); return getTypeId().isDerivedFrom(T::getClassTypeId()); } /** * Template that works just like dynamic_cast, but expects the argument to * inherit from Base::BaseClass. - * */ -template -T* freecad_cast(Base::BaseClass* type) +template> + requires(std::is_pointer_v) +T freecad_cast(Base::BaseClass* type) { - static_assert(std::is_base_of::value, - "T must be derived from Base::BaseClass"); + static_assert(std::is_base_of_v, "T must be derived from Base::BaseClass"); - if (type && type->isDerivedFrom(T::getClassTypeId())) { - return static_cast(type); + if (type && type->isDerivedFrom(U::getClassTypeId())) { + return static_cast(type); } return nullptr; @@ -216,16 +215,15 @@ T* freecad_cast(Base::BaseClass* type) /** * Template that works just like dynamic_cast, but expects the argument to * inherit from a const Base::BaseClass. - * */ -template -const T* freecad_cast(const Base::BaseClass* type) +template> + requires(std::is_pointer_v) +const U* freecad_cast(const Base::BaseClass* type) { - static_assert(std::is_base_of::value, - "T must be derived from Base::BaseClass"); + static_assert(std::is_base_of_v, "T must be derived from Base::BaseClass"); - if (type && type->isDerivedFrom(T::getClassTypeId())) { - return static_cast(type); + if (type && type->isDerivedFrom(U::getClassTypeId())) { + return static_cast(type); } return nullptr; diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 83f5b6f007..24c5bceea4 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -159,7 +159,7 @@ public: void newObject(const ViewProvider& vp) { auto vpd = - freecad_cast(const_cast(&vp)); + freecad_cast(const_cast(&vp)); if (vpd && vpd->getObject()) { map[vpd->getObject()] = vpd; } @@ -167,7 +167,7 @@ public: void deleteObject(const ViewProvider& vp) { auto vpd = - freecad_cast(const_cast(&vp)); + freecad_cast(const_cast(&vp)); if (vpd && vpd->getObject()) { map.erase(vpd->getObject()); } diff --git a/src/Gui/CommandLink.cpp b/src/Gui/CommandLink.cpp index f172521848..618861a147 100644 --- a/src/Gui/CommandLink.cpp +++ b/src/Gui/CommandLink.cpp @@ -398,7 +398,7 @@ static void linkConvert(bool unlink) { for(auto &v : infos) { auto &info = v.second; auto parent = info.parent.getObject(); - auto parentVp = freecad_cast( + auto parentVp = freecad_cast( Application::Instance->getViewProvider(parent)); auto obj = info.obj.getObject(); if(!parent || !obj || !parentVp) @@ -418,7 +418,7 @@ static void linkConvert(bool unlink) { FC_THROWM(Base::RuntimeError,"Failed to create link"); link->setLink(-1,obj); link->Label.setValue(obj->Label.getValue()); - auto pla = freecad_cast( + auto pla = freecad_cast( obj->getPropertyByName("Placement")); if(pla) link->Placement.setValue(pla->getValue()); @@ -662,7 +662,7 @@ static App::DocumentObject *getSelectedLink(bool finalLink, std::string *subname auto sobj = sels[0].pObject->getSubObject(sels[0].SubName); if(!sobj) return nullptr; - auto vp = freecad_cast( + auto vp = freecad_cast( Application::Instance->getViewProvider(sobj)); if(!vp) return nullptr; diff --git a/src/Gui/DAGView/DAGModel.cpp b/src/Gui/DAGView/DAGModel.cpp index 70f32bc6d5..2dd2056d60 100644 --- a/src/Gui/DAGView/DAGModel.cpp +++ b/src/Gui/DAGView/DAGModel.cpp @@ -146,7 +146,7 @@ Model::Model(QObject *parentIn, const Gui::Document &documentIn) : QGraphicsScen //NOLINTEND for (auto obj : documentIn.getDocument()->getObjects()) { - auto vpd = freecad_cast(documentIn.getViewProvider(obj)); + auto vpd = freecad_cast(documentIn.getViewProvider(obj)); if (vpd) slotNewObject(*vpd); } diff --git a/src/Gui/DemoMode.cpp b/src/Gui/DemoMode.cpp index e55b216819..31818f15de 100644 --- a/src/Gui/DemoMode.cpp +++ b/src/Gui/DemoMode.cpp @@ -145,7 +145,7 @@ void DemoMode::hideEvent(QHideEvent*) Gui::View3DInventor* DemoMode::activeView() const { if (Document* doc = Application::Instance->activeDocument()) { - return freecad_cast(doc->getActiveView()); + return freecad_cast(doc->getActiveView()); } return nullptr; diff --git a/src/Gui/Dialogs/DlgAddProperty.cpp b/src/Gui/Dialogs/DlgAddProperty.cpp index 700e5ea9d9..af04c125e3 100644 --- a/src/Gui/Dialogs/DlgAddProperty.cpp +++ b/src/Gui/Dialogs/DlgAddProperty.cpp @@ -82,13 +82,13 @@ DlgAddProperty::DlgAddProperty(QWidget* parent, DlgAddProperty::~DlgAddProperty() = default; static std::string containerName(const App::PropertyContainer *c) { - auto doc = freecad_cast(c); + auto doc = freecad_cast(c); if(doc) return doc->getName(); - auto obj = freecad_cast(c); + auto obj = freecad_cast(c); if(obj) return obj->getFullName(); - auto vpd = freecad_cast(c); + auto vpd = freecad_cast(c); if(vpd) return vpd->getObject()->getFullName(); return "?"; diff --git a/src/Gui/Dialogs/DlgExpressionInput.cpp b/src/Gui/Dialogs/DlgExpressionInput.cpp index aef3d2c38e..b6e676da0f 100644 --- a/src/Gui/Dialogs/DlgExpressionInput.cpp +++ b/src/Gui/Dialogs/DlgExpressionInput.cpp @@ -286,7 +286,7 @@ void DlgExpressionInput::checkExpression(const QString& text) //set default palette as we may have read text right now ui->msg->setPalette(ui->okBtn->palette()); - auto * n = freecad_cast(result.get()); + auto * n = freecad_cast(result.get()); if (n) { Base::Quantity value = n->getQuantity(); if (!value.isValid()) { @@ -554,7 +554,7 @@ static void addGroupsVarSetComboBox(App::VarSet* varSet, QTreeWidgetItem* varSet static void addVarSetsVarSetComboBox(std::vector& varSets, QTreeWidgetItem* docItem) { for (auto varSet : varSets) { - auto vp = freecad_cast( + auto vp = freecad_cast( Gui::Application::Instance->getViewProvider(varSet)); // the item will be automatically destroyed when the docItem will be destroyed auto item = new QTreeWidgetItem(docItem); diff --git a/src/Gui/Dialogs/DlgObjectSelection.cpp b/src/Gui/Dialogs/DlgObjectSelection.cpp index 9c86365c2a..a7cc6f5332 100644 --- a/src/Gui/Dialogs/DlgObjectSelection.cpp +++ b/src/Gui/Dialogs/DlgObjectSelection.cpp @@ -194,7 +194,7 @@ QTreeWidgetItem *DlgObjectSelection::getItem(App::DocumentObject *obj, if (!items.empty()) return items[0]; item = new QTreeWidgetItem(ui->treeWidget); - auto vp = freecad_cast( + auto vp = freecad_cast( Gui::Application::Instance->getViewProvider(obj)); if (vp) item->setIcon(0, vp->getIcon()); App::SubObjectT objT(obj, ""); diff --git a/src/Gui/Dialogs/DlgPropertyLink.cpp b/src/Gui/Dialogs/DlgPropertyLink.cpp index 2d0e65b283..17dd3a06ef 100644 --- a/src/Gui/Dialogs/DlgPropertyLink.cpp +++ b/src/Gui/Dialogs/DlgPropertyLink.cpp @@ -272,7 +272,7 @@ void DlgPropertyLink::init(const App::DocumentObjectT& prop, bool tryFilter) ui->searchBox->setDocumentObject(owner); - auto propLink = freecad_cast(objProp.getProperty()); + auto propLink = freecad_cast(objProp.getProperty()); if (!propLink) { return; } @@ -580,7 +580,7 @@ void DlgPropertyLink::onItemSelectionChanged() focus = ui->treeWidget->hasFocus(); auto doc = Gui::Application::Instance->getDocument(sobjs.front().getDocumentName().c_str()); if (doc) { - auto vp = freecad_cast( + auto vp = freecad_cast( doc->getViewProvider(obj)); if (vp) { // If the view provider uses a special window for rendering, switch to it @@ -1016,7 +1016,7 @@ QTreeWidgetItem* DlgPropertyLink::createItem(App::DocumentObject* obj, QTreeWidg return nullptr; } - auto vp = freecad_cast( + auto vp = freecad_cast( Application::Instance->getViewProvider(obj)); if (!vp) { return nullptr; @@ -1047,7 +1047,7 @@ QTreeWidgetItem* DlgPropertyLink::createItem(App::DocumentObject* obj, QTreeWidg QByteArray proxyType; auto prop = - freecad_cast(obj->getPropertyByName("Proxy")); + freecad_cast(obj->getPropertyByName("Proxy")); if (prop) { Base::PyGILStateLocker lock; Py::Object proxy = prop->getValue(); diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 4fd7a05eb8..193e852ff5 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1932,7 +1932,7 @@ void Document::importObjects(const std::vector& obj, Base: Gui::ViewProvider* pObj = this->getViewProviderByName(name.c_str()); if (pObj) { pObj->setStatus(Gui::isRestoring,true); - auto vpd = freecad_cast(pObj); + auto vpd = freecad_cast(pObj); if(vpd) vpd->startRestoring(); pObj->Restore(*localreader); if (expanded && vpd) diff --git a/src/Gui/DocumentObserver.h b/src/Gui/DocumentObserver.h index ba9eb9ddb1..38600565cf 100644 --- a/src/Gui/DocumentObserver.h +++ b/src/Gui/DocumentObserver.h @@ -120,7 +120,7 @@ public: template inline T* getObjectAs() const { - return freecad_cast(getViewProvider()); + return freecad_cast(getViewProvider()); } private: @@ -215,7 +215,7 @@ public: template inline T* get() const noexcept { - return freecad_cast(_get()); + return freecad_cast(_get()); } private: diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index e72f71815d..9171ca6142 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -120,7 +120,7 @@ void InputField::bind(const App::ObjectIdentifier &_path) { ExpressionBinding::bind(_path); - auto * prop = freecad_cast(getPath().getProperty()); + auto * prop = freecad_cast(getPath().getProperty()); if (prop) actQuantity = Base::Quantity(prop->getValue()); @@ -259,7 +259,7 @@ void InputField::newInput(const QString & text) std::unique_ptr evalRes(getExpression()->eval()); - auto * value = freecad_cast(evalRes.get()); + auto * value = freecad_cast(evalRes.get()); if (value) { res.setValue(value->getValue()); res.setUnit(value->getUnit()); diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 222b4cba93..326e04bc4b 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -139,7 +139,7 @@ public: if (expr) { std::unique_ptr res(expr->eval()); - NumberExpression * n = freecad_cast(res.get()); + NumberExpression * n = freecad_cast(res.get()); if (n){ result = n->getQuantity(); value = result.getValue(); diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index 005fafdb9b..7ccfdccdd1 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -102,7 +102,7 @@ void ExpressionSpinBox::showInvalidExpression(const QString& tip) void ExpressionSpinBox::showValidExpression(ExpressionSpinBox::Number number) { std::unique_ptr result(getExpression()->eval()); - auto * value = freecad_cast(result.get()); + auto * value = freecad_cast(result.get()); if (value) { switch (number) { @@ -186,7 +186,7 @@ void ExpressionSpinBox::openFormulaDialog() { Q_ASSERT(isBound()); - auto * qprop = freecad_cast(getPath().getProperty()); + auto * qprop = freecad_cast(getPath().getProperty()); Unit unit; if (qprop) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 064b8ead5c..4d8c67364c 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1918,14 +1918,14 @@ namespace { if (topObj) { auto sobj = topObj->getSubObject(info.topSubname.c_str(), nullptr, &mat); if (sobj == obj) { - propPlacement = freecad_cast( + propPlacement = freecad_cast( obj->getPropertyByName("Placement")); } } } } else { - propPlacement = freecad_cast( + propPlacement = freecad_cast( obj->getPropertyByName("Placement")); if (propPlacement) mat = propPlacement->getValue().toMatrix(); @@ -2484,7 +2484,7 @@ bool TreeWidget::dropInObject(QDropEvent* event, TargetItemInfo& targetInfo, for (auto& info : infos) { auto& subname = info.subname; targetObj = targetDoc->getObject(target.c_str()); - vp = freecad_cast( Application::Instance->getViewProvider(targetObj)); + vp = freecad_cast( Application::Instance->getViewProvider(targetObj)); if (!vp) { FC_ERR("Cannot find drop target object " << target); break; @@ -2652,7 +2652,7 @@ bool TreeWidget::dropInObject(QDropEvent* event, TargetItemInfo& targetInfo, (!info.dragging && sobj->getLinkedObject(false) == obj)) { if (!info.dragging) - propPlacement = freecad_cast( + propPlacement = freecad_cast( sobj->getPropertyByName("Placement")); if (propPlacement) { newMat *= propPlacement->getValue().inverse().toMatrix(); @@ -2791,7 +2791,7 @@ void TreeWidget::sortDroppedObjects(TargetItemInfo& targetInfo, std::vector(targetInfo.targetItem); App::DocumentObject* targetObj = targetItemObj->object()->getObject(); - auto propGroup = freecad_cast(targetObj->getPropertyByName("Group")); + auto propGroup = freecad_cast(targetObj->getPropertyByName("Group")); if (!propGroup) { return; } @@ -3061,7 +3061,7 @@ void TreeWidget::onUpdateStatus() errors.push_back(obj); if (docItem->ObjectMap.count(obj)) continue; - auto vpd = freecad_cast(gdoc->getViewProvider(obj)); + auto vpd = freecad_cast(gdoc->getViewProvider(obj)); if (vpd) docItem->createNewItem(*vpd); } @@ -3746,7 +3746,7 @@ void TreeWidget::selectLinkedObject(App::DocumentObject* linked) { if (!isSelectionAttached() || isSelectionBlocked()) return; - auto linkedVp = freecad_cast( + auto linkedVp = freecad_cast( Application::Instance->getViewProvider(linked)); if (!linkedVp) { TREE_ERR("invalid linked view provider"); @@ -3962,7 +3962,7 @@ bool DocumentItem::createNewItem(const Gui::ViewProviderDocumentObject& obj, } ViewProviderDocumentObject* DocumentItem::getViewProvider(App::DocumentObject* obj) { - return freecad_cast( + return freecad_cast( Application::Instance->getViewProvider(obj)); } diff --git a/src/Gui/ViewProviderDocumentObject.cpp b/src/Gui/ViewProviderDocumentObject.cpp index 5ac6bcb22f..5b4e608a81 100644 --- a/src/Gui/ViewProviderDocumentObject.cpp +++ b/src/Gui/ViewProviderDocumentObject.cpp @@ -547,7 +547,7 @@ int ViewProviderDocumentObject::replaceObject( std::vector props; obj->getPropertyList(props); for(auto prop : props) { - auto linkProp = freecad_cast(prop); + auto linkProp = freecad_cast(prop); if(!linkProp) continue; std::unique_ptr copy(linkProp->CopyOnLinkReplace(obj, oldObj,newObj)); @@ -567,7 +567,7 @@ int ViewProviderDocumentObject::replaceObject( std::vector props; o->getPropertyList(props); for(auto prop : props) { - auto linkProp = freecad_cast(prop); + auto linkProp = freecad_cast(prop); if(!linkProp) continue; std::unique_ptr copy(linkProp->CopyOnLinkReplace(obj,oldObj,newObj)); @@ -691,7 +691,7 @@ ViewProviderDocumentObject *ViewProviderDocumentObject::getLinkedViewProvider( auto linked = pcObject->getLinkedObject(recursive); if(!linked || linked == pcObject) return self; - auto res = freecad_cast( + auto res = freecad_cast( Application::Instance->getViewProvider(linked)); if(!res) res = self; diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 3ed56f0fc5..8a4cb8a5ee 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -745,7 +745,7 @@ void ViewProviderLinkObserver::extensionBeforeDelete() { void ViewProviderLinkObserver::extensionReattach(App::DocumentObject *) { if(linkInfo) { linkInfo->pcLinked = - freecad_cast(getExtendedContainer()); + freecad_cast(getExtendedContainer()); linkInfo->update(); } } @@ -755,7 +755,7 @@ void ViewProviderLinkObserver::extensionOnChanged(const App::Property *prop) { } void ViewProviderLinkObserver::extensionModeSwitchChange() { - auto owner = freecad_cast(getExtendedContainer()); + auto owner = freecad_cast(getExtendedContainer()); if(owner && linkInfo) linkInfo->updateSwitch(); } @@ -1026,7 +1026,7 @@ void LinkView::setMaterial(int index, const App::Material *material) { } void LinkView::setLink(App::DocumentObject *obj, const std::vector &subs) { - setLinkViewObject(freecad_cast( + setLinkViewObject(freecad_cast( Application::Instance->getViewProvider(obj)),subs); } @@ -1743,7 +1743,7 @@ QPixmap ViewProviderLink::getOverlayPixmap() const { void ViewProviderLink::onChanged(const App::Property* prop) { if(prop==&ChildViewProvider) { - childVp = freecad_cast(ChildViewProvider.getObject().get()); + childVp = freecad_cast(ChildViewProvider.getObject().get()); if(childVp && getObject()) { if(strcmp(childVp->getTypeId().getName(),getObject()->getViewProviderName())!=0 && !childVp->allowOverride(*getObject())) @@ -1864,7 +1864,7 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension *ext, const App: } }else if(prop == ext->getLinkCopyOnChangeGroupProperty()) { if (auto group = ext->getLinkCopyOnChangeGroupValue()) { - auto vp = freecad_cast( + auto vp = freecad_cast( Application::Instance->getViewProvider(group)); if (vp) { vp->hide(); @@ -1915,7 +1915,7 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension *ext, const App: }else if(prop == ext->_getShowElementProperty()) { if(!ext->_getShowElementValue()) { - auto linked = freecad_cast(getLinkedView(true,ext)); + auto linked = freecad_cast(getLinkedView(true,ext)); if(linked && linked->getDocument()==getDocument()) linked->hide(); @@ -1929,9 +1929,9 @@ void ViewProviderLink::updateDataPrivate(App::LinkBaseExtension *ext, const App: bool hasMaterial = false; materials.reserve(elements.size()); for(size_t i=0;i(elements[i]); + auto element = freecad_cast(elements[i]); if(!element) continue; - auto vp = freecad_cast( + auto vp = freecad_cast( Application::Instance->getViewProvider(element)); if(!vp) continue; overrideMaterial = overrideMaterial || vp->OverrideMaterial.getValue(); @@ -2016,7 +2016,7 @@ void ViewProviderLink::updateElementList(App::LinkBaseExtension *ext) { int i=-1; for(auto obj : elements) { ++i; - auto vp = freecad_cast( + auto vp = freecad_cast( Application::Instance->getViewProvider(obj)); if(!vp) continue; if(OverrideMaterialList.getSize()>i) @@ -2234,7 +2234,7 @@ bool ViewProviderLink::canDropObjectEx(App::DocumentObject *obj, if(!hasSubName && linkView->isLinked()) { auto linked = getLinkedView(false,ext); if(linked) { - auto linkedVdp = freecad_cast(linked); + auto linkedVdp = freecad_cast(linked); if(linkedVdp) { if(linkedVdp->getObject()==obj || linkedVdp->getObject()==owner) return false; @@ -2243,7 +2243,7 @@ bool ViewProviderLink::canDropObjectEx(App::DocumentObject *obj, } } if(obj->getDocument() != getObject()->getDocument() && - !freecad_cast(ext->getLinkedObjectProperty())) + !freecad_cast(ext->getLinkedObjectProperty())) return false; return true; @@ -2600,7 +2600,7 @@ void ViewProviderLink::_setupContextMenu( App::LinkBaseExtension *ext, QMenu* menu, QObject* receiver, const char* member) { if(linkEdit(ext)) { - if (auto linkvp = freecad_cast(linkView->getLinkedView())) + if (auto linkvp = freecad_cast(linkView->getLinkedView())) linkvp->_setupContextMenu(ext, menu, receiver, member); else linkView->getLinkedView()->setupContextMenu(menu,receiver,member); @@ -2743,7 +2743,7 @@ bool ViewProviderLink::initDraggingPlacement() { { App::PropertyPlacement *propPla = nullptr; if(ext->getLinkTransformValue() && ext->getLinkedObjectValue()) { - propPla = freecad_cast( + propPla = freecad_cast( ext->getLinkedObjectValue()->getPropertyByName("Placement")); } if(propPla) { @@ -2828,7 +2828,7 @@ ViewProvider *ViewProviderLink::startEditing(int mode) { FC_ERR("no linked object"); return nullptr; } - auto vpd = freecad_cast( + auto vpd = freecad_cast( Application::Instance->getViewProvider(linked)); if(!vpd) { FC_ERR("no linked viewprovider"); @@ -3018,7 +3018,7 @@ std::map ViewProviderLink::getElementColors(const char auto link = vp->getObject()->getLinkedObject(false); if(!link || link==vp->getObject()) break; - auto next = freecad_cast( + auto next = freecad_cast( Application::Instance->getViewProvider(link)); if(!next) break; @@ -3341,7 +3341,7 @@ ViewProviderDocumentObject *ViewProviderLink::getLinkedViewProvider( linked = ext->getTrueLinkedObject(recursive); if(!linked) return self; - auto res = freecad_cast( + auto res = freecad_cast( Application::Instance->getViewProvider(linked)); if(res) return res; diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index e5a717ba67..653064ed15 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -319,9 +319,9 @@ void PropertyEditor::openEditor(const QModelIndex& index) } auto prop = items[0]; auto parent = prop->getContainer(); - auto obj = freecad_cast(parent); + auto obj = freecad_cast(parent); if (!obj) { - auto view = freecad_cast(parent); + auto view = freecad_cast(parent); if (view) { obj = view->getObject(); } diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index d4e4c8b335..be609e7ae5 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -158,7 +158,7 @@ void PropertyItem::setPropertyData(const std::vector& items) try { // Check for 'DocumentObject' as parent because otherwise 'ObjectIdentifier' raises an // exception - auto* docObj = freecad_cast(prop.getContainer()); + auto* docObj = freecad_cast(prop.getContainer()); if (docObj && !docObj->isReadOnly(&prop)) { App::ObjectIdentifier id(prop); std::vector paths; @@ -4558,7 +4558,7 @@ void LinkLabel::updatePropertyLink() { QString text; auto owner = objProp.getObject(); - auto prop = freecad_cast(objProp.getProperty()); + auto prop = freecad_cast(objProp.getProperty()); link = QVariant(); @@ -4673,7 +4673,7 @@ QVariant PropertyLinkItem::data(int column, int role) const QVariant PropertyLinkItem::value(const App::Property* prop) const { - auto propLink = freecad_cast(prop); + auto propLink = freecad_cast(prop); if (!propLink) { return {}; } diff --git a/src/Mod/CAM/Gui/ViewProviderPath.cpp b/src/Mod/CAM/Gui/ViewProviderPath.cpp index 24cc979792..b2c435dc1f 100644 --- a/src/Mod/CAM/Gui/ViewProviderPath.cpp +++ b/src/Mod/CAM/Gui/ViewProviderPath.cpp @@ -111,7 +111,7 @@ public: } Base::Matrix4D linkMat; auto linked = sobj->getLinkedObject(true, &linkMat, false); - auto vp = freecad_cast(Application::Instance->getViewProvider(linked)); + auto vp = freecad_cast(Application::Instance->getViewProvider(linked)); if (!vp) { setArrow(); return; diff --git a/src/Mod/Drawing/App/FeatureViewSpreadsheet.cpp b/src/Mod/Drawing/App/FeatureViewSpreadsheet.cpp index 86b6585e93..bfac86f870 100644 --- a/src/Mod/Drawing/App/FeatureViewSpreadsheet.cpp +++ b/src/Mod/Drawing/App/FeatureViewSpreadsheet.cpp @@ -186,13 +186,13 @@ App::DocumentObjectExecReturn* FeatureViewSpreadsheet::execute(void) App::Property* prop = sheet->getPropertyByName(address.toString().c_str()); std::stringstream field; if (prop) { - if (auto* p = freecad_cast(prop)) { + if (auto* p = freecad_cast(prop)) { field << p->getValue(); } - else if (auto p = freecad_cast(prop)) { + else if (auto p = freecad_cast(prop)) { field << p->getValue(); } - else if (auto p = freecad_cast(prop)) { + else if (auto p = freecad_cast(prop)) { field << p->getValue(); } else { diff --git a/src/Mod/Fem/App/FemPostFilter.cpp b/src/Mod/Fem/App/FemPostFilter.cpp index 80a926db7f..338dec9e89 100644 --- a/src/Mod/Fem/App/FemPostFilter.cpp +++ b/src/Mod/Fem/App/FemPostFilter.cpp @@ -616,7 +616,7 @@ void FemPostClipFilter::onChanged(const Property* prop) { if (prop == &Function) { - if (auto* value = freecad_cast(Function.getValue())) { + if (auto* value = freecad_cast(Function.getValue())) { m_clipper->SetClipFunction(value->getImplicitFunction()); m_extractor->SetImplicitFunction(value->getImplicitFunction()); } @@ -1078,7 +1078,7 @@ FemPostCutFilter::~FemPostCutFilter() = default; void FemPostCutFilter::onChanged(const Property* prop) { if (prop == &Function) { - if (auto* value = freecad_cast(Function.getValue())) { + if (auto* value = freecad_cast(Function.getValue())) { m_cutter->SetCutFunction(value->getImplicitFunction()); } else { diff --git a/src/Mod/Fem/App/FemPostPipeline.cpp b/src/Mod/Fem/App/FemPostPipeline.cpp index ec29613cd4..85e3b988bb 100644 --- a/src/Mod/Fem/App/FemPostPipeline.cpp +++ b/src/Mod/Fem/App/FemPostPipeline.cpp @@ -459,7 +459,7 @@ void FemPostPipeline::onChanged(const Property* prop) value = frames[Frame.getValue()]; } for (const auto& obj : Group.getValues()) { - if (auto* postFilter = freecad_cast(obj)) { + if (auto* postFilter = freecad_cast(obj)) { postFilter->Frame.setValue(value); } } diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.h b/src/Mod/Fem/Gui/TaskPostBoxes.h index 095a380437..a13f9a6d7e 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.h +++ b/src/Mod/Fem/Gui/TaskPostBoxes.h @@ -83,7 +83,7 @@ public: template T* getObject() const { - return freecad_cast(getObject()); + return freecad_cast(getObject()); } QMetaObject::Connection connSelectPoint; @@ -159,7 +159,7 @@ protected: template T* getObject() const { - return freecad_cast(getObject()); + return freecad_cast(getObject()); } template T* getTypedObject() const diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp index d1a6c8a5d8..6e83a9f24d 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp @@ -94,8 +94,8 @@ ViewProviderFemAnalysis* getAnalyzeView(App::DocumentObject* obj) ViewProviderFemAnalysis* analyzeView = nullptr; App::DocumentObject* grp = App::GroupExtension::getGroupOfObject(obj); - if (Fem::FemAnalysis* analyze = freecad_cast(grp)) { - analyzeView = freecad_cast( + if (Fem::FemAnalysis* analyze = freecad_cast(grp)) { + analyzeView = freecad_cast( Gui::Application::Instance->getViewProvider(analyze)); } diff --git a/src/Mod/Import/App/ImportOCAF2.cpp b/src/Mod/Import/App/ImportOCAF2.cpp index 0acbdf2351..de872e0dad 100644 --- a/src/Mod/Import/App/ImportOCAF2.cpp +++ b/src/Mod/Import/App/ImportOCAF2.cpp @@ -478,7 +478,7 @@ bool ImportOCAF2::createGroup(App::Document* doc, auto link = doc->addObject("Link"); link->Label.setValue(child->Label.getValue()); link->setLink(-1, child); - auto pla = freecad_cast(child->getPropertyByName("Placement")); + auto pla = freecad_cast(child->getPropertyByName("Placement")); if (pla) { link->Placement.setValue(pla->getValue()); } diff --git a/src/Mod/Measure/Gui/TaskMeasure.cpp b/src/Mod/Measure/Gui/TaskMeasure.cpp index ab03896d8c..9b2cc03b71 100644 --- a/src/Mod/Measure/Gui/TaskMeasure.cpp +++ b/src/Mod/Measure/Gui/TaskMeasure.cpp @@ -249,7 +249,7 @@ void TaskMeasure::update() App::DocumentObject* sub = ob->getSubObject(sel.SubName); // Resolve App::Link - if (auto link = freecad_cast(sub)) { + if (auto link = freecad_cast(sub)) { sub = link->getLinkedObject(true); } diff --git a/src/Mod/Measure/Gui/ViewProviderMeasureDistance.cpp b/src/Mod/Measure/Gui/ViewProviderMeasureDistance.cpp index 6e1095eb0c..e46183762e 100644 --- a/src/Mod/Measure/Gui/ViewProviderMeasureDistance.cpp +++ b/src/Mod/Measure/Gui/ViewProviderMeasureDistance.cpp @@ -237,8 +237,8 @@ SbMatrix ViewProviderMeasureDistance::getMatrix() return {}; } - auto prop1 = freecad_cast(pcObject->getPropertyByName("Position1")); - auto prop2 = freecad_cast(pcObject->getPropertyByName("Position2")); + auto prop1 = freecad_cast(pcObject->getPropertyByName("Position1")); + auto prop2 = freecad_cast(pcObject->getPropertyByName("Position2")); if (!prop1 || !prop2) { return {}; @@ -456,8 +456,8 @@ void ViewProviderMeasureDistance::redrawAnnotation() return; } - auto prop1 = freecad_cast(pcObject->getPropertyByName("Position1")); - auto prop2 = freecad_cast(pcObject->getPropertyByName("Position2")); + auto prop1 = freecad_cast(pcObject->getPropertyByName("Position1")); + auto prop2 = freecad_cast(pcObject->getPropertyByName("Position2")); if (!prop1 || !prop2) { return; diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 60abc7b905..5a9027ab1f 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -386,12 +386,12 @@ void ViewProviderMesh::setOpenEdgeColorFrom(const Base::Color& c) const Mesh::PropertyMeshKernel& ViewProviderMesh::getMeshProperty() const { - return freecad_cast(getObject())->Mesh; + return freecad_cast(getObject())->Mesh; } Mesh::PropertyMeshKernel& ViewProviderMesh::getMeshProperty() { - return freecad_cast(getObject())->Mesh; + return freecad_cast(getObject())->Mesh; } const Mesh::MeshObject& ViewProviderMesh::getMeshObject() const @@ -2420,14 +2420,15 @@ void ViewProviderMesh::highlightColors() { const Mesh::MeshObject& rMesh = getMeshObject(); { - auto prop = freecad_cast(pcObject->getPropertyByName("FaceColors")); + auto prop = + freecad_cast(pcObject->getPropertyByName("FaceColors")); if (prop && prop->getSize() == int(rMesh.countFacets())) { setColorPerFace(prop); } } { auto prop = - freecad_cast(pcObject->getPropertyByName("VertexColors")); + freecad_cast(pcObject->getPropertyByName("VertexColors")); if (prop && prop->getSize() == int(rMesh.countPoints())) { setColorPerVertex(prop); } @@ -2438,14 +2439,15 @@ bool ViewProviderMesh::canHighlightColors() const { const Mesh::MeshObject& rMesh = getMeshObject(); { - auto prop = freecad_cast(pcObject->getPropertyByName("FaceColors")); + auto prop = + freecad_cast(pcObject->getPropertyByName("FaceColors")); if (prop && prop->getSize() == int(rMesh.countFacets())) { return true; } } { auto prop = - freecad_cast(pcObject->getPropertyByName("VertexColors")); + freecad_cast(pcObject->getPropertyByName("VertexColors")); if (prop && prop->getSize() == int(rMesh.countPoints())) { return true; } diff --git a/src/Mod/MeshPart/Gui/Tessellation.cpp b/src/Mod/MeshPart/Gui/Tessellation.cpp index 6553c469c7..2031453a8d 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.cpp +++ b/src/Mod/MeshPart/Gui/Tessellation.cpp @@ -374,7 +374,7 @@ void Tessellation::setFaceColors(int method, App::Document* doc, App::DocumentOb Gui::Application::Instance->getViewProvider(doc->getActiveObject()); auto vpmesh = dynamic_cast(vpm); - auto svp = freecad_cast( + auto svp = freecad_cast( Gui::Application::Instance->getViewProvider(obj)); if (vpmesh && svp) { std::vector diff_col = svp->ShapeAppearance.getDiffuseColors(); @@ -463,7 +463,7 @@ QString Tessellation::getStandardParameters(App::DocumentObject* obj) const param += QStringLiteral(",Segments=True"); } - auto svp = freecad_cast( + auto svp = freecad_cast( Gui::Application::Instance->getViewProvider(obj)); if (ui->groupsFaceColors->isChecked() && svp) { // TODO: currently, we can only retrieve part feature diff --git a/src/Mod/Part/App/AttachExtension.cpp b/src/Mod/Part/App/AttachExtension.cpp index d84543c591..493a3b13ea 100644 --- a/src/Mod/Part/App/AttachExtension.cpp +++ b/src/Mod/Part/App/AttachExtension.cpp @@ -168,7 +168,7 @@ static inline bool getProp(bool force, const char* name, const char* doc) { - prop = freecad_cast(owner->getDynamicPropertyByName(name)); + prop = freecad_cast(owner->getDynamicPropertyByName(name)); if (prop || !force) { return false; } @@ -573,7 +573,7 @@ AttachExtension::Properties AttachExtension::getInitedProperties(bool base) App::PropertyPlacement& AttachExtension::getPlacement() const { - auto pla = freecad_cast( + auto pla = freecad_cast( getExtendedObject()->getPropertyByName("Placement")); if (!pla) { throw Base::RuntimeError("AttachExtension cannot find placement property"); diff --git a/src/Mod/Part/App/Geometry.cpp b/src/Mod/Part/App/Geometry.cpp index 0f676335e4..f42510268e 100644 --- a/src/Mod/Part/App/Geometry.cpp +++ b/src/Mod/Part/App/Geometry.cpp @@ -215,9 +215,9 @@ bool Geometry::hasSameExtensions(const Geometry& other) const size_t index = 0; for (const auto& ext : extensions) { if (auto persistExt = - freecad_cast(ext.get())) { + freecad_cast(ext.get())) { for (; index < other.extensions.size(); ++index) { - if (auto extOther = freecad_cast( + if (auto extOther = freecad_cast( other.extensions[index].get())) { if (!persistExt->isSame(*extOther)) { return false; @@ -232,7 +232,7 @@ bool Geometry::hasSameExtensions(const Geometry& other) const } } for (; index < other.extensions.size(); ++index) { - if (freecad_cast( + if (freecad_cast( other.extensions[index].get())) { return false; } diff --git a/src/Mod/Part/App/PartFeature.cpp b/src/Mod/Part/App/PartFeature.cpp index 9481a63b66..72797760d1 100644 --- a/src/Mod/Part/App/PartFeature.cpp +++ b/src/Mod/Part/App/PartFeature.cpp @@ -166,7 +166,7 @@ App::ElementNamePair Feature::getElementName(const char* name, // This function is overridden to provide higher level shape topo names that // are generated on demand, e.g. Wire, Shell, Solid, etc. - auto prop = freecad_cast(getPropertyOfGeometry()); + auto prop = freecad_cast(getPropertyOfGeometry()); if (!prop) { return App::GeoFeature::getElementName(name, type); } @@ -1686,7 +1686,7 @@ bool Feature::isElementMappingDisabled(App::PropertyContainer* container) // if (prop && prop->getValue()) { // return true; // } -// if (auto obj = freecad_cast(container)) { +// if (auto obj = freecad_cast(container)) { // if (auto doc = obj->getDocument()) { // if (auto prop = propDisableMapping(doc, /*forced*/ false)) { // return prop->getValue(); diff --git a/src/Mod/Part/App/PropertyGeometryList.cpp b/src/Mod/Part/App/PropertyGeometryList.cpp index 1f0138255e..c4c9a30ff3 100644 --- a/src/Mod/Part/App/PropertyGeometryList.cpp +++ b/src/Mod/Part/App/PropertyGeometryList.cpp @@ -191,7 +191,7 @@ void PropertyGeometryList::trySaveGeometry(Geometry * geom, Base::Writer &writer geom->Save(writer); for( auto & ext : geom->getExtensions() ) { auto extension = ext.lock(); - auto gpe = freecad_cast(extension.get()); + auto gpe = freecad_cast(extension.get()); if (gpe) gpe->postSave(writer); } @@ -232,7 +232,7 @@ void PropertyGeometryList::Save(Writer &writer) const << _lValueList[i]->getTypeId().getName() << "\""; for (auto &e : _lValueList[i]->getExtensions() ) { auto ext = e.lock(); - if (auto gpe = freecad_cast(ext.get())) { + if (auto gpe = freecad_cast(ext.get())) { gpe->preSave(writer); } } diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index b5fe8a3d16..cf7dc91951 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -67,7 +67,7 @@ void PropertyPartShape::setValue(const TopoShape& sh) { aboutToSetValue(); _Shape = sh; - auto obj = freecad_cast(getContainer()); + auto obj = freecad_cast(getContainer()); if(obj) { auto tag = obj->getID(); if(_Shape.Tag && tag!=_Shape.Tag) { @@ -109,7 +109,7 @@ const TopoShape& PropertyPartShape::getShape() const // res.Tag = -1; // else if (!res.Tag) { if (!_Shape.Tag) { - if (auto parent = freecad_cast(getContainer())) { + if (auto parent = freecad_cast(getContainer())) { _Shape.Tag = parent->getID(); } } @@ -219,7 +219,7 @@ App::Property *PropertyPartShape::Copy() const void PropertyPartShape::Paste(const App::Property &from) { - auto prop = freecad_cast(&from); + auto prop = freecad_cast(&from); if(prop) { setValue(prop->_Shape); _Ver = prop->_Ver; @@ -249,7 +249,7 @@ void PropertyPartShape::beforeSave() const { _HasherIndex = 0; _SaveHasher = false; - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); if(owner && !_Shape.isNull() && _Shape.getElementMapSize()>0) { auto ret = owner->getDocument()->addStringHasher(_Shape.Hasher); _HasherIndex = ret.second; @@ -323,7 +323,7 @@ void PropertyPartShape::Restore(Base::XMLReader &reader) { reader.readElement("Part"); - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); _Ver = "?"; bool has_ver = reader.hasAttribute("ElementMap"); if (has_ver) @@ -943,7 +943,7 @@ void PropertyShapeCache::setPyObject(PyObject *value) { * @return The shape cache, or null if we aren't creating and it doesn't exist */ PropertyShapeCache *PropertyShapeCache::get(const App::DocumentObject *obj, bool create) { - auto prop = freecad_cast( + auto prop = freecad_cast( obj->getDynamicPropertyByName(SHAPE_CACHE_NAME)); if(prop && prop->getContainer()==obj) return prop; diff --git a/src/Mod/Part/Gui/CommandSimple.cpp b/src/Mod/Part/Gui/CommandSimple.cpp index e470632456..21d4f1f58a 100644 --- a/src/Mod/Part/Gui/CommandSimple.cpp +++ b/src/Mod/Part/Gui/CommandSimple.cpp @@ -154,12 +154,12 @@ void CmdPartPointsFromMesh::activated(int iMsg) double distance{1.0}; auto found = std::find_if(geoms.begin(), geoms.end(), [](App::DocumentObject* obj) { - return freecad_cast(obj); + return freecad_cast(obj); }); if (found != geoms.end()) { - double defaultDistance = getDefaultDistance(freecad_cast(*found)); + double defaultDistance = getDefaultDistance(freecad_cast(*found)); double STD_OCC_TOLERANCE = 1e-6; diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index ea9f6a977d..7d3c6cf5aa 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -194,7 +194,7 @@ bool Body::isSolidFeature(const App::DocumentObject *obj) // Datum objects are not solid return false; } - if (auto transFeature = freecad_cast(obj)) { + if (auto transFeature = freecad_cast(obj)) { // Transformed Features inside a MultiTransform are not solid features return !transFeature->isMultiTransformChild(); } diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index 2447d5ed42..959a429e65 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -389,7 +389,7 @@ TopoShape Feature::makeTopoShapeFromPlane(const App::DocumentObject* obj) Body* Feature::getFeatureBody() const { - auto body = freecad_cast(_Body.getValue()); + auto body = freecad_cast(_Body.getValue()); if(body) return body; diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index 84241b36b3..4cf3ae246f 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -310,7 +310,7 @@ void DressUp::getAddSubShape(Part::TopoShape &addShape, Part::TopoShape &subShap // feature (which must be of type FeatureAddSub), and skipping // any consecutive DressUp in-between. for(Feature *current=this; ;current=static_cast(base)) { - base = freecad_cast(current->getBaseObject(true)); + base = freecad_cast(current->getBaseObject(true)); if(!base) FC_THROWM(Base::CADKernelError, "Cannot find additive or subtractive support for " << getFullName()); diff --git a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp index 9ba3453299..8c84596cc0 100644 --- a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp +++ b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp @@ -52,7 +52,7 @@ void MultiTransform::positionBySupport() PartDesign::Transformed::positionBySupport(); std::vector transFeatures = Transformations.getValues(); for (auto f : transFeatures) { - auto transFeature = freecad_cast(f); + auto transFeature = freecad_cast(f); if (!transFeature) { throw Base::TypeError("Transformation features must be subclasses of Transformed"); } @@ -85,7 +85,7 @@ MultiTransform::getTransformations(const std::vector origi // Find centre of gravity of first original // FIXME: This method will NOT give the expected result for more than one original! if (auto addFeature = - freecad_cast(originals.front())) { + freecad_cast(originals.front())) { TopoDS_Shape original = addFeature->AddSubShape.getShape().getShape(); GProp_GProps props; @@ -98,7 +98,7 @@ MultiTransform::getTransformations(const std::vector origi std::list cogs; for (auto const& f : transFeatures) { - auto transFeature = freecad_cast(f); + auto transFeature = freecad_cast(f); if (!transFeature) { throw Base::TypeError("Transformation features must be subclasses of Transformed"); } diff --git a/src/Mod/PartDesign/App/FeatureScaled.cpp b/src/Mod/PartDesign/App/FeatureScaled.cpp index 0bbd29ec81..3a85ee4a8a 100644 --- a/src/Mod/PartDesign/App/FeatureScaled.cpp +++ b/src/Mod/PartDesign/App/FeatureScaled.cpp @@ -72,7 +72,7 @@ Scaled::getTransformations(const std::vector originals) if (!originals.empty()) { // Find centre of gravity of first original // FIXME: This method will NOT give the expected result for more than one original! - if (auto feature = freecad_cast(originals.front())) { + if (auto feature = freecad_cast(originals.front())) { TopoDS_Shape original = feature->AddSubShape.getShape().getShape(); GProp_GProps props; diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index f43e0c8949..3fc8a2f186 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -1449,7 +1449,7 @@ Base::Vector3d ProfileBased::getProfileNormal() const { // If the shape is a line, then return an arbitrary direction that is perpendicular to the line auto geom = Part::Geometry::fromShape(shape.getSubShape(TopAbs_EDGE, 1), true); - auto geomLine = freecad_cast(geom.get()); + auto geomLine = freecad_cast(geom.get()); if (geomLine) { Base::Vector3d dir = geomLine->getDir(); double x = std::fabs(dir.x); diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index e6d439715b..7e0dce819b 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -95,7 +95,7 @@ Part::Feature* Transformed::getBaseObject(bool silent) const // first App::DocumentObject* firstOriginal = originals.empty() ? nullptr : originals.front(); if (firstOriginal) { - rv = freecad_cast(firstOriginal); + rv = freecad_cast(firstOriginal); if (!rv) { err = QT_TRANSLATE_NOOP("Exception", "Transformation feature Linked object is not a Part object"); @@ -117,19 +117,19 @@ App::DocumentObject* Transformed::getSketchObject() const std::vector originals = Originals.getValues(); DocumentObject const* firstOriginal = !originals.empty() ? originals.front() : nullptr; - if (auto feature = freecad_cast(firstOriginal)) { + if (auto feature = freecad_cast(firstOriginal)) { return feature->getVerifiedSketch(true); } - if (freecad_cast(firstOriginal)) { + if (freecad_cast(firstOriginal)) { return nullptr; } - if (auto pattern = freecad_cast(this)) { + if (auto pattern = freecad_cast(this)) { return pattern->Direction.getValue(); } - if (auto pattern = freecad_cast(this)) { + if (auto pattern = freecad_cast(this)) { return pattern->Axis.getValue(); } - if (auto pattern = freecad_cast(this)) { + if (auto pattern = freecad_cast(this)) { return pattern->MirrorPlane.getValue(); } @@ -147,7 +147,7 @@ bool Transformed::isMultiTransformChild() const // because the dependencies are only established after creation. /* for (auto const* obj : getInList()) { - auto mt = freecad_cast(obj); + auto mt = freecad_cast(obj); if (!mt) { continue; } @@ -175,7 +175,7 @@ void Transformed::handleChangedPropertyType(Base::XMLReader& reader, // The property 'Angle' of PolarPattern has changed from PropertyFloat // to PropertyAngle and the property 'Length' has changed to PropertyLength. Base::Type inputType = Base::Type::fromName(TypeName); - if (auto property = freecad_cast(prop); + if (auto property = freecad_cast(prop); property != nullptr && inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) { // Do not directly call the property's Restore method in case the implementation // has changed. So, create a temporary PropertyFloat object and assign the value. @@ -214,7 +214,7 @@ App::DocumentObjectExecReturn* Transformed::execute() // there auto eraseIter = std::remove_if(originals.begin(), originals.end(), [](App::DocumentObject const* obj) { - auto feature = freecad_cast(obj); + auto feature = freecad_cast(obj); return feature != nullptr && feature->Suppressed.getValue(); }); originals.erase(eraseIter, originals.end()); @@ -298,7 +298,7 @@ App::DocumentObjectExecReturn* Transformed::execute() Part::TopoShape fuseShape; Part::TopoShape cutShape; - auto feature = freecad_cast(original); + auto feature = freecad_cast(original); if (!feature) { return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP( "Exception", diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index c97f80a06a..cdbe83def8 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -718,7 +718,7 @@ void SubShapeBinder::update(SubShapeBinder::UpdateOption options) { if (!forced) { bool hit = true; for (auto& v : mats) { - auto prop = freecad_cast( + auto prop = freecad_cast( getDynamicPropertyByName(cacheName(v.first))); if (!prop || prop->getValue() != v.second) { hit = false; diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index c8ba66fa9b..328bc0a805 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -677,7 +677,7 @@ bool importExternalElements(App::PropertyLinkSub& prop, std::vector(prop.getContainer()); + auto editObj = freecad_cast(prop.getContainer()); if (!editObj) { FC_THROWM(Base::RuntimeError, "Editing object not found"); } @@ -784,7 +784,7 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons // Populate the subs parameter by checking for external elements before // we construct our command. - auto ProfileFeature = freecad_cast(Feat); + auto ProfileFeature = freecad_cast(Feat); std::vector& cmdSubs = const_cast&>(subs); if (subs.size() == 0) { diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 8ceaa82a74..dd59340daa 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -391,7 +391,7 @@ TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::string sub, bool indepe // we are a independent copy, therefore no external geometry was copied. WE therefore // can delete all constraints - if (auto* sketchObj = freecad_cast(obj)) { + if (auto* sketchObj = freecad_cast(obj)) { sketchObj->delConstraintsToExternal(); } } diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 328bdde456..ef28139a2f 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -192,7 +192,7 @@ void ViewProvider::onChanged(const App::Property* prop) { for(App::DocumentObject* obj : body->Group.getValues()) { if(obj->isDerivedFrom() && obj != getObject()) { - auto vpd = freecad_cast( + auto vpd = freecad_cast( Gui::Application::Instance->getViewProvider(obj)); if(vpd && vpd->Visibility.getValue()) vpd->Visibility.setValue(false); diff --git a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp index 4c447d66ea..5da2b897ec 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp @@ -413,7 +413,7 @@ void ViewProviderSubShapeBinder::updatePlacement(bool transaction) { std::vector ViewProviderSubShapeBinder::claimChildren() const { std::vector ret; - auto self = freecad_cast(getObject()); + auto self = freecad_cast(getObject()); if (self && self->ClaimChildren.getValue() && self->Support.getValue()) { std::set objSet; for (auto& l : self->Support.getSubListValues()) { diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index c8e45f45db..f1d4790999 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -8234,7 +8234,7 @@ static Part::Geometry *fitArcs(std::vector > &ar double m = 0.0; Base::Vector3d center; for (auto &geo : arcs) { - if (auto arc = freecad_cast(geo.get())) { + if (auto arc = freecad_cast(geo.get())) { if (radius == 0.0) { radius = arc->getRadius(); center = arc->getCenter(); diff --git a/src/Mod/Spreadsheet/App/Cell.cpp b/src/Mod/Spreadsheet/App/Cell.cpp index 73c551d36c..d5f573af89 100644 --- a/src/Mod/Spreadsheet/App/Cell.cpp +++ b/src/Mod/Spreadsheet/App/Cell.cpp @@ -250,14 +250,14 @@ bool Cell::getStringContent(std::string& s, bool persistent) const if (expression->hasComponent()) { s = "=" + expression->toString(persistent); } - else if (freecad_cast(expression.get())) { + else if (freecad_cast(expression.get())) { s = static_cast(expression.get())->getText(); s = "'" + s; } - else if (freecad_cast(expression.get())) { + else if (freecad_cast(expression.get())) { s = "=" + expression->toString(); } - else if (freecad_cast(expression.get())) { + else if (freecad_cast(expression.get())) { s = expression->toString(); } else { @@ -274,7 +274,7 @@ bool Cell::getStringContent(std::string& s, bool persistent) const void Cell::afterRestore() { - auto expr = freecad_cast(expression.get()); + auto expr = freecad_cast(expression.get()); if (expr) { setContent(expr->getText().c_str()); } @@ -331,10 +331,10 @@ void Cell::setContent(const char* value) try { ExpressionPtr parsedExpr(App::ExpressionParser::parse(owner->sheet(), value)); - if (const auto fraction = freecad_cast(parsedExpr.get())) { + if (const auto fraction = freecad_cast(parsedExpr.get())) { if (fraction->getOperator() == OperatorExpression::UNIT) { - const auto left = freecad_cast(fraction->getLeft()); - const auto right = freecad_cast(fraction->getRight()); + const auto left = freecad_cast(fraction->getLeft()); + const auto right = freecad_cast(fraction->getRight()); if (left && right) { newExpr = std::move(parsedExpr); } @@ -345,22 +345,22 @@ void Cell::setContent(const char* value) // check for numbers in (de)nominator const bool isNumberNom = - freecad_cast(fraction->getLeft()); + freecad_cast(fraction->getLeft()); const bool isNumberDenom = - freecad_cast(fraction->getRight()); + freecad_cast(fraction->getRight()); // check for numbers with units in (de)nominator const auto opNom = - freecad_cast(fraction->getLeft()); + freecad_cast(fraction->getLeft()); const auto opDenom = - freecad_cast(fraction->getRight()); + freecad_cast(fraction->getRight()); const bool isQuantityNom = opNom && opNom->getOperator() == OperatorExpression::UNIT; const bool isQuantityDenom = opDenom && opDenom->getOperator() == OperatorExpression::UNIT; // check for units in denomainator - const auto uDenom = freecad_cast(fraction->getRight()); + const auto uDenom = freecad_cast(fraction->getRight()); const bool isUnitDenom = uDenom && uDenom->is(); const bool isNomValid = isNumberNom || isQuantityNom; @@ -371,7 +371,8 @@ void Cell::setContent(const char* value) } } } - else if (const auto number = freecad_cast(parsedExpr.get())) { + else if (const auto number = + freecad_cast(parsedExpr.get())) { // NumbersExpressions can accept more than can be parsed with strtod. // Example: 12.34 and 12,34 are both valid NumberExpressions newExpr = std::move(parsedExpr); diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index 9a5f4664a0..c787893b14 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -378,7 +378,7 @@ void PropertySheet::Paste(const Property& from) if (!spanChanges.empty()) { mergedCells = froms.mergedCells; - if (auto sheet = freecad_cast(getContainer())) { + if (auto sheet = freecad_cast(getContainer())) { for (const auto& addr : spanChanges) { sheet->cellSpanChanged(addr); } @@ -1476,7 +1476,7 @@ void PropertySheet::recomputeDependants(const App::DocumentObject* owner, const // Check for hidden reference. Because a hidden reference is not // protected by cyclic dependency checking, we need to take special // care to prevent it from misbehave. - Sheet* sheet = freecad_cast(getContainer()); + Sheet* sheet = freecad_cast(getContainer()); if (!sheet || sheet->testStatus(App::ObjectStatus::Recompute2) || !owner || owner->testStatus(App::ObjectStatus::Recompute2)) { return; @@ -2078,7 +2078,7 @@ PropertySheet::BindingType PropertySheet::getBinding(const Range& range, if (expr->getFunction() == FunctionExpression::TUPLE && expr->getArgs().size() == 3) { if (pTarget) { - if (auto e = freecad_cast(expr->getArgs()[0])) { + if (auto e = freecad_cast(expr->getArgs()[0])) { *pTarget = e->getPath(); } } @@ -2117,7 +2117,7 @@ void PropertySheet::setPathValue(const ObjectIdentifier& path, const boost::any& && Py::Object(seq[1].ptr()).isString() && Py::Object(seq[2].ptr()).isString()) { AtomicPropertyChange signaller(*this, false); auto other = static_cast(seq[0].ptr())->getPropertySheetPtr(); - auto otherOwner = freecad_cast(other->getContainer()); + auto otherOwner = freecad_cast(other->getContainer()); if (!otherOwner) { FC_THROWM(Base::RuntimeError, "Invalid binding of '" << other->getFullName() << " in " @@ -2287,7 +2287,7 @@ void PropertySheet::getLinksTo(std::vector& identifiers, auto subObject = objT.getSubObject(); auto subElement = objT.getOldElementName(); - auto owner = freecad_cast(getContainer()); + auto owner = freecad_cast(getContainer()); for (const auto& [cellName, cellExpression] : data) { if (auto expr = cellExpression->getExpression()) { const auto& deps = expr->getDeps(option); diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index 9f7ed76aea..52fb12fd1b 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -344,16 +344,16 @@ bool Sheet::exportToFile(const std::string& filename, std::stringstream field; - if (auto p = freecad_cast(prop)) { + if (auto p = freecad_cast(prop)) { field << p->getValue(); } - else if (auto p = freecad_cast(prop)) { + else if (auto p = freecad_cast(prop)) { field << p->getValue(); } - else if (auto p = freecad_cast(prop)) { + else if (auto p = freecad_cast(prop)) { field << p->getValue(); } - else if (auto p = freecad_cast(prop)) { + else if (auto p = freecad_cast(prop)) { field << p->getValue(); } else { @@ -593,7 +593,7 @@ Property* Sheet::setFloatProperty(CellAddress key, double value) this->removeDynamicProperty(name.c_str()); propAddress.erase(prop); } - floatProp = freecad_cast( + floatProp = freecad_cast( addDynamicProperty("App::PropertyFloat", name.c_str(), nullptr, @@ -621,7 +621,7 @@ Property* Sheet::setIntegerProperty(CellAddress key, long value) this->removeDynamicProperty(name.c_str()); propAddress.erase(prop); } - intProp = freecad_cast( + intProp = freecad_cast( addDynamicProperty("App::PropertyInteger", name.c_str(), nullptr, @@ -666,7 +666,7 @@ Property* Sheet::setQuantityProperty(CellAddress key, double value, const Base:: nullptr, nullptr, Prop_ReadOnly | Prop_Hidden | Prop_NoPersist); - quantityProp = freecad_cast(p); + quantityProp = freecad_cast(p); } else { quantityProp = static_cast(prop); @@ -695,14 +695,14 @@ Property* Sheet::setStringProperty(CellAddress key, const std::string& value) { std::string name = key.toString(CellAddress::Cell::ShowRowColumn); Property* prop = props.getDynamicPropertyByName(name.c_str()); - PropertyString* stringProp = freecad_cast(prop); + PropertyString* stringProp = freecad_cast(prop); if (!stringProp) { if (prop) { this->removeDynamicProperty(name.c_str()); propAddress.erase(prop); } - stringProp = freecad_cast( + stringProp = freecad_cast( addDynamicProperty("App::PropertyString", name.c_str(), nullptr, @@ -720,14 +720,14 @@ Property* Sheet::setObjectProperty(CellAddress key, Py::Object object) { std::string name = key.toString(CellAddress::Cell::ShowRowColumn); Property* prop = props.getDynamicPropertyByName(name.c_str()); - PropertyPythonObject* pyProp = freecad_cast(prop); + PropertyPythonObject* pyProp = freecad_cast(prop); if (!pyProp) { if (prop) { this->removeDynamicProperty(name.c_str()); propAddress.erase(prop); } - pyProp = freecad_cast( + pyProp = freecad_cast( addDynamicProperty("App::PropertyPythonObject", name.c_str(), nullptr, @@ -794,10 +794,10 @@ void Sheet::updateProperty(CellAddress key) /* Eval returns either NumberExpression or StringExpression, or * PyObjectExpression objects */ - auto number = freecad_cast(output.get()); + auto number = freecad_cast(output.get()); if (number) { long l; - auto constant = freecad_cast(output.get()); + auto constant = freecad_cast(output.get()); if (constant && !constant->isNumber()) { Base::PyGILStateLocker lock; setObjectProperty(key, constant->getPyValue()); @@ -813,13 +813,13 @@ void Sheet::updateProperty(CellAddress key) } } else { - auto str_expr = freecad_cast(output.get()); + auto str_expr = freecad_cast(output.get()); if (str_expr) { setStringProperty(key, str_expr->getText().c_str()); } else { Base::PyGILStateLocker lock; - auto py_expr = freecad_cast(output.get()); + auto py_expr = freecad_cast(output.get()); if (py_expr) { setObjectProperty(key, py_expr->getPyValue()); } diff --git a/src/Mod/Spreadsheet/Gui/Command.cpp b/src/Mod/Spreadsheet/Gui/Command.cpp index 220a70a534..ae44d1ccb8 100644 --- a/src/Mod/Spreadsheet/Gui/Command.cpp +++ b/src/Mod/Spreadsheet/Gui/Command.cpp @@ -71,7 +71,7 @@ void CmdSpreadsheetMergeCells::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -101,7 +101,7 @@ bool CmdSpreadsheetMergeCells::isActive() if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { return (sheetView->selectedIndexesRaw().size() > 1); @@ -132,7 +132,7 @@ void CmdSpreadsheetSplitCell::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -157,7 +157,7 @@ bool CmdSpreadsheetSplitCell::isActive() if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { QModelIndex current = sheetView->currentIndex(); @@ -246,7 +246,7 @@ void CmdSpreadsheetExport::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -263,7 +263,7 @@ bool CmdSpreadsheetExport::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -292,7 +292,7 @@ void CmdSpreadsheetAlignLeft::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -320,7 +320,7 @@ bool CmdSpreadsheetAlignLeft::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -349,7 +349,7 @@ void CmdSpreadsheetAlignCenter::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -377,7 +377,7 @@ bool CmdSpreadsheetAlignCenter::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -406,7 +406,7 @@ void CmdSpreadsheetAlignRight::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -434,7 +434,7 @@ bool CmdSpreadsheetAlignRight::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -463,7 +463,7 @@ void CmdSpreadsheetAlignTop::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -491,7 +491,7 @@ bool CmdSpreadsheetAlignTop::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -520,7 +520,7 @@ void CmdSpreadsheetAlignBottom::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -548,7 +548,7 @@ bool CmdSpreadsheetAlignBottom::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -577,7 +577,7 @@ void CmdSpreadsheetAlignVCenter::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -605,7 +605,7 @@ bool CmdSpreadsheetAlignVCenter::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -635,7 +635,7 @@ void CmdSpreadsheetStyleBold::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -689,7 +689,7 @@ bool CmdSpreadsheetStyleBold::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -719,7 +719,7 @@ void CmdSpreadsheetStyleItalic::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -773,7 +773,7 @@ bool CmdSpreadsheetStyleItalic::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -803,7 +803,7 @@ void CmdSpreadsheetStyleUnderline::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -857,7 +857,7 @@ bool CmdSpreadsheetStyleUnderline::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && freecad_cast(activeWindow)) { + if (activeWindow && freecad_cast(activeWindow)) { return true; } } @@ -887,7 +887,7 @@ void CmdSpreadsheetSetAlias::activated(int iMsg) if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -921,7 +921,7 @@ bool CmdSpreadsheetSetAlias::isActive() if (activeWindow) { SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { QModelIndexList selection = sheetView->selectedIndexes(); diff --git a/src/Mod/Spreadsheet/Gui/DlgBindSheet.cpp b/src/Mod/Spreadsheet/Gui/DlgBindSheet.cpp index feece7f35f..797b30b070 100644 --- a/src/Mod/Spreadsheet/Gui/DlgBindSheet.cpp +++ b/src/Mod/Spreadsheet/Gui/DlgBindSheet.cpp @@ -168,10 +168,10 @@ void DlgBindSheet::accept() if (!doc) { FC_THROWM(Base::RuntimeError, "Cannot find document " << docname); } - obj = freecad_cast(doc->getObject(sep + 1)); + obj = freecad_cast(doc->getObject(sep + 1)); } else { - obj = freecad_cast(sheet->getDocument()->getObject(ref)); + obj = freecad_cast(sheet->getDocument()->getObject(ref)); } if (!obj) { FC_THROWM(Base::RuntimeError, "Cannot find Spreadsheet '" << ref << "'"); diff --git a/src/Mod/Spreadsheet/Gui/DlgSheetConf.cpp b/src/Mod/Spreadsheet/Gui/DlgSheetConf.cpp index 82f710db2b..67b0fa352a 100644 --- a/src/Mod/Spreadsheet/Gui/DlgSheetConf.cpp +++ b/src/Mod/Spreadsheet/Gui/DlgSheetConf.cpp @@ -140,7 +140,7 @@ App::Property* DlgSheetConf::prepare(CellAddress& from, if (cell && cell->getExpression()) { auto expr = cell->getExpression(); if (expr->isDerivedFrom()) { - auto fexpr = freecad_cast(cell->getExpression()); + auto fexpr = freecad_cast(cell->getExpression()); if (fexpr && (fexpr->getFunction() == FunctionExpression::HREF || fexpr->getFunction() == FunctionExpression::HIDDENREF) @@ -148,11 +148,11 @@ App::Property* DlgSheetConf::prepare(CellAddress& from, expr = fexpr->getArgs().front(); } } - auto vexpr = freecad_cast(expr); + auto vexpr = freecad_cast(expr); if (vexpr) { - auto prop = freecad_cast(vexpr->getPath().getProperty()); + auto prop = freecad_cast(vexpr->getPath().getProperty()); if (prop) { - auto obj = freecad_cast(prop->getContainer()); + auto obj = freecad_cast(prop->getContainer()); if (obj && prop->hasName()) { path = ObjectIdentifier(sheet); path.setDocumentObjectName(obj, true); diff --git a/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.cpp b/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.cpp index f44cf08b90..f9591f54ae 100644 --- a/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.cpp +++ b/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.cpp @@ -146,7 +146,7 @@ void ViewProviderSheet::setupContextMenu(QMenu* menu, QObject* receiver, const c Sheet* ViewProviderSheet::getSpreadsheetObject() const { - return freecad_cast(pcObject); + return freecad_cast(pcObject); } void ViewProviderSheet::beforeDelete() diff --git a/src/Mod/Spreadsheet/Gui/Workbench.cpp b/src/Mod/Spreadsheet/Gui/Workbench.cpp index ca0cb3db8d..7a58ca9388 100644 --- a/src/Mod/Spreadsheet/Gui/Workbench.cpp +++ b/src/Mod/Spreadsheet/Gui/Workbench.cpp @@ -129,7 +129,7 @@ void WorkbenchHelper::setForegroundColor(const QColor& color) if (doc) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); @@ -163,7 +163,7 @@ void WorkbenchHelper::setBackgroundColor(const QColor& color) if (doc) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); SpreadsheetGui::SheetView* sheetView = - freecad_cast(activeWindow); + freecad_cast(activeWindow); if (sheetView) { Sheet* sheet = sheetView->getSheet(); diff --git a/src/Mod/TechDraw/Gui/QGSPage.cpp b/src/Mod/TechDraw/Gui/QGSPage.cpp index 8a3e41075a..3a37b37193 100644 --- a/src/Mod/TechDraw/Gui/QGSPage.cpp +++ b/src/Mod/TechDraw/Gui/QGSPage.cpp @@ -390,49 +390,49 @@ bool QGSPage::attachView(App::DocumentObject* obj) QGIView* qview(nullptr); - if (auto o = freecad_cast(obj)) { + if (auto o = freecad_cast(obj)) { qview = addViewSection(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addViewPart(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addProjectionGroup(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addDrawView(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addViewDimension(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addViewBalloon(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addAnnotation(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addDrawViewSymbol(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addDrawViewClip(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addDrawViewSpreadsheet(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addDrawViewImage(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addViewLeader(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addRichAnno(o); } - else if (auto o = freecad_cast(obj)) { + else if (auto o = freecad_cast(obj)) { qview = addWeldSymbol(o); } - else if (freecad_cast(obj)) { + else if (freecad_cast(obj)) { //Hatch is not attached like other Views (since it isn't really a View) return true; } diff --git a/src/Tools/params_utils.py b/src/Tools/params_utils.py index c27d7d291b..69d21b0cba 100644 --- a/src/Tools/params_utils.py +++ b/src/Tools/params_utils.py @@ -1197,7 +1197,7 @@ class Property: ) cog.out( f""" - if (auto prop = freecad_cast<{self.type_name}>( + if (auto prop = freecad_cast<{self.type_name}*>( obj->getPropertyByName("{self.name}"))) {{ if (prop->getContainer() == obj)