diff -r edc716c1d8e1 -r f895379d7fab src/editmodes/circleMode.cpp --- a/src/editmodes/circleMode.cpp Sun Apr 12 23:02:26 2015 +0300 +++ b/src/editmodes/circleMode.cpp Tue Jul 07 21:35:20 2015 +0300 @@ -37,14 +37,18 @@ double CircleMode::getCircleDrawDist (int pos) const { - assert (m_drawedVerts.size() >= pos + 1); - Vertex v1 = (m_drawedVerts.size() >= pos + 2) ? m_drawedVerts[pos + 1] : - renderer()->coordconv2_3 (renderer()->mousePosition(), false); - Axis localx, localy; - renderer()->getRelativeAxes (localx, localy); - double dx = m_drawedVerts[0][localx] - v1[localx]; - double dy = m_drawedVerts[0][localy] - v1[localy]; - return Grid::Snap (sqrt ((dx * dx) + (dy * dy)), Grid::Coordinate); + if (m_drawedVerts.size() >= pos + 1) + { + Vertex v1 = (m_drawedVerts.size() >= pos + 2) ? m_drawedVerts[pos + 1] : + renderer()->coordconv2_3 (renderer()->mousePosition(), false); + Axis localx, localy; + renderer()->getRelativeAxes (localx, localy); + double dx = m_drawedVerts[0][localx] - v1[localx]; + double dy = m_drawedVerts[0][localy] - v1[localy]; + return Grid::Snap (sqrt ((dx * dx) + (dy * dy)), Grid::Coordinate); + } + + return 0.0; } Matrix CircleMode::getCircleDrawMatrix (double scale) @@ -63,7 +67,7 @@ { if (transform[i] == 2) transform[i] = scale; - elif (transform[i] == 1 and renderer()->camera() >= 3) + else if (transform[i] == 1 and renderer()->camera() >= 3) transform[i] = -1; } @@ -91,14 +95,14 @@ transform = getCircleDrawMatrix (dist0); circleOrDisc = true; } - elif (dist0 == 0 or dist1 == 0) + else if (dist0 == 0 or dist1 == 0) { // If either radii is 0, use a disc. refFile = GetPrimitive (::Disc, segments, divisions, 0); transform = getCircleDrawMatrix ((dist0 != 0) ? dist0 : dist1); circleOrDisc = true; } - elif (g_RingFinder.findRings (dist0, dist1)) + else if (g_RingFinder.findRings (dist0, dist1)) { // The ring finder found a solution, use that. Add the component rings to the file. for (const RingFinder::Component& cmp : g_RingFinder.bestSolution()->getComponents()) @@ -155,7 +159,7 @@ } } - if (circleOrDisc and refFile != null) + if (circleOrDisc and refFile != nullptr) { LDSubfilePtr ref = LDSpawn(); ref->setFileInfo (refFile); @@ -165,13 +169,13 @@ objs << ref; } - unless (objs.isEmpty()) + if (not objs.isEmpty()) { Axis relZ = renderer()->getRelativeZ();; const int l (relZ == X ? 1 : 0); const int m (relZ == Y ? 1 : 0); const int n (relZ == Z ? 1 : 0); - RotateObjects (l, m, n, -m_angleOffset, objs); + rotateObjects (l, m, n, -m_angleOffset, objs); } finishDraw (objs);