##// END OF EJS Templates
Adds name to a graph...
Alexandre Leroux -
r196:8ddc77b998a0
parent child
Show More
@@ -19,7 +19,7 class VisualizationGraphWidget : public QWidget, public IVisualizationWidget {
19 19 Q_OBJECT
20 20
21 21 public:
22 explicit VisualizationGraphWidget(QWidget *parent = 0);
22 explicit VisualizationGraphWidget(const QString name = {}, QWidget *parent = 0);
23 23 virtual ~VisualizationGraphWidget();
24 24
25 25 void addVariable(std::shared_ptr<Variable> variable);
@@ -22,13 +22,17 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
22 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 26 : QWidget{parent},
27 27 ui{new Ui::VisualizationGraphWidget},
28 28 impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()}
29 29 {
30 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 36 // Set qcpplot properties :
33 37 // - Drag (on x-axis) and zoom are enabled
34 38 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
@@ -65,7 +69,12 void VisualizationGraphWidget::close()
65 69
66 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 80 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
General Comments 0
You need to be logged in to leave comments. Login now