Core: modernize type checking

This commit is contained in:
Florian Foinant-Willig
2023-10-15 21:38:48 +02:00
parent 6d8fb68f3b
commit 773c701eec
31 changed files with 110 additions and 110 deletions

View File

@@ -62,7 +62,7 @@ using ExtensionPython = ExtensionPythonT<App::Extension>;
Py::Object result;\
try {\
Property* proxy = this->getExtendedContainer()->getPropertyByName("Proxy");\
if (proxy && proxy->getTypeId() == PropertyPythonObject::getClassTypeId()) {\
if (proxy && proxy->is<PropertyPythonObject>()) {\
Py::Object feature = static_cast<PropertyPythonObject*>(proxy)->getValue();\
if (feature.hasAttr(std::string("function"))) {\
if (feature.hasAttr("__object__")) {\

View File

@@ -189,7 +189,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
std::vector<App::Property*> list;
obj->getPropertyList(list);
for(App::Property* prop : list) {
if(prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) {
if(prop->isDerivedFrom<App::PropertyLink>()) {
auto p = static_cast<App::PropertyLink*>(prop);
if(!p->getValue() || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId()))
@@ -197,7 +197,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
p->setValue(getOrigin()->getOriginFeature(static_cast<OriginFeature*>(p->getValue())->Role.getValue()));
}
else if(prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) {
else if(prop->isDerivedFrom<App::PropertyLinkList>()) {
auto p = static_cast<App::PropertyLinkList*>(prop);
auto vec = p->getValues();
std::vector<App::DocumentObject*> result;
@@ -213,7 +213,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
if(changed)
static_cast<App::PropertyLinkList*>(prop)->setValues(result);
}
else if(prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId())) {
else if(prop->isDerivedFrom<App::PropertyLinkSub>()) {
auto p = static_cast<App::PropertyLinkSub*>(prop);
if(!p->getValue() || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId()))
continue;
@@ -221,7 +221,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj)
std::vector<std::string> subValues = p->getSubValues();
p->setValue(getOrigin()->getOriginFeature(static_cast<OriginFeature*>(p->getValue())->Role.getValue()), subValues);
}
else if(prop->getTypeId().isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())) {
else if(prop->isDerivedFrom<App::PropertyLinkSubList>()) {
auto p = static_cast<App::PropertyLinkSubList*>(prop);
auto vec = p->getSubListValues();
bool changed = false;

View File

@@ -998,7 +998,7 @@ PropertyPlacementLink::~PropertyPlacementLink() = default;
App::Placement * PropertyPlacementLink::getPlacementObject() const
{
if (_pcLink->getTypeId().isDerivedFrom(App::Placement::getClassTypeId()))
if (_pcLink->isDerivedFrom<App::Placement>())
return dynamic_cast<App::Placement*>(_pcLink);
else
return nullptr;

View File

@@ -478,7 +478,7 @@ void PropertyLink::Restore(Base::XMLReader &reader)
std::string name = reader.getName(reader.getAttribute("value"));
// Property not in a DocumentObject!
assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId()) );
assert(getContainer()->isDerivedFrom<App::DocumentObject>() );
if (!name.empty()) {
DocumentObject* parent = static_cast<DocumentObject*>(getContainer());
@@ -729,7 +729,7 @@ void PropertyLinkList::Restore(Base::XMLReader &reader)
App::PropertyContainer* container = getContainer();
if (!container)
throw Base::RuntimeError("Property is not part of a container");
if (!container->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId())) {
if (!container->isDerivedFrom<App::DocumentObject>()) {
std::stringstream str;
str << "Container is not a document object ("
<< container->getTypeId().getName() << ")";
@@ -1330,7 +1330,7 @@ void PropertyLinkSub::Restore(Base::XMLReader &reader)
int count = reader.getAttributeAsInteger("count");
// Property not in a DocumentObject!
assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId()) );
assert(getContainer()->isDerivedFrom<App::DocumentObject>() );
App::Document* document = static_cast<DocumentObject*>(getContainer())->getDocument();
DocumentObject *pcObject = nullptr;
@@ -3339,7 +3339,7 @@ void PropertyXLink::Restore(Base::XMLReader &reader)
else
name = reader.getAttribute("name");
assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId()));
assert(getContainer()->isDerivedFrom<App::DocumentObject>());
DocumentObject *object = nullptr;
if(!name.empty() && file.empty()) {
DocumentObject* parent = static_cast<DocumentObject*>(getContainer());

View File

@@ -432,7 +432,7 @@ Property *PropertyPythonObject::Copy() const
void PropertyPythonObject::Paste(const Property &from)
{
if (from.getTypeId() == PropertyPythonObject::getClassTypeId()) {
if (from.is<PropertyPythonObject>()) {
Base::PyGILStateLocker lock;
aboutToSetValue();
this->object = static_cast<const PropertyPythonObject&>(from).object;

View File

@@ -76,7 +76,7 @@ Transaction::~Transaction()
// of an object is not undone or when an addition is undone.
if (!It.first->isAttachedToDocument()) {
if (It.first->getTypeId().isDerivedFrom(DocumentObject::getClassTypeId())) {
if (It.first->isDerivedFrom<DocumentObject>()) {
// #0003323: Crash when clearing transaction list
// It can happen that when clearing the transaction list several objects
// are destroyed with dependencies which can lead to dangling pointers.

View File

@@ -54,12 +54,12 @@ struct TypeData;
\code
void getRightFeature(Base::Base * anode)
{
assert(anode->getTypeId().isDerivedFrom(App::Feature::getClassTypeId()));
assert(anode->isDerivedFrom<App::Feature>());
if (anode->getTypeId() == Mesh::MeshFeature::getClassTypeId()) {
if (anode->is<Mesh::MeshFeature>()) {
// do something..
}
else if (anode->getTypeId() == Part::PartFeature::getClassTypeId()) {
else if (anode->is<Part::PartFeature>()) {
// do something..
}
else {

View File

@@ -222,7 +222,7 @@ FreeCADGui_subgraphFromObject(PyObject * /*self*/, PyObject *args)
auto base =
static_cast<Base::BaseClass*>(Base::Type::createInstanceByName(vp.c_str(), true));
if (base
&& base->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) {
&& base->isDerivedFrom<Gui::ViewProviderDocumentObject>()) {
std::unique_ptr<Gui::ViewProviderDocumentObject> vp(
static_cast<Gui::ViewProviderDocumentObject*>(base));
std::map<std::string, App::Property*> Map;
@@ -231,7 +231,7 @@ FreeCADGui_subgraphFromObject(PyObject * /*self*/, PyObject *args)
// this is needed to initialize Python-based view providers
App::Property* pyproxy = vp->getPropertyByName("Proxy");
if (pyproxy && pyproxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
if (pyproxy && pyproxy->is<App::PropertyPythonObject>()) {
static_cast<App::PropertyPythonObject*>(pyproxy)->setValue(Py::Long(1));
}
@@ -1702,7 +1702,7 @@ void Application::setupContextMenu(const char* recipient, MenuItem* items) const
if (actWb) {
// when populating the context-menu of a Python workbench invoke the method
// 'ContextMenu' of the handler object
if (actWb->getTypeId().isDerivedFrom(PythonWorkbench::getClassTypeId())) {
if (actWb->isDerivedFrom<PythonWorkbench>()) {
static_cast<PythonWorkbench*>(actWb)->clearContextMenu();
Base::PyGILStateLocker lock;
PyObject* pWorkbench = nullptr;

View File

@@ -1549,7 +1549,7 @@ void StdCmdPlacement::activated(int iMsg)
auto plm = new Gui::Dialog::TaskPlacement();
if (!sel.empty()) {
App::Property* prop = sel.front()->getPropertyByName("Placement");
if (prop && prop->getTypeId() == App::PropertyPlacement::getClassTypeId()) {
if (prop && prop->is<App::PropertyPlacement>()) {
plm->setPlacement(static_cast<App::PropertyPlacement*>(prop)->getValue());
std::vector<Gui::SelectionObject> selection;

View File

@@ -160,7 +160,7 @@ void StdCmdSendToPythonConsole::activated(int iMsg)
cmd = QString::fromLatin1("doc = App.getDocument(\"%1\")").arg(docname);
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
//support links
if (obj->getTypeId().isDerivedFrom(App::Link::getClassTypeId())) {
if (obj->isDerivedFrom<App::Link>()) {
cmd = QString::fromLatin1("lnk = doc.getObject(\"%1\")").arg(objname);
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
cmd = QString::fromLatin1("obj = lnk.getLinkedObject()");
@@ -171,7 +171,7 @@ void StdCmdSendToPythonConsole::activated(int iMsg)
cmd = QString::fromLatin1("obj = doc.getObject(\"%1\")").arg(objname);
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
}
if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
if (obj->isDerivedFrom<App::GeoFeature>()) {
const auto geoObj = static_cast<const App::GeoFeature*>(obj);
const App::PropertyGeometry* geo = geoObj->getPropertyOfGeometry();
if (geo){

View File

@@ -125,7 +125,7 @@ void StdCmdGroup::activated(int iMsg)
Gui::Document* gui = Application::Instance->activeDocument();
App::Document* app = gui->getDocument();
ViewProvider* vp = gui->getViewProvider(app->getActiveObject());
if (vp && vp->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
if (vp && vp->isDerivedFrom<ViewProviderDocumentObject>())
gui->signalScrollToObject(*static_cast<ViewProviderDocumentObject*>(vp));
}

View File

@@ -242,7 +242,7 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
if (!name)
return;
std::string prop_name = name;
if (prop.getTypeId() == App::PropertyColor::getClassTypeId()) {
if (prop.is<App::PropertyColor>()) {
App::Color value = static_cast<const App::PropertyColor&>(prop).getValue();
if (prop_name == "ShapeColor") {
bool blocked = d->ui.buttonColor->blockSignals(true);
@@ -266,7 +266,7 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
d->ui.buttonPointColor->blockSignals(blocked);
}
}
else if (prop.getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
else if (prop.isDerivedFrom<App::PropertyInteger>()) {
long value = static_cast<const App::PropertyInteger&>(prop).getValue();
if (prop_name == "Transparency") {
bool blocked = d->ui.spinTransparency->blockSignals(true);
@@ -285,7 +285,7 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
d->ui.sliderLineTransparency->blockSignals(blocked);
}
}
else if (prop.getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
else if (prop.isDerivedFrom<App::PropertyFloat>()) {
double value = static_cast<const App::PropertyFloat&>(prop).getValue();
if (prop_name == "PointSize") {
bool blocked = d->ui.spinPointSize->blockSignals(true);

View File

@@ -98,7 +98,7 @@ void DlgMaterialPropertiesImp::onAmbientColorChanged()
for (std::vector<ViewProvider*>::iterator it= Objects.begin(); it != Objects.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName(material.c_str());
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyMaterial>()) {
auto ShapeMaterial = static_cast<App::PropertyMaterial*>(prop);
App::Material mat = ShapeMaterial->getValue();
mat.ambientColor = ambient;
@@ -120,7 +120,7 @@ void DlgMaterialPropertiesImp::onDiffuseColorChanged()
for (std::vector<ViewProvider*>::iterator it = Objects.begin(); it != Objects.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName(material.c_str());
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyMaterial>()) {
auto ShapeMaterial = static_cast<App::PropertyMaterial*>(prop);
App::Material mat = ShapeMaterial->getValue();
mat.diffuseColor = diffuse;
@@ -142,7 +142,7 @@ void DlgMaterialPropertiesImp::onEmissiveColorChanged()
for (std::vector<ViewProvider*>::iterator it = Objects.begin(); it != Objects.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName(material.c_str());
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyMaterial>()) {
auto ShapeMaterial = static_cast<App::PropertyMaterial*>(prop);
App::Material mat = ShapeMaterial->getValue();
mat.emissiveColor = emissive;
@@ -164,7 +164,7 @@ void DlgMaterialPropertiesImp::onSpecularColorChanged()
for (std::vector<ViewProvider*>::iterator it = Objects.begin(); it != Objects.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName(material.c_str());
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyMaterial>()) {
auto ShapeMaterial = static_cast<App::PropertyMaterial*>(prop);
App::Material mat = ShapeMaterial->getValue();
mat.specularColor = specular;
@@ -181,7 +181,7 @@ void DlgMaterialPropertiesImp::onShininessValueChanged(int sh)
float shininess = (float)sh / 100.0f;
for (std::vector<ViewProvider*>::iterator it = Objects.begin(); it != Objects.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName(material.c_str());
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyMaterial>()) {
auto ShapeMaterial = static_cast<App::PropertyMaterial*>(prop);
App::Material mat = ShapeMaterial->getValue();
mat.shininess = shininess;
@@ -199,7 +199,7 @@ void DlgMaterialPropertiesImp::setViewProviders(const std::vector<Gui::ViewProvi
for (std::vector<ViewProvider*>::iterator it = Objects.begin(); it != Objects.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName(material.c_str());
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyMaterial>()) {
auto ShapeMaterial = static_cast<App::PropertyMaterial*>(prop);
App::Material mat = ShapeMaterial->getValue();
int r = int(mat.ambientColor.r * 255.0f);

View File

@@ -627,7 +627,7 @@ void Document::setShow(const char* name)
{
ViewProvider* pcProv = getViewProviderByName(name);
if (pcProv && pcProv->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
if (pcProv && pcProv->isDerivedFrom<ViewProviderDocumentObject>()) {
static_cast<ViewProviderDocumentObject*>(pcProv)->Visibility.setValue(true);
}
}
@@ -637,7 +637,7 @@ void Document::setHide(const char* name)
{
ViewProvider* pcProv = getViewProviderByName(name);
if (pcProv && pcProv->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
if (pcProv && pcProv->isDerivedFrom<ViewProviderDocumentObject>()) {
static_cast<ViewProviderDocumentObject*>(pcProv)->Visibility.setValue(false);
}
}
@@ -1383,7 +1383,7 @@ void Document::Save (Base::Writer &writer) const
size = Base::clamp<int>(size, 64, 512);
std::list<MDIView*> mdi = getMDIViews();
for (const auto & it : mdi) {
if (it->getTypeId().isDerivedFrom(View3DInventor::getClassTypeId())) {
if (it->isDerivedFrom<View3DInventor>()) {
View3DInventorViewer* view = static_cast<View3DInventor*>(it)->getViewer();
d->thumb.setFileName(d->_pcDocument->FileName.getValue());
d->thumb.setSize(size);
@@ -1841,7 +1841,7 @@ Gui::MDIView* Document::cloneView(Gui::MDIView* oldview)
if (!oldview)
return nullptr;
if (oldview->getTypeId() == View3DInventor::getClassTypeId()) {
if (oldview->is<View3DInventor>()) {
auto view3D = new View3DInventor(this, getMainWindow());
auto firstView = static_cast<View3DInventor*>(oldview);

View File

@@ -565,7 +565,7 @@ const Document* DocumentModel::getDocument(const QModelIndex& index) const
return nullptr;
Base::BaseClass* item = nullptr;
item = static_cast<Base::BaseClass*>(index.internalPointer());
if (item->getTypeId() == DocumentIndex::getClassTypeId()) {
if (item->is<DocumentIndex>()) {
const Gui::Document& d = static_cast<DocumentIndex*>(item)->d;
return (&d);
}
@@ -593,7 +593,7 @@ DocumentModel::claimChildren(const Gui::Document& doc, const ViewProviderDocumen
std::vector<App::DocumentObject*> childs = obj.claimChildren();
for (const auto & child : childs) {
ViewProvider* view = doc.getViewProvider(child);
if (view && view->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
if (view && view->isDerivedFrom<ViewProviderDocumentObject>())
views.push_back(static_cast<ViewProviderDocumentObject*>(view));
}

View File

@@ -172,7 +172,7 @@ bool ExpressionBinding::assignToProperty(const std::string & propName, double va
if (prop && prop->isReadOnly())
return true;
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyPlacement>()) {
std::string p = path.getSubPathStr();
if (p == ".Rotation.Angle") {
value = Base::toRadians(value);

View File

@@ -1087,7 +1087,7 @@ bool ManualAlignment::computeAlignment(const std::vector<PickedPoint>& movPts,
*/
void ManualAlignment::alignObject(App::DocumentObject *obj)
{
if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
if (obj->isDerivedFrom<App::GeoFeature>()) {
auto geom = static_cast<App::GeoFeature*>(obj);
geom->transformPlacement(this->myTransform);
}
@@ -1137,7 +1137,7 @@ void ManualAlignment::slotDeletedDocument(const Gui::Document& Doc)
void ManualAlignment::slotDeletedObject(const Gui::ViewProvider& Obj)
{
// remove the view provider either from the left or the right view
if (Obj.getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) {
if (Obj.isDerivedFrom<Gui::ViewProviderDocumentObject>()) {
// remove the view provider immediately from the split window
bool found = false;
auto vp = const_cast<Gui::ViewProviderDocumentObject*>
@@ -1214,7 +1214,7 @@ void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n)
const SoPickedPoint * point = view->getPickedPoint(n);
if (point) {
auto vp = static_cast<Gui::ViewProvider*>(view->getViewProviderByPath(point->getPath()));
if (vp && vp->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) {
if (vp && vp->isDerivedFrom<Gui::ViewProviderDocumentObject>()) {
auto that = static_cast<Gui::ViewProviderDocumentObject*>(vp);
if (self->applyPickedProbe(that, point)) {
const SbVec3f& vec = point->getPoint();

View File

@@ -548,7 +548,7 @@ QString SelectionView::getModule(const char* type) const
QString SelectionView::getProperty(App::DocumentObject* obj) const
{
QString property;
if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
if (obj->isDerivedFrom<App::GeoFeature>()) {
App::GeoFeature* geo = static_cast<App::GeoFeature*>(obj);
const App::PropertyComplexGeoData* data = geo->getPropertyOfGeometry();
const char* name = data ? data->getName() : nullptr;
@@ -562,7 +562,7 @@ QString SelectionView::getProperty(App::DocumentObject* obj) const
bool SelectionView::supportPart(App::DocumentObject* obj, const QString& part) const
{
if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
if (obj->isDerivedFrom<App::GeoFeature>()) {
App::GeoFeature* geo = static_cast<App::GeoFeature*>(obj);
const App::PropertyComplexGeoData* data = geo->getPropertyOfGeometry();
if (data) {

View File

@@ -127,7 +127,7 @@ void TaskAppearance::slotChangedObject(const Gui::ViewProvider& obj,
if (vp != Provider.end()) {
std::string prop_name = obj.getPropertyName(&prop);
if (prop.getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
if (prop.isDerivedFrom<App::PropertyInteger>()) {
long value = static_cast<const App::PropertyInteger&>(prop).getValue();
if (prop_name == "Transparency") {
bool blocked = ui->spinTransparency->blockSignals(true);
@@ -138,7 +138,7 @@ void TaskAppearance::slotChangedObject(const Gui::ViewProvider& obj,
ui->horizontalSlider->blockSignals(blocked);
}
}
else if (prop.getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
else if (prop.isDerivedFrom<App::PropertyFloat>()) {
float value = static_cast<const App::PropertyFloat&>(prop).getValue();
if (prop_name == "PointSize") {
bool blocked = ui->spinPointSize->blockSignals(true);
@@ -163,7 +163,7 @@ void TaskAppearance::onChangeModeActivated(const QString& s)
std::vector<Gui::ViewProvider*> Provider = getSelection();
for (const auto & It : Provider) {
App::Property* prop = It->getPropertyByName("DisplayMode");
if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
if (prop && prop->is<App::PropertyEnumeration>()) {
auto Display = static_cast<App::PropertyEnumeration*>(prop);
Display->setValue((const char*)s.toLatin1());
}
@@ -183,7 +183,7 @@ void TaskAppearance::onTransparencyValueChanged(int transparency)
std::vector<Gui::ViewProvider*> Provider = getSelection();
for (const auto & It : Provider) {
App::Property* prop = It->getPropertyByName("Transparency");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyInteger>()) {
auto Transparency = static_cast<App::PropertyInteger*>(prop);
Transparency->setValue(transparency);
}
@@ -198,7 +198,7 @@ void TaskAppearance::onPointSizeValueChanged(int pointsize)
std::vector<Gui::ViewProvider*> Provider = getSelection();
for (const auto & It : Provider) {
App::Property* prop = It->getPropertyByName("PointSize");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyFloat>()) {
auto PointSize = static_cast<App::PropertyFloat*>(prop);
PointSize->setValue(static_cast<float>(pointsize));
}
@@ -213,7 +213,7 @@ void TaskAppearance::onLineWidthValueChanged(int linewidth)
std::vector<Gui::ViewProvider*> Provider = getSelection();
for (const auto & It : Provider) {
App::Property* prop = It->getPropertyByName("LineWidth");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyFloat>()) {
auto LineWidth = static_cast<App::PropertyFloat*>(prop);
LineWidth->setValue(static_cast<float>(linewidth));
}
@@ -225,7 +225,7 @@ void TaskAppearance::setDisplayModes(const std::vector<Gui::ViewProvider*>& view
QStringList commonModes, modes;
for (auto it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("DisplayMode");
if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
if (prop && prop->is<App::PropertyEnumeration>()) {
auto display = static_cast<App::PropertyEnumeration*>(prop);
if (!display->hasEnums())
return;
@@ -253,7 +253,7 @@ void TaskAppearance::setDisplayModes(const std::vector<Gui::ViewProvider*>& view
// find the display mode to activate
for (const auto view : views) {
App::Property* prop = view->getPropertyByName("DisplayMode");
if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
if (prop && prop->is<App::PropertyEnumeration>()) {
auto display = static_cast<App::PropertyEnumeration*>(prop);
QString activeMode = QString::fromLatin1(display->getValueAsString());
int index = ui->changeMode->findText(activeMode);
@@ -270,7 +270,7 @@ void TaskAppearance::setPointSize(const std::vector<Gui::ViewProvider*>& views)
bool pointSize = false;
for (const auto & view : views) {
App::Property* prop = view->getPropertyByName("PointSize");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyFloat>()) {
bool blocked = ui->spinPointSize->blockSignals(true);
ui->spinPointSize->setValue((int)static_cast<App::PropertyFloat*>(prop)->getValue());
ui->spinPointSize->blockSignals(blocked);
@@ -287,7 +287,7 @@ void TaskAppearance::setLineWidth(const std::vector<Gui::ViewProvider*>& views)
bool lineWidth = false;
for (const auto & view : views) {
App::Property* prop = view->getPropertyByName("LineWidth");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyFloat>()) {
bool blocked = ui->spinLineWidth->blockSignals(true);
ui->spinLineWidth->setValue((int)static_cast<App::PropertyFloat*>(prop)->getValue());
ui->spinLineWidth->blockSignals(blocked);
@@ -304,7 +304,7 @@ void TaskAppearance::setTransparency(const std::vector<Gui::ViewProvider*>& view
bool transparency = false;
for (const auto & view : views) {
App::Property* prop = view->getPropertyByName("Transparency");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyInteger>()) {
bool blocked = ui->spinTransparency->blockSignals(true);
ui->spinTransparency->setValue(static_cast<App::PropertyInteger*>(prop)->getValue());
ui->spinTransparency->blockSignals(blocked);

View File

@@ -125,7 +125,7 @@ void TaskImage::initialiseTransparency()
// NOLINTBEGIN
auto vp = Application::Instance->getViewProvider(feature.get());
App::Property* prop = vp->getPropertyByName("Transparency");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyInteger>()) {
auto Transparency = static_cast<App::PropertyInteger*>(prop);
ui->spinBoxTransparency->setValue(Transparency->getValue());
ui->sliderTransparency->setValue(Transparency->getValue());

View File

@@ -63,10 +63,10 @@ TaskSelectLinkProperty::TaskSelectLinkProperty(const char *sFilter,App::Property
// property have to be set!
assert(prop);
StartObject = nullptr;
if (prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId())) {
if (prop->isDerivedFrom<App::PropertyLinkSub>()) {
LinkSub = dynamic_cast<App::PropertyLinkSub *>(prop);
}
else if (prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) {
else if (prop->isDerivedFrom<App::PropertyLinkList>()) {
LinkList = dynamic_cast<App::PropertyLinkList *>(prop);
}
else {

View File

@@ -72,7 +72,7 @@ Base::Vector3d TransformStrategy::getRotationCenter() const
Base::BoundBox3d bbox;
bool first=true;
for (const auto & object : objects) {
if (object->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
if (object->isDerivedFrom<App::GeoFeature>()) {
// search for a data property
const App::PropertyGeometry* geo = static_cast<App::GeoFeature*>(object)->getPropertyOfGeometry();
if (geo) {
@@ -126,7 +126,7 @@ void TransformStrategy::acceptDataTransform(const Base::Matrix4D& mat, App::Docu
}
// Apply the transformation
if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
if (obj->isDerivedFrom<App::GeoFeature>()) {
// search for a data property
const App::PropertyGeometry* geo = static_cast<App::GeoFeature*>(obj)->getPropertyOfGeometry();
if (geo) {
@@ -225,7 +225,7 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m
std::vector<App::DocumentObject*> sel = Gui::Selection().getObjectsOfType
(App::DocumentObject::getClassTypeId());
for (const auto & it : sel) {
if (it->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
if (it->isDerivedFrom<App::GeoFeature>()) {
// search for a data property
const App::PropertyGeometry* geo = static_cast<App::GeoFeature*>(it)->getPropertyOfGeometry();
if (geo) {

View File

@@ -59,7 +59,7 @@ void TreeView::mouseDoubleClickEvent (QMouseEvent * event)
return;
Base::BaseClass* item = nullptr;
item = static_cast<Base::BaseClass*>(index.internalPointer());
if (item->getTypeId() == Document::getClassTypeId()) {
if (item->is<Document>()) {
QTreeView::mouseDoubleClickEvent(event);
const Gui::Document* doc = static_cast<Gui::Document*>(item);
MDIView *view = doc->getActiveView();
@@ -67,7 +67,7 @@ void TreeView::mouseDoubleClickEvent (QMouseEvent * event)
return;
getMainWindow()->setActiveWindow(view);
}
else if (item->getTypeId().isDerivedFrom(ViewProvider::getClassTypeId())) {
else if (item->isDerivedFrom<ViewProvider>()) {
if (!static_cast<ViewProvider*>(item)->doubleClicked())
QTreeView::mouseDoubleClickEvent(event);
}

View File

@@ -2403,7 +2403,7 @@ void View3DInventorViewer::selectAll()
std::vector<App::DocumentObject*> objs;
for (auto it : _ViewProviderSet) {
if (it->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
if (it->isDerivedFrom<ViewProviderDocumentObject>()) {
auto vp = static_cast<ViewProviderDocumentObject*>(it);
App::DocumentObject* obj = vp->getObject();

View File

@@ -239,7 +239,7 @@ void ViewProviderAnnotation::attach(App::DocumentObject* f)
void ViewProviderAnnotation::updateData(const App::Property* prop)
{
if (prop->getTypeId() == App::PropertyStringList::getClassTypeId() &&
if (prop->is<App::PropertyStringList>() &&
strcmp(prop->getName(),"LabelText") == 0) {
const std::vector<std::string> lines = static_cast<const App::PropertyStringList*>(prop)->getValues();
int index=0;
@@ -261,7 +261,7 @@ void ViewProviderAnnotation::updateData(const App::Property* prop)
index++;
}
}
else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() &&
else if (prop->is<App::PropertyVector>() &&
strcmp(prop->getName(),"Position") == 0) {
Base::Vector3d v = static_cast<const App::PropertyVector*>(prop)->getValue();
pTranslation->translation.setValue(v.x,v.y,v.z);
@@ -324,7 +324,7 @@ void ViewProviderAnnotationLabel::onChanged(const App::Property* prop)
prop == &FontName || prop == &Frame) {
if (getObject()) {
App::Property* label = getObject()->getPropertyByName("LabelText");
if (label && label->getTypeId() == App::PropertyStringList::getClassTypeId())
if (label && label->is<App::PropertyStringList>())
drawImage(static_cast<App::PropertyStringList*>(label)->getValues());
}
}
@@ -380,16 +380,16 @@ void ViewProviderAnnotationLabel::attach(App::DocumentObject* f)
void ViewProviderAnnotationLabel::updateData(const App::Property* prop)
{
if (prop->getTypeId() == App::PropertyStringList::getClassTypeId() &&
if (prop->is<App::PropertyStringList>() &&
strcmp(prop->getName(),"LabelText") == 0) {
drawImage(static_cast<const App::PropertyStringList*>(prop)->getValues());
}
else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() &&
else if (prop->is<App::PropertyVector>() &&
strcmp(prop->getName(),"BasePosition") == 0) {
Base::Vector3d v = static_cast<const App::PropertyVector*>(prop)->getValue();
pBaseTranslation->translation.setValue(v.x,v.y,v.z);
}
else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() &&
else if (prop->is<App::PropertyVector>() &&
strcmp(prop->getName(),"TextPosition") == 0) {
Base::Vector3d v = static_cast<const App::PropertyVector*>(prop)->getValue();
pCoords->point.set1Value(1, SbVec3f(v.x,v.y,v.z));
@@ -427,7 +427,7 @@ void ViewProviderAnnotationLabel::dragMotionCallback(void *data, SoDragger *drag
auto that = static_cast<ViewProviderAnnotationLabel*>(data);
const SbMatrix& mat = drag->getMotionMatrix();
App::DocumentObject* obj = that->getObject();
if (obj && obj->getTypeId() == App::AnnotationLabel::getClassTypeId()) {
if (obj && obj->is<App::AnnotationLabel>()) {
static_cast<App::AnnotationLabel*>(obj)->TextPosition.setValue(mat[3][0],mat[3][1],mat[3][2]);
}
}

View File

@@ -70,13 +70,13 @@ QIcon ViewProviderDocumentObjectGroup::getIcon() const
void ViewProviderDocumentObjectGroup::getViewProviders(std::vector<ViewProviderDocumentObject*>& vp) const
{
App::DocumentObject* doc = getObject();
if (doc->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) {
if (doc->isDerivedFrom<App::DocumentObjectGroup>()) {
Gui::Document* gd = Application::Instance->getDocument(doc->getDocument());
auto grp = static_cast<App::DocumentObjectGroup*>(doc);
std::vector<App::DocumentObject*> obj = grp->getObjects();
for (const auto & it : obj) {
ViewProvider* v = gd->getViewProvider(it);
if (v && v->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
if (v && v->isDerivedFrom<ViewProviderDocumentObject>())
vp.push_back(static_cast<ViewProviderDocumentObject*>(v));
}
}

View File

@@ -2620,7 +2620,7 @@ bool ViewProviderLink::initDraggingPlacement() {
Base::PyGILStateLocker lock;
try {
auto* proxy = getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
if (proxy && proxy->is<App::PropertyPythonObject>()) {
Py::Object feature = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
const char *fname = "initDraggingPlacement";
if (feature.hasAttr(fname)) {
@@ -2940,7 +2940,7 @@ bool ViewProviderLink::callDraggerProxy(const char *fname, bool update) {
Base::PyGILStateLocker lock;
try {
auto* proxy = getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
if (proxy && proxy->is<App::PropertyPythonObject>()) {
Py::Object feature = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (feature.hasAttr(fname)) {
Py::Callable method(feature.getAttr(fname));

View File

@@ -196,7 +196,7 @@ void ViewProviderMeasureDistance::attach(App::DocumentObject* pcObject)
void ViewProviderMeasureDistance::updateData(const App::Property* prop)
{
if (prop->getTypeId() == App::PropertyVector::getClassTypeId() ||
if (prop->is<App::PropertyVector>() ||
prop == &Mirror || prop == &DistFactor) {
if (strcmp(prop->getName(),"P1") == 0) {
Base::Vector3d v = static_cast<const App::PropertyVector*>(prop)->getValue();

View File

@@ -100,7 +100,7 @@ void ViewProviderOriginFeature::attach(App::DocumentObject* pcObject)
// Setup font size
auto font = new SoFont ();
float fontRatio = 10.0f;
if ( pcObject->getTypeId() == App::Line::getClassTypeId() ) {
if ( pcObject->is<App::Line>() ) {
// keep font size on axes equal to font size on planes
fontRatio *= ViewProviderOrigin::axesScaling;
const char* axisName = pcObject->getNameInDocument();

View File

@@ -236,7 +236,7 @@ void Workbench::setupCustomToolbars(ToolBarItem* root, const char* toolbar) cons
}
// for this workbench global toolbars are not allowed
if (getTypeId() == NoneWorkbench::getClassTypeId()) {
if (is<NoneWorkbench>()) {
return;
}

View File

@@ -746,7 +746,7 @@ PropertyStringItem::PropertyStringItem() = default;
QVariant PropertyStringItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyString::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyString>());
std::string value = static_cast<const App::PropertyString*>(prop)->getValue();
return {QString::fromUtf8(value.c_str())};
@@ -798,7 +798,7 @@ PropertyFontItem::PropertyFontItem() = default;
QVariant PropertyFontItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFont::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyFont>());
std::string value = static_cast<const App::PropertyFont*>(prop)->getValue();
return {QString::fromUtf8(value.c_str())};
@@ -861,7 +861,7 @@ PropertyIntegerItem::PropertyIntegerItem() = default;
QVariant PropertyIntegerItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyInteger>());
int value = (int)static_cast<const App::PropertyInteger*>(prop)->getValue();
return {value};
@@ -926,7 +926,7 @@ PropertyIntegerConstraintItem::PropertyIntegerConstraintItem() = default;
QVariant PropertyIntegerConstraintItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyIntegerConstraint::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyIntegerConstraint>());
int value = (int)static_cast<const App::PropertyIntegerConstraint*>(prop)->getValue();
return {value};
@@ -1018,7 +1018,7 @@ QVariant PropertyFloatItem::toString(const QVariant& prop) const
QVariant PropertyFloatItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyFloat>());
double value = static_cast<const App::PropertyFloat*>(prop)->getValue();
return {value};
@@ -1084,7 +1084,7 @@ QVariant PropertyUnitItem::toString(const QVariant& prop) const
QVariant PropertyUnitItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyQuantity>());
Base::Quantity value = static_cast<const App::PropertyQuantity*>(prop)->getQuantityValue();
return QVariant::fromValue<Base::Quantity>(value);
@@ -1187,7 +1187,7 @@ QVariant PropertyFloatConstraintItem::toString(const QVariant& prop) const
QVariant PropertyFloatConstraintItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFloatConstraint::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyFloatConstraint>());
double value = static_cast<const App::PropertyFloatConstraint*>(prop)->getValue();
return {value};
@@ -1284,7 +1284,7 @@ PropertyBoolItem::PropertyBoolItem() = default;
QVariant PropertyBoolItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyBool::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyBool>());
bool value = static_cast<const App::PropertyBool*>(prop)->getValue();
return {value};
@@ -1391,7 +1391,7 @@ QVariant PropertyVectorItem::toString(const QVariant& prop) const
QVariant PropertyVectorItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyVector::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyVector>());
const Base::Vector3d& value = static_cast<const App::PropertyVector*>(prop)->getValue();
return QVariant::fromValue<Base::Vector3d>(value);
@@ -1604,7 +1604,7 @@ QVariant PropertyVectorListItem::toString(const QVariant& prop) const
QVariant PropertyVectorListItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyVectorList::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyVectorList>());
const std::vector<Base::Vector3d>& value = static_cast<const App::PropertyVectorList*>(prop)->getValue();
QList<Base::Vector3d> list;
@@ -1685,7 +1685,7 @@ QVariant PropertyVectorDistanceItem::toString(const QVariant& prop) const
QVariant PropertyVectorDistanceItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyVector::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyVector>());
const Base::Vector3d& value = static_cast<const App::PropertyVector*>(prop)->getValue();
return QVariant::fromValue<Base::Vector3d>(value);
@@ -1894,7 +1894,7 @@ QVariant PropertyMatrixItem::toString(const QVariant& prop) const
QVariant PropertyMatrixItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMatrix::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyMatrix>());
const Base::Matrix4D& value = static_cast<const App::PropertyMatrix*>(prop)->getValue();
return QVariant::fromValue<Base::Matrix4D>(value);
@@ -1902,7 +1902,7 @@ QVariant PropertyMatrixItem::value(const App::Property* prop) const
QVariant PropertyMatrixItem::toolTip(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMatrix::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyMatrix>());
const Base::Matrix4D& value = static_cast<const App::PropertyMatrix*>(prop)->getValue();
return {QString::fromStdString(value.analyse())};
@@ -2294,7 +2294,7 @@ void PropertyRotationItem::assignProperty(const App::Property* prop)
// Choose an adaptive epsilon to avoid changing the axis when they are considered to
// be equal. See https://forum.freecad.org/viewtopic.php?f=10&t=24662&start=10
double eps = std::pow(10.0, -2*(decimals()+1));
if (prop->getTypeId().isDerivedFrom(App::PropertyRotation::getClassTypeId())) {
if (prop->isDerivedFrom<App::PropertyRotation>()) {
const Base::Rotation& value = static_cast<const App::PropertyRotation*>(prop)->getValue();
h.assignProperty(value, eps);
}
@@ -2302,7 +2302,7 @@ void PropertyRotationItem::assignProperty(const App::Property* prop)
QVariant PropertyRotationItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyRotation::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyRotation>());
const Base::Rotation& value = static_cast<const App::PropertyRotation*>(prop)->getValue();
double angle;
@@ -2339,7 +2339,7 @@ QVariant PropertyRotationItem::value(const App::Property* prop) const
QVariant PropertyRotationItem::toolTip(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyRotation::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyRotation>());
const Base::Rotation& p = static_cast<const App::PropertyRotation*>(prop)->getValue();
double angle;
@@ -2586,7 +2586,7 @@ void PropertyPlacementItem::assignProperty(const App::Property* prop)
// Choose an adaptive epsilon to avoid changing the axis when they are considered to
// be equal. See https://forum.freecad.org/viewtopic.php?f=10&t=24662&start=10
double eps = std::pow(10.0, -2*(decimals()+1));
if (prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) {
if (prop->isDerivedFrom<App::PropertyPlacement>()) {
const Base::Placement& value = static_cast<const App::PropertyPlacement*>(prop)->getValue();
h.assignProperty(value.getRotation(), eps);
}
@@ -2594,7 +2594,7 @@ void PropertyPlacementItem::assignProperty(const App::Property* prop)
QVariant PropertyPlacementItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyPlacement>());
const Base::Placement& value = static_cast<const App::PropertyPlacement*>(prop)->getValue();
double angle;
@@ -2631,7 +2631,7 @@ QVariant PropertyPlacementItem::value(const App::Property* prop) const
QVariant PropertyPlacementItem::toolTip(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyPlacement>());
const Base::Placement& p = static_cast<const App::PropertyPlacement*>(prop)->getValue();
double angle;
@@ -2769,7 +2769,7 @@ QStringList PropertyEnumItem::getEnum() const
{
QStringList res;
auto prop = getFirstProperty();
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyEnumeration::getClassTypeId())) {
if (prop && prop->isDerivedFrom<App::PropertyEnumeration>()) {
const auto prop_enum = static_cast<const App::PropertyEnumeration*>(prop);
std::vector<std::string> enums = prop_enum->getEnumVector();
for (const auto& it : enums)
@@ -2780,7 +2780,7 @@ QStringList PropertyEnumItem::getEnum() const
QVariant PropertyEnumItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyEnumeration::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyEnumeration>());
const auto prop_enum = static_cast<const App::PropertyEnumeration*>(prop);
if(!prop_enum->isValid())
@@ -2857,7 +2857,7 @@ QWidget* PropertyEnumItem::createEditor(QWidget* parent, const QObject* receiver
QStringList commonModes, modes;
for (auto it = items.begin(); it != items.end(); ++it) {
if ((*it)->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
if ((*it)->is<App::PropertyEnumeration>()) {
auto prop = static_cast<App::PropertyEnumeration*>(*it);
if (!prop->hasEnums()) {
commonModes.clear();
@@ -3012,7 +3012,7 @@ QVariant PropertyStringListItem::toString(const QVariant& prop) const
QVariant PropertyStringListItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyStringList::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyStringList>());
QStringList list;
const std::vector<std::string>& value = (static_cast<const App::PropertyStringList*>(prop))->getValues();
for (const auto & jt : value) {
@@ -3088,7 +3088,7 @@ QVariant PropertyFloatListItem::toString(const QVariant& prop) const
QVariant PropertyFloatListItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFloatList::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyFloatList>());
QStringList list;
const std::vector<double>& value = static_cast<const App::PropertyFloatList*>(prop)->getValues();
@@ -3161,7 +3161,7 @@ QVariant PropertyIntegerListItem::toString(const QVariant& prop) const
QVariant PropertyIntegerListItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyIntegerList::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyIntegerList>());
QStringList list;
const std::vector<long>& value = static_cast<const App::PropertyIntegerList*>(prop)->getValues();
@@ -3216,7 +3216,7 @@ QVariant PropertyColorItem::toString(const QVariant& prop) const
QVariant PropertyColorItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyColor::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyColor>());
App::Color value = static_cast<const App::PropertyColor*>(prop)->getValue();
return QVariant(value.asValue<QColor>());
@@ -3467,7 +3467,7 @@ QVariant PropertyMaterialItem::toString(const QVariant& prop) const
QVariant PropertyMaterialItem::toolTip(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyMaterial>());
const App::Material& value = static_cast<const App::PropertyMaterial*>(prop)->getValue();
auto dc = value.diffuseColor.asValue<QColor>();
@@ -3496,7 +3496,7 @@ QVariant PropertyMaterialItem::toolTip(const App::Property* prop) const
QVariant PropertyMaterialItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyMaterial>());
const App::Material& value = static_cast<const App::PropertyMaterial*>(prop)->getValue();
Material mat;
@@ -3888,7 +3888,7 @@ QVariant PropertyMaterialListItem::toString(const QVariant& prop) const
QVariant PropertyMaterialListItem::toolTip(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterialList::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyMaterialList>());
const std::vector<App::Material>& values = static_cast<const App::PropertyMaterialList*>(prop)->getValues();
if (values.empty())
@@ -3921,7 +3921,7 @@ QVariant PropertyMaterialListItem::toolTip(const App::Property* prop) const
QVariant PropertyMaterialListItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterialList::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyMaterialList>());
const std::vector<App::Material>& value = static_cast<const App::PropertyMaterialList*>(prop)->getValues();
QVariantList variantList;
@@ -4054,7 +4054,7 @@ PropertyFileItem::PropertyFileItem() = default;
QVariant PropertyFileItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFile::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyFile>());
std::string value = static_cast<const App::PropertyFile*>(prop)->getValue();
return {QString::fromUtf8(value.c_str())};
@@ -4111,7 +4111,7 @@ PropertyPathItem::PropertyPathItem() = default;
QVariant PropertyPathItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyPath::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyPath>());
std::string value = static_cast<const App::PropertyPath*>(prop)->getValue().string();
return {QString::fromUtf8(value.c_str())};
@@ -4161,7 +4161,7 @@ PropertyTransientFileItem::PropertyTransientFileItem() = default;
QVariant PropertyTransientFileItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFileIncluded::getClassTypeId()));
assert(prop && prop->isDerivedFrom<App::PropertyFileIncluded>());
std::string value = static_cast<const App::PropertyFileIncluded*>(prop)->getValue();
return {QString::fromUtf8(value.c_str())};