src/editmodes/abstractEditMode.cc

changeset 866
4951b737f8cb
parent 861
83426c5fa732
child 874
ba75c789667e
equal deleted inserted replaced
865:6d68840fcb26 866:4951b737f8cb
172 } 172 }
173 173
174 m_drawedVerts.clear(); 174 m_drawedVerts.clear();
175 } 175 }
176 176
177 void AbstractDrawMode::renderPolygon (QPainter& painter, const QVector<Vertex>& poly3d, bool withangles) const 177 void AbstractDrawMode::renderPolygon (QPainter& painter, const QVector<Vertex>& poly3d,
178 bool withlengths, bool withangles) const
178 { 179 {
179 QVector<QPoint> poly (poly3d.size()); 180 QVector<QPoint> poly (poly3d.size());
180 QFontMetrics metrics = QFontMetrics (QFont()); 181 QFontMetrics metrics = QFontMetrics (QFont());
181 182
182 // Convert to 2D 183 // Convert to 2D
198 painter.setPen (renderer()->textPen()); 199 painter.setPen (renderer()->textPen());
199 painter.drawText (blip.x(), blip.y() - 8, poly3d[i].toString (true)); 200 painter.drawText (blip.x(), blip.y() - 8, poly3d[i].toString (true));
200 } 201 }
201 202
202 // Draw line lenghts and angle info if appropriate 203 // Draw line lenghts and angle info if appropriate
203 if (poly3d.size() >= 2) 204 if (poly3d.size() >= 2 and (withlengths or withangles))
204 { 205 {
205 painter.setPen (renderer()->textPen()); 206 painter.setPen (renderer()->textPen());
206 207
207 for (int i = 0; i < poly3d.size(); ++i) 208 for (int i = 0; i < poly3d.size(); ++i)
208 { 209 {
209 const int j = (i + 1) % poly3d.size(); 210 const int j = (i + 1) % poly3d.size();
210 const int h = (i - 1 >= 0) ? (i - 1) : (poly3d.size() - 1); 211 const int h = (i - 1 >= 0) ? (i - 1) : (poly3d.size() - 1);
211 212
212 if (cfg::DrawLineLengths) 213 if (withlengths and cfg::DrawLineLengths)
213 { 214 {
214 const QString label = QString::number ((poly3d[j] - poly3d[i]).length()); 215 const QString label = QString::number ((poly3d[j] - poly3d[i]).length());
215 QPoint origin = QLineF (poly[i], poly[j]).pointAt (0.5).toPoint(); 216 QPoint origin = QLineF (poly[i], poly[j]).pointAt (0.5).toPoint();
216 painter.drawText (origin, label); 217 painter.drawText (origin, label);
217 } 218 }

mercurial