From 336f8672760cc7f17496975b460f9ef5dbb941b8 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 25 Jul 2013 20:17:27 +0000 Subject: [PATCH] Cleanup of palette-selection code. Provide an error message if selected palette file is not found. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3505 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- about.cpp | 10 ++++----- mainwindow.cpp | 2 +- plotter.cpp | 60 ++++++++++++++++++-------------------------------- 3 files changed, 27 insertions(+), 45 deletions(-) diff --git a/about.cpp b/about.cpp index 5cab294c3..59deec323 100644 --- a/about.cpp +++ b/about.cpp @@ -9,11 +9,11 @@ CAboutDlg::CAboutDlg(QWidget *parent, QString Revision) : ui->setupUi(this); ui->labelTxt->clear(); m_Str = "

" + m_Revision + "

\n\n"; - m_Str += "WSJT-X implements experimental mode JT9 for
"; - m_Str += "Amateur Radio communication at HF, MF, and LF.

"; - m_Str += "Copyright 2001-2013 by Joe Taylor, K1JT. Additional
"; - m_Str += "contributions from AC6SL, AE4JY, G4KLA, K3WYC, PY2SDR,
"; - m_Str += "and VK4BDJ.
"; + m_Str += "WSJT-X implements digital modes JT9 and JT65 for
"; + m_Str += "Amateur Radio communication.

"; + m_Str += "Copyright 2001-2013 by Joe Taylor, K1JT -- with grateful
"; + m_Str += "acknowledgment for contributions from AC6SL, AE4JY,
"; + m_Str += "G4KLA, G4WJS, K3WYC, KA6MAL, KA9Q, PY2SDR, and VK4BDJ.
"; ui->labelTxt->setText(m_Str); } diff --git a/mainwindow.cpp b/mainwindow.cpp index c0c5c3bc6..76b3be028 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,4 +1,4 @@ -//------------------------------------------------------------- MainWindow +//-------------------------------------------------------------- MainWindow #include "mainwindow.h" #include "ui_mainwindow.h" #include "devsetup.h" diff --git a/plotter.cpp b/plotter.cpp index db93de0c9..360861f9c 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -466,7 +466,7 @@ void CPlotter::setPalette(QString palette) //setPalette() m_ColorTbl[i].setRgb(int(255.0*r),int(255.0*g),int(255.0*b)); } m_ColorTbl[255].setRgb(255,255,100); - + return; } if(palette=="CuteSDR") { @@ -485,48 +485,30 @@ void CPlotter::setPalette(QString palette) //setPalette() m_ColorTbl[i].setRgb( 255, 0, 128*(i-217)/38); } m_ColorTbl[255].setRgb(255,255,100); + return; } - if(palette=="Blue") { - FILE* fp=fopen("blue.dat","r"); - int n,r,g,b; - float xr,xg,xb; - for(int i=0; i<256; i++) { - int nn=fscanf(fp,"%d%f%f%f",&n,&xr,&xg,&xb); - r=255.0*xr + 0.5; - g=255.0*xg + 0.5; - b=255.0*xb + 0.5; - m_ColorTbl[i].setRgb(r,g,b); - if(nn==-999999) i++; //Silence compiler warning - } + FILE* fp; + if(palette=="Blue") fp=fopen("blue.dat","r"); + if(palette=="AFMHot") fp=fopen("afmhot.dat","r"); + if(palette=="Gray1") fp=fopen("gray1.dat","r"); + if(int(fp)==0) { + QMessageBox msgBox0; + QString t="Error: Cannot find requested palette file."; + msgBox0.setText(t); + msgBox0.exec(); + return; } - if(palette=="AFMHot") { - FILE* fp=fopen("afmhot.dat","r"); - int n,r,g,b; - float xr,xg,xb; - for(int i=0; i<256; i++) { - int nn=fscanf(fp,"%d%f%f%f",&n,&xr,&xg,&xb); - r=255.0*xr + 0.5; - g=255.0*xg + 0.5; - b=255.0*xb + 0.5; - m_ColorTbl[i].setRgb(r,g,b); - if(nn==-999999) i++; //Silence compiler warning - } - } - - if(palette=="Gray1") { - FILE* fp=fopen("gray1.dat","r"); - int n,r,g,b; - float xr,xg,xb; - for(int i=0; i<256; i++) { - int nn=fscanf(fp,"%d%f%f%f",&n,&xr,&xg,&xb); - r=255.0*xr + 0.5; - g=255.0*xg + 0.5; - b=255.0*xb + 0.5; - m_ColorTbl[i].setRgb(r,g,b); - if(nn==-999999) i++; //Silence compiler warning - } + int n,r,g,b; + float xr,xg,xb; + for(int i=0; i<256; i++) { + int nn=fscanf(fp,"%d%f%f%f",&n,&xr,&xg,&xb); + r=255.0*xr + 0.5; + g=255.0*xg + 0.5; + b=255.0*xb + 0.5; + m_ColorTbl[i].setRgb(r,g,b); + if(nn==-999999) i++; //Silence compiler warning } }