src/parser.cpp

changeset 141
185eb297dc1e
parent 140
2f383e88acf4
child 144
5d73a6717321
equal deleted inserted replaced
140:2f383e88acf4 141:185eb297dc1e
251 { 251 {
252 editor.invertObject(id); 252 editor.invertObject(id);
253 } 253 }
254 invertNext = false; 254 invertNext = false;
255 } 255 }
256 /*
256 // Test quadrilateral splitting by splitting all the quadrilaterals 257 // Test quadrilateral splitting by splitting all the quadrilaterals
257 QVector<ldraw::quadrilateralid_t> quadrilateral_ids; 258 QVector<ldraw::quadrilateralid_t> quadrilateral_ids;
258 for (int i = 0; i < editor.model().size(); i += 1) 259 for (int i = 0; i < editor.model().size(); i += 1)
259 { 260 {
260 const ldraw::id_t id = editor.model().resolve(editor.model().index(i)); 261 const ldraw::id_t id = editor.model().resolve(editor.model().index(i));
266 } 267 }
267 for (const ldraw::quadrilateralid_t id : quadrilateral_ids) 268 for (const ldraw::quadrilateralid_t id : quadrilateral_ids)
268 { 269 {
269 ldraw::splitQuadrilateral(editor, id); 270 ldraw::splitQuadrilateral(editor, id);
270 } 271 }
272 */
271 } 273 }
272 274
273 static ldraw::Color colorFromString(const QString& colorString) 275 static ldraw::Color colorFromString(const QString& colorString)
274 { 276 {
275 bool colorSucceeded; 277 bool colorSucceeded;
342 const QStringList& tokens) 344 const QStringList& tokens)
343 { 345 {
344 Q_UNUSED(tokens) 346 Q_UNUSED(tokens)
345 if (line.startsWith("0 //")) 347 if (line.startsWith("0 //"))
346 { 348 {
347 return std::make_unique<ldraw::Comment>(line.mid(std::strlen("0 //")).simplified()); 349 // lol wut
350 return std::make_unique<ldraw::Comment>(line.mid(std::strlen("0 //")).trimmed());
348 } 351 }
349 else 352 else
350 { 353 {
351 return std::make_unique<ldraw::MetaCommand>(line.mid(1).simplified()); 354 return std::make_unique<ldraw::MetaCommand>(line.mid(1).trimmed());
352 } 355 }
353 } 356 }
354 357
355 static std::unique_ptr<ldraw::SubfileReference> parseType1Line( 358 static std::unique_ptr<ldraw::SubfileReference> parseType1Line(
356 const QString& line, 359 const QString& line,
392 return std::make_unique<T>(vertices, color); 395 return std::make_unique<T>(vertices, color);
393 } 396 }
394 397
395 std::unique_ptr<ldraw::Object> Parser::parseFromString(QString line) 398 std::unique_ptr<ldraw::Object> Parser::parseFromString(QString line)
396 { 399 {
397 line = line.simplified(); 400 line = line.trimmed();
398 try 401 try
399 { 402 {
400 const QStringList tokens = line.split(QRegExp{R"(\s+)"}); 403 const QStringList tokens = line.split(QRegExp{R"(\s+)"});
401 if (tokens.empty() or tokens == QStringList{{""}}) 404 if (tokens.empty() or tokens == QStringList{{""}})
402 { 405 {

mercurial