9 PartRenderer{model, documents, colorTable, parent} |
9 PartRenderer{model, documents, colorTable, parent} |
10 { |
10 { |
11 this->setMouseTracking(true); |
11 this->setMouseTracking(true); |
12 } |
12 } |
13 |
13 |
|
14 void Canvas::handleSelectionChange(const QSet<ldraw::Id>& selectedIds, const QSet<ldraw::Id>& deselectedIds) |
|
15 { |
|
16 this->selection.subtract(deselectedIds); |
|
17 this->selection.unite(selectedIds); |
|
18 this->compiler->setSelectedObjects(this->selection); |
|
19 this->update(); |
|
20 } |
|
21 |
14 void Canvas::mouseMoveEvent(QMouseEvent* event) |
22 void Canvas::mouseMoveEvent(QMouseEvent* event) |
15 { |
23 { |
16 const ldraw::Id id = this->pick(event->pos()); |
24 const ldraw::Id id = this->pick(event->pos()); |
17 this->newStatusText("Selected: %1"_q.arg(id.value)); |
25 this->newStatusText("Selected: %1"_q.arg(id.value)); |
18 this->setHighlight(id); |
26 this->highlighted = id; |
|
27 this->totalMouseMove += (event->pos() - this->lastMousePosition).manhattanLength(); |
|
28 this->lastMousePosition = event->pos(); |
19 PartRenderer::mouseMoveEvent(event); |
29 PartRenderer::mouseMoveEvent(event); |
20 } |
30 } |
|
31 |
|
32 void Canvas::mousePressEvent(QMouseEvent* event) |
|
33 { |
|
34 this->totalMouseMove = 0; |
|
35 this->lastMousePosition = event->pos(); |
|
36 PartRenderer::mousePressEvent(event); |
|
37 } |
|
38 |
|
39 void Canvas::mouseReleaseEvent(QMouseEvent* event) |
|
40 { |
|
41 if (this->totalMouseMove < (2.0 / sqrt(2)) * 5.0) |
|
42 { |
|
43 this->selection = {this->highlighted}; |
|
44 this->compiler->setSelectedObjects(this->selection); |
|
45 emit selectionChanged(this->selection); |
|
46 this->update(); |
|
47 } |
|
48 PartRenderer::mouseReleaseEvent(event); |
|
49 } |