@@ -142,7 +142,7 @@ MainWindow::MainWindow(QWidget *parent)
142142 satellitesAzimuth[i][j] = satellitesElevation[i][j] = 0.0 ;
143143 for (int k = 0 ; k < NFREQ ; k++) {
144144 validSatellites[i][j][k] = 0 ;
145- satellitesSNR[i][j][k] = 0 ;
145+ satellitesSNR[i][j][k] = 0.0 ;
146146 }
147147 }
148148
@@ -1664,7 +1664,8 @@ void MainWindow::drawSolutionPlot(QLabel *plot, int type, int freq)
16641664
16651665 int w = buffer.size ().width () - 2 ;
16661666 int h = buffer.height () - 2 ;
1667- int i, j, x, sat[2 ][MAXSAT ], ns[2 ], snr[2 ][MAXSAT ][NFREQ ], vsat[2 ][MAXSAT ][NFREQ ];
1667+ int i, j, x, sat[2 ][MAXSAT ], ns[2 ], vsat[2 ][MAXSAT ][NFREQ ];
1668+ double snr[2 ][MAXSAT ][NFREQ ];
16681669 int topMargin = QFontMetrics (optDialog->panelFont ).height ()*3 /2 ;
16691670 double az[2 ][MAXSAT ], el[2 ][MAXSAT ], rr[3 ], pos[3 ];
16701671
@@ -1698,7 +1699,7 @@ void MainWindow::drawSolutionPlot(QLabel *plot, int type, int freq)
16981699 for (j = 0 ; j < numSatellites[i]; j++) {
16991700 for (int k = 0 ; k < NFREQ ; k++) {
17001701 validSatellites[i][j][k] = 0 ;
1701- satellitesSNR[i][j][k] = 0 ;
1702+ satellitesSNR[i][j][k] = 0.0 ;
17021703 }
17031704 }
17041705 }
@@ -1780,17 +1781,17 @@ void MainWindow::updatePlot()
17801781 }
17811782}
17821783// snr color ----------------------------------------------------------------
1783- QColor MainWindow::snrColor (int snr)
1784+ QColor MainWindow::snrColor (double snr)
17841785{
17851786 QColor color[] = {Qt::darkGreen, Color::Orange, Color::Fuchsia, Qt::blue, Qt::red, Qt::darkGray};
17861787 uint32_t r1, g1, b1;
17871788 QColor c1, c2;
17881789 double a;
17891790 int i;
17901791
1791- if (snr < 25 ) return color[5 ];
1792- if (snr < 27 ) return color[4 ];
1793- if (snr > 47 ) return color[0 ];
1792+ if (snr < 25.0 ) return color[5 ];
1793+ if (snr < 27.0 ) return color[4 ];
1794+ if (snr > 47.0 ) return color[0 ];
17941795 a = (snr - 27.5 ) / 5.0 ;
17951796 i = static_cast <int >(a);
17961797 a -= i;
@@ -1812,7 +1813,8 @@ void MainWindow::drawSnr(QPainter &c, int w, int h, int x0, int y0,
18121813 QColor (128 , 128 , 128 )
18131814 };
18141815 static const QColor color_sys[] = {Qt::darkGreen, Color::Orange, Color::Fuchsia, Qt::blue, Qt::red, Color::Teal, Qt::darkGray};
1815- int i, j, snrIdx, sysIdx, numSystems, x1, y1, height, offset, topMargin, bottomMargin, hh, barDistance, barWidth, snr[NFREQ + 1 ], sysMask[7 ] = {0 };
1816+ int i, j, snrIdx, sysIdx, numSystems, x1, y1, height, offset, topMargin, bottomMargin, hh, barDistance, barWidth, sysMask[7 ] = {0 };
1817+ double snr[NFREQ + 1 ];
18161818 char id[8 ], sys[] = " GREJCS" , *q;
18171819
18181820 trace (4 , " drawSnr: w=%d h=%d x0=%d y0=%d index=%d freq=%d\n " , w, h, x0, y0, index, freq);
@@ -1828,7 +1830,7 @@ void MainWindow::drawSnr(QPainter &c, int w, int h, int x0, int y0,
18281830 for (snr[0 ] = MINSNR + 10 ; snr[0 ] < MAXSNR ; snr[0 ] += 10 ) {
18291831 y1 = y0 + hh - (snr[0 ] - MINSNR ) * hh / (MAXSNR - MINSNR );
18301832 c.drawLine (x0 + 2 , y1, x0 + w - 20 , y1);
1831- drawText (c, x0 + w - 4 , y1, QLocale (). toString (snr[0 ]), Qt::darkGray, 2 , 0 );
1833+ drawText (c, x0 + w - 4 , y1, QString::number ( qRound (snr[0 ]) ), Qt::darkGray, 2 , 0 );
18321834 }
18331835
18341836 // draw outer box
@@ -1846,15 +1848,16 @@ void MainWindow::drawSnr(QPainter &c, int w, int h, int x0, int y0,
18461848 satno2id (satellites[index][i], id);
18471849 sysIdx = (q = strchr (sys, id[0 ])) ? (int )(q - sys) : 6 ;
18481850
1849- for (j = snr[0 ] = 0 ; j < NFREQ ; j++) {
1851+ snr[0 ] = 0.0 ;
1852+ for (j = 0 ; j < NFREQ ; j++) {
18501853 snr[j + 1 ] = satellitesSNR[index][i][j];
18511854 if ((freq && freq == j + 1 ) || ((!freq || freq > NFREQ ) && snr[j + 1 ] > snr[0 ]))
18521855 snr[0 ] = snr[j + 1 ]; // store max snr
18531856 }
18541857 for (j = 0 ; j < NFREQ + 2 ; j++) {
18551858 snrIdx = j < NFREQ + 1 ? j : 0 ;
18561859 offset = j < NFREQ + 1 ? 0 : 2 ;
1857- if (snr[snrIdx] > 0 ) height = (snr[snrIdx] - MINSNR ) * hh / (MAXSNR - MINSNR );
1860+ if (snr[snrIdx] > 0 ) height = (int ) round (( snr[snrIdx] - MINSNR ) * hh / (MAXSNR - MINSNR ) );
18581861 else height = offset;
18591862 height = height > y1 - 2 ? y1 - 2 : (height < 0 ? 0 : height); // limit bar from going negative or too high
18601863
@@ -1896,7 +1899,8 @@ void MainWindow::drawSatellites(QPainter &c, int w, int h, int x0, int y0,
18961899 QColor color_text;
18971900 QPoint p (w / 2 , h / 2 );
18981901 double r = qMin (w * 0.95 , h * 0.95 ) / 2 , azel[MAXSAT * 2 ], dop[4 ];
1899- int i, j, k, sysIdx, radius, x[MAXSAT ], y[MAXSAT ], snr[NFREQ + 1 ], nsats = 0 ;
1902+ int i, j, k, sysIdx, radius, x[MAXSAT ], y[MAXSAT ], nsats = 0 ;
1903+ double snr[NFREQ + 1 ];
19001904 char id[8 ], sys[] = " GREJCIS" , *q;
19011905
19021906 trace (4 , " drawSatellites: w=%d h=%d index=%d freq=%d\n " , w, h, index, freq);
@@ -1906,7 +1910,8 @@ void MainWindow::drawSatellites(QPainter &c, int w, int h, int x0, int y0,
19061910 // draw satellites
19071911 for (i = 0 , k = numSatellites[index] - 1 ; i < numSatellites[index] && i < MAXSAT ; i++, k--) {
19081912 if (satellitesElevation[index][k] <= 0.0 ) continue ;
1909- for (j = snr[0 ] = 0 ; j < NFREQ ; j++) {
1913+ snr[0 ] = 0.0 ;
1914+ for (j = 0 ; j < NFREQ ; j++) {
19101915 snr[j + 1 ] = satellitesSNR[index][k][j];
19111916 if ((freq && freq == j + 1 ) || ((!freq || freq > NFREQ ) && snr[j + 1 ] > snr[0 ])) {
19121917 snr[0 ] = snr[j + 1 ]; // max snr
@@ -1915,7 +1920,7 @@ void MainWindow::drawSatellites(QPainter &c, int w, int h, int x0, int y0,
19151920 int anyValidSatFreq = 0 ;
19161921 for (int fi = 0 ; fi < NFREQ ; fi++)
19171922 if (validSatellites[index][k][fi]) { anyValidSatFreq = 1 ; break ; }
1918- if (anyValidSatFreq && (freq > NFREQ || snr[freq] > 0 )) {
1923+ if (anyValidSatFreq && (freq > NFREQ || snr[freq] > 0.0 )) {
19191924 azel[nsats * 2 ] = satellitesAzimuth[index][k];
19201925 azel[nsats * 2 + 1 ] = satellitesElevation[index][k];
19211926 nsats++;
@@ -1930,7 +1935,7 @@ void MainWindow::drawSatellites(QPainter &c, int w, int h, int x0, int y0,
19301935 (freq < NFREQ + 1 ? snrColor (snr[freq]) : color_sys[sysIdx]));
19311936 c.setPen (Qt::darkGray);
19321937 color_text = Qt::white;
1933- if (freq < NFREQ + 1 && snr[freq] <= 0 ) {
1938+ if (freq < NFREQ + 1 && snr[freq] <= 0.0 ) {
19341939 c.setPen (Color::Silver);
19351940 color_text = Color::Silver;
19361941 }
0 commit comments