src/canvas.cpp

changeset 1369
1e2391b78d17
parent 1368
36105978da93
child 1376
83dd6cbd7f1a
equal deleted inserted replaced
1368:36105978da93 1369:1e2391b78d17
84 { 84 {
85 // Find the top left corner of the grid 85 // Find the top left corner of the grid
86 Vertex topLeft = currentCamera().idealize(currentCamera().convert2dTo3d({0, 0})); 86 Vertex topLeft = currentCamera().idealize(currentCamera().convert2dTo3d({0, 0}));
87 Vertex bottomRight = currentCamera().idealize(currentCamera().convert2dTo3d({width(), height()})); 87 Vertex bottomRight = currentCamera().idealize(currentCamera().convert2dTo3d({width(), height()}));
88 qreal gridSize = grid()->coordinateSnap(); 88 qreal gridSize = grid()->coordinateSnap();
89 // glEnable(GL_LINE_STIPPLE); 89 glEnable(GL_LINE_STIPPLE);
90 glBegin(GL_LINES); 90 glBegin(GL_LINES);
91 91
92 switch (grid()->type()) 92 switch (grid()->type())
93 { 93 {
94 case Grid::Cartesian: 94 case Grid::Cartesian:
95 { 95 {
96 qreal x0 = sign(topLeft.x) * (fabs(topLeft.x) - fmod(fabs(topLeft.x), gridSize)); 96 qreal x0 = sign(topLeft.x) * (abs(topLeft.x) - fmod(abs(topLeft.x), gridSize));
97 qreal y0 = sign(topLeft.y) * (fabs(topLeft.y) - fmod(fabs(topLeft.y), gridSize)); 97 qreal y0 = sign(topLeft.y) * (abs(topLeft.y) - fmod(abs(topLeft.y), gridSize));
98 98
99 static const auto prepareGridLine = [](qreal value) -> bool 99 static const auto prepareGridLine = [](qreal value) -> bool
100 { 100 {
101 if (not isZero(value)) 101 if (not isZero(value))
102 { 102 {
196 break; 196 break;
197 } 197 }
198 198
199 glEnd(); 199 glEnd();
200 glDisable(GL_LINE_STIPPLE); 200 glDisable(GL_LINE_STIPPLE);
201
202 if (this->camera() < Camera::Free)
203 {
204 GLfloat cullz = this->cullValues[static_cast<int>(this->camera())];
205 GLRotationMatrix matrix = {
206 1, 0, 0, cullz,
207 0, 1, 0, 0,
208 0, 0, 1, 0,
209 0, 0, 0, 1,
210 };
211 glMultMatrixf(matrix);
212 }
201 } 213 }
202 214
203 bool Canvas::freeCameraAllowed() const 215 bool Canvas::freeCameraAllowed() const
204 { 216 {
205 return m_currentEditMode->allowFreeCamera(); 217 return m_currentEditMode->allowFreeCamera();
374 /* 386 /*
375 if (m_window and event->source() == m_window->getPrimitivesTree() and m_window->getPrimitivesTree()->currentItem()) 387 if (m_window and event->source() == m_window->getPrimitivesTree() and m_window->getPrimitivesTree()->currentItem())
376 event->acceptProposedAction(); 388 event->acceptProposedAction();
377 */ 389 */
378 } 390 }
391
392 double Canvas::currentCullValue() const
393 {
394 if (this->camera() < Camera::Free)
395 return far - this->cullValues[static_cast<int>(this->camera())];
396 else
397 return 0.0;
398 }
399
400 void Canvas::setCullValue(double value)
401 {
402 if (this->camera() < Camera::Free)
403 this->cullValues[static_cast<int>(this->camera())] = far - value;
404 }
405
406 void Canvas::clearCurrentCullValue()
407 {
408 if (this->camera() < Camera::Free)
409 this->cullValues[static_cast<int>(this->camera())] = 0.0;
410 }

mercurial