Fri, 16 Mar 2018 11:50:35 +0200
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1072 | 3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #pragma once |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QObject> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "main.h" |
1147
a26568aa3cce
Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
22 | #include "linetypes/modelobject.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "editHistory.h" |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
24 | #include "glShared.h" |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
25 | #include "model.h" |
1159
6ad8cdcd88d9
print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
26 | #include "hierarchyelement.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | struct LDGLData; |
997
1b49f34e533d
Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
29 | class DocumentManager; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
1287
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
31 | struct LDHeader |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
32 | { |
1288
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
33 | struct HistoryEntry |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
34 | { |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
35 | QDate date; |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
36 | QString author; |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
37 | QString description; |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
38 | enum { UserName, RealName } authorType = UserName; |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
39 | }; |
1287
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
40 | enum FileType |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
41 | { |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
42 | Part, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
43 | Subpart, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
44 | Shortcut, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
45 | Primitive, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
46 | Primitive_8, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
47 | Primitive_48, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
48 | Configuration, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
49 | } type = Part; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
50 | enum Qualifier |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
51 | { |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
52 | Alias = 1 << 0, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
53 | Physical_Color = 1 << 1, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
54 | Flexible_Section = 1 << 2, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
55 | }; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
56 | QFlags<Qualifier> qualfiers; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
57 | QString description; |
1288
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
58 | QString name; |
1287
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
59 | struct |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
60 | { |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
61 | QString realName; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
62 | QString userName; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
63 | } author; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
64 | QString category; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
65 | QString cmdline; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
66 | QStringList help; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
67 | QStringList keywords; |
1288
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
68 | QVector<HistoryEntry> history; |
1287
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
69 | enum |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
70 | { |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
71 | NoWinding, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
72 | CounterClockwise, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
73 | Clockwise, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
74 | } winding = NoWinding; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
75 | enum |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
76 | { |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
77 | CaLicense, |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
78 | NonCaLicense |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
79 | } license = CaLicense; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
80 | }; |
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
81 | |
1288
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
82 | Q_DECLARE_OPERATORS_FOR_FLAGS(QFlags<LDHeader::Qualifier>) |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
83 | |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
84 | decltype(LDHeader::winding) operator^( |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
85 | decltype(LDHeader::winding) one, |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
86 | decltype(LDHeader::winding) other |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
87 | ); |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
88 | |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
89 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | // This class stores a document either as a editable file for the user or for |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
91 | // subfile caching. |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | // |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
93 | // A document is implicit when they are opened automatically for caching purposes |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | // and are hidden from the user. User-opened files are explicit (not implicit). |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | // The default name is a placeholder, initially suggested name for a file. The |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | // primitive generator uses this to give initial names to primitives. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | // |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1102
diff
changeset
|
99 | class LDDocument : public Model, public HierarchyElement |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
101 | Q_OBJECT |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | |
794 | 103 | public: |
997
1b49f34e533d
Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
104 | LDDocument (DocumentManager* parent); |
794 | 105 | ~LDDocument(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
107 | void addHistoryStep(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
108 | void clearHistory(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
109 | void close(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
110 | QString defaultName() const; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
111 | QString fullPath(); |
794 | 112 | QString getDisplayName(); |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
113 | bool hasUnsavedChanges() const; |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
980
diff
changeset
|
114 | EditHistory* history() const; |
794 | 115 | void initializeCachedData(); |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
116 | void inlineContents(Model& model, bool deep, bool renderinline); |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
117 | QList<LDPolygon> inlinePolygons(); |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
118 | const QSet<Vertex>& inlineVertices(); |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
119 | bool isFrozen() const; |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
120 | bool isSafeToClose(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
121 | QString name() const; |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
122 | void objectRemoved(LDObject* object, int index); |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
123 | const QList<LDPolygon>& polygonData() const; |
1017
fc1c13db9618
Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1015
diff
changeset
|
124 | void recountTriangles(); |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
125 | void redo(); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
126 | void redoVertices(); |
1135
8e0691be0b6f
Removed the intXX type aliases and removed uses of intXX_t in favor of qintXX
Teemu Piippo <teemu@hecknology.net>
parents:
1118
diff
changeset
|
127 | bool save (QString path = "", qint64* sizeptr = nullptr); |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
128 | long savePosition() const; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
129 | void setDefaultName (QString value); |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
130 | void setFrozen(bool value); |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
131 | void setFullPath (QString value); |
1288
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1287
diff
changeset
|
132 | void setHeader(LDHeader&& header); |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
133 | void setName (QString value); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
134 | void setSavePosition (long value); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
135 | void setTabIndex (int value); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
136 | int tabIndex() const; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
137 | void undo(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
138 | void vertexChanged (const Vertex& a, const Vertex& b); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
140 | static QString shortenName (QString a); // Turns a full path into a relative path |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
142 | protected: |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
143 | LDObject* withdrawAt(int position); |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
144 | |
794 | 145 | private: |
1287
f1da43b7f5c6
begin work on document loading rework
Teemu Piippo <teemu@hecknology.net>
parents:
1286
diff
changeset
|
146 | LDHeader m_header; |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
147 | QString m_name; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
148 | QString m_fullPath; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
149 | QString m_defaultName; |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
980
diff
changeset
|
150 | EditHistory* m_history; |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
151 | bool m_isFrozen = true; // Document may not be modified |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
152 | bool m_verticesOutdated = true; |
1275 | 153 | bool m_isBeingDestroyed = false; |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
154 | bool m_needsRecache = true; // The next polygon inline of this document rebuilds stored polygon data. |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
155 | long m_savePosition; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
156 | int m_tabIndex; |
1015
92c6ec099075
Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
157 | int m_triangleCount; |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
158 | QList<LDPolygon> m_polygonData; |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
159 | QMap<LDObject*, QSet<Vertex>> m_objectVertices; |
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
160 | QSet<Vertex> m_vertices; |
997
1b49f34e533d
Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
161 | DocumentManager* m_manager; |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
162 | |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
163 | template<typename T, typename... Args> |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
164 | void addToHistory(Args&&... args) |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
165 | { |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
166 | m_history->add<T>(args...); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
167 | } |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
168 | |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
169 | private slots: |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
170 | void objectChanged(const LDObjectState &before, const LDObjectState &after); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
171 | void handleNewObject(const QModelIndex& index); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
172 | void handleImminentObjectRemoval(const QModelIndex& index); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | // Parses a string line containing an LDraw object and returns the object parsed. |
944 | 176 | LDObject* ParseLine (QString line); |