src/gldraw.cpp

changeset 553
2418d5955421
parent 551
0efe5dbcef07
equal deleted inserted replaced
552:454f8b730946 553:2418d5955421
25 #include <QTimer> 25 #include <QTimer>
26 #include <GL/glu.h> 26 #include <GL/glu.h>
27 27
28 #include "main.h" 28 #include "main.h"
29 #include "config.h" 29 #include "config.h"
30 #include "file.h" 30 #include "document.h"
31 #include "gldraw.h" 31 #include "gldraw.h"
32 #include "colors.h" 32 #include "colors.h"
33 #include "gui.h" 33 #include "gui.h"
34 #include "misc.h" 34 #include "misc.h"
35 #include "history.h" 35 #include "history.h"
1178 glLineWidth (max<double> (gl_linethickness, 6.5f)); 1178 glLineWidth (max<double> (gl_linethickness, 6.5f));
1179 1179
1180 // Clear the selection if we do not wish to add to it. 1180 // Clear the selection if we do not wish to add to it.
1181 if (!m_addpick) 1181 if (!m_addpick)
1182 { QList<LDObject*> oldsel = selection(); 1182 { QList<LDObject*> oldsel = selection();
1183 LDFile::current()->clearSelection(); 1183 getCurrentDocument()->clearSelection();
1184 1184
1185 for (LDObject* obj : oldsel) 1185 for (LDObject* obj : oldsel)
1186 compileObject (obj); 1186 compileObject (obj);
1187 } 1187 }
1188 1188
1312 // Use the crosshair cursor when drawing. 1312 // Use the crosshair cursor when drawing.
1313 setCursor (Qt::CrossCursor); 1313 setCursor (Qt::CrossCursor);
1314 1314
1315 // Clear the selection when beginning to draw. 1315 // Clear the selection when beginning to draw.
1316 QList<LDObject*> priorsel = selection(); 1316 QList<LDObject*> priorsel = selection();
1317 LDFile::current()->clearSelection(); 1317 getCurrentDocument()->clearSelection();
1318 1318
1319 for (LDObject* obj : priorsel) 1319 for (LDObject* obj : priorsel)
1320 compileObject (obj); 1320 compileObject (obj);
1321 1321
1322 g_win->updateSelection(); 1322 g_win->updateSelection();
1326 1326
1327 g_win->updateEditModeActions(); 1327 g_win->updateEditModeActions();
1328 update(); 1328 update();
1329 } 1329 }
1330 1330
1331 void GLRenderer::setFile (LDFile* const& a) 1331 void GLRenderer::setFile (LDDocument* const& a)
1332 { m_File = a; 1332 { m_File = a;
1333 1333
1334 if (a != null) 1334 if (a != null)
1335 initOverlaysFromObjects(); 1335 initOverlaysFromObjects();
1336 } 1336 }
1409 1409
1410 case ECircleMode: 1410 case ECircleMode:
1411 { const int segs = lores, divs = lores; // TODO: make customizable 1411 { const int segs = lores, divs = lores; // TODO: make customizable
1412 double dist0 = getCircleDrawDist (0), 1412 double dist0 = getCircleDrawDist (0),
1413 dist1 = getCircleDrawDist (1); 1413 dist1 = getCircleDrawDist (1);
1414 LDFile* refFile = null; 1414 LDDocument* refFile = null;
1415 matrix transform; 1415 matrix transform;
1416 bool circleOrDisc = false; 1416 bool circleOrDisc = false;
1417 1417
1418 if (dist1 < dist0) 1418 if (dist1 < dist0)
1419 std::swap<double> (dist0, dist1); 1419 std::swap<double> (dist0, dist1);
1420 1420
1421 if (dist0 == dist1) 1421 if (dist0 == dist1)
1422 { // If the radii are the same, there's no ring space to fill. Use a circle. 1422 { // If the radii are the same, there's no ring space to fill. Use a circle.
1423 refFile = ::getFile ("4-4edge.dat"); 1423 refFile = ::getDocument ("4-4edge.dat");
1424 transform = getCircleDrawMatrix (dist0); 1424 transform = getCircleDrawMatrix (dist0);
1425 circleOrDisc = true; 1425 circleOrDisc = true;
1426 } 1426 }
1427 elif (dist0 == 0 || dist1 == 0) 1427 elif (dist0 == 0 || dist1 == 0)
1428 { // If either radii is 0, use a disc. 1428 { // If either radii is 0, use a disc.
1429 refFile = ::getFile ("4-4disc.dat"); 1429 refFile = ::getDocument ("4-4disc.dat");
1430 transform = getCircleDrawMatrix ((dist0 != 0) ? dist0 : dist1); 1430 transform = getCircleDrawMatrix ((dist0 != 0) ? dist0 : dist1);
1431 circleOrDisc = true; 1431 circleOrDisc = true;
1432 } 1432 }
1433 elif (g_RingFinder (dist0, dist1)) 1433 elif (g_RingFinder (dist0, dist1))
1434 { // The ring finder found a solution, use that. Add the component rings to the file. 1434 { // The ring finder found a solution, use that. Add the component rings to the file.
1435 for (const RingFinder::Component& cmp : g_RingFinder.bestSolution()->getComponents()) 1435 for (const RingFinder::Component& cmp : g_RingFinder.bestSolution()->getComponents())
1436 { // Get a ref file for this primitive. If we cannot find it in the 1436 { // Get a ref file for this primitive. If we cannot find it in the
1437 // LDraw library, generate it. 1437 // LDraw library, generate it.
1438 if ((refFile = ::getFile (radialFileName (::Ring, lores, lores, cmp.num))) == null) 1438 if ((refFile = ::getDocument (radialFileName (::Ring, lores, lores, cmp.num))) == null)
1439 { refFile = generatePrimitive (::Ring, lores, lores, cmp.num); 1439 { refFile = generatePrimitive (::Ring, lores, lores, cmp.num);
1440 refFile->setImplicit (false); 1440 refFile->setImplicit (false);
1441 } 1441 }
1442 1442
1443 LDSubfile* ref = new LDSubfile; 1443 LDSubfile* ref = new LDSubfile;

mercurial