@@ -1,51 +1,54 | |||||
1 | #include "Visualization/VisualizationSelectionZoneManager.h" |
|
1 | #include "Visualization/VisualizationSelectionZoneManager.h" | |
2 | #include "Visualization/VisualizationSelectionZoneItem.h" |
|
2 | #include "Visualization/VisualizationSelectionZoneItem.h" | |
3 |
|
3 | |||
4 | struct VisualizationSelectionZoneManager::VisualizationSelectionZoneManagerPrivate { |
|
4 | struct VisualizationSelectionZoneManager::VisualizationSelectionZoneManagerPrivate { | |
5 | QVector<VisualizationSelectionZoneItem *> m_SelectedItems; |
|
5 | QVector<VisualizationSelectionZoneItem *> m_SelectedItems; | |
6 | }; |
|
6 | }; | |
7 |
|
7 | |||
8 | VisualizationSelectionZoneManager::VisualizationSelectionZoneManager() |
|
8 | VisualizationSelectionZoneManager::VisualizationSelectionZoneManager() | |
9 | : impl{spimpl::make_unique_impl<VisualizationSelectionZoneManagerPrivate>()} |
|
9 | : impl{spimpl::make_unique_impl<VisualizationSelectionZoneManagerPrivate>()} | |
10 | { |
|
10 | { | |
11 | } |
|
11 | } | |
12 |
|
12 | |||
13 | void VisualizationSelectionZoneManager::select( |
|
13 | void VisualizationSelectionZoneManager::select( | |
14 | const QVector<VisualizationSelectionZoneItem *> &items) |
|
14 | const QVector<VisualizationSelectionZoneItem *> &items) | |
15 | { |
|
15 | { | |
16 | clearSelection(); |
|
16 | clearSelection(); | |
17 | for (auto item : items) { |
|
17 | for (auto item : items) { | |
18 | setSelected(item, true); |
|
18 | setSelected(item, true); | |
19 | } |
|
19 | } | |
20 | } |
|
20 | } | |
21 |
|
21 | |||
22 | void VisualizationSelectionZoneManager::setSelected(VisualizationSelectionZoneItem *item, |
|
22 | void VisualizationSelectionZoneManager::setSelected(VisualizationSelectionZoneItem *item, | |
23 | bool value) |
|
23 | bool value) | |
24 | { |
|
24 | { | |
25 | if (value != item->selected()) { |
|
25 | if (value != item->selected()) { | |
26 | item->setSelected(value); |
|
26 | item->setSelected(value); | |
27 | item->parentPlot()->replot(QCustomPlot::rpQueuedReplot); |
|
27 | item->parentPlot()->replot(QCustomPlot::rpQueuedReplot); | |
28 | } |
|
28 | } | |
29 |
|
29 | |||
30 | if (!value && impl->m_SelectedItems.contains(item)) { |
|
30 | if (!value && impl->m_SelectedItems.contains(item)) { | |
31 | impl->m_SelectedItems.removeAll(item); |
|
31 | impl->m_SelectedItems.removeAll(item); | |
32 | } |
|
32 | } | |
33 | else if (value) { |
|
33 | else if (value) { | |
34 | impl->m_SelectedItems << item; |
|
34 | impl->m_SelectedItems << item; | |
35 | } |
|
35 | } | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | void VisualizationSelectionZoneManager::clearSelection() |
|
38 | void VisualizationSelectionZoneManager::clearSelection() | |
39 | { |
|
39 | { | |
40 | for (auto item : impl->m_SelectedItems) { |
|
40 | for (auto item : impl->m_SelectedItems) { | |
41 | item->setSelected(false); |
|
41 | item->setSelected(false); | |
42 | item->parentPlot()->replot(QCustomPlot::rpQueuedReplot); |
|
42 | auto parentPlot = item->parentPlot(); | |
|
43 | if (parentPlot) { | |||
|
44 | parentPlot->replot(QCustomPlot::rpQueuedReplot); | |||
|
45 | } | |||
43 | } |
|
46 | } | |
44 |
|
47 | |||
45 | impl->m_SelectedItems.clear(); |
|
48 | impl->m_SelectedItems.clear(); | |
46 | } |
|
49 | } | |
47 |
|
50 | |||
48 | QVector<VisualizationSelectionZoneItem *> VisualizationSelectionZoneManager::selectedItems() const |
|
51 | QVector<VisualizationSelectionZoneItem *> VisualizationSelectionZoneManager::selectedItems() const | |
49 | { |
|
52 | { | |
50 | return impl->m_SelectedItems; |
|
53 | return impl->m_SelectedItems; | |
51 | } |
|
54 | } |
General Comments 0
You need to be logged in to leave comments.
Login now