@@ -19,7 +19,7 class VisualizationGraphWidget : public QWidget, public IVisualizationWidget { | |||||
19 | Q_OBJECT |
|
19 | Q_OBJECT | |
20 |
|
20 | |||
21 | public: |
|
21 | public: | |
22 | explicit VisualizationGraphWidget(QWidget *parent = 0); |
|
22 | explicit VisualizationGraphWidget(const QString name = {}, QWidget *parent = 0); | |
23 | virtual ~VisualizationGraphWidget(); |
|
23 | virtual ~VisualizationGraphWidget(); | |
24 |
|
24 | |||
25 | void addVariable(std::shared_ptr<Variable> variable); |
|
25 | void addVariable(std::shared_ptr<Variable> variable); |
@@ -22,13 +22,17 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { | |||||
22 | std::unordered_map<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMap; |
|
22 | std::unordered_map<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMap; | |
23 | }; |
|
23 | }; | |
24 |
|
24 | |||
25 | VisualizationGraphWidget::VisualizationGraphWidget(QWidget *parent) |
|
25 | VisualizationGraphWidget::VisualizationGraphWidget(const QString name, QWidget *parent) | |
26 | : QWidget{parent}, |
|
26 | : QWidget{parent}, | |
27 | ui{new Ui::VisualizationGraphWidget}, |
|
27 | ui{new Ui::VisualizationGraphWidget}, | |
28 | impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()} |
|
28 | impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()} | |
29 | { |
|
29 | { | |
30 | ui->setupUi(this); |
|
30 | ui->setupUi(this); | |
31 |
|
31 | |||
|
32 | // qcpplot title | |||
|
33 | ui->widget->plotLayout()->insertRow(0); | |||
|
34 | ui->widget->plotLayout()->addElement(0, 0, new QCPTextElement{ui->widget, name}); | |||
|
35 | ||||
32 | // Set qcpplot properties : |
|
36 | // Set qcpplot properties : | |
33 | // - Drag (on x-axis) and zoom are enabled |
|
37 | // - Drag (on x-axis) and zoom are enabled | |
34 | // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation |
|
38 | // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation | |
@@ -65,7 +69,12 void VisualizationGraphWidget::close() | |||||
65 |
|
69 | |||
66 | QString VisualizationGraphWidget::name() const |
|
70 | QString VisualizationGraphWidget::name() const | |
67 | { |
|
71 | { | |
68 | return QStringLiteral("MainView"); |
|
72 | if (auto title = dynamic_cast<QCPTextElement *>(ui->widget->plotLayout()->elementAt(0))) { | |
|
73 | return title->text(); | |||
|
74 | } | |||
|
75 | else { | |||
|
76 | return QString{}; | |||
|
77 | } | |||
69 | } |
|
78 | } | |
70 |
|
79 | |||
71 | void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept |
|
80 | void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept |
General Comments 0
You need to be logged in to leave comments.
Login now