Fri, 18 Apr 2014 23:17:01 +0300
- sped up known vertex information gathering by an order of magnitude
src/ldDocument.cc | file | annotate | diff | comparison | revisions | |
src/ldDocument.h | file | annotate | diff | comparison | revisions | |
src/ldObject.cc | file | annotate | diff | comparison | revisions |
--- a/src/ldDocument.cc Fri Apr 18 18:58:13 2014 +0300 +++ b/src/ldDocument.cc Fri Apr 18 23:17:01 2014 +0300 @@ -132,7 +132,7 @@ setTabIndex (-1); setHistory (new History); history()->setDocument (this); - m_needsGLReInit = true; + m_needsReCache = true; } // ============================================================================= @@ -1114,10 +1114,12 @@ if (obj->type() == LDObject::ESubfile) { - for (LDObject* sub : static_cast<LDSubfile*> (obj)->inlineContents (true, false)) + LDSubfile* ref = static_cast<LDSubfile*> (obj); + + for (Vertex vrt : ref->fileInfo()->inlineVertices()) { - addKnownVerticesOf (sub); - sub->destroy(); + vrt.transform (ref->transform(), ref->position()); + addKnownVertexReference (vrt); } } else @@ -1136,10 +1138,12 @@ if (obj->type() == LDObject::ESubfile) { - for (LDObject* sub : static_cast<LDSubfile*> (obj)->inlineContents (true, false)) + LDSubfile* ref = static_cast<LDSubfile*> (obj); + + for (Vertex vrt : ref->fileInfo()->inlineVertices()) { - removeKnownVerticesOf (sub); - sub->destroy(); + vrt.transform (ref->transform(), ref->position()); + removeKnownVertexReference (vrt); } } else @@ -1293,10 +1297,13 @@ // ============================================================================= // -void LDDocument::initializeGLData() +void LDDocument::initializeCachedData() { - print (getDisplayName() + ": Initializing GL data"); + if (not m_needsReCache) + return; + LDObjectList objs = inlineContents (true, true); + m_storedVertices.clear(); for (LDObject* obj : objs) { @@ -1309,19 +1316,21 @@ delete data; } + for (int i = 0; i < obj->vertices(); ++i) + m_storedVertices << obj->vertex (i); + obj->destroy(); } - m_needsGLReInit = false; + removeDuplicates (m_storedVertices); + m_needsReCache = false; } // ============================================================================= // QList<LDPolygon> LDDocument::inlinePolygons() { - if (m_needsGLReInit == true) - initializeGLData(); - + initializeCachedData(); return polygonData(); } @@ -1530,3 +1539,11 @@ if (references().isEmpty()) invokeLater (closeUnused); } + +// ============================================================================= +// +QList<Vertex> LDDocument::inlineVertices() +{ + initializeCachedData(); + return m_storedVertices; +}
--- a/src/ldDocument.h Fri Apr 18 18:58:13 2014 +0300 +++ b/src/ldDocument.h Fri Apr 18 23:17:01 2014 +0300 @@ -94,7 +94,7 @@ QString getDisplayName(); const LDObjectList& getSelection() const; bool hasUnsavedChanges() const; // Does this document have unsaved changes? - void initializeGLData(); + void initializeCachedData(); LDObjectList inlineContents (bool deep, bool renderinline); void insertObj (int pos, LDObject* obj); int getObjectCount() const; @@ -109,6 +109,7 @@ void vertexChanged (const Vertex& a, const Vertex& b); void addKnownVerticesOf(LDObject* obj); void removeKnownVerticesOf (LDObject* sub); + QList<Vertex> inlineVertices(); inline LDDocument& operator<< (LDObject* obj) { @@ -165,10 +166,11 @@ private: LDObjectList m_sel; LDGLData* m_gldata; + QList<Vertex> m_storedVertices; // If set to true, next polygon inline of this document discards the // stored polygon data and re-builds it. - bool m_needsGLReInit; + bool m_needsReCache; static LDDocument* m_curdoc;