"Fossies" - the Fresh Open Source Software Archive

Member "xosview-1.23/fieldmeter.h" (11 Jul 2020, 1979 Bytes) of package /linux/misc/xosview-1.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "fieldmeter.h" see the Fossies "Dox" file reference documentation.

    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 #ifndef _FIELDMETER_H_
    8 #define _FIELDMETER_H_
    9 
   10 #include "meter.h"
   11 #include "xosview.h"
   12 #include "timer.h"
   13 
   14 
   15 class FieldMeter : public Meter {
   16 public:
   17   FieldMeter( XOSView *parent, int numfields,
   18           const char *title = "", const char *legend = "",
   19           int docaptions = 0, int dolegends = 0, int dousedlegends = 0 );
   20   virtual ~FieldMeter( void );
   21 
   22   virtual void drawfields( int mandatory = 0 );
   23   void setfieldcolor( int field, const char *color );
   24   void setfieldcolor( int field, unsigned long color);
   25   void docaptions( int val ) { docaptions_ = val; }
   26   void dolegends( int val ) { dolegends_ = val; }
   27   void dousedlegends( int val ) { dousedlegends_ = val; }
   28   void reset( void );
   29   void setUsed (double val, double total);
   30   void draw( void );
   31   void checkevent( void );
   32   void disableMeter ( void );
   33 
   34   virtual void checkResources( void );
   35 
   36 protected:
   37   enum UsedType { INVALID_0, FLOAT, PERCENT, AUTOSCALE, INVALID_TAIL };
   38 
   39   int numfields_;
   40   double *fields_;
   41   double total_, used_, lastused_;
   42   int *lastvals_, *lastx_;
   43   unsigned long *colors_;
   44   unsigned long usedcolor_;
   45   UsedType print_;
   46   int printedZeroTotalMesg_;
   47   int numWarnings_;
   48   bool metric_;
   49   int usedoffset_;
   50 
   51   void SetUsedFormat ( const char * const str );
   52   void drawlegend( void );
   53   void drawused( int mandatory );
   54   bool checkX(int x, int width) const;
   55 
   56   void setNumFields(int n);
   57 
   58 
   59 private:
   60   Timer _timer;
   61 protected:
   62   void IntervalTimerStart() { _timer.start(); }
   63   void IntervalTimerStop() { _timer.stop(); }
   64   //  Before, we simply called _timer.report(), which returns usecs.
   65   //  However, it suffers from wrap/overflow/sign-bit problems, so
   66   //  instead we use doubles for everything.
   67   double IntervalTimeInMicrosecs() { return _timer.report_usecs(); }
   68   double IntervalTimeInSecs() { return _timer.report_usecs()/1e6; }
   69 };
   70 
   71 #endif