24 NodeTypeUnknow = 1001,
36 RolePlot = Qt::UserRole + 1,
37 RoleScale = Qt::UserRole + 2,
38 RolePlotItem = Qt::UserRole + 3,
39 RoleAxisId = Qt::UserRole + 4,
40 RoleNodeType = Qt::UserRole + 5
43 explicit DAFigureTreeModel(QObject* parent =
nullptr);
46 void setFigure(QwtFigure* figure);
47 QwtFigure* figure()
const
55 NodeType itemType(QStandardItem* item)
const;
57 template<
typename T >
58 T* pointerFromItem(
const QStandardItem* item, CustomRoles role)
const
63 QVariant v = item->data(role);
64 return v.isValid() ?
reinterpret_cast< T*
>(v.value< quintptr >()) :
nullptr;
67 template<
typename T >
68 T* pointerFromIndex(
const QModelIndex& index, CustomRoles role)
const
72 QStandardItem* item = itemFromIndex(index);
73 return pointerFromItem< T >(item, role);
75 QwtPlot* plotFromItem(
const QStandardItem* item)
const;
76 QwtPlot* plotFromIndex(
const QModelIndex& index)
const;
77 QwtScaleWidget* scaleFromItem(
const QStandardItem* item)
const;
78 QwtScaleWidget* scaleFromIndex(
const QModelIndex& index)
const;
79 QwtPlotItem* plotItemFromItem(
const QStandardItem* item)
const;
80 QwtPlotItem* plotItemFromIndex(
const QModelIndex& index)
const;
81 QwtAxisId axisIdFromItem(
const QStandardItem* item)
const;
82 QwtAxisId axisIdFromItem(
const QModelIndex& index)
const;
85 virtual QString generatePlotTitleText(QwtPlot* plot)
const;
87 virtual QString generatePlotItemName(QwtPlotItem* item)
const;
89 virtual QIcon generatePlotItemIcon(QwtPlotItem* item)
const;
91 virtual QIcon generateBrushIcon(
const QBrush& b)
const;
93 void chartItemAttached(QwtPlotItem* item,
bool on);
95 void onAxesAdded(QwtPlot* plot);
96 void onAxesRemoved(QwtPlot* plot);
97 void onFigureCleared();
98 void onCurrentAxesChanged(QwtPlot* plot);
99 void onItemAttached(QwtPlotItem* item,
bool on);
103 void clearAllConnections();
104 void addPlotToModel(QwtPlot* plot, QStandardItem* parentItem);
105 void addLayerToModel(QwtPlot* plot, QStandardItem* parentItem);
106 void addAxesToLayer(QwtPlot* plot, QStandardItem* layerItem);
107 void addPlotItemsToLayer(QwtPlot* plot, QStandardItem* layerItem);
108 void addPlotItem(QwtPlotItem* item, QStandardItem* parentItem);
109 void removePlotItem(QwtPlotItem* item, QStandardItem* parentItem);
110 void removePlotFromModel(QwtPlot* plot);
112 QStandardItem* createEmptyItem()
const;
114 QStandardItem* createAxesPropertyItem(QwtPlot* plot)
const;
116 void updateAxesPropertyItem();
118 QStandardItem* findPlotItem(QwtPlot* plot)
const;
119 QStandardItem* findItemsFolderForPlot(QStandardItem* plotItem, QwtPlot* plot)
const;
123 QHash< QwtPlot*, QStandardItem* > m_plotItems;
124 QHash< QwtPlotItem*, QStandardItem* > m_plotItemItems;
127 QList< QMetaObject::Connection > m_figureConnections;
128 QHash< QwtPlot*, QList< QMetaObject::Connection > > m_plotConnections;