src/editmodes/drawMode.cpp

changeset 1065
c8ecddbd99e9
parent 1063
1f15c52c11f6
child 1072
9ce9496427f2
equal deleted inserted replaced
1064:4c7a353cf583 1065:c8ecddbd99e9
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 (length(poly) < 4) 41 if (countof(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
49 // If we picked an already-existing vertex, stop drawing 49 // If we picked an already-existing vertex, stop drawing
50 for (Vertex& vert : m_drawedVerts) 50 for (Vertex& vert : m_drawedVerts)
51 { 51 {
52 if (vert == pos) 52 if (vert == pos)
53 { 53 {
54 if (length(m_drawedVerts) >= 2) 54 if (countof(m_drawedVerts) >= 2)
55 endDraw(); 55 endDraw();
56 56
57 return true; 57 return true;
58 } 58 }
59 } 59 }
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 (length(verts)) 70 switch (countof(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 = (length(verts) == 3) ? 84 LDObject* obj = (countof(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 < length(verts); ++i) 90 for (int i = 0; i < countof(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 }

mercurial