src/ldDocument.h

changeset 1017
fc1c13db9618
parent 1015
92c6ec099075
child 1031
55c0d3beea0d
equal deleted inserted replaced
1016:3b279b5e57d3 1017:fc1c13db9618
42 class LDDocument : public QObject, public HierarchyElement 42 class LDDocument : public QObject, public HierarchyElement
43 { 43 {
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 enum Flag
48 {
49 IsCache = (1 << 0),
50 VerticesOutdated = (1 << 1),
51 NeedsVertexMerge = (1 << 2),
52 IsBeingDestroyed = (1 << 3),
53 NeedsRecache = (1 << 4), // The next polygon inline of this document rebuilds stored polygon data.
54 NeedsTriangleRecount = (1 << 5),
55 };
56
57 Q_DECLARE_FLAGS(Flags, Flag)
58
47 LDDocument (DocumentManager* parent); 59 LDDocument (DocumentManager* parent);
48 ~LDDocument(); 60 ~LDDocument();
49 61
50 void addHistoryStep(); 62 void addHistoryStep();
51 void addKnownVertices (LDObject* obj);
52 int addObject (LDObject* obj); 63 int addObject (LDObject* obj);
53 void addObjects (const LDObjectList& objs); 64 void addObjects (const LDObjectList& objs);
54 void addToHistory (AbstractHistoryEntry* entry); 65 void addToHistory (AbstractHistoryEntry* entry);
55 void addToSelection (LDObject* obj); 66 void addToSelection (LDObject* obj);
56 void clear(); 67 void clear();
69 EditHistory* history() const; 80 EditHistory* history() const;
70 void initializeCachedData(); 81 void initializeCachedData();
71 LDObjectList inlineContents (bool deep, bool renderinline); 82 LDObjectList inlineContents (bool deep, bool renderinline);
72 QList<LDPolygon> inlinePolygons(); 83 QList<LDPolygon> inlinePolygons();
73 const QVector<Vertex>& inlineVertices(); 84 const QVector<Vertex>& inlineVertices();
74 void insertObj (int pos, LDObject* obj); 85 void insertObject (int pos, LDObject* obj);
75 bool isCache() const; 86 bool isCache() const;
76 bool isSafeToClose(); 87 bool isSafeToClose();
77 void mergeVertices();
78 QString name() const; 88 QString name() const;
79 void needVertexMerge(); 89 void needVertexMerge();
80 void needRecount();
81 const LDObjectList& objects() const; 90 const LDObjectList& objects() const;
82 void openForEditing(); 91 void openForEditing();
83 const QList<LDPolygon>& polygonData() const; 92 const QList<LDPolygon>& polygonData() const;
93 void recountTriangles();
84 void redo(); 94 void redo();
85 void redoVertices(); 95 void redoVertices();
86 void reloadAllSubfiles(); 96 void reloadAllSubfiles();
87 void removeFromSelection (LDObject* obj); 97 void removeFromSelection (LDObject* obj);
88 bool save (QString path = "", int64* sizeptr = nullptr); 98 bool save (QString path = "", int64* sizeptr = nullptr);
89 long savePosition() const; 99 long savePosition() const;
90 void setDefaultName (QString value); 100 void setDefaultName (QString value);
91 void setFullPath (QString value); 101 void setFullPath (QString value);
92 void setImplicit (bool value);
93 void setName (QString value); 102 void setName (QString value);
94 void setObject (int idx, LDObject* obj); 103 void setObjectAt (int idx, LDObject* obj);
95 void setSavePosition (long value); 104 void setSavePosition (long value);
96 void setTabIndex (int value); 105 void setTabIndex (int value);
97 void swapObjects (LDObject* one, LDObject* other); 106 void swapObjects (LDObject* one, LDObject* other);
98 int tabIndex() const; 107 int tabIndex() const;
99 int triangleCount(); 108 int triangleCount();
106 QString m_name; 115 QString m_name;
107 QString m_fullPath; 116 QString m_fullPath;
108 QString m_defaultName; 117 QString m_defaultName;
109 LDObjectList m_objects; 118 LDObjectList m_objects;
110 EditHistory* m_history; 119 EditHistory* m_history;
111 bool m_isCache; 120 Flags m_flags;
112 bool m_verticesOutdated;
113 bool m_needVertexMerge;
114 bool m_needsReCache; // If true, next polygon inline of this document rebuilds stored polygon data.
115 bool m_beingDestroyed;
116 bool m_needRecount;
117 long m_savePosition; 121 long m_savePosition;
118 int m_tabIndex; 122 int m_tabIndex;
119 int m_triangleCount; 123 int m_triangleCount;
120 QList<LDPolygon> m_polygonData; 124 QList<LDPolygon> m_polygonData;
121 QMap<LDObject*, QVector<Vertex>> m_objectVertices; 125 QMap<LDObject*, QVector<Vertex>> m_objectVertices;
122 QVector<Vertex> m_vertices; 126 QVector<Vertex> m_vertices;
123 LDObjectList m_sel; 127 LDObjectList m_sel;
124 LDGLData* m_gldata; 128 LDGLData* m_gldata;
125 DocumentManager* m_manager; 129 DocumentManager* m_manager;
130
131 DEFINE_FLAG_ACCESS_METHODS
132 void addKnownVertices (LDObject* obj);
133 void mergeVertices();
126 }; 134 };
135
136 Q_DECLARE_OPERATORS_FOR_FLAGS(LDDocument::Flags)
127 137
128 // Parses a string line containing an LDraw object and returns the object parsed. 138 // Parses a string line containing an LDraw object and returns the object parsed.
129 LDObject* ParseLine (QString line); 139 LDObject* ParseLine (QString line);

mercurial