36 |
36 |
37 for (Vertex const& vert : m_drawedVerts) |
37 for (Vertex const& vert : m_drawedVerts) |
38 poly << vert; |
38 poly << vert; |
39 |
39 |
40 // Draw the cursor vertex as the last one in the list. |
40 // Draw the cursor vertex as the last one in the list. |
41 if (poly.size() < 4) |
41 if (length(poly) < 4) |
42 poly << getCursorVertex(); |
42 poly << getCursorVertex(); |
43 |
43 |
44 renderPolygon (painter, poly, true, true); |
44 renderPolygon (painter, poly, true, true); |
45 } |
45 } |
46 |
46 |
65 { |
65 { |
66 // Clean the selection and create the object |
66 // Clean the selection and create the object |
67 QList<Vertex>& verts = m_drawedVerts; |
67 QList<Vertex>& verts = m_drawedVerts; |
68 LDObjectList objs; |
68 LDObjectList objs; |
69 |
69 |
70 switch (verts.size()) |
70 switch (length(verts)) |
71 { |
71 { |
72 case 2: |
72 case 2: |
73 { |
73 { |
74 // 2 verts - make a line |
74 // 2 verts - make a line |
75 LDLine* obj = LDSpawn<LDLine> (verts[0], verts[1]); |
75 LDLine* obj = LDSpawn<LDLine> (verts[0], verts[1]); |
79 } |
79 } |
80 |
80 |
81 case 3: |
81 case 3: |
82 case 4: |
82 case 4: |
83 { |
83 { |
84 LDObject* obj = (verts.size() == 3) ? |
84 LDObject* obj = (length(verts) == 3) ? |
85 static_cast<LDObject*> (LDSpawn<LDTriangle>()) : |
85 static_cast<LDObject*> (LDSpawn<LDTriangle>()) : |
86 static_cast<LDObject*> (LDSpawn<LDQuad>()); |
86 static_cast<LDObject*> (LDSpawn<LDQuad>()); |
87 |
87 |
88 obj->setColor (MainColor); |
88 obj->setColor (MainColor); |
89 |
89 |
90 for (int i = 0; i < verts.size(); ++i) |
90 for (int i = 0; i < length(verts); ++i) |
91 obj->setVertex (i, verts[i]); |
91 obj->setVertex (i, verts[i]); |
92 |
92 |
93 objs << obj; |
93 objs << obj; |
94 break; |
94 break; |
95 } |
95 } |