130 setImplicit (true); |
130 setImplicit (true); |
131 setSavePosition (-1); |
131 setSavePosition (-1); |
132 setTabIndex (-1); |
132 setTabIndex (-1); |
133 setHistory (new History); |
133 setHistory (new History); |
134 history()->setDocument (this); |
134 history()->setDocument (this); |
135 m_needsGLReInit = true; |
135 m_needsReCache = true; |
136 } |
136 } |
137 |
137 |
138 // ============================================================================= |
138 // ============================================================================= |
139 // |
139 // |
140 LDDocument::~LDDocument() |
140 LDDocument::~LDDocument() |
1112 if (isImplicit()) |
1112 if (isImplicit()) |
1113 return; |
1113 return; |
1114 |
1114 |
1115 if (obj->type() == LDObject::ESubfile) |
1115 if (obj->type() == LDObject::ESubfile) |
1116 { |
1116 { |
1117 for (LDObject* sub : static_cast<LDSubfile*> (obj)->inlineContents (true, false)) |
1117 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
1118 { |
1118 |
1119 addKnownVerticesOf (sub); |
1119 for (Vertex vrt : ref->fileInfo()->inlineVertices()) |
1120 sub->destroy(); |
1120 { |
|
1121 vrt.transform (ref->transform(), ref->position()); |
|
1122 addKnownVertexReference (vrt); |
1121 } |
1123 } |
1122 } |
1124 } |
1123 else |
1125 else |
1124 { |
1126 { |
1125 for (int i = 0; i < obj->vertices(); ++i) |
1127 for (int i = 0; i < obj->vertices(); ++i) |
1134 if (isImplicit()) |
1136 if (isImplicit()) |
1135 return; |
1137 return; |
1136 |
1138 |
1137 if (obj->type() == LDObject::ESubfile) |
1139 if (obj->type() == LDObject::ESubfile) |
1138 { |
1140 { |
1139 for (LDObject* sub : static_cast<LDSubfile*> (obj)->inlineContents (true, false)) |
1141 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
1140 { |
1142 |
1141 removeKnownVerticesOf (sub); |
1143 for (Vertex vrt : ref->fileInfo()->inlineVertices()) |
1142 sub->destroy(); |
1144 { |
|
1145 vrt.transform (ref->transform(), ref->position()); |
|
1146 removeKnownVertexReference (vrt); |
1143 } |
1147 } |
1144 } |
1148 } |
1145 else |
1149 else |
1146 { |
1150 { |
1147 for (int i = 0; i < obj->vertices(); ++i) |
1151 for (int i = 0; i < obj->vertices(); ++i) |
1291 return tr ("<anonymous>"); |
1295 return tr ("<anonymous>"); |
1292 } |
1296 } |
1293 |
1297 |
1294 // ============================================================================= |
1298 // ============================================================================= |
1295 // |
1299 // |
1296 void LDDocument::initializeGLData() |
1300 void LDDocument::initializeCachedData() |
1297 { |
1301 { |
1298 print (getDisplayName() + ": Initializing GL data"); |
1302 if (not m_needsReCache) |
|
1303 return; |
|
1304 |
1299 LDObjectList objs = inlineContents (true, true); |
1305 LDObjectList objs = inlineContents (true, true); |
|
1306 m_storedVertices.clear(); |
1300 |
1307 |
1301 for (LDObject* obj : objs) |
1308 for (LDObject* obj : objs) |
1302 { |
1309 { |
1303 assert (obj->type() != LDObject::ESubfile); |
1310 assert (obj->type() != LDObject::ESubfile); |
1304 LDPolygon* data = obj->getPolygon(); |
1311 LDPolygon* data = obj->getPolygon(); |
1307 { |
1314 { |
1308 m_polygonData << *data; |
1315 m_polygonData << *data; |
1309 delete data; |
1316 delete data; |
1310 } |
1317 } |
1311 |
1318 |
|
1319 for (int i = 0; i < obj->vertices(); ++i) |
|
1320 m_storedVertices << obj->vertex (i); |
|
1321 |
1312 obj->destroy(); |
1322 obj->destroy(); |
1313 } |
1323 } |
1314 |
1324 |
1315 m_needsGLReInit = false; |
1325 removeDuplicates (m_storedVertices); |
|
1326 m_needsReCache = false; |
1316 } |
1327 } |
1317 |
1328 |
1318 // ============================================================================= |
1329 // ============================================================================= |
1319 // |
1330 // |
1320 QList<LDPolygon> LDDocument::inlinePolygons() |
1331 QList<LDPolygon> LDDocument::inlinePolygons() |
1321 { |
1332 { |
1322 if (m_needsGLReInit == true) |
1333 initializeCachedData(); |
1323 initializeGLData(); |
|
1324 |
|
1325 return polygonData(); |
1334 return polygonData(); |
1326 } |
1335 } |
1327 |
1336 |
1328 // ============================================================================= |
1337 // ============================================================================= |
1329 // ----------------------------------------------------------------------------- |
1338 // ----------------------------------------------------------------------------- |