I'm having a problem creating a band around a meter, and I'm wondering what I'm doing wrong. The code to replicate the problem is:
int main(int argc, char *argv)
// Create an AngularMeter object of size 250 x 250 pixels with transparent background
AngularMeter *m = new AngularMeter(250, 250, Chart::Transparent);
// Center at (125, 125), scale radius = 111 pixels, scale angle -145 to +145 degrees
m->setMeter(125, 125, 111, -175, 175);
// Add a red band all the around the meter
m->addZone(0, 100, 95, 111, 0xFF0000);
// Output the chart
//free up resources
This is based on the code for the "Round Meter" sample from the help, with everything that isn't related to the bug removed. When I run this, I get the "Good" image as attached. However, the red band does not go all the way around the meter, since I am passing -175, 175 into the setMeter call. If I change these parameters to be -180, 180 I get the "Bad" image as attached, with the red band just a very thin line at the bottom of the meter.
How can I add a zone that goes all the around the meter?
Some experimentation here indicates that if the gauge goes from 0 - 100, calling addZone(0, 99.99999 ...) works as expected, and if I call setScale(0, 100.000001) and then call addZone(0, 100), it also works as expected, so it looks as if for gauges where the start and end angles define a complete circle, ChartDirector is comparing the value to the maximum, and not drawing the zone if they are the same.
Do I need to detect when the addZone would add a full ring and change the call to addRing, or is there a better way to do it?
If it is easy to detect the full ring condition, I would just check if it is a full ring, and use addRing in such case and addZone in other cases.
If your code will never draw 0% or over 100% (that is, will not create a sector like 20 to 150 where the scale is 0 to 100), you can also try addZone(a, b - 0.000000001). This is visually the same as (a, b) and can avoid the full ring problem.