CircleFillMeter.C

00001 
00002 #include "GUI/CircleFillMeter.H"
00003 #include "Image/PixelsTypes.H"
00004 
00005 CircleFillMeter::CircleFillMeter(int width, int height, int max = 0):
00006   itsWidth(width),
00007   itsHeight(height),
00008   itsCurrentValue(0),
00009   itsMaxRadius(14),
00010   itsMaxValue(max)
00011 {
00012 }
00013 
00014 Image<PixRGB<byte> > CircleFillMeter::render(short val)
00015 {
00016   itsCurrentValue = val;
00017   //  float fillRad = (float)(val) / 20.0;
00018 
00019   Image<PixRGB<byte> > circleImage(itsWidth,itsHeight,ZEROS);
00020 
00021   drawCircle(circleImage,
00022              Point2D<int>(itsWidth/2,itsHeight/2),
00023              .9*std::min(itsWidth,itsHeight)/2,
00024              PixRGB<byte>(100,100,100));
00025 
00026   drawCircle(circleImage,
00027              Point2D<int>(itsWidth/2,itsHeight/2),
00028              .35*std::min(itsWidth,itsHeight)/2,
00029              PixRGB<byte>(100,100,100));
00030 
00031   float numLines = ((float)val / (float)itsMaxValue)*24.0;
00032 
00033   for(int i = 0; i < (int)numLines; i++)
00034     {
00035       int x1 = (int)(.9*std::min(itsWidth,itsHeight)/2*cos((15*i-90)*(M_PI/180))); //shift by 90 so that 0 is up
00036       int y1 = (int)(.9*std::min(itsWidth,itsHeight)/2*sin((15*i-90)*(M_PI/180)));
00037 
00038       int x2 = (int)(.35*std::min(itsWidth,itsHeight)/2*cos((15*i-90)*(M_PI/180))); //shift by 90 so that 0 is up
00039       int y2 = (int)(.35*std::min(itsWidth,itsHeight)/2*sin((15*i-90)*(M_PI/180)));
00040 
00041       drawLine(circleImage, Point2D<int>(itsWidth/2+x2,itsHeight/2+y2),
00042                Point2D<int>(itsWidth/2+x1,itsHeight/2+y1),
00043                PixRGB<byte>(0,255,0),1);
00044     }
00045 
00046   return circleImage;
00047 }
Generated on Sun May 8 08:40:39 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3