2 #include <QColorDialog>
4 #include <spectrumdisplayform.h>
6 int SpectrumDisplayForm::_openGLWaterfall3DFlag = -1;
8 SpectrumDisplayForm::SpectrumDisplayForm(bool useOpenGL, QWidget* parent)
13 _useOpenGL = useOpenGL;
14 _systemSpecifiedFlag = false;
15 _intValidator = new QIntValidator(this);
16 _intValidator->setBottom(0);
17 _frequencyDisplayPlot = new FrequencyDisplayPlot(FrequencyPlotDisplayFrame);
18 _waterfallDisplayPlot = new WaterfallDisplayPlot(WaterfallPlotDisplayFrame);
20 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
21 _waterfall3DDisplayPlot = new Waterfall3DDisplayPlot(Waterfall3DPlotDisplayFrame);
24 _timeDomainDisplayPlot = new TimeDomainDisplayPlot(TimeDomainDisplayFrame);
25 _constellationDisplayPlot = new ConstellationDisplayPlot(ConstellationDisplayFrame);
26 _numRealDataPoints = 1024;
27 _realFFTDataPoints = new double[_numRealDataPoints];
28 _averagedValues = new double[_numRealDataPoints];
29 _historyVector = new std::vector<double*>;
31 AvgLineEdit->setRange(0, 500); // Set range of Average box value from 0 to 500
32 MinHoldCheckBox_toggled( false );
33 MaxHoldCheckBox_toggled( false );
35 WaterfallMaximumIntensityWheel->setRange(-200, 0);
36 WaterfallMaximumIntensityWheel->setTickCnt(50);
37 WaterfallMinimumIntensityWheel->setRange(-200, 0);
38 WaterfallMinimumIntensityWheel->setTickCnt(50);
39 WaterfallMinimumIntensityWheel->setValue(-200);
41 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
42 Waterfall3DMaximumIntensityWheel->setRange(-200, 0);
43 Waterfall3DMaximumIntensityWheel->setTickCnt(50);
44 Waterfall3DMinimumIntensityWheel->setRange(-200, 0);
45 Waterfall3DMinimumIntensityWheel->setTickCnt(50);
46 Waterfall3DMinimumIntensityWheel->setValue(-200);
50 _peakAmplitude = -HUGE_VAL;
52 _noiseFloorAmplitude = -HUGE_VAL;
54 connect(_waterfallDisplayPlot, SIGNAL(UpdatedLowerIntensityLevel(const double)),
55 _frequencyDisplayPlot, SLOT(SetLowerIntensityLevel(const double)));
56 connect(_waterfallDisplayPlot, SIGNAL(UpdatedUpperIntensityLevel(const double)),
57 _frequencyDisplayPlot, SLOT(SetUpperIntensityLevel(const double)));
59 _frequencyDisplayPlot->SetLowerIntensityLevel(-200);
60 _frequencyDisplayPlot->SetUpperIntensityLevel(-200);
62 // Load up the acceptable FFT sizes...
63 FFTSizeComboBox->clear();
64 for(long fftSize = SpectrumGUIClass::MIN_FFT_SIZE; fftSize <= SpectrumGUIClass::MAX_FFT_SIZE; fftSize *= 2){
65 FFTSizeComboBox->insertItem(FFTSizeComboBox->count(), QString("%1").arg(fftSize));
69 ToggleTabFrequency(false);
70 ToggleTabWaterfall(false);
71 ToggleTabWaterfall3D(false);
73 ToggleTabConstellation(false);
75 // Create a timer to update plots at the specified rate
76 displayTimer = new QTimer(this);
77 connect(displayTimer, SIGNAL(timeout()), this, SLOT(UpdateGuiTimer()));
80 SpectrumDisplayForm::~SpectrumDisplayForm()
82 // Qt deletes children when parent is deleted
84 // Don't worry about deleting Display Plots - they are deleted when parents are deleted
85 /* delete _intValidator; */
87 delete[] _realFFTDataPoints;
88 delete[] _averagedValues;
90 for(unsigned int count = 0; count < _historyVector->size(); count++){
91 delete[] _historyVector->operator[](count);
94 delete _historyVector;
100 SpectrumDisplayForm::setSystem( SpectrumGUIClass * newSystem,
101 const uint64_t numFFTDataPoints,
102 const uint64_t numTimeDomainDataPoints )
104 ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints);
106 if(newSystem != NULL){
108 _systemSpecifiedFlag = true;
111 _systemSpecifiedFlag = false;
116 SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdateEvent)
118 //_lastSpectrumEvent = (SpectrumUpdateEvent)(*spectrumUpdateEvent);
119 const std::complex<float>* complexDataPoints = spectrumUpdateEvent->getFFTPoints();
120 const uint64_t numFFTDataPoints = spectrumUpdateEvent->getNumFFTDataPoints();
121 const double* realTimeDomainDataPoints = spectrumUpdateEvent->getRealTimeDomainPoints();
122 const double* imagTimeDomainDataPoints = spectrumUpdateEvent->getImagTimeDomainPoints();
123 const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints();
124 const timespec dataTimestamp = spectrumUpdateEvent->getDataTimestamp();;
125 const bool repeatDataFlag = spectrumUpdateEvent->getRepeatDataFlag();
126 const bool lastOfMultipleUpdatesFlag = spectrumUpdateEvent->getLastOfMultipleUpdateFlag();
127 const timespec generatedTimestamp = spectrumUpdateEvent->getEventGeneratedTimestamp();
129 // REMEMBER: The dataTimestamp is NOT valid when the repeat data flag is true...
130 ResizeBuffers(numFFTDataPoints, numTimeDomainDataPoints);
132 // Calculate the Magnitude of the complex point
133 const std::complex<float>* complexDataPointsPtr = complexDataPoints+numFFTDataPoints/2;
134 double* realFFTDataPointsPtr = _realFFTDataPoints;
136 // Run this twice to perform the fftshift operation on the data here as well
137 for(uint64_t point = 0; point < numFFTDataPoints/2; point++){
139 // 50 ohm load assumption
140 // 10 * log10 (v^2 / (2 * 50.0 * .001)) = 10 * log10( v^2 * 10)
141 // 75 ohm load assumption
142 // 10 * log10 (v^2 / (2 * 75.0 * .001)) = 10 * log10( v^2 * 15)
144 // perform scaling here
145 std::complex<float> pt = (*complexDataPointsPtr) / std::complex<float>((float)numFFTDataPoints);
146 *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20);
148 complexDataPointsPtr++;
149 realFFTDataPointsPtr++;
152 // This loop takes the first half of the input data and puts it in the
153 // second half of the plotted data
154 complexDataPointsPtr = complexDataPoints;
155 for(uint64_t point = 0; point < numFFTDataPoints/2; point++){
156 std::complex<float> pt = (*complexDataPointsPtr) / std::complex<float>((float)numFFTDataPoints);
157 *realFFTDataPointsPtr = 10.0*log10((pt.real() * pt.real() + pt.imag()*pt.imag()) + 1e-20);
159 complexDataPointsPtr++;
160 realFFTDataPointsPtr++;
163 // Don't update the averaging history if this is repeated data
165 _AverageHistory(_realFFTDataPoints);
168 const double fft_bin_size = (_stopFrequency-_startFrequency) /
169 static_cast<double>(numFFTDataPoints);
171 // find the peak, sum (for mean), etc
172 _peakAmplitude = -HUGE_VAL;
174 for(uint64_t number = 0; number < numFFTDataPoints; number++){
176 if(_realFFTDataPoints[number] > _peakAmplitude){
177 // Calculate the frequency relative to the local bw, adjust for _startFrequency later
178 _peakFrequency = (static_cast<float>(number) * fft_bin_size);
179 _peakAmplitude = _realFFTDataPoints[number];
180 // _peakBin = number;
183 sumMean += _realFFTDataPoints[number];
186 // calculate the spectral mean
187 // +20 because for the comparison below we only want to throw out bins
188 // that are significantly higher (and would, thus, affect the mean more)
189 const double meanAmplitude = (sumMean / numFFTDataPoints) + 20.0;
191 // now throw out any bins higher than the mean
193 uint64_t newNumDataPoints = numFFTDataPoints;
194 for(uint64_t number = 0; number < numFFTDataPoints; number++){
195 if (_realFFTDataPoints[number] <= meanAmplitude)
196 sumMean += _realFFTDataPoints[number];
201 if (newNumDataPoints == 0) // in the odd case that all
202 _noiseFloorAmplitude = meanAmplitude; // amplitudes are equal!
204 _noiseFloorAmplitude = sumMean / newNumDataPoints;
207 if(lastOfMultipleUpdatesFlag){
208 int tabindex = SpectrumTypeTab->currentIndex();
209 if(tabindex == d_plot_fft) {
210 _frequencyDisplayPlot->PlotNewData(_averagedValues, numFFTDataPoints,
211 _noiseFloorAmplitude, _peakFrequency,
212 _peakAmplitude, d_update_time);
214 if(tabindex == d_plot_time) {
215 _timeDomainDisplayPlot->PlotNewData(realTimeDomainDataPoints,
216 imagTimeDomainDataPoints,
217 numTimeDomainDataPoints,
220 if(tabindex == d_plot_constellation) {
221 _constellationDisplayPlot->PlotNewData(realTimeDomainDataPoints,
222 imagTimeDomainDataPoints,
223 numTimeDomainDataPoints,
227 // Don't update the repeated data for the waterfall
229 if(tabindex == d_plot_waterfall) {
230 _waterfallDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints,
231 d_update_time, dataTimestamp,
232 spectrumUpdateEvent->getDroppedFFTFrames());
234 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
235 if( _openGLWaterfall3DFlag == 1 && (tabindex == d_plot_waterfall3d)) {
236 _waterfall3DDisplayPlot->PlotNewData(_realFFTDataPoints, numFFTDataPoints,
237 d_update_time, dataTimestamp,
238 spectrumUpdateEvent->getDroppedFFTFrames());
244 // Tell the system the GUI has been updated
245 if(_systemSpecifiedFlag){
246 _system->SetLastGUIUpdateTime(generatedTimestamp);
247 _system->DecrementPendingGUIUpdateEvents();
253 SpectrumDisplayForm::resizeEvent( QResizeEvent *e )
256 s.setWidth(FrequencyPlotDisplayFrame->width());
257 s.setHeight(FrequencyPlotDisplayFrame->height());
258 emit _frequencyDisplayPlot->resizeSlot(&s);
260 s.setWidth(TimeDomainDisplayFrame->width());
261 s.setHeight(TimeDomainDisplayFrame->height());
262 emit _timeDomainDisplayPlot->resizeSlot(&s);
264 s.setWidth(WaterfallPlotDisplayFrame->width());
265 s.setHeight(WaterfallPlotDisplayFrame->height());
266 emit _waterfallDisplayPlot->resizeSlot(&s);
268 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
269 s.setWidth(Waterfall3DPlotDisplayFrame->width());
270 s.setHeight(Waterfall3DPlotDisplayFrame->height());
271 emit _waterfall3DDisplayPlot->resizeSlot(&s);
274 s.setWidth(ConstellationDisplayFrame->width());
275 s.setHeight(ConstellationDisplayFrame->height());
276 emit _constellationDisplayPlot->resizeSlot(&s);
280 SpectrumDisplayForm::customEvent( QEvent * e)
282 if(e->type() == QEvent::User+3){
283 if(_systemSpecifiedFlag){
284 WindowComboBox->setCurrentIndex(_system->GetWindowType());
285 FFTSizeComboBox->setCurrentIndex(_system->GetFFTSizeIndex());
286 //FFTSizeComboBox->setCurrentIndex(1);
289 waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensityWheel->value());
290 waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensityWheel->value());
292 // If the video card doesn't support OpenGL then don't display the 3D Waterfall
293 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
294 waterfall3DMinimumIntensityChangedCB(Waterfall3DMinimumIntensityWheel->value());
295 waterfall3DMaximumIntensityChangedCB(Waterfall3DMaximumIntensityWheel->value());
297 // Check for Hardware Acceleration of the OpenGL
298 if(!_waterfall3DDisplayPlot->format().directRendering()){
299 // Only ask this once while the program is running...
300 if(_openGLWaterfall3DFlag == -1){
301 _openGLWaterfall3DFlag = 0;
302 if(QMessageBox::warning(this, "OpenGL Direct Rendering NOT Supported", "<center>The system's video card hardware or current drivers do not support direct hardware rendering of the OpenGL modules.</center><br><center>Software rendering is VERY processor intensive.</center><br><center>Do you want to use software rendering?</center>", QMessageBox::Yes, QMessageBox::No | QMessageBox::Default | QMessageBox::Escape) == QMessageBox::Yes){
303 _openGLWaterfall3DFlag = 1;
308 _openGLWaterfall3DFlag = 1;
312 if(_openGLWaterfall3DFlag != 1){
313 ToggleTabWaterfall3D(false);
316 // Clear any previous display
319 else if(e->type() == 10005){
320 SpectrumUpdateEvent* spectrumUpdateEvent = (SpectrumUpdateEvent*)e;
321 newFrequencyData(spectrumUpdateEvent);
323 else if(e->type() == 10008){
324 setWindowTitle(((SpectrumWindowCaptionEvent*)e)->getLabel());
326 else if(e->type() == 10009){
328 if(_systemSpecifiedFlag){
329 _system->ResetPendingGUIUpdateEvents();
332 else if(e->type() == 10010){
333 _startFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStartFrequency();
334 _stopFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStopFrequency();
335 _centerFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetCenterFrequency();
337 UseRFFrequenciesCB(UseRFFrequenciesCheckBox->isChecked());
342 SpectrumDisplayForm::UpdateGuiTimer()
344 // This is called by the displayTimer and redraws the canvases of
346 _frequencyDisplayPlot->canvas()->update();
347 _waterfallDisplayPlot->canvas()->update();
348 //if((QGLFormat::hasOpenGL()) && (_useOpenGL))
349 //_waterfall3DDisplayPlot->canvas()->update();
350 _timeDomainDisplayPlot->canvas()->update();
351 _constellationDisplayPlot->canvas()->update();
356 SpectrumDisplayForm::AvgLineEdit_valueChanged( int value )
358 SetAverageCount(value);
363 SpectrumDisplayForm::MaxHoldCheckBox_toggled( bool newState )
365 MaxHoldResetBtn->setEnabled(newState);
366 _frequencyDisplayPlot->SetMaxFFTVisible(newState);
367 MaxHoldResetBtn_clicked();
372 SpectrumDisplayForm::MinHoldCheckBox_toggled( bool newState )
374 MinHoldResetBtn->setEnabled(newState);
375 _frequencyDisplayPlot->SetMinFFTVisible(newState);
376 MinHoldResetBtn_clicked();
381 SpectrumDisplayForm::MinHoldResetBtn_clicked()
383 _frequencyDisplayPlot->ClearMinData();
384 _frequencyDisplayPlot->replot();
389 SpectrumDisplayForm::MaxHoldResetBtn_clicked()
391 _frequencyDisplayPlot->ClearMaxData();
392 _frequencyDisplayPlot->replot();
397 SpectrumDisplayForm::TabChanged(int index)
399 // This might be dangerous to call this with NULL
404 SpectrumDisplayForm::SetFrequencyRange(const double newCenterFrequency,
405 const double newStartFrequency,
406 const double newStopFrequency)
409 if(UseRFFrequenciesCheckBox->isChecked()) {
410 fdiff = newCenterFrequency;
413 fdiff = std::max(fabs(newStartFrequency), fabs(newStopFrequency));
417 std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"};
418 std::string strtime[4] = {"sec", "ms", "us", "ns"};
419 double units10 = floor(log10(fdiff));
420 double units3 = std::max(floor(units10 / 3.0), 0.0);
421 double units = pow(10, (units10-fmod(units10, 3.0)));
422 int iunit = static_cast<int>(units3);
424 _startFrequency = newStartFrequency;
425 _stopFrequency = newStopFrequency;
426 _centerFrequency = newCenterFrequency;
428 _frequencyDisplayPlot->SetFrequencyRange(_startFrequency,
431 UseRFFrequenciesCheckBox->isChecked(),
432 units, strunits[iunit]);
433 _waterfallDisplayPlot->SetFrequencyRange(_startFrequency,
436 UseRFFrequenciesCheckBox->isChecked(),
437 units, strunits[iunit]);
438 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
439 _waterfall3DDisplayPlot->SetFrequencyRange(_startFrequency,
442 UseRFFrequenciesCheckBox->isChecked(),
443 units, strunits[iunit]);
445 _timeDomainDisplayPlot->SetSampleRate(_stopFrequency - _startFrequency,
446 units, strtime[iunit]);
451 SpectrumDisplayForm::GetAverageCount()
453 return _historyVector->size();
457 SpectrumDisplayForm::SetAverageCount(const int newCount)
460 if(newCount != static_cast<int>(_historyVector->size())){
461 std::vector<double*>::iterator pos;
462 while(newCount < static_cast<int>(_historyVector->size())){
463 pos = _historyVector->begin();
465 _historyVector->erase(pos);
468 while(newCount > static_cast<int>(_historyVector->size())){
469 _historyVector->push_back(new double[_numRealDataPoints]);
477 SpectrumDisplayForm::_AverageHistory(const double* newBuffer)
479 if(_numRealDataPoints > 0){
480 if(_historyVector->size() > 0){
481 memcpy(_historyVector->operator[](_historyEntry), newBuffer,
482 _numRealDataPoints*sizeof(double));
484 // Increment the next location to store data
485 _historyEntryCount++;
486 if(_historyEntryCount > static_cast<int>(_historyVector->size())){
487 _historyEntryCount = _historyVector->size();
489 _historyEntry = (++_historyEntry)%_historyVector->size();
491 // Total up and then average the values
493 for(uint64_t location = 0; location < _numRealDataPoints; location++){
495 for(int number = 0; number < _historyEntryCount; number++){
496 sum += _historyVector->operator[](number)[location];
498 _averagedValues[location] = sum/static_cast<double>(_historyEntryCount);
502 memcpy(_averagedValues, newBuffer, _numRealDataPoints*sizeof(double));
508 SpectrumDisplayForm::ResizeBuffers( const uint64_t numFFTDataPoints,
509 const uint64_t /*numTimeDomainDataPoints*/ )
511 // Convert from Complex to Real for certain Displays
512 if(_numRealDataPoints != numFFTDataPoints){
513 _numRealDataPoints = numFFTDataPoints;
514 delete[] _realFFTDataPoints;
515 delete[] _averagedValues;
517 _realFFTDataPoints = new double[_numRealDataPoints];
518 _averagedValues = new double[_numRealDataPoints];
519 memset(_realFFTDataPoints, 0x0, _numRealDataPoints*sizeof(double));
521 const int historySize = _historyVector->size();
522 SetAverageCount(0); // Clear the existing history
523 SetAverageCount(historySize);
530 SpectrumDisplayForm::Reset()
534 _waterfallDisplayPlot->Reset();
535 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
536 _waterfall3DDisplayPlot->Reset();
542 SpectrumDisplayForm::AverageDataReset()
545 _historyEntryCount = 0;
547 memset(_averagedValues, 0x0, _numRealDataPoints*sizeof(double));
549 MaxHoldResetBtn_clicked();
550 MinHoldResetBtn_clicked();
555 SpectrumDisplayForm::closeEvent( QCloseEvent *e )
557 if(_systemSpecifiedFlag){
558 _system->SetWindowOpenFlag(false);
561 qApp->processEvents();
563 QWidget::closeEvent(e);
568 SpectrumDisplayForm::WindowTypeChanged( int newItem )
570 if(_systemSpecifiedFlag){
571 _system->SetWindowType(newItem);
577 SpectrumDisplayForm::UseRFFrequenciesCB( bool useRFFlag )
579 SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency);
584 SpectrumDisplayForm::waterfallMaximumIntensityChangedCB( double newValue )
586 if(newValue > WaterfallMinimumIntensityWheel->value()){
587 WaterfallMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0));
590 WaterfallMaximumIntensityWheel->setValue(WaterfallMinimumIntensityWheel->value());
593 _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(),
594 WaterfallMaximumIntensityWheel->value());
599 SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue )
601 if(newValue < WaterfallMaximumIntensityWheel->value()){
602 WaterfallMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0));
605 WaterfallMinimumIntensityWheel->setValue(WaterfallMaximumIntensityWheel->value());
608 _waterfallDisplayPlot->SetIntensityRange(WaterfallMinimumIntensityWheel->value(),
609 WaterfallMaximumIntensityWheel->value());
613 SpectrumDisplayForm::waterfall3DMaximumIntensityChangedCB( double newValue )
615 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
616 if(newValue > Waterfall3DMinimumIntensityWheel->value()){
617 Waterfall3DMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0));
620 Waterfall3DMaximumIntensityWheel->setValue(Waterfall3DMinimumIntensityWheel->value());
623 _waterfall3DDisplayPlot->SetIntensityRange(Waterfall3DMinimumIntensityWheel->value(),
624 Waterfall3DMaximumIntensityWheel->value());
630 SpectrumDisplayForm::waterfall3DMinimumIntensityChangedCB( double newValue )
632 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
633 if(newValue < Waterfall3DMaximumIntensityWheel->value()){
634 Waterfall3DMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0));
637 Waterfall3DMinimumIntensityWheel->setValue(Waterfall3DMaximumIntensityWheel->value());
640 _waterfall3DDisplayPlot->SetIntensityRange(Waterfall3DMinimumIntensityWheel->value(),
641 Waterfall3DMaximumIntensityWheel->value());
647 SpectrumDisplayForm::FFTComboBoxSelectedCB( const QString &fftSizeString )
649 if(_systemSpecifiedFlag){
650 _system->SetFFTSize(fftSizeString.toLong());
656 SpectrumDisplayForm::WaterfallAutoScaleBtnCB()
658 double minimumIntensity = _noiseFloorAmplitude - 5;
659 if(minimumIntensity < WaterfallMinimumIntensityWheel->minValue()){
660 minimumIntensity = WaterfallMinimumIntensityWheel->minValue();
662 WaterfallMinimumIntensityWheel->setValue(minimumIntensity);
663 double maximumIntensity = _peakAmplitude + 10;
664 if(maximumIntensity > WaterfallMaximumIntensityWheel->maxValue()){
665 maximumIntensity = WaterfallMaximumIntensityWheel->maxValue();
667 WaterfallMaximumIntensityWheel->setValue(maximumIntensity);
668 waterfallMaximumIntensityChangedCB(maximumIntensity);
672 SpectrumDisplayForm::Waterfall3DAutoScaleBtnCB()
674 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
675 double minimumIntensity = _noiseFloorAmplitude - 5;
676 if(minimumIntensity < Waterfall3DMinimumIntensityWheel->minValue()){
677 minimumIntensity = Waterfall3DMinimumIntensityWheel->minValue();
679 Waterfall3DMinimumIntensityWheel->setValue(minimumIntensity);
680 double maximumIntensity = _peakAmplitude + 10;
681 if(maximumIntensity > Waterfall3DMaximumIntensityWheel->maxValue()){
682 maximumIntensity = Waterfall3DMaximumIntensityWheel->maxValue();
684 Waterfall3DMaximumIntensityWheel->setValue(maximumIntensity);
685 waterfallMaximumIntensityChangedCB(maximumIntensity);
690 SpectrumDisplayForm::WaterfallIntensityColorTypeChanged( int newType )
692 QColor lowIntensityColor;
693 QColor highIntensityColor;
694 if(newType == WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED){
695 // Select the Low Intensity Color
696 lowIntensityColor = _waterfallDisplayPlot->GetUserDefinedLowIntensityColor();
697 if(!lowIntensityColor.isValid()){
698 lowIntensityColor = Qt::black;
700 QMessageBox::information(this, "Low Intensity Color Selection", "In the next window, select the low intensity color for the waterfall display", QMessageBox::Ok);
701 lowIntensityColor = QColorDialog::getColor(lowIntensityColor, this);
703 // Select the High Intensity Color
704 highIntensityColor = _waterfallDisplayPlot->GetUserDefinedHighIntensityColor();
705 if(!highIntensityColor.isValid()){
706 highIntensityColor = Qt::white;
708 QMessageBox::information(this, "High Intensity Color Selection", "In the next window, select the high intensity color for the waterfall display", QMessageBox::Ok);
709 highIntensityColor = QColorDialog::getColor(highIntensityColor, this);
712 _waterfallDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor, highIntensityColor);
716 SpectrumDisplayForm::Waterfall3DIntensityColorTypeChanged( int newType )
718 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
719 QColor lowIntensityColor;
720 QColor highIntensityColor;
721 if(newType == Waterfall3DDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED){
722 // Select the Low Intensity Color
723 lowIntensityColor = _waterfallDisplayPlot->GetUserDefinedLowIntensityColor();
724 if(!lowIntensityColor.isValid()){
725 lowIntensityColor = Qt::black;
727 QMessageBox::information(this, "Low Intensity Color Selection", "In the next window, select the low intensity color for the waterfall display", QMessageBox::Ok);
728 lowIntensityColor = QColorDialog::getColor(lowIntensityColor, this);
730 // Select the High Intensity Color
731 highIntensityColor = _waterfallDisplayPlot->GetUserDefinedHighIntensityColor();
732 if(!highIntensityColor.isValid()){
733 highIntensityColor = Qt::white;
735 QMessageBox::information(this, "High Intensity Color Selection", "In the next window, select the high intensity color for the waterfall display", QMessageBox::Ok);
736 highIntensityColor = QColorDialog::getColor(highIntensityColor, this);
738 _waterfall3DDisplayPlot->SetIntensityColorMapType(newType, lowIntensityColor,
745 SpectrumDisplayForm::ToggleTabFrequency(const bool state)
748 if(d_plot_fft == -1) {
749 SpectrumTypeTab->addTab(FrequencyPage, "Frequency Display");
750 d_plot_fft = SpectrumTypeTab->count()-1;
754 SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(FrequencyPage));
760 SpectrumDisplayForm::ToggleTabWaterfall(const bool state)
763 if(d_plot_waterfall == -1) {
764 SpectrumTypeTab->addTab(WaterfallPage, "Waterfall Display");
765 d_plot_waterfall = SpectrumTypeTab->count()-1;
769 SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(WaterfallPage));
770 d_plot_waterfall = -1;
775 SpectrumDisplayForm::ToggleTabWaterfall3D(const bool state)
778 if((QGLFormat::hasOpenGL()) && (_useOpenGL)) {
779 if(d_plot_waterfall3d == -1) {
780 SpectrumTypeTab->addTab(Waterfall3DPage, "3D Waterfall Display");
781 d_plot_waterfall3d = SpectrumTypeTab->count()-1;
786 SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(Waterfall3DPage));
787 d_plot_waterfall3d = -1;
792 SpectrumDisplayForm::ToggleTabTime(const bool state)
795 if(d_plot_time == -1) {
796 SpectrumTypeTab->addTab(TimeDomainPage, "Time Domain Display");
797 d_plot_time = SpectrumTypeTab->count()-1;
801 SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(TimeDomainPage));
807 SpectrumDisplayForm::ToggleTabConstellation(const bool state)
810 if(d_plot_constellation == -1) {
811 SpectrumTypeTab->addTab(ConstellationPage, "Constellation Display");
812 d_plot_constellation = SpectrumTypeTab->count()-1;
816 SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(ConstellationPage));
817 d_plot_constellation = -1;
823 SpectrumDisplayForm::SetTimeDomainAxis(double min, double max)
825 _timeDomainDisplayPlot->set_yaxis(min, max);
829 SpectrumDisplayForm::SetConstellationAxis(double xmin, double xmax,
830 double ymin, double ymax)
832 _constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax);
836 SpectrumDisplayForm::SetConstellationPenSize(int size)
838 _constellationDisplayPlot->set_pen_size( size );
842 SpectrumDisplayForm::SetFrequencyAxis(double min, double max)
844 _frequencyDisplayPlot->set_yaxis(min, max);
848 SpectrumDisplayForm::SetUpdateTime(double t)
851 // QTimer class takes millisecond input
852 displayTimer->start(d_update_time*1000);