src/misc.cpp

Tue, 30 Jul 2013 17:27:04 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 30 Jul 2013 17:27:04 +0300
changeset 404
902f137ea753
parent 402
ec95fc95e5f3
child 406
5371baa17346
permissions
-rw-r--r--

cosmetics

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 "dialogs.h"
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
26 #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
27
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 // 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
29 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
30 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
31 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
32 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
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76 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
77 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
78 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
79 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
80 };
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 // Grid stuff
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 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
87
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 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
98 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
99 cfg (float, grid_fine_angle, 7.5f);
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
100 cfg (int, edit_rotpoint, 0);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
101 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
102 cfg (float, edit_rotpoint_y, 0.0f);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
103 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
104
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 const gridinfo g_GridInfo[3] = {
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
106 { "Coarse", { &grid_coarse_x, &grid_coarse_y, &grid_coarse_z, &grid_coarse_angle }},
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
107 { "Medium", { &grid_medium_x, &grid_medium_y, &grid_medium_z, &grid_medium_angle }},
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
108 { "Fine", { &grid_fine_x, &grid_fine_y, &grid_fine_z, &grid_fine_angle }}
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 // =============================================================================
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
112 // 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
113 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
114 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
115 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
116 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
117 double out = mult * gridval;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 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
120 out += gridval;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 if (neg && out != 0)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 out *= -1;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 return out;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 // =============================================================================
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
131 // 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
132 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
133 // 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
134 // 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
135 setlocale (LC_NUMERIC, "C");
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
137 str rep;
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
138 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
139
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 // Remove trailing zeroes
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
141 while (rep.right (1) == "0")
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
142 rep.chop (1);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
144 // 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
145 // the decimal point now.
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
146 if (rep.right (1) == ".")
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
147 rep.chop (1);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
149 return rep;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 // =============================================================================
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
155 bool isNumber (const str& tok) {
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
156 bool gotDot = false;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
158 for (int i = 0; i < tok.length (); ++i) {
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
159 const qchar c = tok[i];
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
160
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
161 // Allow leading hyphen for negatives
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
162 if (i == 0 && c == '-')
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
163 continue;
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
164
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
165 // Check for decimal point
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
166 if (!gotDot && c == '.') {
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
167 gotDot = true;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170
256
9f7e6e288953 rewrote isNumber using range-for
Santeri Piippo <crimsondusk64@gmail.com>
parents: 223
diff changeset
171 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
172 continue; // Digit
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 // 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
175 // 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
176 return false;
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 return true;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 }
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 // =============================================================================
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
185 void simplify (short& numer, short& denom) {
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
186 bool repeat;
183
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 do {
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
189 repeat = false;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
190
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
191 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
192 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
193
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
194 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
195 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
197 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
198 numer /= prime;
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
199 denom /= prime;
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
200 repeat = true;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 break;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 }
268
778eed342ee4 Make LDMatrixObject's transform and pos members properties
Santeri Piippo <crimsondusk64@gmail.com>
parents: 257
diff changeset
204 } while (repeat);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 }
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 // =============================================================================
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
208 vertex rotPoint( const List<LDObject*>& objs )
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
209 {
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 373
diff changeset
210 LDBoundingBox box;
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
211
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
212 switch( edit_rotpoint )
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
213 {
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
214 case ObjectOrigin:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
215 // Calculate center vertex
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
216 for( LDObject * obj : objs )
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 if( obj->hasMatrix() )
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
219 box << dynamic_cast<LDMatrixObject*>( obj )->position();
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
220 else
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
221 box << obj;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
222 }
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
223
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
224 return box.center ();
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
225
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
226 case WorldOrigin:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
227 return g_origin;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
228
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
229 case CustomPoint:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
230 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
231 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
232
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
233 return vertex();
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
234 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
235
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
236 void configRotationPoint()
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
237 {
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
238 QDialog* dlg = new QDialog;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
239 Ui::RotPointUI ui;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
240 ui.setupUi( dlg );
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 switch( edit_rotpoint )
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
243 {
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
244 case ObjectOrigin:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
245 ui.objectPoint->setChecked( true );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
246 break;
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
247
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
248 case WorldOrigin:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
249 ui.worldPoint->setChecked( true );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
250 break;
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
251
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
252 case CustomPoint:
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
253 ui.customPoint->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
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
257 ui.customX->setValue( edit_rotpoint_x );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
258 ui.customY->setValue( edit_rotpoint_y );
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
259 ui.customZ->setValue( edit_rotpoint_z );
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 if (!dlg->exec ())
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
262 return;
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
263
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
264 edit_rotpoint =
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
265 ( ui.objectPoint->isChecked() ) ? ObjectOrigin :
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
266 ( ui.worldPoint->isChecked() ) ? WorldOrigin :
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
267 CustomPoint;
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
268
332
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
269 edit_rotpoint_x = ui.customX->value();
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
270 edit_rotpoint_y = ui.customY->value();
3013acb1df53 Converted rotation point prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 308
diff changeset
271 edit_rotpoint_z = ui.customZ->value();
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
272 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
273
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
274 str join (initlist<StringFormatArg> vals, str delim) {
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
275 QStringList list;
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
276 for (const StringFormatArg& arg : vals)
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
277 list << arg.value ();
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
278
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
279 return list.join (delim);
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
280 }
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
281
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
282 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
283 {
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
284 // 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
285 // 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
286 // 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
287 setlocale( LC_NUMERIC, "C" );
363
75583c9f289d primitive generator: add conditional lines to cylinders; improved bad color handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 332
diff changeset
288
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
289 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
290 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
291
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 for( qchar& c : val )
373
91bea18bd77a Fixed compilation under windows/qt5
Santeri Piippo <crimsondusk64@gmail.com>
parents: 363
diff changeset
293 *bufptr++ = c.toLatin1();
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
294 *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
295
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 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
297 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
298 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
299 }
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 268
diff changeset
300
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
301 // =============================================================================
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 // =============================================================================
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
304 StringParser::StringParser (str inText, char sep) {
402
ec95fc95e5f3 Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
305 m_tokens = container_cast<QStringList, List<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
306 m_pos = -1;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
307 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 // -----------------------------------------------------------------------------
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 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
311 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
312 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314 // -----------------------------------------------------------------------------
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315 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
316 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
317 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
318
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319 // -----------------------------------------------------------------------------
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
320 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
321 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
322 return false;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323
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
324 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
325 return true;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 // -----------------------------------------------------------------------------
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
329 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
330 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
331 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333 // -----------------------------------------------------------------------------
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
334 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
335 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
336 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
337
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
338 // -----------------------------------------------------------------------------
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
339 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
340 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
341 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
342 result = i;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343 return true;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
347 return false;
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 // -----------------------------------------------------------------------------
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
351 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
352 m_pos = -1;
183
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
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355 // -----------------------------------------------------------------------------
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
356 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
357 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
358 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360 // -----------------------------------------------------------------------------
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 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
362 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
363 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
364
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 // -----------------------------------------------------------------------------
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
366 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
367 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
368 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
369 return false;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 return (tok == sOther);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372 }

mercurial