168 namespace { |
168 namespace { |
169 struct Pens |
169 struct Pens |
170 { |
170 { |
171 const QBrush pointBrush; |
171 const QBrush pointBrush; |
172 const QPen pointPen; |
172 const QPen pointPen; |
|
173 const QPen textPen; |
173 const QPen polygonPen; |
174 const QPen polygonPen; |
174 const QPen badPolygonPen; |
175 const QPen badPolygonPen; |
175 const QBrush greenPolygonBrush; |
176 const QBrush greenPolygonBrush; |
176 const QBrush redPolygonBrush; |
177 const QBrush redPolygonBrush; |
177 }; |
178 }; |
178 } |
179 } |
179 |
180 |
180 static const Pens brightPens{ |
181 static const Pens brightPens{ |
181 .pointBrush = {Qt::white}, |
182 .pointBrush = {Qt::black}, |
182 .pointPen = {QBrush{Qt::black}, 2.0}, |
183 .pointPen = {QBrush{Qt::black}, 2.0}, |
|
184 .textPen = {Qt::black}, |
183 .polygonPen = {QBrush{Qt::black}, 2.0, Qt::DashLine}, |
185 .polygonPen = {QBrush{Qt::black}, 2.0, Qt::DashLine}, |
184 .greenPolygonBrush = {QColor{64, 255, 128, 192}}, |
186 .greenPolygonBrush = {QColor{64, 255, 128, 192}}, |
185 .redPolygonBrush = {QColor{255, 96, 96, 192}}, |
187 .redPolygonBrush = {QColor{255, 96, 96, 192}}, |
186 }; |
188 }; |
187 |
189 |
188 static const Pens darkPens{ |
190 static const Pens darkPens{ |
189 .pointBrush = {Qt::black}, |
191 .pointBrush = {Qt::white}, |
190 .pointPen = {QBrush{Qt::white}, 2.0}, |
192 .pointPen = {QBrush{Qt::white}, 2.0}, |
|
193 .textPen = {Qt::white}, |
191 .polygonPen = {QBrush{Qt::white}, 2.0, Qt::DashLine}, |
194 .polygonPen = {QBrush{Qt::white}, 2.0, Qt::DashLine}, |
192 .greenPolygonBrush = {QColor{64, 255, 128, 192}}, |
195 .greenPolygonBrush = {QColor{64, 255, 128, 192}}, |
193 .redPolygonBrush = {QColor{255, 96, 96, 192}}, |
196 .redPolygonBrush = {QColor{255, 96, 96, 192}}, |
194 }; |
197 }; |
195 |
198 |
196 void EditTools::overpaint(QPainter* painter) |
199 void EditTools::overpaint(QPainter* painter) |
197 { |
200 { |
|
201 painter->save(); |
198 const Pens& pens = (this->renderer->isDark() ? darkPens : brightPens); |
202 const Pens& pens = (this->renderer->isDark() ? darkPens : brightPens); |
199 this->renderPreview(painter, &pens); |
203 this->renderPreview(painter, &pens); |
|
204 QFont font; |
|
205 font.setBold(true); |
200 if (this->worldPosition.has_value()) |
206 if (this->worldPosition.has_value()) |
201 { |
207 { |
202 painter->setRenderHint(QPainter::Antialiasing); |
208 painter->setRenderHint(QPainter::Antialiasing); |
203 painter->setPen(Qt::white); |
209 painter->setPen(pens.pointPen); |
204 painter->setBrush(Qt::green); |
210 painter->setBrush(pens.greenPolygonBrush); |
205 const QPointF pos = this->renderer->modelToScreenCoordinates(*this->worldPosition); |
211 const QPointF pos = this->renderer->modelToScreenCoordinates(*this->worldPosition); |
206 painter->drawEllipse(pos, 5, 5); |
212 painter->drawEllipse(pos, 5, 5); |
207 painter->drawText(pos + QPointF{5, 5}, vectorToString(*this->worldPosition)); |
213 drawBorderedText(painter, pos + QPointF{5, 5}, font, vectorToString(*this->worldPosition)); |
208 } |
214 } |
|
215 painter->restore(); |
209 } |
216 } |
210 |
217 |
211 const std::vector<ModelAction> EditTools::modelActions() const |
218 const std::vector<ModelAction> EditTools::modelActions() const |
212 { |
219 { |
213 switch(this->mode) { |
220 switch(this->mode) { |