Add plot() script method
This commit is contained in:
+2
-2
@@ -17,7 +17,7 @@ if(SANITIZE_ADDRESS_LEAK)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fsanitize=leak")
|
||||
endif(SANITIZE_ADDRESS_LEAK)
|
||||
|
||||
find_package(Qt6 COMPONENTS Widgets Sql OpenGLWidgets Qml REQUIRED)
|
||||
find_package(Qt6 COMPONENTS Widgets Sql OpenGLWidgets Qml Charts REQUIRED)
|
||||
find_library(EXIF_LIB exif REQUIRED)
|
||||
find_library(FITS_LIB cfitsio REQUIRED)
|
||||
find_library(RAW_LIB NAMES raw_r REQUIRED)
|
||||
@@ -102,7 +102,7 @@ if(STELLARSOLVER_INCLUDE AND STELLARSOLVER_LIB)
|
||||
message(STATUS "Found stellarsolver ${STELLARSOLVER_INCLUDE} ${STELLARSOLVER_LIB}")
|
||||
endif(STELLARSOLVER_INCLUDE AND STELLARSOLVER_LIB)
|
||||
|
||||
target_link_libraries(tenmon PRIVATE Qt6::Widgets Qt6::Sql Qt6::OpenGLWidgets Qt6::Qml ${EXIF_LIB} ${FITS_LIB} ${RAW_LIB} ${WCS_LIB} ${LCMS2_LIB} XISF)
|
||||
target_link_libraries(tenmon PRIVATE Qt6::Widgets Qt6::Sql Qt6::OpenGLWidgets Qt6::Qml Qt6::Charts ${EXIF_LIB} ${FITS_LIB} ${RAW_LIB} ${WCS_LIB} ${LCMS2_LIB} XISF)
|
||||
if(APPLE)
|
||||
target_link_libraries(tenmon PRIVATE Qt6::DBus "-framework CoreFoundation")
|
||||
elseif(UNIX)
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QInputDialog>
|
||||
#include <QChart>
|
||||
#include <QChartView>
|
||||
#include <QLineSeries>
|
||||
#include "scriptengine.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
@@ -279,3 +282,30 @@ QJSValue BatchProcessing::getItem(const QStringList &items, const QString &label
|
||||
QString ret = QInputDialog::getItem(this, tr("Select item"), label, items, current, false, &ok);
|
||||
return ok ? ret : QJSValue();
|
||||
}
|
||||
|
||||
void BatchProcessing::plot(const QVector<QPointF> &points)
|
||||
{
|
||||
QDialog *diag = new QDialog(this);
|
||||
diag->setAttribute(Qt::WA_DeleteOnClose);
|
||||
diag->setModal(false);
|
||||
diag->setWindowTitle(tr("Chart"));
|
||||
|
||||
QChartView *chartView = new QChartView(diag);
|
||||
diag->setLayout(new QVBoxLayout);
|
||||
diag->layout()->addWidget(chartView);
|
||||
|
||||
QChart *chart = new QChart;
|
||||
chart->setParent(chartView);
|
||||
|
||||
auto series = new QLineSeries(chartView);
|
||||
series->append(points);
|
||||
chart->addSeries(series);
|
||||
chart->createDefaultAxes();
|
||||
chart->setTitle("Simple line graph");
|
||||
chart->legend()->hide();
|
||||
|
||||
chartView->setChart(chart);
|
||||
chartView->setRenderHint(QPainter::Antialiasing);
|
||||
diag->resize(640, 480);
|
||||
diag->show();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ public slots:
|
||||
QJSValue getInt(const QString &label, int value);
|
||||
QJSValue getFloat(const QString &label, double value, int decimals);
|
||||
QJSValue getItem(const QStringList &items, const QString &label, int current);
|
||||
|
||||
void plot(const QVector<QPointF> &points);
|
||||
};
|
||||
|
||||
#endif // BATCHPROCESSING_H
|
||||
|
||||
@@ -134,6 +134,21 @@ QJSValue ScriptEngine::getItem(const QStringList &items, const QString &label, i
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ScriptEngine::plot(const QJSValue &pointsArray)
|
||||
{
|
||||
if(pointsArray.isArray())
|
||||
{
|
||||
int len = pointsArray.property("length").toInt();
|
||||
QVector<QPointF> points;
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
QJSValue point = pointsArray.property(i);
|
||||
points.append(QPointF(point.property("x").toNumber(), point.property("y").toNumber()));
|
||||
}
|
||||
QMetaObject::invokeMethod(_parent, "plot", Qt::QueuedConnection, Q_ARG(QVector<QPointF>, points));
|
||||
}
|
||||
}
|
||||
|
||||
bool ScriptEngine::convert(File *file, QString &outpath, const QString &format, const QVariantMap ¶ms, bool async)
|
||||
{
|
||||
QString path;
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
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 getItem(const QStringList &items, const QString &label = "", int current = 0) const;
|
||||
Q_INVOKABLE void plot(const QJSValue &pointsArray);
|
||||
bool convert(File *file, QString &outpath, const QString &format, const QVariantMap ¶ms, bool async);
|
||||
#ifdef PLATESOLVER
|
||||
Q_INVOKABLE void setSolverProfile(int index);
|
||||
|
||||
Reference in New Issue
Block a user