"Fossies" - the Fresh Open Source Software Archive

Member "xosview-1.23/bitfieldmeter.h" (11 Jul 2020, 2384 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 "bitfieldmeter.h" see the Fossies "Dox" file reference documentation.

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