Mon, 06 May 2013 00:10:56 +0300
cleanup
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
104 | 3 | * Copyright (C) 2013 Santeri Piippo |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
18 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
19 | #ifndef LDTYPES_H |
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
20 | #define LDTYPES_H |
0 | 21 | |
22 | #include "common.h" | |
64
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
23 | #include "types.h" |
0 | 24 | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
25 | #define IMPLEMENT_LDTYPE(T, NUMVERTS) \ |
164 | 26 | LD##T () {} \ |
27 | virtual ~LD##T () {} \ | |
0 | 28 | virtual LDObjectType_e getType () const { \ |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
29 | return OBJ_##T; \ |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
30 | } \ |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
31 | virtual str getContents (); \ |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
32 | virtual LD##T* clone () { \ |
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
33 | return new LD##T (*this); \ |
102
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
34 | } \ |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
35 | virtual void move (vertex vVector); \ |
138
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
36 | virtual short vertices () const { return NUMVERTS; } \ |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
37 | |
164 | 38 | #define LDOBJ_SETCOLORED(V) virtual bool isColored () const { return V; } |
39 | #define LDOBJ_COLORED LDOBJ_SETCOLORED (true) | |
40 | #define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false) | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
41 | |
151
15fe6c51de54
Switched the object list from a QTreeWidget to a QListWidget-derivative. Derivative because I'm going to add a context menu.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
42 | class QListWidgetItem; |
104 | 43 | class LDSubfile; |
0 | 44 | |
45 | // ============================================================================= | |
46 | // LDObjectType_e | |
47 | // | |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
48 | // Object type codes. Codes are sorted in order of significance. |
0 | 49 | // ============================================================================= |
50 | enum LDObjectType_e { | |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
51 | OBJ_Subfile, // Object represents a sub-file reference |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
52 | OBJ_Radial, // Object represents a generic radial |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
53 | OBJ_Quad, // Object represents a quadrilateral |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
54 | OBJ_Triangle, // Object represents a triangle |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
55 | OBJ_Line, // Object represents a line |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
56 | OBJ_CondLine, // Object represents a conditional line |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
57 | OBJ_Vertex, // Object is a vertex, LDForge extension object |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
58 | OBJ_BFC, // Object represents a BFC statement |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
59 | OBJ_Comment, // Object represents a comment |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
60 | OBJ_Gibberish, // Object is the result of failed parsing |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
61 | OBJ_Empty, // Object represents an empty line |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
62 | OBJ_Unidentified, // Object is an uninitialized (SHOULD NEVER HAPPEN) |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
63 | NUM_ObjectTypes // Amount of object types |
0 | 64 | }; |
65 | ||
66 | // ============================================================================= | |
67 | // LDObject | |
68 | // | |
69 | // Base class object for all LD* types. Each LDObject represents a single line | |
70 | // in the LDraw code file. The virtual method getType returns an enumerator | |
71 | // which is a token of the object's type. The object can be casted into | |
72 | // sub-classes based on this enumerator. | |
73 | // ============================================================================= | |
74 | class LDObject { | |
75 | public: | |
76 | LDObject (); | |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
77 | virtual ~LDObject (); |
0 | 78 | |
13
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
79 | // Index (i.e. line number) of this object |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
64
diff
changeset
|
80 | long getIndex (OpenFile* pFile); |
13
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
81 | |
50
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
82 | // Color used by this object. Comments, gibberish and empty entries |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
83 | // do not use this field. |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
84 | short dColor; |
7fd213c6b844
Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
85 | |
103
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
102
diff
changeset
|
86 | // OpenGL list for this object |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
87 | uint uGLList, uGLPickList; |
103
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
102
diff
changeset
|
88 | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
89 | // Vertices of this object |
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
90 | vertex vaCoords[4]; |
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
91 | |
104 | 92 | // Object this object was referenced from, if any |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
93 | LDObject* parent; |
104 | 94 | |
13
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
95 | // Type enumerator of this object |
0 | 96 | virtual LDObjectType_e getType () const { |
97 | return OBJ_Unidentified; | |
98 | }; | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
99 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
100 | // A string that represents this line |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
101 | virtual str getContents () { |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
102 | return ""; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
103 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
104 | |
76
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
73
diff
changeset
|
105 | // Creates a new LDObject identical to this one and returns a pointer to it. |
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
73
diff
changeset
|
106 | virtual LDObject* clone () { |
55
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
107 | return new LDObject (*this); |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
108 | } |
b08f10e668e5
Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
109 | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
110 | // Replace this LDObject with another LDObject. This method deletes the |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
111 | // object and any pointers to it become invalid. |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
112 | void replace (LDObject* replacement); |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
113 | |
84
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
114 | // Swap this object with another. |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
115 | void swap (LDObject* other); |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
116 | |
102
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
117 | // Moves this object using the given vertex as a movement vector |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
118 | virtual void move (vertex vVector); |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
119 | |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
120 | // What object in the current file ultimately references this? |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
121 | LDObject* topLevelParent (); |
104 | 122 | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
123 | // Number of vertices this object has |
138
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
124 | virtual short vertices () const { |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
125 | return 0; |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
126 | } |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
127 | |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
128 | // Is this object colored? |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
129 | virtual bool isColored () const { |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
130 | return false; |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
131 | } |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
132 | |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
133 | // Returns a sample object by the given value |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
134 | static LDObject* getDefault (const LDObjectType_e type); |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
135 | |
91
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
136 | static void moveObjects (std::vector<LDObject*> objs, const bool bUp); |
117
7eb7a43a511b
Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents:
114
diff
changeset
|
137 | static str objectListContents (const std::vector<LDObject*>& objs); |
91
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
138 | |
151
15fe6c51de54
Switched the object list from a QTreeWidget to a QListWidget-derivative. Derivative because I'm going to add a context menu.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
139 | // Object list entry for this object |
15fe6c51de54
Switched the object list from a QTreeWidget to a QListWidget-derivative. Derivative because I'm going to add a context menu.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
140 | QListWidgetItem* qObjListEntry; |
0 | 141 | }; |
142 | ||
143 | // ============================================================================= | |
144 | // LDGibberish | |
145 | // | |
146 | // Represents a line in the LDraw file that could not be properly parsed. It is | |
147 | // represented by a (!) ERROR in the code view. It exists for the purpose of | |
148 | // allowing garbage lines be debugged and corrected within LDForge. The member | |
149 | // zContent contains the contents of the unparsable line. | |
150 | // ============================================================================= | |
151 | class LDGibberish : public LDObject { | |
152 | public: | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
153 | IMPLEMENT_LDTYPE (Gibberish, 0) |
164 | 154 | LDOBJ_UNCOLORED |
0 | 155 | |
11
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
156 | LDGibberish (str _zContent, str _zReason); |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
157 | |
0 | 158 | // Content of this unknown line |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
159 | str zContents; |
11
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
160 | |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
161 | // Why is this gibberish? |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
162 | str zReason; |
0 | 163 | }; |
164 | ||
165 | // ============================================================================= | |
166 | // LDEmptyLine | |
167 | // | |
168 | // Represents an empty line in the LDraw code file. | |
169 | // ============================================================================= | |
170 | class LDEmpty : public LDObject { | |
171 | public: | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
172 | IMPLEMENT_LDTYPE (Empty, 0) |
164 | 173 | LDOBJ_UNCOLORED |
0 | 174 | }; |
175 | ||
176 | // ============================================================================= | |
177 | // LDComment | |
178 | // | |
179 | // Represents a code-0 comment in the LDraw code file. Member zText contains | |
180 | // the text of the comment. | |
181 | // ============================================================================= | |
182 | class LDComment : public LDObject { | |
183 | public: | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
184 | IMPLEMENT_LDTYPE (Comment, 0) |
164 | 185 | LDOBJ_UNCOLORED |
138
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
186 | |
164 | 187 | LDComment (str zText) : text (zText) {} |
0 | 188 | |
164 | 189 | str text; // The text of this comment |
0 | 190 | }; |
191 | ||
192 | // ============================================================================= | |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
193 | // LDBFC |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
194 | // |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
195 | // Represents a 0 BFC statement in the LDraw code. eStatement contains the type |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
196 | // of this statement. |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
197 | // ============================================================================= |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
198 | class LDBFC : public LDComment { |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
199 | public: |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
200 | enum Type { |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
201 | CertifyCCW, |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
202 | CCW, |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
203 | CertifyCW, |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
204 | CW, |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
205 | NoCertify, // Winding becomes disabled (0 BFC NOCERTIFY) |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
206 | InvertNext, // Winding is inverted for next object (0 BFC INVERTNEXT) |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
207 | NumStatements |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
208 | }; |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
209 | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
210 | IMPLEMENT_LDTYPE (BFC, 0) |
164 | 211 | LDOBJ_UNCOLORED |
138
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
212 | |
164 | 213 | LDBFC (const LDBFC::Type eType) : type (eType) {} |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
214 | |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
215 | // Statement strings |
164 | 216 | static const char* statements[]; |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
217 | |
164 | 218 | Type type; |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
219 | }; |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
220 | |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
221 | // ============================================================================= |
0 | 222 | // LDSubfile |
223 | // | |
224 | // Represents a single code-1 subfile reference. | |
225 | // ============================================================================= | |
226 | class LDSubfile : public LDObject { | |
227 | public: | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
228 | IMPLEMENT_LDTYPE (Subfile, 0) |
164 | 229 | LDOBJ_COLORED |
0 | 230 | |
164 | 231 | vertex vPosition; // Position of the subpart (FIXME: should get rid of this) |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
232 | matrix<3> mMatrix; // Transformation matrix for the subpart |
0 | 233 | str zFileName; // Filename of the subpart |
104 | 234 | OpenFile* pFile; // Pointer to opened file for this subfile. null if unopened. |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
235 | |
164 | 236 | // Inlines this subfile. Note that return type is an array of heap-allocated |
237 | // LDObject-clones, they must be deleted one way or another. | |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
64
diff
changeset
|
238 | std::vector<LDObject*> inlineContents (bool bDeepInline, bool bCache); |
0 | 239 | }; |
240 | ||
241 | // ============================================================================= | |
242 | // LDLine | |
243 | // | |
244 | // Represents a single code-2 line in the LDraw code file. v0 and v1 are the end | |
245 | // points of the line. The line is colored with dColor unless uncolored mode is | |
246 | // set. | |
247 | // ============================================================================= | |
248 | class LDLine : public LDObject { | |
249 | public: | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
250 | IMPLEMENT_LDTYPE (Line, 2) |
164 | 251 | LDOBJ_COLORED |
138
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
252 | |
57
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
55
diff
changeset
|
253 | LDLine (vertex v1, vertex v2); |
0 | 254 | }; |
255 | ||
256 | // ============================================================================= | |
257 | // LDCondLine | |
258 | // | |
259 | // Represents a single code-5 conditional line. The end-points v0 and v1 are | |
260 | // inherited from LDLine, c0 and c1 are the control points of this line. | |
261 | // ============================================================================= | |
262 | class LDCondLine : public LDLine { | |
263 | public: | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
264 | IMPLEMENT_LDTYPE (CondLine, 4) |
164 | 265 | LDOBJ_COLORED |
0 | 266 | }; |
267 | ||
268 | // ============================================================================= | |
269 | // LDTriangle | |
270 | // | |
271 | // Represents a single code-3 triangle in the LDraw code file. Vertices v0, v1 | |
272 | // and v2 contain the end-points of this triangle. dColor is the color the | |
273 | // triangle is colored with. | |
274 | // ============================================================================= | |
275 | class LDTriangle : public LDObject { | |
276 | public: | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
277 | IMPLEMENT_LDTYPE (Triangle, 3) |
164 | 278 | LDOBJ_COLORED |
0 | 279 | |
280 | LDTriangle (vertex _v0, vertex _v1, vertex _v2) { | |
281 | vaCoords[0] = _v0; | |
282 | vaCoords[1] = _v1; | |
283 | vaCoords[2] = _v2; | |
284 | } | |
285 | }; | |
286 | ||
287 | // ============================================================================= | |
288 | // LDQuad | |
289 | // | |
290 | // Represents a single code-4 quadrilateral. v0, v1, v2 and v3 are the end points | |
291 | // of the quad, dColor is the color used for the quad. | |
292 | // ============================================================================= | |
293 | class LDQuad : public LDObject { | |
294 | public: | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
295 | IMPLEMENT_LDTYPE (Quad, 4) |
164 | 296 | LDOBJ_COLORED |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
297 | |
164 | 298 | // Split this quad into two triangles (note: heap-allocated) |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
299 | vector<LDTriangle*> splitToTriangles (); |
0 | 300 | }; |
301 | ||
302 | // ============================================================================= | |
303 | // LDVertex | |
304 | // | |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
305 | // The vertex is an LDForce-specific extension which represents a single |
0 | 306 | // vertex which can be used as a parameter to tools or to store coordinates |
307 | // with. Vertices are a part authoring tool and they should not appear in | |
308 | // finished parts. | |
309 | // ============================================================================= | |
310 | class LDVertex : public LDObject { | |
311 | public: | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
312 | IMPLEMENT_LDTYPE (Vertex, 0) // TODO: move vPosition to vaCoords[0] |
164 | 313 | LDOBJ_COLORED |
0 | 314 | |
315 | vertex vPosition; | |
316 | }; | |
317 | ||
318 | // ============================================================================= | |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
319 | // LDRadial |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
320 | // |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
321 | // The generic radial primitive (radial for short) is another LDforge-specific |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
322 | // extension which represents an arbitrary circular primitive. Radials can appear |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
323 | // as circles, cylinders, rings, cones, discs and disc negatives; the point is to |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
324 | // allow part authors to add radial primitives to parts without much hassle about |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
325 | // non-existant primitive parts. |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
326 | // ============================================================================= |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
327 | class LDRadial : public LDObject { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
328 | public: |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
329 | enum Type { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
330 | Circle, |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
331 | Cylinder, |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
332 | Disc, |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
333 | DiscNeg, |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
334 | Ring, |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
335 | Cone, |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
336 | NumTypes |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
337 | }; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
338 | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
339 | IMPLEMENT_LDTYPE (Radial, 0) |
164 | 340 | LDOBJ_COLORED |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
341 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
342 | LDRadial::Type eRadialType; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
343 | vertex vPosition; |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
344 | matrix<3> mMatrix; |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
345 | short dDivisions, dSegments, dRingNum; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
346 | |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
347 | LDRadial (LDRadial::Type eRadialType, vertex vPosition, matrix<3> mMatrix, |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
348 | short dDivisions, short dSegments, short dRingNum) : |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
349 | eRadialType (eRadialType), vPosition (vPosition), mMatrix (mMatrix), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
350 | dDivisions (dDivisions), dSegments (dSegments), dRingNum (dRingNum) {} |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
351 | |
164 | 352 | // Returns a set of objects that provide the equivalent of this radial. |
353 | // Note: objects are heap-allocated. | |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
354 | std::vector<LDObject*> decompose (bool bTransform); |
164 | 355 | |
356 | // Compose a file name for this radial. | |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
357 | str makeFileName (); |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
358 | |
164 | 359 | char const* radialTypeName (); |
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
360 | static char const* radialTypeName (const LDRadial::Type eType); |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
361 | }; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
362 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
363 | // ============================================================================= |
0 | 364 | // Object type names. Pass the return value of getType as the index to get a |
365 | // string representation of the object's type. | |
366 | extern const char* g_saObjTypeNames[]; | |
367 | ||
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
368 | // Icons for these types |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
369 | extern const char* g_saObjTypeIcons[]; |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
370 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
371 | #endif // LDTYPES_H |