From 0382f276a297c33363039e2ef6b0e5464e0cd2e8 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Fri, 17 Jun 2022 12:00:26 -0300 Subject: [PATCH] Gui: Replace C cast --- src/Gui/Action.cpp | 2 +- src/Gui/Application.cpp | 2 +- src/Gui/CallTips.cpp | 10 +-- src/Gui/Command.cpp | 2 +- src/Gui/CommandView.cpp | 2 +- src/Gui/DlgActivateWindowImp.cpp | 2 +- src/Gui/DlgDisplayPropertiesImp.cpp | 22 +++---- src/Gui/DlgMaterialPropertiesImp.cpp | 12 ++-- src/Gui/DlgPreferencesImp.cpp | 10 +-- src/Gui/DlgSettingsUnitsImp.cpp | 4 +- src/Gui/Document.cpp | 4 +- src/Gui/Inventor/SoAutoZoomTranslation.cpp | 14 +++-- src/Gui/LinkViewPyImp.cpp | 4 +- src/Gui/NavigationStyle.cpp | 17 +++--- src/Gui/OnlineDocumentation.cpp | 4 +- src/Gui/ReportView.cpp | 2 +- src/Gui/Selection.cpp | 2 +- src/Gui/SoFCBoundingBox.cpp | 12 ++-- src/Gui/SoFCSelection.cpp | 67 +++++++++++---------- src/Gui/SoFCSelectionAction.cpp | 12 ++-- src/Gui/SoFCUnifiedSelection.cpp | 20 +++--- src/Gui/SoNavigationDragger.cpp | 6 +- src/Gui/TaskView/TaskAppearance.cpp | 12 ++-- src/Gui/TaskView/TaskDialogPython.cpp | 10 +-- src/Gui/TextEdit.cpp | 2 +- src/Gui/UiLoader.cpp | 2 +- src/Gui/View3DPy.cpp | 14 ++--- src/Gui/View3DViewerPy.cpp | 6 +- src/Gui/ViewProvider.cpp | 2 +- src/Gui/ViewProviderDocumentObjectGroup.cpp | 4 +- src/Gui/ViewProviderExtern.cpp | 2 +- src/Gui/ViewProviderLink.cpp | 4 +- src/Gui/ViewProviderPyImp.cpp | 2 +- src/Gui/ViewProviderPythonFeature.cpp | 6 +- src/Gui/WidgetFactory.cpp | 6 +- src/Gui/propertyeditor/PropertyItem.cpp | 4 +- 36 files changed, 156 insertions(+), 152 deletions(-) diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index 261a5612fc..689fd2ee11 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -613,7 +613,7 @@ void WorkbenchGroup::refreshWorkbenchList() void WorkbenchGroup::customEvent( QEvent* e ) { if (e->type() == QEvent::User) { - auto ce = (Gui::WorkbenchActionEvent*)e; + auto ce = static_cast(e); ce->action()->trigger(); } } diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 53c167b790..4e23c8444c 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -242,7 +242,7 @@ FreeCADGui_subgraphFromObject(PyObject * /*self*/, PyObject *args) type += " *"; PyObject* proxy = nullptr; - proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), (void*)node, 1); + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), static_cast(node), 1); return Py::new_reference_to(Py::Object(proxy, true)); } } diff --git a/src/Gui/CallTips.cpp b/src/Gui/CallTips.cpp index 8be8fccf48..5046dbdabf 100644 --- a/src/Gui/CallTips.cpp +++ b/src/Gui/CallTips.cpp @@ -300,7 +300,7 @@ QMap CallTipsList::extractTips(const QString& context) const // names. So, we add these names to the list, too. PyObject* appdoctypeobj = Base::getTypeAsObject(&App::DocumentPy::Type); if (PyObject_IsSubclass(type.ptr(), appdoctypeobj) == 1) { - auto docpy = (App::DocumentPy*)(inst.ptr()); + auto docpy = static_cast(inst.ptr()); auto document = docpy->getDocumentPtr(); // Make sure that the C++ object is alive if (document) { @@ -316,7 +316,7 @@ QMap CallTipsList::extractTips(const QString& context) const // names. So, we add these names to the list, too. PyObject* guidoctypeobj = Base::getTypeAsObject(&Gui::DocumentPy::Type); if (PyObject_IsSubclass(type.ptr(), guidoctypeobj) == 1) { - auto docpy = (Gui::DocumentPy*)(inst.ptr()); + auto docpy = static_cast(inst.ptr()); if (docpy->getDocumentPtr()) { App::Document* document = docpy->getDocumentPtr()->getDocument(); // Make sure that the C++ object is alive @@ -426,7 +426,7 @@ void CallTipsList::extractTipsFromObject(Py::Object& obj, Py::List& list, QMap& tips) const { - auto cont = (App::PropertyContainerPy*)(obj.ptr()); + auto cont = static_cast(obj.ptr()); App::PropertyContainer* container = cont->getPropertyContainerPtr(); // Make sure that the C++ object is alive if (!container) @@ -605,7 +605,7 @@ bool CallTipsList::eventFilter(QObject * watched, QEvent * event) } else if (isVisible() && watched == textEdit) { if (event->type() == QEvent::KeyPress) { - auto ke = (QKeyEvent*)event; + auto ke = static_cast(event); if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { keyPressEvent(ke); return true; @@ -648,7 +648,7 @@ bool CallTipsList::eventFilter(QObject * watched, QEvent * event) } } else if (event->type() == QEvent::KeyRelease) { - auto* ke = (QKeyEvent*)event; + auto ke = static_cast(event); if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down || ke->key() == Qt::Key_PageUp || ke->key() == Qt::Key_PageDown) { QList items = selectedItems(); diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index 4340e61b40..dd7e9b780d 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -927,7 +927,7 @@ const char* Command::keySequenceToAccel(int sk) const if (i != strings.end()) return i->second.c_str(); - auto type = (QKeySequence::StandardKey)sk; + auto type = static_cast(sk); QKeySequence ks(type); QString qs = ks.toString(); QByteArray data = qs.toLatin1(); diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 0aef32e356..7b5f36cc92 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -558,7 +558,7 @@ StdCmdToggleClipPlane::StdCmdToggleClipPlane() Action * StdCmdToggleClipPlane::createAction() { - auto pcAction = (Action*)Command::createAction(); + Action *pcAction = Command::createAction(); return pcAction; } diff --git a/src/Gui/DlgActivateWindowImp.cpp b/src/Gui/DlgActivateWindowImp.cpp index ded4999f32..e134bfe65d 100644 --- a/src/Gui/DlgActivateWindowImp.cpp +++ b/src/Gui/DlgActivateWindowImp.cpp @@ -95,7 +95,7 @@ void DlgActivateWindowImp::accept() if (item) { int index = ui->treeWidget->indexOfTopLevelItem(item); - getMainWindow()->setActiveWindow((MDIView*)windows.at(index)); + getMainWindow()->setActiveWindow(static_cast(windows.at(index))); } QDialog::accept(); diff --git a/src/Gui/DlgDisplayPropertiesImp.cpp b/src/Gui/DlgDisplayPropertiesImp.cpp index 17f4c7dae4..7a783f8807 100644 --- a/src/Gui/DlgDisplayPropertiesImp.cpp +++ b/src/Gui/DlgDisplayPropertiesImp.cpp @@ -277,7 +277,7 @@ void DlgDisplayPropertiesImp::on_changeMaterial_activated(int index) for (auto It= Provider.begin(); It != Provider.end(); ++It) { App::Property* prop = (*It)->getPropertyByName("ShapeMaterial"); if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) { - auto ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = static_cast(prop); ShapeMaterial->setValue(mat); } } @@ -293,8 +293,8 @@ void DlgDisplayPropertiesImp::on_changeMode_activated(const QString& s) for (auto It= Provider.begin();It!=Provider.end();++It) { App::Property* prop = (*It)->getPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { - auto Display = (App::PropertyEnumeration*)prop; - Display->setValue((const char*)s.toLatin1()); + auto Display = static_cast(prop); + Display->setValue(static_cast(s.toLatin1())); } } } @@ -315,7 +315,7 @@ void DlgDisplayPropertiesImp::on_buttonColor_changed() for (auto It= Provider.begin();It!=Provider.end();++It) { App::Property* prop = (*It)->getPropertyByName("ShapeColor"); if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { - auto ShapeColor = (App::PropertyColor*)prop; + auto ShapeColor = static_cast(prop); ShapeColor->setValue(c); } } @@ -330,7 +330,7 @@ void DlgDisplayPropertiesImp::on_spinTransparency_valueChanged(int transparency) for (auto It= Provider.begin();It!=Provider.end();++It) { App::Property* prop = (*It)->getPropertyByName("Transparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { - auto Transparency = (App::PropertyInteger*)prop; + auto Transparency = static_cast(prop); Transparency->setValue(transparency); } } @@ -345,8 +345,8 @@ void DlgDisplayPropertiesImp::on_spinPointSize_valueChanged(int pointsize) for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("PointSize"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - auto PointSize = (App::PropertyFloat*)prop; - PointSize->setValue((double)pointsize); + auto PointSize = static_cast(prop); + PointSize->setValue(static_cast(pointsize)); } } } @@ -360,8 +360,8 @@ void DlgDisplayPropertiesImp::on_spinLineWidth_valueChanged(int linewidth) for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("LineWidth"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - auto LineWidth = (App::PropertyFloat*)prop; - LineWidth->setValue((double)linewidth); + auto LineWidth = static_cast(prop); + LineWidth->setValue(static_cast(linewidth)); } } } @@ -374,7 +374,7 @@ void DlgDisplayPropertiesImp::on_buttonLineColor_changed() for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("LineColor"); if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { - auto ShapeColor = (App::PropertyColor*)prop; + auto ShapeColor = static_cast(prop); ShapeColor->setValue(c); } } @@ -386,7 +386,7 @@ void DlgDisplayPropertiesImp::on_spinLineTransparency_valueChanged(int transpare for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("LineTransparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { - auto Transparency = (App::PropertyInteger*)prop; + auto Transparency = static_cast(prop); Transparency->setValue(transparency); } } diff --git a/src/Gui/DlgMaterialPropertiesImp.cpp b/src/Gui/DlgMaterialPropertiesImp.cpp index ae16c78a73..ec0a7d8fa7 100644 --- a/src/Gui/DlgMaterialPropertiesImp.cpp +++ b/src/Gui/DlgMaterialPropertiesImp.cpp @@ -84,7 +84,7 @@ void DlgMaterialPropertiesImp::on_ambientColor_changed() for (std::vector::iterator it= Objects.begin(); it != Objects.end(); ++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - auto ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.ambientColor = ambient; ShapeMaterial->setValue(mat); @@ -106,7 +106,7 @@ void DlgMaterialPropertiesImp::on_diffuseColor_changed() for (std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - auto ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.diffuseColor = diffuse; ShapeMaterial->setValue(mat); @@ -128,7 +128,7 @@ void DlgMaterialPropertiesImp::on_emissiveColor_changed() for (std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - auto ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.emissiveColor = emissive; ShapeMaterial->setValue(mat); @@ -150,7 +150,7 @@ void DlgMaterialPropertiesImp::on_specularColor_changed() for (std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - auto ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.specularColor = specular; ShapeMaterial->setValue(mat); @@ -167,7 +167,7 @@ void DlgMaterialPropertiesImp::on_shininess_valueChanged(int sh) for (std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - auto ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.shininess = shininess; ShapeMaterial->setValue(mat); @@ -185,7 +185,7 @@ void DlgMaterialPropertiesImp::setViewProviders(const std::vector::iterator it= Objects.begin();it!=Objects.end();++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { - auto ShapeMaterial = (App::PropertyMaterial*)prop; + auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); int r = int(mat.ambientColor.r * 255.0f); int g = int(mat.ambientColor.g * 255.0f); diff --git a/src/Gui/DlgPreferencesImp.cpp b/src/Gui/DlgPreferencesImp.cpp index 423d2c6a73..a23d9fc0bb 100644 --- a/src/Gui/DlgPreferencesImp.cpp +++ b/src/Gui/DlgPreferencesImp.cpp @@ -292,7 +292,7 @@ void DlgPreferencesImp::activateGroupPage(const QString& group, int index) QListWidgetItem* item = ui->listBox->item(i); if (item->data(GroupNameRole).toString() == group) { ui->listBox->setCurrentItem(item); - auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = static_cast(ui->tabWidgetStack->widget(i)); tabWidget->setCurrentIndex(index); break; } @@ -400,7 +400,7 @@ void DlgPreferencesImp::applyChanges() // cancel further operation in other methods (like in accept()). try { for (int i=0; itabWidgetStack->count(); i++) { - auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = static_cast(ui->tabWidgetStack->widget(i)); for (int j=0; jcount(); j++) { QWidget* page = tabWidget->widget(j); int index = page->metaObject()->indexOfMethod("checkSettings()"); @@ -425,7 +425,7 @@ void DlgPreferencesImp::applyChanges() // If everything is ok (i.e., no validation problem), call method // saveSettings() in every subpage (DlgSetting*) object. for (int i=0; itabWidgetStack->count(); i++) { - auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = static_cast(ui->tabWidgetStack->widget(i)); for (int j=0; jcount(); j++) { auto page = qobject_cast(tabWidget->widget(j)); if (page) @@ -495,7 +495,7 @@ void DlgPreferencesImp::changeEvent(QEvent *e) ui->retranslateUi(this); // update the widgets' tabs for (int i=0; itabWidgetStack->count(); i++) { - auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = static_cast(ui->tabWidgetStack->widget(i)); for (int j=0; jcount(); j++) { QWidget* page = tabWidget->widget(j); tabWidget->setTabText(j, page->windowTitle()); @@ -515,7 +515,7 @@ void DlgPreferencesImp::changeEvent(QEvent *e) void DlgPreferencesImp::reload() { for (int i = 0; i < ui->tabWidgetStack->count(); i++) { - auto tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i); + auto tabWidget = static_cast(ui->tabWidgetStack->widget(i)); for (int j = 0; j < tabWidget->count(); j++) { auto page = qobject_cast(tabWidget->widget(j)); if (page) diff --git a/src/Gui/DlgSettingsUnitsImp.cpp b/src/Gui/DlgSettingsUnitsImp.cpp index 7ee25c36b2..5805976699 100644 --- a/src/Gui/DlgSettingsUnitsImp.cpp +++ b/src/Gui/DlgSettingsUnitsImp.cpp @@ -96,7 +96,7 @@ void DlgSettingsUnitsImp::on_comboBox_ViewSystem_currentIndexChanged(int index) return; // happens when clearing the combo box in retranslateUi() // Enable/disable the fractional inch option depending on system - if( (UnitSystem)index == UnitSystem::ImperialBuilding ) + if( static_cast(index) == UnitSystem::ImperialBuilding ) { ui->comboBox_FracInch->setEnabled(true); } @@ -135,7 +135,7 @@ void DlgSettingsUnitsImp::saveSettings() // Set and save the Unit System viewSystemIndex = ui->comboBox_ViewSystem->currentIndex(); - UnitsApi::setSchema((UnitSystem)viewSystemIndex); + UnitsApi::setSchema(static_cast(viewSystemIndex)); } void DlgSettingsUnitsImp::loadSettings() diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index d8790be87f..05989dae13 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -619,7 +619,7 @@ void Document::setShow(const char* name) ViewProvider* pcProv = getViewProviderByName(name); if (pcProv && pcProv->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) { - ((ViewProviderDocumentObject*)pcProv)->Visibility.setValue(true); + static_cast(pcProv)->Visibility.setValue(true); } } @@ -629,7 +629,7 @@ void Document::setHide(const char* name) ViewProvider* pcProv = getViewProviderByName(name); if (pcProv && pcProv->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) { - ((ViewProviderDocumentObject*)pcProv)->Visibility.setValue(false); + static_cast(pcProv)->Visibility.setValue(false); } } diff --git a/src/Gui/Inventor/SoAutoZoomTranslation.cpp b/src/Gui/Inventor/SoAutoZoomTranslation.cpp index f708597243..241fe47516 100644 --- a/src/Gui/Inventor/SoAutoZoomTranslation.cpp +++ b/src/Gui/Inventor/SoAutoZoomTranslation.cpp @@ -25,6 +25,10 @@ #ifndef _PreComp_ # include # include +# include +# include +# include +# include # include # include # include @@ -83,7 +87,7 @@ SoAutoZoomTranslation::SoAutoZoomTranslation() void SoAutoZoomTranslation::GLRender(SoGLRenderAction * action) { - SoAutoZoomTranslation::doAction((SoAction *)action); + SoAutoZoomTranslation::doAction(static_cast(action)); inherited::GLRender(action); } @@ -130,21 +134,21 @@ void SoAutoZoomTranslation::getMatrix(SoGetMatrixAction * action) void SoAutoZoomTranslation::callback(SoCallbackAction * action) { - SoAutoZoomTranslation::doAction((SoAction*)action); + SoAutoZoomTranslation::doAction(static_cast(action)); } void SoAutoZoomTranslation::getBoundingBox(SoGetBoundingBoxAction * action) { - SoAutoZoomTranslation::doAction((SoAction*)action); + SoAutoZoomTranslation::doAction(static_cast(action)); } void SoAutoZoomTranslation::pick(SoPickAction * action) { - SoAutoZoomTranslation::doAction((SoAction*)action); + SoAutoZoomTranslation::doAction(static_cast(action)); } // Doc in superclass. void SoAutoZoomTranslation::getPrimitiveCount(SoGetPrimitiveCountAction * action) { - SoAutoZoomTranslation::doAction((SoAction*)action); + SoAutoZoomTranslation::doAction(static_cast(action)); } diff --git a/src/Gui/LinkViewPyImp.cpp b/src/Gui/LinkViewPyImp.cpp index d10860e2eb..a8b10b6e78 100644 --- a/src/Gui/LinkViewPyImp.cpp +++ b/src/Gui/LinkViewPyImp.cpp @@ -194,7 +194,7 @@ PyObject* LinkViewPy::setChildren(PyObject *args) { links.setPyObject(pyObj); if(pyVis!=Py_None) vis.setPyObject(pyVis); - getLinkViewPtr()->setChildren(links.getValue(),vis.getValue(),(LinkView::SnapshotType)type); + getLinkViewPtr()->setChildren(links.getValue(),vis.getValue(),static_cast(type)); Py_Return; } PY_CATCH; } @@ -304,7 +304,7 @@ PyObject* LinkViewPy::getDetailPath(PyObject* args) getLinkViewPtr()->linkGetDetailPath(sub,static_cast(pPath),det); if(!det) Py_Return; - return Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoDetail *", (void*)det, 0); + return Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoDetail *", static_cast(det), 0); }PY_CATCH } diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 64e7d8a770..d239079b97 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -584,7 +584,7 @@ void NavigationStyle::viewAll() float aspect = cam->aspectRatio.getValue(); if (cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) { - auto ocam = (SoOrthographicCamera *)cam; // safe downward cast, knows the type + auto ocam = static_cast(cam); if (aspect < 1.0f) ocam->height = cam_height / aspect; else @@ -692,7 +692,8 @@ void NavigationStyle::zoom(SoCamera * cam, float diffvalue) // of the word won't have any visible effect. So we just increase // or decrease the field-of-view values of the camera instead, to // "shrink" the projection size of the model / scene. - auto oc = (SoOrthographicCamera *)cam; + + auto oc = static_cast(cam); oc->height = oc->height.getValue() * multiplicator; } @@ -1478,12 +1479,8 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev) // check for left click without selecting something if ((curmode == NavigationStyle::SELECTION || curmode == NavigationStyle::IDLE) && !processed) { - if (ev->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - auto const e = (SoMouseButtonEvent *) ev; - if (SoMouseButtonEvent::isButtonReleaseEvent(e,SoMouseButtonEvent::BUTTON1)) { - Gui::Selection().clearSelection(); - } - } + if (SoMouseButtonEvent::isButtonReleaseEvent(ev,SoMouseButtonEvent::BUTTON1)) + Gui::Selection().clearSelection(); } return processed; @@ -1526,7 +1523,7 @@ void NavigationStyle::syncWithEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - auto const event = (const SoKeyboardEvent *) ev; + auto const event = static_cast(ev); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; switch (event->getKey()) { case SoKeyboardEvent::LEFT_CONTROL: @@ -1548,7 +1545,7 @@ void NavigationStyle::syncWithEvent(const SoEvent * const ev) // Mouse Button / Spaceball Button handling if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { - auto const event = (const SoMouseButtonEvent *) ev; + auto const event = static_cast(ev); const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; diff --git a/src/Gui/OnlineDocumentation.cpp b/src/Gui/OnlineDocumentation.cpp index adeff98e7a..0343a7a815 100644 --- a/src/Gui/OnlineDocumentation.cpp +++ b/src/Gui/OnlineDocumentation.cpp @@ -311,7 +311,7 @@ void HttpServer::readClient() // This slot is called when the client sent data to the server. The // server looks if it was a GET request and sends back the // corresponding HTML document from the ZIP file. - auto socket = (QTcpSocket*)sender(); + auto socket = static_cast(sender()); if (socket->canReadLine()) { QString httpRequestHeader = QString::fromLatin1(socket->readLine()); QStringList lst = httpRequestHeader.simplified().split(QLatin1String(" ")); @@ -345,7 +345,7 @@ void HttpServer::readClient() void HttpServer::discardClient() { - auto socket = (QTcpSocket*)sender(); + auto socket = static_cast(sender()); socket->deleteLater(); } diff --git a/src/Gui/ReportView.cpp b/src/Gui/ReportView.cpp index b27a400227..55a3efaa2a 100644 --- a/src/Gui/ReportView.cpp +++ b/src/Gui/ReportView.cpp @@ -486,7 +486,7 @@ void ReportOutput::customEvent ( QEvent* ev ) { // Appends the text stored in the event to the text view if ( ev->type() == QEvent::User ) { - auto ce = (CustomReportEvent*)ev; + auto ce = static_cast(ev); reportHl->setParagraphType(ce->messageType()); bool showTimecode = getWindowParameter()->GetBool("checkShowReportTimecode", true); diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index 2346d1b158..7e34480730 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -1489,7 +1489,7 @@ void SelectionSingleton::setVisible(VisibleState vis) { // Fall back to direct object visibility setting } - if(!filter.insert(std::make_pair(obj,(App::DocumentObject*)nullptr)).second){ + if(!filter.insert(std::make_pair(obj,static_cast(nullptr))).second){ continue; } diff --git a/src/Gui/SoFCBoundingBox.cpp b/src/Gui/SoFCBoundingBox.cpp index 8dce00ae19..65624d34bc 100644 --- a/src/Gui/SoFCBoundingBox.cpp +++ b/src/Gui/SoFCBoundingBox.cpp @@ -161,11 +161,11 @@ void SoFCBoundingBox::GLRender (SoGLRenderAction *action) str.setf(std::ios::fixed | std::ios::showpoint); str << "(" << vptr[i][0] << "," << vptr[i][1] << "," << vptr[i][2] << ")"; - SoSeparator *sep = (SoSeparator *)textSep->getChild(i); - SoTransform *trans = (SoTransform *)sep->getChild(0); + SoSeparator *sep = static_cast(textSep->getChild(i)); + SoTransform *trans = static_cast(sep->getChild(0)); trans->translation.setValue(vptr[i].getValue()); - SoText2* t = (SoText2 *)sep->getChild(1); + SoText2* t = static_cast(sep->getChild(1)); t->string.setValue(str.str().c_str()); } @@ -187,13 +187,13 @@ void SoFCBoundingBox::GLRender (SoGLRenderAction *action) str.setf(std::ios::fixed | std::ios::showpoint); str << (2.0f * ctr[i]); - SoSeparator *sep = (SoSeparator *)dimSep->getChild(i); - SoTransform *trans = (SoTransform *)sep->getChild(0); + SoSeparator *sep = static_cast(dimSep->getChild(i)); + SoTransform *trans = static_cast(sep->getChild(0)); SbVec3f point = corner[0]; point[i] += ctr[i]; trans->translation.setValue(point.getValue()); - SoText2* t = (SoText2 *)sep->getChild(1); + SoText2* t = static_cast(sep->getChild(1)); t->string.setValue(str.str().c_str()); } diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index 5cd3805273..c7073a56dd 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -196,7 +196,7 @@ void SoFCSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCDocumentAction::getClassTypeId()) { - auto docaction = (SoFCDocumentAction*)action; + auto docaction = static_cast(action); this->documentName = docaction->documentName; } @@ -211,7 +211,7 @@ void SoFCSelection::doAction(SoAction *action) if(!useNewSelection.getValue()) { if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) { - auto preaction = (SoFCEnableHighlightAction*)action; + auto preaction = static_cast(action); if (preaction->highlight) { this->highlightMode = SoFCSelection::AUTO; } @@ -221,7 +221,7 @@ void SoFCSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCEnableSelectionAction::getClassTypeId()) { - auto selaction = (SoFCEnableSelectionAction*)action; + auto selaction = static_cast(action); if (selaction->selection) { this->selectionMode = SoFCSelection::SEL_ON; } @@ -234,12 +234,12 @@ void SoFCSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCSelectionColorAction::getClassTypeId()) { - auto colaction = (SoFCSelectionColorAction*)action; + auto colaction = static_cast(action); this->colorSelection = colaction->selectionColor; } if (action->getTypeId() == SoFCHighlightColorAction::getClassTypeId()) { - auto colaction = (SoFCHighlightColorAction*)action; + auto colaction = static_cast(action); this->colorHighlight = colaction->highlightColor; } @@ -353,7 +353,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) } static char buf[513]; - auto mymode = (HighlightModes) this->highlightMode.getValue(); + auto mymode = static_cast(this->highlightMode.getValue()); const SoEvent * event = action->getEvent(); #ifdef NO_FRONTBUFFER // mouse move events for preselection @@ -372,7 +372,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) ,pp->getPoint()[1] ,pp->getPoint()[2])){ SoFCSelection::turnoffcurrent(action); - SoFCSelection::currenthighlight = (SoFullPath*)action->getCurPath()->copy(); + SoFCSelection::currenthighlight = static_cast(action->getCurPath()->copy()); SoFCSelection::currenthighlight->ref(); highlighted = true; this->touch(); // force scene redraw @@ -406,7 +406,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) } } // key press events else if (event->isOfType(SoKeyboardEvent ::getClassTypeId())) { - auto const e = (SoKeyboardEvent *) event; + auto const e = static_cast(event); if (SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::LEFT_SHIFT) || SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::RIGHT_SHIFT) ) bShift = true; @@ -421,7 +421,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) bCtrl = false; } // mouse press events for (de)selection else if (event->isOfType(SoMouseButtonEvent::getClassTypeId())) { - auto const e = (SoMouseButtonEvent *) event; + auto const e = static_cast(event); if (SoMouseButtonEvent::isButtonReleaseEvent(e,SoMouseButtonEvent::BUTTON1)) { //FIXME: Shouldn't we remove the preselection for newly selected objects? // Otherwise the tree signals that an object is preselected even though it is hidden. (Werner) @@ -555,7 +555,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) } // key press events else if (event->isOfType(SoKeyboardEvent ::getClassTypeId())) { - SoKeyboardEvent * const e = (SoKeyboardEvent *) event; + const SoKeyboardEvent * const e = static_cast(event); if (SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::LEFT_SHIFT) || SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::RIGHT_SHIFT) ) bShift = true; @@ -572,7 +572,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) // mouse press events for (de)selection (only if selection is enabled on this node) else if (event->isOfType(SoMouseButtonEvent::getClassTypeId()) && selectionMode.getValue() == SoFCSelection::SEL_ON) { - SoMouseButtonEvent * const e = (SoMouseButtonEvent *) event; + const SoMouseButtonEvent * const e = static_cast(event); if (SoMouseButtonEvent::isButtonReleaseEvent(e,SoMouseButtonEvent::BUTTON1)) { //FIXME: Shouldn't we remove the preselection for newly selected objects? // Otherwise the tree signals that an object is preselected even though it is hidden. (Werner) @@ -830,32 +830,34 @@ SoFCSelection::preRender(SoGLRenderAction *action, GLint &oldDepthFunc) void SoFCSelection::redrawHighlighted(SoAction * action , SbBool doHighlight ) { - Q_UNUSED(action); - Q_UNUSED(doHighlight); + //Base::Console().Log("SoFCSelection::redrawHighlighted() (%p) doHigh=%d \n",this,doHighlight?1:0); #ifdef NO_FRONTBUFFER + Q_UNUSED(action); + Q_UNUSED(doHighlight); #else // If we are about to highlight, and there is something else highlighted, // that something else needs to unhighlight. - if (doHighlight && currenthighlight != NULL && - !(*((SoFullPath *)action->getCurPath()) == *currenthighlight)) { + if (doHighlight && currenthighlight && + !(*(static_cast(action->getCurPath())) == *currenthighlight)) { SoNode *tail = currenthighlight->getTail(); - if (tail->isOfType( SoFCSelection::getClassTypeId())) - ((SoFCSelection *)tail)->redrawHighlighted(action, false); + if (tail->isOfType( SoFCSelection::getClassTypeId())) { + static_cast(tail)->redrawHighlighted(action, false); + } else { // Just get rid of the path. It's no longer valid for redraw. currenthighlight->unref(); - currenthighlight = NULL; + currenthighlight = nullptr; } } SoPath *pathToRender; // save the path to ourself for later de-highlight if (doHighlight) { - if (currenthighlight != NULL) + if (currenthighlight) currenthighlight->unref(); - currenthighlight = (SoFullPath *) action->getCurPath()->copy(); + currenthighlight = static_cast(action->getCurPath()->copy()); currenthighlight->ref(); // We will be rendering this new path to highlight it @@ -870,7 +872,7 @@ SoFCSelection::redrawHighlighted(SoAction * action , SbBool doHighlight ) pathToRender->ref(); currenthighlight->unref(); - currenthighlight = NULL; + currenthighlight = nullptr; } } @@ -888,7 +890,7 @@ SoFCSelection::redrawHighlighted(SoAction * action , SbBool doHighlight ) SoGLRenderActionElement::get(state, glAction); // If we don't have a current window, then simply return... - if (window == 0 /*|| context == NULL || display == NULL*/ || glAction == NULL) + if (!window /*|| context == NULL || display == NULL*/ || !glAction) return; window->makeCurrent(); @@ -928,7 +930,7 @@ SoFCSelection::readInstance ( SoInput * in, unsigned short flags ) bool SoFCSelection::setOverride(SoGLRenderAction * action, SelContextPtr ctx) { - auto mymode = (HighlightModes) this->highlightMode.getValue(); + auto mymode = static_cast(this->highlightMode.getValue()); bool preselected = ctx && ctx->isHighlighted() && (useNewSelection.getValue()||mymode == AUTO); if (!preselected && mymode!=ON && (!ctx || !ctx->isSelected())) return false; @@ -940,7 +942,7 @@ SoFCSelection::setOverride(SoGLRenderAction * action, SelContextPtr ctx) auto oldId = this->uniqueId; this->uniqueId ^= std::hash()(ctx.get()) + 0x9e3779b9 + (oldId << 6) + (oldId >> 2); - auto mystyle = (Styles) this->style.getValue(); + auto mystyle = static_cast(this->style.getValue()); if (mystyle == SoFCSelection::BOX) { if (ctx) { @@ -987,9 +989,10 @@ SoFCSelection::turnoffcurrent(SoAction * action) SoFCSelection::currenthighlight->getLength()) { SoNode * tail = SoFCSelection::currenthighlight->getTail(); if (tail->isOfType(SoFCSelection::getClassTypeId())) { - ((SoFCSelection*)tail)->highlighted = false; - ((SoFCSelection*)tail)->touch(); // force scene redraw - if (action) ((SoFCSelection*)tail)->redrawHighlighted(action, false); + static_cast(tail)->highlighted = false; + static_cast(tail)->touch(); // force scene redraw + if (action) + static_cast(tail)->redrawHighlighted(action, false); } } if (SoFCSelection::currenthighlight) { @@ -997,7 +1000,7 @@ SoFCSelection::turnoffcurrent(SoAction * action) SoFCSelection::currenthighlight = nullptr; } #else - if (currenthighlight == NULL) + if (!currenthighlight) return; SoNode *tail = currenthighlight->getTail(); @@ -1007,12 +1010,12 @@ SoFCSelection::turnoffcurrent(SoAction * action) // (processing events during render abort might cause this) SoState *state = action->getState(); if (state && state->getDepth() == 1) - ((SoFCSelection *)tail)->redrawHighlighted(action, false); + static_cast(tail)->redrawHighlighted(action, false); } else { // Just get rid of the path. It's no longer valid for redraw. currenthighlight->unref(); - currenthighlight = NULL; + currenthighlight = nullptr; } #endif } @@ -1022,8 +1025,8 @@ SoFCSelection::isHighlighted(SoAction *action) // //////////////////////////////////////////////////////////////////////// { - auto actionPath = (SoFullPath *) action->getCurPath(); - return (currenthighlight != nullptr && + auto actionPath = static_cast(action->getCurPath()); + return (currenthighlight && currenthighlight->getTail() == actionPath->getTail() && // nested SoHL! *currenthighlight == *actionPath); } diff --git a/src/Gui/SoFCSelectionAction.cpp b/src/Gui/SoFCSelectionAction.cpp index e45d33020c..22b6a6eafb 100644 --- a/src/Gui/SoFCSelectionAction.cpp +++ b/src/Gui/SoFCSelectionAction.cpp @@ -1038,7 +1038,7 @@ SoBoxSelectionRenderActionP::updateBbox(const SoPath * path) this->camerasearch->setFind(SoSearchAction::TYPE); this->camerasearch->setInterest(SoSearchAction::LAST); this->camerasearch->setType(SoCamera::getClassTypeId()); - this->camerasearch->apply((SoPath*) path); + this->camerasearch->apply(const_cast(path)); if (!this->camerasearch->getPath()) { // if there is no camera there is no point rendering the bbox @@ -1051,7 +1051,7 @@ SoBoxSelectionRenderActionP::updateBbox(const SoPath * path) this->bboxaction = new SoGetBoundingBoxAction(SbViewportRegion(100, 100)); } this->bboxaction->setViewportRegion(PUBLIC(this)->getViewportRegion()); - this->bboxaction->apply((SoPath*) path); + this->bboxaction->apply(const_cast(path)); SbXfBox3f & box = this->bboxaction->getXfBoundingBox(); @@ -1164,7 +1164,7 @@ SoBoxSelectionRenderAction::apply(SoNode * node) for (int i = 0; i < pathlist.getLength(); i++ ) { SoPath * path = pathlist[i]; assert(path); - auto selection = (SoFCSelection *) path->getTail(); + auto selection = static_cast(path->getTail()); assert(selection->getTypeId().isDerivedFrom(SoFCSelection::getClassTypeId())); if (selection->selected.getValue() && selection->style.getValue() == SoFCSelection::BOX) { PRIVATE(this)->basecolor->rgb.setValue(selection->colorSelection.getValue()); @@ -1219,7 +1219,7 @@ SoBoxSelectionRenderAction::apply(SoPath * path) SoGLRenderAction::apply(path); SoNode* node = path->getTail(); if (node && node->getTypeId() == SoFCSelection::getClassTypeId()) { - auto selection = (SoFCSelection *) node; + auto selection = static_cast(node); // This happens when dehighlighting the current shape if (PRIVATE(this)->highlightPath == path) { @@ -1305,7 +1305,7 @@ void SoBoxSelectionRenderAction::drawBoxes(SoPath * pathtothis, const SoPathList * pathlist) { int i; - int thispos = ((SoFullPath *)pathtothis)->getLength()-1; + int thispos = static_cast(pathtothis)->getLength()-1; assert(thispos >= 0); PRIVATE(this)->postprocpath->truncate(0); // reset @@ -1321,7 +1321,7 @@ SoBoxSelectionRenderAction::drawBoxes(SoPath * pathtothis, const SoPathList * pa thestate->push(); for (i = 0; i < pathlist->getLength(); i++) { - auto path = (SoFullPath *)(*pathlist)[i]; + auto path = static_cast((*pathlist)[i]); for (int j = 0; j < path->getLength(); j++) { PRIVATE(this)->postprocpath->append(path->getNode(j)); diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index 327761fb9b..99e9a63e04 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -206,7 +206,7 @@ void SoFCUnifiedSelection::write(SoWriteAction * action) // Do not write out the fields of this class if (this->writeHeader(out, true, false)) return; - SoGroup::doAction((SoAction *)action); + SoGroup::doAction(static_cast(action)); this->writeFooter(out); } else { @@ -306,7 +306,7 @@ SoFCUnifiedSelection::getPickedList(SoHandleEventAction* action, bool singlePick void SoFCUnifiedSelection::doAction(SoAction *action) { if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) { - auto preaction = (SoFCEnableHighlightAction*)action; + auto preaction = static_cast(action); if (preaction->highlight) { this->highlightMode = SoFCUnifiedSelection::AUTO; } @@ -316,7 +316,7 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCEnableSelectionAction::getClassTypeId()) { - auto selaction = (SoFCEnableSelectionAction*)action; + auto selaction = static_cast(action); if (selaction->selection) { this->selectionMode = SoFCUnifiedSelection::ON; } @@ -326,12 +326,12 @@ void SoFCUnifiedSelection::doAction(SoAction *action) } if (action->getTypeId() == SoFCSelectionColorAction::getClassTypeId()) { - auto colaction = (SoFCSelectionColorAction*)action; + auto colaction = static_cast(action); this->colorSelection = colaction->selectionColor; } if (action->getTypeId() == SoFCHighlightColorAction::getClassTypeId()) { - auto colaction = (SoFCHighlightColorAction*)action; + auto colaction = static_cast(action); this->colorHighlight = colaction->highlightColor; } @@ -580,7 +580,7 @@ bool SoFCUnifiedSelection::setSelection(const std::vector &infos, bo auto pPath = static_cast(pp->getPath()); const auto &pt = pp->getPoint(); SoSelectionElementAction::Type type = SoSelectionElementAction::None; - auto mymode = (HighlightModes) this->highlightMode.getValue(); + auto mymode = static_cast(this->highlightMode.getValue()); static char buf[513]; if (ctrlDown) { @@ -700,7 +700,7 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) return; } - auto mymode = (HighlightModes) this->highlightMode.getValue(); + auto mymode = static_cast(this->highlightMode.getValue()); const SoEvent * event = action->getEvent(); // If we don't need to pick for locate highlighting, @@ -1038,7 +1038,7 @@ typedef struct { static void so_bbox_construct_data(void * closure) { - auto data = (SoFCBBoxRenderInfo*) closure; + auto data = static_cast(closure); data->bboxaction = nullptr; data->cube = nullptr; data->packer = nullptr; @@ -1046,7 +1046,7 @@ static void so_bbox_construct_data(void * closure) static void so_bbox_destruct_data(void * closure) { - auto data = (SoFCBBoxRenderInfo*) closure; + auto data = static_cast(closure); delete data->bboxaction; if(data->cube) data->cube->unref(); @@ -1202,7 +1202,7 @@ std::pair SoFCSelectionRoot::findActionContex bool SoFCSelectionRoot::renderBBox(SoGLRenderAction *action, SoNode *node, SbColor color) { - auto data = (SoFCBBoxRenderInfo*) so_bbox_storage->get(); + auto data = static_cast(so_bbox_storage->get()); if (!data->bboxaction) { // The viewport region will be replaced every time the action is // used, so we can just feed it a dummy here. diff --git a/src/Gui/SoNavigationDragger.cpp b/src/Gui/SoNavigationDragger.cpp index 14a3531ed3..32d471d345 100644 --- a/src/Gui/SoNavigationDragger.cpp +++ b/src/Gui/SoNavigationDragger.cpp @@ -331,7 +331,7 @@ RotTransDragger::setUpConnections(SbBool onOff, SbBool doItAlways) void RotTransDragger::valueChangedCB(void *, SoDragger *inDragger) { - auto myself = (RotTransDragger *) inDragger; + auto myself = static_cast(inDragger); // Factor the motionMatrix into its parts SbMatrix motMat = myself->getMotionMatrix(); // clazy:exclude=rule-of-two-soft @@ -355,7 +355,7 @@ RotTransDragger::valueChangedCB(void *, SoDragger *inDragger) void RotTransDragger::fieldSensorCB(void *inDragger, SoSensor *) { - auto myself = (RotTransDragger *) inDragger; + auto myself = static_cast(inDragger); SbMatrix motMat = myself->getMotionMatrix(); // clazy:exclude=rule-of-two-soft myself->workFieldsIntoTransform(motMat); @@ -369,7 +369,7 @@ RotTransDragger::fieldSensorCB(void *inDragger, SoSensor *) void RotTransDragger::invalidateSurroundScaleCB(void *parent, SoDragger *) { - auto myParentDragger = (RotTransDragger *) parent; + auto myParentDragger = static_cast(parent); // Invalidate the surroundScale, if it exists. SoSurroundScale *mySS = SO_CHECK_PART( diff --git a/src/Gui/TaskView/TaskAppearance.cpp b/src/Gui/TaskView/TaskAppearance.cpp index ac48b92bcc..b5d3613616 100644 --- a/src/Gui/TaskView/TaskAppearance.cpp +++ b/src/Gui/TaskView/TaskAppearance.cpp @@ -139,7 +139,7 @@ void TaskAppearance::on_changeMode_activated(const QString& s) for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("DisplayMode"); if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { - auto Display = (App::PropertyEnumeration*)prop; + auto Display = static_cast(prop); Display->setValue((const char*)s.toLatin1()); } } @@ -159,7 +159,7 @@ void TaskAppearance::on_spinTransparency_valueChanged(int transparency) for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("Transparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { - auto Transparency = (App::PropertyInteger*)prop; + auto Transparency = static_cast(prop); Transparency->setValue(transparency); } } @@ -174,8 +174,8 @@ void TaskAppearance::on_spinPointSize_valueChanged(int pointsize) for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("PointSize"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - auto PointSize = (App::PropertyFloat*)prop; - PointSize->setValue((float)pointsize); + auto PointSize = static_cast(prop); + PointSize->setValue(static_cast(pointsize)); } } } @@ -189,8 +189,8 @@ void TaskAppearance::on_spinLineWidth_valueChanged(int linewidth) for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("LineWidth"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - auto LineWidth = (App::PropertyFloat*)prop; - LineWidth->setValue((float)linewidth); + auto LineWidth = static_cast(prop); + LineWidth->setValue(static_cast(linewidth)); } } } diff --git a/src/Gui/TaskView/TaskDialogPython.cpp b/src/Gui/TaskView/TaskDialogPython.cpp index d080900a2e..55012ee715 100644 --- a/src/Gui/TaskView/TaskDialogPython.cpp +++ b/src/Gui/TaskView/TaskDialogPython.cpp @@ -216,14 +216,14 @@ TaskWatcherPython::TaskWatcherPython(const Py::Object& o) QString title; if (watcher.hasAttr(std::string("title"))) { Py::String name(watcher.getAttr(std::string("title"))); - std::string s = (std::string)name; + std::string s = static_cast(name); title = QString::fromUtf8(s.c_str()); } QPixmap icon; if (watcher.hasAttr(std::string("icon"))) { Py::String name(watcher.getAttr(std::string("icon"))); - std::string s = (std::string)name; + std::string s = static_cast(name); icon = BitmapFactory().pixmap(s.c_str()); } @@ -234,7 +234,7 @@ TaskWatcherPython::TaskWatcherPython(const Py::Object& o) CommandManager &mgr = Gui::Application::Instance->commandManager(); for (Py::Sequence::iterator it = cmds.begin(); it != cmds.end(); ++it) { Py::String name(*it); - std::string s = (std::string)name; + std::string s = static_cast(name); Command *c = mgr.getCommandByName(s.c_str()); if (c) c->addTo(tb); @@ -267,7 +267,7 @@ TaskWatcherPython::TaskWatcherPython(const Py::Object& o) if (watcher.hasAttr(std::string("filter"))) { Py::String name(watcher.getAttr(std::string("filter"))); - std::string s = (std::string)name; + std::string s = static_cast(name); this->setFilter(s.c_str()); } } @@ -313,7 +313,7 @@ TaskDialogPython::TaskDialogPython(const Py::Object& o) : dlg(o) loader.setLanguageChangeEnabled(true); QString fn, icon; Py::String ui(dlg.getAttr(std::string("ui"))); - std::string path = (std::string)ui; + std::string path = static_cast(ui); fn = QString::fromUtf8(path.c_str()); QFile file(fn); diff --git a/src/Gui/TextEdit.cpp b/src/Gui/TextEdit.cpp index 4d7845ba0c..6b247d5ff3 100644 --- a/src/Gui/TextEdit.cpp +++ b/src/Gui/TextEdit.cpp @@ -565,7 +565,7 @@ bool CompletionList::eventFilter(QObject * watched, QEvent * event) hide(); } else if (isVisible() && watched == textEdit) { if (event->type() == QEvent::KeyPress) { - auto ke = (QKeyEvent*)event; + auto ke = static_cast(event); if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { keyPressEvent(ke); return true; diff --git a/src/Gui/UiLoader.cpp b/src/Gui/UiLoader.cpp index 6b8bd7b1a3..65518bd663 100644 --- a/src/Gui/UiLoader.cpp +++ b/src/Gui/UiLoader.cpp @@ -561,7 +561,7 @@ Py::Object UiLoaderPy::load(const Py::Tuple& args) device = &file; } else if (args[0].isString()) { - fn = (std::string)Py::String(args[0]); + fn = static_cast(Py::String(args[0])); file.setFileName(QString::fromUtf8(fn.c_str())); if (!file.open(QFile::ReadOnly)) throw Py::RuntimeError("Cannot open file"); diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 2827814e2a..3a09a1c696 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -888,7 +888,7 @@ Py::Object View3DInventorPy::setCameraOrientation(const Py::Tuple& args) getView3DIventorPtr()->getViewer()->setCameraOrientation(SbRotation(q0, q1, q2, q3), Base::asBoolean(m)); } else if (PyObject_TypeCheck(o, &Base::RotationPy::Type)) { - Base::Rotation r = (Base::Rotation)Py::Rotation(o,false); + Base::Rotation r = static_cast(Py::Rotation(o,false)); double q0, q1, q2, q3; r.getValue(q0, q1, q2, q3); getView3DIventorPtr()->getViewer()->setCameraOrientation(SbRotation((float)q0, (float)q1, (float)q2, (float)q3), Base::asBoolean(m)); @@ -1097,7 +1097,7 @@ Py::Object View3DInventorPy::getCameraNode(const Py::Tuple& args) type = "So"; // seems that So prefix is missing in camera node type += camera->getTypeId().getName().getString(); type += " *"; - proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), (void*)camera, 1); + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), static_cast(camera), 1); camera->ref(); return Py::Object(proxy, true); } @@ -2240,7 +2240,7 @@ Py::Object View3DInventorPy::getSceneGraph(const Py::Tuple& args) try { SoNode* scene = getView3DIventorPtr()->getViewer()->getSceneGraph(); PyObject* proxy = nullptr; - proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoSeparator *", (void*)scene, 1); + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoSeparator *", static_cast(scene), 1); scene->ref(); return Py::Object(proxy, true); } @@ -2267,10 +2267,10 @@ void View3DInventorPy::eventCallbackPivy(void * ud, SoEventCallback * n) PyObject* proxy = nullptr; try { - proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), (void*)e, 0); + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), const_cast(static_cast(e)), 0); // now run the method Py::Object event(proxy,true); - Py::Callable method(reinterpret_cast(ud)); + Py::Callable method(static_cast(ud)); Py::Tuple args(1); args.setItem(0, event); method.apply(args); @@ -2300,7 +2300,7 @@ void View3DInventorPy::eventCallbackPivyEx(void * ud, SoEventCallback * n) PyObject* proxy = nullptr; try { - proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), (void*)n, 0); + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), static_cast(n), 0); // now run the method Py::Object event(proxy,true); Py::Callable method(reinterpret_cast(ud)); @@ -2432,7 +2432,7 @@ void View3DInventorPy::draggerCallback(void * ud, SoDragger* n) Base::PyGILStateLocker lock; PyObject* proxy = nullptr; try { - proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoDragger *", (void*)n, 0); + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoDragger *", static_cast(n), 0); //call the method Py::Object dragger(proxy,true); Py::Callable method(reinterpret_cast(ud)); diff --git a/src/Gui/View3DViewerPy.cpp b/src/Gui/View3DViewerPy.cpp index d16a1208c7..b958f22b03 100644 --- a/src/Gui/View3DViewerPy.cpp +++ b/src/Gui/View3DViewerPy.cpp @@ -179,7 +179,7 @@ Py::Object View3DInventorViewerPy::getSoRenderManager(const Py::Tuple& args) try { SoRenderManager* manager = _viewer->getSoRenderManager(); PyObject* proxy = nullptr; - proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoRenderManager *", (void*)manager, 0); + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoRenderManager *", static_cast(manager), 0); return Py::Object(proxy, true); } catch (const Base::Exception& e) { @@ -195,7 +195,7 @@ Py::Object View3DInventorViewerPy::getSceneGraph(const Py::Tuple& args) try { SoNode* scene = _viewer->getSceneGraph(); PyObject* proxy = nullptr; - proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoSeparator *", (void*)scene, 1); + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoSeparator *", static_cast(scene), 1); scene->ref(); return Py::Object(proxy, true); } @@ -230,7 +230,7 @@ Py::Object View3DInventorViewerPy::getSoEventManager(const Py::Tuple& args) try { SoEventManager* manager = _viewer->getSoEventManager(); PyObject* proxy = nullptr; - proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoEventManager *", (void*)manager, 0); + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoEventManager *", static_cast(manager), 0); return Py::Object(proxy, true); } catch (const Base::Exception& e) { diff --git a/src/Gui/ViewProvider.cpp b/src/Gui/ViewProvider.cpp index 873f67e27e..905cb22cba 100644 --- a/src/Gui/ViewProvider.cpp +++ b/src/Gui/ViewProvider.cpp @@ -204,7 +204,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node) try { // Keyboard events if (ev->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { - auto ke = (SoKeyboardEvent *)ev; + auto ke = static_cast(ev); const SbBool press = ke->getState() == SoButtonEvent::DOWN ? true : false; switch (ke->getKey()) { case SoKeyboardEvent::ESCAPE: diff --git a/src/Gui/ViewProviderDocumentObjectGroup.cpp b/src/Gui/ViewProviderDocumentObjectGroup.cpp index 51a3ac491d..9826c9fe0e 100644 --- a/src/Gui/ViewProviderDocumentObjectGroup.cpp +++ b/src/Gui/ViewProviderDocumentObjectGroup.cpp @@ -74,12 +74,12 @@ void ViewProviderDocumentObjectGroup::getViewProviders(std::vectorgetTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) { Gui::Document* gd = Application::Instance->getDocument(doc->getDocument()); - auto grp = (App::DocumentObjectGroup*)doc; + auto grp = static_cast(doc); std::vector obj = grp->getObjects(); for (const auto & it : obj) { ViewProvider* v = gd->getViewProvider(it); if (v && v->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) - vp.push_back((ViewProviderDocumentObject*)v); + vp.push_back(static_cast(v)); } } } diff --git a/src/Gui/ViewProviderExtern.cpp b/src/Gui/ViewProviderExtern.cpp index c169f381b9..f62c8e868b 100644 --- a/src/Gui/ViewProviderExtern.cpp +++ b/src/Gui/ViewProviderExtern.cpp @@ -129,7 +129,7 @@ void ViewProviderExtern::adjustRecursiveDocumentName(SoNode* child, const char* static_cast(child)->documentName = docname; } else if (child->getTypeId().isDerivedFrom( SoGroup::getClassTypeId())) { - SoGroup* group = (SoGroup*)child; + SoGroup* group = static_cast(child); for (int i=0; igetNumChildren(); i++) { SoNode* subchild = group->getChild(i); adjustRecursiveDocumentName(subchild, docname); diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 301ac66fec..14a66256ad 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -896,7 +896,7 @@ PyObject *LinkView::getPyObject() void LinkView::setInvalid() { if (!PythonObject.is(Py::_None())){ - auto obj = (Base::PyObjectBase*)PythonObject.ptr(); + auto obj = static_cast(PythonObject.ptr()); obj->setInvalid(); obj->DecRef(); }else @@ -2835,7 +2835,7 @@ void ViewProviderLink::setEditViewer(Gui::View3DInventorViewer* viewer, int ModN // we use an invisible cube sized by the bounding box obtained from // initDraggingPlacement() to scale the centerball dragger properly - auto * ss = (SoSurroundScale*)dragger->getPart("surroundScale", TRUE); + auto * ss = static_cast(dragger->getPart("surroundScale", TRUE)); ss->numNodesUpToContainer = 3; ss->numNodesUpToReset = 2; diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index 8643508201..0bdd03563c 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -509,7 +509,7 @@ PyObject* ViewProviderPy::getDetailPath(PyObject* args) } if(!det) Py_Return; - return Base::Interpreter().createSWIGPointerObj("pivy.coin", "_p_SoDetail", (void*)det, 0); + return Base::Interpreter().createSWIGPointerObj("pivy.coin", "_p_SoDetail", static_cast(det), 0); } PyObject *ViewProviderPy::signalChangeIcon(PyObject *args) diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonFeature.cpp index cf65b1e1bd..c58df52a1b 100644 --- a/src/Gui/ViewProviderPythonFeature.cpp +++ b/src/Gui/ViewProviderPythonFeature.cpp @@ -212,7 +212,7 @@ bool ViewProviderPythonFeatureImp::getElement(const SoDetail *det, std::string & // Note: As there is no ref'counting mechanism for the SoDetail class we must // pass '0' as the last parameter so that the Python object does not 'own' // the detail object. - pivy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoDetail *", (void*)det, 0); + pivy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoDetail *", const_cast(static_cast(det)), 0); Py::Tuple args(1); args.setItem(0, Py::Object(pivy, true)); Py::String name(Base::pyCall(py_getElement.ptr(),args.ptr())); @@ -242,7 +242,7 @@ ViewProviderPythonFeatureImp::getElementPicked(const SoPickedPoint *pp, std::str Base::PyGILStateLocker lock; try { PyObject* pivy = nullptr; - pivy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoPickedPoint *", (void*)pp, 0); + pivy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoPickedPoint *", const_cast(static_cast(pp)), 0); Py::Tuple args(1); args.setItem(0, Py::Object(pivy, true)); Py::Object ret(Base::pyCall(py_getElementPicked.ptr(),args.ptr())); @@ -306,7 +306,7 @@ ViewProviderPythonFeatureImp::ValueT ViewProviderPythonFeatureImp::getDetailPath auto length = path->getLength(); try { PyObject* pivy = nullptr; - pivy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoFullPath *", (void*)path, 1); + pivy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoFullPath *", static_cast(path), 1); path->ref(); Py::Tuple args(3); args.setItem(0, Py::String(name)); diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 6e706eb13e..701d5c98c9 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -72,7 +72,7 @@ void WidgetFactoryInst::destruct () */ QWidget* WidgetFactoryInst::createWidget (const char* sName, QWidget* parent) const { - auto w = (QWidget*)Produce(sName); + auto w = static_cast(Produce(sName)); // this widget class is not registered if (!w) { @@ -217,7 +217,7 @@ PrefPageUiProducer::~PrefPageUiProducer() void* PrefPageUiProducer::Produce () const { QWidget* page = new Gui::Dialog::PreferenceUiForm(fn); - return (void*)page; + return static_cast(page); } // ---------------------------------------------------- @@ -476,7 +476,7 @@ void PyResource::load(const char* name) throw Base::ValueError("Invalid widget."); if (w->inherits("QDialog")) { - myDlg = (QDialog*)w; + myDlg = static_cast(w); } else { myDlg = new ContainerDialog(w); diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 2d71e821d9..4626fd7961 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -1306,7 +1306,7 @@ QVariant PropertyBoolItem::value(const App::Property* prop) const { assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyBool::getClassTypeId())); - bool value = ((App::PropertyBool*)prop)->getValue(); + bool value = static_cast(prop)->getValue(); return QVariant(value); } @@ -3253,7 +3253,7 @@ QVariant PropertyColorItem::value(const App::Property* prop) const { assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyColor::getClassTypeId())); - App::Color value = ((App::PropertyColor*)prop)->getValue(); + App::Color value = static_cast(prop)->getValue(); return QVariant(value.asValue()); }