Auto status change to "Under Review"
@@ -1,442 +1,440 | |||
|
1 | 1 | #include "Visualization/VisualizationSelectionZoneItem.h" |
|
2 | 2 | #include "Visualization/VisualizationGraphWidget.h" |
|
3 | 3 | #include "Visualization/VisualizationSelectionZoneManager.h" |
|
4 | 4 | #include "Visualization/VisualizationWidget.h" |
|
5 | 5 | |
|
6 | 6 | const QString &DEFAULT_COLOR = QStringLiteral("#E79D41"); |
|
7 | 7 | |
|
8 | 8 | struct VisualizationSelectionZoneItem::VisualizationSelectionZoneItemPrivate { |
|
9 | 9 | |
|
10 | 10 | QCustomPlot *m_Plot; |
|
11 | 11 | double m_T1 = 0; |
|
12 | 12 | double m_T2 = 0; |
|
13 | 13 | QColor m_Color; |
|
14 | 14 | |
|
15 | 15 | bool m_IsEditionEnabled = true; |
|
16 | 16 | double m_MovedOrinalT1 = 0; |
|
17 | 17 | double m_MovedOrinalT2 = 0; |
|
18 | 18 | |
|
19 | 19 | QCPItemStraightLine *m_LeftLine; |
|
20 | 20 | QCPItemStraightLine *m_RightLine; |
|
21 | 21 | QCPItemText *m_NameLabelItem = nullptr; |
|
22 | 22 | |
|
23 | 23 | enum class EditionMode { NoEdition, ResizeLeft, ResizeRight, Move }; |
|
24 | 24 | EditionMode m_CurrentEditionMode; |
|
25 | 25 | |
|
26 | 26 | QVector<VisualizationSelectionZoneItem *> m_AssociatedEditedZones; |
|
27 | 27 | |
|
28 | 28 | VisualizationSelectionZoneItemPrivate(QCustomPlot *plot) |
|
29 | 29 | : m_Plot(plot), m_Color(Qt::blue), m_CurrentEditionMode(EditionMode::NoEdition) |
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | 33 | void updatePosition(VisualizationSelectionZoneItem *item) |
|
34 | 34 | { |
|
35 | 35 | item->topLeft->setCoords(m_T1, 0); |
|
36 | 36 | item->bottomRight->setCoords(m_T2, 1); |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | EditionMode getEditionMode(const QPoint &pos, const VisualizationSelectionZoneItem *zoneItem) |
|
40 | 40 | { |
|
41 | 41 | auto distanceLeft = m_LeftLine->selectTest(pos, false); |
|
42 | 42 | auto distanceRight = m_RightLine->selectTest(pos, false); |
|
43 | 43 | auto distance = zoneItem->selectTest(pos, false); |
|
44 | 44 | |
|
45 | 45 | if (distanceRight <= distance) { |
|
46 | 46 | return VisualizationSelectionZoneItemPrivate::EditionMode::ResizeRight; |
|
47 | 47 | } |
|
48 | 48 | else if (distanceLeft <= distance) { |
|
49 | 49 | return VisualizationSelectionZoneItemPrivate::EditionMode::ResizeLeft; |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | return VisualizationSelectionZoneItemPrivate::EditionMode::Move; |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | 55 | double pixelSizeToAxisXSize(double pixels) |
|
56 | 56 | { |
|
57 | 57 | auto axis = m_Plot->axisRect()->axis(QCPAxis::atBottom); |
|
58 | 58 | return axis->pixelToCoord(pixels) - axis->pixelToCoord(0); |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | 61 | bool alignZones(VisualizationSelectionZoneItem *referenceZone, |
|
62 | 62 | const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool alignOnLeft, |
|
63 | 63 | bool allowResize, bool vertically) |
|
64 | 64 | { |
|
65 | 65 | auto result = false; |
|
66 | 66 | |
|
67 | 67 | auto referenceTime |
|
68 | 68 | = alignOnLeft ? referenceZone->range().m_TStart : referenceZone->range().m_TEnd; |
|
69 | 69 | |
|
70 | 70 | auto referenceBottomAxis = m_Plot->axisRect()->axis(QCPAxis::atBottom); |
|
71 | 71 | auto referenceVerticalPosition = referenceBottomAxis->coordToPixel(referenceTime); |
|
72 | 72 | |
|
73 | 73 | for (auto otherZone : zonesToAlign) { |
|
74 | 74 | |
|
75 | 75 | auto otherZoneRange = otherZone->range(); |
|
76 | 76 | auto newZoneStart = otherZoneRange.m_TStart; |
|
77 | 77 | auto newZoneEnd = otherZoneRange.m_TEnd; |
|
78 | 78 | |
|
79 | 79 | auto alignedTime = referenceTime; |
|
80 | 80 | if (vertically) { |
|
81 | 81 | auto otherZoneAxis = otherZone->parentPlot()->axisRect()->axis(QCPAxis::atBottom); |
|
82 | 82 | alignedTime = otherZoneAxis->pixelToCoord(referenceVerticalPosition); |
|
83 | 83 | } |
|
84 | 84 | |
|
85 | 85 | if (alignOnLeft) { |
|
86 | 86 | newZoneStart = alignedTime; |
|
87 | 87 | if (!allowResize) { |
|
88 | 88 | newZoneEnd = alignedTime + (otherZoneRange.m_TEnd - otherZoneRange.m_TStart); |
|
89 | 89 | } |
|
90 | 90 | } |
|
91 | 91 | else { // align on right |
|
92 | 92 | newZoneEnd = alignedTime; |
|
93 | 93 | if (!allowResize) { |
|
94 | 94 | newZoneStart = alignedTime - (otherZoneRange.m_TEnd - otherZoneRange.m_TStart); |
|
95 | 95 | } |
|
96 | 96 | } |
|
97 | 97 | |
|
98 | 98 | if (newZoneStart < newZoneEnd) { |
|
99 | 99 | result = true; |
|
100 | 100 | otherZone->setRange(newZoneStart, newZoneEnd); |
|
101 | 101 | otherZone->parentPlot()->replot(); |
|
102 | 102 | } |
|
103 | 103 | } |
|
104 | 104 | |
|
105 | 105 | return result; |
|
106 | 106 | } |
|
107 | 107 | }; |
|
108 | 108 | |
|
109 | 109 | VisualizationSelectionZoneItem::VisualizationSelectionZoneItem(QCustomPlot *plot) |
|
110 | 110 | : QCPItemRect(plot), |
|
111 | 111 | impl{spimpl::make_unique_impl<VisualizationSelectionZoneItemPrivate>(plot)} |
|
112 | 112 | { |
|
113 | 113 | topLeft->setTypeX(QCPItemPosition::ptPlotCoords); |
|
114 | 114 | topLeft->setTypeY(QCPItemPosition::ptAxisRectRatio); |
|
115 | 115 | bottomRight->setTypeX(QCPItemPosition::ptPlotCoords); |
|
116 | 116 | bottomRight->setTypeY(QCPItemPosition::ptAxisRectRatio); |
|
117 | 117 | setSelectable(false); |
|
118 | 118 | |
|
119 | 119 | impl->m_RightLine = new QCPItemStraightLine(plot); |
|
120 | 120 | impl->m_RightLine->point1->setParentAnchor(topRight); |
|
121 | 121 | impl->m_RightLine->point2->setParentAnchor(bottomRight); |
|
122 | 122 | impl->m_RightLine->point1->setTypeX(QCPItemPosition::ptAbsolute); |
|
123 | 123 | impl->m_RightLine->point1->setTypeY(QCPItemPosition::ptAbsolute); |
|
124 | 124 | impl->m_RightLine->point2->setTypeX(QCPItemPosition::ptAbsolute); |
|
125 | 125 | impl->m_RightLine->point2->setTypeY(QCPItemPosition::ptAbsolute); |
|
126 | 126 | impl->m_RightLine->setSelectable(false); |
|
127 | 127 | |
|
128 | 128 | impl->m_LeftLine = new QCPItemStraightLine(plot); |
|
129 | 129 | impl->m_LeftLine->point1->setParentAnchor(topLeft); |
|
130 | 130 | impl->m_LeftLine->point2->setParentAnchor(bottomLeft); |
|
131 | 131 | impl->m_LeftLine->point1->setTypeX(QCPItemPosition::ptAbsolute); |
|
132 | 132 | impl->m_LeftLine->point1->setTypeY(QCPItemPosition::ptAbsolute); |
|
133 | 133 | impl->m_LeftLine->point2->setTypeX(QCPItemPosition::ptAbsolute); |
|
134 | 134 | impl->m_LeftLine->point2->setTypeY(QCPItemPosition::ptAbsolute); |
|
135 | 135 | impl->m_LeftLine->setSelectable(false); |
|
136 | 136 | |
|
137 | 137 | connect(this, &VisualizationSelectionZoneItem::selectionChanged, impl->m_RightLine, |
|
138 | 138 | &QCPItemStraightLine::setSelected); |
|
139 | 139 | connect(this, &VisualizationSelectionZoneItem::selectionChanged, impl->m_LeftLine, |
|
140 | 140 | &QCPItemStraightLine::setSelected); |
|
141 | 141 | |
|
142 | 142 | setColor(QColor(DEFAULT_COLOR)); |
|
143 | 143 | } |
|
144 | 144 | |
|
145 | 145 | VisualizationSelectionZoneItem::~VisualizationSelectionZoneItem() |
|
146 | 146 | { |
|
147 | impl->m_Plot->removeItem(impl->m_RightLine); | |
|
148 | impl->m_Plot->removeItem(impl->m_LeftLine); | |
|
149 | 147 | } |
|
150 | 148 | |
|
151 | 149 | VisualizationGraphWidget *VisualizationSelectionZoneItem::parentGraphWidget() const noexcept |
|
152 | 150 | { |
|
153 | 151 | auto parent = impl->m_Plot->parentWidget(); |
|
154 | 152 | while (parent != nullptr && !qobject_cast<VisualizationGraphWidget *>(parent)) { |
|
155 | 153 | parent = parent->parentWidget(); |
|
156 | 154 | } |
|
157 | 155 | |
|
158 | 156 | return qobject_cast<VisualizationGraphWidget *>(parent); |
|
159 | 157 | } |
|
160 | 158 | |
|
161 | 159 | void VisualizationSelectionZoneItem::setName(const QString &name) |
|
162 | 160 | { |
|
163 | 161 | if (name.isEmpty() && impl->m_NameLabelItem) { |
|
164 | 162 | impl->m_Plot->removeItem(impl->m_NameLabelItem); |
|
165 | 163 | impl->m_NameLabelItem = nullptr; |
|
166 | 164 | } |
|
167 | 165 | else if (!impl->m_NameLabelItem) { |
|
168 | 166 | impl->m_NameLabelItem = new QCPItemText(impl->m_Plot); |
|
169 | 167 | impl->m_NameLabelItem->setText(name); |
|
170 | 168 | impl->m_NameLabelItem->setPositionAlignment(Qt::AlignHCenter | Qt::AlignTop); |
|
171 | 169 | impl->m_NameLabelItem->setColor(impl->m_Color); |
|
172 | 170 | impl->m_NameLabelItem->position->setParentAnchor(top); |
|
173 | 171 | } |
|
174 | 172 | } |
|
175 | 173 | |
|
176 | 174 | QString VisualizationSelectionZoneItem::name() const |
|
177 | 175 | { |
|
178 | 176 | if (!impl->m_NameLabelItem) { |
|
179 | 177 | return QString(); |
|
180 | 178 | } |
|
181 | 179 | |
|
182 | 180 | return impl->m_NameLabelItem->text(); |
|
183 | 181 | } |
|
184 | 182 | |
|
185 | 183 | SqpRange VisualizationSelectionZoneItem::range() const |
|
186 | 184 | { |
|
187 | 185 | SqpRange range; |
|
188 | 186 | range.m_TStart = impl->m_T1 <= impl->m_T2 ? impl->m_T1 : impl->m_T2; |
|
189 | 187 | range.m_TEnd = impl->m_T1 > impl->m_T2 ? impl->m_T1 : impl->m_T2; |
|
190 | 188 | return range; |
|
191 | 189 | } |
|
192 | 190 | |
|
193 | 191 | void VisualizationSelectionZoneItem::setRange(double tstart, double tend) |
|
194 | 192 | { |
|
195 | 193 | impl->m_T1 = tstart; |
|
196 | 194 | impl->m_T2 = tend; |
|
197 | 195 | impl->updatePosition(this); |
|
198 | 196 | } |
|
199 | 197 | |
|
200 | 198 | void VisualizationSelectionZoneItem::setStart(double tstart) |
|
201 | 199 | { |
|
202 | 200 | impl->m_T1 = tstart; |
|
203 | 201 | impl->updatePosition(this); |
|
204 | 202 | } |
|
205 | 203 | |
|
206 | 204 | void VisualizationSelectionZoneItem::setEnd(double tend) |
|
207 | 205 | { |
|
208 | 206 | impl->m_T2 = tend; |
|
209 | 207 | impl->updatePosition(this); |
|
210 | 208 | } |
|
211 | 209 | |
|
212 | 210 | void VisualizationSelectionZoneItem::setColor(const QColor &color) |
|
213 | 211 | { |
|
214 | 212 | impl->m_Color = color; |
|
215 | 213 | |
|
216 | 214 | auto brushColor = color; |
|
217 | 215 | brushColor.setAlpha(80); |
|
218 | 216 | setBrush(QBrush(brushColor)); |
|
219 | 217 | setPen(QPen(Qt::NoPen)); |
|
220 | 218 | |
|
221 | 219 | auto selectedBrushColor = brushColor; |
|
222 | 220 | selectedBrushColor.setAlpha(150); |
|
223 | 221 | setSelectedBrush(QBrush(selectedBrushColor)); |
|
224 | 222 | setSelectedPen(QPen(Qt::NoPen)); |
|
225 | 223 | |
|
226 | 224 | auto linePen = QPen(color); |
|
227 | 225 | linePen.setStyle(Qt::SolidLine); |
|
228 | 226 | linePen.setWidth(4); |
|
229 | 227 | |
|
230 | 228 | auto selectedLinePen = linePen; |
|
231 | 229 | selectedLinePen.setColor(color.darker(120)); |
|
232 | 230 | selectedLinePen.setWidth(4); |
|
233 | 231 | |
|
234 | 232 | impl->m_LeftLine->setPen(linePen); |
|
235 | 233 | impl->m_RightLine->setPen(linePen); |
|
236 | 234 | |
|
237 | 235 | impl->m_LeftLine->setSelectedPen(selectedLinePen); |
|
238 | 236 | impl->m_RightLine->setSelectedPen(selectedLinePen); |
|
239 | 237 | } |
|
240 | 238 | |
|
241 | 239 | void VisualizationSelectionZoneItem::setEditionEnabled(bool value) |
|
242 | 240 | { |
|
243 | 241 | impl->m_IsEditionEnabled = value; |
|
244 | 242 | setSelectable(value); |
|
245 | 243 | if (!value) { |
|
246 | 244 | setSelected(false); |
|
247 | 245 | impl->m_CurrentEditionMode = VisualizationSelectionZoneItemPrivate::EditionMode::NoEdition; |
|
248 | 246 | } |
|
249 | 247 | } |
|
250 | 248 | |
|
251 | 249 | bool VisualizationSelectionZoneItem::isEditionEnabled() const |
|
252 | 250 | { |
|
253 | 251 | return impl->m_IsEditionEnabled; |
|
254 | 252 | } |
|
255 | 253 | |
|
256 | 254 | void VisualizationSelectionZoneItem::moveToTop() |
|
257 | 255 | { |
|
258 | 256 | moveToLayer(layer(), false); |
|
259 | 257 | } |
|
260 | 258 | |
|
261 | 259 | Qt::CursorShape |
|
262 | 260 | VisualizationSelectionZoneItem::curshorShapeForPosition(const QPoint &position) const |
|
263 | 261 | { |
|
264 | 262 | auto mode = impl->m_CurrentEditionMode |
|
265 | 263 | == VisualizationSelectionZoneItemPrivate::EditionMode::NoEdition |
|
266 | 264 | ? impl->getEditionMode(position, this) |
|
267 | 265 | : impl->m_CurrentEditionMode; |
|
268 | 266 | switch (mode) { |
|
269 | 267 | case VisualizationSelectionZoneItemPrivate::EditionMode::Move: |
|
270 | 268 | return Qt::SizeAllCursor; |
|
271 | 269 | case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeLeft: |
|
272 | 270 | case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeRight: // fallthrough |
|
273 | 271 | return Qt::SizeHorCursor; |
|
274 | 272 | default: |
|
275 | 273 | return Qt::ArrowCursor; |
|
276 | 274 | } |
|
277 | 275 | } |
|
278 | 276 | |
|
279 | 277 | void VisualizationSelectionZoneItem::setHovered(bool value) |
|
280 | 278 | { |
|
281 | 279 | if (value) { |
|
282 | 280 | auto linePen = impl->m_LeftLine->pen(); |
|
283 | 281 | linePen.setStyle(Qt::DotLine); |
|
284 | 282 | linePen.setWidth(3); |
|
285 | 283 | |
|
286 | 284 | auto selectedLinePen = impl->m_LeftLine->selectedPen(); |
|
287 | 285 | ; |
|
288 | 286 | selectedLinePen.setStyle(Qt::DotLine); |
|
289 | 287 | selectedLinePen.setWidth(3); |
|
290 | 288 | |
|
291 | 289 | impl->m_LeftLine->setPen(linePen); |
|
292 | 290 | impl->m_RightLine->setPen(linePen); |
|
293 | 291 | |
|
294 | 292 | impl->m_LeftLine->setSelectedPen(selectedLinePen); |
|
295 | 293 | impl->m_RightLine->setSelectedPen(selectedLinePen); |
|
296 | 294 | } |
|
297 | 295 | else { |
|
298 | 296 | setColor(impl->m_Color); |
|
299 | 297 | } |
|
300 | 298 | } |
|
301 | 299 | |
|
302 | 300 | void VisualizationSelectionZoneItem::setAssociatedEditedZones( |
|
303 | 301 | const QVector<VisualizationSelectionZoneItem *> &associatedZones) |
|
304 | 302 | { |
|
305 | 303 | impl->m_AssociatedEditedZones = associatedZones; |
|
306 | 304 | impl->m_AssociatedEditedZones.removeAll(this); |
|
307 | 305 | } |
|
308 | 306 | |
|
309 | 307 | bool VisualizationSelectionZoneItem::alignZonesVerticallyOnLeft( |
|
310 | 308 | const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool allowResize) |
|
311 | 309 | { |
|
312 | 310 | return impl->alignZones(this, zonesToAlign, true, allowResize, true); |
|
313 | 311 | } |
|
314 | 312 | |
|
315 | 313 | bool VisualizationSelectionZoneItem::alignZonesVerticallyOnRight( |
|
316 | 314 | const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool allowResize) |
|
317 | 315 | { |
|
318 | 316 | return impl->alignZones(this, zonesToAlign, false, allowResize, true); |
|
319 | 317 | } |
|
320 | 318 | |
|
321 | 319 | bool VisualizationSelectionZoneItem::alignZonesTemporallyOnLeft( |
|
322 | 320 | const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool allowResize) |
|
323 | 321 | { |
|
324 | 322 | return impl->alignZones(this, zonesToAlign, true, allowResize, false); |
|
325 | 323 | } |
|
326 | 324 | |
|
327 | 325 | bool VisualizationSelectionZoneItem::alignZonesTemporallyOnRight( |
|
328 | 326 | const QVector<VisualizationSelectionZoneItem *> &zonesToAlign, bool allowResize) |
|
329 | 327 | { |
|
330 | 328 | return impl->alignZones(this, zonesToAlign, false, allowResize, false); |
|
331 | 329 | } |
|
332 | 330 | |
|
333 | 331 | void VisualizationSelectionZoneItem::mousePressEvent(QMouseEvent *event, const QVariant &details) |
|
334 | 332 | { |
|
335 | 333 | Q_UNUSED(details); |
|
336 | 334 | |
|
337 | 335 | if (isEditionEnabled() && event->button() == Qt::LeftButton) { |
|
338 | 336 | impl->m_CurrentEditionMode = impl->getEditionMode(event->pos(), this); |
|
339 | 337 | |
|
340 | 338 | impl->m_MovedOrinalT1 = impl->m_T1; |
|
341 | 339 | impl->m_MovedOrinalT2 = impl->m_T2; |
|
342 | 340 | for (auto associatedZone : impl->m_AssociatedEditedZones) { |
|
343 | 341 | associatedZone->impl->m_MovedOrinalT1 = associatedZone->impl->m_T1; |
|
344 | 342 | associatedZone->impl->m_MovedOrinalT2 = associatedZone->impl->m_T2; |
|
345 | 343 | } |
|
346 | 344 | } |
|
347 | 345 | else { |
|
348 | 346 | impl->m_CurrentEditionMode = VisualizationSelectionZoneItemPrivate::EditionMode::NoEdition; |
|
349 | 347 | event->ignore(); |
|
350 | 348 | } |
|
351 | 349 | } |
|
352 | 350 | |
|
353 | 351 | void VisualizationSelectionZoneItem::mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) |
|
354 | 352 | { |
|
355 | 353 | if (isEditionEnabled()) { |
|
356 | 354 | if (!selected()) { |
|
357 | 355 | // Force the item to be selected during the edition |
|
358 | 356 | parentGraphWidget()->parentVisualizationWidget()->selectionZoneManager().setSelected( |
|
359 | 357 | this, true); |
|
360 | 358 | } |
|
361 | 359 | |
|
362 | 360 | auto axis = impl->m_Plot->axisRect()->axis(QCPAxis::atBottom); |
|
363 | 361 | auto pixelDiff = event->pos().x() - startPos.x(); |
|
364 | 362 | auto diff = impl->pixelSizeToAxisXSize(pixelDiff); |
|
365 | 363 | |
|
366 | 364 | switch (impl->m_CurrentEditionMode) { |
|
367 | 365 | case VisualizationSelectionZoneItemPrivate::EditionMode::Move: |
|
368 | 366 | setRange(impl->m_MovedOrinalT1 + diff, impl->m_MovedOrinalT2 + diff); |
|
369 | 367 | for (auto associatedZone : impl->m_AssociatedEditedZones) { |
|
370 | 368 | associatedZone->move(pixelDiff); |
|
371 | 369 | } |
|
372 | 370 | break; |
|
373 | 371 | case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeLeft: |
|
374 | 372 | setStart(impl->m_MovedOrinalT1 + diff); |
|
375 | 373 | for (auto associatedZone : impl->m_AssociatedEditedZones) { |
|
376 | 374 | impl->m_MovedOrinalT1 < impl->m_MovedOrinalT2 |
|
377 | 375 | ? associatedZone->resizeLeft(pixelDiff) |
|
378 | 376 | : associatedZone->resizeRight(pixelDiff); |
|
379 | 377 | } |
|
380 | 378 | break; |
|
381 | 379 | case VisualizationSelectionZoneItemPrivate::EditionMode::ResizeRight: |
|
382 | 380 | setEnd(impl->m_MovedOrinalT2 + diff); |
|
383 | 381 | for (auto associatedZone : impl->m_AssociatedEditedZones) { |
|
384 | 382 | impl->m_MovedOrinalT1 < impl->m_MovedOrinalT2 |
|
385 | 383 | ? associatedZone->resizeRight(pixelDiff) |
|
386 | 384 | : associatedZone->resizeLeft(pixelDiff); |
|
387 | 385 | } |
|
388 | 386 | break; |
|
389 | 387 | default: |
|
390 | 388 | break; |
|
391 | 389 | } |
|
392 | 390 | |
|
393 | 391 | for (auto associatedZone : impl->m_AssociatedEditedZones) { |
|
394 | 392 | associatedZone->parentPlot()->replot(); |
|
395 | 393 | } |
|
396 | 394 | } |
|
397 | 395 | else { |
|
398 | 396 | event->ignore(); |
|
399 | 397 | } |
|
400 | 398 | } |
|
401 | 399 | |
|
402 | 400 | void VisualizationSelectionZoneItem::mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) |
|
403 | 401 | { |
|
404 | 402 | Q_UNUSED(startPos); |
|
405 | 403 | |
|
406 | 404 | if (isEditionEnabled()) { |
|
407 | 405 | impl->m_CurrentEditionMode = VisualizationSelectionZoneItemPrivate::EditionMode::NoEdition; |
|
408 | 406 | } |
|
409 | 407 | else { |
|
410 | 408 | event->ignore(); |
|
411 | 409 | } |
|
412 | 410 | |
|
413 | 411 | impl->m_AssociatedEditedZones.clear(); |
|
414 | 412 | } |
|
415 | 413 | |
|
416 | 414 | void VisualizationSelectionZoneItem::resizeLeft(double pixelDiff) |
|
417 | 415 | { |
|
418 | 416 | auto diff = impl->pixelSizeToAxisXSize(pixelDiff); |
|
419 | 417 | if (impl->m_MovedOrinalT1 <= impl->m_MovedOrinalT2) { |
|
420 | 418 | setStart(impl->m_MovedOrinalT1 + diff); |
|
421 | 419 | } |
|
422 | 420 | else { |
|
423 | 421 | setEnd(impl->m_MovedOrinalT2 + diff); |
|
424 | 422 | } |
|
425 | 423 | } |
|
426 | 424 | |
|
427 | 425 | void VisualizationSelectionZoneItem::resizeRight(double pixelDiff) |
|
428 | 426 | { |
|
429 | 427 | auto diff = impl->pixelSizeToAxisXSize(pixelDiff); |
|
430 | 428 | if (impl->m_MovedOrinalT1 > impl->m_MovedOrinalT2) { |
|
431 | 429 | setStart(impl->m_MovedOrinalT1 + diff); |
|
432 | 430 | } |
|
433 | 431 | else { |
|
434 | 432 | setEnd(impl->m_MovedOrinalT2 + diff); |
|
435 | 433 | } |
|
436 | 434 | } |
|
437 | 435 | |
|
438 | 436 | void VisualizationSelectionZoneItem::move(double pixelDiff) |
|
439 | 437 | { |
|
440 | 438 | auto diff = impl->pixelSizeToAxisXSize(pixelDiff); |
|
441 | 439 | setRange(impl->m_MovedOrinalT1 + diff, impl->m_MovedOrinalT2 + diff); |
|
442 | 440 | } |
General Comments 4
Status change > Approved
Status change > Approved
You need to be logged in to leave comments.
Login now