93 virtual LDObject* clone() |
94 virtual LDObject* clone() |
94 { return 0; // Creates a new LDObject identical to this one. |
95 { return 0; // Creates a new LDObject identical to this one. |
95 } |
96 } |
96 long getIndex() const; // Index (i.e. line number) of this object |
97 long getIndex() const; // Index (i.e. line number) of this object |
97 virtual LDObject::Type getType() const; // Type enumerator of this object |
98 virtual LDObject::Type getType() const; // Type enumerator of this object |
98 const vertex& getVertex (int i) const; // Get a vertex by index |
99 const vertex& getVertex (int i) const; // Get a vertex by index |
99 virtual bool hasMatrix() const; // Does this object have a matrix and position? (see LDMatrixObject) |
100 virtual bool hasMatrix() const; // Does this object have a matrix and position? (see LDMatrixObject) |
100 virtual void invert(); // Inverts this object (winding is reversed) |
101 virtual void invert(); // Inverts this object (winding is reversed) |
101 virtual bool isColored() const; // Is this object colored? |
102 virtual bool isColored() const; // Is this object colored? |
102 virtual bool isScemantic() const; // Does this object have meaning in the part model? |
103 virtual bool isScemantic() const; // Does this object have meaning in the part model? |
103 virtual void move (vertex vect); // Moves this object using the given vertex as a movement List |
104 virtual void move (vertex vect); // Moves this object using the given vertex as a movement List |
130 protected: |
131 protected: |
131 bool m_glinit; |
132 bool m_glinit; |
132 friend class GLRenderer; |
133 friend class GLRenderer; |
133 |
134 |
134 private: |
135 private: |
135 vertex m_coords[4]; |
136 LDSharedVertex* m_coords[4]; |
|
137 }; |
|
138 |
|
139 // ============================================================================= |
|
140 // LDSharedVertex |
|
141 // |
|
142 // For use as coordinates of LDObjects. Keeps count of references. |
|
143 // ----------------------------------------------------------------------------- |
|
144 class LDSharedVertex |
|
145 { public: |
|
146 inline const vertex& data() const |
|
147 { return m_data; |
|
148 } |
|
149 |
|
150 inline operator const vertex&() const |
|
151 { return m_data; |
|
152 } |
|
153 |
|
154 void addRef (LDObject* a); |
|
155 void delRef (LDObject* a); |
|
156 |
|
157 static LDSharedVertex* getSharedVertex (const vertex& a); |
|
158 |
|
159 protected: |
|
160 LDSharedVertex (const vertex& a) : m_data (a) {} |
|
161 |
|
162 private: |
|
163 QList<LDObject*> m_refs; |
|
164 vertex m_data; |
136 }; |
165 }; |
137 |
166 |
138 // ============================================================================= |
167 // ============================================================================= |
139 // LDMatrixObject |
168 // LDMatrixObject |
140 // ============================================================================= |
169 // ============================================================================= |
150 // matrix as well. Even though right now only LDSubfile uses this, I'm keeping |
179 // matrix as well. Even though right now only LDSubfile uses this, I'm keeping |
151 // this class distinct in case I get new extension ideas. :) |
180 // this class distinct in case I get new extension ideas. :) |
152 // ============================================================================= |
181 // ============================================================================= |
153 class LDMatrixObject |
182 class LDMatrixObject |
154 { DECLARE_PROPERTY (matrix, transform, setTransform) |
183 { DECLARE_PROPERTY (matrix, transform, setTransform) |
155 DECLARE_PROPERTY (vertex, position, setPosition) |
|
156 PROPERTY (LDObject*, linkPointer, setLinkPointer) |
184 PROPERTY (LDObject*, linkPointer, setLinkPointer) |
157 |
185 |
158 public: |
186 public: |
159 LDMatrixObject() {} |
187 LDMatrixObject() {} |
160 LDMatrixObject (const matrix& transform, const vertex& pos) : |
188 LDMatrixObject (const matrix& transform, const vertex& pos) : |
161 PROP_NAME (transform) (transform), PROP_NAME (position) (pos) {} |
189 m_transform (transform), m_position (LDSharedVertex::getSharedVertex (pos)) {} |
|
190 |
|
191 const vertex& position() const |
|
192 { return m_position->data(); |
|
193 } |
|
194 |
|
195 void setPosition (const vertex& a); |
162 |
196 |
163 const double& setCoordinate (const Axis ax, double value) |
197 const double& setCoordinate (const Axis ax, double value) |
164 { vertex v = position(); |
198 { vertex v = position(); |
165 v[ax] = value; |
199 v[ax] = value; |
166 setPosition (v); |
200 setPosition (v); |
167 |
201 |
168 return position() [ax]; |
202 return position() [ax]; |
169 } |
203 } |
|
204 |
|
205 private: |
|
206 LDSharedVertex* m_position; |
170 }; |
207 }; |
171 |
208 |
172 // ============================================================================= |
209 // ============================================================================= |
173 // LDError |
210 // LDError |
174 // |
211 // |