16 return result; |
16 return result; |
17 } |
17 } |
18 |
18 |
19 bool DrawTool::mouseClick(const Canvas::MouseClickInfo& info) |
19 bool DrawTool::mouseClick(const Canvas::MouseClickInfo& info) |
20 { |
20 { |
21 static_cast<void>(info); |
21 if (info.worldPosition.has_value()) |
22 QMessageBox::information(nullptr, "hleelo", "it works"); |
22 { |
|
23 const glm::vec3& pos = info.worldPosition.value(); |
|
24 const auto isCloseToPos = [&](const glm::vec3& x){return geom::isclose(x, pos);}; |
|
25 if (any(this->polygon, isCloseToPos)) |
|
26 { |
|
27 QMessageBox::information(nullptr, "test", "close the polygon"); |
|
28 } |
|
29 else |
|
30 { |
|
31 this->polygon.push_back(pos); |
|
32 auto& previewLayer = info.invoker->modifyPreviewLayer(Canvas::DrawToolPreview).polygons; |
|
33 previewLayer.clear(); |
|
34 previewLayer.push_back({this->polygon}); |
|
35 if (this->polygon.size() == 4) |
|
36 { |
|
37 QMessageBox::information(nullptr, "test", "close the polygon"); |
|
38 } |
|
39 } |
|
40 } |
23 return true; |
41 return true; |
24 } |
42 } |
|
43 |
|
44 void DrawTool::reset() |
|
45 { |
|
46 this->polygon.clear(); |
|
47 } |