Sat, 16 Mar 2013 03:24:50 +0200
Added icon for setting contents
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 | ||
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
|
26 | #ifdef __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
|
27 | #define FORMAT_PRINTF(M,N) __attribute__ ((format (printf, M, N))) |
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
|
28 | #else |
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
|
29 | #define FORMAT_PRINTF(M,N) |
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
|
30 | #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
|
31 | |
0 | 32 | using std::vector; |
33 | ||
34 | class LDForgeWindow; | |
35 | class LDObject; | |
36 | class bbox; | |
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
37 | class OpenFile; |
0 | 38 | |
39 | // ============================================================================= | |
40 | // vertex (v) | |
41 | // | |
42 | // Vertex class. Not to be confused with LDVertex, which is a vertex used in an | |
43 | // LDraw code file. | |
44 | // | |
45 | // Methods: | |
46 | // - midpoint (vertex&): returns a midpoint | |
47 | // ============================================================================= | |
48 | class vertex { | |
49 | public: | |
50 | double x, y, z; | |
51 | ||
52 | // ========================================================================= | |
53 | // Midpoint between this vertex and another vertex. | |
54 | vertex midpoint (vertex& other); | |
55 | str getStringRep (); | |
56 | }; | |
57 | ||
58 | // ============================================================================= | |
59 | // bearing | |
60 | // | |
61 | // A bearing is a combination of an angle and a pitch. Essentially a 3D angle. | |
62 | // The project method projects a vertex from a given vertex by a given length. | |
63 | // | |
64 | // Prefix: g, since b is bool | |
65 | // ============================================================================= | |
66 | class bearing { | |
67 | double fAngle, fPitch; | |
68 | ||
69 | vertex project (vertex& vSource, ulong ulLength); | |
70 | }; | |
71 | ||
72 | // ============================================================================= | |
73 | // Plural expression | |
74 | #define PLURAL(n) ((n != 1) ? "s" : "") | |
75 | ||
76 | // Shortcut for formatting | |
77 | #define PERFORM_FORMAT(in, out) \ | |
78 | va_list v; \ | |
79 | va_start (v, in); \ | |
80 | char* out = vdynformat (in, v, 256); \ | |
81 | va_end (v); | |
82 | ||
83 | // Shortcuts for stuffing vertices into printf-formatting. | |
84 | #define FMT_VERTEX "(%.3f, %.3f, %.3f)" | |
85 | #define FVERTEX(V) V.x, V.y, V.z | |
86 | ||
87 | typedef unsigned char byte; | |
88 | ||
89 | template<class T> inline T clamp (T a, T min, T max) { | |
90 | return (a > max) ? max : (a < min) ? min : a; | |
91 | } | |
92 | ||
93 | template<class T> inline T min (T a, T b) { | |
94 | return (a < b) ? a : b; | |
95 | } | |
96 | ||
97 | template<class T> inline T max (T a, T b) { | |
98 | return (a > b) ? a : b; | |
99 | } | |
100 | ||
101 | static const double pi = 3.14159265358979323846f; | |
102 | ||
103 | // main.cpp | |
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
|
104 | enum logtype_e { |
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
|
105 | 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
|
106 | LOG_Success, |
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
|
107 | LOG_Info, |
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
|
108 | 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
|
109 | LOG_Error, |
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
|
110 | }; |
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
|
111 | |
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
|
112 | void logf (const char* fmt, ...) FORMAT_PRINTF (1, 2); |
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
|
113 | void logf (logtype_e eType, const char* fmt, ...) FORMAT_PRINTF (2, 3); |
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
|
114 | |
0 | 115 | extern OpenFile* g_CurrentFile; |
116 | extern bbox g_BBox; | |
117 | extern LDForgeWindow* g_qWindow; | |
118 | extern vector<OpenFile*> g_LoadedFiles; | |
119 | ||
120 | #ifndef unix | |
121 | typedef unsigned int uint; | |
122 | typedef unsigned long ulong; | |
123 | #endif // unix | |
124 | ||
125 | typedef int8_t xchar; | |
126 | typedef int16_t xshort; | |
127 | typedef int32_t xlong; | |
128 | typedef int64_t xlonglong; | |
129 | typedef uint8_t xuchar; | |
130 | typedef uint16_t xushort; | |
131 | typedef uint32_t xulong; | |
132 | typedef uint64_t xulonglong; | |
133 | ||
134 | #endif |