src/ldDocument.h

branch
experimental
changeset 891
00d76b281021
parent 890
903ec1e46298
equal deleted inserted replaced
890:903ec1e46298 891:00d76b281021
62 // 62 //
63 class LDDocument : public QObject 63 class LDDocument : public QObject
64 { 64 {
65 public: 65 public:
66 PROPERTY (public, QString, name, setName, STOCK_WRITE) 66 PROPERTY (public, QString, name, setName, STOCK_WRITE)
67 PROPERTY (private, LDObjectList, objects, setObjects, STOCK_WRITE)
68 PROPERTY (private, LDObjectList, cache, setCache, STOCK_WRITE) 67 PROPERTY (private, LDObjectList, cache, setCache, STOCK_WRITE)
69 PROPERTY (private, History*, history, setHistory, STOCK_WRITE) 68 PROPERTY (private, History*, history, setHistory, STOCK_WRITE)
70 PROPERTY (public, QString, fullPath, setFullPath, STOCK_WRITE) 69 PROPERTY (public, QString, fullPath, setFullPath, STOCK_WRITE)
71 PROPERTY (public, QString, defaultName, setDefaultName, STOCK_WRITE) 70 PROPERTY (public, QString, defaultName, setDefaultName, STOCK_WRITE)
72 PROPERTY (public, bool, isImplicit, setImplicit, CUSTOM_WRITE) 71 PROPERTY (public, bool, isImplicit, setImplicit, CUSTOM_WRITE)
88 int addObject (LDObjectPtr obj); // Adds an object to this file at the end of the file. 87 int addObject (LDObjectPtr obj); // Adds an object to this file at the end of the file.
89 void addObjects (const LDObjectList& objs); 88 void addObjects (const LDObjectList& objs);
90 void clearSelection(); 89 void clearSelection();
91 void forgetObject (LDObjectPtr obj); // Deletes the given object from the object chain. 90 void forgetObject (LDObjectPtr obj); // Deletes the given object from the object chain.
92 QString getDisplayName(); 91 QString getDisplayName();
93 const LDObjectList& getSelection() const; 92 const LDObjectList& getSelection();
94 bool hasUnsavedChanges() const; // Does this document have unsaved changes? 93 bool hasUnsavedChanges() const; // Does this document have unsaved changes?
95 void initializeCachedData(); 94 void initializeCachedData();
96 LDObjectList inlineContents (bool deep, bool renderinline); 95 LDObjectList inlineContents (bool deep, bool renderinline);
97 void insertObj (int pos, LDObjectPtr obj); 96 void insertObj (int pos, LDObjectPtr obj);
98 int getObjectCount() const; 97 int getObjectCount() const;
99 LDObjectPtr getObject (int pos) const; 98 LDObjectPtr getObject (int pos);
100 bool save (QString path = "", int64* sizeptr = null); // Saves this file to disk. 99 bool save (QString path = "", int64* sizeptr = null); // Saves this file to disk.
101 void swapObjects (LDObjectPtr one, LDObjectPtr other); 100 void swapObjects (LDObjectPtr one, LDObjectPtr other);
102 bool isSafeToClose(); // Perform safety checks. Do this before closing any files! 101 bool isSafeToClose(); // Perform safety checks. Do this before closing any files!
103 void setObject (int idx, LDObjectPtr obj); 102 void setObject (int idx, LDObjectPtr obj);
104 QList<LDPolygon> inlinePolygons(); 103 QList<LDPolygon> inlinePolygons();
107 void clear(); 106 void clear();
108 void addKnownVertices (LDObjectPtr obj); 107 void addKnownVertices (LDObjectPtr obj);
109 void redoVertices(); 108 void redoVertices();
110 void needVertexMerge(); 109 void needVertexMerge();
111 void reloadAllSubfiles(); 110 void reloadAllSubfiles();
111 void sweepBFC();
112 LDObjectList const& objects();
112 113
113 inline LDDocument& operator<< (LDObjectPtr obj) 114 inline LDDocument& operator<< (LDObjectPtr obj)
114 { 115 {
115 addObject (obj); 116 addObject (obj);
116 return *this; 117 return *this;
142 } 143 }
143 144
144 inline void dismiss() 145 inline void dismiss()
145 { 146 {
146 setImplicit (true); 147 setImplicit (true);
148 }
149
150 inline void requireBFCSweep()
151 {
152 m_needBFCSweep = true;
147 } 153 }
148 154
149 static LDDocumentPtr current(); 155 static LDDocumentPtr current();
150 static void setCurrent (LDDocumentPtr f); 156 static void setCurrent (LDDocumentPtr f);
151 static void closeInitialFile(); 157 static void closeInitialFile();
168 174
169 friend class LDObject; 175 friend class LDObject;
170 friend class GLRenderer; 176 friend class GLRenderer;
171 177
172 private: 178 private:
179 LDObjectList m_objects;
173 LDObjectList m_sel; 180 LDObjectList m_sel;
174 LDGLData* m_gldata; 181 LDGLData* m_gldata;
175 182
176 // If set to true, next polygon inline of this document discards the 183 // If set to true, next polygon inline of this document discards the
177 // stored polygon data and re-builds it. 184 // stored polygon data and re-builds it.
178 bool m_needsReCache; 185 bool m_needsReCache;
186
187 // If set to true, next object reference request causes BFC sweep.
188 bool m_needBFCSweep;
179 }; 189 };
180 190
181 inline LDDocumentPtr CurrentDocument() 191 inline LDDocumentPtr CurrentDocument()
182 { 192 {
183 return LDDocument::current(); 193 return LDDocument::current();

mercurial