src/tools/drawtool.cpp

changeset 168
24590af32ad6
parent 164
8305e2f968fb
child 185
a38a0eb007b0
--- a/src/tools/drawtool.cpp	Sat Mar 05 15:40:43 2022 +0200
+++ b/src/tools/drawtool.cpp	Sat Mar 05 16:57:28 2022 +0200
@@ -8,9 +8,10 @@
 
 static const QBrush pointBrush = {Qt::white};
 static const QPen polygonPen = {QBrush{Qt::black}, 2.0, Qt::DashLine};
+static const QPen badPolygonPen = {QBrush{Qt::red}, 2.0, Qt::DashLine};
 static const QPen pointPen = {QBrush{Qt::black}, 2.0};
-static const QBrush polygonBrush = {QColor{64, 255, 128, 192}};
-static const QBrush badPolygonBrush = {QColor{255, 96, 96, 192}};
+static const QBrush greenPolygonBrush = {QColor{64, 255, 128, 192}};
+static const QBrush redPolygonBrush = {QColor{255, 96, 96, 192}};
 
 DrawTool::DrawTool(Document* document) :
 	BaseTool{document}
@@ -114,10 +115,17 @@
 
 void DrawTool::overpaint(Canvas* canvas, QPainter* painter) const
 {
-	painter->setBrush(this->isconcave ? ::badPolygonBrush : ::polygonBrush);
-	painter->setPen(::polygonPen);
-	if (this->previewPolygon.size() > 2)
+	painter->setPen(this->isconcave ? ::badPolygonPen : ::polygonPen);
+	if (this->previewPolygon.size() > 2 and not this->isconcave)
 	{
+		if (canvas->worldPolygonWinding(this->previewPolygon) == Winding::Clockwise)
+		{
+			painter->setBrush(::greenPolygonBrush);
+		}
+		else
+		{
+			painter->setBrush(::redPolygonBrush);
+		}
 		canvas->drawWorldPolygon(painter, this->previewPolygon);
 	}
 	else

mercurial