App: Use freecad_cast whenever possible
This commit is contained in:
committed by
Benjamin Nauck
parent
019a25ad75
commit
7accf81bbe
@@ -797,7 +797,7 @@ void Document::onChanged(const Property* prop)
|
||||
}
|
||||
else if (prop == &UseHasher) {
|
||||
for (auto obj : d->objectArray) {
|
||||
auto geofeature = dynamic_cast<GeoFeature*>(obj);
|
||||
auto geofeature = freecad_cast<GeoFeature*>(obj);
|
||||
if (geofeature && geofeature->getPropertyOfGeometry()) {
|
||||
geofeature->enforceRecompute();
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ void DocumentObject::getOutList(int options, std::vector<DocumentObject*>& res)
|
||||
bool noHidden = !!(options & OutListNoHidden);
|
||||
std::size_t size = res.size();
|
||||
for (auto prop : props) {
|
||||
auto link = dynamic_cast<PropertyLinkBase*>(prop);
|
||||
auto link = freecad_cast<PropertyLinkBase*>(prop);
|
||||
if (link) {
|
||||
link->getLinks(res, noHidden);
|
||||
}
|
||||
@@ -457,7 +457,7 @@ std::vector<App::DocumentObject*> DocumentObject::getOutListOfProperty(App::Prop
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto link = dynamic_cast<PropertyLinkBase*>(prop);
|
||||
auto link = freecad_cast<PropertyLinkBase*>(prop);
|
||||
if (link) {
|
||||
link->getLinks(ret);
|
||||
}
|
||||
@@ -629,7 +629,7 @@ DocumentObject::getPathsByOutList(App::DocumentObject* to) const
|
||||
|
||||
DocumentObjectGroup* DocumentObject::getGroup() const
|
||||
{
|
||||
return dynamic_cast<DocumentObjectGroup*>(GroupExtension::getGroupOfObject(this));
|
||||
return freecad_cast<DocumentObjectGroup*>(GroupExtension::getGroupOfObject(this));
|
||||
}
|
||||
|
||||
bool DocumentObject::testIfLinkDAGCompatible(DocumentObject* linkTo) const
|
||||
@@ -1130,7 +1130,7 @@ DocumentObject* DocumentObject::getLinkedObject(bool recursive,
|
||||
}
|
||||
}
|
||||
if (transform && mat) {
|
||||
auto pla = dynamic_cast<PropertyPlacement*>(getPropertyByName("Placement"));
|
||||
auto pla = freecad_cast<PropertyPlacement*>(getPropertyByName("Placement"));
|
||||
if (pla) {
|
||||
*mat *= pla->getValue().toMatrix();
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
/// find a property by its name, dynamic cased to specified type
|
||||
template<typename T>
|
||||
T* getPropertyByName(const char* name) const {
|
||||
return dynamic_cast<T*>(this->getPropertyByName(name));
|
||||
return freecad_cast<T*>(this->getPropertyByName(name));
|
||||
}
|
||||
/// get the name of a property
|
||||
const char* getPropertyName(const Property* prop) const override;
|
||||
|
||||
@@ -482,7 +482,7 @@ PyObject* PropertyContainerPy::getEnumerationsOfProperty(PyObject* args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PropertyEnumeration* enumProp = dynamic_cast<PropertyEnumeration*>(prop);
|
||||
PropertyEnumeration* enumProp = freecad_cast<PropertyEnumeration*>(prop);
|
||||
if (!enumProp) {
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void PropertyLinkBase::setReturnNewElement(bool enable)
|
||||
|
||||
void PropertyLinkBase::hasSetValue()
|
||||
{
|
||||
auto owner = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(getContainer());
|
||||
if (owner) {
|
||||
owner->clearOutListCache();
|
||||
}
|
||||
@@ -1521,7 +1521,7 @@ static bool updateLinkReference(App::PropertyLinkBase* prop,
|
||||
if (!link || !link->isAttachedToDocument()) {
|
||||
return false;
|
||||
}
|
||||
auto owner = dynamic_cast<DocumentObject*>(prop->getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(prop->getContainer());
|
||||
if (owner && owner->isRestoring()) {
|
||||
return false;
|
||||
}
|
||||
@@ -1846,7 +1846,7 @@ void PropertyLinkSub::Save(Base::Writer& writer) const
|
||||
<< _cSubList.size();
|
||||
writer.Stream() << "\">" << std::endl;
|
||||
writer.incInd();
|
||||
auto owner = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(getContainer());
|
||||
bool exporting = owner && owner->isExporting();
|
||||
for (unsigned int i = 0; i < _cSubList.size(); i++) {
|
||||
const auto& shadow = _ShadowSubList[i];
|
||||
@@ -2788,7 +2788,7 @@ void PropertyLinkSubList::Save(Base::Writer& writer) const
|
||||
}
|
||||
writer.Stream() << writer.ind() << "<LinkSubList count=\"" << count << "\">" << endl;
|
||||
writer.incInd();
|
||||
auto owner = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(getContainer());
|
||||
bool exporting = owner && owner->isExporting();
|
||||
for (int i = 0; i < getSize(); i++) {
|
||||
auto obj = _lValueList[i];
|
||||
@@ -2844,7 +2844,7 @@ void PropertyLinkSubList::Restore(Base::XMLReader& reader)
|
||||
SubNames.reserve(count);
|
||||
std::vector<ShadowSub> shadows;
|
||||
shadows.reserve(count);
|
||||
DocumentObject* father = dynamic_cast<DocumentObject*>(getContainer());
|
||||
DocumentObject* father = freecad_cast<DocumentObject*>(getContainer());
|
||||
App::Document* document = father ? father->getDocument() : nullptr;
|
||||
std::vector<int> mapped;
|
||||
bool restoreLabel = false;
|
||||
@@ -3609,7 +3609,7 @@ public:
|
||||
for (auto it = links.begin(), itNext = it; it != links.end(); it = itNext) {
|
||||
++itNext;
|
||||
auto link = *it;
|
||||
auto obj = dynamic_cast<DocumentObject*>(link->getContainer());
|
||||
auto obj = freecad_cast<DocumentObject*>(link->getContainer());
|
||||
if (obj && obj->getDocument() == &doc) {
|
||||
links.erase(it);
|
||||
// must call unlink here, so that PropertyLink::resetLink can
|
||||
@@ -3654,7 +3654,7 @@ public:
|
||||
bool hasXLink(const App::Document* doc) const
|
||||
{
|
||||
for (auto link : links) {
|
||||
auto obj = dynamic_cast<DocumentObject*>(link->getContainer());
|
||||
auto obj = freecad_cast<DocumentObject*>(link->getContainer());
|
||||
if (obj && obj->getDocument() == doc) {
|
||||
return true;
|
||||
}
|
||||
@@ -3703,7 +3703,7 @@ void PropertyLinkBase::breakLinks(App::DocumentObject* link,
|
||||
props.clear();
|
||||
obj->getPropertyList(props);
|
||||
for (auto prop : props) {
|
||||
auto linkProp = dynamic_cast<PropertyLinkBase*>(prop);
|
||||
auto linkProp = freecad_cast<PropertyLinkBase*>(prop);
|
||||
if (linkProp) {
|
||||
linkProp->breakLink(link, clear);
|
||||
}
|
||||
@@ -3826,7 +3826,7 @@ void PropertyXLink::restoreLink(App::DocumentObject* lValue)
|
||||
{
|
||||
assert(!_pcLink && lValue && docInfo);
|
||||
|
||||
auto owner = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(getContainer());
|
||||
if (!owner || !owner->isAttachedToDocument()) {
|
||||
throw Base::RuntimeError("invalid container");
|
||||
}
|
||||
@@ -3863,7 +3863,7 @@ void PropertyXLink::setValue(App::DocumentObject* lValue,
|
||||
throw Base::ValueError("Invalid object");
|
||||
}
|
||||
|
||||
auto owner = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(getContainer());
|
||||
if (!owner || !owner->isAttachedToDocument()) {
|
||||
throw Base::RuntimeError("invalid container");
|
||||
}
|
||||
@@ -3930,7 +3930,7 @@ void PropertyXLink::setValue(std::string&& filename,
|
||||
setValue(nullptr, std::move(subs), std::move(shadows));
|
||||
return;
|
||||
}
|
||||
auto owner = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto owner = freecad_cast<DocumentObject*>(getContainer());
|
||||
if (!owner || !owner->isAttachedToDocument()) {
|
||||
throw Base::RuntimeError("invalid container");
|
||||
}
|
||||
|
||||
@@ -1442,7 +1442,7 @@ void PropertyString::setValue(const char* newValue)
|
||||
|
||||
std::vector<std::pair<Property*, std::unique_ptr<Property>>> propChanges;
|
||||
std::string newValueStr = newValue;
|
||||
auto obj = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto obj = freecad_cast<DocumentObject*>(getContainer());
|
||||
bool commit = false;
|
||||
|
||||
if (obj && this == &obj->Label) {
|
||||
@@ -1510,7 +1510,7 @@ void PropertyString::setPyObject(PyObject* value)
|
||||
void PropertyString::Save(Base::Writer& writer) const
|
||||
{
|
||||
std::string val;
|
||||
auto obj = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto obj = freecad_cast<DocumentObject*>(getContainer());
|
||||
writer.Stream() << writer.ind() << "<String ";
|
||||
bool exported = false;
|
||||
if (obj && obj->isAttachedToDocument() && obj->isExporting() && &obj->Label == this) {
|
||||
@@ -1534,7 +1534,7 @@ void PropertyString::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("String");
|
||||
// get the value of my Attribute
|
||||
auto obj = dynamic_cast<DocumentObject*>(getContainer());
|
||||
auto obj = freecad_cast<DocumentObject*>(getContainer());
|
||||
if (obj && &obj->Label == this) {
|
||||
if (reader.hasAttribute("restore")) {
|
||||
int restore = reader.getAttributeAsInteger("restore");
|
||||
|
||||
Reference in New Issue
Block a user