Skip to content

Commit

Permalink
Merge pull request rlancaste#146 from rlancaste/supportingQT6
Browse files Browse the repository at this point in the history
Supporting qt6
  • Loading branch information
rlancaste authored Jun 23, 2024
2 parents fbd63a1 + ca4afff commit 0a3c0d7
Show file tree
Hide file tree
Showing 44 changed files with 476 additions and 348 deletions.
78 changes: 43 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 3.0)
PROJECT(StellarSolver C CXX)
set(CMAKE_CXX_STANDARD 17)

if(APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" )
endif(APPLE)

#cmake_policy(SET CMP0003 NEW)

Expand Down Expand Up @@ -101,7 +103,16 @@ option(BUILD_CLI "Build stellarsolver command line interface, instead of just th
find_package(CFITSIO REQUIRED)
find_package(GSL REQUIRED)
find_package(WCSLIB REQUIRED)
find_package(Qt5 5.4 REQUIRED COMPONENTS Gui Widgets Core Concurrent Network)

# Option to choose between Qt5 and Qt6
option(USE_QT5 "Use Qt5" ON)

if(USE_QT5)
find_package(Qt5 5.15 REQUIRED COMPONENTS Gui Widgets Core Concurrent Network)
else()
message(WARNING "QT6 support is fairly new and not fully vetted yet. Currently there is an issue with partitioning in StellarSolver in QT6.")
find_package(Qt6 REQUIRED COMPONENTS Gui Widgets Core Concurrent Network)
endif()

if(WIN32)
find_package(Boost 1.45.0 COMPONENTS regex)
Expand Down Expand Up @@ -250,10 +261,10 @@ target_link_libraries(stellarsolver
${CFITSIO_LIBRARIES}
${GSL_LIBRARIES}
${WCSLIB_LIBRARIES}
Qt5::Core
Qt5::Network
Qt5::Widgets
Qt5::Concurrent
Qt::Core
Qt::Network
Qt::Widgets
Qt::Concurrent
)

if(WIN32)
Expand Down Expand Up @@ -319,11 +330,11 @@ if(BUILD_TESTER OR BUILD_BATCH_SOLVER OR BUILD_DEMOS OR BUILD_TESTS OR BUILD_CLI
${CFITSIO_LIBRARIES}
${GSL_LIBRARIES}
${WCSLIB_LIBRARIES}
Qt5::Gui
Qt5::Widgets
Qt5::Core
Qt5::Network
Qt5::Concurrent
Qt::Gui
Qt::Widgets
Qt::Core
Qt::Network
Qt::Concurrent
)
endif(BUILD_TESTER OR BUILD_BATCH_SOLVER OR BUILD_DEMOS OR BUILD_TESTS OR BUILD_CLI)

Expand All @@ -337,10 +348,7 @@ set(StellarSolverTester_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/tester/mainwindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tester/resources.qrc
)

qt5_wrap_ui(StellarSolverui_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/tester/mainwindow.ui
)
set(CMAKE_AUTOUIC ON)

if(APPLE)
set(MACOSX_BUNDLE_ICON_FILE StellarSolverIcon.icns)
Expand All @@ -365,11 +373,11 @@ target_link_libraries(StellarSolverTester
${CFITSIO_LIBRARIES}
${GSL_LIBRARIES}
${WCSLIB_LIBRARIES}
Qt5::Gui
Qt5::Widgets
Qt5::Core
Qt5::Network
Qt5::Concurrent
Qt::Gui
Qt::Widgets
Qt::Core
Qt::Network
Qt::Concurrent
)

if(WIN32)
Expand Down Expand Up @@ -405,7 +413,7 @@ if(BUILD_BATCH_SOLVER)
${CMAKE_CURRENT_SOURCE_DIR}/stellarbatchsolver/resources.qrc
)

qt5_wrap_ui(StellarBatchSolverui_SRCS
qt_wrap_ui(StellarBatchSolverui_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/stellarbatchsolver/stellarbatchsolver.ui
)

Expand All @@ -431,10 +439,10 @@ if(BUILD_BATCH_SOLVER)
${CFITSIO_LIBRARIES}
${GSL_LIBRARIES}
${WCSLIB_LIBRARIES}
Qt5::Widgets
Qt5::Core
Qt5::Network
Qt5::Concurrent
Qt::Widgets
Qt::Core
Qt::Network
Qt::Concurrent
)

if(WIN32)
Expand Down Expand Up @@ -471,10 +479,10 @@ if(BUILD_DEMOS)
${CFITSIO_LIBRARIES}
${GSL_LIBRARIES}
${WCSLIB_LIBRARIES}
Qt5::Widgets
Qt5::Core
Qt5::Network
Qt5::Concurrent
Qt::Widgets
Qt::Core
Qt::Network
Qt::Concurrent
)

add_executable(DemoStarExtract ${CMAKE_CURRENT_SOURCE_DIR}/demos/demostarextract.cpp)
Expand Down Expand Up @@ -518,8 +526,8 @@ if(BUILD_CLI)
${CFITSIO_LIBRARIES}
${GSL_LIBRARIES}
${WCSLIB_LIBRARIES}
Qt5::Core
Qt5::Concurrent
Qt::Core
Qt::Concurrent
)

add_executable(CommandLineInterface ${CMAKE_CURRENT_SOURCE_DIR}/cli/main.cpp)
Expand Down Expand Up @@ -554,10 +562,10 @@ if(BUILD_TESTS)
${CFITSIO_LIBRARIES}
${GSL_LIBRARIES}
${WCSLIB_LIBRARIES}
Qt5::Widgets
Qt5::Core
Qt5::Network
Qt5::Concurrent
Qt::Widgets
Qt::Core
Qt::Network
Qt::Concurrent
)

add_executable(TestTwoStellarSolvers ${CMAKE_CURRENT_SOURCE_DIR}/tests/testtwostellarsolvers.cpp)
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ Another thought I had in the back of my mind was that there were a copule of rea

git clone https://github.com/rlancaste/stellarsolver.git

- Run the installLinux.sh script
- Change into the directory of the Linux install scripts:

./installLinux.sh
cd stellarsolver/linux-scripts

- Run the appropriate script for your system and purpose. For example:

./installStellarSolverTesterQt6.sh

- It will build and install the program and create a shortcut on the desktop

Expand Down
2 changes: 1 addition & 1 deletion cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ std::optional<QString> extractAddPathDirectiveFromConfigLine(QString line)
// Check if the line contains 'add_path'
if (trimmedLine.startsWith("add_path", Qt::CaseInsensitive))
{
QStringList parts = trimmedLine.split(QRegExp("\\s+"), Qt::SkipEmptyParts);
QStringList parts = trimmedLine.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
if (parts.size() > 1)
{
// The string after 'add_path' is what we want to extract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../
if [ -f /usr/lib/fedora-release ]; then
sudo dnf -y install git cmake qt5 cfitsio-devel gsl-devel wcslib-devel
else
sudo apt -y install git cmake qt5-default libcfitsio-dev libgsl-dev wcslib-dev
sudo apt -y install g++ git cmake qt5-default libcfitsio-dev libgsl-dev wcslib-dev
fi

#This makes and installs the library
mkdir -p $DIR/build
cd $DIR/build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo $DIR
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_QT5=ON $DIR
make -j $(expr $(nproc) + 2)
sudo make install
sudo make install
18 changes: 18 additions & 0 deletions linux-scripts/installStellarSolverLibraryQt6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

#This gets the directory of the script, but note that the script is in a subdirectory, so to get the Repo's directory, we need ../
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../

#This installs the dependencies
if [ -f /usr/lib/fedora-release ]; then
sudo dnf -y install git cmake qt6 cfitsio-devel gsl-devel wcslib-devel
else
sudo apt -y install g++ git cmake qt6-base-dev libgl1-mesa-dev libcfitsio-dev libgsl-dev wcslib-dev
fi

#This makes and installs the library
mkdir -p $DIR/build
cd $DIR/build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_QT5=Off -DBUILD_TESTER=Off $DIR
make -j $(expr $(nproc) + 2)
sudo make install
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../
if [ -f /usr/lib/fedora-release ]; then
sudo dnf -y install git cmake qt5 cfitsio-devel gsl-devel wcslib-devel
else
sudo apt -y install git cmake qt5-default libcfitsio-dev libgsl-dev wcslib-dev
sudo apt -y install g++ git cmake qt5-default libcfitsio-dev libgsl-dev wcslib-dev
fi

#This makes and installs the library
mkdir -p $DIR/build
cd $DIR/build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTER=ON $DIR
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_QT5=ON -DBUILD_TESTER=ON $DIR
make -j $(expr $(nproc) + 2)
sudo make install

Expand Down
36 changes: 36 additions & 0 deletions linux-scripts/installStellarSolverTesterQt6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

#This gets the directory of the script, but note that the script is in a subdirectory, so to get the Repo's directory, we need ../
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../

#This installs the dependencies
if [ -f /usr/lib/fedora-release ]; then
sudo dnf -y install git cmake qt6 cfitsio-devel gsl-devel wcslib-devel
else
sudo apt -y install g++ git cmake qt6-base-dev libgl1-mesa-dev libcfitsio-dev libgsl-dev wcslib-dev
fi

#This makes and installs the library
mkdir -p $DIR/build
cd $DIR/build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_QT5=Off -DBUILD_TESTER=ON $DIR
make -j $(expr $(nproc) + 2)
sudo make install

#This copies the icon into the pictures directory for the section below
cp $DIR/tester/StellarSolverIcon.png $HOME/Pictures/

# This will create a shortcut on the desktop for launching StellarSolver
##################
cat >$HOME/Desktop/StellarSolverTester.desktop <<-EOF
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=$HOME/Pictures/StellarSolverIcon.png
Icon=$HOME/Pictures/StellarSolverIcon.png
Exec=/usr/bin/StellarSolverTester
Name[en_US]=StellarSolverTester
Name=StellarSolverTester
EOF
##################
10 changes: 5 additions & 5 deletions ssolverutils/dms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* (at your option) any later version. *
* *
***************************************************************************/

#include "dms.h"

//Qt Includes
#include <QLocale>
#include <QRegularExpression>

#include <QRegExp>
//Project Includes
#include "dms.h"

#ifdef COUNT_DMS_SINCOS_CALLS
long unsigned dms::dms_constructor_calls = 0;
Expand Down Expand Up @@ -59,7 +59,7 @@ bool dms::setFromString(const QString &str, bool isDeg)
double s(0.0);
bool checkValue(false), badEntry(false), negative(false);
QString entry = str.trimmed();
entry.remove(QRegExp("[hdms'\"°]"));
entry.remove(QRegularExpression("[hdms'\"°]"));

//Account for localized decimal-point settings
//QString::toDouble() requires that the decimal symbol is "."
Expand Down
7 changes: 5 additions & 2 deletions ssolverutils/dms.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@

#pragma once

#include "nan.h"

//Qt Includes
#include <QString>
#include <QDataStream>

//System Includes
#include <cmath>

//Project Includes
#include "nan.h"

//#define COUNT_DMS_SINCOS_CALLS true
//#define PROFILE_SINCOS true

Expand Down
15 changes: 8 additions & 7 deletions ssolverutils/fileio.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "fileio.h"
//Qt Includes
#include <QFileInfo>

//Project Includes
#include "fileio.h"

fileio::fileio()
{
Expand Down Expand Up @@ -662,7 +664,7 @@ bool fileio::parseHeader()
Record oneRecord;
// Quotes cause issues for simplified below so we're removing them.
QString record = recordList.mid(i * 80, 80).remove("'");
QStringList properties = record.split(QRegExp("[=/]"));
QStringList properties = record.split(QRegularExpression("[=/]"));
// If it is only a comment
if (properties.size() == 1)
{
Expand Down Expand Up @@ -809,24 +811,23 @@ bool fileio::saveAsFITS(QString fileName, FITSImage::Statistic &imageStats, uint
key == "BZERO" ||
key == "BSCALE")
continue;

switch (value.type())
switch (static_cast<QMetaType::Type>(value.userType()))
{
case QVariant::Int:
case QMetaType::Int:
{
int number = value.toInt();
fits_write_key(fptr, TINT, key.toLatin1().constData(), &number, comment.toLatin1().constData(), &status);
}
break;

case QVariant::Double:
case QMetaType::Double:
{
double number = value.toDouble();
fits_write_key(fptr, TDOUBLE, key.toLatin1().constData(), &number, comment.toLatin1().constData(), &status);
}
break;

case QVariant::String:
case QMetaType::QString:
default:
{
if(key == "COMMENT" && (value.toString().contains("FITS (Flexible Image Transport System) format") ||
Expand Down
3 changes: 2 additions & 1 deletion ssolverutils/fileio.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef FILEIO_H
#define FILEIO_H

//Qt Includes
#include <QObject>
#include <QImageReader>
#include <QFile>
#include <QVariant>

//CFitsio Includes
#include "longnam.h"
#include "fitsio.h"

//KStars related includes
Expand All @@ -16,6 +16,7 @@
#include "dms.h"
#include "bayer.h"

//Project Includes
#include "parameters.h"
#include "structuredefinitions.h"
#include "stellarsolver/sep/sep.h"
Expand Down
1 change: 1 addition & 0 deletions ssolverutils/imagelabel.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef IMAGELABEL_H
#define IMAGELABEL_H

//Qt Includes
#include <QLabel>
#include <QMouseEvent>
#include <QPoint>
Expand Down
Loading

0 comments on commit 0a3c0d7

Please sign in to comment.