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

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

initial import for the community edition

Line 
1//
2//  Copyright (c) 1994, 1995, 2006 by Mike Romberg ( mike.romberg@noaa.gov )
3//
4//  This file may be distributed under terms of the GPL
5//
6//
7// $Id: fieldmeter.h,v 1.1.1.1 2008/05/04 15:53:48 emasson Exp $
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
17class FieldMeter : public Meter {
18public:
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    /*  These next two are deprecated -- use setUsed instead.  bgrayson  */
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
42protected:
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
63private:
64  Timer _timer;
65protected:
66  void IntervalTimerStart() { _timer.start(); }
67  void IntervalTimerStop() { _timer.stop(); }
68  //  Before, we simply called _timer.report(), which returns usecs.
69  //  However, it suffers from wrap/overflow/sign-bit problems, so
70  //  instead we use doubles for everything.
71  double IntervalTimeInMicrosecs() { return _timer.report_usecs(); }
72  double IntervalTimeInSecs() { return _timer.report_usecs()/1e6; }
73};
74
75#endif
Note: See TracBrowser for help on using the browser.