Thu, 09 Feb 2017 22:46:37 +0200
Moved LDComment and LDEmpty into their own source file pairs.
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 |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
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" |
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
|
20 | #include "ldObject.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" |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1113
diff
changeset
|
22 | #include "linetypes/empty.h" |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1113
diff
changeset
|
23 | #include "linetypes/comment.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
|
24 | |
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
|
25 | Model::Model(DocumentManager* manager) : |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
26 | QObject {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
|
27 | _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
|
28 | |
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 | 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
|
30 | { |
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 | 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
|
32 | 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
|
33 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
35 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
36 | * Takes an existing object and migrates it to the end of this model. The object is removed from its old model in the process. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
37 | */ |
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
|
38 | void Model::addObject(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
|
39 | { |
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
|
40 | insertObject(size(), 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
|
41 | } |
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
|
42 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
43 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
44 | * Returns the amount of objects in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
45 | */ |
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
|
46 | 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
|
47 | { |
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
|
48 | 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
|
49 | } |
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
|
50 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
51 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
52 | * Returns the vector of objects in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
53 | */ |
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
|
54 | 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
|
55 | { |
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
|
56 | 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
|
57 | } |
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
|
58 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
59 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
60 | * Takes an existing object and migrates it to this model, at the specified position. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
61 | */ |
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 | void Model::insertObject(int position, 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
|
63 | { |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
64 | if (object->model() and object->model() != this) |
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
|
65 | object->model()->withdraw(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
|
66 | |
1082
1738bdaf36d6
The "all objects have valid models" invariant seems to be holding up now. At least basic drawing works again.
Teemu Piippo <teemu@hecknology.net>
parents:
1079
diff
changeset
|
67 | // TODO: check that the object isn't in the vector once there's a cheap way to do so! |
1738bdaf36d6
The "all objects have valid models" invariant seems to be holding up now. At least basic drawing works again.
Teemu Piippo <teemu@hecknology.net>
parents:
1079
diff
changeset
|
68 | _objects.insert(position, object); |
1738bdaf36d6
The "all objects have valid models" invariant seems to be holding up now. At least basic drawing works again.
Teemu Piippo <teemu@hecknology.net>
parents:
1079
diff
changeset
|
69 | _needsTriangleRecount = true; |
1738bdaf36d6
The "all objects have valid models" invariant seems to be holding up now. At least basic drawing works again.
Teemu Piippo <teemu@hecknology.net>
parents:
1079
diff
changeset
|
70 | object->setDocument(this); |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
71 | emit objectAdded(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
|
72 | } |
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
|
73 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
74 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
75 | * Swaps one object with another, assuming they both are in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
76 | */ |
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
|
77 | bool Model::swapObjects(LDObject* one, LDObject* other) |
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 | int a = _objects.indexOf(one); |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
80 | int b = _objects.indexOf(other); |
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
|
81 | |
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
|
82 | if (a != b and a != -1 and b != -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
|
83 | { |
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 | _objects[b] = one; |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
85 | _objects[a] = other; |
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
|
86 | 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
|
87 | } |
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
|
88 | 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
|
89 | { |
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
|
90 | 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
|
91 | } |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
92 | } |
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
|
93 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
94 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
95 | * 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
|
96 | */ |
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
|
97 | bool Model::setObjectAt(int idx, LDObject* obj) |
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
|
98 | { |
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
|
99 | if (idx < 0 or idx >= 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
|
100 | { |
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
|
101 | 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
|
102 | } |
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
|
103 | 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
|
104 | { |
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
|
105 | removeAt(idx); |
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
|
106 | insertObject(idx, obj); |
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
|
107 | 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
|
108 | } |
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
|
109 | } |
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
|
110 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
111 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
112 | * 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
|
113 | */ |
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
|
114 | 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
|
115 | { |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
116 | 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
|
117 | 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
|
118 | 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
|
119 | 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
|
120 | } |
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
|
121 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
122 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
123 | * Removes the given object from the model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
124 | */ |
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
|
125 | 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
|
126 | { |
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 | int position = object->lineNumber(); |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
128 | 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
|
129 | 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
|
130 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
132 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
133 | * Removes the object at the provided position. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
134 | */ |
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 | 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
|
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 | LDObject* object = withdrawAt(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
|
138 | 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
|
139 | } |
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
|
140 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
141 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
142 | * 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
|
143 | */ |
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
|
144 | void Model::replace(LDObject *object, 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
|
145 | { |
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 | if (object->model() == this) |
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 | int position = object->lineNumber(); |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
149 | |
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
|
150 | for (int i = countof(model.objects()) - 1; i >= 1; 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
|
151 | insertObject(position + i, model.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
|
152 | |
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 | setObjectAt(position, model.objects()[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
|
154 | } |
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
|
155 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
157 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
158 | * Signals the model to recount its triangles. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
159 | */ |
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
|
160 | 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
|
161 | { |
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
|
162 | _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
|
163 | } |
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
165 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
166 | * Returns the triangle count in the model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
167 | */ |
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
|
168 | 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
|
169 | { |
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
|
170 | 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
|
171 | { |
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 | _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
|
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 | for (LDObject* object : 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
|
175 | _triangleCount += object->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
|
176 | |
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
|
177 | _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
|
178 | } |
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
|
179 | |
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
|
180 | 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
|
181 | } |
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
|
182 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
183 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
184 | * 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
|
185 | */ |
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
|
186 | 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
|
187 | { |
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 | 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
|
189 | 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
|
190 | |
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 | // 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
|
192 | 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
|
193 | |
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 | // 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
|
195 | 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
|
196 | { |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
197 | insertObject(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
|
198 | 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
|
199 | } |
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 | |
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 | 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
|
202 | } |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
203 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
204 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
205 | * 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
|
206 | */ |
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
|
207 | 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
|
208 | { |
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 | 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
|
210 | } |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
211 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
212 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
213 | * 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
|
214 | */ |
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
|
215 | 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
|
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 | 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
|
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 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
220 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
221 | * Removes all objects in this model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
222 | */ |
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
|
223 | 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
|
224 | { |
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
|
225 | 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
|
226 | 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
|
227 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
228 | _triangleCount = 0; |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
229 | _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
|
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 | |
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 | /* |
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 | * Drops the object from the model. The object becomes a free object as a result (thus violating the invariant that every 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
|
234 | * has a model!). The caller must immediately add the withdrawn object to another model. |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
235 | * |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
236 | * This private method is only used to implement public API. |
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
|
237 | */ |
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 | void Model::withdraw(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
|
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 | if (object->model() == this) |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
241 | { |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
242 | int position = object->lineNumber(); |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
243 | |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
244 | 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
|
245 | withdrawAt(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
|
246 | } |
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 | } |
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 | /* |
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 | * Drops an object from the model at the provided position. The caller must immediately put the result value object into a new 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
|
251 | */ |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
252 | LDObject* Model::withdrawAt(int position) |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
253 | { |
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
|
254 | LDObject* object = _objects[position]; |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
255 | emit aboutToRemoveObject(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
|
256 | _objects.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
|
257 | _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
|
258 | return 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
|
259 | } |
1077
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
260 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
261 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
262 | * Returns whether or not this model is empty. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
263 | */ |
1077
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
264 | 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
|
265 | { |
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
266 | return _objects.isEmpty(); |
952d6b3e7d11
Replaced uses of LDSpawn with the Model class in edit modes
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
267 | } |
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
|
268 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
269 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
270 | * 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
|
271 | */ |
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
|
272 | 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
|
273 | { |
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
|
274 | 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
|
275 | } |
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
|
276 | |
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
|
277 | // ============================================================================= |
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
|
278 | // |
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 | static void CheckTokenCount (const QStringList& tokens, int num) |
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
280 | { |
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
|
281 | if (countof(tokens) != num) |
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
|
282 | throw QString (format ("Bad amount of tokens, expected %1, got %2", num, countof(tokens))); |
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
|
283 | } |
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
|
284 | |
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
|
285 | // ============================================================================= |
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
|
286 | // |
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
|
287 | static void CheckTokenNumbers (const QStringList& tokens, int min, int max) |
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
|
288 | { |
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
|
289 | bool ok; |
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
|
290 | QRegExp scientificRegex ("\\-?[0-9]+\\.[0-9]+e\\-[0-9]+"); |
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
|
291 | |
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
|
292 | for (int i = min; i <= max; ++i) |
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
|
293 | { |
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
|
294 | // Check for floating point |
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
|
295 | tokens[i].toDouble (&ok); |
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
|
296 | if (ok) |
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 | return; |
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 | // Check hex |
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 | if (tokens[i].startsWith ("0x")) |
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
301 | { |
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1077
diff
changeset
|
302 | tokens[i].mid (2).toInt (&ok, 16); |
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
|
303 | |
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
|
304 | if (ok) |
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
|
305 | return; |
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
|
306 | } |
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
|
307 | |
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
|
308 | // Check scientific notation, e.g. 7.99361e-15 |
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
|
309 | if (scientificRegex.exactMatch (tokens[i])) |
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
|
310 | return; |
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
|
311 | |
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
|
312 | throw QString (format ("Token #%1 was `%2`, expected a number (matched length: %3)", |
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
|
313 | (i + 1), tokens[i], scientificRegex.matchedLength())); |
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
|
314 | } |
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
|
315 | } |
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
|
316 | |
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
|
317 | // ============================================================================= |
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
|
318 | // |
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
|
319 | static Vertex ParseVertex (QStringList& s, const int n) |
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
|
320 | { |
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
|
321 | Vertex v; |
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
|
322 | v.apply ([&] (Axis ax, double& a) { a = s[n + ax].toDouble(); }); |
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
|
323 | return v; |
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
|
324 | } |
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
|
325 | |
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
|
326 | static int32 StringToNumber (QString a, bool* ok = nullptr) |
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
|
327 | { |
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
|
328 | int base = 10; |
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
|
329 | |
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
|
330 | if (a.startsWith ("0x")) |
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
|
331 | { |
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
|
332 | a.remove (0, 2); |
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
|
333 | base = 16; |
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
|
334 | } |
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
|
335 | |
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
|
336 | return a.toLong (ok, base); |
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
|
337 | } |
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
|
338 | |
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
|
339 | // ============================================================================= |
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
|
340 | // This is the LDraw code parser function. It takes in a string containing LDraw |
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
|
341 | // code and returns the object parsed from it. parseLine never returns null, |
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
|
342 | // the object will be LDError if it could not be parsed properly. |
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
|
343 | // ============================================================================= |
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
|
344 | LDObject* Model::insertFromString(int position, QString line) |
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
|
345 | { |
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
|
346 | try |
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
|
347 | { |
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
|
348 | QStringList tokens = line.split(" ", QString::SkipEmptyParts); |
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
|
349 | |
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
|
350 | if (countof(tokens) <= 0) |
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
|
351 | { |
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
|
352 | // Line was empty, or only consisted of whitespace |
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
|
353 | return emplaceAt<LDEmpty>(position); |
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
|
354 | } |
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
|
355 | |
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
|
356 | if (countof(tokens[0]) != 1 or not tokens[0][0].isDigit()) |
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
|
357 | throw QString ("Illogical line code"); |
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
|
358 | |
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
|
359 | int num = tokens[0][0].digitValue(); |
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
|
360 | |
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
|
361 | switch (num) |
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
|
362 | { |
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
|
363 | case 0: |
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
|
364 | { |
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
|
365 | // Comment |
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
|
366 | QString commentText = line.mid (line.indexOf ("0") + 2); |
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
|
367 | QString commentTextSimplified = commentText.simplified(); |
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
|
368 | |
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
|
369 | // Handle BFC statements |
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
|
370 | if (countof(tokens) > 2 and tokens[1] == "BFC") |
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
|
371 | { |
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
|
372 | for (BfcStatement statement : iterateEnum<BfcStatement>()) |
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
|
373 | { |
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
|
374 | if (commentTextSimplified == format("BFC %1", LDBfc::statementToString (statement))) |
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
|
375 | return emplaceAt<LDBfc>(position, statement); |
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
|
376 | } |
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
|
377 | |
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
|
378 | // MLCAD is notorious for stuffing these statements in parts it |
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
|
379 | // creates. The above block only handles valid statements, so we |
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
|
380 | // need to handle MLCAD-style invertnext, clip and noclip separately. |
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
|
381 | if (commentTextSimplified == "BFC CERTIFY INVERTNEXT") |
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
|
382 | return emplaceAt<LDBfc>(position, BfcStatement::InvertNext); |
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
|
383 | else if (commentTextSimplified == "BFC CERTIFY CLIP") |
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
|
384 | return emplaceAt<LDBfc>(position, BfcStatement::Clip); |
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
|
385 | else if (commentTextSimplified == "BFC CERTIFY NOCLIP") |
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
|
386 | return emplaceAt<LDBfc>(position, BfcStatement::NoClip); |
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
|
387 | } |
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
|
388 | |
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
|
389 | if (countof(tokens) > 2 and tokens[1] == "!LDFORGE") |
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
|
390 | { |
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
|
391 | // Handle LDForge-specific types, they're embedded into comments too |
1100
9b2797729c82
Removed all overlay support. It's a messy pile of mess and I will reimplement it later as background images and it will be much better then.
Teemu Piippo <teemu@hecknology.net>
parents:
1091
diff
changeset
|
392 | if (tokens[2] == "BEZIER_CURVE") |
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
|
393 | { |
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
|
394 | CheckTokenCount (tokens, 16); |
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
|
395 | CheckTokenNumbers (tokens, 3, 15); |
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
|
396 | LDBezierCurve* obj = emplaceAt<LDBezierCurve>(position); |
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
|
397 | obj->setColor (StringToNumber (tokens[3])); |
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
|
398 | |
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
|
399 | for (int i = 0; i < 4; ++i) |
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
|
400 | obj->setVertex (i, ParseVertex (tokens, 4 + (i * 3))); |
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
|
401 | |
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
|
402 | return obj; |
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
|
403 | } |
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
|
404 | } |
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
|
405 | |
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
|
406 | // Just a regular comment: |
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
|
407 | return emplaceAt<LDComment>(position, commentText); |
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
|
408 | } |
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
|
409 | |
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
|
410 | case 1: |
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
|
411 | { |
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
|
412 | // Subfile |
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
|
413 | CheckTokenCount (tokens, 15); |
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
|
414 | CheckTokenNumbers (tokens, 1, 13); |
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
|
415 | LDDocument* document = _manager->getDocumentByName(tokens[14]); |
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
|
416 | |
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
|
417 | // If we cannot open the file, mark it an error. Note we cannot use LDParseError |
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
|
418 | // here because the error object needs the document reference. |
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
|
419 | if (not document) |
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
|
420 | { |
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
|
421 | LDError* obj = emplaceAt<LDError>(position, line, format ("Could not open %1", tokens[14])); |
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
|
422 | obj->setFileReferenced (tokens[14]); |
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
|
423 | return obj; |
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
|
424 | } |
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
|
425 | |
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
|
426 | Vertex referncePosition = ParseVertex (tokens, 2); // 2 - 4 |
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
|
427 | Matrix transform; |
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
|
428 | |
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
|
429 | for (int i = 0; i < 9; ++i) |
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
|
430 | transform.value(i) = tokens[i + 5].toDouble(); // 5 - 13 |
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
|
431 | |
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
|
432 | LDSubfileReference* obj = emplaceAt<LDSubfileReference>(position, document, transform, referncePosition); |
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
|
433 | obj->setColor (StringToNumber (tokens[1])); |
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
|
434 | return obj; |
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
|
435 | } |
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
|
436 | |
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
|
437 | case 2: |
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
|
438 | { |
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
|
439 | CheckTokenCount (tokens, 8); |
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
|
440 | CheckTokenNumbers (tokens, 1, 7); |
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
|
441 | |
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
|
442 | // Line |
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
|
443 | LDLine* obj = emplaceAt<LDLine>(position); |
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
|
444 | obj->setColor (StringToNumber (tokens[1])); |
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
|
445 | |
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
|
446 | for (int i = 0; i < 2; ++i) |
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
|
447 | obj->setVertex (i, ParseVertex (tokens, 2 + (i * 3))); // 2 - 7 |
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
|
448 | |
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
|
449 | return obj; |
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
|
450 | } |
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
|
451 | |
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
|
452 | case 3: |
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
|
453 | { |
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
|
454 | CheckTokenCount (tokens, 11); |
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
|
455 | CheckTokenNumbers (tokens, 1, 10); |
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
|
456 | |
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
|
457 | // Triangle |
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
|
458 | LDTriangle* obj = emplaceAt<LDTriangle>(position); |
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
|
459 | obj->setColor (StringToNumber (tokens[1])); |
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
|
460 | |
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
|
461 | for (int i = 0; i < 3; ++i) |
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
|
462 | obj->setVertex (i, ParseVertex (tokens, 2 + (i * 3))); // 2 - 10 |
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
|
463 | |
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
|
464 | return obj; |
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
|
465 | } |
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
|
466 | |
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
|
467 | case 4: |
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
|
468 | case 5: |
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
|
469 | { |
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
|
470 | CheckTokenCount (tokens, 14); |
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
|
471 | CheckTokenNumbers (tokens, 1, 13); |
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
|
472 | |
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
|
473 | // Quadrilateral / Conditional line |
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
|
474 | LDObject* obj; |
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
|
475 | |
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
|
476 | if (num == 4) |
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
|
477 | obj = emplaceAt<LDQuad>(position); |
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
|
478 | else |
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
|
479 | obj = emplaceAt<LDCondLine>(position); |
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
|
480 | |
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
|
481 | obj->setColor (StringToNumber (tokens[1])); |
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
|
482 | |
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
|
483 | for (int i = 0; i < 4; ++i) |
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
|
484 | obj->setVertex (i, ParseVertex (tokens, 2 + (i * 3))); // 2 - 13 |
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
|
485 | |
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
|
486 | return obj; |
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
|
487 | } |
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
|
488 | |
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
|
489 | default: |
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
|
490 | throw QString {"Unknown line code number"}; |
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
|
491 | } |
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
|
492 | } |
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
|
493 | catch (QString& errorMessage) |
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
|
494 | { |
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
|
495 | // Strange line we couldn't parse |
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
|
496 | return emplaceAt<LDError>(position, line, errorMessage); |
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
|
497 | } |
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
|
498 | } |
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
|
499 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
500 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
501 | * Given an LDraw object string, parses it and inserts it into the model. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
502 | */ |
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
|
503 | LDObject* Model::addFromString(QString line) |
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
|
504 | { |
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
|
505 | return insertFromString(size(), line); |
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
|
506 | } |
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
|
507 | |
1091
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
508 | /* |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
509 | * Replaces the given object with a new one that is parsed from the given LDraw object string. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
510 | * If the parsing fails, the object is replaced with an error object. |
4a754362f660
Wrote documentation to the Model class.
Teemu Piippo <teemu@hecknology.net>
parents:
1087
diff
changeset
|
511 | */ |
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
|
512 | LDObject* Model::replaceWithFromString(LDObject* object, QString line) |
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
|
513 | { |
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
|
514 | if (object and object->model() == this) |
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
|
515 | { |
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
|
516 | int position = object->lineNumber(); |
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
|
517 | removeAt(position); |
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
|
518 | return insertFromString(position, line); |
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
|
519 | } |
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
|
520 | else |
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
|
521 | return nullptr; |
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
|
522 | } |
1087
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
523 | |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
524 | int countof(Model& model) |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
525 | { |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
526 | return model.size(); |
80e25f6b0bb0
Some code cleanup in abstract editing modes.
Teemu Piippo <teemu@hecknology.net>
parents:
1082
diff
changeset
|
527 | } |