| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | #ifndef _FIELDMETER_H_ |
|---|
| 10 | #define _FIELDMETER_H_ |
|---|
| 11 | |
|---|
| 12 | #define FIELDMETER_H_CVSID "$Id: fieldmeter.h,v 1.1.1.1 2008/05/04 15:53:48 emasson Exp $" |
|---|
| 13 | |
|---|
| 14 | #include "meter.h" |
|---|
| 15 | #include "timer.h" |
|---|
| 16 | |
|---|
| 17 | class FieldMeter : public Meter { |
|---|
| 18 | public: |
|---|
| 19 | FieldMeter( XOSView *parent, int numfields, |
|---|
| 20 | const char *title = "", const char *legend = "", |
|---|
| 21 | int docaptions = 0, int dolegends = 0, int dousedlegends = 0 ); |
|---|
| 22 | virtual ~FieldMeter( void ); |
|---|
| 23 | |
|---|
| 24 | virtual void drawfields( int manditory = 0 ); |
|---|
| 25 | void setfieldcolor( int field, const char *color ); |
|---|
| 26 | void setfieldcolor( int field, unsigned long color); |
|---|
| 27 | void docaptions( int val ) { docaptions_ = val; } |
|---|
| 28 | void dolegends( int val ) { dolegends_ = val; } |
|---|
| 29 | void dousedlegends( int val ) { dousedlegends_ = val; } |
|---|
| 30 | void reset( void ); |
|---|
| 31 | |
|---|
| 32 | void used_obsolete( int val ) { print_ = PERCENT; used_ = val; } |
|---|
| 33 | void absolute_obsolete( float val ) { print_ = FLOAT; used_ = val; } |
|---|
| 34 | |
|---|
| 35 | void setUsed (float val, float total); |
|---|
| 36 | void draw( void ); |
|---|
| 37 | void checkevent( void ); |
|---|
| 38 | void disableMeter ( void ); |
|---|
| 39 | |
|---|
| 40 | virtual void checkResources( void ); |
|---|
| 41 | |
|---|
| 42 | protected: |
|---|
| 43 | enum UsedType { INVALID_0, FLOAT, PERCENT, AUTOSCALE, INVALID_TAIL }; |
|---|
| 44 | |
|---|
| 45 | int numfields_; |
|---|
| 46 | float *fields_; |
|---|
| 47 | float total_, used_, lastused_; |
|---|
| 48 | int *lastvals_, *lastx_; |
|---|
| 49 | unsigned long *colors_; |
|---|
| 50 | unsigned long usedcolor_; |
|---|
| 51 | UsedType print_; |
|---|
| 52 | int printedZeroTotalMesg_; |
|---|
| 53 | int numWarnings_; |
|---|
| 54 | |
|---|
| 55 | void SetUsedFormat ( const char * const str ); |
|---|
| 56 | void drawlegend( void ); |
|---|
| 57 | void drawused( int manditory ); |
|---|
| 58 | bool checkX(int x, int width) const; |
|---|
| 59 | |
|---|
| 60 | void setNumFields(int n); |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | private: |
|---|
| 64 | Timer _timer; |
|---|
| 65 | protected: |
|---|
| 66 | void IntervalTimerStart() { _timer.start(); } |
|---|
| 67 | void IntervalTimerStop() { _timer.stop(); } |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | double IntervalTimeInMicrosecs() { return _timer.report_usecs(); } |
|---|
| 72 | double IntervalTimeInSecs() { return _timer.report_usecs()/1e6; } |
|---|
| 73 | }; |
|---|
| 74 | |
|---|
| 75 | #endif |
|---|