Tue, 22 Sep 2015 00:59:21 +0300
LDVertexObject stuff (ultimately not worth it)
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
968 | 3 | * Copyright (C) 2013 - 2015 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
19 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include "main.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "ldObject.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "ldDocument.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "miscallenous.h" |
962
a4b463a7ee82
Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
959
diff
changeset
|
24 | #include "mainwindow.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "editHistory.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "glRenderer.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | #include "colors.h" |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
28 | #include "glCompiler.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
30 | ConfigOption (QString DefaultName = "") |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
31 | ConfigOption (QString DefaultUser = "") |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
32 | ConfigOption (bool UseCaLicense = true) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | // List of all LDObjects |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
35 | QMap<int32, LDObject*> g_allObjects; |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
36 | |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
37 | enum { MAX_LDOBJECT_IDS = (1 << 24) }; |
769
8bb3bed44570
- improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
38 | |
770
b04c1e6ca1fb
- hopefully stabilized the entire shared pointers deal now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
769
diff
changeset
|
39 | #define LDOBJ_DEFAULT_CTOR(T,BASE) \ |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
40 | T :: T (LDDocument* document) : \ |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
41 | BASE (document) {} |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | // LDObject constructors |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | // |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
46 | LDObject::LDObject (LDDocument* document) : |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | m_isHidden (false), |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | m_isSelected (false), |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
49 | m_isDestroyed (false), |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
50 | m_document (nullptr) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
52 | if (document) |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
53 | document->addObject (this); |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
54 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
55 | // Let's hope that nobody goes to create 17 million objects anytime soon... |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
56 | static int32 nextId = 1; // 0 shalt be null |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
57 | if (nextId < MAX_LDOBJECT_IDS) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
58 | m_id = nextId++; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
59 | else |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
60 | m_id = 0; |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
61 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
62 | if (m_id != 0) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
63 | g_allObjects[m_id] = this; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
64 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
65 | m_randomColor = QColor::fromHsv (rand() % 360, rand() % 256, rand() % 96 + 128); |
770
b04c1e6ca1fb
- hopefully stabilized the entire shared pointers deal now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
769
diff
changeset
|
66 | } |
769
8bb3bed44570
- improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
67 | |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
68 | LDSubfile::LDSubfile (LDDocument* document) : |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
69 | LDMatrixObject (document) {} |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | |
770
b04c1e6ca1fb
- hopefully stabilized the entire shared pointers deal now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
769
diff
changeset
|
71 | LDOBJ_DEFAULT_CTOR (LDEmpty, LDObject) |
b04c1e6ca1fb
- hopefully stabilized the entire shared pointers deal now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
769
diff
changeset
|
72 | LDOBJ_DEFAULT_CTOR (LDError, LDObject) |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
73 | LDOBJ_DEFAULT_CTOR (LDLine, LDVertexObject) |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
74 | LDOBJ_DEFAULT_CTOR (LDTriangle, LDVertexObject) |
770
b04c1e6ca1fb
- hopefully stabilized the entire shared pointers deal now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
769
diff
changeset
|
75 | LDOBJ_DEFAULT_CTOR (LDCondLine, LDLine) |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
76 | LDOBJ_DEFAULT_CTOR (LDQuad, LDVertexObject) |
770
b04c1e6ca1fb
- hopefully stabilized the entire shared pointers deal now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
769
diff
changeset
|
77 | LDOBJ_DEFAULT_CTOR (LDOverlay, LDObject) |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
78 | LDOBJ_DEFAULT_CTOR (LDBfc, LDObject) |
770
b04c1e6ca1fb
- hopefully stabilized the entire shared pointers deal now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
769
diff
changeset
|
79 | LDOBJ_DEFAULT_CTOR (LDComment, LDObject) |
b04c1e6ca1fb
- hopefully stabilized the entire shared pointers deal now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
769
diff
changeset
|
80 | |
944 | 81 | LDObject::~LDObject() |
82 | { | |
987
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
83 | if (not m_isDestroyed) |
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
84 | print ("Warning: Object #%1 (%2) was not destroyed before being deleted\n", id(), this); |
944 | 85 | } |
86 | ||
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
89 | QString LDComment::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | return format ("0 %1", text()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
96 | QString LDSubfile::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
98 | QString val = format ("1 %1 %2 ", color(), position()); |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
99 | val += transformationMatrix().toString(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | val += ' '; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | val += fileInfo()->name(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | return val; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
107 | QString LDLine::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
109 | QString val = format ("2 %1", color()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | for (int i = 0; i < 2; ++i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | val += format (" %1", vertex (i)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | return val; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
119 | QString LDTriangle::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
121 | QString val = format ("3 %1", color()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | for (int i = 0; i < 3; ++i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | val += format (" %1", vertex (i)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | return val; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
131 | QString LDQuad::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
133 | QString val = format ("4 %1", color()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | for (int i = 0; i < 4; ++i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | val += format (" %1", vertex (i)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | return val; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
143 | QString LDCondLine::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
145 | QString val = format ("5 %1", color()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | // Add the coordinates |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | for (int i = 0; i < 4; ++i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | val += format (" %1", vertex (i)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | return val; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
156 | QString LDError::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | return contents(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
163 | QString LDEmpty::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | return ""; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
170 | QString LDBfc::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | { |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
172 | return format ("0 BFC %1", statementToString()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
177 | QList<LDTriangle*> LDQuad::splitToTriangles() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | // Create the two triangles based on this quadrilateral: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | // 0---3 0---3 3 |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | // | | | / /| |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | // | | ==> | / / | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | // | | |/ / | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | // 1---2 1 1---2 |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
185 | LDTriangle* tri1 (new LDTriangle (vertex (0), vertex (1), vertex (3))); |
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
186 | LDTriangle* tri2 (new LDTriangle (vertex (1), vertex (2), vertex (3))); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | // The triangles also inherit the quad's color |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | tri1->setColor (color()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | tri2->setColor (color()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
192 | return {tri1, tri2}; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
197 | // Replace this LDObject with another LDObject. Object is deleted in the process. |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
198 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
199 | void LDObject::replace (LDObject* other) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
200 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
201 | int idx = lineNumber(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
203 | if (idx != -1) |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
204 | { |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
205 | // Replace the instance of the old object with the new object |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
206 | document()->setObject (idx, other); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
208 | // Remove the old object |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
209 | destroy(); |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
210 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
215 | // Swap this object with another. |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
216 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
217 | void LDObject::swap (LDObject* other) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
956
diff
changeset
|
219 | if (document() == other->document()) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
956
diff
changeset
|
220 | document()->swapObjects (this, other); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | // |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
225 | LDLine::LDLine (Vertex v1, Vertex v2, LDDocument* document) : |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
226 | LDVertexObject (document) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | setVertex (0, v1); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | setVertex (1, v2); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
231 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
232 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | // |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
234 | LDTriangle::LDTriangle (const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document) : |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
235 | LDVertexObject (document) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | { |
805
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
237 | setVertex (0, v1); |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
238 | setVertex (1, v2); |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
239 | setVertex (2, v3); |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
240 | } |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
241 | |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
242 | // ============================================================================= |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
243 | // |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
244 | LDQuad::LDQuad (const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, LDDocument* document) : |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
245 | LDVertexObject (document) |
805
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
246 | { |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
247 | setVertex (0, v1); |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
248 | setVertex (1, v2); |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
249 | setVertex (2, v3); |
d88c0354de97
- refactor. got rid of the LDSharedVertex nonsense, fixed up split lines action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
250 | setVertex (3, v4); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | // |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
255 | LDCondLine::LDCondLine (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document) : |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
256 | LDLine (document) |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
257 | { |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
258 | setVertex (0, v0); |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
259 | setVertex (1, v1); |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
260 | setVertex (2, v2); |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
261 | setVertex (3, v3); |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
262 | } |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
263 | |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
264 | // ============================================================================= |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
265 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
266 | // Deletes this object |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
267 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | void LDObject::destroy() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | { |
987
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
270 | deselect(); |
956
2af18ba2665f
Replace LDIterate function with LDObjectIterator class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
271 | |
987
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
272 | // If this object was associated to a file, remove it off it now |
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
273 | if (document()) |
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
274 | document()->forgetObject (this); |
956
2af18ba2665f
Replace LDIterate function with LDObjectIterator class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
275 | |
987
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
276 | // Delete the GL lists |
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
277 | if (g_win) |
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
278 | g_win->renderer()->forgetObject (this); |
956
2af18ba2665f
Replace LDIterate function with LDObjectIterator class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
279 | |
987
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
280 | // Remove this object from the list of LDObjects |
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
281 | g_allObjects.erase (g_allObjects.find (id())); |
956
2af18ba2665f
Replace LDIterate function with LDObjectIterator class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
282 | |
987
91281e39c50c
Removed the exiting hacks
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
283 | m_isDestroyed = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
285 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
287 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
288 | void LDObject::setDocument (LDDocument* document) |
880
5dcd2e741d1c
- fixed documentless objects being selected on document close
Teemu Piippo <crimsondusk64@gmail.com>
parents:
867
diff
changeset
|
289 | { |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
290 | m_document = document; |
880
5dcd2e741d1c
- fixed documentless objects being selected on document close
Teemu Piippo <crimsondusk64@gmail.com>
parents:
867
diff
changeset
|
291 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
292 | if (document == nullptr) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
293 | m_isSelected = false; |
880
5dcd2e741d1c
- fixed documentless objects being selected on document close
Teemu Piippo <crimsondusk64@gmail.com>
parents:
867
diff
changeset
|
294 | } |
5dcd2e741d1c
- fixed documentless objects being selected on document close
Teemu Piippo <crimsondusk64@gmail.com>
parents:
867
diff
changeset
|
295 | |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
296 | LDVertexObject::LDVertexObject (LDDocument* document) : |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
297 | LDObject (document) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
299 | memset (m_coordinates, 0, sizeof m_coordinates); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
300 | } |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
301 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
302 | void LDObject::transform (const Matrix&, const Vertex&) {} |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
303 | |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
304 | void LDVertexObject::transform (const Matrix& transformationMatrix, const Vertex& position) |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
305 | { |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
306 | for (int i = 0; i < numVertices(); ++i) |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
307 | { |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
308 | Vertex vertex = this->vertex (i); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
309 | vertex.transform (transformationMatrix, position); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
310 | setVertex (i, vertex); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
311 | } |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
312 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
314 | void LDMatrixObject::transform (const Matrix& transformationMatrix, const Vertex& position) |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
315 | { |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
316 | Vertex newPosition = this->position(); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
317 | newPosition.transform (transformationMatrix, position); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
318 | setPosition (newPosition); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
319 | setTransformationMatrix (transformationMatrix * this->transformationMatrix()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
320 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
321 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | // ============================================================================= |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
323 | // ----------------------------------------------------------------------------- |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
324 | LDObjectList LDSubfile::inlineContents (bool deep, bool render) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | { |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
326 | LDObjectList objs = fileInfo()->inlineContents (deep, render); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | // Transform the objects |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
329 | for (LDObject* obj : objs) |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
330 | { |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
331 | obj->transform (transformationMatrix(), position()); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
332 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
333 | if (obj->color() == MainColor) |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
334 | obj->setColor (color()); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
335 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | return objs; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
339 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
340 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | // |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
342 | LDPolygon* LDVertexObject::getPolygon() |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
343 | { |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
784
diff
changeset
|
344 | LDObjectType ot = type(); |
847 | 345 | int num = (ot == OBJ_Line) ? 2 |
346 | : (ot == OBJ_Triangle) ? 3 | |
347 | : (ot == OBJ_Quad) ? 4 | |
348 | : (ot == OBJ_CondLine) ? 5 | |
349 | : 0; | |
350 | ||
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
351 | if (num == 0) |
984 | 352 | return nullptr; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
353 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
354 | LDPolygon* data = new LDPolygon; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
355 | data->id = id(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
356 | data->num = num; |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
805
diff
changeset
|
357 | data->color = color().index(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
358 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
359 | for (int i = 0; i < data->numVertices(); ++i) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
360 | data->vertices[i] = vertex (i); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
361 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
362 | return data; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
363 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
364 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
365 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
366 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
367 | QList<LDPolygon> LDSubfile::inlinePolygons() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
368 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
369 | QList<LDPolygon> data = fileInfo()->inlinePolygons(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
370 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
371 | for (LDPolygon& entry : data) |
847 | 372 | { |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
373 | for (int i = 0; i < entry.numVertices(); ++i) |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
374 | entry.vertices[i].transform (transformationMatrix(), position()); |
847 | 375 | } |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
376 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
377 | return data; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
378 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
379 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
380 | // ============================================================================= |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
381 | // |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
382 | // Index (i.e. line number) of this object |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
383 | // |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
384 | int LDObject::lineNumber() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
385 | { |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
386 | if (document()) |
847 | 387 | { |
949
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
388 | for (int i = 0; i < document()->getObjectCount(); ++i) |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
389 | { |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
390 | if (document()->getObject (i) == this) |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
391 | return i; |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
392 | } |
847 | 393 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
394 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
395 | return -1; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
398 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
399 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | void LDObject::moveObjects (LDObjectList objs, const bool up) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
402 | if (objs.isEmpty()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
403 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
404 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
405 | // If we move down, we need to iterate the array in reverse order. |
847 | 406 | long const start = up ? 0 : (objs.size() - 1); |
407 | long const end = up ? objs.size() : -1; | |
408 | long const incr = up ? 1 : -1; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | LDObjectList objsToCompile; |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
410 | LDDocument* file = objs[0]->document(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
412 | for (long i = start; i != end; i += incr) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | { |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
414 | LDObject* obj = objs[i]; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | |
847 | 416 | long const idx = obj->lineNumber(); |
417 | long const target = idx + (up ? -1 : 1); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
835
diff
changeset
|
419 | if ((up and idx == 0) or (not up and idx == (long) file->objects().size() - 1l)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
420 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | // One of the objects hit the extrema. If this happens, this should be the first |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
422 | // object to be iterated on. Thus, nothing has changed yet and it's safe to just |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
423 | // abort the entire operation. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
424 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
425 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
426 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
427 | objsToCompile << obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | objsToCompile << file->getObject (target); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
429 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | obj->swap (file->getObject (target)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
432 | |
966
a834e43a57da
Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
433 | removeDuplicates (objsToCompile); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
434 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | // The objects need to be recompiled, otherwise their pick lists are left with |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
436 | // the wrong index colors which messes up selection. |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
437 | for (LDObject* obj : objsToCompile) |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
438 | g_win->renderer()->compileObject (obj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
439 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
440 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
441 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
442 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
443 | // Get type name by enumerator |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
444 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
445 | QString LDObject::typeName (LDObjectType type) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
446 | { |
769
8bb3bed44570
- improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
447 | return LDObject::getDefault (type)->typeName(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
448 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
449 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
450 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
451 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
452 | // Get a description of a list of LDObjects |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
453 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
454 | QString LDObject::describeObjects (const LDObjectList& objs) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
455 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
456 | QString text; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
457 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
458 | if (objs.isEmpty()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
459 | return "nothing"; // :) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
460 | |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
784
diff
changeset
|
461 | for (LDObjectType objType = OBJ_FirstType; objType < OBJ_NumTypes; ++objType) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
462 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
463 | int count = 0; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
464 | |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
465 | for (LDObject* obj : objs) |
847 | 466 | { |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
467 | if (obj->type() == objType) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
468 | count++; |
847 | 469 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
470 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
471 | if (count == 0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
472 | continue; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
473 | |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
474 | if (not text.isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
475 | text += ", "; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
476 | |
966
a834e43a57da
Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
477 | QString noun = format ("%1%2", typeName (objType), plural (count)); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
478 | text += format ("%1 %2", count, noun); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
479 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
480 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
481 | return text; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
482 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
483 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
484 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
485 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
486 | // Object after this in the current file |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
487 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
488 | LDObject* LDObject::next() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
489 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
490 | int idx = lineNumber(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
491 | |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
956
diff
changeset
|
492 | if (idx == -1 or idx == document()->getObjectCount() - 1) |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
493 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
494 | |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
495 | return document()->getObject (idx + 1); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
496 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
497 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
498 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
500 | // Object prior to this in the current file |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
501 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
502 | LDObject* LDObject::previous() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
503 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
504 | int idx = lineNumber(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
505 | |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
956
diff
changeset
|
506 | if (idx <= 0) |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
507 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
508 | |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
509 | return document()->getObject (idx - 1); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
510 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
511 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
512 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
513 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
514 | // Is the previous object INVERTNEXT? |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
515 | // |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
516 | bool LDObject::previousIsInvertnext (LDBfc*& ptr) |
776
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
517 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
518 | LDObject* prev = previous(); |
776
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
519 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
520 | if (prev and prev->type() == OBJ_Bfc and static_cast<LDBfc*> (prev)->statement() == BfcStatement::InvertNext) |
776
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
521 | { |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
522 | ptr = static_cast<LDBfc*> (prev); |
776
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
523 | return true; |
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
524 | } |
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
525 | |
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
526 | return false; |
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
527 | } |
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
528 | |
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
529 | // ============================================================================= |
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
530 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
531 | // Moves this object using the given vertex as a movement List |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
532 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
533 | void LDObject::move (Vertex vect) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
534 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
535 | if (hasMatrix()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
536 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
537 | LDMatrixObject* mo = static_cast<LDMatrixObject*> (this); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
538 | mo->setPosition (mo->position() + vect); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
539 | } |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
540 | else if (hasVertices()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
541 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
542 | LDVertexObject* vo = static_cast<LDVertexObject*> (this); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
543 | for (int i = 0; i < vo->numVertices(); ++i) |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
544 | vo->setVertex (i, vo->vertex (i) + vect); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
545 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
546 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
547 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
548 | bool LDObject::isHidden() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
549 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
550 | return m_isHidden; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
551 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
552 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
553 | void LDObject::setHidden (bool value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
554 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
555 | m_isHidden = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
556 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
557 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
558 | bool LDObject::isSelected() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
559 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
560 | return m_isSelected; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
561 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
562 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
563 | qint32 LDObject::id() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
564 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
565 | return m_id; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
566 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
567 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
568 | LDColor LDObject::color() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
569 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
570 | return m_color; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
571 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
572 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
573 | QColor LDObject::randomColor() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
574 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
575 | return m_randomColor; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
576 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
577 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
578 | LDDocument* LDObject::document() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
579 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
580 | return m_document; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
581 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
582 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
583 | bool LDObject::isDestroyed() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
584 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
585 | return m_isDestroyed; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
586 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
587 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
588 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
589 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
590 | // Returns a default-constructed LDObject by the given type |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
591 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
592 | LDObject* LDObject::getDefault (const LDObjectType type) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
593 | { |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
594 | switch (type) |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
595 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
596 | case OBJ_Comment: return LDSpawn<LDComment>(); |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
597 | case OBJ_Bfc: return LDSpawn<LDBfc>(); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
598 | case OBJ_Line: return LDSpawn<LDLine>(); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
599 | case OBJ_CondLine: return LDSpawn<LDCondLine>(); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
600 | case OBJ_Subfile: return LDSpawn<LDSubfile>(); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
601 | case OBJ_Triangle: return LDSpawn<LDTriangle>(); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
602 | case OBJ_Quad: return LDSpawn<LDQuad>(); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
603 | case OBJ_Empty: return LDSpawn<LDEmpty>(); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
604 | case OBJ_Error: return LDSpawn<LDError>(); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
605 | case OBJ_Overlay: return LDSpawn<LDOverlay>(); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
956
diff
changeset
|
606 | case OBJ_NumTypes: break; |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
607 | } |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
608 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
609 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
610 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
611 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
612 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
613 | void LDObject::invert() {} |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
614 | void LDBfc::invert() {} |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
615 | void LDEmpty::invert() {} |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
616 | void LDComment::invert() {} |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
617 | void LDError::invert() {} |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
618 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
619 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
620 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
621 | void LDTriangle::invert() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
622 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
623 | // Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
624 | // Thus, we swap 1 and 2. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
625 | Vertex tmp = vertex (1); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
626 | setVertex (1, vertex (2)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
627 | setVertex (2, tmp); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
628 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
629 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
630 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
631 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
632 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
633 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
634 | void LDQuad::invert() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
635 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
636 | // Quad: 0 -> 1 -> 2 -> 3 |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
637 | // reversed: 0 -> 3 -> 2 -> 1 |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
638 | // Thus, we swap 1 and 3. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
639 | Vertex tmp = vertex (1); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
640 | setVertex (1, vertex (3)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
641 | setVertex (3, tmp); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
642 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
643 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
644 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
645 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
646 | void LDSubfile::invert() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
647 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
648 | if (document() == nullptr) |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
783
diff
changeset
|
649 | return; |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
783
diff
changeset
|
650 | |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
651 | // Check whether subfile is flat |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
652 | int axisSet = (1 << X) | (1 << Y) | (1 << Z); |
846
e4ad109f33c6
- use the untransformed subfile when testing whether a subfile is flat, otherwise it won't be considered flat if the subfile is rotated. or worse...
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
653 | LDObjectList objs = fileInfo()->inlineContents (true, false); |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
654 | |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
655 | for (LDObject* obj : objs) |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
656 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
657 | if (not obj->hasVertices()) |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
658 | continue; |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
659 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
660 | LDVertexObject* vo = static_cast<LDVertexObject*> (obj); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
661 | for (int i = 0; i < vo->numVertices(); ++i) |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
662 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
663 | Vertex const& vrt = vo->vertex (i); |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
664 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
835
diff
changeset
|
665 | if (axisSet & (1 << X) and vrt.x() != 0.0) |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
666 | axisSet &= ~(1 << X); |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
667 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
835
diff
changeset
|
668 | if (axisSet & (1 << Y) and vrt.y() != 0.0) |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
669 | axisSet &= ~(1 << Y); |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
670 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
835
diff
changeset
|
671 | if (axisSet & (1 << Z) and vrt.z() != 0.0) |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
672 | axisSet &= ~(1 << Z); |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
673 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
674 | |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
675 | if (axisSet == 0) |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
676 | break; |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
677 | } |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
678 | |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
679 | if (axisSet != 0) |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
680 | { |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
681 | // Subfile has all vertices zero on one specific plane, so it is flat. |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
682 | // Let's flip it. |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
683 | Matrix matrixModifier = IdentityMatrix; |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
684 | |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
685 | if (axisSet & (1 << X)) |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
686 | matrixModifier[0] = -1; |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
687 | |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
688 | if (axisSet & (1 << Y)) |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
689 | matrixModifier[4] = -1; |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
690 | |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
691 | if (axisSet & (1 << Z)) |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
692 | matrixModifier[8] = -1; |
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
693 | |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
694 | setTransformationMatrix (transformationMatrix() * matrixModifier); |
783
1db20d88650f
- subfile inverting now detects flatness and acts accordingly instead of naively applying invertnext to everything
Santeri Piippo <crimsondusk64@gmail.com>
parents:
776
diff
changeset
|
695 | } |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
696 | else |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
697 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
698 | // Subfile is not flat. Resort to invertnext. |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
699 | int idx = lineNumber(); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
700 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
701 | if (idx > 0) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
702 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
703 | LDBfc* bfc = dynamic_cast<LDBfc*> (previous()); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
704 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
705 | if (bfc and bfc->statement() == BfcStatement::InvertNext) |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
706 | { |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
707 | // This is prefixed with an invertnext, thus remove it. |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
708 | bfc->destroy(); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
709 | return; |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
710 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
711 | } |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
712 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
713 | // Not inverted, thus prefix it with a new invertnext. |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
714 | document()->insertObj (idx, new LDBfc (BfcStatement::InvertNext)); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
715 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
716 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
717 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
718 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
719 | // |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
720 | void LDLine::invert() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
721 | { |
775
4661d6e83630
- don't crash when inverting conditional lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
773
diff
changeset
|
722 | // For lines, we swap the vertices. |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
723 | Vertex tmp = vertex (0); |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
724 | setVertex (0, vertex (1)); |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
725 | setVertex (1, tmp); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
726 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
727 | |
775
4661d6e83630
- don't crash when inverting conditional lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
773
diff
changeset
|
728 | // ============================================================================= |
4661d6e83630
- don't crash when inverting conditional lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
773
diff
changeset
|
729 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
730 | void LDCondLine::invert() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
731 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
732 | // I don't think that a conditional line's control points need to be swapped, do they? |
775
4661d6e83630
- don't crash when inverting conditional lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
773
diff
changeset
|
733 | Vertex tmp = vertex (0); |
4661d6e83630
- don't crash when inverting conditional lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
773
diff
changeset
|
734 | setVertex (0, vertex (1)); |
4661d6e83630
- don't crash when inverting conditional lines
Santeri Piippo <crimsondusk64@gmail.com>
parents:
773
diff
changeset
|
735 | setVertex (1, tmp); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
736 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
737 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
738 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
739 | // |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
740 | LDLine* LDCondLine::toEdgeLine() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
741 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
742 | LDLine* replacement = new LDLine; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
743 | |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
744 | for (int i = 0; i < replacement->numVertices(); ++i) |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
745 | replacement->setVertex (i, vertex (i)); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
746 | |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
747 | replacement->setColor (color()); |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
748 | replace (replacement); |
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
749 | return replacement; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
750 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
751 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
752 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
753 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
754 | LDObject* LDObject::fromID (int id) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
755 | { |
769
8bb3bed44570
- improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
756 | auto it = g_allObjects.find (id); |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
757 | |
769
8bb3bed44570
- improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
758 | if (it != g_allObjects.end()) |
8bb3bed44570
- improved shared pointer behavior, still not there yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
759 | return *it; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
760 | |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
761 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
762 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
763 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
764 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
765 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
766 | QString LDOverlay::asText() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
767 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
768 | return format ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
769 | fileName(), camera(), x(), y(), width(), height()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
770 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
771 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
772 | void LDOverlay::invert() {} |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
773 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
774 | // ============================================================================= |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
775 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
776 | // Hook the set accessors of certain properties to this changeProperty function. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
777 | // It takes care of history management so we can capture low-level changes, this |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
778 | // makes history stuff work out of the box. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
779 | // |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
767
diff
changeset
|
780 | template<typename T> |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
781 | static void changeProperty (LDObject* obj, T* ptr, const T& val) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
782 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
783 | int idx; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
784 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
785 | if (*ptr == val) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
786 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
787 | |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
788 | if (obj->document() and (idx = obj->lineNumber()) != -1) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
789 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
790 | QString before = obj->asText(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
791 | *ptr = val; |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
787
diff
changeset
|
792 | QString after = obj->asText(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
793 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
794 | if (before != after) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
795 | { |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
796 | obj->document()->addToHistory (new EditHistoryEntry (idx, before, after)); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
797 | g_win->renderer()->compileObject (obj); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
798 | g_win->currentDocument()->redoVertices(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
799 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
800 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
801 | else |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
802 | { |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
803 | *ptr = val; |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
804 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
805 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
806 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
807 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
808 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
809 | void LDObject::setColor (LDColor color) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
810 | { |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
811 | changeProperty (this, &m_color, color); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
812 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
813 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
814 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
815 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
816 | // Get a vertex by index |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
817 | // |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
818 | const Vertex& LDVertexObject::vertex (int i) const |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
819 | { |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
820 | return m_coordinates[i]; |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
821 | } |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
822 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
823 | QSet<Vertex> LDVertexObject::vertexSet() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
824 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
825 | QSet<Vertex> result; |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
826 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
827 | for (int i = 0; i < numVertices(); ++i) |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
828 | result.insert (vertex (i)); |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
829 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
830 | return result; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
831 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
832 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
833 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
834 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
835 | // Set a vertex to the given value |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
836 | // |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
837 | void LDVertexObject::setVertex (int i, const Vertex& vert) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
838 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
839 | changeProperty (this, &m_coordinates[i], vert); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
840 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
841 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
842 | LDMatrixObject::LDMatrixObject (LDDocument* document) : |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
843 | LDObject (document), |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
844 | m_position (Origin) {} |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
845 | |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
846 | LDMatrixObject::LDMatrixObject (const Matrix& transformationMatrix, const Vertex& position, LDDocument* document) : |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
847 | LDObject (document), |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
848 | m_position (position), |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
849 | m_transformationMatrix (transformationMatrix) {} |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
850 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
851 | void LDMatrixObject::setCoordinate (const Axis ax, double value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
852 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
853 | Vertex v = position(); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
854 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
855 | switch (ax) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
856 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
857 | case X: v.setX (value); break; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
858 | case Y: v.setY (value); break; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
859 | case Z: v.setZ (value); break; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
860 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
861 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
862 | setPosition (v); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
863 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
864 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
865 | const Vertex& LDMatrixObject::position() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
866 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
867 | return m_position; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
868 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
869 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
870 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
871 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
872 | void LDMatrixObject::setPosition (const Vertex& a) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
873 | { |
946 | 874 | changeProperty (this, &m_position, a); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
875 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
876 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
877 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
878 | // |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
879 | const Matrix& LDMatrixObject::transformationMatrix() const |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
880 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
881 | return m_transformationMatrix; |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
882 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
883 | |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
884 | void LDMatrixObject::setTransformationMatrix (const Matrix& val) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
885 | { |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
886 | changeProperty (this, &m_transformationMatrix, val); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
887 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
888 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
889 | LDError::LDError (QString contents, QString reason, LDDocument* document) : |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
890 | LDObject (document), |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
891 | m_contents (contents), |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
892 | m_reason (reason) {} |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
893 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
894 | QString LDError::reason() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
895 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
896 | return m_reason; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
897 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
898 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
899 | QString LDError::contents() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
900 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
901 | return m_contents; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
902 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
903 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
904 | QString LDError::fileReferenced() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
905 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
906 | return m_fileReferenced; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
907 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
908 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
909 | void LDError::setFileReferenced (QString value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
910 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
911 | m_fileReferenced = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
912 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
913 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
914 | LDComment::LDComment (QString text, LDDocument* document) : |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
915 | LDObject (document), |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
916 | m_text (text) {} |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
917 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
918 | QString LDComment::text() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
919 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
920 | return m_text; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
921 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
922 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
923 | void LDComment::setText (QString value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
924 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
925 | changeProperty (this, &m_text, value); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
926 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
927 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
928 | LDBfc::LDBfc (const BfcStatement type, LDDocument* document) : |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
929 | LDObject (document), |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
930 | m_statement (type) {} |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
931 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
932 | BfcStatement LDBfc::statement() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
933 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
934 | return m_statement; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
935 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
936 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
937 | void LDBfc::setStatement (BfcStatement value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
938 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
939 | m_statement = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
940 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
941 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
942 | QString LDBfc::statementToString() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
943 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
944 | return LDBfc::statementToString (statement()); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
945 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
946 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
947 | QString LDBfc::statementToString (BfcStatement statement) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
948 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
949 | static const char* statementStrings[] = |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
950 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
951 | "CERTIFY CCW", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
952 | "CCW", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
953 | "CERTIFY CW", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
954 | "CW", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
955 | "NOCERTIFY", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
956 | "INVERTNEXT", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
957 | "CLIP", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
958 | "CLIP CCW", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
959 | "CLIP CW", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
960 | "NOCLIP", |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
961 | }; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
962 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
963 | if ((int) statement >= 0 and (int) statement < countof (statementStrings)) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
964 | return QString::fromLatin1 (statementStrings[(int) statement]); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
965 | else |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
966 | return ""; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
967 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
968 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
969 | int LDOverlay::camera() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
970 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
971 | return m_camera; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
972 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
973 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
974 | void LDOverlay::setCamera (int value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
975 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
976 | m_camera = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
977 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
978 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
979 | int LDOverlay::x() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
980 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
981 | return m_x; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
982 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
983 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
984 | void LDOverlay::setX (int value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
985 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
986 | m_x = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
987 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
988 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
989 | int LDOverlay::y() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
990 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
991 | return m_y; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
992 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
993 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
994 | void LDOverlay::setY (int value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
995 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
996 | m_y = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
997 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
998 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
999 | int LDOverlay::width() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1000 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1001 | return m_width; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1002 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1003 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1004 | void LDOverlay::setWidth (int value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1005 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1006 | m_width = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1007 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1008 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1009 | int LDOverlay::height() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1010 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1011 | return m_height; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1012 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1013 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1014 | void LDOverlay::setHeight (int value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1015 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1016 | m_height = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1017 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1018 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1019 | QString LDOverlay::fileName() const |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1020 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1021 | return m_fileName; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1022 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1023 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1024 | void LDOverlay::setFileName (QString value) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1025 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1026 | m_fileName = value; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1027 | } |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1028 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1029 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1030 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1031 | // Selects this object. |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1032 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1033 | void LDObject::select() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1034 | { |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1035 | if (not isSelected() and document()) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1036 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1037 | m_isSelected = true; |
946 | 1038 | document()->addToSelection (this); |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1039 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1040 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1041 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1042 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1043 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1044 | // Removes this object from selection |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1045 | // |
767
44f0d5322628
- slight refactor in ldobject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
764
diff
changeset
|
1046 | void LDObject::deselect() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1047 | { |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
1048 | if (isSelected() and document()) |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1049 | { |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1050 | m_isSelected = false; |
946 | 1051 | document()->removeFromSelection (this); |
776
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
1052 | |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1053 | // If this object is inverted with INVERTNEXT, deselect the INVERTNEXT as well. |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1054 | LDBfc* invertnext; |
776
624131d0163d
- selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents:
775
diff
changeset
|
1055 | |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1056 | if (previousIsInvertnext (invertnext)) |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1057 | invertnext->deselect(); |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1058 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1059 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1060 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1061 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1062 | // |
848 | 1063 | QString PreferredLicenseText() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1064 | { |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
1065 | return g_win->configBag()->useCaLicense() ? CALicenseText : ""; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1066 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1067 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1068 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1069 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
1070 | LDObject* LDObject::createCopy() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1071 | { |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
1072 | LDObject* copy = ParseLine (asText()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1073 | return copy; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1074 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1075 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1076 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1077 | // |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1078 | LDDocument* LDSubfile::fileInfo() const |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1079 | { |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1080 | return m_fileInfo; |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1081 | } |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1082 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1083 | void LDSubfile::setFileInfo (LDDocument* document) |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1084 | { |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1085 | changeProperty (this, &m_fileInfo, document); |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1086 | |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1087 | // If it's an immediate subfile reference (i.e. this subfile is in an opened document), we need to pre-compile the |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1088 | // GL polygons for the document if they don't exist already. |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1089 | if (document and |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1090 | document->isCache() == false and |
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1091 | document->polygonData().isEmpty()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1092 | { |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
987
diff
changeset
|
1093 | document->initializeCachedData(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1094 | } |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
1095 | } |
725
37b71daf4cb5
- added ability to draw with random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
724
diff
changeset
|
1096 | |
996
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
1097 | void LDObject::getVertices (QVector<Vertex>&) const {} |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
1098 | |
9ecc878c7dea
LDVertexObject stuff (ultimately not worth it)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
995
diff
changeset
|
1099 | void LDVertexObject::getVertices (QVector<Vertex>& verts) const |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
1100 | { |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
1101 | for (int i = 0; i < numVertices(); ++i) |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
1102 | verts << vertex (i); |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
1103 | } |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
1104 | |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
1105 | void LDSubfile::getVertices (QVector<Vertex>& verts) const |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
1106 | { |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
1107 | verts << fileInfo()->inlineVertices(); |
959
737245eee433
Remove the vertex object type
Teemu Piippo <crimsondusk64@gmail.com>
parents:
958
diff
changeset
|
1108 | } |