49 painter.drawText((width() - textSize.width()) / 2, height() - textSize.height(), textSize.width(), |
49 painter.drawText((width() - textSize.width()) / 2, height() - textSize.height(), textSize.width(), |
50 textSize.height(), Qt::AlignCenter, text); |
50 textSize.height(), Qt::AlignCenter, text); |
51 } |
51 } |
52 #endif |
52 #endif |
53 |
53 |
54 if (camera() != FreeCamera) |
54 if (camera() != Camera::Free) |
55 { |
55 { |
56 // Paint the coordinates onto the screen. |
56 // Paint the coordinates onto the screen. |
57 QString text = format(tr("X: %1, Y: %2, Z: %3"), m_position3D[X], m_position3D[Y], m_position3D[Z]); |
57 QString text = format(tr("X: %1, Y: %2, Z: %3"), m_position3D[X], m_position3D[Y], m_position3D[Z]); |
58 QFontMetrics metrics {font()}; |
58 QFontMetrics metrics {font()}; |
59 QRect textSize = metrics.boundingRect (0, 0, width(), height(), Qt::AlignCenter, text); |
59 QRect textSize = metrics.boundingRect (0, 0, width(), height(), Qt::AlignCenter, text); |
99 |
99 |
100 delete m_currentEditMode; |
100 delete m_currentEditMode; |
101 m_currentEditMode = AbstractEditMode::createByType(this, a); |
101 m_currentEditMode = AbstractEditMode::createByType(this, a); |
102 |
102 |
103 // If we cannot use the free camera, use the top one instead. |
103 // If we cannot use the free camera, use the top one instead. |
104 if (camera() == FreeCamera and not m_currentEditMode->allowFreeCamera()) |
104 if (camera() == Camera::Free and not m_currentEditMode->allowFreeCamera()) |
105 setCamera(TopCamera); |
105 setCamera(Camera::Top); |
106 |
106 |
107 m_window->updateEditModeActions(); |
107 m_window->updateEditModeActions(); |
108 update(); |
108 update(); |
109 } |
109 } |
110 |
110 |
232 |
232 |
233 // ============================================================================= |
233 // ============================================================================= |
234 // |
234 // |
235 void Canvas::setDepthValue (double depth) |
235 void Canvas::setDepthValue (double depth) |
236 { |
236 { |
237 if (camera() < FreeCamera) |
237 if (camera() < Camera::Free) |
238 m_depthValues[camera()] = depth; |
238 m_depthValues[static_cast<int>(camera())] = depth; |
239 } |
239 } |
240 |
240 |
241 // ============================================================================= |
241 // ============================================================================= |
242 // |
242 // |
243 double Canvas::getDepthValue() const |
243 double Canvas::getDepthValue() const |
244 { |
244 { |
245 if (camera() < FreeCamera) |
245 if (camera() < Camera::Free) |
246 return m_depthValues[camera()]; |
246 return m_depthValues[static_cast<int>(camera())]; |
247 else |
247 else |
248 return 0.0; |
248 return 0.0; |
249 } |
249 } |
250 |
250 |
251 /* |
251 /* |
252 * This converts a 2D point on the screen to a 3D point in the model. If 'snap' is true, the 3D point will snap to the current grid. |
252 * This converts a 2D point on the screen to a 3D point in the model. If 'snap' is true, the 3D point will snap to the current grid. |
253 */ |
253 */ |
254 Vertex Canvas::convert2dTo3d(const QPoint& position2d, bool snap) const |
254 Vertex Canvas::convert2dTo3d(const QPoint& position2d, bool snap) const |
255 { |
255 { |
256 if (camera() == FreeCamera) |
256 if (camera() == Camera::Free) |
257 { |
257 { |
258 return {0, 0, 0}; |
258 return {0, 0, 0}; |
259 } |
259 } |
260 else |
260 else |
261 { |
261 { |