diff -r dc33f8a707c4 -r 59b6027b9843 src/layers/edittools.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/layers/edittools.h Sun Jun 26 21:00:06 2022 +0300
@@ -0,0 +1,78 @@
+/*
+ * LDForge: LDraw parts authoring CAD
+ * Copyright (C) 2013 - 2020 Teemu Piippo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+#include
+#include
+#include
+#include "model.h"
+#include "vertexmap.h"
+#include "gl/common.h"
+
+enum EditingMode
+{
+ SelectMode,
+ DrawMode,
+ CircleMode
+};
+
+Q_DECLARE_METATYPE(EditingMode)
+
+Q_DECLARE_METATYPE(ModelAction)
+
+class EditTools final : public QObject, public RenderLayer
+{
+ Q_OBJECT
+ std::vector polygon = {{0, 0, 0}};
+ std::size_t numpoints = 1;
+ EditingMode mode = SelectMode;
+ glm::mat4 mvpMatrix;
+ glm::mat4 gridMatrix{1};
+ Plane gridPlane;
+ opt worldPosition;
+ CircleToolOptions circleToolOptions = {
+ .fraction = {16, 16},
+ .type = CircularPrimitive::Circle,
+ };
+public:
+ explicit EditTools(QObject *parent = nullptr);
+ ~EditTools() override;
+ void applyToVertices(VertexMap::ApplyFunction fn) const;
+ const QSet selectedObjects() const;
+ EditingMode currentEditingMode() const;
+ Q_SLOT void setEditMode(EditingMode mode);
+ Q_SLOT void setGridMatrix(const glm::mat4& gridMatrix);
+ Q_SLOT void setCircleToolOptions(const CircleToolOptions& options);
+Q_SIGNALS:
+ void newStatusText(const QString& newStatusText);
+ void modelAction(const ModelAction& action);
+ void select(const QSet& ids, bool retain);
+protected:
+ void mvpMatrixChanged(const glm::mat4& matrix) override;
+ void mouseMoved(const QMouseEvent* event) override;
+ void mouseClick(const QMouseEvent* event) override;
+ void overpaint(QPainter* painter) override;
+private:
+ const std::vector modelActions() const;
+ const std::vector circleModeActions() const;
+ const std::vector drawModeActions() const;
+ void closeShape();
+ void renderPreview(QPainter* painter, const void* pensptr);
+ void removeLastPoint();
+ bool isCloseToExistingPoints() const;
+};