Sat, 24 Jul 2021 01:50:38 +0300
Move selection logic into select tool
#include <QMessageBox> #include "drawtool.h" DrawTool::DrawTool(QObject* parent) : BaseTool{parent} {} QString DrawTool::name() const { static const QString result = tr("Draw"); return result; } QString DrawTool::toolTip() const { static const QString result = tr("Draw new elements into the model."); return result; } bool DrawTool::mouseClick(const Canvas::MouseClickInfo& info) { if (info.worldPosition.has_value()) { const glm::vec3& pos = info.worldPosition.value(); const auto isCloseToPos = [&](const glm::vec3& x){return geom::isclose(x, pos);}; if (any(this->polygon, isCloseToPos)) { QMessageBox::information(nullptr, "test", "close the polygon"); } else { this->polygon.push_back(pos); auto& previewLayer = info.invoker->modifyPreviewLayer(Canvas::DrawToolPreview).polygons; previewLayer.clear(); previewLayer.push_back({this->polygon}); if (this->polygon.size() == 4) { QMessageBox::information(nullptr, "test", "close the polygon"); } } } return true; } void DrawTool::reset() { this->polygon.clear(); }