Wed, 08 May 2013 04:10:31 +0300
Moved LDraw path setting out of the configuration dialog to the LDraw path dialog, it does the job better.
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
104 | 3 | * Copyright (C) 2013 Santeri Piippo |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
18 | |
0 | 19 | #include <QApplication> |
20 | #include "gui.h" | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
21 | #include "file.h" |
0 | 22 | #include "bbox.h" |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
23 | #include "misc.h" |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
24 | #include "config.h" |
48
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
25 | #include "colors.h" |
64
ada4679d5bce
Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
26 | #include "types.h" |
0 | 27 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
28 | vector<OpenFile*> g_loadedFiles; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
29 | OpenFile* g_curfile = null; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
30 | ForgeWindow* g_win = null; |
0 | 31 | bbox g_BBox; |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
32 | const QApplication* g_app = null; |
0 | 33 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
34 | const vertex g_origin (0.0f, 0.0f, 0.0f); |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
161
diff
changeset
|
35 | const matrix<3> g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
36 | |
117
7eb7a43a511b
Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
37 | // ============================================================================= |
7eb7a43a511b
Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
38 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
7eb7a43a511b
Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
39 | // ============================================================================= |
179
f98391b179ab
Added a dialog for inquering the user's LDraw directory, not having it set leads to crashing...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
169
diff
changeset
|
40 | int main (int argc, char* argv[]) { |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
41 | // Load or create the configuration |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
42 | if (!config::load()) { |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
43 | printf ("Creating configuration file...\n"); |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
44 | if (config::save ()) |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
45 | printf ("Configuration file successfully created.\n"); |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
46 | else |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
47 | printf ("failed to create configuration file!\n"); |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
48 | } |
0 | 49 | |
179
f98391b179ab
Added a dialog for inquering the user's LDraw directory, not having it set leads to crashing...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
169
diff
changeset
|
50 | const QApplication app (argc, argv); |
f98391b179ab
Added a dialog for inquering the user's LDraw directory, not having it set leads to crashing...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
169
diff
changeset
|
51 | LDPaths::initPaths (); |
f98391b179ab
Added a dialog for inquering the user's LDraw directory, not having it set leads to crashing...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
169
diff
changeset
|
52 | |
48
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
53 | initColors (); |
117
7eb7a43a511b
Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
54 | initPartList (); |
48
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
55 | |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
56 | ForgeWindow* win = new ForgeWindow; |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
57 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
58 | g_app = &app; |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
59 | |
42
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
60 | newFile (); |
499c25af0303
Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
61 | |
0 | 62 | win->show (); |
63 | return app.exec (); | |
64 | } | |
65 | ||
13
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
66 | // ============================================================================= |
117
7eb7a43a511b
Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
67 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
13
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
68 | // ============================================================================= |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
69 | void logf (const char* fmtstr, ...) { |
13
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
70 | va_list va; |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
71 | va_start (va, fmtstr); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
72 | g_win->logVA (LOG_Normal, fmtstr, va); |
13
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
73 | va_end (va); |
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
74 | } |
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
75 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
76 | void logf (LogType type, const char* fmtstr, ...) { |
13
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
77 | va_list va; |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
78 | va_start (va, fmtstr); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
79 | g_win->logVA (type, fmtstr, va); |
13
3955ff2a7d72
Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
80 | va_end (va); |
117
7eb7a43a511b
Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
81 | } |
161 | 82 | |
83 | void warnf (const char* fmtstr, ...) { | |
84 | va_list va; | |
85 | va_start (va, fmtstr); | |
86 | g_win->logVA (LOG_Warning, fmtstr, va); | |
87 | va_end (va); | |
88 | } | |
89 | ||
90 | void errf (const char* fmtstr, ...) { | |
91 | va_list va; | |
92 | va_start (va, fmtstr); | |
93 | g_win->logVA (LOG_Error, fmtstr, va); | |
94 | va_end (va); | |
95 | } | |
96 | ||
97 | #ifndef RELEASE | |
98 | void devf (const char* fmtstr, ...) { | |
99 | va_list va; | |
100 | va_start (va, fmtstr); | |
101 | g_win->logVA (LOG_Dev, fmtstr, va); | |
102 | va_end (va); | |
103 | } | |
104 | #endif // RELEASE |