"Fossies" - the Fresh Open Source Software Archive

Member "xosview-1.23/meter.h" (11 Jul 2020, 1860 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 "meter.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 _METER_H_
    8 #define _METER_H_
    9 
   10 #include "xosview.h"
   11 #include <iostream>
   12 
   13 
   14 class Meter {
   15 public:
   16   Meter( XOSView *parent, const char *title = "", const char *legend ="",
   17      int docaptions = 0, int dolegends = 0, int dousedlegends = 0 );
   18   virtual ~Meter( void );
   19 
   20   virtual const char *name( void ) const { return "Meter"; }
   21   void resize( int x, int y, int width, int height );
   22   virtual void checkevent( void ) = 0;
   23   virtual void draw( void ) = 0;
   24   void title( const char *title );
   25   const char *title( void ) { return title_; }
   26   void legend( const char *legend );
   27   const char *legend( void ) { return legend_; }
   28   void docaptions( int val ) { docaptions_ = val; }
   29   void dolegends( int val ) { dolegends_ = val; }
   30   void dousedlegends( int val ) { dousedlegends_ = val; }
   31   int requestevent( void ){
   32     if (priority_ == 0) {
   33       std::cerr << "Warning:  meter " << name() << " had an invalid priority "
   34                 << "of 0. Resetting to 1..." << std::endl;
   35       priority_ = 1;
   36     }
   37     int rval = counter_ % priority_;
   38     counter_ = (counter_ + 1) % priority_;
   39     return !rval;
   40   }
   41 
   42   int getX() const { return x_; }
   43   int getY() const { return y_; }
   44   int getWidth() const { return width_; }
   45   int getHeight() const { return height_; }
   46 
   47   virtual void checkResources( void );
   48 
   49   static double scaleValue( double value, char *scale, bool metric );
   50 
   51 protected:
   52   XOSView *parent_;
   53   int x_, y_, width_, height_, docaptions_, dolegends_, dousedlegends_;
   54   int priority_, counter_;
   55   char *title_, *legend_;
   56   unsigned long textcolor_;
   57   double samplesPerSecond() { return 1.0*MAX_SAMPLES_PER_SECOND/priority_; }
   58   double secondsPerSample() { return 1.0/samplesPerSecond(); }
   59 
   60 private:
   61 };
   62 
   63 #endif