root/foundation-apps/grosview-maxx/bitfieldmeter.h

Revision 2, 2.3 KB (checked in by emasson, 3 years ago)

initial import for the community edition

Line 
1//
2//  Copyright (c) 1999, 2006 Thomas Waldmann (ThomasWaldmann@gmx.de)
3//  based on work of Mike Romberg ( mike.romberg@noaa.gov )
4//
5//  This file may be distributed under terms of the GPL
6//
7//
8#ifndef _BITFIELDMETER_H_
9#define _BITFIELDMETER_H_
10
11#include "meter.h"
12#include "timer.h"
13
14class BitFieldMeter : public Meter {
15public:
16  BitFieldMeter( XOSView *parent, int numBits = 1, int numfields = 1,
17              const char *title = "",
18              const char *bitlegend = "", const char *fieldlegend = "",
19              int docaptions = 0, int dolegends = 0, int dousedlegends = 0 );
20  virtual ~BitFieldMeter( void );
21
22  virtual void drawfields( int manditory = 0 );
23  void drawBits( int manditory = 0 );
24
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 setUsed (float val, float total);
33  void setBits(int startbit, unsigned char values);
34
35  void draw( void );
36  void checkevent( void );
37  void disableMeter ( void );
38
39  virtual void checkResources( void );
40
41protected:
42  enum UsedType { INVALID_0, FLOAT, PERCENT, AUTOSCALE, INVALID_TAIL };
43
44  int numfields_;
45  float *fields_;
46  float total_, used_, lastused_;
47  int *lastvals_, *lastx_;
48  unsigned long *colors_;
49  unsigned long usedcolor_;
50  UsedType print_;
51  int printedZeroTotalMesg_;
52  int numWarnings_;
53
54  unsigned long onColor_, offColor_;
55  char *bits_, *lastbits_;
56  int numbits_;
57
58  void SetUsedFormat ( const char * const str );
59  void drawfieldlegend( void );
60  void drawused( int manditory );
61  bool checkX(int x, int width) const;
62
63  void setNumFields(int n);
64  void setNumBits(int n);
65  char *fieldLegend_;
66
67  void setfieldlegend(const char *fieldlegend);
68
69private:
70  Timer _timer;
71protected:
72  void IntervalTimerStart() { _timer.start(); }
73  void IntervalTimerStop() { _timer.stop(); }
74  //  Before, we simply called _timer.report(), which returns usecs.
75  //  However, it suffers from wrap/overflow/sign-bit problems, so
76  //  instead we use doubles for everything.
77  double IntervalTimeInMicrosecs() { return _timer.report_usecs(); }
78  double IntervalTimeInSecs() { return _timer.report_usecs()/1e6; }
79};
80
81#endif
Note: See TracBrowser for help on using the browser.