358 line.chop (1); |
358 line.chop (1); |
359 |
359 |
360 LDObject* obj = parseLine (line); |
360 LDObject* obj = parseLine (line); |
361 |
361 |
362 // Check for parse errors and warn about tthem |
362 // Check for parse errors and warn about tthem |
363 if (obj->getType() == LDObject::Error) |
363 if (obj->getType() == LDObject::EError) |
364 { |
364 { |
365 log ("Couldn't parse line #%1: %2", getProgress() + 1, static_cast<LDError*> (obj)->reason); |
365 log ("Couldn't parse line #%1: %2", getProgress() + 1, static_cast<LDError*> (obj)->reason); |
366 |
366 |
367 if (getWarnings() != null) |
367 if (getWarnings() != null) |
368 (*getWarnings())++; |
368 (*getWarnings())++; |
675 // If the second object in the list holds the file name, update that now. |
675 // If the second object in the list holds the file name, update that now. |
676 // Only do this if the file is explicitly open. |
676 // Only do this if the file is explicitly open. |
677 LDComment* fpathComment = null; |
677 LDComment* fpathComment = null; |
678 LDObject* first = getObject (1); |
678 LDObject* first = getObject (1); |
679 |
679 |
680 if (!isImplicit() && first != null && first->getType() == LDObject::Comment) |
680 if (!isImplicit() && first != null && first->getType() == LDObject::EComment) |
681 { |
681 { |
682 fpathComment = static_cast<LDComment*> (first); |
682 fpathComment = static_cast<LDComment*> (first); |
683 |
683 |
684 if (fpathComment->text.left (6) == "Name: ") |
684 if (fpathComment->text.left (6) == "Name: ") |
685 { |
685 { |
749 } |
749 } |
750 } |
750 } |
751 |
751 |
752 // ============================================================================= |
752 // ============================================================================= |
753 // ----------------------------------------------------------------------------- |
753 // ----------------------------------------------------------------------------- |
754 static vertex parseVertex (QStringList& s, const int n) |
754 static Vertex parseVertex (QStringList& s, const int n) |
755 { |
755 { |
756 vertex v; |
756 Vertex v; |
757 |
757 |
758 for_axes (ax) |
758 for_axes (ax) |
759 v[ax] = s[n + ax].toDouble(); |
759 v[ax] = s[n + ax].toDouble(); |
760 |
760 |
761 return v; |
761 return v; |
878 |
878 |
879 LDSubfile* obj = new LDSubfile; |
879 LDSubfile* obj = new LDSubfile; |
880 obj->setColor (tokens[1].toLong()); |
880 obj->setColor (tokens[1].toLong()); |
881 obj->setPosition (parseVertex (tokens, 2)); // 2 - 4 |
881 obj->setPosition (parseVertex (tokens, 2)); // 2 - 4 |
882 |
882 |
883 matrix transform; |
883 Matrix transform; |
884 |
884 |
885 for (int i = 0; i < 9; ++i) |
885 for (int i = 0; i < 9; ++i) |
886 transform[i] = tokens[i + 5].toDouble(); // 5 - 13 |
886 transform[i] = tokens[i + 5].toDouble(); // 5 - 13 |
887 |
887 |
888 obj->setTransform (transform); |
888 obj->setTransform (transform); |
977 g_loadedFiles << getCurrentDocument(); |
977 g_loadedFiles << getCurrentDocument(); |
978 |
978 |
979 // Go through all objects in the current file and reload the subfiles |
979 // Go through all objects in the current file and reload the subfiles |
980 for (LDObject* obj : getCurrentDocument()->getObjects()) |
980 for (LDObject* obj : getCurrentDocument()->getObjects()) |
981 { |
981 { |
982 if (obj->getType() == LDObject::Subfile) |
982 if (obj->getType() == LDObject::ESubfile) |
983 { |
983 { |
984 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
984 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
985 LDDocument* fileInfo = getDocument (ref->getFileInfo()->getName()); |
985 LDDocument* fileInfo = getDocument (ref->getFileInfo()->getName()); |
986 |
986 |
987 if (fileInfo) |
987 if (fileInfo) |
990 ref->replace (new LDError (ref->raw(), fmt ("Could not open %1", ref->getFileInfo()->getName()))); |
990 ref->replace (new LDError (ref->raw(), fmt ("Could not open %1", ref->getFileInfo()->getName()))); |
991 } |
991 } |
992 |
992 |
993 // Reparse gibberish files. It could be that they are invalid because |
993 // Reparse gibberish files. It could be that they are invalid because |
994 // of loading errors. Circumstances may be different now. |
994 // of loading errors. Circumstances may be different now. |
995 if (obj->getType() == LDObject::Error) |
995 if (obj->getType() == LDObject::EError) |
996 obj->replace (parseLine (static_cast<LDError*> (obj)->contents)); |
996 obj->replace (parseLine (static_cast<LDError*> (obj)->contents)); |
997 } |
997 } |
998 } |
998 } |
999 |
999 |
1000 // ============================================================================= |
1000 // ============================================================================= |
1002 int LDDocument::addObject (LDObject* obj) |
1002 int LDDocument::addObject (LDObject* obj) |
1003 { |
1003 { |
1004 getHistory()->add (new AddHistory (getObjects().size(), obj)); |
1004 getHistory()->add (new AddHistory (getObjects().size(), obj)); |
1005 m_Objects << obj; |
1005 m_Objects << obj; |
1006 |
1006 |
1007 if (obj->getType() == LDObject::Vertex) |
1007 if (obj->getType() == LDObject::EVertex) |
1008 m_Vertices << obj; |
1008 m_Vertices << obj; |
1009 |
1009 |
1010 #ifdef DEBUG |
1010 #ifdef DEBUG |
1011 if (!isImplicit()) |
1011 if (!isImplicit()) |
1012 dlog ("Added object #%1 (%2)\n", obj->getID(), obj->getTypeName()); |
1012 dlog ("Added object #%1 (%2)\n", obj->getID(), obj->getTypeName()); |
1173 continue; |
1173 continue; |
1174 |
1174 |
1175 // Got another sub-file reference, inline it if we're deep-inlining. If not, |
1175 // Got another sub-file reference, inline it if we're deep-inlining. If not, |
1176 // just add it into the objects normally. Also, we only cache immediate |
1176 // just add it into the objects normally. Also, we only cache immediate |
1177 // subfiles and this is not one. Yay, recursion! |
1177 // subfiles and this is not one. Yay, recursion! |
1178 if (deep && obj->getType() == LDObject::Subfile) |
1178 if (deep && obj->getType() == LDObject::ESubfile) |
1179 { |
1179 { |
1180 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
1180 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
1181 |
1181 |
1182 // We only want to cache immediate subfiles, so shed the caching |
1182 // We only want to cache immediate subfiles, so shed the caching |
1183 // flag when recursing deeper in hierarchy. |
1183 // flag when recursing deeper in hierarchy. |