Sat, 16 Mar 2013 00:35:36 +0200
Check whether the numeric arguments of lines really are numeric, and treat lines that don't pass this check as gibberish
0 | 1 | #ifndef __COMMON_H__ |
2 | #define __COMMON_H__ | |
3 | ||
4 | #define APPNAME "ldforge" | |
5 | #define APPNAME_DISPLAY "LDForge" | |
6 | #define APPNAME_CAPS "LDFORGE" | |
7 | ||
8 | #define VERSION_MAJOR 0 | |
9 | #define VERSION_MAJOR_STR "0" | |
10 | #define VERSION_MINOR 1 | |
11 | #define VERSION_MINOR_STR "1" | |
12 | ||
13 | #define VERSION_STRING VERSION_MAJOR_STR "." VERSION_MINOR_STR | |
14 | ||
15 | #define CONFIG_WITH_QT | |
16 | ||
17 | #include <stdio.h> | |
18 | #include <stdlib.h> | |
19 | #include <assert.h> | |
20 | #include <vector> | |
21 | #include <stdint.h> | |
22 | #include "stdarg.h" | |
23 | #include "str.h" | |
24 | #include "config.h" | |
25 | ||
26 | using std::vector; | |
27 | ||
28 | class LDForgeWindow; | |
29 | class LDObject; | |
30 | class bbox; | |
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
31 | class OpenFile; |
0 | 32 | |
33 | // ============================================================================= | |
34 | // vertex (v) | |
35 | // | |
36 | // Vertex class. Not to be confused with LDVertex, which is a vertex used in an | |
37 | // LDraw code file. | |
38 | // | |
39 | // Methods: | |
40 | // - midpoint (vertex&): returns a midpoint | |
41 | // ============================================================================= | |
42 | class vertex { | |
43 | public: | |
44 | double x, y, z; | |
45 | ||
46 | // ========================================================================= | |
47 | // Midpoint between this vertex and another vertex. | |
48 | vertex midpoint (vertex& other); | |
49 | str getStringRep (); | |
50 | }; | |
51 | ||
52 | // ============================================================================= | |
53 | // bearing | |
54 | // | |
55 | // A bearing is a combination of an angle and a pitch. Essentially a 3D angle. | |
56 | // The project method projects a vertex from a given vertex by a given length. | |
57 | // | |
58 | // Prefix: g, since b is bool | |
59 | // ============================================================================= | |
60 | class bearing { | |
61 | double fAngle, fPitch; | |
62 | ||
63 | vertex project (vertex& vSource, ulong ulLength); | |
64 | }; | |
65 | ||
66 | // ============================================================================= | |
67 | // Plural expression | |
68 | #define PLURAL(n) ((n != 1) ? "s" : "") | |
69 | ||
70 | // Shortcut for formatting | |
71 | #define PERFORM_FORMAT(in, out) \ | |
72 | va_list v; \ | |
73 | va_start (v, in); \ | |
74 | char* out = vdynformat (in, v, 256); \ | |
75 | va_end (v); | |
76 | ||
77 | // Shortcuts for stuffing vertices into printf-formatting. | |
78 | #define FMT_VERTEX "(%.3f, %.3f, %.3f)" | |
79 | #define FVERTEX(V) V.x, V.y, V.z | |
80 | ||
81 | typedef unsigned char byte; | |
82 | ||
83 | template<class T> inline T clamp (T a, T min, T max) { | |
84 | return (a > max) ? max : (a < min) ? min : a; | |
85 | } | |
86 | ||
87 | template<class T> inline T min (T a, T b) { | |
88 | return (a < b) ? a : b; | |
89 | } | |
90 | ||
91 | template<class T> inline T max (T a, T b) { | |
92 | return (a > b) ? a : b; | |
93 | } | |
94 | ||
95 | static const double pi = 3.14159265358979323846f; | |
96 | ||
97 | // main.cpp | |
98 | extern OpenFile* g_CurrentFile; | |
99 | extern bbox g_BBox; | |
100 | extern LDForgeWindow* g_qWindow; | |
101 | extern vector<OpenFile*> g_LoadedFiles; | |
102 | ||
103 | #ifndef unix | |
104 | typedef unsigned int uint; | |
105 | typedef unsigned long ulong; | |
106 | #endif // unix | |
107 | ||
108 | typedef int8_t xchar; | |
109 | typedef int16_t xshort; | |
110 | typedef int32_t xlong; | |
111 | typedef int64_t xlonglong; | |
112 | typedef uint8_t xuchar; | |
113 | typedef uint16_t xushort; | |
114 | typedef uint32_t xulong; | |
115 | typedef uint64_t xulonglong; | |
116 | ||
117 | #endif |