src/ldtypes.h

changeset 667
31540c1f22ea
parent 618
de0d51349f6c
equal deleted inserted replaced
666:c595cfb4791c 667:31540c1f22ea
1 /* 1 /*
2 * LDForge: LDraw parts authoring CAD 2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 Santeri Piippo 3 * Copyright (C) 2013, 2014 Santeri Piippo
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or 7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
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 LDTYPES_H 19 #ifndef LDFORGE_LDTYPES_H
20 #define LDTYPES_H 20 #define LDFORGE_LDTYPES_H
21 21
22 #include "common.h" 22 #include "main.h"
23 #include "types.h" 23 #include "types.h"
24 24 #include "misc/documentPointer.h"
25 #define LDOBJ(T) \ 25
26 public: \ 26 #define LDOBJ(T) \
27 virtual ~LD##T() {} \ 27 protected: \
28 virtual LDObject::Type getType() const override { \ 28 virtual LD##T* clone() override \
29 return LDObject::T; \ 29 { \
30 } \ 30 return new LD##T (*this); \
31 virtual str raw(); \ 31 } \
32 virtual LD##T* clone() { \ 32 \
33 return new LD##T (*this); \ 33 public: \
34 } \ 34 virtual LDObject::Type getType() const override \
35 virtual void move (vertex where); \ 35 { \
36 virtual void invert(); 36 return LDObject::E##T; \
37 37 } \
38 #define LDOBJ_NAME(N) virtual str typeName() const override { return #N; } 38 virtual QString raw() const override; \
39 #define LDOBJ_VERTICES(V) virtual short vertices() const override { return V; } 39 virtual void invert() override;
40
41 #define LDOBJ_NAME(N) virtual QString getTypeName() const override { return #N; }
42 #define LDOBJ_VERTICES(V) virtual int vertices() const override { return V; }
40 #define LDOBJ_SETCOLORED(V) virtual bool isColored() const override { return V; } 43 #define LDOBJ_SETCOLORED(V) virtual bool isColored() const override { return V; }
41 #define LDOBJ_COLORED LDOBJ_SETCOLORED (true) 44 #define LDOBJ_COLORED LDOBJ_SETCOLORED (true)
42 #define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false) 45 #define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false)
43 46
44 #define LDOBJ_CUSTOM_SCEMANTIC virtual bool isScemantic() const override 47 #define LDOBJ_CUSTOM_SCEMANTIC virtual bool isScemantic() const override
49 #define LDOBJ_HAS_MATRIX LDOBJ_SETMATRIX (true) 52 #define LDOBJ_HAS_MATRIX LDOBJ_SETMATRIX (true)
50 #define LDOBJ_NO_MATRIX LDOBJ_SETMATRIX (false) 53 #define LDOBJ_NO_MATRIX LDOBJ_SETMATRIX (false)
51 54
52 class QListWidgetItem; 55 class QListWidgetItem;
53 class LDSubfile; 56 class LDSubfile;
54 class LDFile; 57 class LDDocument;
55 class LDSharedVertex; 58 class LDSharedVertex;
56 59
57 // ============================================================================= 60 // =============================================================================
58 // LDObject 61 // LDObject
59 // 62 //
61 // in the LDraw code file. The virtual method getType returns an enumerator 64 // in the LDraw code file. The virtual method getType returns an enumerator
62 // which is a token of the object's type. The object can be casted into 65 // which is a token of the object's type. The object can be casted into
63 // sub-classes based on this enumerator. 66 // sub-classes based on this enumerator.
64 // ============================================================================= 67 // =============================================================================
65 class LDObject 68 class LDObject
66 { PROPERTY (bool, hidden, setHidden) 69 {
67 PROPERTY (bool, selected, setSelected) 70 PROPERTY (public, bool, Hidden, BOOL_OPS, STOCK_WRITE)
68 PROPERTY (LDObject*, parent, setParent) 71 PROPERTY (public, bool, Selected, BOOL_OPS, STOCK_WRITE)
69 PROPERTY (LDFile*, file, setFile) 72 PROPERTY (public, LDObject*, Parent, NO_OPS, STOCK_WRITE)
70 READ_PROPERTY (int32, id, setID) 73 PROPERTY (public, LDDocument*, File, NO_OPS, STOCK_WRITE) // TODO: rename~
71 DECLARE_PROPERTY (short, color, setColor) 74 PROPERTY (private, int, ID, NUM_OPS, STOCK_WRITE)
72 75 PROPERTY (public, int, Color, NUM_OPS, CUSTOM_WRITE)
73 public: 76 PROPERTY (public, bool, GLInit, BOOL_OPS, STOCK_WRITE)
74 // Object type codes. Codes are sorted in order of significance. 77
78 public:
79 // Object type codes.
75 enum Type 80 enum Type
76 { Subfile, // Object represents a sub-file reference 81 {
77 Quad, // Object represents a quadrilateral 82 ESubfile, // Object represents a sub-file reference
78 Triangle, // Object represents a triangle 83 EQuad, // Object represents a quadrilateral
79 Line, // Object represents a line 84 ETriangle, // Object represents a triangle
80 CndLine, // Object represents a conditional line 85 ELine, // Object represents a line
81 Vertex, // Object is a vertex, LDForge extension object 86 ECondLine, // Object represents a conditional line
82 BFC, // Object represents a BFC statement 87 EVertex, // Object is a vertex, LDForge extension object
83 Overlay, // Object contains meta-info about an overlay image. 88 EBFC, // Object represents a BFC statement
84 Comment, // Object represents a comment 89 EOverlay, // Object contains meta-info about an overlay image.
85 Error, // Object is the result of failed parsing 90 EComment, // Object represents a comment
86 Empty, // Object represents an empty line 91 EError, // Object is the result of failed parsing
87 Unidentified, // Object is an uninitialized (SHOULD NEVER HAPPEN) 92 EEmpty, // Object represents an empty line
88 NumTypes // Amount of object types 93 EUnidentified, // Unknown object type (some functions return this; TODO: they probably should not)
94 ENumTypes // Amount of object types
89 }; 95 };
90 96
91 LDObject(); 97 LDObject();
92 virtual ~LDObject(); 98
93 99 // Makes a copy of this object
94 virtual LDObject* clone() 100 LDObject* createCopy() const;
95 { return 0; // Creates a new LDObject identical to this one. 101
96 } 102 // Deletes this object
97 long getIndex() const; // Index (i.e. line number) of this object 103 void deleteSelf();
98 virtual LDObject::Type getType() const; // Type enumerator of this object 104
99 const vertex& getVertex (int i) const; // Get a vertex by index 105 // Index (i.e. line number) of this object
100 virtual bool hasMatrix() const; // Does this object have a matrix and position? (see LDMatrixObject) 106 long getIndex() const;
101 virtual void invert(); // Inverts this object (winding is reversed) 107
102 virtual bool isColored() const; // Is this object colored? 108 // Type enumerator of this object
103 virtual bool isScemantic() const; // Does this object have meaning in the part model? 109 virtual Type getType() const = 0;
104 virtual void move (vertex vect); // Moves this object using the given vertex as a movement List 110
105 LDObject* next() const; // Object after this in the current file 111 // Get a vertex by index
106 LDObject* prev() const; // Object prior to this in the current file 112 const Vertex& getVertex (int i) const;
107 virtual str raw() { return ""; } // This object as LDraw code 113
108 void replace (LDObject* other); // Replace this LDObject with another LDObject. Object is deleted in the process. 114 // Type name of this object
109 void select(); 115 virtual QString getTypeName() const = 0;
110 void setVertex (int i, const vertex& vert); // Set a vertex to the given value 116
111 void setVertexCoord (int i, Axis ax, double value); // Set a single coordinate of a vertex 117 // Does this object have a matrix and position? (see LDMatrixObject)
112 void swap (LDObject* other); // Swap this object with another. 118 virtual bool hasMatrix() const = 0;
113 LDObject* topLevelParent(); // What object in the current file ultimately references this? 119
114 virtual str typeName() const; // Type name of this object 120 // Inverts this object (winding is reversed)
115 void unselect(); 121 virtual void invert() = 0;
116 virtual short vertices() const; // Number of vertices this object has 122
117 123 // Is this object colored?
118 static str typeName (LDObject::Type type); // Get type name by enumerator 124 virtual bool isColored() const = 0;
119 static LDObject* getDefault (const LDObject::Type type); // Returns a sample object by the given enumerator 125
120 static void moveObjects (QList<LDObject*> objs, const bool up); // TODO: move this to LDFile? 126 // Does this object have meaning in the part model?
121 static str objectListContents (const QList<LDObject*>& objs); // Get a description of a list of LDObjects 127 virtual bool isScemantic() const = 0;
128
129 // Moves this object using the given vertex as a movement List
130 void move (Vertex vect);
131
132 // Object after this in the current file
133 LDObject* next() const;
134
135 // Object prior to this in the current file
136 LDObject* prev() const;
137
138 // This object as LDraw code
139 virtual QString raw() const = 0;
140
141 // Replace this LDObject with another LDObject. Object is deleted in the process.
142 void replace (LDObject* other);
143
144 // Selects this object.
145 void select();
146
147 // Set a vertex to the given value
148 void setVertex (int i, const Vertex& vert);
149
150 // Set a single coordinate of a vertex
151 void setVertexCoord (int i, Axis ax, double value);
152
153 // Swap this object with another.
154 void swap (LDObject* other);
155
156 // What object in the current file ultimately references this?
157 LDObject* topLevelParent();
158
159 // Removes this object from selection // TODO: rename to deselect?
160 void unselect();
161
162 // Number of vertices this object has // TODO: rename to getNumVertices
163 virtual int vertices() const = 0;
164
165 // Get type name by enumerator
166 static QString typeName (LDObject::Type type);
167
168 // Returns a default-constructed LDObject by the given type
169 static LDObject* getDefault (const LDObject::Type type);
170
171 // TODO: move this to LDDocument?
172 static void moveObjects (LDObjectList objs, const bool up);
173
174 // Get a description of a list of LDObjects
175 static QString describeObjects (const LDObjectList& objs);
122 static LDObject* fromID (int id); 176 static LDObject* fromID (int id);
123 177
124 // TODO: make these private! 178 // TODO: make these private!
125 // OpenGL list for this object 179 // OpenGL list for this object
126 uint glLists[4]; 180 uint glLists[4];
127 181
128 // Object list entry for this object 182 // Object list entry for this object
129 QListWidgetItem* qObjListEntry; 183 QListWidgetItem* qObjListEntry;
130 184
131 protected: 185 protected:
132 bool m_glinit; 186 // LDObjects are to be deleted with the deleteSelf() method, not with
133 friend class GLRenderer; 187 // operator delete. This is because it seems virtual functions cannot
188 // be properly called from the destructor, thus a normal method must
189 // be used instead. The destructor also doesn't seem to be able to
190 // be private without causing a truckload of problems so it's protected
191 // instead.
192 virtual ~LDObject();
193 void chooseID();
134 194
135 private: 195 private:
136 LDSharedVertex* m_coords[4]; 196 virtual LDObject* clone() = 0;
197 LDSharedVertex* m_coords[4];
137 }; 198 };
138 199
139 // ============================================================================= 200 // =============================================================================
140 // LDSharedVertex 201 // LDSharedVertex
141 // 202 //
142 // For use as coordinates of LDObjects. Keeps count of references. 203 // For use as coordinates of LDObjects. Keeps count of references.
143 // ----------------------------------------------------------------------------- 204 // -----------------------------------------------------------------------------
144 class LDSharedVertex 205 class LDSharedVertex
145 { public: 206 {
146 inline const vertex& data() const 207 public:
147 { return m_data; 208 inline const Vertex& data() const
209 {
210 return m_data;
148 } 211 }
149 212
150 inline operator const vertex&() const 213 inline operator const Vertex&() const
151 { return m_data; 214 {
215 return m_data;
152 } 216 }
153 217
154 void addRef (LDObject* a); 218 void addRef (LDObject* a);
155 void delRef (LDObject* a); 219 void delRef (LDObject* a);
156 220
157 static LDSharedVertex* getSharedVertex (const vertex& a); 221 static LDSharedVertex* getSharedVertex (const Vertex& a);
158 222
159 protected: 223 protected:
160 LDSharedVertex (const vertex& a) : m_data (a) {} 224 LDSharedVertex (const Vertex& a) : m_data (a) {}
161 225
162 private: 226 private:
163 QList<LDObject*> m_refs; 227 LDObjectList m_refs;
164 vertex m_data; 228 Vertex m_data;
165 }; 229 };
166 230
167 // ============================================================================= 231 // =============================================================================
168 // LDMatrixObject 232 // LDMatrixObject
169 // ============================================================================= 233 // =============================================================================
178 // In 0.1-alpha, there was a separate 'radial' type which had a position and 242 // In 0.1-alpha, there was a separate 'radial' type which had a position and
179 // matrix as well. Even though right now only LDSubfile uses this, I'm keeping 243 // matrix as well. Even though right now only LDSubfile uses this, I'm keeping
180 // this class distinct in case I get new extension ideas. :) 244 // this class distinct in case I get new extension ideas. :)
181 // ============================================================================= 245 // =============================================================================
182 class LDMatrixObject 246 class LDMatrixObject
183 { DECLARE_PROPERTY (matrix, transform, setTransform) 247 {
184 PROPERTY (LDObject*, linkPointer, setLinkPointer) 248 PROPERTY (public, LDObject*, LinkPointer, NO_OPS, STOCK_WRITE)
185 249 PROPERTY (public, Matrix, Transform, NO_OPS, CUSTOM_WRITE)
186 public: 250
187 LDMatrixObject() {} 251 public:
188 LDMatrixObject (const matrix& transform, const vertex& pos) : 252 LDMatrixObject() :
189 m_transform (transform), m_position (LDSharedVertex::getSharedVertex (pos)) {} 253 m_Position (LDSharedVertex::getSharedVertex (g_origin)) {}
190 254
191 const vertex& position() const 255 LDMatrixObject (const Matrix& transform, const Vertex& pos) :
192 { return m_position->data(); 256 m_Transform (transform),
257 m_Position (LDSharedVertex::getSharedVertex (pos)) {}
258
259 inline const Vertex& getPosition() const
260 {
261 return m_Position->data();
193 } 262 }
194 263
195 void setPosition (const vertex& a); 264 void setCoordinate (const Axis ax, double value)
196 265 {
197 const double& setCoordinate (const Axis ax, double value) 266 Vertex v = getPosition();
198 { vertex v = position();
199 v[ax] = value; 267 v[ax] = value;
200 setPosition (v); 268 setPosition (v);
201
202 return position() [ax];
203 } 269 }
204 270
271 void setPosition (const Vertex& a);
272
205 private: 273 private:
206 LDSharedVertex* m_position; 274 LDSharedVertex* m_Position;
207 }; 275 };
208 276
209 // ============================================================================= 277 // =============================================================================
210 // LDError 278 // LDError
211 // 279 //
213 // represented by a (!) ERROR in the code view. It exists for the purpose of 281 // represented by a (!) ERROR in the code view. It exists for the purpose of
214 // allowing garbage lines be debugged and corrected within LDForge. The member 282 // allowing garbage lines be debugged and corrected within LDForge. The member
215 // zContent contains the contents of the unparsable line. 283 // zContent contains the contents of the unparsable line.
216 // ============================================================================= 284 // =============================================================================
217 class LDError : public LDObject 285 class LDError : public LDObject
218 { LDOBJ (Error) 286 {
287 LDOBJ (Error)
219 LDOBJ_NAME (error) 288 LDOBJ_NAME (error)
220 LDOBJ_VERTICES (0) 289 LDOBJ_VERTICES (0)
221 LDOBJ_UNCOLORED 290 LDOBJ_UNCOLORED
222 LDOBJ_SCEMANTIC 291 LDOBJ_SCEMANTIC
223 LDOBJ_NO_MATRIX 292 LDOBJ_NO_MATRIX
224 PROPERTY (str, fileRef, setFileRef) 293 PROPERTY (public, QString, FileReferenced, STR_OPS, STOCK_WRITE)
225 294
226 public: 295 public:
227 LDError(); 296 LDError();
228 LDError (str contents, str reason) : contents (contents), reason (reason) {} 297 LDError (QString contents, QString reason) : contents (contents), reason (reason) {}
229 298
230 // Content of this unknown line 299 // Content of this unknown line
231 str contents; 300 QString contents;
232 301
233 // Why is this gibberish? 302 // Why is this gibberish?
234 str reason; 303 QString reason;
235 }; 304 };
236 305
237 // ============================================================================= 306 // =============================================================================
238 // LDEmpty 307 // LDEmpty
239 // 308 //
240 // Represents an empty line in the LDraw code file. 309 // Represents an empty line in the LDraw code file.
241 // ============================================================================= 310 // =============================================================================
242 class LDEmpty : public LDObject 311 class LDEmpty : public LDObject
243 { LDOBJ (Empty) 312 {
313 LDOBJ (Empty)
314 LDOBJ_NAME (empty)
244 LDOBJ_VERTICES (0) 315 LDOBJ_VERTICES (0)
245 LDOBJ_UNCOLORED 316 LDOBJ_UNCOLORED
246 LDOBJ_NON_SCEMANTIC 317 LDOBJ_NON_SCEMANTIC
247 LDOBJ_NO_MATRIX 318 LDOBJ_NO_MATRIX
248 }; 319 };
252 // 323 //
253 // Represents a code-0 comment in the LDraw code file. Member text contains 324 // Represents a code-0 comment in the LDraw code file. Member text contains
254 // the text of the comment. 325 // the text of the comment.
255 // ============================================================================= 326 // =============================================================================
256 class LDComment : public LDObject 327 class LDComment : public LDObject
257 { LDOBJ (Comment) 328 {
329 LDOBJ (Comment)
258 LDOBJ_NAME (comment) 330 LDOBJ_NAME (comment)
259 LDOBJ_VERTICES (0) 331 LDOBJ_VERTICES (0)
260 LDOBJ_UNCOLORED 332 LDOBJ_UNCOLORED
261 LDOBJ_NON_SCEMANTIC 333 LDOBJ_NON_SCEMANTIC
262 LDOBJ_NO_MATRIX 334 LDOBJ_NO_MATRIX
263 335
264 public: 336 public:
265 LDComment() {} 337 LDComment() {}
266 LDComment (str text) : text (text) {} 338 LDComment (QString text) : text (text) {}
267 339
268 str text; // The text of this comment 340 QString text; // The text of this comment
269 }; 341 };
270 342
271 // ============================================================================= 343 // =============================================================================
272 // LDBFC 344 // LDBFC
273 // 345 //
274 // Represents a 0 BFC statement in the LDraw code. eStatement contains the type 346 // Represents a 0 BFC statement in the LDraw code. eStatement contains the type
275 // of this statement. 347 // of this statement.
276 // ============================================================================= 348 // =============================================================================
277 class LDBFC : public LDObject 349 class LDBFC : public LDObject
278 { public: 350 {
351 public:
279 enum Type 352 enum Type
280 { CertifyCCW, 353 {
354 CertifyCCW,
281 CCW, 355 CCW,
282 CertifyCW, 356 CertifyCW,
283 CW, 357 CW,
284 NoCertify, 358 NoCertify,
285 InvertNext, 359 InvertNext,
297 LDOBJ_CUSTOM_SCEMANTIC { return (type == InvertNext); } 371 LDOBJ_CUSTOM_SCEMANTIC { return (type == InvertNext); }
298 LDOBJ_NO_MATRIX 372 LDOBJ_NO_MATRIX
299 373
300 public: 374 public:
301 LDBFC() {} 375 LDBFC() {}
302 LDBFC (const LDBFC::Type type) : type (type) {} 376 LDBFC (const LDBFC::Type type) :
377 type (type) {}
303 378
304 // Statement strings 379 // Statement strings
305 static const char* statements[]; 380 static const char* statements[];
306 381
307 Type type; 382 Type type;
311 // LDSubfile 386 // LDSubfile
312 // 387 //
313 // Represents a single code-1 subfile reference. 388 // Represents a single code-1 subfile reference.
314 // ============================================================================= 389 // =============================================================================
315 class LDSubfile : public LDObject, public LDMatrixObject 390 class LDSubfile : public LDObject, public LDMatrixObject
316 { LDOBJ (Subfile) 391 {
392 LDOBJ (Subfile)
317 LDOBJ_NAME (subfile) 393 LDOBJ_NAME (subfile)
318 LDOBJ_VERTICES (0) 394 LDOBJ_VERTICES (0)
319 LDOBJ_COLORED 395 LDOBJ_COLORED
320 LDOBJ_SCEMANTIC 396 LDOBJ_SCEMANTIC
321 LDOBJ_HAS_MATRIX 397 LDOBJ_HAS_MATRIX
322 PROPERTY (LDFile*, fileInfo, setFileInfo) 398 PROPERTY (public, LDDocumentPointer, FileInfo, NO_OPS, STOCK_WRITE)
323 399
324 public: 400 public:
325 enum InlineFlag 401 enum InlineFlag
326 { DeepInline = (1 << 0), 402 {
403 DeepInline = (1 << 0),
327 CacheInline = (1 << 1), 404 CacheInline = (1 << 1),
328 RendererInline = (1 << 2), 405 RendererInline = (1 << 2),
329 406
330 DeepCacheInline = DeepInline | CacheInline, 407 DeepCacheInline = DeepInline | CacheInline,
331 }; 408 };
332 409
333 Q_DECLARE_FLAGS (InlineFlags, InlineFlag) 410 Q_DECLARE_FLAGS (InlineFlags, InlineFlag)
334 411
335 LDSubfile() 412 LDSubfile()
336 { setLinkPointer (this); 413 {
414 setLinkPointer (this);
337 } 415 }
338 416
339 // Inlines this subfile. Note that return type is an array of heap-allocated 417 // Inlines this subfile. Note that return type is an array of heap-allocated
340 // LDObject-clones, they must be deleted one way or another. 418 // LDObject copies, they must be deleted manually.
341 QList<LDObject*> inlineContents (InlineFlags flags); 419 LDObjectList inlineContents (InlineFlags flags);
420
421 protected:
422 ~LDSubfile();
342 }; 423 };
343 424
344 Q_DECLARE_OPERATORS_FOR_FLAGS (LDSubfile::InlineFlags) 425 Q_DECLARE_OPERATORS_FOR_FLAGS (LDSubfile::InlineFlags)
345 426
346 // ============================================================================= 427 // =============================================================================
349 // Represents a single code-2 line in the LDraw code file. v0 and v1 are the end 430 // Represents a single code-2 line in the LDraw code file. v0 and v1 are the end
350 // points of the line. The line is colored with dColor unless uncolored mode is 431 // points of the line. The line is colored with dColor unless uncolored mode is
351 // set. 432 // set.
352 // ============================================================================= 433 // =============================================================================
353 class LDLine : public LDObject 434 class LDLine : public LDObject
354 { LDOBJ (Line) 435 {
436 LDOBJ (Line)
355 LDOBJ_NAME (line) 437 LDOBJ_NAME (line)
356 LDOBJ_VERTICES (2) 438 LDOBJ_VERTICES (2)
357 LDOBJ_COLORED 439 LDOBJ_COLORED
358 LDOBJ_SCEMANTIC 440 LDOBJ_SCEMANTIC
359 LDOBJ_NO_MATRIX 441 LDOBJ_NO_MATRIX
360 442
361 public: 443 public:
362 LDLine() {} 444 LDLine() {}
363 LDLine (vertex v1, vertex v2); 445 LDLine (Vertex v1, Vertex v2);
364 }; 446 };
365 447
366 // ============================================================================= 448 // =============================================================================
367 // LDCndLine 449 // LDCondLine
368 // 450 //
369 // Represents a single code-5 conditional line. The end-points v0 and v1 are 451 // Represents a single code-5 conditional line. The end-points v0 and v1 are
370 // inherited from LDLine, c0 and c1 are the control points of this line. 452 // inherited from LDLine, c0 and c1 are the control points of this line.
371 // ============================================================================= 453 // =============================================================================
372 class LDCndLine : public LDLine 454 class LDCondLine : public LDLine
373 { LDOBJ (CndLine) 455 {
456 LDOBJ (CondLine)
374 LDOBJ_NAME (condline) 457 LDOBJ_NAME (condline)
375 LDOBJ_VERTICES (4) 458 LDOBJ_VERTICES (4)
376 LDOBJ_COLORED 459 LDOBJ_COLORED
377 LDOBJ_SCEMANTIC 460 LDOBJ_SCEMANTIC
378 LDOBJ_NO_MATRIX 461 LDOBJ_NO_MATRIX
379 462
380 public: 463 public:
381 LDCndLine() {} 464 LDCondLine() {}
382 LDLine* demote(); 465 LDLine* demote();
383 }; 466 };
384 467
385 // ============================================================================= 468 // =============================================================================
386 // LDTriangle 469 // LDTriangle
388 // Represents a single code-3 triangle in the LDraw code file. Vertices v0, v1 471 // Represents a single code-3 triangle in the LDraw code file. Vertices v0, v1
389 // and v2 contain the end-points of this triangle. dColor is the color the 472 // and v2 contain the end-points of this triangle. dColor is the color the
390 // triangle is colored with. 473 // triangle is colored with.
391 // ============================================================================= 474 // =============================================================================
392 class LDTriangle : public LDObject 475 class LDTriangle : public LDObject
393 { LDOBJ (Triangle) 476 {
477 LDOBJ (Triangle)
394 LDOBJ_NAME (triangle) 478 LDOBJ_NAME (triangle)
395 LDOBJ_VERTICES (3) 479 LDOBJ_VERTICES (3)
396 LDOBJ_COLORED 480 LDOBJ_COLORED
397 LDOBJ_SCEMANTIC 481 LDOBJ_SCEMANTIC
398 LDOBJ_NO_MATRIX 482 LDOBJ_NO_MATRIX
399 483
400 public: 484 public:
401 LDTriangle() {} 485 LDTriangle() {}
402 LDTriangle (vertex v0, vertex v1, vertex v2) 486 LDTriangle (Vertex v0, Vertex v1, Vertex v2)
403 { setVertex (0, v0); 487 {
488 setVertex (0, v0);
404 setVertex (1, v1); 489 setVertex (1, v1);
405 setVertex (2, v2); 490 setVertex (2, v2);
406 } 491 }
407 }; 492 };
408 493
411 // 496 //
412 // Represents a single code-4 quadrilateral. v0, v1, v2 and v3 are the end points 497 // Represents a single code-4 quadrilateral. v0, v1, v2 and v3 are the end points
413 // of the quad, dColor is the color used for the quad. 498 // of the quad, dColor is the color used for the quad.
414 // ============================================================================= 499 // =============================================================================
415 class LDQuad : public LDObject 500 class LDQuad : public LDObject
416 { LDOBJ (Quad) 501 {
502 LDOBJ (Quad)
417 LDOBJ_NAME (quad) 503 LDOBJ_NAME (quad)
418 LDOBJ_VERTICES (4) 504 LDOBJ_VERTICES (4)
419 LDOBJ_COLORED 505 LDOBJ_COLORED
420 LDOBJ_SCEMANTIC 506 LDOBJ_SCEMANTIC
421 LDOBJ_NO_MATRIX 507 LDOBJ_NO_MATRIX
422 508
423 public: 509 public:
424 LDQuad() {} 510 LDQuad() {}
425 LDQuad (const vertex& v0, const vertex& v1, const vertex& v2, const vertex& v3); 511 LDQuad (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3);
426 512
427 // Split this quad into two triangles (note: heap-allocated) 513 // Split this quad into two triangles (note: heap-allocated)
428 QList<LDTriangle*> splitToTriangles(); 514 QList<LDTriangle*> splitToTriangles();
429 }; 515 };
430 516
435 // vertex which can be used as a parameter to tools or to store coordinates 521 // vertex which can be used as a parameter to tools or to store coordinates
436 // with. Vertices are a part authoring tool and they should not appear in 522 // with. Vertices are a part authoring tool and they should not appear in
437 // finished parts. 523 // finished parts.
438 // ============================================================================= 524 // =============================================================================
439 class LDVertex : public LDObject 525 class LDVertex : public LDObject
440 { LDOBJ (Vertex) 526 {
527 LDOBJ (Vertex)
441 LDOBJ_NAME (vertex) 528 LDOBJ_NAME (vertex)
442 LDOBJ_VERTICES (0) // TODO: move pos to vaCoords[0] 529 LDOBJ_VERTICES (0) // TODO: move pos to vaCoords[0]
443 LDOBJ_COLORED 530 LDOBJ_COLORED
444 LDOBJ_NON_SCEMANTIC 531 LDOBJ_NON_SCEMANTIC
445 LDOBJ_NO_MATRIX 532 LDOBJ_NO_MATRIX
446 533
447 public: 534 public:
448 LDVertex() {} 535 LDVertex() {}
449 536
450 vertex pos; 537 Vertex pos;
451 }; 538 };
452 539
453 // ============================================================================= 540 // =============================================================================
454 // LDOverlay 541 // LDOverlay
455 // 542 //
456 // Overlay image meta, stored in the header of parts so as to preserve overlay 543 // Overlay image meta, stored in the header of parts so as to preserve overlay
457 // information. 544 // information.
458 // ============================================================================= 545 // =============================================================================
459 class LDOverlay : public LDObject 546 class LDOverlay : public LDObject
460 { LDOBJ (Overlay) 547 {
548 LDOBJ (Overlay)
461 LDOBJ_NAME (overlay) 549 LDOBJ_NAME (overlay)
462 LDOBJ_VERTICES (0) 550 LDOBJ_VERTICES (0)
463 LDOBJ_UNCOLORED 551 LDOBJ_UNCOLORED
464 LDOBJ_NON_SCEMANTIC 552 LDOBJ_NON_SCEMANTIC
465 LDOBJ_NO_MATRIX 553 LDOBJ_NO_MATRIX
466 PROPERTY (int, camera, setCamera) 554 PROPERTY (public, int, Camera, NUM_OPS, STOCK_WRITE)
467 PROPERTY (int, x, setX) 555 PROPERTY (public, int, X, NUM_OPS, STOCK_WRITE)
468 PROPERTY (int, y, setY) 556 PROPERTY (public, int, Y, NUM_OPS, STOCK_WRITE)
469 PROPERTY (int, width, setWidth) 557 PROPERTY (public, int, Width, NUM_OPS, STOCK_WRITE)
470 PROPERTY (int, height, setHeight) 558 PROPERTY (public, int, Height, NUM_OPS, STOCK_WRITE)
471 PROPERTY (str, filename, setFilename) 559 PROPERTY (public, QString, FileName, STR_OPS, STOCK_WRITE)
472 }; 560 };
473 561
474 // Other common LDraw stuff 562 // Other common LDraw stuff
475 static const str CALicense = "!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt", 563 static const QString CALicense = "!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt",
476 NonCALicense = "!LICENSE Not redistributable : see NonCAreadme.txt"; 564 NonCALicense = "!LICENSE Not redistributable : see NonCAreadme.txt";
477 static const short lores = 16; 565 static const int lores = 16;
478 static const short hires = 48; 566 static const int hires = 48;
479 567
480 #endif // LDTYPES_H 568 QString getLicenseText (int id);
569
570 #endif // LDFORGE_LDTYPES_H

mercurial