1 /* 2 * Copyright (C) 2016, Mike Walters <mike@flomp.net> 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 std::shared_ptr<AbstractSampleSource> output(); 38 virtual void paintBack(QPainter &painter, QRect &rect, range_t<size_t> sampleRange); 39 virtual void paintMid(QPainter &painter, QRect &rect, range_t<size_t> sampleRange); 40 virtual void paintFront(QPainter &painter, QRect &rect, range_t<size_t> sampleRange); height()41 int height() const { return _height; }; 42 43 signals: 44 void repaint(); 45 46 protected: setHeight(int height)47 void setHeight(int height) { _height = height; }; 48 49 std::shared_ptr<AbstractSampleSource> sampleSource; 50 51 private: 52 // TODO: don't hardcode this 53 int _height = 200; 54 }; 55