misc.cpp

changeset 147
291a1fe2d278
parent 146
2ab24976acaa
child 161
c9fba92c4e35
equal deleted inserted replaced
146:2ab24976acaa 147:291a1fe2d278
19 #include <math.h> 19 #include <math.h>
20 #include <locale.h> 20 #include <locale.h>
21 #include <qcolor.h> 21 #include <qcolor.h>
22 #include "common.h" 22 #include "common.h"
23 #include "misc.h" 23 #include "misc.h"
24 #include "gui.h"
24 25
25 // Prime number table. 26 // Prime number table.
26 const ushort g_uaPrimes[NUM_PRIMES] = { 27 const ushort g_uaPrimes[NUM_PRIMES] = {
27 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 28 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
28 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 29 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
79 // ============================================================================= 80 // =============================================================================
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
81 // ============================================================================= 82 // =============================================================================
82 // Grid stuff 83 // Grid stuff
83 cfg (int, grid, Grid::Medium); 84 cfg (int, grid, Grid::Medium);
84 85 EXTERN_ACTION (gridCoarse)
85 cfg (float, grid_coarse_x, 5.0f); 86 EXTERN_ACTION (gridMedium)
86 cfg (float, grid_coarse_y, 5.0f); 87 EXTERN_ACTION (gridFine)
87 cfg (float, grid_coarse_z, 5.0f); 88
89 cfg (float, grid_coarse_x, 5.0f);
90 cfg (float, grid_coarse_y, 5.0f);
91 cfg (float, grid_coarse_z, 5.0f);
88 cfg (float, grid_coarse_angle, 45.0f); 92 cfg (float, grid_coarse_angle, 45.0f);
89 cfg (float, grid_medium_x, 1.0f); 93 cfg (float, grid_medium_x, 1.0f);
90 cfg (float, grid_medium_y, 1.0f); 94 cfg (float, grid_medium_y, 1.0f);
91 cfg (float, grid_medium_z, 1.0f); 95 cfg (float, grid_medium_z, 1.0f);
92 cfg (float, grid_medium_angle, 22.5f); 96 cfg (float, grid_medium_angle, 22.5f);
93 cfg (float, grid_fine_x, 0.1f); 97 cfg (float, grid_fine_x, 0.1f);
94 cfg (float, grid_fine_y, 0.1f); 98 cfg (float, grid_fine_y, 0.1f);
95 cfg (float, grid_fine_z, 0.1f); 99 cfg (float, grid_fine_z, 0.1f);
96 cfg (float, grid_fine_angle, 7.5f); 100 cfg (float, grid_fine_angle, 7.5f);
97 101
98 const gridinfo g_GridInfo[3] = { 102 const gridinfo g_GridInfo[3] = {
99 { "Coarse", { &grid_coarse_x, &grid_coarse_y, &grid_coarse_z, &grid_coarse_angle } }, 103 { "Coarse", { &grid_coarse_x, &grid_coarse_y, &grid_coarse_z, &grid_coarse_angle }, &ACTION (gridCoarse) },
100 { "Medium", { &grid_medium_x, &grid_medium_y, &grid_medium_z, &grid_medium_angle } }, 104 { "Medium", { &grid_medium_x, &grid_medium_y, &grid_medium_z, &grid_medium_angle }, &ACTION (gridMedium) },
101 { "Fine", { &grid_fine_x, &grid_fine_y, &grid_fine_z, &grid_fine_angle } } 105 { "Fine", { &grid_fine_x, &grid_fine_y, &grid_fine_z, &grid_fine_angle }, &ACTION (gridFine) }
102 }; 106 };
103
104 template<class T> inline T abs (T a) {
105 return (a >= 0) ? a : -a;
106 }
107 107
108 // ============================================================================= 108 // =============================================================================
109 double Grid::snap (double in, const Grid::Config axis) { 109 double Grid::snap (double in, const Grid::Config axis) {
110 const double gridval = currentGrid ().confs[axis]->value; 110 const double gridval = currentGrid ().confs[axis]->value;
111 const long mult = abs (in / gridval); 111 const long mult = abs (in / gridval);

mercurial