src/ldtypes.h

changeset 538
2f85d4d286e5
parent 522
afa691788bdb
child 539
72ad83a67165
equal deleted inserted replaced
537:1add0ee96fb3 538:2f85d4d286e5
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 "common.h"
23 #include "types.h" 23 #include "types.h"
24 24
25 #define LDOBJ(T) \ 25 #define LDOBJ(T) \
33 return new LD##T (*this); \ 33 return new LD##T (*this); \
34 } \ 34 } \
35 virtual void move (vertex where); \ 35 virtual void move (vertex where); \
36 virtual void invert(); 36 virtual void invert();
37 37
38 #define LDOBJ_NAME(N) virtual str typeName() const override { return #N; } 38 #define LDOBJ_NAME(N) virtual str getTypeName() const override { return #N; }
39 #define LDOBJ_VERTICES(V) virtual short vertices() const override { return V; } 39 #define LDOBJ_VERTICES(V) virtual int vertices() const override { return V; }
40 #define LDOBJ_SETCOLORED(V) virtual bool isColored() const override { return V; } 40 #define LDOBJ_SETCOLORED(V) virtual bool isColored() const override { return V; }
41 #define LDOBJ_COLORED LDOBJ_SETCOLORED (true) 41 #define LDOBJ_COLORED LDOBJ_SETCOLORED (true)
42 #define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false) 42 #define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false)
43 43
44 #define LDOBJ_CUSTOM_SCEMANTIC virtual bool isScemantic() const override 44 #define LDOBJ_CUSTOM_SCEMANTIC virtual bool isScemantic() const override
66 { PROPERTY (bool, hidden, setHidden) 66 { PROPERTY (bool, hidden, setHidden)
67 PROPERTY (bool, selected, setSelected) 67 PROPERTY (bool, selected, setSelected)
68 PROPERTY (LDObject*, parent, setParent) 68 PROPERTY (LDObject*, parent, setParent)
69 PROPERTY (LDFile*, file, setFile) 69 PROPERTY (LDFile*, file, setFile)
70 READ_PROPERTY (int32, id, setID) 70 READ_PROPERTY (int32, id, setID)
71 DECLARE_PROPERTY (short, color, setColor) 71 DECLARE_PROPERTY (int, color, setColor)
72 72
73 public: 73 public:
74 // Object type codes. Codes are sorted in order of significance. 74 // Object type codes. Codes are sorted in order of significance.
75 enum Type 75 enum Type
76 { Subfile, // Object represents a sub-file reference 76 { Subfile, // Object represents a sub-file reference
95 { return 0; // Creates a new LDObject identical to this one. 95 { return 0; // Creates a new LDObject identical to this one.
96 } 96 }
97 long getIndex() const; // Index (i.e. line number) of this object 97 long getIndex() const; // Index (i.e. line number) of this object
98 virtual LDObject::Type getType() const; // Type enumerator of this object 98 virtual LDObject::Type getType() const; // Type enumerator of this object
99 const vertex& getVertex (int i) const; // Get a vertex by index 99 const vertex& getVertex (int i) const; // Get a vertex by index
100 virtual str getTypeName() const; // Type name of this object
100 virtual bool hasMatrix() const; // Does this object have a matrix and position? (see LDMatrixObject) 101 virtual bool hasMatrix() const; // Does this object have a matrix and position? (see LDMatrixObject)
101 virtual void invert(); // Inverts this object (winding is reversed) 102 virtual void invert(); // Inverts this object (winding is reversed)
102 virtual bool isColored() const; // Is this object colored? 103 virtual bool isColored() const; // Is this object colored?
103 virtual bool isScemantic() const; // Does this object have meaning in the part model? 104 virtual bool isScemantic() const; // Does this object have meaning in the part model?
104 virtual void move (vertex vect); // Moves this object using the given vertex as a movement List 105 virtual void move (vertex vect); // Moves this object using the given vertex as a movement List
109 void select(); 110 void select();
110 void setVertex (int i, const vertex& vert); // Set a vertex to the given value 111 void setVertex (int i, const vertex& vert); // Set a vertex to the given value
111 void setVertexCoord (int i, Axis ax, double value); // Set a single coordinate of a vertex 112 void setVertexCoord (int i, Axis ax, double value); // Set a single coordinate of a vertex
112 void swap (LDObject* other); // Swap this object with another. 113 void swap (LDObject* other); // Swap this object with another.
113 LDObject* topLevelParent(); // What object in the current file ultimately references this? 114 LDObject* topLevelParent(); // What object in the current file ultimately references this?
114 virtual str typeName() const; // Type name of this object
115 void unselect(); 115 void unselect();
116 virtual short vertices() const; // Number of vertices this object has 116 virtual int vertices() const; // Number of vertices this object has
117 117
118 static str typeName (LDObject::Type type); // Get type name by enumerator 118 static str typeName (LDObject::Type type); // Get type name by enumerator
119 static LDObject* getDefault (const LDObject::Type type); // Returns a sample object by the given enumerator 119 static LDObject* getDefault (const LDObject::Type type); // Returns a sample object by the given enumerator
120 static void moveObjects (QList<LDObject*> objs, const bool up); // TODO: move this to LDFile? 120 static void moveObjects (QList<LDObject*> objs, const bool up); // TODO: move this to LDFile?
121 static str objectListContents (const QList<LDObject*>& objs); // Get a description of a list of LDObjects 121 static str describeObjects (const QList<LDObject*>& objs); // Get a description of a list of LDObjects
122 static LDObject* fromID (int id); 122 static LDObject* fromID (int id);
123 123
124 // TODO: make these private! 124 // TODO: make these private!
125 // OpenGL list for this object 125 // OpenGL list for this object
126 uint glLists[4]; 126 uint glLists[4];
472 }; 472 };
473 473
474 // Other common LDraw stuff 474 // Other common LDraw stuff
475 static const str CALicense = "!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt", 475 static const str CALicense = "!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt",
476 NonCALicense = "!LICENSE Not redistributable : see NonCAreadme.txt"; 476 NonCALicense = "!LICENSE Not redistributable : see NonCAreadme.txt";
477 static const short lores = 16; 477 static const int lores = 16;
478 static const short hires = 48; 478 static const int hires = 48;
479 479
480 #endif // LDTYPES_H 480 #endif // LDFORGE_LDTYPES_H

mercurial