src/tools/circletool.cpp

changeset 191
d355d4c52d51
parent 190
3dbdc243f053
child 192
e6faeffed1d1
--- a/src/tools/circletool.cpp	Wed May 25 13:49:45 2022 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-#include "circletool.h"
-#include "document.h"
-
-CircleTool::CircleTool(Document *document) :
-	AbstractDrawTool{document}
-{
-}
-
-QString CircleTool::name() const
-{
-	return tr("Circle");
-}
-
-QString CircleTool::toolTip() const
-{
-	return tr("Draw circular primitives like circles or discs");
-}
-
-std::vector<glm::vec3> circle(int divisions)
-{
-	std::vector<glm::vec3> points;
-	points.reserve(divisions + 1);
-	for (int i = 0; i <= divisions; ++i) {
-		float ang = i * 2.0f * glm::pi<float>() / divisions;
-		points.push_back({std::sin(ang), std::cos(ang), 0.0f});
-	}
-	return points;
-}
-
-void CircleTool::overpaint(Canvas *canvas, QPainter *painter) const
-{
-	if (this->previewPolygon.size() >= 2)
-	{
-		for (int i : {0, 1}) {
-			canvas->drawWorldPoint(painter, this->previewPolygon[i]);
-		}
-		painter->setPen(QPen{Qt::green, 2, Qt::DashLine, Qt::RoundCap, Qt::MiterJoin});
-		canvas->drawWorldPolyline(painter, {this->previewPolygon[0], this->previewPolygon[1]});
-		const float size = glm::distance(this->previewPolygon[1], this->previewPolygon[0]);
-		glm::mat4 matrix = size * this->baseGridMatrix;
-		matrix[3] = {this->previewPolygon[0], 1};
-		std::vector<glm::vec3> points = circle(16);
-		for (std::size_t i = 0; i < points.size(); ++i) {
-			points[i] = matrix * glm::vec4{points[i], 1.0f};
-		}
-		painter->setPen(QPen{Qt::black, 2, Qt::DashLine, Qt::RoundCap, Qt::MiterJoin});
-		canvas->drawWorldPolyline(painter, points);
-	}
-	if (this->previewPolygon.size() >= 3)
-	{
-
-	}
-}
-
-QString CircleTool::iconName() const
-{
-	return ":/icons/linetype-circularprimitive.png";
-}
-
-void CircleTool::addPoint(const glm::vec3 &pos)
-{
-	AbstractDrawTool::addPoint(pos);
-	if (this->polygon.size() >= 2)
-	{
-		const glm::mat4& grid = this->document->currentGrid();
-		const glm::mat4 newGrid = {grid[1], grid[2], grid[0], {this->polygon[0], 1}};
-		Q_EMIT this->desiredGridChange(newGrid);
-	}
-}
-
-void CircleTool::closeShape()
-{
-	
-}
-
-void CircleTool::reset()
-{
-	this->baseGridMatrix = this->document->currentGrid();
-}

mercurial