Fix compiling without stellarsolver

This commit is contained in:
2024-10-02 15:25:32 +02:00
parent 6c42315f87
commit 3c5fef988e
3 changed files with 43 additions and 24 deletions
+7 -2
View File
@@ -93,16 +93,21 @@ if(LIBRAW_STATIC)
target_link_libraries(tenmon PRIVATE jasper) target_link_libraries(tenmon PRIVATE jasper)
endif() endif()
find_path(STELLARSOLVER_INCLUDE stellarsolver.h PATH_SUFFIXES libstellarsolver) #find_path(STELLARSOLVER_INCLUDE stellarsolver.h PATH_SUFFIXES libstellarsolver)
if(STELLARSOLVER_INCLUDE AND STELLARSOLVER_LIB) if(STELLARSOLVER_INCLUDE AND STELLARSOLVER_LIB)
target_include_directories(tenmon PRIVATE ${STELLARSOLVER_INCLUDE}) target_include_directories(tenmon PRIVATE ${STELLARSOLVER_INCLUDE})
target_link_libraries(tenmon PRIVATE ${STELLARSOLVER_LIB}) if(MXE)
target_link_libraries(tenmon PRIVATE ${STELLARSOLVER_LIB} ${GSL_LIB} ${GSLCBLAS_LIB} boost_regex-mt-x64)
else(MXE)
target_link_libraries(tenmon PRIVATE ${STELLARSOLVER_LIB})
endif(MXE)
target_compile_definitions(tenmon PRIVATE "PLATESOLVER") target_compile_definitions(tenmon PRIVATE "PLATESOLVER")
target_sources(tenmon PRIVATE target_sources(tenmon PRIVATE
solver.cpp solver.h solver.cpp solver.h
platesolving.cpp platesolving.h platesolving.ui platesolving.cpp platesolving.h platesolving.ui
platesolvingsettings.cpp platesolvingsettings.h platesolvingsettings.ui platesolvingsettings.cpp platesolvingsettings.h platesolvingsettings.ui
) )
message(STATUS "Found stellarsolver ${STELLARSOLVER_INCLUDE} ${STELLARSOLVER_LIB}")
endif(STELLARSOLVER_INCLUDE AND STELLARSOLVER_LIB) endif(STELLARSOLVER_INCLUDE AND STELLARSOLVER_LIB)
option(FLATPAK "Flatpak build" OFF) option(FLATPAK "Flatpak build" OFF)
+30 -20
View File
@@ -9,7 +9,9 @@
#include "batchprocessing.h" #include "batchprocessing.h"
#include <fitsio2.h> #include <fitsio2.h>
#include "libXISF/libxisf.h" #include "libXISF/libxisf.h"
#ifdef PLATESOLVER
#include "solver.h" #include "solver.h"
#endif // PLATESOLVER
namespace Script namespace Script
{ {
@@ -27,7 +29,9 @@ ScriptEngine::ScriptEngine(BatchProcessing *parent)
_database->init(QLatin1String("scriptengine")); _database->init(QLatin1String("scriptengine"));
_semaphore.release(_pool->maxThreadCount()); _semaphore.release(_pool->maxThreadCount());
#ifdef PLATESOLVER
_solver = new Solver(this); _solver = new Solver(this);
#endif // PLATESOLVER
} }
void ScriptEngine::setParams(const QString &scriptPath, const QList<QPair<QString, QString>> &paths, const QString &outputDir) void ScriptEngine::setParams(const QString &scriptPath, const QList<QPair<QString, QString>> &paths, const QString &outputDir)
@@ -49,7 +53,9 @@ const QString &ScriptEngine::outputDir() const
void ScriptEngine::interrupt() void ScriptEngine::interrupt()
{ {
_solver->abort(); #ifdef PLATESOLVER
if(_solver)_solver->abort();
#endif
_jsEngine->setInterrupted(true); _jsEngine->setInterrupted(true);
} }
@@ -122,25 +128,6 @@ QJSValue ScriptEngine::getItem(const QStringList &items, const QString &label, i
return ret; return ret;
} }
void ScriptEngine::setStartingSolution(const QJSValue &solution)
{
if(solution.isObject())
{
if(solution.hasProperty("ra") && solution.hasProperty("dec") && solution.property("ra").isNumber() && solution.property("dec").isNumber())
_solver->setSearchPosition(solution.property("ra").toNumber(), solution.property("dec").toNumber());
if(solution.hasProperty("pixscale") && solution.property("pixscale").isNumber())
{
double scale = solution.property("pixscale").toNumber();
_solver->setSearchScale(scale * 0.8, scale * 1.2, SSolver::ScaleUnits::ARCSEC_PER_PIX);
}
}
else
{
_solver->clearStartingPositionAndScale();
}
}
bool ScriptEngine::convert(File *file, QString &outpath, const QString &format, const QVariantMap &params, bool async) bool ScriptEngine::convert(File *file, QString &outpath, const QString &format, const QVariantMap &params, bool async)
{ {
QString path; QString path;
@@ -174,6 +161,26 @@ bool ScriptEngine::convert(File *file, QString &outpath, const QString &format,
return true; return true;
} }
#ifdef PLATESOLVER
void ScriptEngine::setStartingSolution(const QJSValue &solution)
{
if(solution.isObject())
{
if(solution.hasProperty("ra") && solution.hasProperty("dec") && solution.property("ra").isNumber() && solution.property("dec").isNumber())
_solver->setSearchPosition(solution.property("ra").toNumber(), solution.property("dec").toNumber());
if(solution.hasProperty("pixscale") && solution.property("pixscale").isNumber())
{
double scale = solution.property("pixscale").toNumber();
_solver->setSearchScale(scale * 0.8, scale * 1.2, SSolver::ScaleUnits::ARCSEC_PER_PIX);
}
}
else
{
_solver->clearStartingPositionAndScale();
}
}
QJSValue ScriptEngine::solveImage(File *file, bool updateHeader) QJSValue ScriptEngine::solveImage(File *file, bool updateHeader)
{ {
QString path = file->absoluteFilePath(); QString path = file->absoluteFilePath();
@@ -253,6 +260,7 @@ QJSValue ScriptEngine::extractStars(File *file, bool hfr)
return ret; return ret;
} }
#endif // PLATESOLVER
QJSValue ScriptEngine::newObject() QJSValue ScriptEngine::newObject()
{ {
@@ -682,6 +690,7 @@ QJSValue File::stats()
return _stats; return _stats;
} }
#ifdef PLATESOLVER
QJSValue File::solve(bool updateHeader) QJSValue File::solve(bool updateHeader)
{ {
if(_solution.isUndefined() || updateHeader) if(_solution.isUndefined() || updateHeader)
@@ -697,6 +706,7 @@ QJSValue File::extractStars(bool hfr)
return _stars; return _stars;
} }
#endif // PLATESOLVER
ScriptEngineThread::ScriptEngineThread(BatchProcessing *parent) : QObject(parent) ScriptEngineThread::ScriptEngineThread(BatchProcessing *parent) : QObject(parent)
{ {
+6 -2
View File
@@ -29,7 +29,7 @@ class ScriptEngine : public QObject
QString _scriptPath; QString _scriptPath;
QString _outputDir; QString _outputDir;
QList<QPair<QString, QString>> _paths; QList<QPair<QString, QString>> _paths;
Solver *_solver; Solver *_solver = nullptr;
public: public:
explicit ScriptEngine(BatchProcessing *parent = nullptr); explicit ScriptEngine(BatchProcessing *parent = nullptr);
void setParams(const QString &scriptPath, const QList<QPair<QString, QString>> &paths, const QString &outputDir); void setParams(const QString &scriptPath, const QList<QPair<QString, QString>> &paths, const QString &outputDir);
@@ -47,10 +47,12 @@ public:
Q_INVOKABLE QJSValue getInt(const QString &label = QString(), int value = 0); Q_INVOKABLE QJSValue getInt(const QString &label = QString(), int value = 0);
Q_INVOKABLE QJSValue getFloat(const QString &label = QString(), double value = 0, int decimals = 3) const; Q_INVOKABLE QJSValue getFloat(const QString &label = QString(), double value = 0, int decimals = 3) const;
Q_INVOKABLE QJSValue getItem(const QStringList &items, const QString &label = "", int current = 0) const; Q_INVOKABLE QJSValue getItem(const QStringList &items, const QString &label = "", int current = 0) const;
Q_INVOKABLE void setStartingSolution(const QJSValue &solution = QJSValue());
bool convert(File *file, QString &outpath, const QString &format, const QVariantMap &params, bool async); bool convert(File *file, QString &outpath, const QString &format, const QVariantMap &params, bool async);
#ifdef PLATESOLVER
Q_INVOKABLE void setStartingSolution(const QJSValue &solution = QJSValue());
QJSValue solveImage(File *file, bool updateHeader); QJSValue solveImage(File *file, bool updateHeader);
QJSValue extractStars(File *file, bool hfr); QJSValue extractStars(File *file, bool hfr);
#endif // PLATESOLVER
QJSValue newObject(); QJSValue newObject();
QJSValue newArray(uint size); QJSValue newArray(uint size);
public slots: public slots:
@@ -116,8 +118,10 @@ public:
Q_INVOKABLE File* convert(const QString &outpath, const QString &format, const QVariantMap &params = QVariantMap()); Q_INVOKABLE File* convert(const QString &outpath, const QString &format, const QVariantMap &params = QVariantMap());
Q_INVOKABLE File* convertAsync(const QString &outpath, const QString &format, const QVariantMap &params = QVariantMap()); Q_INVOKABLE File* convertAsync(const QString &outpath, const QString &format, const QVariantMap &params = QVariantMap());
Q_INVOKABLE QJSValue stats(); Q_INVOKABLE QJSValue stats();
#ifdef PLATESOLVER
Q_INVOKABLE QJSValue solve(bool updateHeader = false); Q_INVOKABLE QJSValue solve(bool updateHeader = false);
Q_INVOKABLE QJSValue extractStars(bool hfr); Q_INVOKABLE QJSValue extractStars(bool hfr);
#endif // PLATESOLVER
}; };
class FITSRecordModify : public QObject class FITSRecordModify : public QObject