| 205 * - v0 and v1 are the line vertices in 3D space. |
205 * - v0 and v1 are the line vertices in 3D space. |
| 206 * - v0p and v1p are the line vertices in 2D space (so that this function does not have to calculate them separately) |
206 * - v0p and v1p are the line vertices in 2D space (so that this function does not have to calculate them separately) |
| 207 */ |
207 */ |
| 208 void AbstractDrawMode::drawLineLength(QPainter &painter, const Vertex &v0, const Vertex &v1, const QPointF& v0p, const QPointF& v1p) const |
208 void AbstractDrawMode::drawLineLength(QPainter &painter, const Vertex &v0, const Vertex &v1, const QPointF& v0p, const QPointF& v1p) const |
| 209 { |
209 { |
| 210 if (not m_config->drawLineLengths()) |
210 if (not config::drawLineLengths()) |
| 211 return; |
211 return; |
| 212 |
212 |
| 213 const QString label = QString::number(abs(v1 - v0), 'f', 2); |
213 const QString label = QString::number(abs(v1 - v0), 'f', 2); |
| 214 QPoint origin = QLineF {v0p, v1p}.pointAt(0.5).toPoint(); |
214 QPoint origin = QLineF {v0p, v1p}.pointAt(0.5).toPoint(); |
| 215 painter.drawText (origin, label); |
215 painter.drawText (origin, label); |
| 254 int prior = (i - 1 >= 0) ? (i - 1) : (countof(polygon3d) - 1); |
254 int prior = (i - 1 >= 0) ? (i - 1) : (countof(polygon3d) - 1); |
| 255 |
255 |
| 256 if (drawLineLengths) |
256 if (drawLineLengths) |
| 257 drawLineLength(painter, polygon3d[i], polygon3d[j], polygon2d[i], polygon2d[j]); |
257 drawLineLength(painter, polygon3d[i], polygon3d[j], polygon2d[i], polygon2d[j]); |
| 258 |
258 |
| 259 if (drawAngles and m_config->drawAngles()) |
259 if (drawAngles and config::drawAngles()) |
| 260 { |
260 { |
| 261 QLineF line0 = {polygon2d[prior], polygon2d[i]}; |
261 QLineF line0 = {polygon2d[prior], polygon2d[i]}; |
| 262 QLineF line1 = {polygon2d[i], polygon2d[j]}; |
262 QLineF line1 = {polygon2d[i], polygon2d[j]}; |
| 263 double angle = 180 - line0.angleTo(line1); |
263 double angle = 180 - line0.angleTo(line1); |
| 264 |
264 |