src/ldDocument.h

changeset 1073
a0a0d581309b
parent 1072
9ce9496427f2
child 1083
5903cfa6b4d9
--- a/src/ldDocument.h	Sat Jan 28 17:47:06 2017 +0200
+++ b/src/ldDocument.h	Sun Jan 29 15:05:14 2017 +0200
@@ -22,6 +22,7 @@
 #include "ldObject.h"
 #include "editHistory.h"
 #include "glShared.h"
+#include "model.h"
 
 class EditHistory;
 class OpenProgressDialog;
@@ -39,7 +40,7 @@
 // The default name is a placeholder, initially suggested name for a file. The
 // primitive generator uses this to give initial names to primitives.
 //
-class LDDocument : public QObject, public HierarchyElement
+class LDDocument : public QObject, public Model, public HierarchyElement
 {
 	Q_OBJECT
 
@@ -51,7 +52,6 @@
 		NeedsVertexMerge = (1 << 2),
 		IsBeingDestroyed = (1 << 3),
 		NeedsRecache = (1 << 4), // The next polygon inline of this document rebuilds stored polygon data.
-		NeedsTriangleRecount = (1 << 5),
 	};
 
 	Q_DECLARE_FLAGS(Flags, Flag)
@@ -60,11 +60,9 @@
 	~LDDocument();
 
 	void addHistoryStep();
-	int addObject (LDObject* obj);
 	void addObjects (const LDObjectList& objs);
 	void addToHistory (AbstractHistoryEntry* entry);
 	void addToSelection (LDObject* obj);
-	void clear();
 	void clearHistory();
 	void clearSelection();
 	void close();
@@ -72,14 +70,13 @@
 	void forgetObject (LDObject* obj);
 	QString fullPath();
 	QString getDisplayName();
-	LDObject* getObject (int pos) const;
 	int getObjectCount() const;
-	const LDObjectList& getSelection() const;
+	const QSet<LDObject*>& getSelection() const;
 	LDGLData* glData();
 	bool hasUnsavedChanges() const;
 	EditHistory* history() const;
 	void initializeCachedData();
-	LDObjectList inlineContents (bool deep, bool renderinline);
+	void inlineContents(Model& model, bool deep, bool renderinline);
 	QList<LDPolygon> inlinePolygons();
 	const QSet<Vertex>& inlineVertices();
 	void insertObject (int pos, LDObject* obj);
@@ -87,7 +84,7 @@
 	bool isSafeToClose();
 	QString name() const;
 	void needVertexMerge();
-	const LDObjectList& objects() const;
+	void objectRemoved(LDObject* object, int index);
 	void openForEditing();
 	const QList<LDPolygon>& polygonData() const;
 	void recountTriangles();
@@ -100,22 +97,25 @@
 	void setDefaultName (QString value);
 	void setFullPath (QString value);
 	void setName (QString value);
-	void setObjectAt (int idx, LDObject* obj);
 	void setSavePosition (long value);
 	void setTabIndex (int value);
-	void swapObjects (LDObject* one, LDObject* other);
+	bool swapObjects (LDObject* one, LDObject* other);
 	int tabIndex() const;
-	int triangleCount();
 	void undo();
 	void vertexChanged (const Vertex& a, const Vertex& b);
 
 	static QString shortenName (QString a); // Turns a full path into a relative path
 
+public slots:
+	void objectChanged(int position, QString before, QString after);
+
+protected:
+	LDObject* withdrawAt(int position);
+
 private:
 	QString m_name;
 	QString m_fullPath;
 	QString m_defaultName;
-	LDObjectList m_objects;
 	EditHistory* m_history;
 	Flags m_flags;
 	long m_savePosition;
@@ -124,7 +124,7 @@
 	QList<LDPolygon> m_polygonData;
 	QMap<LDObject*, QSet<Vertex>> m_objectVertices;
 	QSet<Vertex> m_vertices;
-	LDObjectList m_sel;
+	QSet<LDObject*> m_selection;
 	LDGLData* m_gldata;
 	DocumentManager* m_manager;
 

mercurial