src/editmodes/circleMode.cpp

changeset 1023
9450ac3cd930
parent 1019
a2e4286adb0d
child 1024
67ba0ee049eb
equal deleted inserted replaced
1022:a7f8ce5aa858 1023:9450ac3cd930
24 #include "../ringFinder.h" 24 #include "../ringFinder.h"
25 #include "../primitives.h" 25 #include "../primitives.h"
26 #include "../glRenderer.h" 26 #include "../glRenderer.h"
27 #include "../mainwindow.h" 27 #include "../mainwindow.h"
28 #include "../ldObjectMath.h" 28 #include "../ldObjectMath.h"
29 #include "../grid.h"
29 30
30 CircleMode::CircleMode (GLRenderer* renderer) : 31 CircleMode::CircleMode (GLRenderer* renderer) :
31 Super (renderer) {} 32 Super (renderer) {}
32 33
33 EditModeType CircleMode::type() const 34 EditModeType CircleMode::type() const
37 38
38 double CircleMode::getCircleDrawDist (int pos) const 39 double CircleMode::getCircleDrawDist (int pos) const
39 { 40 {
40 if (m_drawedVerts.size() >= pos + 1) 41 if (m_drawedVerts.size() >= pos + 1)
41 { 42 {
42 Vertex v1 = (m_drawedVerts.size() >= pos + 2) ? m_drawedVerts[pos + 1] : 43 Vertex v1;
43 renderer()->convert2dTo3d (renderer()->mousePosition(), false); 44
45 if (m_drawedVerts.size() >= pos + 2)
46 v1 = m_drawedVerts[pos + 1];
47 else
48 v1 = renderer()->convert2dTo3d (renderer()->mousePosition(), false);
49
44 Axis localx, localy; 50 Axis localx, localy;
45 renderer()->getRelativeAxes (localx, localy); 51 renderer()->getRelativeAxes (localx, localy);
46 double dx = m_drawedVerts[0][localx] - v1[localx]; 52 double dx = m_drawedVerts[0][localx] - v1[localx];
47 double dy = m_drawedVerts[0][localy] - v1[localy]; 53 double dy = m_drawedVerts[0][localy] - v1[localy];
48 return snapToGrid (sqrt ((dx * dx) + (dy * dy)), Grid::Coordinate); 54 return grid()->snap(hypot(dx, dy), Grid::Coordinate);
49 } 55 }
50 56
51 return 0.0; 57 return 0.0;
52 } 58 }
53 59

mercurial