Sat, 23 Jun 2018 13:57:04 +0300
added icons for circular primitives and enhanced some existing ones
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); |
1278
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
51 | |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
52 | if (this->pickingColorCursor <= 0xffffff) |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
53 | { |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
54 | this->pickingColors[object] = this->pickingColorCursor; |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
55 | this->pickingColorCursor += 1; |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
56 | } |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
57 | |
1281 | 58 | _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
|
59 | 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
|
60 | 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
|
61 | 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
|
62 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
64 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
65 | * Returns the amount of objects in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
66 | */ |
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
|
67 | 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
|
68 | { |
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 | 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
|
70 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
72 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
73 | * Returns the vector of objects in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
74 | */ |
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
|
75 | 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
|
76 | { |
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 | 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
|
78 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
80 | /* |
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
|
81 | * 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
|
82 | */ |
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
|
83 | 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
|
84 | { |
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
|
85 | 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
|
86 | } |
1261
5d2c9d36da9d
Removed LDObject::invert, inversion code moved to basic toolset
Santeri Piippo
parents:
1258
diff
changeset
|
87 | |
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
|
88 | 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
|
89 | { |
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 | 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
|
91 | |
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
|
92 | 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
|
93 | 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
|
94 | } |
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 | |
1273
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
96 | bool Model::moveRows( |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
97 | const QModelIndex&, |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
98 | int sourceRow, |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
99 | int count, |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
100 | const QModelIndex&, |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
101 | int destinationRow |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
102 | ) { |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
103 | int sourceRowLast = sourceRow + count - 1; |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
104 | |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
105 | 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
|
106 | 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
|
107 | ) { |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
108 | beginMoveRows({}, sourceRow, sourceRowLast, {}, destinationRow); |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
109 | migrate(_objects, sourceRow, sourceRowLast, destinationRow); |
900f1dfae46b
Implemented row moving in the model and replaced swapping with it
Santeri Piippo
parents:
1272
diff
changeset
|
110 | 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
|
111 | 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
|
112 | } |
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 | 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
|
114 | { |
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 | 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
|
116 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
119 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
120 | * 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
|
121 | */ |
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
|
122 | 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
|
123 | { |
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
|
124 | 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
|
125 | |
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 | 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
|
127 | { |
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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | } |
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 | 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
|
133 | { |
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
|
134 | 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
|
135 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
138 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
139 | * 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
|
140 | */ |
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
|
141 | 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
|
142 | { |
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 | 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
|
144 | 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
|
145 | 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
|
146 | 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
|
147 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
149 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
150 | * Removes the given object from the model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
151 | */ |
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
|
152 | 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
|
153 | { |
1258 | 154 | int position = indexOf(object).row(); |
155 | ||
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
|
156 | 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
|
157 | 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
|
158 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
160 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
161 | * Removes the object at the provided position. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
162 | */ |
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
|
163 | 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
|
164 | { |
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
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | _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
|
169 | _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
|
170 | endRemoveRows(); |
1377
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
171 | 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
|
172 | 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
|
173 | } |
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 | |
1249 | 175 | void Model::removeAt(const QModelIndex& index) |
176 | { | |
177 | removeAt(index.row()); | |
178 | } | |
179 | ||
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
180 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
181 | * 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
|
182 | */ |
1258 | 183 | 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
|
184 | { |
1258 | 185 | QModelIndex index = this->indexOf(object); |
186 | ||
187 | 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
|
188 | { |
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
|
189 | removeAt(index.row()); |
1369
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1365
diff
changeset
|
190 | 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
|
191 | |
1369
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1365
diff
changeset
|
192 | for (signed int i = 0; i < countof(model); i += 1) |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1365
diff
changeset
|
193 | 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
|
194 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
197 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
198 | * Signals the model to recount its triangles. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
199 | */ |
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
|
200 | 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
|
201 | { |
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 | _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
|
203 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
205 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
206 | * Returns the triangle count in the model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
207 | */ |
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
|
208 | 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
|
209 | { |
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 | 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
|
211 | { |
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 | _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
|
213 | |
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 | 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
|
215 | _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
|
216 | |
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 | _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
|
218 | } |
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 | 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
|
221 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
223 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
224 | * 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
|
225 | */ |
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
|
226 | 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
|
227 | { |
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 | 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
|
229 | 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
|
230 | |
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 | // 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
|
232 | 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
|
233 | |
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 | // 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
|
235 | 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
|
236 | { |
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
|
237 | 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
|
238 | 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
|
239 | } |
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 | 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
|
242 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
244 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
245 | * 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
|
246 | */ |
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
|
247 | 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
|
248 | { |
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 | 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
|
250 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
252 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
253 | * 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
|
254 | */ |
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
|
255 | 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
|
256 | { |
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 | 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
|
258 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
260 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
261 | * Removes all objects in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
262 | */ |
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
|
263 | 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
|
264 | { |
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 | 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
|
266 | 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
|
267 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
268 | _triangleCount = 0; |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
269 | _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
|
270 | } |
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 | /* |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
273 | * Returns whether or not this model is empty. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
274 | */ |
1077
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
275 | 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
|
276 | { |
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
277 | return _objects.isEmpty(); |
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
278 | } |
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
|
279 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
280 | /* |
1258 | 281 | * Returns an index that corresponds to the given object |
282 | */ | |
283 | QModelIndex Model::indexOf(LDObject* object) const | |
284 | { | |
285 | for (int i = 0; i < this->size(); ++i) | |
286 | { | |
287 | if (this->getObject(i) == object) | |
288 | return index(i); | |
289 | } | |
290 | ||
291 | return {}; | |
292 | } | |
293 | ||
294 | /* | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
295 | * 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
|
296 | */ |
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
|
297 | 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
|
298 | { |
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 | 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
|
300 | } |
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 | |
1244 | 302 | IndexGenerator Model::indices() const |
303 | { | |
304 | return {this}; | |
305 | } | |
306 | ||
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
|
307 | 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
|
308 | { |
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 | 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
|
310 | } |
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 | 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
|
313 | { |
1425
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
314 | 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
|
315 | |
1244 | 316 | if (index.row() < 0 or index.row() >= size()) |
317 | return {}; | |
318 | ||
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
|
319 | 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
|
320 | |
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 | 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
|
322 | { |
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 | 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
|
324 | { |
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 | 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
|
326 | |
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 | 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
|
328 | 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
|
329 | |
1365
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
330 | if (object->type() == LDObjectType::SubfileReference) |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
331 | { |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
332 | LDSubfileReference* reference = static_cast<LDSubfileReference*>(object); |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
333 | LDDocument* subfile = reference->fileInfo(this->documentManager()); |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
334 | if (subfile != nullptr) |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
335 | result.prepend(subfile->header.description + "\n"); |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
336 | } |
3f917410e977
show subfile descriptions in the object list
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
337 | |
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
|
338 | 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
|
339 | } |
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 | case Qt::DecorationRole: |
1425
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
342 | { |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
343 | QString iconName = object->iconName(); |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
344 | 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
|
345 | if (it == scaledIcons.end()) |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
346 | { |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
347 | 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
|
348 | .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
|
349 | 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
|
350 | } |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
351 | return *it; |
5354313b9958
added icons for circular primitives and enhanced some existing ones
Teemu Piippo <teemu@hecknology.net>
parents:
1402
diff
changeset
|
352 | } |
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
|
353 | |
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 | 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
|
355 | 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
|
356 | 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
|
357 | 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
|
358 | 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
|
359 | |
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 | 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
|
361 | 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
|
362 | { |
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 | 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
|
364 | } |
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 | 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
|
366 | 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
|
367 | 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
|
368 | 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
|
369 | 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
|
370 | ) { |
1244 | 371 | // If the object isn't in the main or edge color, draw this list |
372 | // 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
|
373 | 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
|
374 | } |
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 | 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
|
376 | { |
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 | 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
|
378 | } |
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 | 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
|
381 | 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
|
382 | { |
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 | 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
|
384 | 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
|
385 | 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
|
386 | } |
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 | 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
|
388 | { |
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 | 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
|
390 | } |
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 | 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
|
393 | 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
|
394 | } |
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 | |
1245 | 397 | /* |
1244 | 398 | bool Model::removeRows(int row, int count, const QModelIndex& parent) |
399 | { | |
400 | if (row >= 0 and row < size() and count <= size() - row) | |
401 | { | |
402 | beginRemoveRows(parent, row, row + count - 1); | |
403 | ||
404 | for (signed int i = row + count - 1; i >= row; i -= 1) | |
405 | this->removeAt(i); | |
406 | ||
407 | endRemoveRows(); | |
408 | return true; | |
409 | } | |
410 | else | |
411 | { | |
412 | return false; | |
413 | } | |
414 | } | |
1245 | 415 | */ |
416 | ||
417 | /* | |
418 | * Looks up an object by the given index. | |
419 | */ | |
420 | LDObject* Model::lookup(const QModelIndex &index) const | |
421 | { | |
422 | if (index.row() >= 0 and index.row() < size()) | |
423 | return this->objects()[index.row()]; | |
424 | else | |
425 | return nullptr; | |
426 | } | |
1244 | 427 | |
1278
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
428 | QColor Model::pickingColorForObject(const QModelIndex& objectIndex) const |
1247 | 429 | { |
1278
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
430 | return QColor::fromRgba(this->pickingColors.value(this->lookup(objectIndex)) | 0xff000000); |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
431 | } |
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 | QModelIndex Model::objectByPickingColor(const QColor& color) const |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
434 | { |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
435 | if (color != qRgb(0, 0, 0)) |
1247 | 436 | { |
1278
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
437 | 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
|
438 | { |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
439 | if (this->pickingColorForObject(this->index(row)) == color) |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
440 | return this->index(row); |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
441 | } |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
442 | |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
443 | return {}; |
1247 | 444 | } |
1278
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
445 | else |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
446 | { |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
447 | return {}; |
6e1ea24e5a5e
moved LDObject indices from a global array into Model
Santeri Piippo
parents:
1277
diff
changeset
|
448 | } |
1247 | 449 | } |
450 | ||
1306
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
451 | Winding Model::winding() const |
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 | return this->_winding; |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
454 | } |
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 | void Model::setWinding(Winding winding) |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
457 | { |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
458 | this->_winding = winding; |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
459 | emit windingChanged(this->_winding); |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
460 | } |
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1288
diff
changeset
|
461 | |
1087
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
462 | int countof(Model& model) |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
463 | { |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
464 | return model.size(); |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
465 | } |