##// END OF EJS Templates
multi selection of zones
trabillard -
r1089:ead367adcd3d
parent child
Show More
@@ -0,0 +1,26
1 #ifndef SCIQLOP_VISUALIZATIONSELECTIONZONEMANAGER_H
2 #define SCIQLOP_VISUALIZATIONSELECTIONZONEMANAGER_H
3
4 #include <Common/spimpl.h>
5
6 #include <QVector>
7
8 class VisualizationSelectionZoneItem;
9
10 class VisualizationSelectionZoneManager {
11 public:
12 VisualizationSelectionZoneManager();
13
14 void select(const QVector<VisualizationSelectionZoneItem *> &items);
15 void setSelected(VisualizationSelectionZoneItem *item, bool value);
16
17 void clearSelection();
18
19 QVector<VisualizationSelectionZoneItem *> selectedItems() const;
20
21 private:
22 class VisualizationSelectionZoneManagerPrivate;
23 spimpl::unique_impl_ptr<VisualizationSelectionZoneManagerPrivate> impl;
24 };
25
26 #endif // SCIQLOP_VISUALIZATIONSELECTIONZONEMANAGER_H
@@ -0,0 +1,51
1 #include "Visualization/VisualizationSelectionZoneManager.h"
2 #include "Visualization/VisualizationSelectionZoneItem.h"
3
4 struct VisualizationSelectionZoneManager::VisualizationSelectionZoneManagerPrivate {
5 QVector<VisualizationSelectionZoneItem *> m_SelectedItems;
6 };
7
8 VisualizationSelectionZoneManager::VisualizationSelectionZoneManager()
9 : impl{spimpl::make_unique_impl<VisualizationSelectionZoneManagerPrivate>()}
10 {
11 }
12
13 void VisualizationSelectionZoneManager::select(
14 const QVector<VisualizationSelectionZoneItem *> &items)
15 {
16 clearSelection();
17 for (auto item : items) {
18 setSelected(item, true);
19 }
20 }
21
22 void VisualizationSelectionZoneManager::setSelected(VisualizationSelectionZoneItem *item,
23 bool value)
24 {
25 if (value != item->selected()) {
26 item->setSelected(value);
27 item->parentPlot()->replot();
28 }
29
30 if (!value && impl->m_SelectedItems.contains(item)) {
31 impl->m_SelectedItems.removeAll(item);
32 }
33 else if (value) {
34 impl->m_SelectedItems << item;
35 }
36 }
37
38 void VisualizationSelectionZoneManager::clearSelection()
39 {
40 for (auto item : impl->m_SelectedItems) {
41 item->setSelected(false);
42 item->parentPlot()->replot();
43 }
44
45 impl->m_SelectedItems.clear();
46 }
47
48 QVector<VisualizationSelectionZoneItem *> VisualizationSelectionZoneManager::selectedItems() const
49 {
50 return impl->m_SelectedItems;
51 }
@@ -17,6 +17,7 class QCPRange;
17 class QCustomPlot;
17 class QCustomPlot;
18 class SqpRange;
18 class SqpRange;
19 class Variable;
19 class Variable;
20 class VisualizationWidget;
20 class VisualizationZoneWidget;
21 class VisualizationZoneWidget;
21
22
22 namespace Ui {
23 namespace Ui {
@@ -33,8 +34,12 public:
33 explicit VisualizationGraphWidget(const QString &name = {}, QWidget *parent = 0);
34 explicit VisualizationGraphWidget(const QString &name = {}, QWidget *parent = 0);
34 virtual ~VisualizationGraphWidget();
35 virtual ~VisualizationGraphWidget();
35
36
37 /// Returns the VisualizationZoneWidget which contains the graph or nullptr
36 VisualizationZoneWidget *parentZoneWidget() const noexcept;
38 VisualizationZoneWidget *parentZoneWidget() const noexcept;
37
39
40 /// Returns the main VisualizationWidget which contains the graph or nullptr
41 VisualizationWidget *parentVisualizationWidget() const;
42
38 /// If acquisition isn't enable, requestDataLoading signal cannot be emit
43 /// If acquisition isn't enable, requestDataLoading signal cannot be emit
39 void enableAcquisition(bool enable);
44 void enableAcquisition(bool enable);
40
45
@@ -6,6 +6,7
6 #include <Visualization/qcustomplot.h>
6 #include <Visualization/qcustomplot.h>
7
7
8 class VisualizationSelectionZoneItem : public QCPItemRect {
8 class VisualizationSelectionZoneItem : public QCPItemRect {
9
9 public:
10 public:
10 VisualizationSelectionZoneItem(QCustomPlot *plot);
11 VisualizationSelectionZoneItem(QCustomPlot *plot);
11 virtual ~VisualizationSelectionZoneItem();
12 virtual ~VisualizationSelectionZoneItem();
@@ -7,11 +7,14
7 #include <QLoggingCategory>
7 #include <QLoggingCategory>
8 #include <QWidget>
8 #include <QWidget>
9
9
10 #include <Common/spimpl.h>
11
10 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
11
13
12 class QMenu;
14 class QMenu;
13 class Variable;
15 class Variable;
14 class VisualizationTabWidget;
16 class VisualizationTabWidget;
17 class VisualizationSelectionZoneManager;
15
18
16 namespace Ui {
19 namespace Ui {
17 class VisualizationWidget;
20 class VisualizationWidget;
@@ -24,6 +27,9 public:
24 explicit VisualizationWidget(QWidget *parent = 0);
27 explicit VisualizationWidget(QWidget *parent = 0);
25 virtual ~VisualizationWidget();
28 virtual ~VisualizationWidget();
26
29
30 /// Returns the class which manage the selection of selection zone across the visualization
31 VisualizationSelectionZoneManager &selectionZoneManager() const;
32
27 // IVisualizationWidget interface
33 // IVisualizationWidget interface
28 void accept(IVisualizationWidgetVisitor *visitor) override;
34 void accept(IVisualizationWidgetVisitor *visitor) override;
29 bool canDrop(const Variable &variable) const override;
35 bool canDrop(const Variable &variable) const override;
@@ -49,6 +55,9 protected:
49
55
50 private:
56 private:
51 Ui::VisualizationWidget *ui;
57 Ui::VisualizationWidget *ui;
58
59 class VisualizationWidgetPrivate;
60 spimpl::unique_impl_ptr<VisualizationWidgetPrivate> impl;
52 };
61 };
53
62
54 #endif // VISUALIZATIONWIDGET_H
63 #endif // VISUALIZATIONWIDGET_H
@@ -83,7 +83,8 gui_sources = [
83 'src/Visualization/ColorScaleEditor.cpp',
83 'src/Visualization/ColorScaleEditor.cpp',
84 'src/Visualization/SqpColorScale.cpp',
84 'src/Visualization/SqpColorScale.cpp',
85 'src/Visualization/QCPColorMapIterator.cpp',
85 'src/Visualization/QCPColorMapIterator.cpp',
86 'src/Visualization/VisualizationSelectionZoneItem.cpp'
86 'src/Visualization/VisualizationSelectionZoneItem.cpp',
87 'src/Visualization/VisualizationSelectionZoneManager.cpp'
87 ]
88 ]
88
89
89 gui_inc = include_directories(['include'])
90 gui_inc = include_directories(['include'])
@@ -5,6 +5,8
5 #include "Visualization/VisualizationGraphHelper.h"
5 #include "Visualization/VisualizationGraphHelper.h"
6 #include "Visualization/VisualizationGraphRenderingDelegate.h"
6 #include "Visualization/VisualizationGraphRenderingDelegate.h"
7 #include "Visualization/VisualizationSelectionZoneItem.h"
7 #include "Visualization/VisualizationSelectionZoneItem.h"
8 #include "Visualization/VisualizationSelectionZoneManager.h"
9 #include "Visualization/VisualizationWidget.h"
8 #include "Visualization/VisualizationZoneWidget.h"
10 #include "Visualization/VisualizationZoneWidget.h"
9 #include "ui_VisualizationGraphWidget.h"
11 #include "ui_VisualizationGraphWidget.h"
10
12
@@ -40,6 +42,9 const auto PAN_SPEED = 5;
40 /// Key pressed to enable a calibration pan
42 /// Key pressed to enable a calibration pan
41 const auto VERTICAL_PAN_MODIFIER = Qt::AltModifier;
43 const auto VERTICAL_PAN_MODIFIER = Qt::AltModifier;
42
44
45 /// Key pressed to enable multi selection of selection zones
46 const auto MULTI_ZONE_SELECTION_MODIFIER = Qt::ControlModifier;
47
43 /// Minimum size for the zoom box, in percentage of the axis range
48 /// Minimum size for the zoom box, in percentage of the axis range
44 const auto ZOOM_BOX_MIN_SIZE = 0.8;
49 const auto ZOOM_BOX_MIN_SIZE = 0.8;
45
50
@@ -109,30 +114,30 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
109 }
114 }
110 }
115 }
111
116
112 void startDrawingZone(const QPoint &pos, QCustomPlot &plot)
117 void startDrawingZone(const QPoint &pos, VisualizationGraphWidget *graph)
113 {
118 {
114 endDrawingZone(plot);
119 endDrawingZone(graph);
115
120
116 auto axisPos = posToAxisPos(pos, plot);
121 auto axisPos = posToAxisPos(pos, graph->plot());
117
122
118 m_DrawingZone = new VisualizationSelectionZoneItem{&plot};
123 m_DrawingZone = new VisualizationSelectionZoneItem{&graph->plot()};
119 m_DrawingZone->setRange(axisPos.x(), axisPos.x());
124 m_DrawingZone->setRange(axisPos.x(), axisPos.x());
120 m_DrawingZone->setEditionEnabled(false);
125 m_DrawingZone->setEditionEnabled(false);
121 }
126 }
122
127
123 void endDrawingZone(QCustomPlot &plot)
128 void endDrawingZone(VisualizationGraphWidget *graph)
124 {
129 {
125 if (m_DrawingZone) {
130 if (m_DrawingZone) {
126 auto drawingZoneRange = m_DrawingZone->range();
131 auto drawingZoneRange = m_DrawingZone->range();
127 if (qAbs(drawingZoneRange.m_TEnd - drawingZoneRange.m_TStart) > 0) {
132 if (qAbs(drawingZoneRange.m_TEnd - drawingZoneRange.m_TStart) > 0) {
128 m_DrawingZone->setEditionEnabled(true);
133 m_DrawingZone->setEditionEnabled(true);
129 m_SelectionZones.append(m_DrawingZone);
134 addSelectionZone(m_DrawingZone);
130 }
135 }
131 else {
136 else {
132 plot.removeItem(m_DrawingZone); // the item is deleted by QCustomPlot
137 graph->plot().removeItem(m_DrawingZone); // the item is deleted by QCustomPlot
133 }
138 }
134
139
135 plot.replot(QCustomPlot::rpQueuedReplot);
140 graph->plot().replot(QCustomPlot::rpQueuedReplot);
136 m_DrawingZone = nullptr;
141 m_DrawingZone = nullptr;
137 }
142 }
138 }
143 }
@@ -144,6 +149,8 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
144 }
149 }
145 }
150 }
146
151
152 void addSelectionZone(VisualizationSelectionZoneItem *zone) { m_SelectionZones << zone; }
153
147 VisualizationSelectionZoneItem *selectionZoneAt(const QPoint &pos,
154 VisualizationSelectionZoneItem *selectionZoneAt(const QPoint &pos,
148 const QCustomPlot &plot) const
155 const QCustomPlot &plot) const
149 {
156 {
@@ -188,7 +195,7 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget
188 // Set qcpplot properties :
195 // Set qcpplot properties :
189 // - zoom is enabled
196 // - zoom is enabled
190 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
197 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
191 ui->widget->setInteractions(QCP::iRangeZoom | QCP::iSelectItems);
198 ui->widget->setInteractions(QCP::iRangeZoom);
192 ui->widget->axisRect()->setRangeDrag(Qt::Horizontal | Qt::Vertical);
199 ui->widget->axisRect()->setRangeDrag(Qt::Horizontal | Qt::Vertical);
193
200
194 // The delegate must be initialized after the ui as it uses the plot
201 // The delegate must be initialized after the ui as it uses the plot
@@ -207,9 +214,10 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget
207 connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel);
214 connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel);
208 connect(ui->widget, &QCustomPlot::mouseDoubleClick, this,
215 connect(ui->widget, &QCustomPlot::mouseDoubleClick, this,
209 &VisualizationGraphWidget::onMouseDoubleClick);
216 &VisualizationGraphWidget::onMouseDoubleClick);
210 connect(ui->widget->xAxis, static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>(
217 connect(
211 &QCPAxis::rangeChanged),
218 ui->widget->xAxis,
212 this, &VisualizationGraphWidget::onRangeChanged, Qt::DirectConnection);
219 static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>(&QCPAxis::rangeChanged),
220 this, &VisualizationGraphWidget::onRangeChanged, Qt::DirectConnection);
213
221
214 // Activates menu when right clicking on the graph
222 // Activates menu when right clicking on the graph
215 ui->widget->setContextMenuPolicy(Qt::CustomContextMenu);
223 ui->widget->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -243,6 +251,16 VisualizationZoneWidget *VisualizationGraphWidget::parentZoneWidget() const noex
243 return qobject_cast<VisualizationZoneWidget *>(parent);
251 return qobject_cast<VisualizationZoneWidget *>(parent);
244 }
252 }
245
253
254 VisualizationWidget *VisualizationGraphWidget::parentVisualizationWidget() const
255 {
256 auto parent = parentWidget();
257 while (parent != nullptr && !qobject_cast<VisualizationWidget *>(parent)) {
258 parent = parent->parentWidget();
259 }
260
261 return qobject_cast<VisualizationWidget *>(parent);
262 }
263
246 void VisualizationGraphWidget::enableAcquisition(bool enable)
264 void VisualizationGraphWidget::enableAcquisition(bool enable)
247 {
265 {
248 impl->m_DoAcquisition = enable;
266 impl->m_DoAcquisition = enable;
@@ -348,9 +366,10 QVector<SqpRange> VisualizationGraphWidget::selectionZoneRanges() const
348 void VisualizationGraphWidget::addSelectionZones(const QVector<SqpRange> &ranges)
366 void VisualizationGraphWidget::addSelectionZones(const QVector<SqpRange> &ranges)
349 {
367 {
350 for (const auto &range : ranges) {
368 for (const auto &range : ranges) {
369 // note: ownership is transfered to QCustomPlot
351 auto zone = new VisualizationSelectionZoneItem(&plot());
370 auto zone = new VisualizationSelectionZoneItem(&plot());
352 zone->setRange(range.m_TStart, range.m_TEnd);
371 zone->setRange(range.m_TStart, range.m_TEnd);
353 impl->m_SelectionZones << zone;
372 impl->addSelectionZone(zone);
354 }
373 }
355
374
356 plot().replot(QCustomPlot::rpQueuedReplot);
375 plot().replot(QCustomPlot::rpQueuedReplot);
@@ -588,9 +607,9 void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept
588
607
589 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange &t2)
608 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange &t2)
590 {
609 {
591 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: VisualizationGraphWidget::onRangeChanged")
610 qCDebug(LOG_VisualizationGraphWidget())
592 << QThread::currentThread()->objectName() << "DoAcqui"
611 << tr("TORM: VisualizationGraphWidget::onRangeChanged")
593 << impl->m_DoAcquisition;
612 << QThread::currentThread()->objectName() << "DoAcqui" << impl->m_DoAcquisition;
594
613
595 auto graphRange = SqpRange{t1.lower, t1.upper};
614 auto graphRange = SqpRange{t1.lower, t1.upper};
596 auto oldGraphRange = SqpRange{t2.lower, t2.upper};
615 auto oldGraphRange = SqpRange{t2.lower, t2.upper};
@@ -728,19 +747,19 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
728 void VisualizationGraphWidget::onMousePress(QMouseEvent *event) noexcept
747 void VisualizationGraphWidget::onMousePress(QMouseEvent *event) noexcept
729 {
748 {
730 bool isDragDropClick = event->modifiers().testFlag(DRAG_DROP_MODIFIER);
749 bool isDragDropClick = event->modifiers().testFlag(DRAG_DROP_MODIFIER);
750 auto isSelectionZoneMode
751 = sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones;
731
752
732 if (!isDragDropClick) {
753 if (!isDragDropClick) {
733 if (sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::ZoomBox) {
754 if (sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::ZoomBox) {
734 // Starts a zoom box
755 // Starts a zoom box
735 impl->startDrawingRect(event->pos(), plot());
756 impl->startDrawingRect(event->pos(), plot());
736 }
757 }
737 else if (sqpApp->plotsInteractionMode()
758 else if (isSelectionZoneMode && impl->m_DrawingZone == nullptr) {
738 == SqpApplication::PlotsInteractionMode::SelectionZones
739 && impl->m_DrawingZone == nullptr) {
740 // Starts a new selection zone
759 // Starts a new selection zone
741 auto zoneAtPos = impl->selectionZoneAt(event->pos(), plot());
760 auto zoneAtPos = impl->selectionZoneAt(event->pos(), plot());
742 if (!zoneAtPos) {
761 if (!zoneAtPos) {
743 impl->startDrawingZone(event->pos(), plot());
762 impl->startDrawingZone(event->pos(), this);
744 }
763 }
745 }
764 }
746 }
765 }
@@ -753,10 +772,31 void VisualizationGraphWidget::onMousePress(QMouseEvent *event) noexcept
753 == SqpApplication::PlotsInteractionMode::None
772 == SqpApplication::PlotsInteractionMode::None
754 && !isDragDropClick);
773 && !isDragDropClick);
755
774
756 // Allows zone edition only in selection zone mode without ALT pressed (ALT is for drag&drop)
775 // Allows zone edition only in selection zone mode without drag&drop
757 impl->setSelectionZonesEditionEnabled(
776 impl->setSelectionZonesEditionEnabled(isSelectionZoneMode && !isDragDropClick);
758 sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones
777
759 && !isDragDropClick);
778 // Selection
779 if (isSelectionZoneMode) {
780 auto isMultiSelectionClick = event->modifiers().testFlag(MULTI_ZONE_SELECTION_MODIFIER);
781 auto selectionZoneItemUnderCursor = impl->selectionZoneAt(event->pos(), plot());
782 if (selectionZoneItemUnderCursor && event->button() == Qt::LeftButton) {
783 if (!isMultiSelectionClick) {
784 parentVisualizationWidget()->selectionZoneManager().select(
785 {selectionZoneItemUnderCursor});
786 }
787 else {
788 parentVisualizationWidget()->selectionZoneManager().setSelected(
789 selectionZoneItemUnderCursor, !selectionZoneItemUnderCursor->selected()
790 || event->button() == Qt::RightButton);
791 }
792 }
793 else if (!isMultiSelectionClick && event->button() == Qt::LeftButton) {
794 parentVisualizationWidget()->selectionZoneManager().clearSelection();
795 }
796 else {
797 // No selection change
798 }
799 }
760
800
761 VisualizationDragWidget::mousePressEvent(event);
801 VisualizationDragWidget::mousePressEvent(event);
762 }
802 }
@@ -786,7 +826,7 void VisualizationGraphWidget::onMouseRelease(QMouseEvent *event) noexcept
786 }
826 }
787 }
827 }
788
828
789 impl->endDrawingZone(plot());
829 impl->endDrawingZone(this);
790
830
791 impl->m_IsCalibration = false;
831 impl->m_IsCalibration = false;
792 }
832 }
@@ -1,5 +1,7
1 #include "Visualization/VisualizationSelectionZoneItem.h"
1 #include "Visualization/VisualizationSelectionZoneItem.h"
2
2
3 const QString &DEFAULT_COLOR = QStringLiteral("#E79D41");
4
3 struct VisualizationSelectionZoneItem::VisualizationSelectionZoneItemPrivate {
5 struct VisualizationSelectionZoneItem::VisualizationSelectionZoneItemPrivate {
4
6
5 QCustomPlot *m_Plot;
7 QCustomPlot *m_Plot;
@@ -54,6 +56,7 VisualizationSelectionZoneItem::VisualizationSelectionZoneItem(QCustomPlot *plot
54 topLeft->setTypeY(QCPItemPosition::ptAxisRectRatio);
56 topLeft->setTypeY(QCPItemPosition::ptAxisRectRatio);
55 bottomRight->setTypeX(QCPItemPosition::ptPlotCoords);
57 bottomRight->setTypeX(QCPItemPosition::ptPlotCoords);
56 bottomRight->setTypeY(QCPItemPosition::ptAxisRectRatio);
58 bottomRight->setTypeY(QCPItemPosition::ptAxisRectRatio);
59 setSelectable(false);
57
60
58 impl->m_RightLine = new QCPItemStraightLine(plot);
61 impl->m_RightLine = new QCPItemStraightLine(plot);
59 impl->m_RightLine->point1->setParentAnchor(topRight);
62 impl->m_RightLine->point1->setParentAnchor(topRight);
@@ -62,6 +65,7 VisualizationSelectionZoneItem::VisualizationSelectionZoneItem(QCustomPlot *plot
62 impl->m_RightLine->point1->setTypeY(QCPItemPosition::ptAbsolute);
65 impl->m_RightLine->point1->setTypeY(QCPItemPosition::ptAbsolute);
63 impl->m_RightLine->point2->setTypeX(QCPItemPosition::ptAbsolute);
66 impl->m_RightLine->point2->setTypeX(QCPItemPosition::ptAbsolute);
64 impl->m_RightLine->point2->setTypeY(QCPItemPosition::ptAbsolute);
67 impl->m_RightLine->point2->setTypeY(QCPItemPosition::ptAbsolute);
68 impl->m_RightLine->setSelectable(false);
65
69
66 impl->m_LeftLine = new QCPItemStraightLine(plot);
70 impl->m_LeftLine = new QCPItemStraightLine(plot);
67 impl->m_LeftLine->point1->setParentAnchor(topLeft);
71 impl->m_LeftLine->point1->setParentAnchor(topLeft);
@@ -70,16 +74,9 VisualizationSelectionZoneItem::VisualizationSelectionZoneItem(QCustomPlot *plot
70 impl->m_LeftLine->point1->setTypeY(QCPItemPosition::ptAbsolute);
74 impl->m_LeftLine->point1->setTypeY(QCPItemPosition::ptAbsolute);
71 impl->m_LeftLine->point2->setTypeX(QCPItemPosition::ptAbsolute);
75 impl->m_LeftLine->point2->setTypeX(QCPItemPosition::ptAbsolute);
72 impl->m_LeftLine->point2->setTypeY(QCPItemPosition::ptAbsolute);
76 impl->m_LeftLine->point2->setTypeY(QCPItemPosition::ptAbsolute);
73
74 impl->m_RightLine->setSelectable(false);
75 impl->m_LeftLine->setSelectable(false);
77 impl->m_LeftLine->setSelectable(false);
76
78
77 // connect(this, &VisualizationSelectionZoneItem::selectionChanged, impl->m_RightLine,
79 setColor(QColor(DEFAULT_COLOR));
78 // &QCPItemStraightLine::setSelected);
79 // connect(this, &VisualizationSelectionZoneItem::selectionChanged, impl->m_LeftLine,
80 // &QCPItemStraightLine::setSelected);
81
82 setColor(QColor("#E79D41"));
83 }
80 }
84
81
85 VisualizationSelectionZoneItem::~VisualizationSelectionZoneItem()
82 VisualizationSelectionZoneItem::~VisualizationSelectionZoneItem()
@@ -225,13 +222,14 void VisualizationSelectionZoneItem::setHovered(bool value)
225
222
226 void VisualizationSelectionZoneItem::mousePressEvent(QMouseEvent *event, const QVariant &details)
223 void VisualizationSelectionZoneItem::mousePressEvent(QMouseEvent *event, const QVariant &details)
227 {
224 {
228 if (isEditionEnabled()) {
225 if (isEditionEnabled() && event->button() == Qt::LeftButton) {
229 impl->m_CurrentEditionMode = impl->getEditionMode(event->pos(), this);
226 impl->m_CurrentEditionMode = impl->getEditionMode(event->pos(), this);
230
227
231 impl->m_MovedOrinalT1 = impl->m_T1;
228 impl->m_MovedOrinalT1 = impl->m_T1;
232 impl->m_MovedOrinalT2 = impl->m_T2;
229 impl->m_MovedOrinalT2 = impl->m_T2;
233 }
230 }
234 else {
231 else {
232 impl->m_CurrentEditionMode = VisualizationSelectionZoneItemPrivate::EditionMode::NoEdition;
235 event->ignore();
233 event->ignore();
236 }
234 }
237 }
235 }
@@ -252,8 +250,8 void VisualizationSelectionZoneItem::mouseMoveEvent(QMouseEvent *event, const QP
252 case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeRight:
250 case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeRight:
253 setEnd(impl->m_MovedOrinalT2 + diff);
251 setEnd(impl->m_MovedOrinalT2 + diff);
254 break;
252 break;
255 // default:
253 default:
256 // unknown edition mode
254 break;
257 }
255 }
258 }
256 }
259 else {
257 else {
@@ -1,6 +1,7
1 #include "Visualization/VisualizationWidget.h"
1 #include "Visualization/VisualizationWidget.h"
2 #include "Visualization/IVisualizationWidgetVisitor.h"
2 #include "Visualization/IVisualizationWidgetVisitor.h"
3 #include "Visualization/VisualizationGraphWidget.h"
3 #include "Visualization/VisualizationGraphWidget.h"
4 #include "Visualization/VisualizationSelectionZoneManager.h"
4 #include "Visualization/VisualizationTabWidget.h"
5 #include "Visualization/VisualizationTabWidget.h"
5 #include "Visualization/VisualizationZoneWidget.h"
6 #include "Visualization/VisualizationZoneWidget.h"
6 #include "Visualization/operations/FindVariableOperation.h"
7 #include "Visualization/operations/FindVariableOperation.h"
@@ -16,10 +17,23
16
17
17 #include <QToolButton>
18 #include <QToolButton>
18
19
20 #include <memory>
21
19 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
22 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
20
23
24 struct VisualizationWidget::VisualizationWidgetPrivate {
25 std::unique_ptr<VisualizationSelectionZoneManager> m_ZoneSelectionManager = nullptr;
26
27 VisualizationWidgetPrivate()
28 : m_ZoneSelectionManager(std::make_unique<VisualizationSelectionZoneManager>())
29 {
30 }
31 };
32
21 VisualizationWidget::VisualizationWidget(QWidget *parent)
33 VisualizationWidget::VisualizationWidget(QWidget *parent)
22 : QWidget{parent}, ui{new Ui::VisualizationWidget}
34 : QWidget{parent},
35 ui{new Ui::VisualizationWidget},
36 impl{spimpl::make_unique_impl<VisualizationWidgetPrivate>()}
23 {
37 {
24 ui->setupUi(this);
38 ui->setupUi(this);
25
39
@@ -82,6 +96,11 VisualizationWidget::~VisualizationWidget()
82 delete ui;
96 delete ui;
83 }
97 }
84
98
99 VisualizationSelectionZoneManager &VisualizationWidget::selectionZoneManager() const
100 {
101 return *impl->m_ZoneSelectionManager.get();
102 }
103
85 void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor)
104 void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor)
86 {
105 {
87 if (visitor) {
106 if (visitor) {
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

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