File indexing completed on 2024-12-01 11:20:36
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2006 by Jonathan Myers and David Saxton * 0003 * electronerd@electronerdia.net david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #ifndef SCOPEVIEWBASE_H 0012 #define SCOPEVIEWBASE_H 0013 0014 #include <QFrame> 0015 0016 class Oscilloscope; 0017 class Simulator; 0018 class ProbeData; 0019 class LogicProbeData; 0020 class FloatingProbeData; 0021 0022 class QMouseEvent; 0023 class QPaintEvent; 0024 class QPixmap; 0025 class QTimer; 0026 0027 typedef long long llong; 0028 0029 /// base class of oscilloscope views 0030 /** 0031 * 0032 * This is a refactoring of OscilloscopeView and my ScopeScreenView to promote 0033 * code reuse, both between the classes and within them. This is an abstract 0034 * class. 0035 * @author John Myers 0036 * @author David Saxton 0037 * 0038 */ 0039 class ScopeViewBase : public QFrame 0040 { 0041 Q_OBJECT 0042 public: 0043 ScopeViewBase(QWidget *parent = nullptr); 0044 virtual void drawBackground(QPainter &p) = 0; 0045 void resizeEvent(QResizeEvent *event) override; 0046 void updateOutputHeight(); 0047 0048 ~ScopeViewBase() override; 0049 0050 protected: 0051 /// Draw the horizontal line indicating the midpoint of our output for \c probe 0052 virtual void drawMidLine(QPainter &p, ProbeData *probe) = 0; 0053 0054 ///\TODO: remove virtual; draw one logic probe 0055 virtual void drawProbe(QPainter &p, LogicProbeData *probe) = 0; 0056 ///\TODO: remove virtual; draw one floating-point probe 0057 virtual void drawProbe(QPainter &p, FloatingProbeData *probe) = 0; 0058 0059 /// gives the first Simulator tick visible in the view 0060 virtual llong visibleStartTime() const = 0; 0061 /// gives the last Simulator tick visible in the view 0062 virtual llong visibleEndTime() const = 0; 0063 0064 virtual double ticksPerPixel() const = 0; 0065 virtual llong pixelsPerTick() const = 0; 0066 0067 bool b_needRedraw; 0068 QPixmap *m_pixmap; 0069 double m_halfOutputHeight; 0070 0071 private: 0072 /// draws a mapping of probes 0073 template<typename T> void drawProbeMap(QPainter &p, QMap<int, T *> &map); 0074 void paintEvent(QPaintEvent *event) override; 0075 }; 0076 0077 #endif