159 return false; |
159 return false; |
160 } |
160 } |
161 |
161 |
162 void AbstractDrawMode::finishDraw (LDObjectList const& objs) |
162 void AbstractDrawMode::finishDraw (LDObjectList const& objs) |
163 { |
163 { |
|
164 int pos = g_win->getInsertionPoint(); |
|
165 |
164 if (objs.size() > 0) |
166 if (objs.size() > 0) |
165 { |
167 { |
166 for (LDObjectPtr obj : objs) |
168 for (LDObjectPtr obj : objs) |
167 { |
169 { |
168 renderer()->document()->addObject (obj); |
170 renderer()->document()->insertObj (pos++, obj); |
169 renderer()->compileObject (obj); |
171 renderer()->compileObject (obj); |
170 } |
172 } |
171 |
173 |
172 g_win->refresh(); |
174 g_win->refresh(); |
173 g_win->endAction(); |
175 g_win->endAction(); |
174 } |
176 } |
175 |
177 |
176 m_drawedVerts.clear(); |
178 m_drawedVerts.clear(); |
|
179 } |
|
180 |
|
181 void AbstractDrawMode::drawLength (QPainter &painter, const Vertex &v0, const Vertex &v1, |
|
182 const QPointF& v0p, const QPointF& v1p) const |
|
183 { |
|
184 if (not cfg::DrawLineLengths) |
|
185 return; |
|
186 |
|
187 const QString label = QString::number ((v1 - v0).length()); |
|
188 QPoint origin = QLineF (v0p, v1p).pointAt (0.5).toPoint(); |
|
189 painter.drawText (origin, label); |
177 } |
190 } |
178 |
191 |
179 void AbstractDrawMode::renderPolygon (QPainter& painter, const QVector<Vertex>& poly3d, |
192 void AbstractDrawMode::renderPolygon (QPainter& painter, const QVector<Vertex>& poly3d, |
180 bool withlengths, bool withangles) const |
193 bool withlengths, bool withangles) const |
181 { |
194 { |
210 for (int i = 0; i < poly3d.size(); ++i) |
223 for (int i = 0; i < poly3d.size(); ++i) |
211 { |
224 { |
212 const int j = (i + 1) % poly3d.size(); |
225 const int j = (i + 1) % poly3d.size(); |
213 const int h = (i - 1 >= 0) ? (i - 1) : (poly3d.size() - 1); |
226 const int h = (i - 1 >= 0) ? (i - 1) : (poly3d.size() - 1); |
214 |
227 |
215 if (withlengths and cfg::DrawLineLengths) |
228 if (withlengths) |
216 { |
229 drawLength (painter, poly3d[i], poly3d[j], poly[i], poly[j]); |
217 const QString label = QString::number ((poly3d[j] - poly3d[i]).length()); |
|
218 QPoint origin = QLineF (poly[i], poly[j]).pointAt (0.5).toPoint(); |
|
219 painter.drawText (origin, label); |
|
220 } |
|
221 |
230 |
222 if (withangles and cfg::DrawAngles) |
231 if (withangles and cfg::DrawAngles) |
223 { |
232 { |
224 QLineF l0 (poly[h], poly[i]), |
233 QLineF l0 (poly[h], poly[i]), |
225 l1 (poly[i], poly[j]); |
234 l1 (poly[i], poly[j]); |