| 1 | /* |
| 2 | * Copyright (C) 2016, Mike Walters <[email protected]> |
| 3 | * |
| 4 | * This file is part of inspectrum. |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation, either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include <QMouseEvent> |
| 23 | #include <QObject> |
| 24 | #include <QPainter> |
| 25 | #include "abstractsamplesource.h" |
| 26 | #include "util.h" |
| 27 | |
| 28 | class Plot : public QObject, public Subscriber |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | |
| 32 | public: |
| 33 | Plot(std::shared_ptr<AbstractSampleSource> src); |
| 34 | ~Plot(); |
| 35 | void invalidateEvent() override; |
| 36 | virtual bool mouseEvent(QEvent::Type type, QMouseEvent *event); |
| 37 | virtual void leaveEvent(); |
| 38 | virtual std::shared_ptr<AbstractSampleSource> output(); |
| 39 | virtual void paintBack(QPainter &painter, QRect &rect, range_t<size_t> sampleRange); |
| 40 | virtual void paintMid(QPainter &painter, QRect &rect, range_t<size_t> sampleRange); |
| 41 | virtual void paintFront(QPainter &painter, QRect &rect, range_t<size_t> sampleRange); |
| 42 | int height() const { return _height; }; |
| 43 | |
| 44 | signals: |
| 45 | void repaint(); |
| 46 | |
| 47 | protected: |
| 48 | void setHeight(int height) { _height = height; }; |
| 49 | |
| 50 | std::shared_ptr<AbstractSampleSource> sampleSource; |
| 51 | |
| 52 | private: |
| 53 | // TODO: don't hardcode this |
| 54 | int _height = 200; |
| 55 | }; |