159 { |
159 { |
160 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (object); |
160 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (object); |
161 |
161 |
162 if (mo) |
162 if (mo) |
163 { |
163 { |
164 Vertex position = mo->position(); |
164 QMatrix4x4 matrix = mo->transformationMatrix(); |
165 Matrix matrix = mo->transformationMatrix(); |
165 |
166 |
166 for (int i : {0, 1, 2, 3}) |
167 for (Axis axis : {X, Y, Z}) |
167 for (int j : {0, 1, 2, 3}) |
168 position[axis] = roundToDecimals(position[axis], config::roundPositionPrecision()); |
|
169 |
|
170 for (int i : {0, 1, 2}) |
|
171 for (int j : {0, 1, 2}) |
|
172 matrix(i, j) = roundToDecimals(matrix(i, j), config::roundMatrixPrecision()); |
168 matrix(i, j) = roundToDecimals(matrix(i, j), config::roundMatrixPrecision()); |
173 |
169 |
174 mo->setPosition(position); |
|
175 mo->setTransformationMatrix(matrix); |
170 mo->setTransformationMatrix(matrix); |
176 num += 12; |
171 num += 12; |
177 } |
172 } |
178 else |
173 else |
179 { |
174 { |
264 { |
259 { |
265 Vertex point = object->vertex(i); |
260 Vertex point = object->vertex(i); |
266 fixVertex(point); |
261 fixVertex(point); |
267 object->setVertex(i, point); |
262 object->setVertex(i, point); |
268 } |
263 } |
269 if (object->type() == LDObjectType::SubfileReference) |
264 if (object->hasMatrix()) |
270 { |
265 { |
271 LDSubfileReference* reference = static_cast<LDSubfileReference*>(object); |
266 LDMatrixObject* reference = static_cast<LDMatrixObject*>(object); |
272 Vertex point = reference->position(); |
267 Vertex point = reference->position(); |
273 fixVertex(point); |
268 fixVertex(point); |
274 reference->setPosition(point); |
269 QMatrix4x4 matrix = reference->transformationMatrix(); |
|
270 matrix.setColumn(3, {(float) point.x, (float) point.y, (float) point.z, 1}); |
|
271 reference->setTransformationMatrix(matrix); |
275 } |
272 } |
276 } |
273 } |
277 } |
274 } |
278 } |
275 } |
279 } |
276 } |
605 // main document. |
602 // main document. |
606 for (LDObject* object : selectedObjects().toList()) |
603 for (LDObject* object : selectedObjects().toList()) |
607 currentDocument()->remove(object); |
604 currentDocument()->remove(object); |
608 |
605 |
609 // Add a reference to the new subfile to where the selection was |
606 // Add a reference to the new subfile to where the selection was |
610 currentDocument()->emplaceAt<LDSubfileReference>(referencePosition, subfile->name(), Matrix::identity, Vertex {0, 0, 0}); |
607 currentDocument()->emplaceAt<LDSubfileReference>(referencePosition, subfile->name()); |
611 |
608 |
612 // Refresh stuff |
609 // Refresh stuff |
613 m_window->updateDocumentList(); |
610 m_window->updateDocumentList(); |
614 m_window->doFullRefresh(); |
611 m_window->doFullRefresh(); |
615 } |
612 } |