src/linetypes/modelobject.cpp

changeset 1305
31627acdd4b5
parent 1299
b692088dc1a6
child 1306
be85306198a2
equal deleted inserted replaced
1304:bb3f43293cf8 1305:31627acdd4b5
24 #include "../mainwindow.h" 24 #include "../mainwindow.h"
25 #include "../editHistory.h" 25 #include "../editHistory.h"
26 #include "../canvas.h" 26 #include "../canvas.h"
27 #include "../colors.h" 27 #include "../colors.h"
28 #include "../glcompiler.h" 28 #include "../glcompiler.h"
29 #include "../algorithms/invert.h"
29 #include "edgeline.h" 30 #include "edgeline.h"
30 #include "triangle.h" 31 #include "triangle.h"
31 #include "quadrilateral.h" 32 #include "quadrilateral.h"
32 #include "conditionaledge.h" 33 #include "conditionaledge.h"
33 #include "comment.h" 34 #include "comment.h"
152 153
153 if (obj->color() == MainColor) 154 if (obj->color() == MainColor)
154 obj->setColor (parentcolor); 155 obj->setColor (parentcolor);
155 } 156 }
156 157
158 bool shouldInvert(LDSubfileReference* reference, Winding winding, DocumentManager* context)
159 {
160 bool result = false;
161 result ^= (reference->isInverted());
162 result ^= (reference->transformationMatrix().determinant() < 0);
163 result ^= (reference->fileInfo(context)->header.winding != winding);
164 return result;
165 }
166
157 // ============================================================================= 167 // =============================================================================
158 // ----------------------------------------------------------------------------- 168 // -----------------------------------------------------------------------------
159 void LDSubfileReference::inlineContents(DocumentManager* context, Model& model, bool deep, bool render) 169 void LDSubfileReference::inlineContents(
160 { 170 DocumentManager* context,
171 Winding parentWinding,
172 Model& model,
173 bool deep,
174 bool render
175 ) {
161 Model inlined {context}; 176 Model inlined {context};
162 fileInfo(context)->inlineContents(inlined, deep, render); 177 fileInfo(context)->inlineContents(inlined, deep, render);
163 178
164 // Transform the objects 179 // Transform the objects
165 for (LDObject* object : inlined) 180 for (LDObject* object : inlined)
181 {
182 if (::shouldInvert(this, parentWinding, context))
183 ::invert(object, context);
184
166 TransformObject(object, transformationMatrix(), position(), color()); 185 TransformObject(object, transformationMatrix(), position(), color());
186 }
167 187
168 model.merge(inlined); 188 model.merge(inlined);
169 } 189 }
170 190
171 // ============================================================================= 191 // =============================================================================
212 return false; 232 return false;
213 } 233 }
214 234
215 // ============================================================================= 235 // =============================================================================
216 // 236 //
217 QList<LDPolygon> LDSubfileReference::inlinePolygons(DocumentManager* context) 237 QList<LDPolygon> LDSubfileReference::inlinePolygons(DocumentManager* context, Winding parentWinding)
218 { 238 {
219 LDDocument* file = fileInfo(context); 239 LDDocument* file = fileInfo(context);
220 240
221 if (file) 241 if (file)
222 { 242 {
224 244
225 for (LDPolygon& entry : data) 245 for (LDPolygon& entry : data)
226 { 246 {
227 for (int i = 0; i < entry.numVertices(); ++i) 247 for (int i = 0; i < entry.numVertices(); ++i)
228 entry.vertices[i].transform (transformationMatrix(), position()); 248 entry.vertices[i].transform (transformationMatrix(), position());
249
250 if (::shouldInvert(this, parentWinding, context))
251 ::invertPolygon(entry);
229 } 252 }
230 253
231 return data; 254 return data;
232 } 255 }
233 else 256 else

mercurial