main.cpp

changeset 183
f1b8cb53d2a2
parent 182
9374fea8f77f
child 184
fae3bc9ce319
equal deleted inserted replaced
182:9374fea8f77f 183:f1b8cb53d2a2
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 Santeri Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <QApplication>
20 #include "gui.h"
21 #include "file.h"
22 #include "bbox.h"
23 #include "misc.h"
24 #include "config.h"
25 #include "colors.h"
26 #include "types.h"
27
28 vector<OpenFile*> g_loadedFiles;
29 OpenFile* g_curfile = null;
30 ForgeWindow* g_win = null;
31 bbox g_BBox;
32 const QApplication* g_app = null;
33
34 const vertex g_origin (0.0f, 0.0f, 0.0f);
35 const matrix<3> g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f});
36
37 // =============================================================================
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
39 // =============================================================================
40 int main (int argc, char* argv[]) {
41 // Load or create the configuration
42 if (!config::load()) {
43 printf ("Creating configuration file...\n");
44 if (config::save ())
45 printf ("Configuration file successfully created.\n");
46 else
47 printf ("failed to create configuration file!\n");
48 }
49
50 const QApplication app (argc, argv);
51 LDPaths::initPaths ();
52
53 initColors ();
54 initPartList ();
55
56 ForgeWindow* win = new ForgeWindow;
57
58 g_app = &app;
59
60 newFile ();
61
62 win->show ();
63 return app.exec ();
64 }
65
66 // =============================================================================
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
68 // =============================================================================
69 void logf (const char* fmtstr, ...) {
70 va_list va;
71 va_start (va, fmtstr);
72 g_win->logVA (LOG_Normal, fmtstr, va);
73 va_end (va);
74 }
75
76 void logf (LogType type, const char* fmtstr, ...) {
77 va_list va;
78 va_start (va, fmtstr);
79 g_win->logVA (type, fmtstr, va);
80 va_end (va);
81 }
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

mercurial