Thu, 20 Jun 2019 08:54:35 +0300
uuid things
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
1 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1326 | 3 | * Copyright (C) 2013 - 2018 Teemu Piippo |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
4 | * |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
8 | * (at your option) any later version. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
9 | * |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
13 | * GNU General Public License for more details. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
14 | * |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
17 | */ |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
18 | |
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:
diff
changeset
|
19 | #include "model.h" |
1147
a26568aa3cce
Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1141
diff
changeset
|
20 | #include "linetypes/modelobject.h" |
1079
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
21 | #include "documentmanager.h" |
1273
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
22 | #include "generics/migrate.h" |
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
|
23 | #include "editHistory.h" |
1365
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
24 | #include "lddocument.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:
diff
changeset
|
25 | |
1079
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
26 | Model::Model(DocumentManager* manager) : |
1240
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
27 | QAbstractListModel {manager}, |
1079
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
28 | _manager {manager} {} |
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:
diff
changeset
|
29 | |
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:
diff
changeset
|
30 | Model::~Model() |
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:
diff
changeset
|
31 | { |
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:
diff
changeset
|
32 | for (int i = 0; i < countof(_objects); ++i) |
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:
diff
changeset
|
33 | delete _objects[i]; |
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:
diff
changeset
|
34 | } |
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:
diff
changeset
|
35 | |
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
|
36 | void Model::installObject(int row, LDObject* object) |
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:
diff
changeset
|
37 | { |
1377
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
38 | connect( |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
39 | object, |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
40 | &LDObject::modified, |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
41 | [&]() |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
42 | { |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
43 | this->recountTriangles(); |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
44 | emit objectModified(static_cast<LDObject*>(sender())); |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
45 | emit modelChanged(); |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
46 | } |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
47 | ); |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
48 | |
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
|
49 | beginInsertRows({}, row, row); |
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
|
50 | _objects.insert(row, object); |
1440 | 51 | _objectsById[object->id] = object; |
1278
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
52 | |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
53 | if (this->pickingColorCursor <= 0xffffff) |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
54 | { |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
55 | this->pickingColors[object] = this->pickingColorCursor; |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
56 | this->pickingColorCursor += 1; |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
57 | } |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
58 | |
1281 | 59 | _triangleCount += object->triangleCount(documentManager()); |
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
|
60 | emit objectAdded(index(row)); |
1377
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
61 | emit modelChanged(); |
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
|
62 | endInsertRows(); |
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:
diff
changeset
|
63 | } |
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:
diff
changeset
|
64 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
65 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
66 | * Returns the amount of objects in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
67 | */ |
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:
diff
changeset
|
68 | int Model::size() const |
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:
diff
changeset
|
69 | { |
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:
diff
changeset
|
70 | return _objects.size(); |
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:
diff
changeset
|
71 | } |
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:
diff
changeset
|
72 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
73 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
74 | * Returns the vector of objects in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
75 | */ |
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:
diff
changeset
|
76 | const QVector<LDObject*>& Model::objects() const |
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:
diff
changeset
|
77 | { |
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:
diff
changeset
|
78 | return _objects; |
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:
diff
changeset
|
79 | } |
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:
diff
changeset
|
80 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
81 | /* |
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
|
82 | * Takes an existing object and copies it to this model, at the specified position. |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
83 | */ |
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
|
84 | void Model::insertCopy(int position, LDObject* object) |
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:
diff
changeset
|
85 | { |
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
|
86 | installObject(position, Serializer::clone(object)); |
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
|
87 | } |
1261
5d2c9d36da9d
Removed LDObject::invert, inversion code moved to basic toolset
Santeri Piippo
parents:
1258
diff
changeset
|
88 | |
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
|
89 | void Model::insertFromArchive(int row, Serializer::Archive& archive) |
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
|
90 | { |
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
|
91 | LDObject* object = Serializer::restore(archive); |
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:
diff
changeset
|
92 | |
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
|
93 | if (object) |
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
|
94 | installObject(row, object); |
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:
diff
changeset
|
95 | } |
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:
diff
changeset
|
96 | |
1273
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
97 | bool Model::moveRows( |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
98 | const QModelIndex&, |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
99 | int sourceRow, |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
100 | int count, |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
101 | const QModelIndex&, |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
102 | int destinationRow |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
103 | ) { |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
104 | int sourceRowLast = sourceRow + count - 1; |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
105 | |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
106 | if (range(0, 1, size() - count).contains(sourceRow) |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
107 | and range(0, 1, size()).contains(destinationRow) |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
108 | ) { |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
109 | beginMoveRows({}, sourceRow, sourceRowLast, {}, destinationRow); |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
110 | migrate(_objects, sourceRow, sourceRowLast, destinationRow); |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
111 | endMoveRows(); |
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:
diff
changeset
|
112 | return true; |
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:
diff
changeset
|
113 | } |
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:
diff
changeset
|
114 | else |
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:
diff
changeset
|
115 | { |
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:
diff
changeset
|
116 | return false; |
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:
diff
changeset
|
117 | } |
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:
diff
changeset
|
118 | } |
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:
diff
changeset
|
119 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
120 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
121 | * Assigns a new object to the specified position in the model. The object that already is in the position is deleted in the process. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
122 | */ |
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
|
123 | bool Model::setObjectAt(int row, Serializer::Archive& archive) |
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:
diff
changeset
|
124 | { |
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
|
125 | LDObject* object = Serializer::restore(archive); |
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
|
126 | |
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
|
127 | if (object and row >= 0 and row < countof(_objects)) |
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:
diff
changeset
|
128 | { |
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
|
129 | removeAt(row); |
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
|
130 | insertCopy(row, object); |
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
|
131 | return true; |
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:
diff
changeset
|
132 | } |
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:
diff
changeset
|
133 | else |
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:
diff
changeset
|
134 | { |
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
|
135 | return false; |
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:
diff
changeset
|
136 | } |
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:
diff
changeset
|
137 | } |
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:
diff
changeset
|
138 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
139 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
140 | * Returns the object at the specified position, or null if not found. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
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:
diff
changeset
|
142 | LDObject* Model::getObject(int position) const |
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:
diff
changeset
|
143 | { |
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:
diff
changeset
|
144 | if (position >= 0 and position < countof(_objects)) |
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:
diff
changeset
|
145 | return _objects[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:
diff
changeset
|
146 | else |
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:
diff
changeset
|
147 | return nullptr; |
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:
diff
changeset
|
148 | } |
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:
diff
changeset
|
149 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
150 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
151 | * Removes the given object from the model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
152 | */ |
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:
diff
changeset
|
153 | void Model::remove(LDObject* object) |
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:
diff
changeset
|
154 | { |
1258 | 155 | int position = indexOf(object).row(); |
156 | ||
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:
diff
changeset
|
157 | if (_objects[position] == object) |
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:
diff
changeset
|
158 | removeAt(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:
diff
changeset
|
159 | } |
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:
diff
changeset
|
160 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
161 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
162 | * Removes the object at the provided position. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
163 | */ |
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:
diff
changeset
|
164 | void Model::removeAt(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:
diff
changeset
|
165 | { |
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
|
166 | beginRemoveRows({}, position, position); |
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 | LDObject* object = _objects[position]; |
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 | emit aboutToRemoveObject(this->index(position)); |
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 | _objects.removeAt(position); |
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 | _needsTriangleRecount = true; |
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 | endRemoveRows(); |
1377
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
172 | emit modelChanged(); |
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:
diff
changeset
|
173 | delete object; |
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:
diff
changeset
|
174 | } |
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:
diff
changeset
|
175 | |
1249 | 176 | void Model::removeAt(const QModelIndex& index) |
177 | { | |
178 | removeAt(index.row()); | |
179 | } | |
180 | ||
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
181 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
182 | * Replaces the given object with the contents of a model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
183 | */ |
1258 | 184 | void Model::replace(LDObject* object, Model& model) |
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:
diff
changeset
|
185 | { |
1258 | 186 | QModelIndex index = this->indexOf(object); |
187 | ||
188 | if (index.isValid()) | |
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:
diff
changeset
|
189 | { |
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
|
190 | removeAt(index.row()); |
1369
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1365
diff
changeset
|
191 | int position = index.row(); |
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:
diff
changeset
|
192 | |
1369
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1365
diff
changeset
|
193 | for (signed int i = 0; i < countof(model); i += 1) |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1365
diff
changeset
|
194 | insertCopy(position + i, model.objects()[i]); |
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:
diff
changeset
|
195 | } |
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:
diff
changeset
|
196 | } |
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:
diff
changeset
|
197 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
198 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
199 | * Signals the model to recount its triangles. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
200 | */ |
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:
diff
changeset
|
201 | void Model::recountTriangles() |
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:
diff
changeset
|
202 | { |
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:
diff
changeset
|
203 | _needsTriangleRecount = true; |
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:
diff
changeset
|
204 | } |
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:
diff
changeset
|
205 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
206 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
207 | * Returns the triangle count in the model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
208 | */ |
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:
diff
changeset
|
209 | int Model::triangleCount() const |
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:
diff
changeset
|
210 | { |
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:
diff
changeset
|
211 | if (_needsTriangleRecount) |
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:
diff
changeset
|
212 | { |
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:
diff
changeset
|
213 | _triangleCount = 0; |
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:
diff
changeset
|
214 | |
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:
diff
changeset
|
215 | for (LDObject* object : objects()) |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1261
diff
changeset
|
216 | _triangleCount += object->triangleCount(documentManager()); |
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:
diff
changeset
|
217 | |
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:
diff
changeset
|
218 | _needsTriangleRecount = false; |
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:
diff
changeset
|
219 | } |
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:
diff
changeset
|
220 | |
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:
diff
changeset
|
221 | return _triangleCount; |
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:
diff
changeset
|
222 | } |
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:
diff
changeset
|
223 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
224 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
225 | * Merges the given model into this model, starting at the given position. The other model is emptied in the process. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
226 | */ |
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:
diff
changeset
|
227 | void Model::merge(Model& other, 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:
diff
changeset
|
228 | { |
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:
diff
changeset
|
229 | if (position < 0) |
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:
diff
changeset
|
230 | position = countof(_objects); |
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:
diff
changeset
|
231 | |
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:
diff
changeset
|
232 | // Copy the vector of objects to copy, so that we don't change the vector while iterating over it. |
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:
diff
changeset
|
233 | QVector<LDObject*> objectsCopy = other._objects; |
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:
diff
changeset
|
234 | |
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:
diff
changeset
|
235 | // Inform the contents of their new owner |
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:
diff
changeset
|
236 | for (LDObject* object : objectsCopy) |
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:
diff
changeset
|
237 | { |
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
|
238 | insertCopy(position, object); |
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:
diff
changeset
|
239 | position += 1; |
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:
diff
changeset
|
240 | } |
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:
diff
changeset
|
241 | |
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:
diff
changeset
|
242 | other.clear(); |
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:
diff
changeset
|
243 | } |
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:
diff
changeset
|
244 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
245 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
246 | * Returns the begin-iterator into this model, so that models can be used in foreach-loops. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
247 | */ |
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:
diff
changeset
|
248 | QVector<LDObject*>::iterator Model::begin() |
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:
diff
changeset
|
249 | { |
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:
diff
changeset
|
250 | return _objects.begin(); |
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:
diff
changeset
|
251 | } |
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:
diff
changeset
|
252 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
253 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
254 | * Returns the end-iterator into this mode, so that models can be used in foreach-loops. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
255 | */ |
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:
diff
changeset
|
256 | QVector<LDObject*>::iterator Model::end() |
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:
diff
changeset
|
257 | { |
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:
diff
changeset
|
258 | return _objects.end(); |
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:
diff
changeset
|
259 | } |
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:
diff
changeset
|
260 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
261 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
262 | * Removes all objects in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
263 | */ |
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:
diff
changeset
|
264 | void Model::clear() |
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:
diff
changeset
|
265 | { |
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:
diff
changeset
|
266 | for (int i = _objects.size() - 1; i >= 0; i -= 1) |
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:
diff
changeset
|
267 | removeAt(i); |
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:
diff
changeset
|
268 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
269 | _triangleCount = 0; |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
270 | _needsTriangleRecount = false; |
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:
diff
changeset
|
271 | } |
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:
diff
changeset
|
272 | |
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:
diff
changeset
|
273 | /* |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
274 | * Returns whether or not this model is empty. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
275 | */ |
1077
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
276 | bool Model::isEmpty() const |
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
277 | { |
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
278 | return _objects.isEmpty(); |
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
279 | } |
1079
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
280 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
281 | /* |
1258 | 282 | * Returns an index that corresponds to the given object |
283 | */ | |
284 | QModelIndex Model::indexOf(LDObject* object) const | |
285 | { | |
286 | for (int i = 0; i < this->size(); ++i) | |
287 | { | |
288 | if (this->getObject(i) == object) | |
289 | return index(i); | |
290 | } | |
291 | ||
292 | return {}; | |
293 | } | |
294 | ||
295 | /* | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
296 | * Returns the model's associated document manager. This pointer is used to resolve subfile references. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
297 | */ |
1079
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
298 | DocumentManager* Model::documentManager() const |
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
299 | { |
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
300 | return _manager; |
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
301 | } |
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
302 | |
1244 | 303 | IndexGenerator Model::indices() const |
304 | { | |
305 | return {this}; | |
306 | } | |
307 | ||
1240
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
308 | int Model::rowCount(const QModelIndex&) const |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
309 | { |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
310 | return this->objects().size(); |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
311 | } |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
312 | |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
313 | QVariant Model::data(const QModelIndex& index, int role) const |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
314 | { |
1425
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
315 | static QMap<QString, QPixmap> scaledIcons; |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
316 | |
1244 | 317 | if (index.row() < 0 or index.row() >= size()) |
318 | return {}; | |
319 | ||
1240
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
320 | LDObject* object = this->objects()[index.row()]; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
321 | |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
322 | switch (role) |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
323 | { |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
324 | case Qt::DisplayRole: |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
325 | { |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
326 | QString result = object->objectListText(); |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
327 | |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
328 | if (object->isInverted()) |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
329 | result.prepend("↺ "); |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
330 | |
1365
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
331 | if (object->type() == LDObjectType::SubfileReference) |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
332 | { |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
333 | LDSubfileReference* reference = static_cast<LDSubfileReference*>(object); |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
334 | LDDocument* subfile = reference->fileInfo(this->documentManager()); |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
335 | if (subfile != nullptr) |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
336 | result.prepend(subfile->header.description + "\n"); |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
337 | } |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
338 | |
1240
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
339 | return result; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
340 | } |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
341 | |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
342 | case Qt::DecorationRole: |
1425
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
343 | { |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
344 | QString iconName = object->iconName(); |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
345 | auto it = scaledIcons.find(iconName); |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
346 | if (it == scaledIcons.end()) |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
347 | { |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
348 | QPixmap pixmap = MainWindow::getIcon(object->iconName()) |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
349 | .scaled({24, 24}, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
350 | it = scaledIcons.insert(iconName, pixmap); |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
351 | } |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
352 | return *it; |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
353 | } |
1240
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
354 | |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
355 | case Qt::BackgroundColorRole: |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
356 | if (object->type() == LDObjectType::Error) |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
357 | return QColor {"#AA0000"}; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
358 | else |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
359 | return {}; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
360 | |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
361 | case Qt::ForegroundRole: |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
362 | if (object->type() == LDObjectType::Error) |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
363 | { |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
364 | return QColor {"#FFAA00"}; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
365 | } |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
366 | else if ( |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
367 | object->isColored() |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
368 | and object->color().isValid() |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
369 | and object->color() != MainColor |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
370 | and object->color() != EdgeColor |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
371 | ) { |
1244 | 372 | // If the object isn't in the main or edge color, draw this list |
373 | // entry in that color. | |
1240
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
374 | return object->color().faceColor(); |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
375 | } |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
376 | else |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
377 | { |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
378 | return {}; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
379 | } |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
380 | |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
381 | case Qt::FontRole: |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
382 | if (object->isHidden()) |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
383 | { |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
384 | QFont font; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
385 | font.setItalic(true); |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
386 | return font; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
387 | } |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
388 | else |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
389 | { |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
390 | return {}; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
391 | } |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
392 | |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
393 | default: |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
394 | return {}; |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
395 | } |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
396 | } |
cebb7ef54f41
changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents:
1149
diff
changeset
|
397 | |
1245 | 398 | /* |
1244 | 399 | bool Model::removeRows(int row, int count, const QModelIndex& parent) |
400 | { | |
401 | if (row >= 0 and row < size() and count <= size() - row) | |
402 | { | |
403 | beginRemoveRows(parent, row, row + count - 1); | |
404 | ||
405 | for (signed int i = row + count - 1; i >= row; i -= 1) | |
406 | this->removeAt(i); | |
407 | ||
408 | endRemoveRows(); | |
409 | return true; | |
410 | } | |
411 | else | |
412 | { | |
413 | return false; | |
414 | } | |
415 | } | |
1245 | 416 | */ |
417 | ||
418 | /* | |
419 | * Looks up an object by the given index. | |
420 | */ | |
1440 | 421 | LDObject* Model::lookup(const Uuid& id) const |
1245 | 422 | { |
1440 | 423 | return _objectsById.value(id, nullptr); |
1245 | 424 | } |
1244 | 425 | |
1440 | 426 | QColor Model::pickingColorForObject(const Uuid& id) const |
1247 | 427 | { |
1440 | 428 | return QColor::fromRgba(this->pickingColors.value(this->lookup(id)) | 0xff000000); |
1278
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
429 | } |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
430 | |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
431 | QModelIndex Model::objectByPickingColor(const QColor& color) const |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
432 | { |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
433 | if (color != qRgb(0, 0, 0)) |
1247 | 434 | { |
1278
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
435 | for (int row = 0; row < this->size(); row += 1) |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
436 | { |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
437 | if (this->pickingColorForObject(this->index(row)) == color) |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
438 | return this->index(row); |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
439 | } |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
440 | |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
441 | return {}; |
1247 | 442 | } |
1278
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
443 | else |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
444 | { |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
445 | return {}; |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
446 | } |
1247 | 447 | } |
448 | ||
1306
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
449 | Winding Model::winding() const |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
450 | { |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
451 | return this->_winding; |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
452 | } |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
453 | |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
454 | void Model::setWinding(Winding winding) |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
455 | { |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
456 | this->_winding = winding; |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
457 | emit windingChanged(this->_winding); |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
458 | } |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
459 | |
1087
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
460 | int countof(Model& model) |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
461 | { |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
462 | return model.size(); |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
463 | } |