From a9bdccc179b23541f24bc274c6ad6bc747f8db6d Mon Sep 17 00:00:00 2001 From: agarnung Date: Mon, 13 Jan 2025 00:47:26 +0100 Subject: [PATCH 1/3] Added gitignore --- .gitignore | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..32db2d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Compiled source +*.o +/build/* + +# Executables +* +!*.* +!*/ + +/*.pro.user + +*.idx + +*.qmake.stash + +# C++ objects and libs +*.o +*.so +*.so.* +*.a + +# Qt +*.pro.user +*.pro.user.* +moc_*.cpp +moc_*.h +qrc_*.cpp +ui_*.h +.qtc_clangd* From b5710c5fb4120dd434d0f871922fa17b26cdd630 Mon Sep 17 00:00:00 2001 From: agarnung Date: Mon, 13 Jan 2025 00:48:25 +0100 Subject: [PATCH 2/3] Initial adaptation to Qt 6. Tested. --- src/Denoising/glexaminer.cpp | 2 +- src/Denoising/glviewer.cpp | 40 ++++++++++++++++++----------- src/Denoising/glviewer.h | 50 ++++++++++++++++++------------------ src/Denoising/main.cpp | 2 +- src/Denoising/mainwindow.cpp | 15 ++++++----- src/Denoising/mainwindow.h | 1 + 6 files changed, 61 insertions(+), 49 deletions(-) diff --git a/src/Denoising/glexaminer.cpp b/src/Denoising/glexaminer.cpp index f37413b..8b6cdd7 100755 --- a/src/Denoising/glexaminer.cpp +++ b/src/Denoising/glexaminer.cpp @@ -181,7 +181,7 @@ void GLExaminer::mouseReleaseEvent(QMouseEvent* event) void GLExaminer::wheelEvent(QWheelEvent *event) { - float dx = event->delta() * 0.5; + float dx = event->angleDelta().y() * 0.5f; zoom(dx); } diff --git a/src/Denoising/glviewer.cpp b/src/Denoising/glviewer.cpp index e188057..e06bb71 100755 --- a/src/Denoising/glviewer.cpp +++ b/src/Denoising/glviewer.cpp @@ -1,17 +1,18 @@ #include "glviewer.h" #include #include +#include +#include -GLViewer::GLViewer(QWidget *parent) - :QGLWidget(parent) +GLViewer::GLViewer(QWindow *parent) + : QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent), examiner_(nullptr), backgroundColor_(Qt::black) { examiner_ = new MeshExaminer(); } GLViewer::~GLViewer() { - if(examiner_) delete examiner_; - examiner_ = NULL; + delete examiner_; } void GLViewer::mousePressEvent(QMouseEvent *event) @@ -27,33 +28,42 @@ void GLViewer::mouseReleaseEvent(QMouseEvent *event) void GLViewer::mouseMoveEvent(QMouseEvent *event) { examiner_->mouseMoveEvent(event); - this->updateGL(); + this->update(); } void GLViewer::wheelEvent(QWheelEvent *event) { examiner_->wheelEvent(event); - this->updateGL(); + this->update(); } void GLViewer::mouseDoubleClickEvent(QMouseEvent*) { + // No operation } -void GLViewer::paintGL() +void GLViewer::initializeGL() { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - examiner_->draw(); + QOpenGLFunctions *gl = context()->functions(); + gl->glClearColor(backgroundColor_.redF(), backgroundColor_.greenF(), backgroundColor_.blueF(), 1.0f); + examiner_->init(); } -void GLViewer::initializeGL() +void GLViewer::resizeEvent(QResizeEvent *event) { - examiner_->init(); + QOpenGLWindow::resizeEvent(event); + if (examiner_) { + examiner_->reshape(event->size().width(), event->size().height()); + } } -void GLViewer::resizeGL(int _w, int _h) +void GLViewer::paintEvent(QPaintEvent*) { - examiner_->reshape(_w, _h); + QOpenGLFunctions *gl = context()->functions(); + gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + if (examiner_) { + examiner_->draw(); + } } void GLViewer::updateMesh(const TriMesh &_mesh) @@ -61,7 +71,7 @@ void GLViewer::updateMesh(const TriMesh &_mesh) examiner_->updateMesh(_mesh); } -void GLViewer::resetMesh(const TriMesh &_mesh, bool _need_normalize) +void GLViewer::resetMesh(const TriMesh &_mesh, bool _needNormalize) { - examiner_->resetMesh(_mesh, _need_normalize); + examiner_->resetMesh(_mesh, _needNormalize); } diff --git a/src/Denoising/glviewer.h b/src/Denoising/glviewer.h index 896ace3..3c70f2e 100755 --- a/src/Denoising/glviewer.h +++ b/src/Denoising/glviewer.h @@ -1,62 +1,62 @@ #ifndef GLVIEWER_H #define GLVIEWER_H -#include -#include "meshexaminer.h" - +#include #include +#include "meshexaminer.h" -class GLViewer : public QGLWidget +class GLViewer : public QOpenGLWindow { Q_OBJECT public: - GLViewer(QWidget *parent = 0); + explicit GLViewer(QWindow *parent = nullptr); ~GLViewer(); void updateMesh(const TriMesh &_mesh); void resetMesh(const TriMesh &_mesh, bool _needNormalize = false); - MeshExaminer* getExaminer(){ + MeshExaminer* getExaminer() { return examiner_; } public slots: - void setDrawPointsStatus(bool _val){ + void setDrawPointsStatus(bool _val) { examiner_->setDrawPointsStatus(_val); - this->updateGL(); + this->update(); } - void setDrawFacesStatus(bool _val){ + void setDrawFacesStatus(bool _val) { examiner_->setDrawFacesStatus(_val); - this->updateGL(); + this->update(); } - void setDrawEdgesStatus(bool _val){ + void setDrawEdgesStatus(bool _val) { examiner_->setDrawEdgesStatus(_val); - this->updateGL(); + this->update(); } - void setBackgroundColor(){ - QColor color = QColorDialog::getColor(Qt::black, this, tr("Set Background Color!")); - if(!color.isValid()) return; - this->qglClearColor(color); - this->updateGL(); + void setBackgroundColor() { + QColor color = QColorDialog::getColor(Qt::black, nullptr, tr("Set Background Color!")); + if (!color.isValid()) return; + backgroundColor_ = color; + this->update(); } protected: - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void wheelEvent(QWheelEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; - void initializeGL(); - void resizeGL(int _w, int _h); - void paintGL(); + void initializeGL() override; + void resizeEvent(QResizeEvent *event) override; + void paintEvent(QPaintEvent *event) override; private: MeshExaminer *examiner_; + QColor backgroundColor_; }; #endif // GLVIEWER_H diff --git a/src/Denoising/main.cpp b/src/Denoising/main.cpp index c9bbbad..f20a3fc 100755 --- a/src/Denoising/main.cpp +++ b/src/Denoising/main.cpp @@ -3,7 +3,7 @@ int main(int argc, char *argv[]) { - QApplication::setStyle(QStyleFactory::create("cleanlooks")); + QApplication::setStyle(QStyleFactory::create("fusion")); QApplication a(argc, argv); MainWindow w; w.show(); diff --git a/src/Denoising/mainwindow.cpp b/src/Denoising/mainwindow.cpp index 435c710..84d79b1 100755 --- a/src/Denoising/mainwindow.cpp +++ b/src/Denoising/mainwindow.cpp @@ -29,7 +29,8 @@ MainWindow::MainWindow(QWidget *parent) : QHBoxLayout *layout_main = new QHBoxLayout; layout_main->addLayout(layout_left_); - layout_main->addWidget(opengl_viewer_); + viewer_container = QWidget::createWindowContainer(opengl_viewer_, this); + layout_main->addWidget(viewer_container); layout_main->setStretch(1,1); this->centralWidget()->setLayout(layout_main); } @@ -57,7 +58,7 @@ MainWindow::~MainWindow() void MainWindow::init() { - opengl_viewer_ = new GLViewer(this); + opengl_viewer_ = new GLViewer(); data_manager_ = new DataManager(); parameter_set_ = new ParameterSet(); parameter_set_widget_ = NULL; @@ -274,21 +275,21 @@ void MainWindow::TransToNoisyMesh() { data_manager_->MeshToNoisyMesh(); opengl_viewer_->resetMesh(data_manager_->getMesh()); - opengl_viewer_->updateGL(); + opengl_viewer_->update(); } void MainWindow::TransToOriginalMesh() { data_manager_->MeshToOriginalMesh(); opengl_viewer_->resetMesh(data_manager_->getMesh()); - opengl_viewer_->updateGL(); + opengl_viewer_->update(); } void MainWindow::TransToDenoisedMesh() { data_manager_->MeshToDenoisedMesh(); opengl_viewer_->resetMesh(data_manager_->getMesh()); - opengl_viewer_->updateGL(); + opengl_viewer_->update(); } void MainWindow::ClearMesh() @@ -296,7 +297,7 @@ void MainWindow::ClearMesh() CloseWidget(); data_manager_->ClearMesh(); opengl_viewer_->resetMesh(data_manager_->getMesh()); - opengl_viewer_->updateGL(); + opengl_viewer_->update(); SetActionStatus(false); action_import_mesh_->setEnabled(true); } @@ -369,7 +370,7 @@ void MainWindow::setActionAndWidget(bool value1, bool value2) void MainWindow::needToUpdateGL(bool value) { opengl_viewer_->resetMesh(data_manager_->getMesh(), value); - opengl_viewer_->updateGL(); + opengl_viewer_->update(); } void MainWindow::About() diff --git a/src/Denoising/mainwindow.h b/src/Denoising/mainwindow.h index 33c6278..4dd92c2 100755 --- a/src/Denoising/mainwindow.h +++ b/src/Denoising/mainwindow.h @@ -97,6 +97,7 @@ private slots: private: // glviewer GLViewer *opengl_viewer_; + QWidget *viewer_container; // datamanager DataManager *data_manager_; // parameter set From 1bc234fd0f3d29ab3bd796f8c5fc13619684f7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Garnung=20Men=C3=A9ndez?= Date: Mon, 13 Jan 2025 00:53:46 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 54dc405..6d6c9d2 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,7 @@ It also implements the denoising methods from the following papers for compariso The code has been tested on the following platforms: -* Windows 10 with Qt 5.11.2, Qt Creator 4.7.1, and MSVC 2017 Community Edition (older versions of MSVC may not work); -* Debian Buster with Qt 5.11.1, Qt Creator 4.6.2, and GCC 8.2.0. +* Pop!_OS 22.04 LTS with Qt 6.8.1, Qt Creator 15.0.0 and GCC 11.4.0. ### Compiling the source code: @@ -53,4 +52,4 @@ This software is released under GNU LGPL V3. ### Contact -If you have any question, please contact Wangyu Zhang <zhwangyu@mail.ustc.edu.cn> or Bailin Deng <bldeng@gmail.com>. \ No newline at end of file +If you have any question, please contact Wangyu Zhang <zhwangyu@mail.ustc.edu.cn> or Bailin Deng <bldeng@gmail.com>.