Changeset 26258 for trunk/Ohana/src/opihi/cmd.data
- Timestamp:
- Nov 22, 2009, 2:54:39 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/grid.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/grid.c
r20936 r26258 1 1 # include "data.h" 2 3 int SetGridScales (double *major, double *minor, double range) { 4 5 double lrange, factor, mantis, fmantis, power; 6 7 lrange = log10(MAX(fabs(range), 1e-30)); 8 factor = (int) (lrange); 9 if (lrange < 0) { factor -= 1; } 10 mantis = lrange - factor; 11 power = pow(10.0, factor); 12 fmantis = pow(10.0, mantis); 13 if ((fmantis >= 1.0) && (fmantis <= 2.0)) { 14 *major = 0.5 * power; 15 *minor = 0.1 * power; 16 } 17 if ((fmantis > 2.0) && (fmantis <= 4.0)) { 18 *major = 1.0 * power; 19 *minor = 0.2 * power; 20 } 21 if ((fmantis > 4.0) && (fmantis <= 6.0)) { 22 *major = 1.0 * power; 23 *minor = 0.5 * power; 24 } 25 if ((fmantis > 6.0) && (fmantis <= 10.0)) { 26 *major = 2.0 * power; 27 *minor = 0.5 * power; 28 } 29 return TRUE; 30 } 2 31 3 32 int grid (int argc, char **argv) { 4 33 34 double range, major, minor, first, next; 5 35 int j, kapa, N, MinorTick, MajorTick; 6 36 Vector Xvec, Yvec; 7 double range, lrange, factor, mantis, fmantis, power, major, minor, first, next;8 37 Graphdata graphmode; 9 38 … … 28 57 major = minor = 1; 29 58 range = graphmode.xmax - graphmode.xmin; 30 lrange = log10(MAX(fabs(range), 1e-30)); 31 factor = (int) (lrange); 32 if (lrange < 0) { factor -= 1; } 33 mantis = lrange - factor; 34 power = pow(10.0, factor); 35 fmantis = pow(10.0, mantis); 36 if ((fmantis >= 1.0) && (fmantis <= 2.0)) { 37 major = 0.5 * power; 38 minor = 0.1 * power; 39 } 40 if ((fmantis > 2.0) && (fmantis <= 4.0)) { 41 major = 1.0 * power; 42 minor = 0.2 * power; 43 } 44 if ((fmantis > 4.0) && (fmantis <= 6.0)) { 45 major = 1.0 * power; 46 minor = 0.5 * power; 47 } 48 if ((fmantis > 6.0) && (fmantis <= 10.0)) { 49 major = 2.0 * power; 50 minor = 0.5 * power; 51 } 59 SetGridScales (&major, &minor, range); 52 60 if (graphmode.xmin > 0) 53 61 first = minor + minor*((int)(graphmode.xmin/minor)); … … 108 116 109 117 range = graphmode.ymax - graphmode.ymin; 110 lrange = log10(MAX(fabs(range), 1e-30)); 111 factor = (int) (lrange); 112 if (lrange < 0) { factor -= 1; } 113 mantis = lrange - factor; 114 power = pow(10.0, factor); 115 fmantis = pow(10.0, mantis); 116 if ((fmantis >= 1.0) && (fmantis <= 2.0)) { 117 major = 0.5 * power; 118 minor = 0.1 * power; 119 } 120 if ((fmantis > 2.0) && (fmantis <= 4.0)) { 121 major = 1.0 * power; 122 minor = 0.2 * power; 123 } 124 if ((fmantis > 4.0) && (fmantis <= 6.0)) { 125 major = 1.0 * power; 126 minor = 0.5 * power; 127 } 128 if ((fmantis > 6.0) && (fmantis <= 10.0)) { 129 major = 2.0 * power; 130 minor = 0.5 * power; 131 } 118 SetGridScales (&major, &minor, range); 132 119 if (graphmode.ymin > 0) 133 120 first = minor + minor*((int)(graphmode.ymin/minor));
Note:
See TracChangeset
for help on using the changeset viewer.
