147 return ""; |
147 return ""; |
148 } |
148 } |
149 |
149 |
150 // ============================================================================= |
150 // ============================================================================= |
151 // |
151 // |
152 void ExtProgramToolset::writeObjects (const LDObjectList& objects, QFile& f) |
152 void ExtProgramToolset::writeObjects (const QVector<LDObject*>& objects, QFile& f) |
153 { |
153 { |
154 for (LDObject* obj : objects) |
154 for (LDObject* obj : objects) |
155 { |
155 { |
156 if (obj->type() == LDObjectType::SubfileReference) |
156 if (obj->type() == LDObjectType::SubfileReference) |
157 { |
157 { |
158 LDSubfileReference* ref = static_cast<LDSubfileReference*> (obj); |
158 LDSubfileReference* ref = static_cast<LDSubfileReference*> (obj); |
159 Model model {m_documents}; |
159 Model model {m_documents}; |
160 ref->inlineContents(model, true, false); |
160 ref->inlineContents(model, true, false); |
161 writeObjects(model.objects().toList(), f); |
161 writeObjects(model.objects(), f); |
162 } |
162 } |
163 else if (obj->type() == LDObjectType::BezierCurve) |
163 else if (obj->type() == LDObjectType::BezierCurve) |
164 { |
164 { |
165 LDBezierCurve* curve = static_cast<LDBezierCurve*> (obj); |
165 LDBezierCurve* curve = static_cast<LDBezierCurve*> (obj); |
166 Model model {m_documents}; |
166 Model model {m_documents}; |
167 curve->rasterize(model, grid()->bezierCurveSegments()); |
167 curve->rasterize(model, grid()->bezierCurveSegments()); |
168 writeObjects(model.objects().toList(), f); |
168 writeObjects(model.objects(), f); |
169 } |
169 } |
170 else |
170 else |
171 f.write ((obj->asText() + "\r\n").toUtf8()); |
171 f.write ((obj->asText() + "\r\n").toUtf8()); |
172 } |
172 } |
173 } |
173 } |
174 |
174 |
175 // ============================================================================= |
175 // ============================================================================= |
176 // |
176 // |
177 void ExtProgramToolset::writeObjects (const LDObjectList& objects, QString filename) |
177 void ExtProgramToolset::writeObjects (const QVector<LDObject*>& objects, QString filename) |
178 { |
178 { |
179 // Write the input file |
179 // Write the input file |
180 QFile f (filename); |
180 QFile f (filename); |
181 |
181 |
182 if (not f.open (QIODevice::WriteOnly | QIODevice::Text)) |
182 if (not f.open (QIODevice::WriteOnly | QIODevice::Text)) |
196 |
196 |
197 // ============================================================================= |
197 // ============================================================================= |
198 // |
198 // |
199 void ExtProgramToolset::writeSelection (QString fname) |
199 void ExtProgramToolset::writeSelection (QString fname) |
200 { |
200 { |
201 writeObjects (selectedObjects().toList(), fname); |
201 writeObjects(selectedObjects().toList().toVector(), fname); |
202 } |
202 } |
203 |
203 |
204 // ============================================================================= |
204 // ============================================================================= |
205 // |
205 // |
206 void ExtProgramToolset::writeColorGroup (LDColor color, QString fname) |
206 void ExtProgramToolset::writeColorGroup (LDColor color, QString fname) |
207 { |
207 { |
208 LDObjectList objects; |
208 QVector<LDObject*> objects; |
209 |
209 |
210 for (LDObject* obj : currentDocument()->objects()) |
210 for (LDObject* obj : currentDocument()->objects()) |
211 { |
211 { |
212 if (not obj->isColored() or obj->color() != color) |
212 if (not obj->isColored() or obj->color() != color) |
213 continue; |
213 continue; |