this is a helper function that computes some useful functions for an axis. It returns the number of ticks
| 31 | // this is a helper function that computes some useful functions |
| 32 | // for an axis. It returns the number of ticks |
| 33 | static int vtkAxisActor2DComputeTicks(double sRange[2], double& interval, double& root) |
| 34 | { |
| 35 | // first we try assuming the first value is reasonable |
| 36 | int numTicks; |
| 37 | double range = fabs(sRange[1] - sRange[0]); |
| 38 | int rootPower = static_cast<int>(floor(log10(range) - 1)); |
| 39 | root = pow(10.0, rootPower); |
| 40 | // val will be between 10 and 100 inclusive of 10 but not 100 |
| 41 | double val = range / root; |
| 42 | // first we check for an exact match |
| 43 | for (numTicks = 5; numTicks < 9; ++numTicks) |
| 44 | { |
| 45 | if (fabs(val / (numTicks - 1.0) - floor(val / (numTicks - 1.0))) < .0001) |
| 46 | { |
| 47 | interval = val * root / (numTicks - 1.0); |
| 48 | return numTicks; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // if there isn't an exact match find a reasonable value |
| 53 | int newIntScale = 10; |
| 54 | if (val > 10) |
| 55 | { |
| 56 | newIntScale = 12; |
| 57 | } |
| 58 | if (val > 12) |
| 59 | { |
| 60 | newIntScale = 15; |
| 61 | } |
| 62 | if (val > 15) |
| 63 | { |
| 64 | newIntScale = 18; |
| 65 | } |
| 66 | if (val > 18) |
| 67 | { |
| 68 | newIntScale = 20; |
| 69 | } |
| 70 | if (val > 20) |
| 71 | { |
| 72 | newIntScale = 25; |
| 73 | } |
| 74 | if (val > 25) |
| 75 | { |
| 76 | newIntScale = 30; |
| 77 | } |
| 78 | if (val > 30) |
| 79 | { |
| 80 | newIntScale = 40; |
| 81 | } |
| 82 | if (val > 40) |
| 83 | { |
| 84 | newIntScale = 50; |
| 85 | } |
| 86 | if (val > 50) |
| 87 | { |
| 88 | newIntScale = 60; |
| 89 | } |
| 90 | if (val > 60) |
no test coverage detected