33 void DrawMode::render (QPainter& painter) const |
33 void DrawMode::render (QPainter& painter) const |
34 { |
34 { |
35 QVector<Vertex> poly; |
35 QVector<Vertex> poly; |
36 QFontMetrics metrics = QFontMetrics (QFont()); |
36 QFontMetrics metrics = QFontMetrics (QFont()); |
37 |
37 |
38 for (Vertex const& vert : _drawedVerts) |
38 for (Vertex const& vert : m_drawedVerts) |
39 poly << vert; |
39 poly << vert; |
40 |
40 |
41 // Draw the cursor vertex as the last one in the list. |
41 // Draw the cursor vertex as the last one in the list. |
42 if (poly.size() < 4) |
42 if (poly.size() < 4) |
43 poly << renderer()->position3D(); |
43 poly << renderer()->position3D(); |
82 } |
82 } |
83 |
83 |
84 void DrawMode::endDraw() |
84 void DrawMode::endDraw() |
85 { |
85 { |
86 // Clean the selection and create the object |
86 // Clean the selection and create the object |
87 QList<Vertex>& verts = _drawedVerts; |
87 QList<Vertex>& verts = m_drawedVerts; |
88 LDObjectList objs; |
88 LDObjectList objs; |
89 |
89 |
90 switch (verts.size()) |
90 switch (verts.size()) |
91 { |
91 { |
92 case 1: |
92 case 1: |
93 { |
93 { |
94 // 1 vertex - add a vertex object |
94 // 1 vertex - add a vertex object |
95 LDVertexPtr obj = spawn<LDVertex>(); |
95 LDVertexPtr obj = LDSpawn<LDVertex>(); |
96 obj->pos = verts[0]; |
96 obj->pos = verts[0]; |
97 obj->setColor (maincolor()); |
97 obj->setColor (MainColor()); |
98 objs << obj; |
98 objs << obj; |
99 break; |
99 break; |
100 } |
100 } |
101 |
101 |
102 case 2: |
102 case 2: |
103 { |
103 { |
104 // 2 verts - make a line |
104 // 2 verts - make a line |
105 LDLinePtr obj = spawn<LDLine> (verts[0], verts[1]); |
105 LDLinePtr obj = LDSpawn<LDLine> (verts[0], verts[1]); |
106 obj->setColor (edgecolor()); |
106 obj->setColor (EdgeColor()); |
107 objs << obj; |
107 objs << obj; |
108 break; |
108 break; |
109 } |
109 } |
110 |
110 |
111 case 3: |
111 case 3: |
112 case 4: |
112 case 4: |
113 { |
113 { |
114 LDObjectPtr obj = (verts.size() == 3) ? |
114 LDObjectPtr obj = (verts.size() == 3) ? |
115 static_cast<LDObjectPtr> (spawn<LDTriangle>()) : |
115 static_cast<LDObjectPtr> (LDSpawn<LDTriangle>()) : |
116 static_cast<LDObjectPtr> (spawn<LDQuad>()); |
116 static_cast<LDObjectPtr> (LDSpawn<LDQuad>()); |
117 |
117 |
118 obj->setColor (maincolor()); |
118 obj->setColor (MainColor()); |
119 |
119 |
120 for (int i = 0; i < verts.size(); ++i) |
120 for (int i = 0; i < verts.size(); ++i) |
121 obj->setVertex (i, verts[i]); |
121 obj->setVertex (i, verts[i]); |
122 |
122 |
123 objs << obj; |
123 objs << obj; |