SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
figurecapture.h
Go to the documentation of this file.
1
29#ifndef OPENSWMMVIS_UI_UTIL_FIGURECAPTURE_H
30#define OPENSWMMVIS_UI_UTIL_FIGURECAPTURE_H
31
32#include <QElapsedTimer>
33#include <QJsonObject>
34#include <QList>
35#include <QObject>
36#include <QSize>
37#include <QString>
38
39class QMainWindow;
40class QTimer;
41class QWidget;
42
43namespace openswmmvis::ui {
44
46enum class FigureLane {
47 Offscreen,
48 Live,
49 Human
50};
51
53struct FigureSpec {
54 QString name;
55 QString action;
56 QString widget;
57 bool wholeWindow = false;
58 QString page;
59 QString tab;
60 QString type;
61 QString typeInto;
62 QString select;
63 QString hostSelect;
64 QString hostSelectIn;
65 QStringList clicks;
66 QString column;
67 QString editCell;
68 QString grab;
69 QSize size;
70 QSize hostSize;
72 int settleMs = 0;
73 int maxWidth = 0;
74};
75
78 QString name;
79 QString status;
80 QString detail;
81 int width = 0;
82 int height = 0;
83 qint64 bytes = 0;
84 bool blank = false;
85 int elapsedMs = 0;
86};
87
95class FigureCapture : public QObject
96{
97 Q_OBJECT
98
99public:
105 static FigureCapture *createIfRequested(QMainWindow *host, QObject *parent);
106
107 ~FigureCapture() override;
108
113 void start();
114
115private:
116 FigureCapture(QMainWindow *host, QString manifestPath, QObject *parent);
117
118 bool loadManifest(QString *error);
119 void applyDefaults();
120 void processNext();
121 void finishSpec(const FigureResult &result);
122 void finishRun();
123
126 bool applyHostSelect(const FigureSpec &spec);
127 void captureSpec(const FigureSpec &spec);
128 void grabInto(QWidget *target, const FigureSpec &spec);
129
131 QWidget *activeDialog() const;
133 bool selectPage(QWidget *target, const QString &page) const;
135 bool selectItem(QWidget *target, const QString &which) const;
137 void dismissDialogs();
139 void dismissOpenedBy(const FigureSpec &spec);
140
141 QMainWindow *mHost = nullptr;
142 QString mManifestPath;
143 QString mOutDir;
144 QJsonObject mDefaults;
145 QList<FigureSpec> mQueue;
146 QList<FigureResult> mResults;
147
148 FigureSpec mCurrent;
149 bool mCurrentDone = false;
150 bool mStarted = false;
151 QElapsedTimer mSpecTimer;
152 QTimer *mWatchdog = nullptr;
153
154 int mDefaultSettleMs = 600;
155 int mStartupMs = 2500;
156 int mWatchdogMs = 20000;
157 int mMaxWidth = 1400;
158 qreal mRenderScale = 2.0;
159};
160
161} // namespace openswmmvis::ui
162
163#endif // OPENSWMMVIS_UI_UTIL_FIGURECAPTURE_H
Drives a manifest of figures to PNG, then quits the application.
Definition figurecapture.h:96
static FigureCapture * createIfRequested(QMainWindow *host, QObject *parent)
Build a capture run when SWMMVIS_CAPTURE_MANIFEST names a readable manifest, else nullptr.
Definition figurecapture.cpp:254
void start()
Begin the queue. Safe to call once; later calls are ignored.
Definition figurecapture.cpp:293
Definition openswmmvislayer.h:43
FigureLane
Which platform a figure can be captured on.
Definition figurecapture.h:46
@ Offscreen
widget-only; no display needed (the default)
@ Live
needs real scene-graph pixels — cocoa on a real display
@ Human
native menus / file pickers / Finder — engine skips it
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
Result of attempting one row; serialised into run.json.
Definition figurecapture.h:77
int height
Definition figurecapture.h:82
QString name
Definition figurecapture.h:78
int elapsedMs
Definition figurecapture.h:85
bool blank
grab carried (almost) no information
Definition figurecapture.h:84
qint64 bytes
Definition figurecapture.h:83
int width
Definition figurecapture.h:81
QString detail
failure reason, or the skip rationale
Definition figurecapture.h:80
QString status
"ok" | "skipped" | "failed"
Definition figurecapture.h:79
One row of the manifest: a figure and how to reach it.
Definition figurecapture.h:53
QString name
"18_routing_hydraulics.png"
Definition figurecapture.h:54
QString grab
narrow the grab to this descendant (objectName or class)
Definition figurecapture.h:68
FigureLane lane
Definition figurecapture.h:71
int settleMs
extra settle before the grab (0 = default)
Definition figurecapture.h:72
QSize hostSize
resize the MAIN WINDOW first (layout-dependent widgets)
Definition figurecapture.h:70
QString tab
sub-tab to select after page (sidebar + tab)
Definition figurecapture.h:59
QString column
scroll the target's table to this column header
Definition figurecapture.h:66
QString select
item to select in the target's list ("first", or its text)
Definition figurecapture.h:62
bool wholeWindow
grab the main window itself
Definition figurecapture.h:57
QSize size
resize the target before grabbing
Definition figurecapture.h:69
QString action
ActionCatalog id to trigger (opens a dialog)
Definition figurecapture.h:55
QStringList clicks
buttons to press in the target; the LAST one's dialog becomes the target
Definition figurecapture.h:65
QString widget
objectName to grab, resolved under the host
Definition figurecapture.h:56
QString editCell
open the row-0 cell editor in this column (compound "Edit…")
Definition figurecapture.h:67
QString hostSelect
item to select in the MAIN WINDOW before action fires
Definition figurecapture.h:63
int maxWidth
clamp THIS figure's width (0 = the manifest default)
Definition figurecapture.h:73
QString type
text to type into the target's first editable field
Definition figurecapture.h:60
QString typeInto
which field: objectName, or part of its placeholder
Definition figurecapture.h:61
QString page
tab / list-row text to select in the target
Definition figurecapture.h:58
QString hostSelectIn
scope hostSelect to this panel (objectName or class)
Definition figurecapture.h:64