src/linetypes/subfilereference.cpp

changeset 141
185eb297dc1e
parent 140
2f383e88acf4
child 148
e1ced2523cad
--- a/src/linetypes/subfilereference.cpp	Mon Sep 27 21:04:45 2021 +0300
+++ b/src/linetypes/subfilereference.cpp	Tue Sep 28 00:10:29 2021 +0300
@@ -36,13 +36,7 @@
 
 QString ldraw::SubfileReference::textRepresentation() const
 {
-	QString out;
-	if (this->isInverted)
-	{
-		out += "0 BFC INVERTNEXT\r\n";
-	}
-	out += referenceName + " " + utility::vertexToStringParens(this->position());
-	return out;
+	return this->referenceName + " " + utility::vertexToStringParens(this->position());
 }
 
 void ldraw::SubfileReference::getPolygons
@@ -108,3 +102,29 @@
 {
 	return ColoredObject::deserialize(stream) >> this->transformation >> this->referenceName >> this->isInverted;
 }
+
+QString ldraw::SubfileReference::toLDrawCode() const
+{
+	QString result;
+	if (this->isInverted)
+	{
+		result += "0 BFC INVERTNEXT\r\n";
+	}
+	result += utility::format(
+		"1 %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14",
+		this->colorIndex.index,
+		this->transformation[3][0],
+		this->transformation[3][1],
+		this->transformation[3][2],
+		this->transformation[0][0],
+		this->transformation[1][0],
+		this->transformation[2][0],
+		this->transformation[0][1],
+		this->transformation[1][1],
+		this->transformation[2][1],
+		this->transformation[0][2],
+		this->transformation[1][2],
+		this->transformation[2][2],
+		this->referenceName);
+	return result;
+}

mercurial