@@ -51,6 +51,9 public: | |||
|
51 | 51 | SqpRange graphRange() const noexcept; |
|
52 | 52 | void setGraphRange(const SqpRange &range); |
|
53 | 53 | |
|
54 | /// Undo the last zoom done with a zoom box | |
|
55 | void undoZoom(); | |
|
56 | ||
|
54 | 57 | // IVisualizationWidget interface |
|
55 | 58 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
56 | 59 | bool canDrop(const Variable &variable) const override; |
@@ -73,6 +73,7 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { | |||
|
73 | 73 | std::unique_ptr<VisualizationGraphRenderingDelegate> m_RenderingDelegate; |
|
74 | 74 | |
|
75 | 75 | QCPItemRect *m_DrawingZoomRect = nullptr; |
|
76 | QStack<QPair<QCPRange, QCPRange> > m_ZoomStack; | |
|
76 | 77 | |
|
77 | 78 | std::unique_ptr<VisualizationCursorItem> m_HorizontalCursor = nullptr; |
|
78 | 79 | std::unique_ptr<VisualizationCursorItem> m_VerticalCursor = nullptr; |
@@ -315,6 +316,18 void VisualizationGraphWidget::setGraphRange(const SqpRange &range) | |||
|
315 | 316 | qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange END"); |
|
316 | 317 | } |
|
317 | 318 | |
|
319 | void VisualizationGraphWidget::undoZoom() | |
|
320 | { | |
|
321 | auto zoom = impl->m_ZoomStack.pop(); | |
|
322 | auto axisX = plot().axisRect()->axis(QCPAxis::atBottom); | |
|
323 | auto axisY = plot().axisRect()->axis(QCPAxis::atLeft); | |
|
324 | ||
|
325 | axisX->setRange(zoom.first); | |
|
326 | axisY->setRange(zoom.second); | |
|
327 | ||
|
328 | plot().replot(QCustomPlot::rpQueuedReplot); | |
|
329 | } | |
|
330 | ||
|
318 | 331 | void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
319 | 332 | { |
|
320 | 333 | if (visitor) { |
@@ -487,6 +500,14 void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept | |||
|
487 | 500 | [ this, var = it->first ]() { removeVariable(var); }); |
|
488 | 501 | } |
|
489 | 502 | |
|
503 | if (!impl->m_ZoomStack.isEmpty()) { | |
|
504 | if (!graphMenu.isEmpty()) { | |
|
505 | graphMenu.addSeparator(); | |
|
506 | } | |
|
507 | ||
|
508 | graphMenu.addAction(tr("Undo Zoom"), [this]() { undoZoom(); }); | |
|
509 | } | |
|
510 | ||
|
490 | 511 | if (!graphMenu.isEmpty()) { |
|
491 | 512 | graphMenu.exec(QCursor::pos()); |
|
492 | 513 | } |
@@ -686,6 +707,7 void VisualizationGraphWidget::onMouseRelease(QMouseEvent *event) noexcept | |||
|
686 | 707 | |
|
687 | 708 | if (newAxisXRange.size() > axisX->range().size() * (ZOOM_BOX_MIN_SIZE / 100.0) |
|
688 | 709 | && newAxisYRange.size() > axisY->range().size() * (ZOOM_BOX_MIN_SIZE / 100.0)) { |
|
710 | impl->m_ZoomStack.push(qMakePair(axisX->range(), axisY->range())); | |
|
689 | 711 | axisX->setRange(newAxisXRange); |
|
690 | 712 | axisY->setRange(newAxisYRange); |
|
691 | 713 |
General Comments 0
You need to be logged in to leave comments.
Login now