##// END OF EJS Templates
Action "Remove Selected Zones"
trabillard -
r1114:716d2411dc36
parent child
Show More
@@ -19,6 +19,7 class SqpRange;
19 class Variable;
19 class Variable;
20 class VisualizationWidget;
20 class VisualizationWidget;
21 class VisualizationZoneWidget;
21 class VisualizationZoneWidget;
22 class VisualizationSelectionZoneItem;
22
23
23 namespace Ui {
24 namespace Ui {
24 class VisualizationGraphWidget;
25 class VisualizationGraphWidget;
@@ -56,11 +57,13 public:
56 SqpRange graphRange() const noexcept;
57 SqpRange graphRange() const noexcept;
57 void setGraphRange(const SqpRange &range);
58 void setGraphRange(const SqpRange &range);
58
59
60 // Zones
59 /// Returns the ranges of all the selection zones on the graph
61 /// Returns the ranges of all the selection zones on the graph
60 QVector<SqpRange> selectionZoneRanges() const;
62 QVector<SqpRange> selectionZoneRanges() const;
61
62 /// Adds new selection zones in the graph
63 /// Adds new selection zones in the graph
63 void addSelectionZones(const QVector<SqpRange> &ranges);
64 void addSelectionZones(const QVector<SqpRange> &ranges);
65 /// Removes the specified selection zone
66 void removeSelectionZone(VisualizationSelectionZoneItem *selectionZone);
64
67
65 /// Undo the last zoom done with a zoom box
68 /// Undo the last zoom done with a zoom box
66 void undoZoom();
69 void undoZoom();
@@ -5,12 +5,16
5 #include <Data/SqpRange.h>
5 #include <Data/SqpRange.h>
6 #include <Visualization/qcustomplot.h>
6 #include <Visualization/qcustomplot.h>
7
7
8 class VisualizationGraphWidget;
9
8 class VisualizationSelectionZoneItem : public QCPItemRect {
10 class VisualizationSelectionZoneItem : public QCPItemRect {
9
11
10 public:
12 public:
11 VisualizationSelectionZoneItem(QCustomPlot *plot);
13 VisualizationSelectionZoneItem(QCustomPlot *plot);
12 virtual ~VisualizationSelectionZoneItem();
14 virtual ~VisualizationSelectionZoneItem();
13
15
16 VisualizationGraphWidget *parentGraphWidget() const noexcept;
17
14 void setName(const QString &name);
18 void setName(const QString &name);
15 QString name() const;
19 QString name() const;
16
20
@@ -1,4 +1,6
1 #include "Visualization/VisualizationActionManager.h"
1 #include "Visualization/VisualizationActionManager.h"
2 #include "Visualization/VisualizationGraphWidget.h"
3 #include "Visualization/VisualizationSelectionZoneItem.h"
2
4
3 #include <Actions/ActionsGuiController.h>
5 #include <Actions/ActionsGuiController.h>
4 #include <SqpApplication.h>
6 #include <SqpApplication.h>
@@ -8,7 +10,13 VisualizationActionManager::VisualizationActionManager() {}
8 void VisualizationActionManager::installSelectionZoneActions()
10 void VisualizationActionManager::installSelectionZoneActions()
9 {
11 {
10 auto &actionController = sqpApp->actionsGuiController();
12 auto &actionController = sqpApp->actionsGuiController();
11 actionController.addSectionZoneAction("Remove Selected Zone(s)", [](auto &zone) {});
13 actionController.addSectionZoneAction("Remove Selected Zone(s)", [](auto &zones) {
12 actionController.addSectionZoneAction("Align Left", [](auto &zone) {});
14 for (auto selectionZone : zones) {
13 actionController.addSectionZoneAction("Align Right", [](auto &zone) {});
15 if (auto graph = selectionZone->parentGraphWidget()) {
16 graph->removeSelectionZone(selectionZone);
17 }
18 }
19 });
20 actionController.addSectionZoneAction("Align Left", [](auto &zones) {});
21 actionController.addSectionZoneAction("Align Right", [](auto &zones) {});
14 }
22 }
@@ -378,6 +378,14 void VisualizationGraphWidget::addSelectionZones(const QVector<SqpRange> &ranges
378 plot().replot(QCustomPlot::rpQueuedReplot);
378 plot().replot(QCustomPlot::rpQueuedReplot);
379 }
379 }
380
380
381 void VisualizationGraphWidget::removeSelectionZone(VisualizationSelectionZoneItem *selectionZone)
382 {
383 impl->m_SelectionZones.removeAll(selectionZone);
384 plot().removeItem(selectionZone);
385 plot().replot(QCustomPlot::rpQueuedReplot);
386 parentVisualizationWidget()->selectionZoneManager().setSelected(selectionZone, false);
387 }
388
381 void VisualizationGraphWidget::undoZoom()
389 void VisualizationGraphWidget::undoZoom()
382 {
390 {
383 auto zoom = impl->m_ZoomStack.pop();
391 auto zoom = impl->m_ZoomStack.pop();
@@ -1,4 +1,5
1 #include "Visualization/VisualizationSelectionZoneItem.h"
1 #include "Visualization/VisualizationSelectionZoneItem.h"
2 #include "Visualization/VisualizationGraphWidget.h"
2
3
3 const QString &DEFAULT_COLOR = QStringLiteral("#E79D41");
4 const QString &DEFAULT_COLOR = QStringLiteral("#E79D41");
4
5
@@ -98,6 +99,16 VisualizationSelectionZoneItem::~VisualizationSelectionZoneItem()
98 impl->m_Plot->removeItem(impl->m_LeftLine);
99 impl->m_Plot->removeItem(impl->m_LeftLine);
99 }
100 }
100
101
102 VisualizationGraphWidget *VisualizationSelectionZoneItem::parentGraphWidget() const noexcept
103 {
104 auto parent = impl->m_Plot->parentWidget();
105 while (parent != nullptr && !qobject_cast<VisualizationGraphWidget *>(parent)) {
106 parent = parent->parentWidget();
107 }
108
109 return qobject_cast<VisualizationGraphWidget *>(parent);
110 }
111
101 void VisualizationSelectionZoneItem::setName(const QString &name)
112 void VisualizationSelectionZoneItem::setName(const QString &name)
102 {
113 {
103 if (name.isEmpty() && impl->m_NameLabelItem) {
114 if (name.isEmpty() && impl->m_NameLabelItem) {
General Comments 4
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

Approved

Status change > Approved

You need to be logged in to leave comments. Login now