src/misc.cpp

Thu, 04 Jul 2013 20:08:14 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 04 Jul 2013 20:08:14 +0300
changeset 332
3013acb1df53
parent 308
4e2425bd4dc7
child 363
75583c9f289d
permissions
-rw-r--r--

Converted rotation point prompt

183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <math.h>
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <locale.h>
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include <qcolor.h>
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "common.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "misc.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "gui.h"
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
25 #include "bbox.h"
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
26 #include "dialogs.h"
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
27 #include "ui_rotpoint.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 // Prime number table.
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
30 const ushort g_primes[NUM_PRIMES] = {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 // Grid stuff
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 cfg (int, grid, Grid::Medium);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 EXTERN_ACTION (gridCoarse)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 EXTERN_ACTION (gridMedium)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 EXTERN_ACTION (gridFine)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 cfg (float, grid_coarse_x, 5.0f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 cfg (float, grid_coarse_y, 5.0f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 cfg (float, grid_coarse_z, 5.0f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 cfg (float, grid_coarse_angle, 45.0f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 cfg (float, grid_medium_x, 1.0f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 cfg (float, grid_medium_y, 1.0f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 cfg (float, grid_medium_z, 1.0f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 cfg (float, grid_medium_angle, 22.5f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 cfg (float, grid_fine_x, 0.1f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 cfg (float, grid_fine_y, 0.1f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 cfg (float, grid_fine_z, 0.1f);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 cfg (float, grid_fine_angle, 7.5f);
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
104 cfg (int, edit_rotpoint, 0);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
105 cfg (float, edit_rotpoint_x, 0.0f); // TODO: make a vertexconfig object and use it here
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
106 cfg (float, edit_rotpoint_y, 0.0f);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
107 cfg (float, edit_rotpoint_z, 0.0f);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 const gridinfo g_GridInfo[3] = {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 { "Coarse", { &grid_coarse_x, &grid_coarse_y, &grid_coarse_z, &grid_coarse_angle }, &ACTION (gridCoarse) },
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 { "Medium", { &grid_medium_x, &grid_medium_y, &grid_medium_z, &grid_medium_angle }, &ACTION (gridMedium) },
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 { "Fine", { &grid_fine_x, &grid_fine_y, &grid_fine_z, &grid_fine_angle }, &ACTION (gridFine) }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 // =============================================================================
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
116 // Snap the given coordinate value on the current grid's given axis.
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 double Grid::snap (double in, const Grid::Config axis) {
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 const double gridval = currentGrid ().confs[axis]->value;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 const long mult = abs (in / gridval);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 const bool neg = (in < 0);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 double out = mult * gridval;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 if (abs<double> (in) - (mult * gridval) > gridval / 2)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 out += gridval;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 if (neg && out != 0)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 out *= -1;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 return out;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 // =============================================================================
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
135 // Float to string. Removes trailing zeroes and is locale-independant.
223
4f95d7f2e9ef Added PROPERTY macro for easier exposed member variable management
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
136 str ftoa (double num) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 // Disable the locale first so that the decimal point will not
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 // turn into anything weird (like commas)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 setlocale (LC_NUMERIC, "C");
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
141 str rep;
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
142 rep.sprintf ("%f", num);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 // Remove trailing zeroes
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
145 while (rep.right (1) == "0")
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
146 rep.chop (1);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
148 // If there were only zeroes in the decimal place, remove
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 // the decimal point now.
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
150 if (rep.right (1) == ".")
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
151 rep.chop (1);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
153 return rep;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 // =============================================================================
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
159 bool isNumber (const str& tok) {
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
160 bool gotDot = false;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
162 for (int i = 0; i < tok.length (); ++i) {
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
163 const qchar c = tok[i];
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
164
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
165 // Allow leading hyphen for negatives
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
166 if (i == 0 && c == '-')
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
167 continue;
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
168
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
169 // Check for decimal point
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
170 if (!gotDot && c == '.') {
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
171 gotDot = true;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
175 if (c >= '0' && c <= '9')
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 continue; // Digit
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 // If the above cases didn't catch this character, it was
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 // illegal and this is therefore not a number.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 return false;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 return true;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 // =============================================================================
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
189 void simplify (short& numer, short& denom) {
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
190 bool repeat;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 do {
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
193 repeat = false;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
195 for (ushort x = 0; x < NUM_PRIMES; x++) {
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
196 const ushort prime = g_primes[NUM_PRIMES - x - 1];
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
198 if (numer <= prime || denom <= prime)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
201 if ((numer % prime == 0) && (denom % prime == 0)) {
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
202 numer /= prime;
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
203 denom /= prime;
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
204 repeat = true;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 break;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 }
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
208 } while (repeat);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 // =============================================================================
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
212 vertex rotPoint( const vector<LDObject*>& objs )
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
213 {
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
214 bbox box;
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
215
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
216 switch( edit_rotpoint )
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
217 {
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
218 case ObjectOrigin:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
219 // Calculate center vertex
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
220 for( LDObject * obj : objs )
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
221 {
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
222 if( obj->hasMatrix() )
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
223 box << dynamic_cast<LDMatrixObject*>( obj )->position();
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
224 else
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
225 box << obj;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
226 }
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
227
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
228 return box.center ();
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
229
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
230 case WorldOrigin:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
231 return g_origin;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
232
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
233 case CustomPoint:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
234 return vertex (edit_rotpoint_x, edit_rotpoint_y, edit_rotpoint_z);
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
235 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
236
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
237 return vertex();
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
238 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
239
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
240 void configRotationPoint()
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
241 {
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
242 QDialog* dlg = new QDialog;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
243 Ui::RotPointUI ui;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
244 ui.setupUi( dlg );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
245
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
246 switch( edit_rotpoint )
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
247 {
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
248 case ObjectOrigin:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
249 ui.objectPoint->setChecked( true );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
250 break;
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
251
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
252 case WorldOrigin:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
253 ui.worldPoint->setChecked( true );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
254 break;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
255
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
256 case CustomPoint:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
257 ui.customPoint->setChecked( true );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
258 break;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
259 }
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
260
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
261 ui.customX->setValue( edit_rotpoint_x );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
262 ui.customY->setValue( edit_rotpoint_y );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
263 ui.customZ->setValue( edit_rotpoint_z );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
264
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
265 if (!dlg->exec ())
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
266 return;
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
267
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
268 edit_rotpoint =
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
269 ( ui.objectPoint->isChecked() ) ? ObjectOrigin :
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
270 ( ui.worldPoint->isChecked() ) ? WorldOrigin :
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
271 CustomPoint;
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
272
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
273 edit_rotpoint_x = ui.customX->value();
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
274 edit_rotpoint_y = ui.customY->value();
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
275 edit_rotpoint_z = ui.customZ->value();
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
276 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
277
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
278 str join (initlist<StringFormatArg> vals, str delim) {
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
279 QStringList list;
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
280 for (const StringFormatArg& arg : vals)
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
281 list << arg.value ();
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
282
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
283 return list.join (delim);
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
284 }
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
285
308
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
286 double atof( str val )
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
287 {
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
288 // Disable the locale while parsing the line or atof's behavior changes
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
289 // between locales (i.e. fails to read decimals properly). That is
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
290 // quite undesired...
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
291 setlocale( LC_NUMERIC, "C" );
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
292 char* buf = new char[val.length()];
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
293 char* bufptr = &buf[0];
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
294
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
295 for( qchar& c : val )
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
296 *bufptr++ = c.toAscii();
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
297 *bufptr = '\0';
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
298
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
299 double fval = atof( buf );
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
300 delete[] buf;
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
301 return fval;
4e2425bd4dc7 Added an atof overload to convert from string to float, hopefully without any precision error
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
302 }
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
303
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
304 // =============================================================================
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306 // =============================================================================
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
307 StringParser::StringParser (str inText, char sep) {
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
308 m_tokens = container_cast<QStringList, vector<str>> (inText.split (sep, QString::SkipEmptyParts));
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
309 m_pos = -1;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
311
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312 // -----------------------------------------------------------------------------
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 bool StringParser::atBeginning () {
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
314 return (m_pos == -1);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317 // -----------------------------------------------------------------------------
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
318 bool StringParser::atEnd () {
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
319 return (m_pos == (signed) m_tokens.size () - 1);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
322 // -----------------------------------------------------------------------------
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
323 bool StringParser::getToken (str& val, const ushort pos) {
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
324 if (pos >= m_tokens.size())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325 return false;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
327 val = m_tokens[pos];
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 return true;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
329 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
330
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 // -----------------------------------------------------------------------------
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
332 bool StringParser::next (str& val) {
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
333 return getToken (val, ++m_pos);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
334 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336 // -----------------------------------------------------------------------------
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
337 bool StringParser::peekNext (str& val) {
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
338 return getToken (val, m_pos + 1);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
340
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341 // -----------------------------------------------------------------------------
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
342 bool StringParser::findToken (short& result, char const* needle, short args) {
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
343 for (ushort i = 0; i < (m_tokens.size () - args); ++i) {
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
344 if (m_tokens[i] == needle) {
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
345 result = i;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346 return true;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
347 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
348 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
349
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350 return false;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
351 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353 // -----------------------------------------------------------------------------
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
354 void StringParser::rewind () {
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
355 m_pos = -1;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
357
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358 // -----------------------------------------------------------------------------
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
359 void StringParser::seek (short amount, bool rel) {
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
360 m_pos = (rel ? m_pos : 0) + amount;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
363 // -----------------------------------------------------------------------------
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
364 size_t StringParser::size () {
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
365 return m_tokens.size();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368 // -----------------------------------------------------------------------------
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
369 bool StringParser::tokenCompare (short inPos, const char* sOther) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 str tok;
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
371 if (!getToken (tok, inPos))
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372 return false;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 return (tok == sOther);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375 }

mercurial