src/ldtypes.cpp

changeset 504
6a1fa662bfc1
parent 503
bebe09014dd6
child 506
525f6c48db83
equal deleted inserted replaced
503:bebe09014dd6 504:6a1fa662bfc1
28 cfg (String, ld_defaultname, ""); 28 cfg (String, ld_defaultname, "");
29 cfg (String, ld_defaultuser, ""); 29 cfg (String, ld_defaultuser, "");
30 cfg (Int, ld_defaultlicense, 0); 30 cfg (Int, ld_defaultlicense, 0);
31 31
32 // List of all LDObjects 32 // List of all LDObjects
33 List<LDObject*> g_LDObjects; 33 QList<LDObject*> g_LDObjects;
34 34
35 // ============================================================================= 35 // =============================================================================
36 // LDObject constructors 36 // LDObject constructors
37 // ----------------------------------------------------------------------------- 37 // -----------------------------------------------------------------------------
38 LDObject::LDObject() : 38 LDObject::LDObject() :
190 { return fmt ("0 BFC %1", LDBFC::statements[type]); 190 { return fmt ("0 BFC %1", LDBFC::statements[type]);
191 } 191 }
192 192
193 // ============================================================================= 193 // =============================================================================
194 // ----------------------------------------------------------------------------- 194 // -----------------------------------------------------------------------------
195 List<LDTriangle*> LDQuad::splitToTriangles() 195 QList<LDTriangle*> LDQuad::splitToTriangles()
196 { // Create the two triangles based on this quadrilateral: 196 { // Create the two triangles based on this quadrilateral:
197 // 0---3 0---3 3 197 // 0---3 0---3 3
198 // | | | / /| 198 // | | | / /|
199 // | | ==> | / / | 199 // | | ==> | / / |
200 // | | |/ / | 200 // | | |/ / |
204 204
205 // The triangles also inherit the quad's color 205 // The triangles also inherit the quad's color
206 tri1->setColor (color()); 206 tri1->setColor (color());
207 tri2->setColor (color()); 207 tri2->setColor (color());
208 208
209 List<LDTriangle*> triangles; 209 QList<LDTriangle*> triangles;
210 triangles << tri1; 210 triangles << tri1;
211 triangles << tri2; 211 triangles << tri2;
212 return triangles; 212 return triangles;
213 } 213 }
214 214
298 obj->setColor (parentcolor); 298 obj->setColor (parentcolor);
299 } 299 }
300 300
301 // ============================================================================= 301 // =============================================================================
302 // ----------------------------------------------------------------------------- 302 // -----------------------------------------------------------------------------
303 List<LDObject*> LDSubfile::inlineContents (InlineFlags flags) 303 QList<LDObject*> LDSubfile::inlineContents (InlineFlags flags)
304 { List<LDObject*> objs = fileInfo()->inlineContents (flags); 304 { QList<LDObject*> objs = fileInfo()->inlineContents (flags);
305 305
306 // Transform the objects 306 // Transform the objects
307 for (LDObject * obj : objs) 307 for (LDObject * obj : objs)
308 { // Set the parent now so we know what inlined this. 308 { // Set the parent now so we know what inlined this.
309 obj->setParent (this); 309 obj->setParent (this);
328 return -1; 328 return -1;
329 } 329 }
330 330
331 // ============================================================================= 331 // =============================================================================
332 // ----------------------------------------------------------------------------- 332 // -----------------------------------------------------------------------------
333 void LDObject::moveObjects (List<LDObject*> objs, const bool up) 333 void LDObject::moveObjects (QList<LDObject*> objs, const bool up)
334 { if (objs.size() == 0) 334 { if (objs.size() == 0)
335 return; 335 return;
336 336
337 // If we move down, we need to iterate the array in reverse order. 337 // If we move down, we need to iterate the array in reverse order.
338 const long start = up ? 0 : (objs.size() - 1); 338 const long start = up ? 0 : (objs.size() - 1);
339 const long end = up ? objs.size() : -1; 339 const long end = up ? objs.size() : -1;
340 const long incr = up ? 1 : -1; 340 const long incr = up ? 1 : -1;
341 List<LDObject*> objsToCompile; 341 QList<LDObject*> objsToCompile;
342 LDFile* file = objs[0]->file(); 342 LDFile* file = objs[0]->file();
343 343
344 for (long i = start; i != end; i += incr) 344 for (long i = start; i != end; i += incr)
345 { LDObject* obj = objs[i]; 345 { LDObject* obj = objs[i];
346 346
378 return name; 378 return name;
379 } 379 }
380 380
381 // ============================================================================= 381 // =============================================================================
382 // ----------------------------------------------------------------------------- 382 // -----------------------------------------------------------------------------
383 str LDObject::objectListContents (const List<LDObject*>& objs) 383 str LDObject::objectListContents (const QList<LDObject*>& objs)
384 { bool firstDetails = true; 384 { bool firstDetails = true;
385 str text = ""; 385 str text = "";
386 386
387 if (objs.size() == 0) 387 if (objs.size() == 0)
388 return "nothing"; // :) 388 return "nothing"; // :)

mercurial