Skip to content

Commit

Permalink
Further fixes for Qt6
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew J. Milner <[email protected]>
  • Loading branch information
matterhorn103 committed Sep 16, 2024
1 parent 534b2b2 commit bb9f656
Show file tree
Hide file tree
Showing 23 changed files with 180 additions and 32 deletions.
6 changes: 3 additions & 3 deletions avogadro/qtopengl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 COMPONENTS Widgets OpenGLWidgets REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Widgets OpenGLWidgets)
else()
find_package(Qt5 COMPONENTS Widgets REQUIRED)
endif()
Expand All @@ -19,7 +19,7 @@ target_sources(QtOpenGL PRIVATE
)

avogadro_add_library(QtOpenGL)
target_link_libraries(QtOpenGL Avogadro::Rendering Avogadro::QtGui Qt::Widgets)
target_link_libraries(QtOpenGL PRIVATE Avogadro::Rendering Avogadro::QtGui Qt::Widgets)
if(QT_VERSION EQUAL 6)
target_link_libraries(QtOpenGL Qt::OpenGLWidgets)
target_link_libraries(QtOpenGL PRIVATE Qt6::OpenGLWidgets)
endif()
7 changes: 6 additions & 1 deletion avogadro/qtopengl/glwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
#include <avogadro/rendering/glrenderer.h>

#include <QPointer>
#include <QOpenGLWidget>

#if QT_VERSION >= 0x060000
#include <QtOpenGLWidgets/QOpenGLWidget>
#else
#include <QOpenGLWidget>
#endif

class QTimer;

Expand Down
18 changes: 17 additions & 1 deletion avogadro/qtplugins/aligntool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 COMPONENTS Gui REQUIRED)
else()
find_package(Qt5 COMPONENTS Widgets REQUIRED)
endif()

set(aligntool_srcs
aligntool.cpp
)
Expand All @@ -19,4 +25,14 @@ avogadro_plugin(AlignTool
"${aligntool_rcs}"
)

target_link_libraries(AlignTool PRIVATE Avogadro::QtOpenGL)
target_link_libraries(AlignTool PRIVATE Avogadro::Rendering Avogadro::QtOpenGL)

if(QT_VERSION EQUAL 6)
target_link_libraries(AlignTool PRIVATE Qt6::Gui)
else()
target_link_libraries(AlignTool PRIVATE Qt5::Widgets)
endif()

target_include_directories(AlignTool
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering)
10 changes: 9 additions & 1 deletion avogadro/qtplugins/bondcentrictool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ avogadro_plugin(BondCentric
"${bondcentrictool_rcs}"
)

target_link_libraries(BondCentric PRIVATE Avogadro::QtOpenGL)
target_link_libraries(BondCentric
PRIVATE
Avogadro::Rendering
Avogadro::QtOpenGL)

target_include_directories(BondCentric
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ QString CoordinateEditorDialog::detectInputFormat() const
FORMAT_DEBUG(qDebug() << "\n\nExamining sample:" << sample;)

// Split the string into tokens, and identify the type of each.
QList<QString> tokens(sample.split(TOKEN_SEPARATOR, QString::SkipEmptyParts));
QList<QString> tokens(sample.split(TOKEN_SEPARATOR, Qt::SkipEmptyParts));
QList<TokenType> tokenTypes;
tokenTypes.reserve(tokens.size());
size_t tokenTypeCounts[3] = { 0, 0, 0 };
Expand Down
7 changes: 6 additions & 1 deletion avogadro/qtplugins/editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ avogadro_plugin(Editor
"${editor_rcs}"
)

target_link_libraries(Editor PRIVATE Avogadro::QtOpenGL)
target_link_libraries(Editor PRIVATE Avogadro::Rendering Avogadro::QtOpenGL)

target_include_directories(Editor
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
7 changes: 6 additions & 1 deletion avogadro/qtplugins/focus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ avogadro_plugin(Focus
""
)

target_link_libraries(Focus PRIVATE Avogadro::QtOpenGL)
target_link_libraries(Focus PRIVATE Avogadro::Rendering Avogadro::QtOpenGL)

target_include_directories(Focus
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
12 changes: 12 additions & 0 deletions avogadro/qtplugins/forcefield/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 COMPONENTS Gui REQUIRED)
else()
find_package(Qt5 COMPONENTS Widgets REQUIRED)
endif()

set(forcefield_srcs
forcefield.cpp
forcefielddialog.cpp
Expand Down Expand Up @@ -28,6 +34,12 @@ avogadro_plugin(Forcefield

target_link_libraries(Forcefield PRIVATE Avogadro::Calc)

if(QT_VERSION EQUAL 6)
target_link_libraries(Forcefield PRIVATE Qt6::Gui)
else()
target_link_libraries(Forcefield PRIVATE Qt5::Widgets)
endif()

if (BUILD_GPL_PLUGINS AND OpenBabel3_LIBRARY)
target_link_libraries(Forcefield PRIVATE OpenBabel3)
endif()
Expand Down
10 changes: 6 additions & 4 deletions avogadro/qtplugins/forcefield/obmmenergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ Real OBMMEnergy::value(const Eigen::VectorXd& x)
input = "coord\n";
for (Index i = 0; i < x.size(); i += 3) {
// write as x y z (space separated)
input += QString::number(x[i]) + " " + QString::number(x[i + 1]) + " " +
QString::number(x[i + 2]) + "\n";
input += QString::number(x[i]).toUtf8() + " " +
QString::number(x[i + 1]).toUtf8() + " " +
QString::number(x[i + 2]).toUtf8() + "\n";
}

result = writeAndRead(input);
Expand Down Expand Up @@ -257,8 +258,9 @@ void OBMMEnergy::gradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad)
QByteArray result, input = "coord\n";
for (Index i = 0; i < x.size(); i += 3) {
// write as x y z (space separated)
input += QString::number(x[i]) + " " + QString::number(x[i + 1]) + " " +
QString::number(x[i + 2]) + "\n";
input += QString::number(x[i]).toUtf8() + " " +
QString::number(x[i + 1]).toUtf8() + " " +
QString::number(x[i + 2]).toUtf8() + "\n";
}

result = writeAndRead(input);
Expand Down
18 changes: 11 additions & 7 deletions avogadro/qtplugins/forcefield/scriptenergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <QtCore/QDir>
#include <QtCore/QScopedPointer>

#include <QRegularExpression>

#include <qjsonarray.h>
#include <qjsondocument.h>
#include <qjsonobject.h>
Expand Down Expand Up @@ -115,8 +117,9 @@ Real ScriptEnergy::value(const Eigen::VectorXd& x)
QByteArray input;
for (Index i = 0; i < x.size(); i += 3) {
// write as x y z (space separated)
input += QString::number(x[i]) + " " + QString::number(x[i + 1]) + " " +
QString::number(x[i + 2]) + "\n";
input += QString::number(x[i]).toUtf8() + " " +
QString::number(x[i + 1]).toUtf8() + " " +
QString::number(x[i + 2]).toUtf8() + "\n";
}
QByteArray result = m_interpreter->asyncWriteAndResponse(input);

Expand All @@ -125,7 +128,7 @@ Real ScriptEnergy::value(const Eigen::VectorXd& x)
double energy = 0.0;
for (auto line : lines) {
if (line.startsWith("AvogadroEnergy:")) {
QStringList items = line.split(" ", QString::SkipEmptyParts);
QStringList items = line.split(" ", Qt::SkipEmptyParts);
if (items.size() > 1) {
energy = items[1].toDouble();
break;
Expand All @@ -148,8 +151,9 @@ void ScriptEnergy::gradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad)
QByteArray input;
for (Index i = 0; i < x.size(); i += 3) {
// write as x y z (space separated)
input += QString::number(x[i]) + " " + QString::number(x[i + 1]) + " " +
QString::number(x[i + 2]) + "\n";
input += QString::number(x[i]).toUtf8() + " " +
QString::number(x[i + 1]).toUtf8() + " " +
QString::number(x[i + 2]).toUtf8() + "\n";
}
QByteArray result = m_interpreter->asyncWriteAndResponse(input);

Expand All @@ -165,7 +169,7 @@ void ScriptEnergy::gradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad)
}

if (readingGrad) {
QStringList items = line.split(" ", QString::SkipEmptyParts);
QStringList items = line.split(" ", Qt::SkipEmptyParts);
if (items.size() == 3) {
grad[i] = items[0].toDouble();
grad[i + 1] = items[1].toDouble();
Expand Down Expand Up @@ -365,7 +369,7 @@ void ScriptEnergy::processElementString(const QString& str)
QString str2(str);
str2.replace(',', ' ');
// then split on whitespace
QStringList strList = str2.split(QRegExp("\\s+"), QString::SkipEmptyParts);
QStringList strList = str2.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
foreach (QString sstr, strList) {
// these should be numbers or ranges (e.g., 1-84)
if (sstr.contains('-')) {
Expand Down
10 changes: 9 additions & 1 deletion avogadro/qtplugins/label/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ avogadro_plugin(LabelEditor
)

target_link_libraries(Label LINK_PRIVATE Avogadro::Rendering)
target_link_libraries(LabelEditor LINK_PRIVATE Avogadro::QtOpenGL)
target_link_libraries(LabelEditor
LINK_PRIVATE
Avogadro::Rendering
Avogadro::QtOpenGL)

target_include_directories(LabelEditor
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
10 changes: 9 additions & 1 deletion avogadro/qtplugins/manipulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ avogadro_plugin(Manipulator
"${manipulator_rcs}"
)

target_link_libraries(Manipulator PRIVATE Avogadro::QtOpenGL)
target_link_libraries(Manipulator
PRIVATE
Avogadro::Rendering
Avogadro::QtOpenGL)

target_include_directories(Manipulator
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
7 changes: 6 additions & 1 deletion avogadro/qtplugins/measuretool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ avogadro_plugin(MeasureTool
"${measuretool_rcs}"
)

target_link_libraries(MeasureTool PRIVATE Avogadro::QtOpenGL)
target_link_libraries(MeasureTool PRIVATE Avogadro::Rendering Avogadro::QtOpenGL)

target_include_directories(MeasureTool
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
7 changes: 6 additions & 1 deletion avogadro/qtplugins/navigator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ avogadro_plugin(Navigator
"${navigator_rcs}"
)

target_link_libraries(Navigator PRIVATE Avogadro::QtOpenGL)
target_link_libraries(Navigator PRIVATE Avogadro::Rendering Avogadro::QtOpenGL)

target_include_directories(Navigator
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
20 changes: 20 additions & 0 deletions avogadro/qtplugins/playertool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6
REQUIRED COMPONENTS
OpenGL
OpenGLWidgets)
endif()

avogadro_plugin(PlayerTool
"Player tool"
ToolPlugin
Expand All @@ -12,4 +19,17 @@ target_link_libraries(PlayerTool
PRIVATE
gwavi
gif-h
Avogadro::Rendering
Avogadro::QtOpenGL)

if(QT_VERSION EQUAL 6)
target_link_libraries(PlayerTool
PRIVATE
Qt6::OpenGL
Qt6::OpenGLWidgets)
endif()

target_include_directories(PlayerTool
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
6 changes: 3 additions & 3 deletions avogadro/qtplugins/qtaim/qtaimwavefunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ bool QTAIMWavefunction::initializeWithWFNFile(const QString& fileName)

while (fileContentsByLine.first().startsWith("TYPE ASSIGNMENTS")) {
QString line(fileContentsByLine.first().mid(20, -1));
QStringList splitLine(line.split(" ", QString::SkipEmptyParts));
QStringList splitLine(line.split(" ", Qt::SkipEmptyParts));

for (qint64 i = 0; i < splitLine.length(); ++i) {
typeAssignmentsList.append(splitLine.at(i).toLongLong());
Expand Down Expand Up @@ -261,7 +261,7 @@ bool QTAIMWavefunction::initializeWithWFNFile(const QString& fileName)

while (fileContentsByLine.first().startsWith("EXPONENTS")) {
QString line(fileContentsByLine.first().mid(9, -1));
QStringList splitLine(line.split(" ", QString::SkipEmptyParts));
QStringList splitLine(line.split(" ", Qt::SkipEmptyParts));

for (qint64 i = 0; i < splitLine.length(); ++i) {
QString str(splitLine.at(i));
Expand Down Expand Up @@ -324,7 +324,7 @@ bool QTAIMWavefunction::initializeWithWFNFile(const QString& fileName)
m_molecularOrbitalEigenvalues[i] = molecularOrbitalEigenvaluesList.at(i);

moCoefficientsStringList =
moCoefficientsStringList.join(" ").split(" ", QString::SkipEmptyParts);
moCoefficientsStringList.join(" ").split(" ", Qt::SkipEmptyParts);

for (qint64 i = 0; i < moCoefficientsStringList.length(); ++i) {
QString str(moCoefficientsStringList.at(i));
Expand Down
17 changes: 16 additions & 1 deletion avogadro/qtplugins/resetview/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 REQUIRED COMPONENTS OpenGLWidgets)
endif()

avogadro_plugin(ResetView
"Manipulate the view camera."
ExtensionPlugin
Expand All @@ -7,4 +11,15 @@ avogadro_plugin(ResetView
""
)

target_link_libraries(ResetView PRIVATE Avogadro::QtOpenGL)
target_link_libraries(ResetView PRIVATE Avogadro::Rendering Avogadro::QtOpenGL)

if(QT_VERSION EQUAL 6)
target_link_libraries(ResetView
PRIVATE
Qt6::OpenGLWidgets)
endif()

target_include_directories(ResetView
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
2 changes: 1 addition & 1 deletion avogadro/qtplugins/scriptcharges/scriptchargemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void ScriptChargeModel::processElementString(const QString& str)
QString str2(str);
str2.replace(',', ' ');
// then split on whitespace
QStringList strList = str2.split(QRegExp("\\s+"), QString::SkipEmptyParts);
QStringList strList = str2.split(QRegExp("\\s+"), Qt::SkipEmptyParts);
foreach (QString sstr, strList) {
// these should be numbers or ranges (e.g., 1-84)
if (sstr.contains('-')) {
Expand Down
7 changes: 6 additions & 1 deletion avogadro/qtplugins/selectiontool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ avogadro_plugin(Selection
"${tool_rcs}"
)

target_link_libraries(Selection PRIVATE Avogadro::QtOpenGL)
target_link_libraries(Selection PRIVATE Avogadro::Rendering Avogadro::QtOpenGL)

target_include_directories(Selection
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
16 changes: 16 additions & 0 deletions avogadro/qtplugins/surfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 REQUIRED COMPONENTS OpenGL)
endif()

set(surfaces_srcs
gaussiansetconcurrent.cpp
slatersetconcurrent.cpp
Expand All @@ -19,7 +23,19 @@ target_link_libraries(Surfaces
Avogadro::Calc
Avogadro::QuantumIO
Avogadro::QtOpenGL
Avogadro::Rendering
Qt::Concurrent
gif-h
gwavi
tinycolormap)

if(QT_VERSION EQUAL 6)
target_link_libraries(Surfaces
PRIVATE
Qt6::OpenGL)
endif()

target_include_directories(Surfaces
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
4 changes: 4 additions & 0 deletions avogadro/qtplugins/svg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ avogadro_plugin(SVG
)

target_link_libraries(SVG PRIVATE Avogadro::QtOpenGL Qt::Svg)

target_include_directories(SVG
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering)
Loading

0 comments on commit bb9f656

Please sign in to comment.