DAWorkbench 0.0.1
DAWorkbench API
载入中...
搜索中...
未找到
DAAbstractChartItemSettingWidget.h
1#ifndef DAABSTRACTCHARTITEMSETTINGWIDGET_H
2#define DAABSTRACTCHARTITEMSETTINGWIDGET_H
3#include "DAGuiAPI.h"
4#include <QWidget>
5#include <QPointer>
6// qwt
7#include "qwt_plot.h"
8#include "qwt_plot_item.h"
9class QwtPlot;
10
16#ifndef DAAbstractChartItemSettingWidget_ReturnWhenItemNull
17#define DAAbstractChartItemSettingWidget_ReturnWhenItemNull \
18 do { \
19 if (nullptr == getPlotItem()) { \
20 return; \
21 } \
22 } while (0)
23
24#endif
25
26namespace DA
27{
31class DAGUI_API DAAbstractChartItemSettingWidget : public QWidget
32{
33 Q_OBJECT
34public:
35 DAAbstractChartItemSettingWidget(QWidget* parent = nullptr);
37 // 设置plotitem
38 void setPlotItem(QwtPlotItem* item);
39 QwtPlotItem* getPlotItem() const;
40 // 判断是否有item
41 bool isHaveItem() const;
42 // 判断当前item是否是对应的rtti,如果没有item也返回false
43 bool checkItemRTTI(QwtPlotItem::RttiValues rtti) const;
44
45 QwtPlot* getPlot() const;
50 template< typename T >
52 {
53 return dynamic_cast< T >(mPlotItem);
54 }
59 template< typename T >
61 {
62 return static_cast< T >(mPlotItem);
63 }
64 // setPlotItem之后调用的虚函数,通过重写此函数可以执行一些设置item之后的界面更新
65 virtual void updateUI(QwtPlotItem* item);
66 // 重绘
67 void replot();
68
69protected:
70 // plot设置,此函数在setPlotItem会调用,避免误操作,设置为protected
71 void setPlot(QwtPlot* plot);
72public Q_SLOTS:
73 virtual void plotItemAttached(QwtPlotItem* plotItem, bool on);
74
75protected:
76 QwtPlotItem* mPlotItem { nullptr };
77 QPointer< QwtPlot > mPlot { nullptr };
78};
79} // end DA
80
81#endif // DAABSTRACTCHARTITEMSETTINGWIDGET_H
chart设置的基类封装了基本操作
Definition DAAbstractChartItemSettingWidget.h:32
T s_cast()
快捷转换为别的item
Definition DAAbstractChartItemSettingWidget.h:60
T d_cast()
快捷转换为别的item
Definition DAAbstractChartItemSettingWidget.h:51
序列化类都是带异常的,使用中需要处理异常
Definition AppMainWindow.cpp:44