2022-08-26 18:31:27 +08:00
|
|
|
#pragma once
|
|
|
|
#include <QApplication>
|
|
|
|
#include "jkqtplotter/jkqtplotter.h"
|
2022-08-27 03:23:19 +08:00
|
|
|
#include "jkqtpappsettingcontroller.h"
|
2022-08-26 18:31:27 +08:00
|
|
|
#include <QDir>
|
2022-09-26 08:07:07 +08:00
|
|
|
#include <functional>
|
2022-08-26 18:31:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class JKQTPExampleApplication: public QApplication {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2022-08-29 04:48:14 +08:00
|
|
|
JKQTPExampleApplication(int &argc, char **argv, bool waitForScreenshotReady=false);
|
2022-08-26 18:31:27 +08:00
|
|
|
|
|
|
|
virtual ~JKQTPExampleApplication();
|
2022-09-26 08:07:07 +08:00
|
|
|
void addExportStepFunctor(const std::function<void(void)>& f);
|
2023-08-14 19:50:21 +08:00
|
|
|
void addExportStepPlot(JKQTPlotter* plot);
|
|
|
|
void addExportStepPlotFunctor(const std::function<JKQTPlotter*(void)>& fplot);
|
2022-08-26 18:31:27 +08:00
|
|
|
int exec();
|
2023-07-22 20:26:02 +08:00
|
|
|
public Q_SLOTS:
|
2022-08-29 04:48:14 +08:00
|
|
|
void notifyReadyForScreenshot();
|
2022-08-26 18:31:27 +08:00
|
|
|
protected:
|
2022-08-29 04:48:14 +08:00
|
|
|
bool waitForScreenshotReady;
|
|
|
|
bool readyForScreenshot;
|
2022-08-26 18:31:27 +08:00
|
|
|
QDir screenshotDir;
|
|
|
|
bool saveScreenshot;
|
|
|
|
bool saveSmallScreenshot;
|
|
|
|
bool saveScreenshotPlot;
|
|
|
|
bool saveSmallScreenshotPlot;
|
2022-08-27 03:23:19 +08:00
|
|
|
bool scaleDownFromHighDPI;
|
2022-09-26 08:07:07 +08:00
|
|
|
bool iterateFunctorSteps;
|
|
|
|
bool iterateFunctorStepsSupressInitial;
|
2022-08-27 03:23:19 +08:00
|
|
|
QStringList screenshotBasename;
|
2023-08-14 19:50:21 +08:00
|
|
|
struct Data {
|
|
|
|
enum Type {
|
|
|
|
FunctorType,
|
|
|
|
PlotterType,
|
|
|
|
PlotterFunctorType
|
|
|
|
};
|
|
|
|
Type type;
|
|
|
|
std::function<void(void)> f;
|
|
|
|
std::function<JKQTPlotter*(void)> plotf;
|
|
|
|
JKQTPlotter* p;
|
|
|
|
inline Data(const std::function<void(void)>& f_):
|
|
|
|
type(FunctorType), f(f_), p(nullptr), plotf()
|
|
|
|
{}
|
|
|
|
inline Data(JKQTPlotter* p_):
|
2023-08-14 20:26:13 +08:00
|
|
|
type(PlotterType), p(p_), f(), plotf()
|
2023-08-14 19:50:21 +08:00
|
|
|
{}
|
|
|
|
inline Data(std::function<JKQTPlotter*(void)> p_):
|
2023-08-14 20:26:13 +08:00
|
|
|
type(PlotterFunctorType), plotf(p_), f(), p(nullptr)
|
2023-08-14 19:50:21 +08:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
QVector<Data> functors;
|
2022-08-26 18:31:27 +08:00
|
|
|
void readCmdLine();
|
|
|
|
QRect getBoundsWithoutColor(QImage qImage, const QColor &exclusionColor = Qt::white);
|
2023-08-14 19:50:21 +08:00
|
|
|
|
|
|
|
void saveWidget(QWidget* w, int iVisible);;
|
2022-08-26 18:31:27 +08:00
|
|
|
};
|