Sat, 05 Sep 2015 23:55:06 +0300
Refactor LDDocument's API
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 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QMessageBox> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QFileDialog> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QDir> |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
22 | #include <QTime> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QApplication> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "main.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "ldDocument.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "miscallenous.h" |
962
a4b463a7ee82
Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
959
diff
changeset
|
27 | #include "mainwindow.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #include "editHistory.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include "glRenderer.h" |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
30 | #include "glCompiler.h" |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
31 | #include "partDownloader.h" |
953
8349552ee5e9
Refactor LDrawPathDialog and LDPaths
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
32 | #include "ldpaths.h" |
957
429c7ed3cc54
Refactor OpenProgressDialog out of dialogs.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents:
954
diff
changeset
|
33 | #include "dialogs/openprogressdialog.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | |
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
|
35 | ConfigOption (QStringList RecentFiles) |
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
|
36 | ConfigOption (bool TryDownloadMissingFiles = false) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | static bool g_loadingMainFile = false; |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
39 | enum { MAX_RECENT_FILES = 10 }; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | static bool g_aborted = false; |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
41 | static LDDocument* g_logoedStud; |
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
42 | static LDDocument* g_logoedStud2; |
877
7c50b61ad5b6
- fixed infinite recursion when loading logoed studs
Teemu Piippo <crimsondusk64@gmail.com>
parents:
872
diff
changeset
|
43 | static bool g_loadingLogoedStuds = false; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | const QStringList g_specialSubdirectories ({ "s", "48", "8" }); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
46 | LDDocument::LDDocument (QObject* parent) : |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
47 | QObject (parent), |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
48 | HierarchyElement (parent), |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
953
diff
changeset
|
49 | m_history (new History), |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
50 | m_isCache (true), |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
51 | m_verticesOutdated (true), |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
52 | m_needVertexMerge (true), |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
53 | m_beingDestroyed (false), |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | m_gldata (new LDGLData) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | setSavePosition (-1); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | setTabIndex (-1); |
949
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
58 | m_history->setDocument (this); |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
59 | m_needsReCache = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | LDDocument::~LDDocument() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | { |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
64 | m_beingDestroyed = true; |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
65 | delete m_history; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | delete m_gldata; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
69 | QString LDDocument::name() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
70 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
71 | return m_name; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
72 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
73 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
74 | void LDDocument::setName (QString value) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
75 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
76 | m_name = value; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
77 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
78 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
79 | const LDObjectList& LDDocument::objects() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
80 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
81 | return m_objects; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
82 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
83 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
84 | History* LDDocument::history() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
85 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
86 | return m_history; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
87 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
88 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
89 | QString LDDocument::fullPath() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
90 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
91 | return m_fullPath; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
92 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
93 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
94 | void LDDocument::setFullPath (QString value) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | { |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
96 | m_fullPath = value; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
97 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
98 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
99 | int LDDocument::tabIndex() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
100 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
101 | return m_tabIndex; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
102 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
103 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
104 | void LDDocument::setTabIndex (int value) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
105 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
106 | m_tabIndex = value; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
107 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
108 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
109 | const QList<LDPolygon>& LDDocument::polygonData() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
110 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
111 | return m_polygonData; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
112 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
113 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
114 | long LDDocument::savePosition() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
115 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
116 | return m_savePosition; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
117 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
118 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
119 | void LDDocument::setSavePosition (long value) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
120 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
121 | m_savePosition = value; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
122 | } |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
123 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
124 | QString LDDocument::defaultName() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
125 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
126 | return m_defaultName; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
127 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
128 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
129 | void LDDocument::setDefaultName (QString value) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
130 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
131 | m_defaultName = value; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
132 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
133 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
134 | void LDDocument::openForEditing() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
135 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
136 | if (m_isCache) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
137 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
138 | m_isCache = false; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
139 | print ("Opened %1", name()); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
140 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
141 | // Cache files are not compiled by the GL renderer. Now that this file is open for editing, it needs to be |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
142 | // compiled. |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
143 | m_window->R()->compiler()->compileDocument (this); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
144 | m_window->updateDocumentList(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
145 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
146 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
147 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
148 | bool LDDocument::isCache() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
149 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
150 | return m_isCache; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
151 | } |
788
c9d1dad83ad0
- added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
786
diff
changeset
|
152 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
153 | void LDDocument::addHistoryStep() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
154 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
155 | history()->addStep(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
156 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
157 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
158 | void LDDocument::undo() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
159 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
160 | history()->undo(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
161 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
162 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
163 | void LDDocument::redo() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
164 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
165 | history()->redo(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
166 | } |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
167 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
168 | void LDDocument::clearHistory() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
169 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
170 | history()->clear(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
171 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
172 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
173 | void LDDocument::addToHistory (AbstractHistoryEntry* entry) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
174 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
175 | *history() << entry; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
176 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
177 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
178 | void LDDocument::close() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
179 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
180 | if (not isCache()) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
181 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
182 | m_isCache = true; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
183 | print ("Closed %1", name()); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
184 | m_window->updateDocumentList(); |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
185 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
186 | // If the current document just became implicit (i.e. user closed it), we need to get a new one to show. |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
187 | if (currentDocument() == this) |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
188 | m_window->currentDocumentClosed(); |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
189 | } |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
190 | } |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
191 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
192 | LDGLData* LDDocument::glData() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
193 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
194 | return m_gldata; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
195 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
196 | |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
197 | // ============================================================================= |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
198 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
199 | LDDocument* FindDocument (QString name) |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
200 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
201 | for (LDDocument* document : g_win->allDocuments()) |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
202 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
203 | if (isOneOf (name, document->name(), document->defaultName())) |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
204 | return document; |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
205 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
207 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
212 | QString Dirname (QString path) |
655
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 | long lastpos = path.lastIndexOf (DIRSLASH); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | if (lastpos > 0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | return path.left (lastpos); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | #ifndef _WIN32 |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
220 | if (path[0] == DIRSLASH_CHAR) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | return DIRSLASH; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | #endif // _WIN32 |
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 | return ""; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | |
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 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
229 | QString Basename (QString path) |
655
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 | long lastpos = path.lastIndexOf (DIRSLASH); |
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 | if (lastpos != -1) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | return path.mid (lastpos + 1); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | return path; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
238 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
241 | static QString FindDocumentPath (QString relpath, bool subdirs) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
243 | QString fullPath; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
245 | // LDraw models use backslashes as path separators. Replace those into forward slashes for Qt. |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | relpath.replace ("\\", "/"); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
248 | // Try find it relative to other currently open documents. We want a file in the immediate vicinity of a current |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
249 | // part model to override stock LDraw stuff. |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
250 | QString reltop = Basename (Dirname (relpath)); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
252 | for (LDDocument* doc : g_win->allDocuments()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
254 | QString partpath = format ("%1/%2", Dirname (doc->fullPath()), relpath); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | QFile f (partpath); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | if (f.exists()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | // ensure we don't mix subfiles and 48-primitives with non-subfiles and non-48 |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
260 | QString proptop = Basename (Dirname (partpath)); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | bool bogus = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
263 | |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
264 | for (QString s : g_specialSubdirectories) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
265 | { |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
266 | if ((proptop == s and reltop != s) or (reltop == s and proptop != s)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | bogus = true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
270 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
271 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
272 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
273 | if (not bogus) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | return partpath; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
275 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
276 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
277 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
278 | if (QFile::exists (relpath)) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
279 | return relpath; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
280 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
281 | // Try with just the LDraw path first |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
282 | fullPath = format ("%1" DIRSLASH "%2", g_win->configBag()->lDrawPath(), relpath); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
283 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | if (QFile::exists (fullPath)) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
285 | return fullPath; |
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 | if (subdirs) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
288 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
289 | // Look in sub-directories: parts and p. Also look in the download path, since that's where we download parts |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
290 | // from the PT to. |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
291 | QStringList dirs = { g_win->configBag()->lDrawPath(), g_win->configBag()->downloadFilePath() }; |
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
|
292 | for (const QString& topdir : dirs) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | { |
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
|
294 | for (const QString& subdir : QStringList ({ "parts", "p" })) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
296 | fullPath = format ("%1" DIRSLASH "%2" DIRSLASH "%3", topdir, subdir, relpath); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | if (QFile::exists (fullPath)) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | return fullPath; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
301 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
303 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
304 | // Did not find the file. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | return ""; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
307 | |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
308 | // ============================================================================= |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
309 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
310 | QFile* OpenLDrawFile (QString relpath, bool subdirs, QString* pathpointer) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | print ("Opening %1...\n", relpath); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
313 | QString path = FindDocumentPath (relpath, subdirs); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
315 | if (pathpointer != null) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
316 | *pathpointer = path; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | if (path.isEmpty()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
319 | return null; |
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 | QFile* fp = new QFile (path); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | if (fp->open (QIODevice::ReadOnly)) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
324 | return fp; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | fp->deleteLater(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | return null; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | void LDFileLoader::start() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | setDone (false); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | setProgress (0); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | setAborted (false); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | if (isOnForeground()) |
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 | g_aborted = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | // Show a progress dialog if we're loading the main ldDocument.here so we can |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
343 | // show progress updates and keep the WM posted that we're still here. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | // Of course we cannot exec() the dialog because then the dialog would |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
345 | // block. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | dlg = new OpenProgressDialog (g_win); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | dlg->setNumLines (lines().size()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | dlg->setModal (true); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | dlg->show(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
350 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
351 | // Connect the loader in so we can show updates |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | connect (this, SIGNAL (workDone()), dlg, SLOT (accept())); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | connect (dlg, SIGNAL (rejected()), this, SLOT (abort())); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
356 | dlg = null; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | // Begin working |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | work (0); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
360 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
361 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
362 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
363 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | void LDFileLoader::work (int i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | // User wishes to abort, so stop here now. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
367 | if (isAborted()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
368 | { |
944 | 369 | for (LDObject* obj : m_objects) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | obj->destroy(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | m_objects.clear(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | setDone (true); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
376 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
377 | // Parse up to 300 lines per iteration |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
378 | int max = i + 300; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
380 | for (; i < max and i < (int) lines().size(); ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
382 | QString line = lines()[i]; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
383 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
384 | // Trim the trailing newline |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
385 | QChar c; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
386 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
387 | while (line.endsWith ("\n") or line.endsWith ("\r")) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | line.chop (1); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
389 | |
944 | 390 | LDObject* obj = ParseLine (line); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
391 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | // Check for parse errors and warn about tthem |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
785
diff
changeset
|
393 | if (obj->type() == OBJ_Error) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
394 | { |
847 | 395 | print ("Couldn't parse line #%1: %2", |
944 | 396 | progress() + 1, static_cast<LDError*> (obj)->reason()); |
655
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 | if (warnings() != null) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
399 | (*warnings())++; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | } |
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 | m_objects << obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
403 | setProgress (i); |
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 have a dialog pointer, update the progress now |
957
429c7ed3cc54
Refactor OpenProgressDialog out of dialogs.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents:
954
diff
changeset
|
406 | if (dlg) |
429c7ed3cc54
Refactor OpenProgressDialog out of dialogs.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents:
954
diff
changeset
|
407 | dlg->setProgress (i); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
408 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | // If we're done now, tell the environment we're done and stop. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | if (i >= ((int) lines().size()) - 1) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
412 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | emit workDone(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | setDone (true); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | // Otherwise, continue, by recursing back. |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
419 | if (not isDone()) |
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 | // If we have a dialog to show progress output to, we cannot just call |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
422 | // work() again immediately as the dialog needs some processor cycles as |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
423 | // well. Thus, take a detour through the event loop by using the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
424 | // meta-object system. |
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 | // This terminates the loop here and control goes back to the function |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
427 | // which called the file loader. It will keep processing the event loop |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | // until we're ready (see loadFileContents), thus the event loop will |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
429 | // eventually catch the invokation we throw here and send us back. Though |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | // it's not technically recursion anymore, more like a for loop. :P |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | if (isOnForeground()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
432 | QMetaObject::invokeMethod (this, "work", Qt::QueuedConnection, Q_ARG (int, i)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
433 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
434 | work (i); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
436 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
437 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
438 | // ============================================================================= |
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 | void LDFileLoader::abort() |
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 | setAborted (true); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
443 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
444 | if (isOnForeground()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
445 | g_aborted = true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
446 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
447 | |
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 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
450 | LDObjectList LoadFileContents (QFile* fp, int* numWarnings, bool* ok) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
451 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
452 | QStringList lines; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
453 | LDObjectList objs; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
454 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
455 | if (numWarnings) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
456 | *numWarnings = 0; |
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 | // Read in the lines |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
459 | while (not fp->atEnd()) |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
460 | lines << QString::fromUtf8 (fp->readLine()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
461 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
462 | LDFileLoader* loader = new LDFileLoader; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
463 | loader->setWarnings (numWarnings); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
464 | loader->setLines (lines); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
465 | loader->setOnForeground (g_loadingMainFile); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
466 | loader->start(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
467 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
468 | // After start() returns, if the loader isn't done yet, it's delaying |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
469 | // its next iteration through the event loop. We need to catch this here |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
470 | // by telling the event loop to tick, which will tick the file loader again. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
471 | // We keep doing this until the file loader is ready. |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
472 | while (not loader->isDone()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
473 | qApp->processEvents(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
474 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
475 | // If we wanted the success value, supply that now |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
476 | if (ok) |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
477 | *ok = not loader->isAborted(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
478 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
479 | objs = loader->objects(); |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
480 | delete loader; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
481 | return objs; |
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 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
486 | LDDocument* OpenDocument (QString path, bool search, bool implicit, LDDocument* fileToOverride) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
487 | { |
872 | 488 | // Convert the file name to lowercase when searching because some parts contain subfile |
489 | // subfile references with uppercase file names. I'll assume here that the library will always | |
490 | // use lowercase file names for the part files. | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
491 | QFile* fp; |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
492 | QString fullpath; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
493 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
494 | if (search) |
872 | 495 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
496 | fp = OpenLDrawFile (path.toLower(), true, &fullpath); |
872 | 497 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
498 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
500 | fp = new QFile (path); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
501 | fullpath = path; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
502 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
503 | if (not fp->open (QIODevice::ReadOnly)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
504 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
505 | delete fp; |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
506 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
507 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
508 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
509 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
510 | if (not fp) |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
511 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
512 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
513 | LDDocument* load = (fileToOverride != null ? fileToOverride : g_win->newDocument (implicit)); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
514 | load->setFullPath (fullpath); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
515 | load->setName (LDDocument::shortenName (load->fullPath())); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
516 | |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
517 | // Loading the file shouldn't count as actual edits to the document. |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
518 | load->history()->setIgnoring (true); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
519 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
520 | int numWarnings; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
521 | bool ok; |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
522 | LDObjectList objs = LoadFileContents (fp, &numWarnings, &ok); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
523 | fp->close(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
524 | fp->deleteLater(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
525 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
526 | if (not ok) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
527 | { |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
528 | load->close(); |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
529 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
530 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
531 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
532 | load->addObjects (objs); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
533 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
534 | if (g_loadingMainFile) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
535 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
536 | g_win->changeDocument (load); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
537 | g_win->R()->setDocument (load); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
538 | print (QObject::tr ("File %1 parsed successfully (%2 errors)."), path, numWarnings); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
539 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
540 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
541 | load->history()->setIgnoring (false); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
542 | return load; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
543 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
544 | |
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 | // |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
547 | // Performs safety checks. Do this before closing any files! |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
548 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
549 | bool LDDocument::isSafeToClose() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
550 | { |
847 | 551 | using msgbox = QMessageBox; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
552 | setlocale (LC_ALL, "C"); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
553 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
554 | // If we have unsaved changes, warn and give the option of saving. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
555 | if (hasUnsavedChanges()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
556 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
557 | QString message = format (tr ("There are unsaved changes to %1. Should it be saved?"), getDisplayName()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
558 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
559 | int button = msgbox::question (m_window, QObject::tr ("Unsaved Changes"), message, |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
560 | (msgbox::Yes | msgbox::No | msgbox::Cancel), msgbox::Cancel); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
561 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
562 | switch (button) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
563 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
564 | case msgbox::Yes: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
566 | // If we don't have a file path yet, we have to ask the user for one. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
567 | if (name().length() == 0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
568 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
569 | QString newpath = QFileDialog::getSaveFileName (m_window, QObject::tr ("Save As"), |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
570 | name(), QObject::tr ("LDraw files (*.dat *.ldr)")); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
571 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
572 | if (newpath.length() == 0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
573 | return false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
574 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
575 | setName (newpath); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
576 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
577 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
578 | if (not save()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
579 | { |
920
147497785496
- fixed stability problems
Teemu Piippo <crimsondusk64@gmail.com>
parents:
902
diff
changeset
|
580 | message = format (QObject::tr ("Failed to save %1 (%2)\nDo you still want to close?"), |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
581 | name(), strerror (errno)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
582 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
583 | if (msgbox::critical (m_window, QObject::tr ("Save Failure"), message, |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
584 | (msgbox::Yes | msgbox::No), msgbox::No) == msgbox::No) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
585 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
586 | return false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
587 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
588 | } |
744
bbe0e1834065
- removed rest of the uses of <anonymous>
Santeri Piippo <crimsondusk64@gmail.com>
parents:
739
diff
changeset
|
589 | break; |
bbe0e1834065
- removed rest of the uses of <anonymous>
Santeri Piippo <crimsondusk64@gmail.com>
parents:
739
diff
changeset
|
590 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
591 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
592 | case msgbox::Cancel: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
593 | return false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
594 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
595 | default: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
596 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
597 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
598 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
599 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
600 | return true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
601 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
602 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
603 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
604 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
605 | void CloseAllDocuments() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
606 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
607 | for (LDDocument* file : g_win->allDocuments()) |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
608 | file->close(); |
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 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
613 | void AddRecentFile (QString path) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
614 | { |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
615 | QStringList recentFiles = g_win->configBag()->recentFiles(); |
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
|
616 | int idx = recentFiles.indexOf (path); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
617 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
618 | // If this file already is in the list, pop it out. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
619 | if (idx != -1) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
620 | { |
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
|
621 | if (idx == recentFiles.size() - 1) |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
622 | return; // first recent file - abort and do nothing |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
623 | |
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
|
624 | recentFiles.removeAt (idx); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
625 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
626 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
627 | // If there's too many recent files, drop one out. |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
628 | while (recentFiles.size() > (MAX_RECENT_FILES - 1)) |
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
|
629 | recentFiles.removeAt (0); |
655
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 | // Add the file |
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
|
632 | recentFiles << path; |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
633 | g_win->configBag()->setRecentFiles (recentFiles); |
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
634 | g_win->syncSettings(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
635 | g_win->updateRecentFilesMenu(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
636 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
637 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
638 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
639 | // Open an LDraw file and set it as the main model |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
640 | // ============================================================================= |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
641 | void OpenMainModel (QString path) |
655
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 | // If there's already a file with the same name, this file must replace it. |
946 | 644 | LDDocument* documentToReplace = nullptr; |
645 | LDDocument* file = nullptr; | |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
646 | QString shortName = LDDocument::shortenName (path); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
647 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
648 | for (LDDocument* doc : g_win->allDocuments()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
649 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
650 | if (doc->name() == shortName) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
651 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
652 | documentToReplace = doc; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
653 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
654 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
655 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
656 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
657 | // We cannot open this file if the document this would replace is not |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
658 | // safe to close. |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
659 | if (documentToReplace != null and not documentToReplace->isSafeToClose()) |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
660 | return; |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
661 | |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
662 | g_loadingMainFile = true; |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
663 | |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
664 | // If we're replacing an existing document, clear the document and |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
665 | // make it ready for being loaded to. |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
666 | if (documentToReplace != null) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
667 | { |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
668 | file = documentToReplace; |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
669 | file->clear(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
670 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
671 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
672 | file = OpenDocument (path, false, false, file); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
673 | |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
674 | if (file == null) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
675 | { |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
676 | if (not g_aborted) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
677 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
678 | // Tell the user loading failed. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
679 | setlocale (LC_ALL, "C"); |
882
2f3cc8e045d5
- fixed compilation on windows
Teemu Piippo <crimsondusk64@gmail.com>
parents:
881
diff
changeset
|
680 | Critical (format (QObject::tr ("Failed to open %1: %2"), path, strerror (errno))); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
681 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
682 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
683 | g_loadingMainFile = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
684 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
685 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
686 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
687 | file->openForEditing(); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
688 | g_win->closeInitialDocument(); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
689 | g_win->changeDocument (file); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
690 | g_win->doFullRefresh(); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
691 | AddRecentFile (path); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
692 | g_loadingMainFile = false; |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
693 | |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
694 | // If there were problems loading subfile references, try see if we can find these |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
695 | // files on the parts tracker. |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
696 | QStringList unknowns; |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
697 | |
944 | 698 | for (LDObject* obj : file->objects()) |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
699 | { |
946 | 700 | if (obj->type() != OBJ_Error or static_cast<LDError*> (obj)->fileReferenced().isEmpty()) |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
701 | continue; |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
702 | |
944 | 703 | unknowns << static_cast<LDError*> (obj)->fileReferenced(); |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
704 | } |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
705 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
706 | if (g_win->configBag()->tryDownloadMissingFiles() and not unknowns.isEmpty()) |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
707 | { |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
708 | PartDownloader dl; |
888
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
709 | |
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
710 | if (dl.checkValidPath()) |
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
711 | { |
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
712 | dl.setSource (PartDownloader::PartsTracker); |
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
713 | dl.setPrimaryFile (file); |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
714 | |
888
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
715 | for (QString const& unknown : unknowns) |
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
716 | dl.downloadFromPartsTracker (unknown); |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
717 | |
888
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
718 | dl.exec(); |
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
719 | dl.checkIfFinished(); |
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
720 | file->reloadAllSubfiles(); |
7ad8fb667084
- improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
721 | } |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
722 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
723 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
724 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
725 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
726 | // |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
727 | bool LDDocument::save (QString path, int64* sizeptr) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
728 | { |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
729 | if (isCache()) |
781
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
730 | return false; |
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
731 | |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
732 | if (not path.length()) |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
733 | path = fullPath(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
734 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
735 | // If the second object in the list holds the file name, update that now. |
944 | 736 | LDObject* nameObject = getObject (1); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
737 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
738 | if (nameObject != null and nameObject->type() == OBJ_Comment) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
739 | { |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
740 | LDComment* nameComment = static_cast<LDComment*> (nameObject); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
741 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
742 | if (nameComment->text().left (6) == "Name: ") |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
743 | { |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
744 | QString newname = shortenName (path); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
745 | nameComment->setText (format ("Name: %1", newname)); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
746 | m_window->buildObjList(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
747 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
748 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
749 | |
781
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
750 | QByteArray data; |
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
751 | |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
752 | if (sizeptr != null) |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
753 | *sizeptr = 0; |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
754 | |
944 | 755 | // File is open, now save the model to it. Note that LDraw requires files to have DOS line endings. |
756 | for (LDObject* obj : objects()) | |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
757 | { |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
758 | QByteArray subdata ((obj->asText() + "\r\n").toUtf8()); |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
759 | data.append (subdata); |
781
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
760 | |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
761 | if (sizeptr != null) |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
762 | *sizeptr += subdata.size(); |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
763 | } |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
764 | |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
765 | QFile f (path); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
766 | |
781
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
767 | if (not f.open (QIODevice::WriteOnly)) |
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
768 | return false; |
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
769 | |
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
770 | f.write (data); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
771 | f.close(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
772 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
773 | // We have successfully saved, update the save position now. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
774 | setSavePosition (history()->position()); |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
775 | setFullPath (path); |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
776 | setName (shortenName (path)); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
777 | m_window->updateDocumentListItem (this); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
778 | m_window->updateTitle(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
779 | return true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
780 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
781 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
782 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
783 | // |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
784 | void LDDocument::clear() |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
785 | { |
944 | 786 | for (LDObject* obj : objects()) |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
787 | forgetObject (obj); |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
788 | } |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
789 | |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
790 | // ============================================================================= |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
791 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
792 | static void CheckTokenCount (const QStringList& tokens, int num) |
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 (tokens.size() != num) |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
795 | throw QString (format ("Bad amount of tokens, expected %1, got %2", num, tokens.size())); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
796 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
797 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
798 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
799 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
800 | static void CheckTokenNumbers (const QStringList& tokens, int min, int max) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
801 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
802 | bool ok; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
803 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
804 | QRegExp scient ("\\-?[0-9]+\\.[0-9]+e\\-[0-9]+"); |
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 | for (int i = min; i <= max; ++i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
807 | { |
847 | 808 | // Check for floating point |
809 | tokens[i].toDouble (&ok); | |
810 | if (ok) | |
811 | return; | |
812 | ||
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
813 | // Check hex |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
814 | if (tokens[i].startsWith ("0x")) |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
815 | { |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
816 | tokens[i].mid (2).toInt (&ok, 16); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
817 | |
847 | 818 | if (ok) |
819 | return; | |
820 | } | |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
821 | |
847 | 822 | // Check scientific notation, e.g. 7.99361e-15 |
823 | if (scient.exactMatch (tokens[i])) | |
824 | return; | |
825 | ||
826 | throw QString (format ("Token #%1 was `%2`, expected a number (matched length: %3)", | |
827 | (i + 1), tokens[i], scient.matchedLength())); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
828 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
829 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
830 | |
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 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
833 | static Vertex ParseVertex (QStringList& s, const int n) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
834 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
835 | Vertex v; |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
719
diff
changeset
|
836 | v.apply ([&] (Axis ax, double& a) { a = s[n + ax].toDouble(); }); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
837 | return v; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
838 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
839 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
840 | static int32 StringToNumber (QString a, bool* ok = null) |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
841 | { |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
842 | int base = 10; |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
843 | |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
844 | if (a.startsWith ("0x")) |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
845 | { |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
846 | a.remove (0, 2); |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
847 | base = 16; |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
848 | } |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
849 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
850 | return a.toLong (ok, base); |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
851 | } |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
852 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
853 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
854 | // This is the LDraw code parser function. It takes in a string containing LDraw |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
855 | // code and returns the object parsed from it. parseLine never returns null, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
856 | // the object will be LDError if it could not be parsed properly. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
857 | // ============================================================================= |
944 | 858 | LDObject* ParseLine (QString line) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
859 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
860 | try |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
861 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
862 | QStringList tokens = line.split (" ", QString::SkipEmptyParts); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
863 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
864 | if (tokens.size() <= 0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
865 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
866 | // Line was empty, or only consisted of whitespace |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
867 | return LDSpawn<LDEmpty>(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
868 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
869 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
870 | if (tokens[0].length() != 1 or not tokens[0][0].isDigit()) |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
871 | throw QString ("Illogical line code"); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
872 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
873 | int num = tokens[0][0].digitValue(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
874 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
875 | switch (num) |
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 | case 0: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
878 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
879 | // Comment |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
880 | QString commentText (line.mid (line.indexOf ("0") + 2)); |
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
881 | QString commentTextSimplified (commentText.simplified()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
882 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
883 | // Handle BFC statements |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
884 | if (tokens.size() > 2 and tokens[1] == "BFC") |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
885 | { |
847 | 886 | for_enum (BFCStatement, i) |
887 | { | |
888 | if (commentTextSimplified == format ("BFC %1", | |
889 | LDBFC::StatementStrings[int (i)])) | |
890 | { | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
891 | return LDSpawn<LDBFC> (i); |
847 | 892 | } |
893 | } | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
894 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
895 | // MLCAD is notorious for stuffing these statements in parts it |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
896 | // creates. The above block only handles valid statements, so we |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
897 | // need to handle MLCAD-style invertnext, clip and noclip separately. |
747
17a854ef4412
- simplified the code handling bfc statements a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
746
diff
changeset
|
898 | if (commentTextSimplified == "BFC CERTIFY INVERTNEXT") |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
899 | return LDSpawn<LDBFC> (BFCStatement::InvertNext); |
967 | 900 | else if (commentTextSimplified == "BFC CERTIFY CLIP") |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
901 | return LDSpawn<LDBFC> (BFCStatement::Clip); |
967 | 902 | else if (commentTextSimplified == "BFC CERTIFY NOCLIP") |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
903 | return LDSpawn<LDBFC> (BFCStatement::NoClip); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
904 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
905 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
906 | if (tokens.size() > 2 and tokens[1] == "!LDFORGE") |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
907 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
908 | // Handle LDForge-specific types, they're embedded into comments too |
959
737245eee433
Remove the vertex object type
Teemu Piippo <crimsondusk64@gmail.com>
parents:
958
diff
changeset
|
909 | if (tokens[2] == "OVERLAY") |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
910 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
911 | CheckTokenCount (tokens, 9); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
912 | CheckTokenNumbers (tokens, 5, 8); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
913 | |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
914 | LDOverlay* obj = LDSpawn<LDOverlay>(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
915 | obj->setFileName (tokens[3]); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
916 | obj->setCamera (tokens[4].toLong()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
917 | obj->setX (tokens[5].toLong()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
918 | obj->setY (tokens[6].toLong()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
919 | obj->setWidth (tokens[7].toLong()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
920 | obj->setHeight (tokens[8].toLong()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
921 | return obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
922 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
923 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
924 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
925 | // Just a regular comment: |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
926 | LDComment* obj = LDSpawn<LDComment>(); |
746
893c43b337dd
- don't simplify (aka remove extra whitespace from) comment texts
Santeri Piippo <crimsondusk64@gmail.com>
parents:
744
diff
changeset
|
927 | obj->setText (commentText); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
928 | return obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
929 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
930 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
931 | case 1: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
932 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
933 | // Subfile |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
934 | CheckTokenCount (tokens, 15); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
935 | CheckTokenNumbers (tokens, 1, 13); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
936 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
937 | // Try open the file. Disable g_loadingMainFile temporarily since we're |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
938 | // not loading the main file now, but the subfile in question. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
939 | bool tmp = g_loadingMainFile; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
940 | g_loadingMainFile = false; |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
941 | LDDocument* load = GetDocument (tokens[14]); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
942 | g_loadingMainFile = tmp; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
943 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
944 | // If we cannot open the file, mark it an error. Note we cannot use LDParseError |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
945 | // here because the error object needs the document reference. |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
946 | if (not load) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
947 | { |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
948 | LDError* obj = LDSpawn<LDError> (line, format ("Could not open %1", tokens[14])); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
949 | obj->setFileReferenced (tokens[14]); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
950 | return obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
951 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
952 | |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
953 | LDSubfile* obj = LDSpawn<LDSubfile>(); |
946 | 954 | obj->setColor (StringToNumber (tokens[1])); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
955 | obj->setPosition (ParseVertex (tokens, 2)); // 2 - 4 |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
956 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
957 | Matrix transform; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
958 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
959 | for (int i = 0; i < 9; ++i) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
960 | transform[i] = tokens[i + 5].toDouble(); // 5 - 13 |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
961 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
962 | obj->setTransform (transform); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
963 | obj->setFileInfo (load); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
964 | return obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
965 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
966 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
967 | case 2: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
968 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
969 | CheckTokenCount (tokens, 8); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
970 | CheckTokenNumbers (tokens, 1, 7); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
971 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
972 | // Line |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
973 | LDLine* obj (LDSpawn<LDLine>()); |
946 | 974 | obj->setColor (StringToNumber (tokens[1])); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
975 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
976 | for (int i = 0; i < 2; ++i) |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
977 | obj->setVertex (i, ParseVertex (tokens, 2 + (i * 3))); // 2 - 7 |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
978 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
979 | return obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
980 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
981 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
982 | case 3: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
983 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
984 | CheckTokenCount (tokens, 11); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
985 | CheckTokenNumbers (tokens, 1, 10); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
986 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
987 | // Triangle |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
988 | LDTriangle* obj (LDSpawn<LDTriangle>()); |
946 | 989 | obj->setColor (StringToNumber (tokens[1])); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
990 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
991 | for (int i = 0; i < 3; ++i) |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
992 | obj->setVertex (i, ParseVertex (tokens, 2 + (i * 3))); // 2 - 10 |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
993 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
994 | return obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
995 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
996 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
997 | case 4: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
998 | case 5: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
999 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1000 | CheckTokenCount (tokens, 14); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1001 | CheckTokenNumbers (tokens, 1, 13); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1002 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1003 | // Quadrilateral / Conditional line |
944 | 1004 | LDObject* obj; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1005 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1006 | if (num == 4) |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1007 | obj = LDSpawn<LDQuad>(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1008 | else |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1009 | obj = LDSpawn<LDCondLine>(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1010 | |
946 | 1011 | obj->setColor (StringToNumber (tokens[1])); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1012 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1013 | for (int i = 0; i < 4; ++i) |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1014 | obj->setVertex (i, ParseVertex (tokens, 2 + (i * 3))); // 2 - 13 |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1015 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1016 | return obj; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1017 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1018 | |
748
8d4a9d03e246
- some minor cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
747
diff
changeset
|
1019 | default: |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
1020 | throw QString ("Unknown line code number"); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1021 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1022 | } |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
1023 | catch (QString& e) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1024 | { |
748
8d4a9d03e246
- some minor cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
747
diff
changeset
|
1025 | // Strange line we couldn't parse |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1026 | return LDSpawn<LDError> (line, e); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1027 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1028 | } |
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 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1031 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
1032 | LDDocument* GetDocument (QString filename) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1033 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1034 | // Try find the file in the list of loaded files |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
1035 | LDDocument* doc = FindDocument (filename); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1036 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1037 | // If it's not loaded, try open it |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
1038 | if (not doc) |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1039 | doc = OpenDocument (filename, true, true); |
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 | return doc; |
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 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1044 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1045 | // |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1046 | void LDDocument::reloadAllSubfiles() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1047 | { |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1048 | print ("Reloading subfiles of %1", getDisplayName()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1049 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1050 | // Go through all objects in the current file and reload the subfiles |
944 | 1051 | for (LDObject* obj : objects()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1052 | { |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
785
diff
changeset
|
1053 | if (obj->type() == OBJ_Subfile) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1054 | { |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
1055 | LDSubfile* ref = static_cast<LDSubfile*> (obj); |
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
1056 | LDDocument* fileInfo = GetDocument (ref->fileInfo()->name()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1057 | |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1058 | if (fileInfo != null) |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1059 | { |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1060 | ref->setFileInfo (fileInfo); |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1061 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1062 | else |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1063 | { |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1064 | ref->replace (LDSpawn<LDError> (ref->asText(), |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1065 | format ("Could not open %1", ref->fileInfo()->name()))); |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1066 | } |
655
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 | // Reparse gibberish files. It could be that they are invalid because |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1070 | // of loading errors. Circumstances may be different now. |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
785
diff
changeset
|
1071 | if (obj->type() == OBJ_Error) |
944 | 1072 | obj->replace (ParseLine (static_cast<LDError*> (obj)->contents())); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1073 | } |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1074 | |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1075 | m_needsReCache = true; |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1076 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1077 | if (this == m_window->currentDocument()) |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1078 | m_window->buildObjList(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1079 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1080 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1081 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1082 | // |
944 | 1083 | int LDDocument::addObject (LDObject* obj) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1084 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1085 | history()->add (new AddHistory (objects().size(), obj)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1086 | m_objects << obj; |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1087 | addKnownVertices (obj); |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1088 | obj->setDocument (this); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1089 | m_window->R()->compileObject (obj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1090 | return getObjectCount() - 1; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1091 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1092 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1093 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1094 | // |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1095 | void LDDocument::addObjects (const LDObjectList& objs) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1096 | { |
944 | 1097 | for (LDObject* obj : objs) |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1098 | { |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1099 | if (obj != null) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1100 | addObject (obj); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1101 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1102 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1103 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1104 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1105 | // |
944 | 1106 | void LDDocument::insertObj (int pos, LDObject* obj) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1107 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1108 | history()->add (new AddHistory (pos, obj)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1109 | m_objects.insert (pos, obj); |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1110 | obj->setDocument (this); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1111 | m_window->R()->compileObject (obj); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1112 | |
890
903ec1e46298
- backed out work done on bfc (re-committing later)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
889
diff
changeset
|
1113 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1114 | #ifdef DEBUG |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
1115 | if (not isCache()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1116 | dprint ("Inserted object #%1 (%2) at %3\n", obj->id(), obj->typeName(), pos); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1117 | #endif |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1118 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1119 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1120 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1121 | // |
944 | 1122 | void LDDocument::addKnownVertices (LDObject* obj) |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
1123 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1124 | auto it = m_objectVertices.find (obj); |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
1125 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1126 | if (it == m_objectVertices.end()) |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1127 | it = m_objectVertices.insert (obj, QVector<Vertex>()); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1128 | else |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1129 | it->clear(); |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
1130 | |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1131 | obj->getVertices (*it); |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1132 | needVertexMerge(); |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
1133 | } |
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
1134 | |
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
1135 | // ============================================================================= |
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
1136 | // |
944 | 1137 | void LDDocument::forgetObject (LDObject* obj) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1138 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1139 | int idx = obj->lineNumber(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1140 | |
949
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1141 | if (m_objects[idx] == obj) |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
1142 | { |
949
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1143 | obj->deselect(); |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1144 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
1145 | if (not isCache() and not m_beingDestroyed) |
949
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1146 | { |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1147 | history()->add (new DelHistory (idx, obj)); |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1148 | m_objectVertices.remove (obj); |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1149 | } |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1150 | |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1151 | m_objects.removeAt (idx); |
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
1152 | obj->setDocument (nullptr); |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
1153 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1154 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1155 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1156 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1157 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1158 | bool IsSafeToCloseAll() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1159 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1160 | for (LDDocument* f : g_win->allDocuments()) |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
1161 | { |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
1162 | if (not f->isSafeToClose()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1163 | return false; |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
1164 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1165 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1166 | return true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1167 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1168 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1169 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1170 | // |
944 | 1171 | void LDDocument::setObject (int idx, LDObject* obj) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1172 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1173 | if (idx < 0 or idx >= m_objects.size()) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1174 | return; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1175 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1176 | // Mark this change to history |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
1177 | if (not m_history->isIgnoring()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1178 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
1179 | QString oldcode = getObject (idx)->asText(); |
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
1180 | QString newcode = obj->asText(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1181 | *m_history << new EditHistory (idx, oldcode, newcode); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1182 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1183 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1184 | m_objectVertices.remove (m_objects[idx]); |
767
44f0d5322628
- slight refactor in ldobject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
761
diff
changeset
|
1185 | m_objects[idx]->deselect(); |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
1186 | m_objects[idx]->setDocument (nullptr); |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1187 | obj->setDocument (this); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1188 | addKnownVertices (obj); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1189 | m_window->R()->compileObject (obj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1190 | m_objects[idx] = obj; |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1191 | needVertexMerge(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1192 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1193 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1194 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1195 | // |
944 | 1196 | LDObject* LDDocument::getObject (int pos) const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1197 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1198 | if (pos < m_objects.size()) |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1199 | return m_objects[pos]; |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1200 | else |
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
1201 | return nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1202 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1203 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1204 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1205 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1206 | int LDDocument::getObjectCount() const |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1207 | { |
890
903ec1e46298
- backed out work done on bfc (re-committing later)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
889
diff
changeset
|
1208 | return objects().size(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1209 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1210 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1211 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1212 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1213 | bool LDDocument::hasUnsavedChanges() const |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1214 | { |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
1215 | return not isCache() and history()->position() != savePosition(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1216 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1217 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1218 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1219 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
1220 | QString LDDocument::getDisplayName() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1221 | { |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
1222 | if (not name().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1223 | return name(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1224 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
1225 | if (not defaultName().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1226 | return "[" + defaultName() + "]"; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1227 | |
920
147497785496
- fixed stability problems
Teemu Piippo <crimsondusk64@gmail.com>
parents:
902
diff
changeset
|
1228 | return QObject::tr ("untitled"); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1229 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1230 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1231 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1232 | // |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
1233 | void LDDocument::initializeCachedData() |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1234 | { |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1235 | if (m_needsReCache) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1236 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1237 | m_vertices.clear(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1238 | |
944 | 1239 | for (LDObject* obj : inlineContents (true, true)) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1240 | { |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1241 | if (obj->type() == OBJ_Subfile) |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1242 | { |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1243 | print ("Warning: unable to inline %1 into %2", |
944 | 1244 | static_cast<LDSubfile*> (obj)->fileInfo()->getDisplayName(), |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1245 | getDisplayName()); |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1246 | continue; |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1247 | } |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
1248 | |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1249 | LDPolygon* data = obj->getPolygon(); |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1250 | |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1251 | if (data != null) |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1252 | { |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1253 | m_polygonData << *data; |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1254 | delete data; |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1255 | } |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1256 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1257 | |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1258 | m_needsReCache = false; |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1259 | } |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1260 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1261 | if (m_verticesOutdated) |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1262 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1263 | m_objectVertices.clear(); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1264 | |
944 | 1265 | for (LDObject* obj : inlineContents (true, false)) |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1266 | addKnownVertices (obj); |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1267 | |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1268 | mergeVertices(); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1269 | m_verticesOutdated = false; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1270 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1271 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1272 | if (m_needVertexMerge) |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1273 | mergeVertices(); |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1274 | } |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1275 | |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1276 | // ============================================================================= |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1277 | // |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1278 | void LDDocument::mergeVertices() |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1279 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1280 | m_vertices.clear(); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1281 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1282 | for (QVector<Vertex> const& verts : m_objectVertices) |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1283 | m_vertices << verts; |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1284 | |
966
a834e43a57da
Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
962
diff
changeset
|
1285 | removeDuplicates (m_vertices); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1286 | m_needVertexMerge = false; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1287 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1288 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1289 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1290 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1291 | QList<LDPolygon> LDDocument::inlinePolygons() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1292 | { |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
1293 | initializeCachedData(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1294 | return polygonData(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1295 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1296 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1297 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1298 | // ----------------------------------------------------------------------------- |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1299 | LDObjectList LDDocument::inlineContents (bool deep, bool renderinline) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1300 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1301 | // Possibly substitute with logoed studs: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1302 | // stud.dat -> stud-logo.dat |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1303 | // stud2.dat -> stud-logo2.dat |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1304 | if (m_config->useLogoStuds() and renderinline) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1305 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1306 | // Ensure logoed studs are loaded first |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1307 | LoadLogoStuds(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1308 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
1309 | if (name() == "stud.dat" and g_logoedStud != null) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1310 | return g_logoedStud->inlineContents (deep, renderinline); |
967 | 1311 | else if (name() == "stud2.dat" and g_logoedStud2 != null) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1312 | return g_logoedStud2->inlineContents (deep, renderinline); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1313 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1314 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1315 | LDObjectList objs, objcache; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1316 | |
944 | 1317 | for (LDObject* obj : objects()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1318 | { |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1319 | // Skip those without scemantic meaning |
714 | 1320 | if (not obj->isScemantic()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1321 | continue; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1322 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1323 | // Got another sub-file reference, inline it if we're deep-inlining. If not, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1324 | // just add it into the objects normally. Yay, recursion! |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
836
diff
changeset
|
1325 | if (deep == true and obj->type() == OBJ_Subfile) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1326 | { |
944 | 1327 | for (LDObject* otherobj : static_cast<LDSubfile*> (obj)->inlineContents (deep, renderinline)) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1328 | objs << otherobj; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1329 | } |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1330 | else |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
1331 | objs << obj->createCopy(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1332 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1333 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1334 | return objs; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1335 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1336 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1337 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1338 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1339 | void LoadLogoStuds() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1340 | { |
877
7c50b61ad5b6
- fixed infinite recursion when loading logoed studs
Teemu Piippo <crimsondusk64@gmail.com>
parents:
872
diff
changeset
|
1341 | if (g_loadingLogoedStuds or (g_logoedStud and g_logoedStud2)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1342 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1343 | |
877
7c50b61ad5b6
- fixed infinite recursion when loading logoed studs
Teemu Piippo <crimsondusk64@gmail.com>
parents:
872
diff
changeset
|
1344 | g_loadingLogoedStuds = true; |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1345 | g_logoedStud = OpenDocument ("stud-logo.dat", true, true); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1346 | g_logoedStud2 = OpenDocument ("stud2-logo.dat", true, true); |
920
147497785496
- fixed stability problems
Teemu Piippo <crimsondusk64@gmail.com>
parents:
902
diff
changeset
|
1347 | print (QObject::tr ("Logoed studs loaded.\n")); |
877
7c50b61ad5b6
- fixed infinite recursion when loading logoed studs
Teemu Piippo <crimsondusk64@gmail.com>
parents:
872
diff
changeset
|
1348 | g_loadingLogoedStuds = false; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1349 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1350 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1351 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1352 | // |
944 | 1353 | void LDDocument::addToSelection (LDObject* obj) // [protected] |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1354 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1355 | if (not obj->isSelected() and obj->document() == this) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1356 | { |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1357 | m_sel << obj; |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1358 | m_window->R()->compileObject (obj); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1359 | obj->setSelected (true); |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1360 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1361 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1362 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1363 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1364 | // |
944 | 1365 | void LDDocument::removeFromSelection (LDObject* obj) // [protected] |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1366 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1367 | if (obj->isSelected() and obj->document() == this) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1368 | { |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1369 | m_sel.removeOne (obj); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1370 | m_window->R()->compileObject (obj); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1371 | obj->setSelected (false); |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1372 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1373 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1374 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1375 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1376 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1377 | void LDDocument::clearSelection() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1378 | { |
944 | 1379 | for (LDObject* obj : m_sel) |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1380 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1381 | m_window->R()->compileObject (obj); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1382 | obj->setSelected (false); |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1383 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1384 | |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1385 | m_sel.clear(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1386 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1387 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1388 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1389 | // |
890
903ec1e46298
- backed out work done on bfc (re-committing later)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
889
diff
changeset
|
1390 | const LDObjectList& LDDocument::getSelection() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1391 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1392 | return m_sel; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1393 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1394 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1395 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1396 | // |
944 | 1397 | void LDDocument::swapObjects (LDObject* one, LDObject* other) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1398 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1399 | int a = m_objects.indexOf (one); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1400 | int b = m_objects.indexOf (other); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1401 | |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1402 | if (a != b and a != -1 and b != -1) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1403 | { |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1404 | m_objects[b] = one; |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1405 | m_objects[a] = other; |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1406 | addToHistory (new SwapHistory (one->id(), other->id())); |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
957
diff
changeset
|
1407 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1408 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1409 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1410 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1411 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
1412 | QString LDDocument::shortenName (QString a) // [static] |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1413 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1414 | QString shortname = Basename (a); |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1415 | QString topdirname = Basename (Dirname (a)); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1416 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1417 | if (g_specialSubdirectories.contains (topdirname)) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1418 | shortname.prepend (topdirname + "\\"); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1419 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1420 | return shortname; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1421 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1422 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1423 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1424 | // |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1425 | QVector<Vertex> const& LDDocument::inlineVertices() |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
1426 | { |
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
1427 | initializeCachedData(); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1428 | return m_vertices; |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
1429 | } |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1430 | |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1431 | void LDDocument::redoVertices() |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1432 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1433 | m_verticesOutdated = true; |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1434 | } |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1435 | |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1436 | void LDDocument::needVertexMerge() |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
1437 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
1438 | m_needVertexMerge = true; |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
1439 | } |