qwt_sampling_thread.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
  2. * Qwt Widget Library
  3. * Copyright (C) 1997 Josef Wilgen
  4. * Copyright (C) 2002 Uwe Rathmann
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Qwt License, Version 1.0
  8. *****************************************************************************/
  9. #ifndef _QWT_SAMPLING_THREAD_H_
  10. #define _QWT_SAMPLING_THREAD_H_
  11. #include "qwt_global.h"
  12. #include <qthread.h>
  13. /*!
  14. \brief A thread collecting samples at regular intervals.
  15. Continuous signals are converted into a discrete signal by
  16. collecting samples at regular intervals. A discrete signal
  17. can be displayed by a QwtPlotSeriesItem on a QwtPlot widget.
  18. QwtSamplingThread starts a thread calling periodically sample(),
  19. to collect and store ( or emit ) a single sample.
  20. \sa QwtPlotCurve, QwtPlotSeriesItem
  21. */
  22. class QWT_EXPORT QwtSamplingThread: public QThread
  23. {
  24. Q_OBJECT
  25. public:
  26. virtual ~QwtSamplingThread();
  27. double interval() const;
  28. double elapsed() const;
  29. public Q_SLOTS:
  30. void setInterval( double interval );
  31. void stop();
  32. protected:
  33. explicit QwtSamplingThread( QObject *parent = NULL );
  34. virtual void run();
  35. /*!
  36. Collect a sample
  37. \param elapsed Time since the thread was started in milliseconds
  38. */
  39. virtual void sample( double elapsed ) = 0;
  40. private:
  41. class PrivateData;
  42. PrivateData *d_data;
  43. };
  44. #endif