Sun, 09 Apr 2023 16:23:05 +0300
Add undo, redo, cut, copy and paste actions to MainWindow which pass onto the editor widget
3 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
24 | 3 | * Copyright (C) 2013 - 2020 Teemu Piippo |
3 | 4 | * |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
19 | #include <QRegularExpression> |
259
c27612f0eac0
- Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
242
diff
changeset
|
20 | #include <QIODevice> |
264
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
259
diff
changeset
|
21 | #include "src/ldrawalgorithm.h" |
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
259
diff
changeset
|
22 | #include "src/model.h" |
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
259
diff
changeset
|
23 | #include "src/parser.h" |
3 | 24 | |
335 | 25 | #define NUMBER_REGEX R"(([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))))" |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
26 | #define SPACE_REGEX R"(\s+)" |
335 | 27 | #define VEC3_REGEX NUMBER_REGEX SPACE_REGEX NUMBER_REGEX SPACE_REGEX NUMBER_REGEX |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
28 | #define TWO_VECTORS VEC3_REGEX SPACE_REGEX VEC3_REGEX |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
29 | #define THREE_VECTORS TWO_VECTORS SPACE_REGEX VEC3_REGEX |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
30 | #define FOUR_VECTORS THREE_VECTORS SPACE_REGEX VEC3_REGEX |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
5
diff
changeset
|
31 | |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
32 | static const auto& exprs() |
3 | 33 | { |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
34 | static const struct |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
35 | { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
36 | QRegularExpression subfileRe{QStringLiteral( |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
37 | R"(^\s*(1)\s+(\d+)\s+)" FOUR_VECTORS SPACE_REGEX R"(([^ ]+)\s*$)" |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
38 | )}; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
39 | QRegularExpression edgeRe{QStringLiteral( |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
40 | R"(^\s*(2)\s+(\d+)\s+)" TWO_VECTORS R"(\s*$)" |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
41 | )}; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
42 | QRegularExpression triangleRe{QStringLiteral( |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
43 | R"(^\s*(3)\s+(\d+)\s+)" THREE_VECTORS R"(\s*$)" |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
44 | )}; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
45 | QRegularExpression quadRe{QStringLiteral( |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
46 | R"(^\s*(4)\s+(\d+)\s+)" FOUR_VECTORS R"(\s*$)" |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
47 | )}; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
48 | QRegularExpression cedgeRe{QStringLiteral( |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
49 | R"(^\s*(5)\s+(\d+)\s+)" FOUR_VECTORS R"(\s*$)" |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
50 | )}; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
51 | #if 0 |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
52 | QRegularExpression bfcRe{QStringLiteral( |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
53 | R"(^\s*(0) (BFC (?:CERTIFY CCW|CERTIFY CW|NOCERTIFY|INVERTNEXT|CLIP|NOCLIP))\s*$)" |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
54 | )}; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
55 | #endif |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
56 | QRegularExpression commentRe{QStringLiteral( |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
57 | R"(^\s*(0)\s+(.+)$)" |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
58 | )}; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
59 | } result; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
60 | return result; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
61 | } |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
62 | template<Attribute Attrib, typename T, Attribute... Attribs> |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
63 | QString attrib(const LineType<T, Attribs...>& parsed) |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
64 | { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
65 | const int index = attribIndex<LineType<T, Attribs...>, Attrib>; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
66 | const TextRange& range = parsed.positions[index]; |
335 | 67 | const QString content = parsed.content; |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
68 | return parsed.content.mid(range.start, range.length); |
3 | 69 | } |
70 | ||
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
71 | template<Attribute X, Attribute Y, Attribute Z, typename T, Attribute... Attribs> |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
72 | glm::vec3 vectorAttrib(const LineType<T, Attribs...>& parsed) |
3 | 73 | { |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
74 | return glm::vec3{ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
75 | attrib<X>(parsed).toFloat(), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
76 | attrib<Y>(parsed).toFloat(), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
77 | attrib<Z>(parsed).toFloat(), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
78 | }; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
79 | } |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
80 | |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
81 | template<typename T> |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
82 | ColorIndex colorAttrib(T* parsed) |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
83 | { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
84 | return ColorIndex{attrib<Attribute::Color>(*parsed).toInt()}; |
3 | 85 | } |
86 | ||
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
87 | opt<ParsedLine> parse(const QString& line) |
4
68988ebc2a68
added regular expressions for the parser
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
88 | { |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
89 | const auto tryRe = [&line](const QRegularExpression& re){ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
90 | opt<QRegularExpressionMatch> result = re.match(line); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
91 | if (not result->hasMatch()) { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
92 | result.reset(); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
93 | } |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
94 | return result; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
95 | }; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
96 | opt<ParsedLine> result; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
97 | //! \brief Put value into result, add matched ranges to it and return a pointer |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
98 | const auto init = [&]<typename T>(T&& value, const QRegularExpressionMatch& match){ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
99 | result = value; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
100 | T* parsed = &std::get<T>(*result); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
101 | for (int i = 0; i < countof(T::attributes); ++i) { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
102 | parsed->positions[i] = { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
103 | .start = match.capturedStart(i + 1), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
104 | .length = match.capturedLength(i + 1), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
105 | }; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
106 | } |
335 | 107 | parsed->content = match.captured(0); |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
108 | return parsed; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
109 | }; |
358
ef90ed0a5720
Hopefully fixed all problems with determining polygon winding
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
335
diff
changeset
|
110 | if (auto line1Match = tryRe(exprs().commentRe)) { |
ef90ed0a5720
Hopefully fixed all problems with determining polygon winding
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
335
diff
changeset
|
111 | LineType0* const parsed = init(LineType0{}, *line1Match); |
ef90ed0a5720
Hopefully fixed all problems with determining polygon winding
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
335
diff
changeset
|
112 | parsed->value = Comment{attrib<Attribute::Text>(*parsed)}; |
ef90ed0a5720
Hopefully fixed all problems with determining polygon winding
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
335
diff
changeset
|
113 | } |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
114 | if (auto line1Match = tryRe(exprs().subfileRe)) { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
115 | LineType1* const parsed = init(LineType1{}, *line1Match); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
116 | parsed->value = { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
117 | SubfileReference{ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
118 | .name = attrib<Attribute::Name>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
119 | .transformation = glm::mat4{ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
120 | glm::vec4{vectorAttrib<Attribute::X2, Attribute::Y2, Attribute::Z2>(*parsed), 0}, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
121 | glm::vec4{vectorAttrib<Attribute::X3, Attribute::Y3, Attribute::Z3>(*parsed), 0}, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
122 | glm::vec4{vectorAttrib<Attribute::X4, Attribute::Y4, Attribute::Z4>(*parsed), 0}, |
358
ef90ed0a5720
Hopefully fixed all problems with determining polygon winding
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
335
diff
changeset
|
123 | glm::vec4{vectorAttrib<Attribute::X1, Attribute::Y1, Attribute::Z1>(*parsed), 1} |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
124 | }, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
125 | }, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
126 | colorAttrib(parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
127 | }; |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
5
diff
changeset
|
128 | } |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
129 | else if (auto line2Match = tryRe(exprs().edgeRe)) { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
130 | LineType2* const parsed = init(LineType2{}, *line2Match); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
131 | parsed->value = { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
132 | LineSegment{ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
133 | .p1 = vectorAttrib<Attribute::X1, Attribute::Y1, Attribute::Z1>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
134 | .p2 = vectorAttrib<Attribute::X2, Attribute::Y2, Attribute::Z2>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
135 | }, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
136 | colorAttrib(parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
137 | }; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
138 | } |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
139 | else if (auto line3Match = tryRe(exprs().triangleRe)) { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
140 | LineType3* const parsed = init(LineType3{}, *line3Match); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
141 | parsed->value = { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
142 | Triangle{ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
143 | .p1 = vectorAttrib<Attribute::X1, Attribute::Y1, Attribute::Z1>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
144 | .p2 = vectorAttrib<Attribute::X2, Attribute::Y2, Attribute::Z2>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
145 | .p3 = vectorAttrib<Attribute::X3, Attribute::Y3, Attribute::Z3>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
146 | }, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
147 | colorAttrib(parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
148 | }; |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
149 | } |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
150 | else if (auto line4Match = tryRe(exprs().quadRe)) { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
151 | LineType4* const parsed = init(LineType4{}, *line4Match); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
152 | parsed->value = { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
153 | Quadrilateral{ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
154 | .p1 = vectorAttrib<Attribute::X1, Attribute::Y1, Attribute::Z1>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
155 | .p2 = vectorAttrib<Attribute::X2, Attribute::Y2, Attribute::Z2>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
156 | .p3 = vectorAttrib<Attribute::X3, Attribute::Y3, Attribute::Z3>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
157 | .p4 = vectorAttrib<Attribute::X4, Attribute::Y4, Attribute::Z4>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
158 | }, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
159 | colorAttrib(parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
160 | }; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
161 | } |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
162 | else if (auto line5Match = tryRe(exprs().cedgeRe)) { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
163 | LineType5* const parsed = init(LineType5{}, *line5Match); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
164 | parsed->value = { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
165 | ConditionalEdge{ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
166 | .p1 = vectorAttrib<Attribute::X1, Attribute::Y1, Attribute::Z1>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
167 | .p2 = vectorAttrib<Attribute::X2, Attribute::Y2, Attribute::Z2>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
168 | .c1 = vectorAttrib<Attribute::X3, Attribute::Y3, Attribute::Z3>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
169 | .c2 = vectorAttrib<Attribute::X4, Attribute::Y4, Attribute::Z4>(*parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
170 | }, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
171 | colorAttrib(parsed), |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
172 | }; |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
5
diff
changeset
|
173 | } |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
5
diff
changeset
|
174 | return result; |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
5
diff
changeset
|
175 | } |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
5
diff
changeset
|
176 | |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
177 | #if 0 |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
178 | static QRegExp re{R"((?:(\d+)\\)?(\d+)-(\d)+([a-z]+)\.dat)"}; |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
179 | if (re.exactMatch(name)) { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
180 | const auto p = std::find(std::begin(circularPrimitiveStems), std::end(circularPrimitiveStems), re.cap(4)); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
181 | const unsigned int divisions = (re.cap(1).isEmpty()) ? 16 : re.cap(1).toUInt(); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
182 | const unsigned int segments = re.cap(2).toUInt() * divisions / re.cap(3).toUInt(); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
183 | if (p != std::end(circularPrimitiveStems)) { |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
184 | const auto type = static_cast<CircularPrimitive::Type>(p - std::begin(circularPrimitiveStems)); |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
185 | return Colored<CircularPrimitive>{ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
186 | CircularPrimitive{ |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
187 | .type = type, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
188 | .fraction = {segments, divisions}, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
189 | .transformation = transform, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
190 | }, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
191 | color, |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
192 | }; |
5 | 193 | } |
194 | } | |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
195 | #endif |
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
328
diff
changeset
|
196 |