##// END OF EJS Templates
Pass Variable as shared_ptr
Alexandre Leroux -
r187:60a84e67b911
parent child
Show More
@@ -4,6 +4,8
4 #include <QLoggingCategory>
4 #include <QLoggingCategory>
5 #include <QVector>
5 #include <QVector>
6
6
7 #include <memory>
8
7 Q_DECLARE_LOGGING_CATEGORY(LOG_GraphPlottablesFactory)
9 Q_DECLARE_LOGGING_CATEGORY(LOG_GraphPlottablesFactory)
8
10
9 class QCPAbstractPlottable;
11 class QCPAbstractPlottable;
@@ -23,7 +25,7 struct GraphPlottablesFactory {
23 * components.
25 * components.
24 * @return the list of the components created
26 * @return the list of the components created
25 */
27 */
26 static QVector<QCPAbstractPlottable *> create(const Variable *variable,
28 static QVector<QCPAbstractPlottable *> create(std::shared_ptr<Variable> variable,
27 QCustomPlot &plot) noexcept;
29 QCustomPlot &plot) noexcept;
28 };
30 };
29
31
@@ -66,7 +66,7 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC
66
66
67 } // namespace
67 } // namespace
68
68
69 QVector<QCPAbstractPlottable *> GraphPlottablesFactory::create(const Variable *variable,
69 QVector<QCPAbstractPlottable *> GraphPlottablesFactory::create(std::shared_ptr<Variable> variable,
70 QCustomPlot &plot) noexcept
70 QCustomPlot &plot) noexcept
71 {
71 {
72 auto result = QVector<QCPAbstractPlottable *>{};
72 auto result = QVector<QCPAbstractPlottable *>{};
@@ -45,7 +45,7 VisualizationGraphWidget::~VisualizationGraphWidget()
45 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
45 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
46 {
46 {
47 // Uses delegate to create the qcpplot components according to the variable
47 // Uses delegate to create the qcpplot components according to the variable
48 auto createdPlottables = GraphPlottablesFactory::create(variable.get(), *ui->widget);
48 auto createdPlottables = GraphPlottablesFactory::create(variable, *ui->widget);
49
49
50 for (auto createdPlottable : qAsConst(createdPlottables)) {
50 for (auto createdPlottable : qAsConst(createdPlottables)) {
51 impl->m_VariableToPlotMap.insert({variable, createdPlottable});
51 impl->m_VariableToPlotMap.insert({variable, createdPlottable});
General Comments 0
You need to be logged in to leave comments. Login now