From 118453053072bef10c0b5874fd4957a4d5c321cd Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 10 Jul 2019 14:02:06 +0200 Subject: [PATCH] More warnings fixed --- AABB_tree/demo/AABB_tree/MainWindow.cpp | 2 +- .../include/CGAL/Qt/DemosMainWindow_impl.h | 3 +-- GraphicsView/include/CGAL/Qt/qglviewer_impl.h | 16 ++++++++-------- Polyhedron/demo/Polyhedron/MainWindow.cpp | 15 +++++++++++---- .../Plugins/Mesh_3/Io_image_plugin.cpp | 12 ++++++++++++ Polyhedron/demo/Polyhedron/Scene.cpp | 2 +- Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp | 4 ++-- Polyhedron/demo/Polyhedron/Viewer.cpp | 8 +++++++- .../Principal_component_analysis/MainWindow.cpp | 2 +- Three/include/CGAL/Three/TextRenderer.h | 8 +++++++- Triangulation_3/demo/Triangulation_3/Viewer.cpp | 4 ++-- 11 files changed, 53 insertions(+), 23 deletions(-) diff --git a/AABB_tree/demo/AABB_tree/MainWindow.cpp b/AABB_tree/demo/AABB_tree/MainWindow.cpp index 8cd596d6bbc..636febda8ce 100644 --- a/AABB_tree/demo/AABB_tree/MainWindow.cpp +++ b/AABB_tree/demo/AABB_tree/MainWindow.cpp @@ -23,7 +23,7 @@ MainWindow::MainWindow(QWidget* parent) m_pViewer = ui->viewer; // does not save the state of the viewer - m_pViewer->setStateFileName(QString::null); + m_pViewer->setStateFileName(QString()); // accepts drop events setAcceptDrops(true); diff --git a/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h b/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h index b4d696f763b..2bd20a14c9d 100644 --- a/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h +++ b/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h @@ -461,9 +461,8 @@ void DemosMainWindow::readState(QString groupname, Options /*what_to_save*/) settings.beginGroup(groupname); resize(settings.value("size", this->size()).toSize()); - QDesktopWidget* desktop = qApp->desktop(); QPoint pos = settings.value("pos", this->pos()).toPoint(); - if(desktop->availableGeometry(pos).contains(pos)) { + if(QGuiApplication::screenAt(pos)) { move(pos); } QByteArray mainWindowState = settings.value("state").toByteArray(); diff --git a/GraphicsView/include/CGAL/Qt/qglviewer_impl.h b/GraphicsView/include/CGAL/Qt/qglviewer_impl.h index 972896a063a..90e8b9e74c8 100644 --- a/GraphicsView/include/CGAL/Qt/qglviewer_impl.h +++ b/GraphicsView/include/CGAL/Qt/qglviewer_impl.h @@ -1606,7 +1606,7 @@ CGAL_INLINE_FUNCTION QString CGAL::QGLViewer::mouseActionString(qglviewer::MouseAction ma) { switch (ma) { case CGAL::qglviewer::NO_MOUSE_ACTION: - return QString::null; + return QString(); case CGAL::qglviewer::ROTATE: return CGAL::QGLViewer::tr("Rotates", "ROTATE mouse action"); case CGAL::qglviewer::ZOOM: @@ -1632,14 +1632,14 @@ QString CGAL::QGLViewer::mouseActionString(qglviewer::MouseAction ma) { case CGAL::qglviewer::ZOOM_ON_REGION: return CGAL::QGLViewer::tr("Zooms on region for", "ZOOM_ON_REGION mouse action"); } - return QString::null; + return QString(); } CGAL_INLINE_FUNCTION QString CGAL::QGLViewer::clickActionString(CGAL::qglviewer::ClickAction ca) { switch (ca) { case CGAL::qglviewer::NO_CLICK_ACTION: - return QString::null; + return QString(); case CGAL::qglviewer::ZOOM_ON_PIXEL: return CGAL::QGLViewer::tr("Zooms on pixel", "ZOOM_ON_PIXEL click action"); case CGAL::qglviewer::ZOOM_TO_FIT: @@ -1664,7 +1664,7 @@ QString CGAL::QGLViewer::clickActionString(CGAL::qglviewer::ClickAction ca) { case CGAL::qglviewer::ALIGN_CAMERA: return CGAL::QGLViewer::tr("Aligns camera", "ALIGN_CAMERA click action"); } - return QString::null; + return QString(); } static QString keyString(unsigned int key) { @@ -1946,7 +1946,7 @@ void CGAL::QGLViewer::setKeyDescription(unsigned int key, QString description) { CGAL_INLINE_FUNCTION QString CGAL::QGLViewer::cameraPathKeysString() const { if (pathIndex_.isEmpty()) - return QString::null; + return QString(); QVector< ::Qt::Key> keys; keys.reserve(pathIndex_.count()); @@ -1954,7 +1954,7 @@ QString CGAL::QGLViewer::cameraPathKeysString() const { endi = pathIndex_.end(); i != endi; ++i) keys.push_back(i.key()); - qSort(keys); + std::sort(keys.begin(), keys.end()); QVector< ::Qt::Key>::const_iterator it = keys.begin(), end = keys.end(); QString res = keyString(*it); @@ -3544,7 +3544,7 @@ This is the name of the XML file where saveStateToFile() saves the viewer state restoreStateFromFile() to restore this state later (usually in your init() method). -Setting this value to \c QString::null will disable the automatic state file +Setting this value to \c QString() will disable the automatic state file saving that normally occurs on exit. If more than one viewer are created by the application, this function will @@ -3576,7 +3576,7 @@ Use restoreStateFromFile() to restore this viewer state. This method is automatically called when a viewer is closed (using Escape or using the window's upper right \c x close button). setStateFileName() to \c -QString::null to prevent this. */ +QString() to prevent this. */ CGAL_INLINE_FUNCTION void CGAL::QGLViewer::saveStateToFile() { QString name = stateFileName(); diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 805f71468e3..326da8f6ead 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -145,7 +145,7 @@ MainWindow::MainWindow(bool verbose, QWidget* parent) sceneView = ui->sceneView; viewer = ui->viewer; // do not save the state of the viewer (anoying) - viewer->setStateFileName(QString::null); + viewer->setStateFileName(QString()); // setup scene scene = new Scene(this); @@ -677,7 +677,7 @@ void MainWindow::updateMenus() } // sort the operations menu by name as = ui->menuOperations->actions(); - qSort(as.begin(), as.end(), actionsByName); + std::sort(as.begin(), as.end(), actionsByName); ui->menuOperations->clear(); ui->menuOperations->addActions(as); } @@ -1990,9 +1990,9 @@ void MainWindow::on_actionLoadPlugin_triggered() void MainWindow::recurseExpand(QModelIndex index) { int row = index.row(); - if(index.child(0,0).isValid()) + if(scene->index(0,0,index).isValid()) { - recurseExpand(index.child(0,0)); + recurseExpand(scene->index(0,0,index)); } CGAL::Three::Scene_group_item* group = qobject_cast(scene->item(scene->getIdFromModelIndex(index))); @@ -2171,10 +2171,17 @@ void MainWindow::resetHeader() sceneView->header()->setSectionResizeMode(Scene::RenderingModeColumn, QHeaderView::ResizeToContents); sceneView->header()->setSectionResizeMode(Scene::ABColumn, QHeaderView::Fixed); sceneView->header()->setSectionResizeMode(Scene::VisibleColumn, QHeaderView::Fixed); +#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + sceneView->header()->resizeSection(Scene::ColorColumn, sceneView->header()->fontMetrics().horizontalAdvance("_#_")); + sceneView->resizeColumnToContents(Scene::RenderingModeColumn); + sceneView->header()->resizeSection(Scene::ABColumn, sceneView->header()->fontMetrics().horizontalAdvance(QString("_AB_"))); + sceneView->header()->resizeSection(Scene::VisibleColumn, sceneView->header()->fontMetrics().horizontalAdvance(QString("_View_"))); +#else sceneView->header()->resizeSection(Scene::ColorColumn, sceneView->header()->fontMetrics().width("_#_")); sceneView->resizeColumnToContents(Scene::RenderingModeColumn); sceneView->header()->resizeSection(Scene::ABColumn, sceneView->header()->fontMetrics().width(QString("_AB_"))); sceneView->header()->resizeSection(Scene::VisibleColumn, sceneView->header()->fontMetrics().width(QString("_View_"))); +#endif } void MainWindow::reset_default_loaders() diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp index 300b1614b73..b02ce415ae7 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -577,7 +577,11 @@ private: // Find the right width for the label to accommodate at least 9999 QFontMetrics metric = x_cubeLabel->fontMetrics(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + x_cubeLabel->setFixedWidth(metric.horizontalAdvance(QString(".9999."))); +#else x_cubeLabel->setFixedWidth(metric.width(QString(".9999."))); +#endif x_cubeLabel->setText("0"); x_cubeLabel->setValidator(validator); @@ -603,7 +607,11 @@ private: // Find the right width for the label to accommodate at least 9999 QFontMetrics metric = y_cubeLabel->fontMetrics(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + y_cubeLabel->setFixedWidth(metric.horizontalAdvance(QString(".9999."))); +#else y_cubeLabel->setFixedWidth(metric.width(QString(".9999."))); +#endif y_cubeLabel->setText("0"); y_cubeLabel->setValidator(validator); y_slider = new QSlider(mw); @@ -628,7 +636,11 @@ private: // Find the right width for the label to accommodate at least 9999 QFontMetrics metric = z_cubeLabel->fontMetrics(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + z_cubeLabel->setFixedWidth(metric.horizontalAdvance(QString(".9999."))); +#else z_cubeLabel->setFixedWidth(metric.width(QString(".9999."))); +#endif z_cubeLabel->setText("0"); z_cubeLabel->setValidator(validator); z_slider = new QSlider(mw); diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index 2d2a3c5020e..cffde5f2c24 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -817,7 +817,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer) QList depths = picked_item_IDs.keys(); if(!depths.isEmpty()) { - qSort(depths); + std::sort(depths.begin(), depths.end()); int id = picked_item_IDs[depths.first()]; setSelectedItemIndex(id); viewer->setSelectedName(id); diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index 6831ddfe75f..08f10fe568d 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -1491,7 +1491,7 @@ void Scene_c3t3_item_priv::computeIntersection(const Primitive& facet) Tr::Cell_handle ch = facet.id().first; if(intersected_cells.find(ch) == intersected_cells.end()) { - QColor c = this->colors_subdomains[ch->subdomain_index()].light(50); + QColor c = this->colors_subdomains[ch->subdomain_index()].lighter(50); const Tr::Bare_point& pa = wp2p(ch->vertex(0)->point()); const Tr::Bare_point& pb = wp2p(ch->vertex(1)->point()); @@ -1516,7 +1516,7 @@ void Scene_c3t3_item_priv::computeIntersection(const Primitive& facet) const Tr::Bare_point& pc = wp2p(nh->vertex(2)->point()); const Tr::Bare_point& pd = wp2p(nh->vertex(3)->point()); - QColor c = this->colors_subdomains[nh->subdomain_index()].light(50); + QColor c = this->colors_subdomains[nh->subdomain_index()].lighter(50); CGAL::Color color(UC(c.red()), UC(c.green()), UC(c.blue())); diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index f3e83ae55dd..40dd2d5310e 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -973,7 +973,13 @@ void Viewer::drawVisualHints() //Prints the displayMessage QFont font = QFont(); QFontMetrics fm(font); - TextItem *message_text = new TextItem(float(10 + fm.width(d->message)/2), + TextItem *message_text = new TextItem(float(10 + + #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + fm.horizontalAdvance(d->message)/2) + #else + fm.width(d->message)/2) + #endif + , float(height()-20), 0, d->message, false, QFont(), Qt::gray ); diff --git a/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp index 1d9eaabc9d1..dba4802cfec 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp +++ b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp @@ -26,7 +26,7 @@ MainWindow::MainWindow(QWidget* parent) m_pViewer = ui->viewer; // does not save the state of the viewer - m_pViewer->setStateFileName(QString::null); + m_pViewer->setStateFileName(QString()); // accepts drop events setAcceptDrops(true); diff --git a/Three/include/CGAL/Three/TextRenderer.h b/Three/include/CGAL/Three/TextRenderer.h index d9c3417fd21..1c7905f3011 100644 --- a/Three/include/CGAL/Three/TextRenderer.h +++ b/Three/include/CGAL/Three/TextRenderer.h @@ -30,6 +30,7 @@ #include #include +#include class QVector3D; namespace CGAL{ @@ -60,7 +61,12 @@ public : :x(p_x), y(p_y), z(p_z),_3D(p_3D), _is_always_visible(always_visible), m_text(p_text), m_font(font), m_color(p_color) { QFontMetrics fm(m_font); - _width = float(fm.width(m_text)); +#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + _width = float(fm.horizontalAdvance(m_text)+2); +#else + _width = float(fm.width(m_text)+2); +#endif + _height = float(fm.height()); } //!\brief Accessor for the string diff --git a/Triangulation_3/demo/Triangulation_3/Viewer.cpp b/Triangulation_3/demo/Triangulation_3/Viewer.cpp index 1bf46499f87..3d3f0d54ffb 100644 --- a/Triangulation_3/demo/Triangulation_3/Viewer.cpp +++ b/Triangulation_3/demo/Triangulation_3/Viewer.cpp @@ -1766,7 +1766,7 @@ void Viewer::endSelection(const QPoint& p) QList depths = picked_IDs.keys(); if(!depths.isEmpty()) { - qSort(depths); + std::sort(depths.begin(), depths.end()); id = picked_IDs[depths.first()]; picked = true; } @@ -2267,7 +2267,7 @@ void Viewer::keyPressEvent(QKeyEvent *event) else if( m_curMode == SELECT && event->key()==Qt::Key_Delete && modifiers==Qt::NoButton ) { // sort selected id's in descending order - qSort(m_vidSeled.begin(), m_vidSeled.end(), qGreater()); + std::sort(m_vidSeled.begin(), m_vidSeled.end(), std::greater()); for(QList::iterator vit=m_vidSeled.begin(); vit