common.h

Tue, 07 May 2013 16:12:15 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 07 May 2013 16:12:15 +0300
changeset 173
2368e3c23ef3
parent 169
f562323760a2
permissions
-rw-r--r--

Add functionality for setting paths to ext progs in config dialog

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
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
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
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: 148
diff changeset
19 // =============================================================================
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: 148
diff changeset
20 // This file is included one way or another in every source file of LDForge.
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: 148
diff changeset
21 // Stuff defined and included here is universally included.
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: 148
diff changeset
22
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
23 #ifndef COMMON_H
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
24 #define COMMON_H
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
26 #include <stdio.h>
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
27 #include <stdlib.h>
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
28 #include <assert.h>
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
29 #include <vector>
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
30 #include <stdint.h>
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
31 #include <stdarg.h>
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
32 #include "str.h"
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
33 #include "config.h"
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
34 #include "types.h"
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
35
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
36 #define APPNAME "LDForge"
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 #define VERSION_MAJOR 0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 #define VERSION_MAJOR_STR "0"
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 #define VERSION_MINOR 1
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 #define VERSION_MINOR_STR "1"
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
43 // ============---
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
44 // #define RELEASE
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
45
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: 148
diff changeset
46 // Version string identifier
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
47 static const str versionString = fmt ("%d.%d", VERSION_MAJOR, VERSION_MINOR);
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48
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: 7
diff changeset
49 #ifdef __GNUC__
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: 148
diff changeset
50 # define FORMAT_PRINTF(M,N) __attribute__ ((format (printf, M, N)))
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: 148
diff changeset
51 # define ATTR(N) __attribute__ ((N))
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: 7
diff changeset
52 #else
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: 148
diff changeset
53 # define FORMAT_PRINTF(M,N)
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: 148
diff changeset
54 # define ATTR(N)
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: 7
diff changeset
55 #endif // __GNUC__
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 7
diff changeset
56
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
57 #ifdef WIN32
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
58 #define DIRSLASH "\\"
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
59 #else // WIN32
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
60 #define DIRSLASH "/"
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
61 #endif // WIN32
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
62
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
63 #ifdef RELEASE
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
64 #define NDEBUG // remove asserts
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
65 #endif // RELEASE
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
66
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
67 #ifdef null
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
68 #undef null
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
69 #endif // null
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
70
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: 148
diff changeset
71 // Null pointer
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
72 static const std::nullptr_t null = nullptr;
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: 148
diff changeset
73
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: 148
diff changeset
74 // Main and edge color identifiers
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
75 static const short maincolor = 16;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
76 static const short edgecolor = 24;
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
77
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
78 static const bool yup = true;
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
79 static const bool nope = false;
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
80
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: 22
diff changeset
81 class ForgeWindow;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 class LDObject;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 class bbox;
7
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
84 class OpenFile;
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
85 class QApplication;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 // =============================================================================
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 // Plural expression
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 #define PLURAL(n) ((n != 1) ? "s" : "")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
91 // -----------------------------------------------------------------------------
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 // Shortcut for formatting
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 #define PERFORM_FORMAT(in, out) \
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 va_list v; \
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 va_start (v, in); \
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 char* out = vdynformat (in, v, 256); \
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 va_end (v);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
99 // -----------------------------------------------------------------------------
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 // Shortcuts for stuffing vertices into printf-formatting.
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 #define FMT_VERTEX "(%.3f, %.3f, %.3f)"
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 #define FVERTEX(V) V.x, V.y, V.z
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
104 // -----------------------------------------------------------------------------
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
105 // Templated clamp
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
106 template<class T> static inline T clamp (T a, T min, T max) {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 return (a > max) ? max : (a < min) ? min : a;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
110 // Templated minimum
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
111 template<class T> static inline T min (T a, T b) {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 return (a < b) ? a : b;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
115 // Templated maximum
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
116 template<class T> static inline T max (T a, T b) {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 return (a > b) ? a : b;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
120 // Templated absolute value
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
121 template<class T> static inline T abs (T a) {
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
122 return (a >= 0) ? a : -a;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
123 }
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
124
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
125 // Quick QString to const char* conversion
78
c190fe218506 Keyboard shortcuts can now be configured.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
126 static inline const char* qchars (QString qstr) {
c190fe218506 Keyboard shortcuts can now be configured.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
127 return qstr.toStdString ().c_str ();
c190fe218506 Keyboard shortcuts can now be configured.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
128 }
c190fe218506 Keyboard shortcuts can now be configured.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
129
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 static const double pi = 3.14159265358979323846f;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131
169
f562323760a2 Added grouping basics - will be needed for ext programs (Intersector, Isecalc and a lot of others use 2 or more inputs, need to get all of those in somehow...) plus I think they can be useful for the actual authoring process
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
132 #ifdef IN_IDE_PARSER // KDevelop workaround
f562323760a2 Added grouping basics - will be needed for ext programs (Intersector, Isecalc and a lot of others use 2 or more inputs, need to get all of those in somehow...) plus I think they can be useful for the actual authoring process
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
133 // Current function name
f562323760a2 Added grouping basics - will be needed for ext programs (Intersector, Isecalc and a lot of others use 2 or more inputs, need to get all of those in somehow...) plus I think they can be useful for the actual authoring process
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
134 static const char* __func__ = "";
f562323760a2 Added grouping basics - will be needed for ext programs (Intersector, Isecalc and a lot of others use 2 or more inputs, need to get all of those in somehow...) plus I think they can be useful for the actual authoring process
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
135 #endif // IN_IDE_PARSER
f562323760a2 Added grouping basics - will be needed for ext programs (Intersector, Isecalc and a lot of others use 2 or more inputs, need to get all of those in somehow...) plus I think they can be useful for the actual authoring process
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
136
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
137 // -----------------------------------------------------------------------------
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: 148
diff changeset
138 enum LogType {
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: 7
diff changeset
139 LOG_Normal,
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 7
diff changeset
140 LOG_Warning,
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 7
diff changeset
141 LOG_Error,
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
142 LOG_Dev,
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: 7
diff changeset
143 };
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 7
diff changeset
144
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: 148
diff changeset
145 // logf - universal access to the message log. Defined here so that I don't have
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: 148
diff changeset
146 // to include gui.h here and recompile everything every time that file changes.
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: 148
diff changeset
147 // logf is defined in main.cpp
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: 148
diff changeset
148 void logf (const char* fmtstr, ...) FORMAT_PRINTF (1, 2);
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: 148
diff changeset
149 void logf (LogType type, const char* fmtstr, ...) FORMAT_PRINTF (2, 3);
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
150 void warnf (const char* fmtstr, ...) FORMAT_PRINTF (1, 2);
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
151 void errf (const char* fmtstr, ...) FORMAT_PRINTF (1, 2);
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
152
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
153 #ifndef RELEASE
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
154 void devf (const char* fmtstr, ...);
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
155 #else
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
156 # define devf(...)
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
157 #endif // RELEASE
97
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
158
52bcca21579e Fleshed out the history dialog further
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
159 // -----------------------------------------------------------------------------
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: 44
diff changeset
160 // Vertex at (0, 0, 0)
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: 148
diff changeset
161 extern const vertex g_origin;
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: 44
diff changeset
162
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
163 // -----------------------------------------------------------------------------
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
164 // Pointer to the OpenFile which is currently being edited by the user.
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: 148
diff changeset
165 extern OpenFile* g_curfile;
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
166
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
167 // -----------------------------------------------------------------------------
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
168 // Pointer to the bounding box.
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 extern bbox g_BBox;
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
170
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
171 // -----------------------------------------------------------------------------
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
172 // Vector of all currently opened files.
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: 148
diff changeset
173 extern vector<OpenFile*> g_loadedFiles;
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
174
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
175 // -----------------------------------------------------------------------------
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 78
diff changeset
176 // Pointer to the main application.
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: 148
diff changeset
177 extern const QApplication* g_app;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178
103
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
179 // -----------------------------------------------------------------------------
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
180 // Identity matrix
162
b7d65e89861a matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
181 extern const matrix<3> g_identity;
103
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
182
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
183 #endif // COMMON_H

mercurial