🛰️航天仿真算法库 SpaceAST 0.3.1
载入中...
搜索中...
未找到
UiFigure.hpp
浏览该文件的文档.
1
21
22#pragma once
23
24#ifdef AST_WITH_QWT
25
26#include "AstGlobal.h"
27#include "EditFigureDialog.hpp"
28#include <QWidget>
29#include <QMap>
30#include <QList>
31#include <QPointer>
32#include <QScopedPointer>
33
34class QwtFigure;
35class QwtPlot;
36class QwtPlotPanner;
37class QwtPlotCanvasZoomer;
38class QwtPlotSeriesDataPicker;
39class QwtPlotSeriesDataPickerGroup;
40class QToolBar;
41class QToolButton;
42class QActionGroup;
43class QMenu;
44class QwtFigureWidgetOverlay;
45
46namespace matplot
47{
48 class figure_type;
49}
50
51AST_NAMESPACE_BEGIN
52
53class AST_CHART_API UiFigure : public QWidget {
54 Q_OBJECT
55public:
57 explicit UiFigure(matplot::figure_type* pltfigure, QWidget* parent = nullptr);
58
59 ~UiFigure() override;
60 UiFigure(const UiFigure&) = delete;
61 UiFigure& operator=(const UiFigure&) = delete;
62
64 QwtFigure* qwtfigure() const { return qwtfigure_; }
65
67 matplot::figure_type* pltfigure() const { return pltfigure_; }
68
70 QToolBar* toolBar() const { return toolBar_; }
71
73 void setFigureSize(int w, int h);
74
76 QSize sizeHint() const override;
77
79 void refreshOriginalLimits();
80
82 void syncToolbarState();
83
85 void replotAll();
86
88 void restoreNavigationState();
89
91 void restoreEditModeIfNeeded();
92
93public slots:
95 void saveFigure();
96
98 void resetView();
99
101 void setPanMode(bool on);
102
104 void setZoomInMode(bool on);
105
107 void zoomOut();
108
110 void toggleLegend(bool on);
111
113 void toggleGrid(bool on);
114
116 void toggleColorbar(bool on);
117
119 void setEditMode(bool on);
120
122 void openPropertyInspector();
123
124private slots:
126 void onOverlayGeometryChanged(QWidget* w, QRectF oldNorm, QRectF newNorm);
128 void onPickActionToggled(bool on);
129
130private:
131 void setupUi();
132 void createActions();
133 void clearPanners();
134 void clearZoomers();
135 void clearDataPickers();
136 void createDataPickers();
137 void createOverlay();
138 void clearOverlay();
139 QIcon loadIcon(const QString& name) const;
140 QList<QwtPlot*> allAxes() const;
141
142 struct AxisLimits {
143 double xMin = 0, xMax = 0, yMin = 0, yMax = 0;
144 };
145
146 QwtFigure* qwtfigure_ = nullptr;
147 matplot::figure_type* pltfigure_ = nullptr;
148 QToolBar* toolBar_ = nullptr;
149 QAction* panAction_ = nullptr;
150 QAction* zoomInAction_ = nullptr;
151 QAction* legendAction_ = nullptr;
152 QAction* gridAction_ = nullptr;
153 QAction* colorbarAction_ = nullptr;
154 QAction* pickYAction_ = nullptr;
155 QAction* pickNearestAction_ = nullptr;
156 QMenu* dataPickMenu_ = nullptr;
157 QToolButton* dataPickBtn_ = nullptr;
158 QMap<QwtPlot*, AxisLimits> originalLimits_{};
159 QList<QPointer<QwtPlotPanner>> panners_{};
160 QList<QPointer<QwtPlotCanvasZoomer>> zoomers_{};
161 QList<QPointer<QwtPlotSeriesDataPicker>> dataPickers_{};
162 QScopedPointer<QwtPlotSeriesDataPickerGroup> dataPickerGroup_{};
163
164 // 编辑模式
165 QAction* editModeAction_ = nullptr;
166 QScopedPointer<QwtFigureWidgetOverlay> overlay_{};
167
168 // 属性检查器
169 QAction* propertiesAction_ = nullptr;
170 QPointer<EditFigureDialog> propertiesDialog_{};
171};
172
173AST_NAMESPACE_END
174
175#endif
Figure 元素属性编辑对话框