src/ui/canvas.cpp

changeset 105
6ca6e8c647d4
parent 104
cd4df75924b7
child 106
128efb9d148b
equal deleted inserted replaced
104:cd4df75924b7 105:6ca6e8c647d4
231 if (intersection.has_value()) 231 if (intersection.has_value())
232 { 232 {
233 renderText(axis.text, *intersection); 233 renderText(axis.text, *intersection);
234 } 234 }
235 } 235 }
236 for (const PreviewLayer& previewLayer : this->previewLayers)
237 {
238 painter.setBrush({previewLayer.color});
239 for (const geom::NPolygon& polygon3d : previewLayer.polygons)
240 {
241 QVector<QPointF> points2d;
242 points2d.reserve(polygon3d.points.size());
243 for (const glm::vec3& point : polygon3d.points)
244 {
245 points2d.push_back(this->modelToScreenCoordinates(point));
246 }
247 painter.drawPolygon({points2d});
248 }
249 }
236 } 250 }
237 } 251 }
238 } 252 }
239 253
240 void Canvas::updateGridMatrix() 254 void Canvas::updateGridMatrix()
270 // If the dot product between these two vectors is 0, the grid normal is perpendicular to the camera vector 284 // If the dot product between these two vectors is 0, the grid normal is perpendicular to the camera vector
271 // and the grid is perpendicular to the screen. 285 // and the grid is perpendicular to the screen.
272 const float dot = glm::dot(glm::normalize(this->gridPlane.normal), glm::normalize(cameraDirection)); 286 const float dot = glm::dot(glm::normalize(this->gridPlane.normal), glm::normalize(cameraDirection));
273 return std::abs(dot) < threshold; 287 return std::abs(dot) < threshold;
274 } 288 }
289
290 const Canvas::PreviewLayer& Canvas::getPreviewLayer(PreviewLayerName name) const
291 {
292 return previewLayers[static_cast<unsigned int>(name)];
293 }
294
295 Canvas::PreviewLayer& Canvas::modifyPreviewLayer(PreviewLayerName name)
296 {
297 return previewLayers[static_cast<unsigned int>(name)];
298 }

mercurial