Skip to content

Commit

Permalink
Remove deprecated Qt version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
SaillantNicolas committed Aug 19, 2024
1 parent 926dab0 commit 1286d8b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ void GridGraphicsItem::setSpacing(int spacing_)
static inline qreal
horizontalAdvance(const QFontMetrics& fm, const QString& text)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return fm.horizontalAdvance(text);
#else
return fm.boundingRect(text).width();
#endif
}

void GridGraphicsItem::paint(
Expand Down
7 changes: 7 additions & 0 deletions GraphicsView/include/CGAL/Qt/qglviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,13 @@ public Q_SLOTS:
qreal bufferTextureMaxU() const { return bufferTextureMaxU_; }
/*! Same as bufferTextureMaxU(), but for the v texture coordinate. */
qreal bufferTextureMaxV() const { return bufferTextureMaxV_; }
// These methods are part of the QGLWidget public API.
// As of version 2.7.0, the use of QOpenGLWidget instead means that they have
// to be provided for backward compatibility.
void renderText(int x, int y, const QString &str,
const QFont &font = QFont());
void renderText(double x, double y, double z, const QString &str,
const QFont &font = QFont());

public Q_SLOTS:
void copyBufferToTexture(GLint, GLenum = GL_NONE);
Expand Down
22 changes: 22 additions & 0 deletions GraphicsView/include/CGAL/Qt/qglviewer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,28 @@ CGAL_INLINE_FUNCTION
void CGAL::QGLViewer::drawLight(GLenum, qreal ) const {
}

CGAL_INLINE_FUNCTION
void CGAL::QGLViewer::renderText(int x, int y, const QString &str,
const QFont &font) {
QColor fontColor = QColor(0, 0,
0, 255);

// Render text
QPainter painter(this);
painter.setPen(fontColor);
painter.setFont(font);
painter.drawText(x, y, str);
painter.end();
}

CGAL_INLINE_FUNCTION
void CGAL::QGLViewer::renderText(double x, double y, double z, const QString &str,
const QFont &font) {
using CGAL::qglviewer::Vec;
const Vec proj = camera_->projectedCoordinatesOf(Vec(x, y, z));
renderText(int(proj.x), int(proj.y), str, font);
}

/*! Draws \p text at position \p x, \p y (expressed in screen coordinates
pixels, origin in the upper left corner of the widget).
Expand Down
3 changes: 3 additions & 0 deletions Lab/demo/Lab/CGAL_Lab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ int& code_to_call_before_creation_of_QCoreApplication(int& i) {
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);

// for windows
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);

return i;
}

Expand Down
6 changes: 6 additions & 0 deletions Lab/demo/Lab/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@ void MainWindow::loadPlugins()
}
}
QString env_path = qgetenv("LAB_DEMO_PLUGINS_PATH");
QChar separator = QDir::listSeparator();
#if defined(_WIN32)
QChar separator = ';';
#else
QChar separator = ':';
#endif
if(!env_path.isEmpty()) {
#if defined(_WIN32)
QString path = qgetenv("PATH");
Expand Down

0 comments on commit 1286d8b

Please sign in to comment.