26 #include "ui_makeprim.h" |
26 #include "ui_makeprim.h" |
27 #include "misc.h" |
27 #include "misc.h" |
28 #include "colors.h" |
28 #include "colors.h" |
29 #include "moc_primitives.cpp" |
29 #include "moc_primitives.cpp" |
30 |
30 |
31 List<PrimitiveCategory> g_PrimitiveCategories; |
31 QList<PrimitiveCategory> g_PrimitiveCategories; |
32 List<Primitive> g_primitives; |
32 QList<Primitive> g_primitives; |
33 static PrimitiveLister* g_activePrimLister = null; |
33 static PrimitiveLister* g_activePrimLister = null; |
34 static bool g_primListerMutex = false; |
34 static bool g_primListerMutex = false; |
35 static const str g_Other = PrimitiveLister::tr ("Other"); |
35 static const str g_Other = PrimitiveLister::tr ("Other"); |
36 |
36 |
37 static const str g_radialNameRoots[] = |
37 static const str g_radialNameRoots[] = |
77 } |
77 } |
78 } |
78 } |
79 |
79 |
80 // ============================================================================= |
80 // ============================================================================= |
81 // ----------------------------------------------------------------------------- |
81 // ----------------------------------------------------------------------------- |
82 static void recursiveGetFilenames (QDir dir, List<str>& fnames) |
82 static void recursiveGetFilenames (QDir dir, QList<str>& fnames) |
83 { QFileInfoList flist = dir.entryInfoList(); |
83 { QFileInfoList flist = dir.entryInfoList(); |
84 |
84 |
85 for (const QFileInfo & info : flist) |
85 for (const QFileInfo & info : flist) |
86 { if (info.fileName() == "." || info.fileName() == "..") |
86 { if (info.fileName() == "." || info.fileName() == "..") |
87 continue; // skip . and .. |
87 continue; // skip . and .. |
100 m_prims.clear(); |
100 m_prims.clear(); |
101 |
101 |
102 QDir dir (LDPaths::prims()); |
102 QDir dir (LDPaths::prims()); |
103 int baselen = dir.absolutePath().length(); |
103 int baselen = dir.absolutePath().length(); |
104 int i = 0; |
104 int i = 0; |
105 List<str> fnames; |
105 QList<str> fnames; |
106 |
106 |
107 assert (dir.exists()); |
107 assert (dir.exists()); |
108 recursiveGetFilenames (dir, fnames); |
108 recursiveGetFilenames (dir, fnames); |
109 emit starting (fnames.size()); |
109 emit starting (fnames.size()); |
110 |
110 |
298 { return (*func) ( (i * 2 * pi) / divs); |
298 { return (*func) ( (i * 2 * pi) / divs); |
299 } |
299 } |
300 |
300 |
301 // ============================================================================= |
301 // ============================================================================= |
302 // ----------------------------------------------------------------------------- |
302 // ----------------------------------------------------------------------------- |
303 void makeCircle (int segs, int divs, double radius, List<QLineF>& lines) |
303 void makeCircle (int segs, int divs, double radius, QList<QLineF>& lines) |
304 { for (int i = 0; i < segs; ++i) |
304 { for (int i = 0; i < segs; ++i) |
305 { double x0 = radius * radialPoint (i, divs, cos), |
305 { double x0 = radius * radialPoint (i, divs, cos), |
306 x1 = radius * radialPoint (i + 1, divs, cos), |
306 x1 = radius * radialPoint (i + 1, divs, cos), |
307 z0 = radius * radialPoint (i, divs, sin), |
307 z0 = radius * radialPoint (i, divs, sin), |
308 z1 = radius * radialPoint (i + 1, divs, sin); |
308 z1 = radius * radialPoint (i + 1, divs, sin); |
311 } |
311 } |
312 } |
312 } |
313 |
313 |
314 // ============================================================================= |
314 // ============================================================================= |
315 // ----------------------------------------------------------------------------- |
315 // ----------------------------------------------------------------------------- |
316 List<LDObject*> makePrimitive (PrimitiveType type, int segs, int divs, int num) |
316 QList<LDObject*> makePrimitive (PrimitiveType type, int segs, int divs, int num) |
317 { List<LDObject*> objs; |
317 { QList<LDObject*> objs; |
318 List<int> condLineSegs; |
318 QList<int> condLineSegs; |
319 List<QLineF> circle; |
319 QList<QLineF> circle; |
320 |
320 |
321 makeCircle (segs, divs, 1, circle); |
321 makeCircle (segs, divs, 1, circle); |
322 |
322 |
323 for (int i = 0; i < segs; ++i) |
323 for (int i = 0; i < segs; ++i) |
324 { double x0 = circle[i].x1(), |
324 { double x0 = circle[i].x1(), |