src/ldDocument.h

changeset 835
268413885cb1
parent 834
3e697ba996e8
child 844
11587d419d2f
--- a/src/ldDocument.h	Mon Jul 07 18:52:10 2014 +0300
+++ b/src/ldDocument.h	Sun Jul 13 16:48:29 2014 +0300
@@ -63,13 +63,10 @@
 class LDDocument : public QObject
 {
 public:
-	using KnownVertexMap = QMap<Vertex, int>;
-
 	PROPERTY (public,	QString,				name,			setName,			STOCK_WRITE)
 	PROPERTY (private,	LDObjectList,		objects, 		setObjects,			STOCK_WRITE)
 	PROPERTY (private,	LDObjectList,		cache, 			setCache,			STOCK_WRITE)
 	PROPERTY (private,	History*,			history,		setHistory,			STOCK_WRITE)
-	PROPERTY (private,	KnownVertexMap,		vertices,		setVertices,		STOCK_WRITE)
 	PROPERTY (public,	QString,				fullPath,		setFullPath,		STOCK_WRITE)
 	PROPERTY (public,	QString,				defaultName,	setDefaultName,		STOCK_WRITE)
 	PROPERTY (public,	bool,				isImplicit,		setImplicit,		CUSTOM_WRITE)
@@ -79,12 +76,17 @@
 	PROPERTY (private,	LDDocumentFlags,	flags,			setFlags,			STOCK_WRITE)
 	PROPERTY (private,	LDDocumentWeakPtr,	self,			setSelf,			STOCK_WRITE)
 
+	QMap<LDObjectPtr, QVector<Vertex>> _objectVertices;
+	QVector<Vertex> _vertices;
+	bool _verticesOutdated;
+	bool _needVertexMerge;
+
 public:
 	LDDocument(LDDocumentPtr* selfptr);
 	~LDDocument();
 
 	int addObject (LDObjectPtr obj); // Adds an object to this file at the end of the file.
-	void addObjects (const LDObjectList objs);
+	void addObjects (const LDObjectList& objs);
 	void clearSelection();
 	void forgetObject (LDObjectPtr obj); // Deletes the given object from the object chain.
 	QString getDisplayName();
@@ -101,10 +103,11 @@
 	void setObject (int idx, LDObjectPtr obj);
 	QList<LDPolygon> inlinePolygons();
 	void vertexChanged (const Vertex& a, const Vertex& b);
-	void addKnownVerticesOf(LDObjectPtr obj);
-	void removeKnownVerticesOf (LDObjectPtr sub);
-	QList<Vertex> inlineVertices();
+	const QVector<Vertex>& inlineVertices();
 	void clear();
+	void addKnownVertices (LDObjectPtr obj);
+	void redoVertices();
+	void needVertexMerge();
 
 	inline LDDocument& operator<< (LDObjectPtr obj)
 	{
@@ -142,7 +145,6 @@
 		setImplicit (true);
 	}
 
-	static void closeUnused();
 	static LDDocumentPtr current();
 	static void setCurrent (LDDocumentPtr f);
 	static void closeInitialFile();
@@ -152,6 +154,7 @@
 	// Turns a full path into a relative path
 	static QString shortenName (QString a);
 	static QList<LDDocumentPtr> const& explicitDocuments();
+	void mergeVertices();
 
 protected:
 	void addToSelection (LDObjectPtr obj);
@@ -168,14 +171,10 @@
 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_needsReCache;
-
-	void addKnownVertexReference (const Vertex& a);
-	void removeKnownVertexReference (const Vertex& a);
 };
 
 inline LDDocumentPtr getCurrentDocument()

mercurial