108 |
108 |
109 } |
109 } |
110 |
110 |
111 // ============================================================================= |
111 // ============================================================================= |
112 str LDComment::getContents () { |
112 str LDComment::getContents () { |
113 return str::mkfmt ("0 %s", zText.chars ()); |
113 return format ("0 %s", zText.chars ()); |
114 } |
114 } |
115 |
115 |
116 str LDSubfile::getContents () { |
116 str LDSubfile::getContents () { |
117 str val = str::mkfmt ("1 %d %s ", dColor, vPosition.getStringRep (false).chars ()); |
117 str val = format ("1 %d %s ", dColor, vPosition.getStringRep (false).chars ()); |
118 val += mMatrix.getStringRep (); |
118 val += mMatrix.getStringRep (); |
119 val += zFileName; |
119 val += zFileName; |
120 return val; |
120 return val; |
121 } |
121 } |
122 |
122 |
123 str LDLine::getContents () { |
123 str LDLine::getContents () { |
124 str val = str::mkfmt ("2 %d", dColor); |
124 str val = format ("2 %d", dColor); |
125 |
125 |
126 for (ushort i = 0; i < 2; ++i) |
126 for (ushort i = 0; i < 2; ++i) |
127 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ()); |
127 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ()); |
128 |
128 |
129 return val; |
129 return val; |
130 } |
130 } |
131 |
131 |
132 str LDTriangle::getContents () { |
132 str LDTriangle::getContents () { |
133 str val = str::mkfmt ("3 %d", dColor); |
133 str val = format ("3 %d", dColor); |
134 |
134 |
135 for (ushort i = 0; i < 3; ++i) |
135 for (ushort i = 0; i < 3; ++i) |
136 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ()); |
136 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ()); |
137 |
137 |
138 return val; |
138 return val; |
139 } |
139 } |
140 |
140 |
141 str LDQuad::getContents () { |
141 str LDQuad::getContents () { |
142 str val = str::mkfmt ("4 %d", dColor); |
142 str val = format ("4 %d", dColor); |
143 |
143 |
144 for (ushort i = 0; i < 4; ++i) |
144 for (ushort i = 0; i < 4; ++i) |
145 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ()); |
145 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ()); |
146 |
146 |
147 return val; |
147 return val; |
148 } |
148 } |
149 |
149 |
150 str LDCondLine::getContents () { |
150 str LDCondLine::getContents () { |
151 str val = str::mkfmt ("5 %d", dColor); |
151 str val = format ("5 %d", dColor); |
152 |
152 |
153 // Add the coordinates |
153 // Add the coordinates |
154 for (ushort i = 0; i < 4; ++i) |
154 for (ushort i = 0; i < 4; ++i) |
155 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ()); |
155 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ()); |
156 |
156 |
180 "NOCERTIFY", |
180 "NOCERTIFY", |
181 "INVERTNEXT", |
181 "INVERTNEXT", |
182 }; |
182 }; |
183 |
183 |
184 str LDBFC::getContents () { |
184 str LDBFC::getContents () { |
185 return str::mkfmt ("0 BFC %s", LDBFC::saStatements[eStatement]); |
185 return format ("0 BFC %s", LDBFC::saStatements[eStatement]); |
186 } |
186 } |
187 |
187 |
188 // ============================================================================= |
188 // ============================================================================= |
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
190 // ============================================================================= |
190 // ============================================================================= |
676 |
676 |
677 // ============================================================================= |
677 // ============================================================================= |
678 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
678 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
679 // ============================================================================= |
679 // ============================================================================= |
680 str LDRadial::getContents () { |
680 str LDRadial::getContents () { |
681 return str::mkfmt ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", |
681 return format ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", |
682 str (radialTypeName()).toupper ().strip (' ').chars (), |
682 str (radialTypeName()).toupper ().strip (' ').chars (), |
683 dColor, dSegments, dDivisions, dRingNum, |
683 dColor, dSegments, dDivisions, dRingNum, |
684 vPosition.getStringRep (false).chars(), mMatrix.getStringRep().chars()); |
684 vPosition.getStringRep (false).chars(), mMatrix.getStringRep().chars()); |
685 } |
685 } |
686 |
686 |
710 dNumerator *= dFactor; |
710 dNumerator *= dFactor; |
711 dDenominator *= dFactor; |
711 dDenominator *= dFactor; |
712 } |
712 } |
713 |
713 |
714 // Compose some general information: prefix, fraction, root, ring number |
714 // Compose some general information: prefix, fraction, root, ring number |
715 str zPrefix = (dDivisions == 16) ? "" : str::mkfmt ("%d/", dDivisions); |
715 str zPrefix = (dDivisions == 16) ? "" : format ("%d/", dDivisions); |
716 str zFrac = str::mkfmt ("%d-%d", dNumerator, dDenominator); |
716 str zFrac = format ("%d-%d", dNumerator, dDenominator); |
717 str zRoot = g_saRadialNameRoots[eRadialType]; |
717 str zRoot = g_saRadialNameRoots[eRadialType]; |
718 str zRingNum = (eRadialType == Ring || eRadialType == Cone) ? str::mkfmt ("%d", dRingNum) : ""; |
718 str zRingNum = (eRadialType == Ring || eRadialType == Cone) ? format ("%d", dRingNum) : ""; |
719 |
719 |
720 // Truncate the root if necessary (7-16rin4.dat for instance). |
720 // Truncate the root if necessary (7-16rin4.dat for instance). |
721 // However, always keep the root at least 2 characters. |
721 // However, always keep the root at least 2 characters. |
722 short dExtra = (~zFrac + ~zRingNum + ~zRoot) - 8; |
722 short dExtra = (~zFrac + ~zRingNum + ~zRoot) - 8; |
723 zRoot -= min<short> (max<short> (dExtra, 0), 2); |
723 zRoot -= min<short> (max<short> (dExtra, 0), 2); |
724 |
724 |
725 // Stick them all together and return the result. |
725 // Stick them all together and return the result. |
726 return str::mkfmt ("%s%s%s%s", zPrefix.chars(), zFrac.chars (), zRoot.chars (), zRingNum.chars ()); |
726 return format ("%s%s%s%s", zPrefix.chars(), zFrac.chars (), zRoot.chars (), zRingNum.chars ()); |
727 } |
727 } |