49 IsCache = (1 << 0), |
50 IsCache = (1 << 0), |
50 VerticesOutdated = (1 << 1), |
51 VerticesOutdated = (1 << 1), |
51 NeedsVertexMerge = (1 << 2), |
52 NeedsVertexMerge = (1 << 2), |
52 IsBeingDestroyed = (1 << 3), |
53 IsBeingDestroyed = (1 << 3), |
53 NeedsRecache = (1 << 4), // The next polygon inline of this document rebuilds stored polygon data. |
54 NeedsRecache = (1 << 4), // The next polygon inline of this document rebuilds stored polygon data. |
54 NeedsTriangleRecount = (1 << 5), |
|
55 }; |
55 }; |
56 |
56 |
57 Q_DECLARE_FLAGS(Flags, Flag) |
57 Q_DECLARE_FLAGS(Flags, Flag) |
58 |
58 |
59 LDDocument (DocumentManager* parent); |
59 LDDocument (DocumentManager* parent); |
60 ~LDDocument(); |
60 ~LDDocument(); |
61 |
61 |
62 void addHistoryStep(); |
62 void addHistoryStep(); |
63 int addObject (LDObject* obj); |
|
64 void addObjects (const LDObjectList& objs); |
63 void addObjects (const LDObjectList& objs); |
65 void addToHistory (AbstractHistoryEntry* entry); |
64 void addToHistory (AbstractHistoryEntry* entry); |
66 void addToSelection (LDObject* obj); |
65 void addToSelection (LDObject* obj); |
67 void clear(); |
|
68 void clearHistory(); |
66 void clearHistory(); |
69 void clearSelection(); |
67 void clearSelection(); |
70 void close(); |
68 void close(); |
71 QString defaultName() const; |
69 QString defaultName() const; |
72 void forgetObject (LDObject* obj); |
70 void forgetObject (LDObject* obj); |
73 QString fullPath(); |
71 QString fullPath(); |
74 QString getDisplayName(); |
72 QString getDisplayName(); |
75 LDObject* getObject (int pos) const; |
|
76 int getObjectCount() const; |
73 int getObjectCount() const; |
77 const LDObjectList& getSelection() const; |
74 const QSet<LDObject*>& getSelection() const; |
78 LDGLData* glData(); |
75 LDGLData* glData(); |
79 bool hasUnsavedChanges() const; |
76 bool hasUnsavedChanges() const; |
80 EditHistory* history() const; |
77 EditHistory* history() const; |
81 void initializeCachedData(); |
78 void initializeCachedData(); |
82 LDObjectList inlineContents (bool deep, bool renderinline); |
79 void inlineContents(Model& model, bool deep, bool renderinline); |
83 QList<LDPolygon> inlinePolygons(); |
80 QList<LDPolygon> inlinePolygons(); |
84 const QSet<Vertex>& inlineVertices(); |
81 const QSet<Vertex>& inlineVertices(); |
85 void insertObject (int pos, LDObject* obj); |
82 void insertObject (int pos, LDObject* obj); |
86 bool isCache() const; |
83 bool isCache() const; |
87 bool isSafeToClose(); |
84 bool isSafeToClose(); |
88 QString name() const; |
85 QString name() const; |
89 void needVertexMerge(); |
86 void needVertexMerge(); |
90 const LDObjectList& objects() const; |
87 void objectRemoved(LDObject* object, int index); |
91 void openForEditing(); |
88 void openForEditing(); |
92 const QList<LDPolygon>& polygonData() const; |
89 const QList<LDPolygon>& polygonData() const; |
93 void recountTriangles(); |
90 void recountTriangles(); |
94 void redo(); |
91 void redo(); |
95 void redoVertices(); |
92 void redoVertices(); |
98 bool save (QString path = "", int64* sizeptr = nullptr); |
95 bool save (QString path = "", int64* sizeptr = nullptr); |
99 long savePosition() const; |
96 long savePosition() const; |
100 void setDefaultName (QString value); |
97 void setDefaultName (QString value); |
101 void setFullPath (QString value); |
98 void setFullPath (QString value); |
102 void setName (QString value); |
99 void setName (QString value); |
103 void setObjectAt (int idx, LDObject* obj); |
|
104 void setSavePosition (long value); |
100 void setSavePosition (long value); |
105 void setTabIndex (int value); |
101 void setTabIndex (int value); |
106 void swapObjects (LDObject* one, LDObject* other); |
102 bool swapObjects (LDObject* one, LDObject* other); |
107 int tabIndex() const; |
103 int tabIndex() const; |
108 int triangleCount(); |
|
109 void undo(); |
104 void undo(); |
110 void vertexChanged (const Vertex& a, const Vertex& b); |
105 void vertexChanged (const Vertex& a, const Vertex& b); |
111 |
106 |
112 static QString shortenName (QString a); // Turns a full path into a relative path |
107 static QString shortenName (QString a); // Turns a full path into a relative path |
113 |
108 |
|
109 public slots: |
|
110 void objectChanged(int position, QString before, QString after); |
|
111 |
|
112 protected: |
|
113 LDObject* withdrawAt(int position); |
|
114 |
114 private: |
115 private: |
115 QString m_name; |
116 QString m_name; |
116 QString m_fullPath; |
117 QString m_fullPath; |
117 QString m_defaultName; |
118 QString m_defaultName; |
118 LDObjectList m_objects; |
|
119 EditHistory* m_history; |
119 EditHistory* m_history; |
120 Flags m_flags; |
120 Flags m_flags; |
121 long m_savePosition; |
121 long m_savePosition; |
122 int m_tabIndex; |
122 int m_tabIndex; |
123 int m_triangleCount; |
123 int m_triangleCount; |
124 QList<LDPolygon> m_polygonData; |
124 QList<LDPolygon> m_polygonData; |
125 QMap<LDObject*, QSet<Vertex>> m_objectVertices; |
125 QMap<LDObject*, QSet<Vertex>> m_objectVertices; |
126 QSet<Vertex> m_vertices; |
126 QSet<Vertex> m_vertices; |
127 LDObjectList m_sel; |
127 QSet<LDObject*> m_selection; |
128 LDGLData* m_gldata; |
128 LDGLData* m_gldata; |
129 DocumentManager* m_manager; |
129 DocumentManager* m_manager; |
130 |
130 |
131 DEFINE_FLAG_ACCESS_METHODS(m_flags) |
131 DEFINE_FLAG_ACCESS_METHODS(m_flags) |
132 void addKnownVertices (LDObject* obj); |
132 void addKnownVertices (LDObject* obj); |