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
This commit is contained in:
Joe Taylor 2013-07-25 20:17:27 +00:00
parent 1d166faa23
commit 8eea459960
3 changed files with 27 additions and 45 deletions

View File

@ -9,11 +9,11 @@ CAboutDlg::CAboutDlg(QWidget *parent, QString Revision) :
ui->setupUi(this);
ui->labelTxt->clear();
m_Str = "<html><h2>" + m_Revision + "</h2>\n\n";
m_Str += "WSJT-X implements experimental mode JT9 for <br>";
m_Str += "Amateur Radio communication at HF, MF, and LF. <br><br>";
m_Str += "Copyright 2001-2013 by Joe Taylor, K1JT. Additional <br>";
m_Str += "contributions from AC6SL, AE4JY, G4KLA, K3WYC, PY2SDR, <br>";
m_Str += "and VK4BDJ.<br>";
m_Str += "WSJT-X implements digital modes JT9 and JT65 for <br>";
m_Str += "Amateur Radio communication. <br><br>";
m_Str += "Copyright 2001-2013 by Joe Taylor, K1JT -- with grateful <br>";
m_Str += "acknowledgment for contributions from AC6SL, AE4JY, <br>";
m_Str += "G4KLA, G4WJS, K3WYC, KA6MAL, KA9Q, PY2SDR, and VK4BDJ.<br>";
ui->labelTxt->setText(m_Str);
}

View File

@ -1,4 +1,4 @@
//------------------------------------------------------------- MainWindow
//-------------------------------------------------------------- MainWindow
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "devsetup.h"

View File

@ -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
}
}