29 #include "../grid.h" |
29 #include "../grid.h" |
30 |
30 |
31 CircleMode::CircleMode (GLRenderer* renderer) : |
31 CircleMode::CircleMode (GLRenderer* renderer) : |
32 Super (renderer) {} |
32 Super (renderer) {} |
33 |
33 |
|
34 |
34 EditModeType CircleMode::type() const |
35 EditModeType CircleMode::type() const |
35 { |
36 { |
36 return EditModeType::Circle; |
37 return EditModeType::Circle; |
37 } |
38 } |
|
39 |
38 |
40 |
39 double CircleMode::getCircleDrawDist (int pos) const |
41 double CircleMode::getCircleDrawDist (int pos) const |
40 { |
42 { |
41 if (m_drawedVerts.size() >= pos + 1) |
43 if (m_drawedVerts.size() >= pos + 1) |
42 { |
44 { |
209 angleoffset *= ((2 * pi) / divisions); // convert to radians |
214 angleoffset *= ((2 * pi) / divisions); // convert to radians |
210 angleoffset *= renderer()->depthNegateFactor(); // negate based on camera |
215 angleoffset *= renderer()->depthNegateFactor(); // negate based on camera |
211 return angleoffset; |
216 return angleoffset; |
212 } |
217 } |
213 |
218 |
|
219 |
214 void CircleMode::render (QPainter& painter) const |
220 void CircleMode::render (QPainter& painter) const |
215 { |
221 { |
216 QFontMetrics metrics = QFontMetrics (QFont()); |
222 QFontMetrics metrics = QFontMetrics (QFont()); |
217 |
223 |
218 // If we have not specified the center point of the circle yet, preview it on the screen. |
224 // If we have not specified the center point of the circle yet, preview it on the screen. |
307 painter.drawText (origin.x() - (metrics.width (label) / 2), |
313 painter.drawText (origin.x() - (metrics.width (label) / 2), |
308 origin.y() + metrics.height(), QString::number (outerdistance)); |
314 origin.y() + metrics.height(), QString::number (outerdistance)); |
309 } |
315 } |
310 } |
316 } |
311 |
317 |
312 bool CircleMode::mouseReleased (MouseEventData const& data) |
|
313 { |
|
314 if (Super::mouseReleased (data)) |
|
315 return true; |
|
316 |
|
317 if (data.releasedButtons & Qt::LeftButton) |
|
318 { |
|
319 if (m_drawedVerts.size() < 3) |
|
320 addDrawnVertex (renderer()->position3D()); |
|
321 else |
|
322 buildCircle(); |
|
323 |
|
324 return true; |
|
325 } |
|
326 |
|
327 return false; |
|
328 } |
|
329 |
318 |
330 bool CircleMode::preAddVertex (const Vertex&) |
319 bool CircleMode::preAddVertex (const Vertex&) |
331 { |
320 { |
332 m_angleOffset = getAngleOffset(); |
321 m_angleOffset = getAngleOffset(); |
333 return false; |
322 return false; |
334 } |
323 } |
|
324 |
|
325 |
|
326 int CircleMode::maxVertices() const |
|
327 { |
|
328 return 3; |
|
329 } |