108 |
108 |
109 } |
109 } |
110 |
110 |
111 // ============================================================================= |
111 // ============================================================================= |
112 str LDComment::getContents () { |
112 str LDComment::getContents () { |
113 return format ("0 %s", zText.chars ()); |
113 return fmt ("0 %s", zText.chars ()); |
114 } |
114 } |
115 |
115 |
116 str LDSubfile::getContents () { |
116 str LDSubfile::getContents () { |
117 str val = format ("1 %d %s ", dColor, vPosition.stringRep (false).chars ()); |
117 str val = fmt ("1 %d %s ", dColor, vPosition.stringRep (false).chars ()); |
118 val += mMatrix.stringRep (); |
118 val += mMatrix.stringRep (); |
119 val += ' '; |
119 val += ' '; |
120 val += zFileName; |
120 val += zFileName; |
121 return val; |
121 return val; |
122 } |
122 } |
123 |
123 |
124 str LDLine::getContents () { |
124 str LDLine::getContents () { |
125 str val = format ("2 %d", dColor); |
125 str val = fmt ("2 %d", dColor); |
126 |
126 |
127 for (ushort i = 0; i < 2; ++i) |
127 for (ushort i = 0; i < 2; ++i) |
128 val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
128 val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
129 |
129 |
130 return val; |
130 return val; |
131 } |
131 } |
132 |
132 |
133 str LDTriangle::getContents () { |
133 str LDTriangle::getContents () { |
134 str val = format ("3 %d", dColor); |
134 str val = fmt ("3 %d", dColor); |
135 |
135 |
136 for (ushort i = 0; i < 3; ++i) |
136 for (ushort i = 0; i < 3; ++i) |
137 val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
137 val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
138 |
138 |
139 return val; |
139 return val; |
140 } |
140 } |
141 |
141 |
142 str LDQuad::getContents () { |
142 str LDQuad::getContents () { |
143 str val = format ("4 %d", dColor); |
143 str val = fmt ("4 %d", dColor); |
144 |
144 |
145 for (ushort i = 0; i < 4; ++i) |
145 for (ushort i = 0; i < 4; ++i) |
146 val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
146 val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
147 |
147 |
148 return val; |
148 return val; |
149 } |
149 } |
150 |
150 |
151 str LDCondLine::getContents () { |
151 str LDCondLine::getContents () { |
152 str val = format ("5 %d", dColor); |
152 str val = fmt ("5 %d", dColor); |
153 |
153 |
154 // Add the coordinates |
154 // Add the coordinates |
155 for (ushort i = 0; i < 4; ++i) |
155 for (ushort i = 0; i < 4; ++i) |
156 val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
156 val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
157 |
157 |
181 "NOCERTIFY", |
181 "NOCERTIFY", |
182 "INVERTNEXT", |
182 "INVERTNEXT", |
183 }; |
183 }; |
184 |
184 |
185 str LDBFC::getContents () { |
185 str LDBFC::getContents () { |
186 return format ("0 BFC %s", LDBFC::saStatements[eStatement]); |
186 return fmt ("0 BFC %s", LDBFC::saStatements[eStatement]); |
187 } |
187 } |
188 |
188 |
189 // ============================================================================= |
189 // ============================================================================= |
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
191 // ============================================================================= |
191 // ============================================================================= |
658 |
658 |
659 // ============================================================================= |
659 // ============================================================================= |
660 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
660 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
661 // ============================================================================= |
661 // ============================================================================= |
662 str LDRadial::getContents () { |
662 str LDRadial::getContents () { |
663 return format ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", |
663 return fmt ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", |
664 str (radialTypeName()).toupper ().strip (' ').chars (), |
664 str (radialTypeName()).toupper ().strip (' ').chars (), |
665 dColor, dSegments, dDivisions, dRingNum, |
665 dColor, dSegments, dDivisions, dRingNum, |
666 vPosition.stringRep (false).chars(), mMatrix.stringRep().chars()); |
666 vPosition.stringRep (false).chars(), mMatrix.stringRep().chars()); |
667 } |
667 } |
668 |
668 |
692 dNumerator *= dFactor; |
692 dNumerator *= dFactor; |
693 dDenominator *= dFactor; |
693 dDenominator *= dFactor; |
694 } |
694 } |
695 |
695 |
696 // Compose some general information: prefix, fraction, root, ring number |
696 // Compose some general information: prefix, fraction, root, ring number |
697 str zPrefix = (dDivisions == 16) ? "" : format ("%d/", dDivisions); |
697 str zPrefix = (dDivisions == 16) ? "" : fmt ("%d/", dDivisions); |
698 str zFrac = format ("%d-%d", dNumerator, dDenominator); |
698 str zFrac = fmt ("%d-%d", dNumerator, dDenominator); |
699 str zRoot = g_saRadialNameRoots[eRadialType]; |
699 str zRoot = g_saRadialNameRoots[eRadialType]; |
700 str zRingNum = (eRadialType == Ring || eRadialType == Cone) ? format ("%d", dRingNum) : ""; |
700 str zRingNum = (eRadialType == Ring || eRadialType == Cone) ? fmt ("%d", dRingNum) : ""; |
701 |
701 |
702 // Truncate the root if necessary (7-16rin4.dat for instance). |
702 // Truncate the root if necessary (7-16rin4.dat for instance). |
703 // However, always keep the root at least 2 characters. |
703 // However, always keep the root at least 2 characters. |
704 short dExtra = (~zFrac + ~zRingNum + ~zRoot) - 8; |
704 short dExtra = (~zFrac + ~zRingNum + ~zRoot) - 8; |
705 zRoot -= min<short> (max<short> (dExtra, 0), 2); |
705 zRoot -= min<short> (max<short> (dExtra, 0), 2); |
706 |
706 |
707 // Stick them all together and return the result. |
707 // Stick them all together and return the result. |
708 return format ("%s%s%s%s", zPrefix.chars(), zFrac.chars (), zRoot.chars (), zRingNum.chars ()); |
708 return fmt ("%s%s%s%s", zPrefix.chars(), zFrac.chars (), zRoot.chars (), zRingNum.chars ()); |
709 } |
709 } |
710 |
710 |
711 // ============================================================================= |
711 // ============================================================================= |
712 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
712 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
713 // ============================================================================= |
713 // ============================================================================= |