30 static const float _sector_angle_rad;
40 :
Gauge(left,top,width,height),_numTicks(5)
58 dc->SetFont(SmallFont);
60 float step_val=(range)/(_numTicks-1);
61 float factor=1000/range;
68 dc->
Sector(x0,y0,radius,_sector_angle_rad);
69 float angle_step=_sector_angle_rad/(_numTicks-1.0);
75 for(
int i=0;i<_numTicks;i++)
77 angle=-_sector_angle_rad/2.0+angle_step*i;
80 dc->MoveTo(x0+radius*sin_val,y0-radius*cos_val);
81 dc->LineTo(x0+radius*1.1*sin_val,y0-radius*1.1*cos_val);
82 value=_minValue+step_val*i;
83 x_offset=AHelper::GetNumberLength(value,1);
88 else if(i == _numTicks-1)
92 dc->
DrawNumber(value,1,x0+radius*1.1*sin_val+x_offset,y0-radius*1.1*cos_val-(dc->
FontHeight()*(i==0||i==_numTicks-1?1.5:1)));
97 dc->SetColor(Color::Red);
98 DrawPointer(
_value,x0,y0,radius,dc);
102 void DrawPointer(
float value,
int x0,
int y0,
int radius,
DC *dc)
106 float angle=-_sector_angle_rad/2.0+_sector_angle_rad/1000.0*dc_val;
107 float sin_val=sin(angle);
108 float cos_val=cos(angle);
109 for(
int i=-3;i<4;i++)
111 dc->MoveTo(x0+radius*0.95*sin_val,y0-radius*0.95*cos_val);
112 dc->LineTo(x0+i+radius*0.5*sin_val,y0-radius*0.5*cos_val);
117 const float GaugeRadialPointer::_sector_angle_rad = 3.14 / 2 * 0.8;
Gauge radial pointer class.
Definition: GaugeRadialPointer.h:24
int FontHeight()
Returns symbol jeight for the current font.
Definition: DC.h:211
void Sector(int x0, int y0, int radius, float angle_rad)
Draws sector. Input coordinates have to be defined in the window coordinate system.
Definition: DC.h:250
void DrawNumber(int number, int x, int y)
Draws integer number. Input coordinates have to be defined in the window coordinate system...
Definition: DC.h:161
Color _fillColor
Gauge fill color.
Definition: Gauge.h:27
void OnDraw(DC *dc)
Implements drawing code.
Definition: GaugeRadialPointer.h:56
Gauge window class, that allows visualisaion of data in form of bar or radial pointer.
Definition: Gauge.h:24
Device context. Abstraction layer to the device specific drawing code. Coordinates in drawing functio...
Definition: DC.h:29
float _value
Current gauge value.
Definition: Gauge.h:28
int Height()
Returns window height.
Definition: Window.h:189
int FontWidth()
Returns symbol width for the current font.
Definition: DC.h:206
float _minValue
Gauge min limit.
Definition: Gauge.h:30
bool _drawOnlyPointer
Defines whether only pointer (not scale has to be drawn)
Definition: Gauge.h:32
float _maxValue
Gauge max limit.
Definition: Gauge.h:31
float _oldValue
Previos gauge value.
Definition: Gauge.h:29
void SetNumberOfTicks(int numTicks)
Sets number of ticks.
Definition: GaugeRadialPointer.h:48
GaugeRadialPointer(int left, int top, int width, int height)
Constructor.
Definition: GaugeRadialPointer.h:39
void DrawRoundRect(int left, int top, int right, int bottom)
Draws rounded rectangle. Input coordinates have to be defined in the window coordinate system...
Definition: DC.h:156
int Width()
Returns window width.
Definition: Window.h:184