Removing Waterfall3DPlot. The qwt_plot3d is too much of a hassle to deal with and...
[debian/gnuradio] / gr-qtgui / src / lib / waterfallGlobalData.cc
index 0cbef4ec37d4245e8a951a23b7e1aefc801cbe60..1ba153f0d2cc3cca374ee6f51d21e8208fbeff9c 100644 (file)
@@ -3,11 +3,13 @@
 
 #include <waterfallGlobalData.h>
 
-#include <Waterfall3DDisplayPlot.h>
-
-WaterfallData::WaterfallData(const double minimumFrequency, const double maximumFrequency, const uint64_t fftPoints, const unsigned int historyExtent):
-  QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */,  0 /* Y START */, maximumFrequency - minimumFrequency /* WIDTH */,  static_cast<double>(historyExtent)/* HEIGHT */))
-
+WaterfallData::WaterfallData(const double minimumFrequency,
+                            const double maximumFrequency,
+                            const uint64_t fftPoints,
+                            const unsigned int historyExtent)
+  : QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */,  0 /* Y START */, 
+                               maximumFrequency - minimumFrequency /* WIDTH */,  
+                               static_cast<double>(historyExtent)/* HEIGHT */))
 {
   _intensityRange = QwtDoubleInterval(-200.0, 0.0);
   
@@ -19,17 +21,20 @@ WaterfallData::WaterfallData(const double minimumFrequency, const double maximum
   Reset();
 }
 
-WaterfallData::~WaterfallData(){
+WaterfallData::~WaterfallData()
+{
   delete[] _spectrumData;
 }
 
-void WaterfallData::Reset(){
+void WaterfallData::Reset()
+{
   memset(_spectrumData, 0x0, _fftPoints*_historyLength*sizeof(double));
 
   _numLinesToUpdate = -1;
 }
 
-void WaterfallData::Copy(const WaterfallData* rhs){
+void WaterfallData::Copy(const WaterfallData* rhs)
+{
   if((_fftPoints != rhs->GetNumFFTPoints()) ||
      (boundingRect() != rhs->boundingRect()) ){
     _fftPoints = rhs->GetNumFFTPoints();
@@ -43,7 +48,10 @@ void WaterfallData::Copy(const WaterfallData* rhs){
   setRange(rhs->range());
 }
 
-void WaterfallData::ResizeData(const double startFreq, const double stopFreq, const uint64_t fftPoints){
+void WaterfallData::ResizeData(const double startFreq,
+                              const double stopFreq,
+                              const uint64_t fftPoints)
+{
   if((fftPoints != GetNumFFTPoints()) ||
      (boundingRect().width() != (stopFreq - startFreq)) ||
      (boundingRect().left() != startFreq)){
@@ -57,21 +65,27 @@ void WaterfallData::ResizeData(const double startFreq, const double stopFreq, co
   Reset();
 }
 
-QwtRasterData *WaterfallData::copy() const{
-  WaterfallData* returnData =  new WaterfallData(boundingRect().left(), boundingRect().right(), _fftPoints, _historyLength);
+QwtRasterData *WaterfallData::copy() const
+{
+  WaterfallData* returnData =  new WaterfallData(boundingRect().left(),
+                                                boundingRect().right(),
+                                                _fftPoints, _historyLength);
   returnData->Copy(this);
   return returnData;
 }
 
-QwtDoubleInterval WaterfallData::range() const{
+QwtDoubleInterval WaterfallData::range() const
+{
   return _intensityRange;
 }
 
-void WaterfallData::setRange(const QwtDoubleInterval& newRange){
+void WaterfallData::setRange(const QwtDoubleInterval& newRange)
+{
   _intensityRange = newRange;
 }
 
-double WaterfallData::value(double x, double y) const{
+double WaterfallData::value(double x, double y) const
+{
   double returnValue = 0.0;
 
   const unsigned int intY = static_cast<unsigned int>((1.0 - (y/boundingRect().height())) * 
@@ -87,11 +101,14 @@ double WaterfallData::value(double x, double y) const{
   return returnValue;
 }
 
-uint64_t WaterfallData::GetNumFFTPoints()const{
+uint64_t WaterfallData::GetNumFFTPoints() const
+{
   return _fftPoints;
 }
 
-void WaterfallData::addFFTData(const double* fftData, const uint64_t fftDataSize, const int droppedFrames){
+void WaterfallData::addFFTData(const double* fftData,
+                              const uint64_t fftDataSize,
+                              const int droppedFrames){
   if(fftDataSize == _fftPoints){
     int64_t heightOffset = _historyLength - 1 - droppedFrames;
     uint64_t drawingDroppedFrames = droppedFrames;
@@ -104,155 +121,44 @@ void WaterfallData::addFFTData(const double* fftData, const uint64_t fftDataSize
     
     // Copy the old data over if any available
     if(heightOffset > 0){
-      memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints], heightOffset * _fftPoints * sizeof(double)) ;
+      memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints],
+              heightOffset * _fftPoints * sizeof(double)) ;
     }
 
     if(drawingDroppedFrames > 0){
       // Fill in zeros data for dropped data
-      memset(&_spectrumData[heightOffset * _fftPoints], 0x00, static_cast<int64_t>(drawingDroppedFrames) * _fftPoints * sizeof(double));
+      memset(&_spectrumData[heightOffset * _fftPoints], 0x00,
+            static_cast<int64_t>(drawingDroppedFrames) * _fftPoints * sizeof(double));
     }
 
     // add the new buffer
     memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints], fftData, _fftPoints*sizeof(double));
-
   }
 }
 
-double* WaterfallData::GetSpectrumDataBuffer()const{
+double* WaterfallData::GetSpectrumDataBuffer() const
+{
   return _spectrumData;
 }
 
-void WaterfallData::SetSpectrumDataBuffer(const double* newData){
+void WaterfallData::SetSpectrumDataBuffer(const double* newData)
+{
   memcpy(_spectrumData, newData, _fftPoints * _historyLength * sizeof(double));
 }
 
-int WaterfallData::GetNumLinesToUpdate()const{
+int WaterfallData::GetNumLinesToUpdate() const
+{
   return _numLinesToUpdate;
 }
 
-void WaterfallData::SetNumLinesToUpdate(const int newNum){
+void WaterfallData::SetNumLinesToUpdate(const int newNum)
+{
   _numLinesToUpdate = newNum;
 }
 
-void WaterfallData::IncrementNumLinesToUpdate(){
-  _numLinesToUpdate++;
-}
-
-Waterfall3DData::Waterfall3DData(const double minimumFrequency, const double maximumFrequency, const uint64_t fftPoints, const unsigned int historyExtent):
-  WaterfallData(minimumFrequency,  maximumFrequency, fftPoints, historyExtent), Qwt3D::Function(){
-
-  _floorValue = 0.0;
-  setMinZ(0.0);
-  setMaxZ(200.0);
-
-  // Create the dummy mesh data until _ResizeMesh is called
-  data = new double*[1];
-  data[0] = new double[1];
-  Qwt3D::Function::setMesh(1,1);
-
-  _ResizeMesh();
-}
-
-Waterfall3DData::~Waterfall3DData(){
-  for ( unsigned i = 0; i < umesh_p; i++){
-    delete[] data[i];
-  }
-  delete[] data;
-
-}
-
-void Waterfall3DData::ResizeData(const double startFreq, const double stopFreq, const uint64_t fftPoints){
-  if((fftPoints != GetNumFFTPoints()) ||
-     (boundingRect().width() != (stopFreq - startFreq)) ||
-     (boundingRect().left() != startFreq)){
-    WaterfallData::ResizeData(startFreq, stopFreq, fftPoints);
-    _ResizeMesh();
-  }
-   
-  Reset();
-}
-
-bool Waterfall3DData::create()
+void WaterfallData::IncrementNumLinesToUpdate()
 {
-  if ((umesh_p<=2) || (vmesh_p<=2) || !plotwidget_p)
-    return false;
-
-  // Almost the same as the old create, except that here we store our own data buffer in the class rather than re-creating it each time...
-
-  unsigned i,j;
-
-  /* get the data */
-  double dx = (maxu_p - minu_p) / (umesh_p - 1);
-  double dy = (maxv_p - minv_p) / (vmesh_p - 1);
-  
-  for (i = 0; i < umesh_p; ++i) 
-    {
-      for (j = 0; j < vmesh_p; ++j) 
-       {
-         data[i][j] = operator()(minu_p + i*dx, minv_p + j*dy);
-         
-         if (data[i][j] > range_p.maxVertex.z)
-           data[i][j] = range_p.maxVertex.z;
-         else if (data[i][j] < range_p.minVertex.z)
-           data[i][j] = range_p.minVertex.z;
-       }
-    }
-  
-  Q_ASSERT(plotwidget_p);
-  if (!plotwidget_p)
-    {
-      fprintf(stderr,"Function: no valid Plot3D Widget assigned");
-    }
-  else
-    {
-      ((Waterfall3DDisplayPlot*)plotwidget_p)->loadFromData(data, umesh_p, vmesh_p, minu_p, maxu_p, minv_p, maxv_p);
-    }
-  
-  return true;
-}
-
-double Waterfall3DData::operator()(double x, double y){
-  return value(x,y) - _floorValue;
-}
-
-double Waterfall3DData::GetFloorValue()const{
-  return _floorValue;
-}
-
-void Waterfall3DData::SetFloorValue(const double newValue){
-  _floorValue = newValue;
-}
-
-double Waterfall3DData::minZ()const{
-  return range_p.minVertex.z;
-}
-
-double Waterfall3DData::maxZ()const{
-  return range_p.maxVertex.z;
-}
-
-void Waterfall3DData::setMesh(unsigned int, unsigned int){
-  // Do Nothing
-  printf("Should Not Reach this Function\n");
-}
-
-void Waterfall3DData::_ResizeMesh(){
-  // Clear out the old mesh
-  for ( unsigned i = 0; i < umesh_p; i++){
-    delete[] data[i];
-  }
-  delete[] data;
-  
-  Qwt3D::Function::setMesh(static_cast<int>(boundingRect().width()/20.0), _historyLength);
-  setDomain( boundingRect().left(), static_cast<int>(boundingRect().right()), 0, _historyLength);
-
-  /* allocate some space for the mesh */
-  unsigned i;
-  data         = new double* [umesh_p] ;
-  for ( i = 0; i < umesh_p; i++) 
-    {
-      data[i]         = new double [vmesh_p];
-    }
+  _numLinesToUpdate++;
 }
 
 #endif /* WATERFALL_GLOBAL_DATA_CPP */