35 { |
35 { |
36 renderPolygon (painter, (m_drawedVerts.size() > 0) ? m_rectangleVerts : |
36 renderPolygon (painter, (m_drawedVerts.size() > 0) ? m_rectangleVerts : |
37 QVector<Vertex> ({renderer()->position3D()}), true, false); |
37 QVector<Vertex> ({renderer()->position3D()}), true, false); |
38 } |
38 } |
39 |
39 |
40 bool RectangleMode::mouseReleased (MouseEventData const& data) |
40 void RectangleMode::endDraw() |
41 { |
41 { |
42 if (Super::mouseReleased (data)) |
42 if (m_drawedVerts.size() == 2) |
43 return true; |
43 { |
|
44 LDQuad* quad = LDSpawn<LDQuad>(); |
|
45 updateRectVerts(); |
44 |
46 |
45 if (data.releasedButtons & Qt::LeftButton) |
47 for (int i = 0; i < quad->numVertices(); ++i) |
46 { |
48 quad->setVertex (i, m_rectangleVerts[i]); |
47 if (m_drawedVerts.size() == 2) |
|
48 { |
|
49 LDQuad* quad (LDSpawn<LDQuad>()); |
|
50 updateRectVerts(); |
|
51 |
49 |
52 for (int i = 0; i < quad->numVertices(); ++i) |
50 quad->setColor (MainColor); |
53 quad->setVertex (i, m_rectangleVerts[i]); |
51 finishDraw (LDObjectList ({quad})); |
54 |
|
55 quad->setColor (MainColor); |
|
56 finishDraw (LDObjectList ({quad})); |
|
57 return true; |
|
58 } |
|
59 |
|
60 addDrawnVertex (renderer()->position3D()); |
|
61 return true; |
|
62 } |
52 } |
63 |
|
64 return false; |
|
65 } |
53 } |
66 |
54 |
67 // |
55 // |
68 // Update rect vertices when the mouse moves since the 3d position likely has changed |
56 // Update rect vertices when the mouse moves since the 3d position likely has changed |
69 // |
57 // |