1
/***************************************************************************
2
cdisplay.cpp - description
4
begin : Sat Mar 18 2000
5
copyright : (C) 2000 by Volker Schroer
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* based on the work of Moe Wheatly, AE4JY *
16
***************************************************************************/
22
CDisplay::CDisplay(QWidget *parent, const char *name ): QFrame(parent,name)
27
setBackgroundColor(white);
28
setFrameStyle(QFrame::Box | QFrame::Raised);
34
from=int((minfreq*1024)/2756.25);
35
to=int((maxfreq*1024)/2756.25);
38
for (int i=0; i<4;i++)
52
void CDisplay::paintEvent(QPaintEvent *)
69
gain=double(0.1*height());
70
plotspectrum(fft.CalcFFT(inputdata,from,to,gain,ave,fftdata));
78
plotwaterfall(fft.CalcFFT(inputdata,from,to,gain,ave,fftdata));
90
void CDisplay::mousePressEvent(QMouseEvent *e)
98
case SPECTRUM: //Changing frequency only if frequency is displayed
100
freq= (e->x()*(maxfreq-minfreq))/width()+minfreq;
102
if (freq != rxfrequency[settings.actChannel])
104
rxfrequency[settings.actChannel]=freq;
105
emit rxFreqChanged(freq);
113
void CDisplay::plotrawinput()
133
p.drawLine(0,y,xmax,y);
142
z=int(*(inputdata+i));
145
if( (z > 16384) || (z < -16384) )
156
bitBlt(this,0,0,pdisplay);
158
// Plot Spectrum of decimated Input
159
void CDisplay::plotspectrum(bool overload)
176
//Plot Frequencylines for the different Rx- Windows
177
for (i=0; i<settings.RxChannels;i++)
179
p.setPen(settings.colours[i]);
180
// Calculate Centerfrequency Coordinates
181
z=((rxfrequency[i]-minfreq)*xmax)/(maxfreq-minfreq);
182
p.drawLine(z,0,z,ymax);
184
if ( settings.DemodulatorType[i] == RTTY ) // RTTY demands to lines
186
z=((rxfrequency[i]-minfreq+170)*xmax)/(maxfreq-minfreq);
187
p.drawLine(z,0,z,ymax);
196
p.drawLine(0,y,xmax,y);
200
if ( (settings.status == TX_OFF_STATE) && (modus != RTTY) )
216
bitBlt(this,0,0,pdisplay);
219
void CDisplay::selecttab(int tab)
227
void CDisplay::scaleminfreq(int freq)
233
void CDisplay::scalemaxfreq(int freq)
239
void CDisplay::filtertype(bool type)
244
void CDisplay::translate(void)
247
from=int(minfreq*1024/2756.25);
248
to=int(maxfreq*1024/2756.25);
249
for (i=0;i<width();i++)
250
xtranslate[i]=(((maxfreq-minfreq)*i*to/width())+minfreq*to)/maxfreq;
253
/** plots the filtered signal vector
254
to recognize phase of signal */
255
void CDisplay::plotVector(QPainter *p)
266
p->drawEllipse(xc,yc,40,40);
270
for( x=196,y=0; x<10*196; y+=196, x+=196 )// 196 = (612.5/31.25)*10
274
tmpx =vector[y1].real() * vector[x1].real() +
275
vector[y1].imag() * vector[x1].imag();
276
tmpy = vector[y1].imag() * vector[x1].real() -
277
vector[y1].real() * vector[x1].imag();
279
mag = 2*sqrt(tmpx * tmpx + tmpy * tmpy);
281
p->lineTo( xc+(int)(yc*tmpy/mag), yc-(int)(yc*tmpx/mag) );
287
/*void CDisplay::PlotSyncData()
301
for( x=k2/2,i=0; i<20; i++,x+=k2)
303
ys = m_SyncHist[i]/k1;
306
p.lineTo( x, ymax-ys );
309
bitBlt(this,0,0,pdisplay);
312
void CDisplay::plotwaterfall(bool overload)
323
for (i=0; i<settings.RxChannels;i++)
325
// Calculate Centerfrequency Coordinates
326
z=((rxfrequency[i]-minfreq)*xmax)/(maxfreq-minfreq);
327
p.setPen(settings.colours[i]);
328
p.drawLine(z,2,z,ymax);
329
if ( settings.DemodulatorType[i] == RTTY ) // RTTY demands to lines
331
z=((rxfrequency[i]-minfreq+170)*xmax)/(maxfreq-minfreq);
332
p.drawLine(z,2,z,ymax);
337
if ( (settings.status == TX_OFF_STATE) && (modus != RTTY) )
341
bitBlt(pwaterfall,0,2,pwaterfall);
353
bitBlt(pdisplay,0,100,pwaterfall);
354
bitBlt(this,0,0,pdisplay);
357
void CDisplay::resizeEvent(QResizeEvent *)
362
translate(); // Translate x- Coordinates for Painting
364
pdisplay->resize(xmax,ymax);
366
pdisplay = new QPixmap(xmax,ymax);
372
pwaterfall->resize(xmax,40);
374
pwaterfall= new QPixmap(xmax,40);
378
void CDisplay::setRxFrequency(int channelNumber,int freq)
380
rxfrequency[channelNumber] = freq;
384
void CDisplay::newPhaseValue(int j,float_complex z)
390
/** Paints a Lineal in the Spectrum or Waterfall Display */
392
/*void CDisplay::paintLineal(QPainter* p)
395
int stepfrequency,stepwidth;
398
QFontMetrics fm(settings.font);
400
stepfrequency=(maxfreq-minfreq)/7;
404
for( i=1; i < 7; i++)
406
frequency.setNum(minfreq+stepfrequency*i);
407
ix=i*stepwidth-fm.width(frequency)/2;
408
p->drawText(ix,iy,frequency);
410
p->drawLine(ix,iy,ix,iy+5);
415
/** Calculates the IMD Value of the Signal */
416
float CDisplay::calcIMD()
420
total=fftdata[int((rxfrequency[settings.actChannel]+46.875)*1024./2756.25)]
421
-fftdata[int((rxfrequency[settings.actChannel]+15.625)*1024./2756.25)];
423
ratio=fftdata[int((rxfrequency[settings.actChannel]-46.875)*1024./2756.25)]
424
-fftdata[int((rxfrequency[settings.actChannel]-15.625)*1024./2756.25)];
425
total=(total+ratio)/2;
429
void CDisplay::setMode(Mode mod)