src/primitives.h

changeset 665
4355e72ffd47
parent 504
6a1fa662bfc1
child 538
2f85d4d286e5
equal deleted inserted replaced
664:e3a32a79a10a 665:4355e72ffd47
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19 #ifndef PRIMITIVES_H 19 #ifndef LDFORGE_PRIMITIVES_H
20 #define PRIMITIVES_H 20 #define LDFORGE_PRIMITIVES_H
21 21
22 #include "common.h" 22 #include "common.h"
23 #include "types.h" 23 #include "types.h"
24 #include <QRegExp> 24 #include <QRegExp>
25 #include <QDialog> 25 #include <QDialog>
26 26
27 class LDFile;
27 class Ui_MakePrimUI; 28 class Ui_MakePrimUI;
28 class PrimitiveCategory; 29 class PrimitiveCategory;
29 struct Primitive { 30 struct Primitive
30 str name, title; 31 { str name, title;
31 PrimitiveCategory* cat; 32 PrimitiveCategory* cat;
32 }; 33 };
33 34
34 class PrimitiveCategory { 35 class PrimitiveCategory
35 PROPERTY (str, name, setName) 36 { PROPERTY (str, name, setName)
36 37
37 public: 38 public:
38 enum Type { 39 enum Type
39 Filename, 40 { Filename,
40 Title 41 Title
41 }; 42 };
42 43
43 struct RegexEntry { 44 struct RegexEntry
44 QRegExp regex; 45 { QRegExp regex;
45 Type type; 46 Type type;
46 }; 47 };
47 48
48 typedef List<RegexEntry>::it it; 49 QList<RegexEntry> regexes;
49 typedef List<RegexEntry>::c_it c_it; 50 QList<Primitive> prims;
50 51 static QList<Primitive> uncat;
51 List<RegexEntry> regexes;
52 List<Primitive> prims;
53 static List<Primitive> uncat;
54 }; 52 };
55 53
56 // ============================================================================= 54 // =============================================================================
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
58 // ============================================================================= 56 // =============================================================================
59 // PrimitiveLister 57 // PrimitiveLister
60 // 58 //
61 // Worker object that scans the primitives folder for primitives and 59 // Worker object that scans the primitives folder for primitives and
62 // builds an index of them. 60 // builds an index of them.
63 // ============================================================================= 61 // =============================================================================
64 class PrimitiveLister : public QObject { 62 class PrimitiveLister : public QObject
65 Q_OBJECT 63 { Q_OBJECT
66 64
67 public: 65 public:
68 static void start(); 66 static void start();
69 67
70 public slots: 68 public slots:
71 void work(); 69 void work();
72 70
73 signals: 71 signals:
74 void starting (ulong num); 72 void starting (int num);
75 void workDone(); 73 void workDone();
76 void update (ulong i); 74 void update (int i);
77 75
78 private: 76 private:
79 List<Primitive> m_prims; 77 QList<Primitive> m_prims;
80 }; 78 };
81 79
82 extern List<PrimitiveCategory> g_PrimitiveCategories; 80 extern QList<PrimitiveCategory> g_PrimitiveCategories;
83 81
84 void loadPrimitives(); 82 void loadPrimitives();
85 bool primitiveLoaderBusy(); 83 bool primitiveLoaderBusy();
86 84
87 enum PrimitiveType 85 enum PrimitiveType
88 { 86 { Circle,
89 Circle,
90 Cylinder, 87 Cylinder,
91 Disc, 88 Disc,
92 DiscNeg, 89 DiscNeg,
93 Ring, 90 Ring,
94 Cone, 91 Cone,
95 }; 92 };
96 93
97 // ============================================================================= 94 // =============================================================================
98 class PrimitivePrompt : public QDialog { 95 class PrimitivePrompt : public QDialog
99 Q_OBJECT 96 { Q_OBJECT
100 97
101 public: 98 public:
102 explicit PrimitivePrompt (QWidget* parent = null, Qt::WindowFlags f = 0); 99 explicit PrimitivePrompt (QWidget* parent = null, Qt::WindowFlags f = 0);
103 virtual ~PrimitivePrompt(); 100 virtual ~PrimitivePrompt();
104 Ui_MakePrimUI* ui; 101 Ui_MakePrimUI* ui;
105 102
106 public slots: 103 public slots:
107 void hiResToggled (bool on); 104 void hiResToggled (bool on);
108 }; 105 };
109 106
110 void generatePrimitive(); 107 void makeCircle (int segs, int divs, double radius, QList<QLineF>& lines);
108 LDFile* generatePrimitive (PrimitiveType type, int segs, int divs, int num);
111 109
112 #endif // PRIMITIVES_H 110 // Gets a primitive by the given specs. If the primitive cannot be found, it will
111 // be automatically generated.
112 LDFile* getPrimitive (PrimitiveType type, int segs, int divs, int num);
113
114 str radialFileName (PrimitiveType type, int segs, int divs, int num);
115
116 #endif // LDFORGE_PRIMITIVES_H

mercurial