63 |
63 |
64 void DrawMode::endDraw() |
64 void DrawMode::endDraw() |
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 Model model; |
69 |
69 |
70 switch (countof(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 = model.emplace<LDLine>(verts[0], verts[1]); |
76 obj->setColor (EdgeColor); |
|
77 objs << obj; |
|
78 break; |
76 break; |
79 } |
77 } |
80 |
78 |
81 case 3: |
79 case 3: |
82 case 4: |
80 case 4: |
83 { |
81 { |
84 LDObject* obj = (countof(verts) == 3) ? |
82 LDObject* obj = (countof(verts) == 3) ? |
85 static_cast<LDObject*> (LDSpawn<LDTriangle>()) : |
83 static_cast<LDObject*>(model.emplace<LDTriangle>()) : |
86 static_cast<LDObject*> (LDSpawn<LDQuad>()); |
84 static_cast<LDObject*>(model.emplace<LDQuad>()); |
87 |
|
88 obj->setColor (MainColor); |
|
89 |
85 |
90 for (int i = 0; i < countof(verts); ++i) |
86 for (int i = 0; i < countof(verts); ++i) |
91 obj->setVertex (i, verts[i]); |
87 obj->setVertex (i, verts[i]); |
92 |
88 |
93 objs << obj; |
|
94 break; |
89 break; |
95 } |
90 } |
96 } |
91 } |
97 |
92 |
98 finishDraw (objs); |
93 finishDraw (model); |
99 } |
94 } |