VectorView.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* VectorView.h - declaration of VectorView class.
  2. *
  3. * Copyright (c) 2019 Martin Pavelek <he29/dot/HS/at/gmail/dot/com>
  4. *
  5. * This file is part of LMMS - https://lmms.io
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with this program (see COPYING); if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. * Boston, MA 02110-1301 USA.
  21. *
  22. */
  23. #ifndef VECTORVIEW_H
  24. #define VECTORVIEW_H
  25. #include <QMouseEvent>
  26. #include <QWheelEvent>
  27. #include <QWidget>
  28. #include "Knob.h"
  29. #include "LedCheckbox.h"
  30. #include "LocklessRingBuffer.h"
  31. #include "VecControls.h"
  32. //#define VEC_DEBUG
  33. // Widget that displays a vectorscope visualization of stereo signal.
  34. class VectorView : public QWidget
  35. {
  36. Q_OBJECT
  37. public:
  38. explicit VectorView(VecControls *controls, LocklessRingBuffer<sampleFrame> *inputBuffer, unsigned short displaySize, QWidget *parent = 0);
  39. virtual ~VectorView() {}
  40. QSize sizeHint() const override {return QSize(300, 300);}
  41. protected:
  42. void paintEvent(QPaintEvent *event) override;
  43. void mouseDoubleClickEvent(QMouseEvent *event) override;
  44. void wheelEvent(QWheelEvent *event) override;
  45. private slots:
  46. void periodicUpdate();
  47. private:
  48. VecControls *m_controls;
  49. LocklessRingBuffer<sampleFrame> *m_inputBuffer;
  50. LocklessRingBufferReader<sampleFrame> m_bufferReader;
  51. std::vector<uchar> m_displayBuffer;
  52. const unsigned short m_displaySize;
  53. bool m_visible;
  54. float m_zoom;
  55. // State variables for comparison with previous repaint
  56. unsigned int m_persistTimestamp;
  57. unsigned int m_zoomTimestamp;
  58. bool m_oldHQ;
  59. int m_oldX;
  60. int m_oldY;
  61. #ifdef VEC_DEBUG
  62. float m_executionAvg = 0;
  63. #endif
  64. };
  65. #endif // VECTORVIEW_H