Wed, 26 Feb 2020 02:21:07 +0200
grid stuff
24 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2020 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
3 | 19 | #include "modeleditcontext.h" |
20 | ||
21 | Model::EditContext::EditContext(Model& model) : | |
22 | model{model} | |
23 | { | |
24 | } | |
25 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
26 | ldraw::Id Model::EditContext::append(std::unique_ptr<ldraw::Object>&& object) |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
27 | { |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
28 | const ldraw::Id id = object->id; |
26 | 29 | this->model.objectsById[id] = object.get(); |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
30 | this->model.append(std::move(object)); |
26 | 31 | return id; |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
32 | } |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
33 | |
3 | 34 | void Model::EditContext::setObjectProperty( |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
35 | ldraw::Object* object, |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
36 | ldraw::Property property, |
3 | 37 | const QVariant& value) |
38 | { | |
39 | object->setProperty(property, value); | |
40 | } | |
26 | 41 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
42 | void Model::EditContext::invertObject(ldraw::Id id) |
26 | 43 | { |
44 | auto it = this->model.objectsById.find(id); | |
45 | if (it != this->model.objectsById.end()) | |
46 | { | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
47 | ldraw::Object* object = it->second; |
26 | 48 | object->invert(); |
49 | } | |
50 | } |