root / gr-qtgui / src / lib / Waterfall3DDisplayPlot.h @ f123fd99
History | View | Annotate | Download (5.3 kB)
| 1 | #ifndef WATERFALL_3D_DISPLAY_PLOT_HPP
|
|---|---|
| 2 | #define WATERFALL_3D_DISPLAY_PLOT_HPP
|
| 3 | |
| 4 | #include <cstdio> |
| 5 | #include <highResTimeFunctions.h> |
| 6 | |
| 7 | #include <waterfallGlobalData.h> |
| 8 | #include <qwt3d_surfaceplot.h> |
| 9 | |
| 10 | #include <qwt3d_color.h> |
| 11 | #include <qwt_color_map.h> |
| 12 | |
| 13 | class Waterfall3DColorMap: public Qwt3D::Color, public QwtLinearColorMap |
| 14 | {
|
| 15 | public:
|
| 16 | Waterfall3DColorMap(); |
| 17 | virtual ~Waterfall3DColorMap(); |
| 18 | |
| 19 | virtual Qwt3D::RGBA operator()(double x, double y, double z)const; |
| 20 | virtual Qwt3D::ColorVector& createVector(Qwt3D::ColorVector& vec); |
| 21 | |
| 22 | virtual void SetInterval(const double minValue, const double maxValue); |
| 23 | |
| 24 | protected:
|
| 25 | |
| 26 | private:
|
| 27 | QwtDoubleInterval _interval; |
| 28 | }; |
| 29 | |
| 30 | class Waterfall3DDisplayPlot:public Qwt3D::SurfacePlot{
|
| 31 | Q_OBJECT |
| 32 | |
| 33 | protected: |
| 34 | class IntensityScale:public Qwt3D::LinearScale{
|
| 35 | |
| 36 | friend class Qwt3D::Axis; |
| 37 | friend class Qwt3D::qwt3d_ptr<Qwt3D::Scale>; |
| 38 | |
| 39 | private:
|
| 40 | double _floor;
|
| 41 | |
| 42 | public:
|
| 43 | explicit IntensityScale(const double newFloor):_floor(newFloor){ } |
| 44 | virtual ~IntensityScale(){}
|
| 45 | |
| 46 | virtual QString ticLabel(unsigned int idx) const{ |
| 47 | if (idx<majors_p.size())
|
| 48 | {
|
| 49 | return QString("%1").arg( majors_p[idx] + GetFloorValue(), 0, 'f', 0 ); |
| 50 | } |
| 51 | return QString(""); |
| 52 | } |
| 53 | |
| 54 | virtual double GetFloorValue()const{ return _floor; } |
| 55 | virtual void SetFloorValue(const double newFloor){ _floor = newFloor; } |
| 56 | |
| 57 | //! Returns a new heap based object utilized from qwt3d_ptr
|
| 58 | Scale* clone() const {return new IntensityScale(*this);} |
| 59 | }; |
| 60 | |
| 61 | class TimeScale:public Qwt3D::LinearScale{
|
| 62 | |
| 63 | friend class Qwt3D::Axis; |
| 64 | friend class Qwt3D::qwt3d_ptr<Qwt3D::Scale>; |
| 65 | friend class Waterfall3DDisplayPlot; |
| 66 | |
| 67 | private:
|
| 68 | Waterfall3DDisplayPlot* _plot; |
| 69 | |
| 70 | public:
|
| 71 | TimeScale(Waterfall3DDisplayPlot* plot ):_plot(plot){
|
| 72 | } |
| 73 | virtual ~TimeScale(){
|
| 74 | } |
| 75 | |
| 76 | virtual QString ticLabel(unsigned int idx) const{ |
| 77 | if (idx<majors_p.size())
|
| 78 | {
|
| 79 | const timespec markerTime = timespec_add(_plot->_dataTimestamp,
|
| 80 | -(_plot->_timePerFFT) * majors_p[idx]); |
| 81 | struct tm timeTm;
|
| 82 | gmtime_r(&markerTime.tv_sec, &timeTm); |
| 83 | |
| 84 | char* timeBuffer = new char[128]; |
| 85 | snprintf(timeBuffer, 128, "%02d:%02d:%02d.%03ld", timeTm.tm_hour, |
| 86 | timeTm.tm_min, timeTm.tm_sec, (markerTime.tv_nsec / 1000000));
|
| 87 | QString returnBuffer(timeBuffer); |
| 88 | delete[] timeBuffer; |
| 89 | return returnBuffer;
|
| 90 | } |
| 91 | return QString(""); |
| 92 | } |
| 93 | |
| 94 | //! Returns a new heap based object utilized from qwt3d_ptr
|
| 95 | Scale* clone() const {return new TimeScale(*this);} |
| 96 | }; |
| 97 | |
| 98 | class FrequencyScale: public Qwt3D::LinearScale{
|
| 99 | |
| 100 | friend class Qwt3D::Axis; |
| 101 | friend class Qwt3D::qwt3d_ptr<Qwt3D::Scale>; |
| 102 | private:
|
| 103 | double _centerFrequency;
|
| 104 | bool _useCenterFrequencyFlag;
|
| 105 | public:
|
| 106 | FrequencyScale(bool useCenterFrequencyFlag, double centerFrequency) |
| 107 | : _centerFrequency(centerFrequency),_useCenterFrequencyFlag(useCenterFrequencyFlag) |
| 108 | {}
|
| 109 | |
| 110 | virtual ~FrequencyScale(){}
|
| 111 | |
| 112 | virtual QString ticLabel(unsigned int idx) const |
| 113 | {
|
| 114 | if (idx<majors_p.size())
|
| 115 | {
|
| 116 | if(!_useCenterFrequencyFlag){
|
| 117 | return QString("%1").arg( majors_p[idx], 0, 'f', 0 ); |
| 118 | |
| 119 | } |
| 120 | else{
|
| 121 | return QString("%1").arg( (majors_p[idx] + _centerFrequency)/1000.0, 0, 'f', 3 ); |
| 122 | } |
| 123 | } |
| 124 | return QString(""); |
| 125 | } |
| 126 | |
| 127 | //! Returns a new heap based object utilized from qwt3d_ptr
|
| 128 | Scale* clone() const {return new FrequencyScale(*this);} |
| 129 | }; |
| 130 | |
| 131 | public:
|
| 132 | Waterfall3DDisplayPlot(QWidget*); |
| 133 | virtual ~Waterfall3DDisplayPlot(); |
| 134 | |
| 135 | void Init();
|
| 136 | void Reset();
|
| 137 | |
| 138 | bool loadFromData(double** data, unsigned int columns, unsigned int rows |
| 139 | ,double minx, double maxx, double miny, double maxy); |
| 140 | |
| 141 | void SetFrequencyRange(const double, const double, |
| 142 | const double, const bool, |
| 143 | const double units, const std::string &strunits); |
| 144 | double GetStartFrequency()const; |
| 145 | double GetStopFrequency()const; |
| 146 | |
| 147 | void PlotNewData(const double* dataPoints, const int64_t numDataPoints, |
| 148 | const double timePerFFT, const timespec timestamp, |
| 149 | const int droppedFrames); |
| 150 | |
| 151 | void SetIntensityRange(const double minIntensity, const double maxIntensity); |
| 152 | |
| 153 | virtual void replot(void); |
| 154 | |
| 155 | int GetIntensityColorMapType()const; |
| 156 | void SetIntensityColorMapType( const int, const QColor, |
| 157 | const QColor, const bool forceFlag = false, |
| 158 | const bool noReplotFlag = false ); |
| 159 | const QColor GetUserDefinedLowIntensityColor()const; |
| 160 | const QColor GetUserDefinedHighIntensityColor()const; |
| 161 | |
| 162 | static const int INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR = 0; |
| 163 | static const int INTENSITY_COLOR_MAP_TYPE_WHITE_HOT = 1; |
| 164 | static const int INTENSITY_COLOR_MAP_TYPE_BLACK_HOT = 2; |
| 165 | static const int INTENSITY_COLOR_MAP_TYPE_INCANDESCENT = 3; |
| 166 | static const int INTENSITY_COLOR_MAP_TYPE_USER_DEFINED = 4; |
| 167 | |
| 168 | public slots: |
| 169 | void resizeSlot( QSize *s );
|
| 170 | |
| 171 | |
| 172 | signals:
|
| 173 | void UpdatedLowerIntensityLevel(const double); |
| 174 | void UpdatedUpperIntensityLevel(const double); |
| 175 | |
| 176 | protected:
|
| 177 | |
| 178 | double _startFrequency;
|
| 179 | double _stopFrequency;
|
| 180 | |
| 181 | Waterfall3DData* _waterfallData; |
| 182 | |
| 183 | timespec _lastReplot; |
| 184 | |
| 185 | int64_t _numPoints; |
| 186 | |
| 187 | double _displayIntervalTime;
|
| 188 | |
| 189 | int _intensityColorMapType;
|
| 190 | QColor _userDefinedLowIntensityColor; |
| 191 | QColor _userDefinedHighIntensityColor; |
| 192 | |
| 193 | bool _useCenterFrequencyFlag;
|
| 194 | double _centerFrequency;
|
| 195 | |
| 196 | timespec _dataTimestamp; |
| 197 | double _timePerFFT;
|
| 198 | bool _initialized;
|
| 199 | |
| 200 | bool _createCoordinateSystemFlag;
|
| 201 | |
| 202 | private:
|
| 203 | |
| 204 | }; |
| 205 | |
| 206 | #endif /* WATERFALL_3D_DISPLAY_PLOT_HPP */ |