Skip to content

Commit

Permalink
Mapple can be built with Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
LiangliangNan committed Dec 14, 2024
1 parent 8d5541c commit 65ed5bd
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 61 deletions.
16 changes: 8 additions & 8 deletions applications/Mapple/dialogs/dialog_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ DialogProperties::DialogProperties(MainWindow *window)
margins.setLeft(7);
lineEditNewPropertyName->setTextMargins(margins);

connect(comboBoxCommand, SIGNAL(currentIndexChanged(const QString &)), this,
connect(comboBoxCommand, SIGNAL(currentTextChanged(const QString &)), this,
SLOT(commandChanged(const QString &)));
connect(comboBoxModels, SIGNAL(currentIndexChanged(const QString &)), this,
connect(comboBoxModels, SIGNAL(currentTextChanged(const QString &)), this,
SLOT(modelChanged(const QString &)));
connect(comboBoxPropertyLocation, SIGNAL(currentIndexChanged(const QString &)), this,
connect(comboBoxPropertyLocation, SIGNAL(currentTextChanged(const QString &)), this,
SLOT(locationChanged(const QString &)));
connect(comboBoxPropertyName, SIGNAL(currentIndexChanged(const QString &)), this,
connect(comboBoxPropertyName, SIGNAL(currentTextChanged(const QString &)), this,
SLOT(propertyChanged(const QString &)));
connect(updateButton, SIGNAL(clicked()), this, SLOT(updateProperties()));
connect(applyButton, SIGNAL(clicked()), this, SLOT(applyCommand()));
Expand Down Expand Up @@ -176,7 +176,7 @@ void DialogProperties::modelChanged(const QString &text) {
if (!model)
return;

disconnect(comboBoxPropertyLocation, SIGNAL(currentIndexChanged(const QString &)), this,
disconnect(comboBoxPropertyLocation, SIGNAL(currentTextChanged(const QString &)), this,
SLOT(locationChanged(const QString &)));

if (dynamic_cast<SurfaceMesh *>(model)) {
Expand All @@ -203,7 +203,7 @@ void DialogProperties::modelChanged(const QString &text) {

locationChanged(comboBoxPropertyLocation->currentText());

connect(comboBoxPropertyLocation, SIGNAL(currentIndexChanged(const QString &)), this,
connect(comboBoxPropertyLocation, SIGNAL(currentTextChanged(const QString &)), this,
SLOT(locationChanged(const QString &)));
}

Expand Down Expand Up @@ -1127,7 +1127,7 @@ void DialogProperties::updateProperties() {
const std::string &model_text = comboBoxModels->currentText().toStdString();
bool model_text_has_match = false;

disconnect(comboBoxModels, SIGNAL(currentIndexChanged(const QString &)), this,
disconnect(comboBoxModels, SIGNAL(currentTextChanged(const QString &)), this,
SLOT(modelChanged(const QString &)));
comboBoxModels->clear();

Expand All @@ -1151,7 +1151,7 @@ void DialogProperties::updateProperties() {
}
modelChanged(comboBoxModels->currentText());

connect(comboBoxModels, SIGNAL(currentIndexChanged(QString)), this, SLOT(modelChanged(QString)));
connect(comboBoxModels, SIGNAL(currentTextChanged(const QString&)), this, SLOT(modelChanged(const QString&)));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ DialogSurfaceMeshRemeshing::DialogSurfaceMeshRemeshing(MainWindow *window)
comboBoxScheme->addItem("Adaptive Remeshing");
comboBoxScheme->setCurrentIndex(0);

connect(comboBoxScheme, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(setRemeshingScheme(const QString &)));
connect(comboBoxScheme, SIGNAL(currentTextChanged(const QString &)),this, SLOT(setRemeshingScheme(const QString &)));

layout()->setSizeConstraint(QLayout::SetFixedSize);
connect(okButton, SIGNAL(clicked()), this, SLOT(apply()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ DialogSurfaceMeshSmoothing::DialogSurfaceMeshSmoothing(MainWindow *window)
comboBoxScheme->addItem("Implicit Smoothing");
comboBoxScheme->setCurrentIndex(0);

connect(comboBoxScheme, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(setSmoothingScheme(const QString &)));
connect(comboBoxScheme, SIGNAL(currentTextChanged(const QString &)),this, SLOT(setSmoothingScheme(const QString &)));

layout()->setSizeConstraint(QLayout::SetFixedSize);
connect(okButton, SIGNAL(clicked()), this, SLOT(apply()));
Expand Down
13 changes: 2 additions & 11 deletions applications/Mapple/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

#include <QStyleFactory>
#include <QSurfaceFormat>
#include <QGLFormat>
#include <QElapsedTimer>
#include <QException>

Expand Down Expand Up @@ -123,8 +122,9 @@ int main(int argc, char *argv[]) {
//QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);

QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#if (defined(Q_OS_WIN) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif

Expand Down Expand Up @@ -164,15 +164,6 @@ int main(int argc, char *argv[]) {
}
#endif

if (!QGLFormat::hasOpenGL()) {
LOG(ERROR) << "Mapple needs OpenGL to run";
return EXIT_FAILURE;
}
if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_3_2) == 0) {
LOG(ERROR) << "Mapple needs OpenGL 3.2 at least to run";
return EXIT_FAILURE;
}

try {
MainWindow win;
if (!logging::log_file().empty())
Expand Down
16 changes: 9 additions & 7 deletions applications/Mapple/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <QSettings>
#include <QMessageBox>
#include <QColorDialog>
#include <QCoreApplication>
#include <QActionGroup>
#include <QLabel>
#include <QPushButton>
#include <QProgressBar>
Expand Down Expand Up @@ -835,12 +835,14 @@ void MainWindow::restoreCameraStateFromFile() {
bool MainWindow::okToContinue()
{
if (isWindowModified()) {
int r = QMessageBox::warning(this, tr("Mapple"),
tr("The model has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No,
QMessageBox::Cancel | QMessageBox::Escape);
QMessageBox::StandardButton r = QMessageBox::warning(
this,
tr("Mapple"),
tr("The model has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
QMessageBox::Yes
);
if (r == QMessageBox::Yes)
return onSave();
else if (r == QMessageBox::Cancel)
Expand Down
16 changes: 8 additions & 8 deletions applications/Mapple/widgets/widget_drawable_lines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ WidgetLinesDrawable::WidgetLinesDrawable(QWidget *parent)

void WidgetLinesDrawable::connectAll() {
// which drawable
connect(ui_->comboBoxDrawables, SIGNAL(currentIndexChanged(const QString &)),
connect(ui_->comboBoxDrawables, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setActiveDrawable(const QString &)));

// visible
Expand All @@ -75,11 +75,11 @@ void WidgetLinesDrawable::connectAll() {
connect(ui_->doubleSpinBoxLineWidth, SIGNAL(valueChanged(double)), this, SLOT(setLineWidth(double)));

// imposter
connect(ui_->comboBoxImposterStyle, SIGNAL(currentIndexChanged(const QString &)),
connect(ui_->comboBoxImposterStyle, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setImposterStyle(const QString &)));

// color scheme
connect(ui_->comboBoxColorScheme, SIGNAL(currentIndexChanged(const QString &)),
connect(ui_->comboBoxColorScheme, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setColorScheme(const QString &)));

// default color
Expand All @@ -99,15 +99,15 @@ void WidgetLinesDrawable::connectAll() {
connect(ui_->doubleSpinBoxScalarFieldClampUpper, SIGNAL(valueChanged(double)), this, SLOT(setScalarFieldClampUpper(double)));

// vector field
connect(ui_->comboBoxVectorField, SIGNAL(currentIndexChanged(const QString&)), this,
connect(ui_->comboBoxVectorField, SIGNAL(currentTextChanged(const QString&)), this,
SLOT(setVectorField(const QString&)));
connect(ui_->doubleSpinBoxVectorFieldScale, SIGNAL(valueChanged(double)), this, SLOT(setVectorFieldScale(double)));
}


void WidgetLinesDrawable::disconnectAll() {
// which drawable
disconnect(ui_->comboBoxDrawables, SIGNAL(currentIndexChanged(const QString &)),
disconnect(ui_->comboBoxDrawables, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setActiveDrawable(const QString &)));

// visible
Expand All @@ -117,11 +117,11 @@ void WidgetLinesDrawable::disconnectAll() {
disconnect(ui_->doubleSpinBoxLineWidth, SIGNAL(valueChanged(double)), this, SLOT(setLineWidth(double)));

// imposter
disconnect(ui_->comboBoxImposterStyle, SIGNAL(currentIndexChanged(const QString &)),
disconnect(ui_->comboBoxImposterStyle, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setImposterStyle(const QString &)));

// color scheme
disconnect(ui_->comboBoxColorScheme, SIGNAL(currentIndexChanged(const QString &)),
disconnect(ui_->comboBoxColorScheme, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setColorScheme(const QString &)));

// default color
Expand All @@ -141,7 +141,7 @@ void WidgetLinesDrawable::disconnectAll() {
disconnect(ui_->doubleSpinBoxScalarFieldClampUpper, SIGNAL(valueChanged(double)), this, SLOT(setScalarFieldClampUpper(double)));

// vector field
disconnect(ui_->comboBoxVectorField, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setVectorField(const QString&)));
disconnect(ui_->comboBoxVectorField, SIGNAL(currentTextChanged(const QString&)), this, SLOT(setVectorField(const QString&)));
disconnect(ui_->doubleSpinBoxVectorFieldScale, SIGNAL(valueChanged(double)), this, SLOT(setVectorFieldScale(double)));
}

Expand Down
20 changes: 10 additions & 10 deletions applications/Mapple/widgets/widget_drawable_points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ WidgetPointsDrawable::WidgetPointsDrawable(QWidget *parent)

void WidgetPointsDrawable::connectAll() {
// which drawable
connect(ui_->comboBoxDrawables, SIGNAL(currentIndexChanged(const QString &)),
connect(ui_->comboBoxDrawables, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setActiveDrawable(const QString &)));

// visible
Expand All @@ -77,15 +77,15 @@ void WidgetPointsDrawable::connectAll() {
connect(ui_->doubleSpinBoxPointSize, SIGNAL(valueChanged(double)), this, SLOT(setPointSize(double)));

// imposter
connect(ui_->comboBoxImposterStyle, SIGNAL(currentIndexChanged(const QString &)),
connect(ui_->comboBoxImposterStyle, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setImposterStyle(const QString &)));

// lighting
connect(ui_->comboBoxLightingOptions, SIGNAL(currentIndexChanged(const QString &)),
connect(ui_->comboBoxLightingOptions, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setLighting(const QString &)));

// color scheme
connect(ui_->comboBoxColorScheme, SIGNAL(currentIndexChanged(const QString &)),
connect(ui_->comboBoxColorScheme, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setColorScheme(const QString &)));

// default color
Expand All @@ -109,15 +109,15 @@ void WidgetPointsDrawable::connectAll() {
connect(ui_->doubleSpinBoxScalarFieldClampUpper, SIGNAL(valueChanged(double)), this, SLOT(setScalarFieldClampUpper(double)));

// vector field
connect(ui_->comboBoxVectorField, SIGNAL(currentIndexChanged(const QString&)), this,
connect(ui_->comboBoxVectorField, SIGNAL(currentTextChanged(const QString&)), this,
SLOT(setVectorField(const QString&)));
connect(ui_->doubleSpinBoxVectorFieldScale, SIGNAL(valueChanged(double)), this, SLOT(setVectorFieldScale(double)));
}


void WidgetPointsDrawable::disconnectAll() {
// which drawable
disconnect(ui_->comboBoxDrawables, SIGNAL(currentIndexChanged(const QString &)),
disconnect(ui_->comboBoxDrawables, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setActiveDrawable(const QString &)));

// visible
Expand All @@ -127,15 +127,15 @@ void WidgetPointsDrawable::disconnectAll() {
disconnect(ui_->doubleSpinBoxPointSize, SIGNAL(valueChanged(double)), this, SLOT(setPointSize(double)));

// imposter
disconnect(ui_->comboBoxImposterStyle, SIGNAL(currentIndexChanged(const QString &)),
disconnect(ui_->comboBoxImposterStyle, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setImposterStyle(const QString &)));

// lighting
disconnect(ui_->comboBoxLightingOptions, SIGNAL(currentIndexChanged(const QString &)),
disconnect(ui_->comboBoxLightingOptions, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setLighting(const QString &)));

// color scheme
disconnect(ui_->comboBoxColorScheme, SIGNAL(currentIndexChanged(const QString &)),
disconnect(ui_->comboBoxColorScheme, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(setColorScheme(const QString &)));

// default color
Expand All @@ -159,7 +159,7 @@ void WidgetPointsDrawable::disconnectAll() {
disconnect(ui_->doubleSpinBoxScalarFieldClampUpper, SIGNAL(valueChanged(double)), this, SLOT(setScalarFieldClampUpper(double)));

// vector field
disconnect(ui_->comboBoxVectorField, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setVectorField(const QString&)));
disconnect(ui_->comboBoxVectorField, SIGNAL(currentTextChanged(const QString&)), this, SLOT(setVectorField(const QString&)));
disconnect(ui_->doubleSpinBoxVectorFieldScale, SIGNAL(valueChanged(double)), this, SLOT(setVectorFieldScale(double)));
}

Expand Down
16 changes: 8 additions & 8 deletions applications/Mapple/widgets/widget_drawable_triangles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ WidgetTrianglesDrawable::WidgetTrianglesDrawable(QWidget *parent)

void WidgetTrianglesDrawable::connectAll() {
// which drawable
connect(ui_->comboBoxDrawables, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(setActiveDrawable(const QString &)));
connect(ui_->comboBoxDrawables, SIGNAL(currentTextChanged(const QString &)),this, SLOT(setActiveDrawable(const QString &)));

// visible
connect(ui_->checkBoxVisible, SIGNAL(toggled(bool)), this, SLOT(setDrawableVisible(bool)));
Expand All @@ -78,10 +78,10 @@ void WidgetTrianglesDrawable::connectAll() {
connect(ui_->checkBoxPhongShading, SIGNAL(toggled(bool)), this, SLOT(setPhongShading(bool)));

// lighting
connect(ui_->comboBoxLightingOptions, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(setLighting(const QString &)));
connect(ui_->comboBoxLightingOptions, SIGNAL(currentTextChanged(const QString &)),this, SLOT(setLighting(const QString &)));

// color scheme
connect(ui_->comboBoxColorScheme, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(setColorScheme(const QString &)));
connect(ui_->comboBoxColorScheme, SIGNAL(currentTextChanged(const QString &)),this, SLOT(setColorScheme(const QString &)));

// default color
connect(ui_->toolButtonDefaultColor, SIGNAL(clicked()), this, SLOT(setDefaultColor()));
Expand Down Expand Up @@ -112,14 +112,14 @@ void WidgetTrianglesDrawable::connectAll() {
connect(ui_->doubleSpinBoxScalarFieldClampUpper, SIGNAL(valueChanged(double)), this, SLOT(setScalarFieldClampUpper(double)));

// vector field
connect(ui_->comboBoxVectorField, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setVectorField(const QString&)));
connect(ui_->comboBoxVectorField, SIGNAL(currentTextChanged(const QString&)), this, SLOT(setVectorField(const QString&)));
connect(ui_->doubleSpinBoxVectorFieldScale, SIGNAL(valueChanged(double)), this, SLOT(setVectorFieldScale(double)));
}


void WidgetTrianglesDrawable::disconnectAll() {
// which drawable
disconnect(ui_->comboBoxDrawables, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(setActiveDrawable(const QString &)));
disconnect(ui_->comboBoxDrawables, SIGNAL(currentTextChanged(const QString &)),this, SLOT(setActiveDrawable(const QString &)));

// visible
disconnect(ui_->checkBoxVisible, SIGNAL(toggled(bool)), this, SLOT(setDrawableVisible(bool)));
Expand All @@ -128,10 +128,10 @@ void WidgetTrianglesDrawable::disconnectAll() {
disconnect(ui_->checkBoxPhongShading, SIGNAL(toggled(bool)), this, SLOT(setPhongShading(bool)));

// lighting
disconnect(ui_->comboBoxLightingOptions, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(setLighting(const QString &)));
disconnect(ui_->comboBoxLightingOptions, SIGNAL(currentTextChanged(const QString &)),this, SLOT(setLighting(const QString &)));

// color scheme
disconnect(ui_->comboBoxColorScheme, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(setColorScheme(const QString &)));
disconnect(ui_->comboBoxColorScheme, SIGNAL(currentTextChanged(const QString &)),this, SLOT(setColorScheme(const QString &)));

// default color
disconnect(ui_->toolButtonDefaultColor, SIGNAL(clicked()), this, SLOT(setDefaultColor()));
Expand Down Expand Up @@ -162,7 +162,7 @@ void WidgetTrianglesDrawable::disconnectAll() {
disconnect(ui_->doubleSpinBoxScalarFieldClampUpper, SIGNAL(valueChanged(double)), this, SLOT(setScalarFieldClampUpper(double)));

// vector field
disconnect(ui_->comboBoxVectorField, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setVectorField(const QString&)));
disconnect(ui_->comboBoxVectorField, SIGNAL(currentTextChanged(const QString&)), this, SLOT(setVectorField(const QString&)));
disconnect(ui_->doubleSpinBoxVectorFieldScale, SIGNAL(valueChanged(double)), this, SLOT(setVectorFieldScale(double)));
}

Expand Down
3 changes: 3 additions & 0 deletions easy3d/algo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ add_module(${module} "${${module}_headers}" "${${module}_sources}" "${private_de
target_include_directories(easy3d_${module} PRIVATE ${Easy3D_THIRD_PARTY}/eigen ${Easy3D_THIRD_PARTY}/ransac)

# It's "Boost", not "BOOST" or "boost". Case matters.
if (POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif ()
find_package(Boost COMPONENTS graph)
if (Boost_FOUND)
target_include_directories(easy3d_${module} PRIVATE ${Boost_INCLUDE_DIRS})
Expand Down
2 changes: 1 addition & 1 deletion tutorials/Tutorial_204_Viewer_Qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ int main(int argc, char *argv[]) {
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);

QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif

Expand Down
14 changes: 8 additions & 6 deletions tutorials/Tutorial_204_Viewer_Qt/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,14 @@ namespace easy3d {

bool Window::okToContinue() {
if (isWindowModified()) {
int r = QMessageBox::warning(this, tr("Viewer"),
tr("The model has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No,
QMessageBox::Cancel | QMessageBox::Escape);
QMessageBox::StandardButton r = QMessageBox::warning(
this,
tr("Viewer"),
tr("The model has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
QMessageBox::Yes
);
if (r == QMessageBox::Yes)
return onSave();
else if (r == QMessageBox::Cancel)
Expand Down

0 comments on commit 65ed5bd

Please sign in to comment.