diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 73fe865..1d112fd 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -62,9 +62,6 @@ set(PROJECT_SOURCES_CPP segmentlistviirsm.cpp poi.cpp equirectangular.cpp - infrascales.cpp - infrawidget.cpp - forminfrascales.cpp qcustomplot.cpp segmentlistolci.cpp segmentolci.cpp diff --git a/core/avhrrsatellite.cpp b/core/avhrrsatellite.cpp index 3345eb6..5e21df4 100644 --- a/core/avhrrsatellite.cpp +++ b/core/avhrrsatellite.cpp @@ -442,45 +442,47 @@ void AVHRRSatellite::AddSegmentsToList(QFileInfoList fileinfolist) // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N__T_0070_0001.nc //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N__T_0070_0041.nc - //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N_JLS_T_0070_0001 + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N_JLS_T_0070_0001.nc //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N_JLS_T_0070_0041.nc for(int i = 0; i < opts.geosatellites.count(); i++) { //qDebug() << fileInfo.fileName().mid( opts.geosatellites.at(i).indexsearchstring, opts.geosatellites.at(i).searchstring.length() ) << "???" << opts.geosatellites.at(i).searchstring; //qDebug() << opts.geosatellites.at(i).fullname; - if(opts.geosatellites.at(i).shortname == "MTG-I1") + if(fileInfo.fileName().mid( opts.geosatellites.at(i).indexsearchstring, opts.geosatellites.at(i).searchstring.length()) == "W_XX") { QString strdate; int filenbr, seqnbr; - getFilenameParametersMTGI1(fileInfo.fileName(), strdate, filenbr, seqnbr); + getFilenameParametersMTGI1(fileInfo.fileName(), &strdate, &filenbr, &seqnbr); seglgeo.at(i)->setImagePath(fileInfo.absolutePath()); QMap hashseqnbr; - QMap > hashfilenbr; + //QMap > hashfilenbr; - if (segmentlistmapgeomtgi1.contains(strdate)) + if (segmentlistmapgeomtgi1.contains(filenbr)) { - hashfilenbr = segmentlistmapgeomtgi1.value(strdate); - if(hashfilenbr.contains(filenbr)) - hashseqnbr = hashfilenbr.value(filenbr); + hashseqnbr = segmentlistmapgeomtgi1.value(filenbr); + hashseqnbr.insert(seqnbr, fileInfo); + segmentlistmapgeomtgi1.insert(filenbr, hashseqnbr); } - hashseqnbr.insert( seqnbr, fileInfo ); - hashfilenbr.insert(filenbr, hashseqnbr); - segmentlistmapgeomtgi1.insert( strdate, hashfilenbr ); - - + else + { + hashseqnbr.insert( seqnbr, fileInfo ); + segmentlistmapgeomtgi1.insert(filenbr, hashseqnbr); + } + //qDebug() << "A" << opts.geosatellites.at(i).shortname << " " << fileInfo.absoluteFilePath() << " " << strdate << " " << QString("%1").arg(seqnbr) << QString("%1").arg(filenbr); } - else if (fileInfo.fileName().mid( opts.geosatellites.at(i).indexsearchstring, opts.geosatellites.at(i).searchstring.length()) == opts.geosatellites.at(i).searchstring && fileInfo.isFile()) + else if((fileInfo.fileName().mid( opts.geosatellites.at(i).indexsearchstring, opts.geosatellites.at(i).searchstring.length()) + == opts.geosatellites.at(i).searchstring) && fileInfo.isFile()) { //int filenbr = fileInfo.fileName().mid(opts.geosatellites.at(i).indexfilenbrstring, opts.geosatellites.at(i).lengthfilenbrstring).toInt(); //QString strspectrum = fileInfo.fileName().mid(opts.geosatellites.at(i).indexspectrumstring, opts.geosatellites.at(i).lengthspectrumstring); QString strspectrum; QString strdate; int filenbr; - getFilenameParameters(i, fileInfo.fileName(), strspectrum, strdate, filenbr); + getFilenameParameters(i, fileInfo.fileName(), &strspectrum, &strdate, &filenbr); if (strspectrum != "___") { @@ -505,7 +507,7 @@ void AVHRRSatellite::AddSegmentsToList(QFileInfoList fileinfolist) segmentlistmapgeo[i].insert( strdate, hashspectrum ); } } - //qDebug() << opts.geosatellites.at(i).shortname << " " << fileInfo.absoluteFilePath() << " " << strdate << " " << strspectrum << " " << QString("%1").arg(filenbr); + //qDebug() << "B" << opts.geosatellites.at(i).shortname << " " << fileInfo.absoluteFilePath() << " " << strdate << " " << strspectrum << " " << QString("%1").arg(filenbr); } } @@ -516,42 +518,65 @@ void AVHRRSatellite::AddSegmentsToList(QFileInfoList fileinfolist) } } -void AVHRRSatellite::getFilenameParametersMTGI1(QString filename, QString &strdate, int &filenbr, int &seqnbr) +void AVHRRSatellite::getFilenameParametersMTGI1(QString filename, QString *strdate, int *filenbr, int *seqnbr) { //MTG-I1 //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N__T_0070_0001.nc //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N__T_0070_0041.nc - //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N_JLS_T_0070_0001 + + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N_JLS_T_0070_0001.nc //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N_JLS_T_0070_0041.nc - if(filename.contains("BODY", Qt::CaseSensitive)) + if(filename.contains("JLS", Qt::CaseSensitive)) { - strdate = filename.mid(82, 6); - filenbr = filename.mid(140, 4).toInt(); - seqnbr = filename.mid(145, 4).toInt(); - } - else if(filename.contains("TRAIL", Qt::CaseSensitive)) + if(filename.contains("BODY", Qt::CaseSensitive)) + { + *strdate = filename.mid(105, 12); + *filenbr = filename.mid(143, 4).toInt(); + *seqnbr = filename.mid(148, 4).toInt(); + } + else if(filename.contains("TRAIL", Qt::CaseSensitive)) + { + *strdate = filename.mid(106, 12); + *filenbr = filename.mid(144, 4).toInt(); + *seqnbr = filename.mid(149, 4).toInt(); + } + } else { - strdate = filename.mid(83, 6); - filenbr = filename.mid(141, 4).toInt(); - seqnbr = filename.mid(146, 4).toInt(); + if(filename.contains("BODY", Qt::CaseSensitive)) + { + *strdate = filename.mid(105, 12); + *filenbr = filename.mid(140, 4).toInt(); + *seqnbr = filename.mid(145, 4).toInt(); + } + else if(filename.contains("TRAIL", Qt::CaseSensitive)) + { + *strdate = filename.mid(106, 12); + *filenbr = filename.mid(141, 4).toInt(); + *seqnbr = filename.mid(146, 4).toInt(); + } + } } -void AVHRRSatellite::getFilenameParameters(int geosatindex, QString filename, QString &strspectrum, QString &strdate, int &filenbr) +void AVHRRSatellite::getFilenameParameters(int geosatindex, QString filename, QString *strspectrum, QString *strdate, int *filenbr) { QString filespectrum = filename.mid(opts.geosatellites.at(geosatindex).indexspectrumhrv, opts.geosatellites.at(geosatindex).spectrumhrv.length()); if(filespectrum != "" && filespectrum == opts.geosatellites.at(geosatindex).spectrumhrv) { - strspectrum = opts.geosatellites.at(geosatindex).spectrumhrv; + *strspectrum = opts.geosatellites.at(geosatindex).spectrumhrv; int ifl = opts.geosatellites.at(geosatindex).indexfilenbrhrv; int lfl = opts.geosatellites.at(geosatindex).lengthfilenbrhrv; - filenbr = filename.mid(ifl, lfl).toInt(); + *filenbr = filename.mid(ifl, lfl).toInt(); int idl = opts.geosatellites.at(geosatindex).indexdatehrv; int ldl = opts.geosatellites.at(geosatindex).lengthdatehrv; - strdate = filename.mid(idl, ldl); + *strdate = filename.mid(idl, ldl); return; } else @@ -564,35 +589,35 @@ void AVHRRSatellite::getFilenameParameters(int geosatindex, QString filename, Q { if(spectrum == filespectrum) { - strspectrum = spectrum; - filenbr = filename.mid(opts.geosatellites.at(geosatindex).indexfilenbr, opts.geosatellites.at(geosatindex).lengthfilenbr).toInt(); - strdate = filename.mid(opts.geosatellites.at(geosatindex).indexdate, opts.geosatellites.at(geosatindex).lengthdate); + *strspectrum = spectrum; + *filenbr = filename.mid(opts.geosatellites.at(geosatindex).indexfilenbr, opts.geosatellites.at(geosatindex).lengthfilenbr).toInt(); + *strdate = filename.mid(opts.geosatellites.at(geosatindex).indexdate, opts.geosatellites.at(geosatindex).lengthdate); if( opts.geosatellites.at(geosatindex).shortname == "GOES_16" || opts.geosatellites.at(geosatindex).shortname == "GOES_17" || opts.geosatellites.at(geosatindex).shortname == "GOES_18" ) //convert YYYYDDDHHmm to YYYYMMDDHHmm { - QDate fdate = QDate(strdate.mid(0, 4).toInt(), 1, 1).addDays(strdate.mid(4, 3).toInt() - 1); - strdate = fdate.toString("yyyyMMdd") + strdate.mid(7, 4); + QDate fdate = QDate(strdate->mid(0, 4).toInt(), 1, 1).addDays(strdate->mid(4, 3).toInt() - 1); + *strdate = fdate.toString("yyyyMMdd") + strdate->mid(7, 4); } - if(strdate.length() < 12) + if(strdate->length() < 12) { - QString temp = strdate.leftJustified(12, '0'); - strdate = temp; + QString temp = (*strdate).leftJustified(12, '0'); + *strdate = temp; } return; } } else { - strspectrum = "___"; - strdate = ""; - filenbr = 0; + *strspectrum = "___"; + *strdate = ""; + *filenbr = 0; return; } } } - strspectrum = "XXX"; - strdate = "123456789012"; - filenbr = 0; + *strspectrum = "XXX"; + *strdate = "123456789012"; + *filenbr = 0; } void AVHRRSatellite::setAbsolutePathFromMap(int geoindex, QString strdate) @@ -623,6 +648,8 @@ void AVHRRSatellite::ReadDirectories(QDate seldate, int hoursbefore) qDebug() << QString("in AVHRRSatellite:ReadDirectories(QDate, int) hoursbefore = %1").arg(hoursbefore); + this->selectiondate = seldate; + QApplication::setOverrideCursor( Qt::WaitCursor ); // this might take time QList *slnoaa = seglnoaa->GetSegmentlistptr(); @@ -679,6 +706,8 @@ void AVHRRSatellite::ReadDirectories(QDate seldate, int hoursbefore) segmentlistmapgeo[i].clear(); } + segmentlistmapgeomtgi1.clear(); + qDebug() << QString("End clearing segments"); @@ -774,6 +803,8 @@ void AVHRRSatellite::ReadDirectories(QDate seldate, int hoursbefore) } qDebug() << QString("fileinfolist.size = %1 in subdir %2").arg(fileinfolist.size()).arg(*its); + //for(int i= 0; i < fileinfolist.size(); i++) + // qDebug() << "list = " << fileinfolist.at(i).absoluteFilePath(); QString yeardir = seldate.toString("yyyyMMdd").mid(0, 4); QString monthdir = seldate.toString("yyyyMMdd").mid(4, 2); @@ -789,8 +820,6 @@ void AVHRRSatellite::ReadDirectories(QDate seldate, int hoursbefore) qDebug() << QString("fileinfolist.size = %1 in subdir %2").arg(fileinfolist.size()).arg(thepathYYYYMMDD); } - //for(int i= 0; i < fileinfolist.size(); i++) - // qDebug() << "list = " << fileinfolist.at(i).absoluteFilePath(); QMap map; @@ -884,7 +913,7 @@ void AVHRRSatellite::ReadDirectories(QDate seldate, int hoursbefore) datebefore.setDate(datebefore.date().addDays(-1)); QString pathbefore = (*its) + "/" + datebefore.toString( "yyyyMMdd").mid(0, 4) + - "/" + datebefore.toString( "yyyyMMdd").mid(4, 2) + "/" + datebefore.toString( "yyyyMMdd").mid(6, 2); + "/" + datebefore.toString( "yyyyMMdd").mid(4, 2) + "/" + datebefore.toString( "yyyyMMdd").mid(6, 2); qDebug() << QString("pathbefore = %1").arg(pathbefore); if(segmentdir.cd( pathbefore )) @@ -1536,17 +1565,21 @@ void AVHRRSatellite::InsertToMap(QFileInfoList fileinfolist, QMap= 24 - hoursbefore) fileok = true; + //qDebug() << fileinfo.fileName() << " ok = " << fileok << " " << "d = " << d << "seldate = " << seldate; + } else if(fileinfo.fileName().contains("TRAIL", Qt::CaseInsensitive)) { - QDate d(fileinfo.fileName().mid( 83, 4).toInt(), fileinfo.fileName().mid( 87, 2).toInt(), fileinfo.fileName().mid( 89, 2).toInt()); + QDate d(fileinfo.fileName().mid( 106, 4).toInt(), fileinfo.fileName().mid( 110, 2).toInt(), fileinfo.fileName().mid( 112, 2).toInt()); //filedate.setDate(d); - QTime t(fileinfo.fileName().mid( 91, 2).toInt(), fileinfo.fileName().mid( 93, 2).toInt(), 0); + QTime t(fileinfo.fileName().mid( 114, 2).toInt(), fileinfo.fileName().mid( 116, 2).toInt(), 0); //filedate.setTime(t); if(hoursbefore == 0) { @@ -2276,7 +2311,10 @@ QStringList AVHRRSatellite::GetOverviewSegmentsMERSI() QStringList AVHRRSatellite::GetOverviewSegmentsGeo(int geoindex) { QStringList strlist; - strlist << seglgeo.at(geoindex)->getImagePath() << QString(opts.geosatellites.at(geoindex).fullname) << QString("%1").arg(this->segmentlistmapgeo.at(geoindex).count()); + if(opts.geosatellites.at(geoindex).shortname == "MTG-I1") + strlist << seglgeo.at(geoindex)->getImagePath() << QString(opts.geosatellites.at(geoindex).shortname) << QString("%1").arg(this->segmentlistmapgeomtgi1.count()); + else + strlist << seglgeo.at(geoindex)->getImagePath() << QString(opts.geosatellites.at(geoindex).shortname) << QString("%1").arg(this->segmentlistmapgeo.at(geoindex).count()); return strlist; } @@ -2446,16 +2484,16 @@ QString AVHRRSatellite::GetOverviewSegments() "\rSegments in directory = %34\n\rTotal Segments SLSTR = %35\n\rselected = %36 \n" "For %37 \n" "\rSegments in directory = %38\n\rTotal Segments MERSI = %39\n\rselected = %40 \n"). - arg(seglmetop->GetDirectoryName()).arg(seglmetop->GetTotalSegmentsInDirectory()).arg(nbrsegmmetop).arg(nbrsegmmetopsel). - arg(seglnoaa->GetDirectoryName()).arg(seglnoaa->GetTotalSegmentsInDirectory()).arg(nbrsegmnoaa).arg(nbrsegmnoaasel). - arg(seglgac->GetDirectoryName()).arg(seglgac->GetTotalSegmentsInDirectory()).arg(nbrsegmgac).arg(nbrsegmgacsel). - arg(seglhrp->GetDirectoryName()).arg(seglhrp->GetTotalSegmentsInDirectory()).arg(nbrsegmhrp).arg(nbrsegmhrpsel). - arg(seglviirsm->GetDirectoryName()).arg(seglviirsm->GetTotalSegmentsInDirectory()).arg(nbrsegmviirsm).arg(nbrsegmviirsmsel). - arg(seglviirsdnb->GetDirectoryName()).arg(seglviirsdnb->GetTotalSegmentsInDirectory()).arg(nbrsegmviirsdnb).arg(nbrsegmviirsdnbsel). - arg(seglolciefr->GetDirectoryName()).arg(seglolciefr->GetTotalSegmentsInDirectory()).arg(nbrsegmolciefr).arg(nbrsegmolciefrsel). - arg(seglolcierr->GetDirectoryName()).arg(seglolcierr->GetTotalSegmentsInDirectory()).arg(nbrsegmolcierr).arg(nbrsegmolcierrsel). - arg(seglslstr->GetDirectoryName()).arg(seglslstr->GetTotalSegmentsInDirectory()).arg(nbrsegmslstr).arg(nbrsegmslstrsel). - arg(seglmersi->GetDirectoryName()).arg(seglmersi->GetTotalSegmentsInDirectory()).arg(nbrsegmmersi).arg(nbrsegmmersisel); + arg(seglmetop->GetDirectoryName()).arg(seglmetop->GetTotalSegmentsInDirectory()).arg(nbrsegmmetop).arg(nbrsegmmetopsel). + arg(seglnoaa->GetDirectoryName()).arg(seglnoaa->GetTotalSegmentsInDirectory()).arg(nbrsegmnoaa).arg(nbrsegmnoaasel). + arg(seglgac->GetDirectoryName()).arg(seglgac->GetTotalSegmentsInDirectory()).arg(nbrsegmgac).arg(nbrsegmgacsel). + arg(seglhrp->GetDirectoryName()).arg(seglhrp->GetTotalSegmentsInDirectory()).arg(nbrsegmhrp).arg(nbrsegmhrpsel). + arg(seglviirsm->GetDirectoryName()).arg(seglviirsm->GetTotalSegmentsInDirectory()).arg(nbrsegmviirsm).arg(nbrsegmviirsmsel). + arg(seglviirsdnb->GetDirectoryName()).arg(seglviirsdnb->GetTotalSegmentsInDirectory()).arg(nbrsegmviirsdnb).arg(nbrsegmviirsdnbsel). + arg(seglolciefr->GetDirectoryName()).arg(seglolciefr->GetTotalSegmentsInDirectory()).arg(nbrsegmolciefr).arg(nbrsegmolciefrsel). + arg(seglolcierr->GetDirectoryName()).arg(seglolcierr->GetTotalSegmentsInDirectory()).arg(nbrsegmolcierr).arg(nbrsegmolcierrsel). + arg(seglslstr->GetDirectoryName()).arg(seglslstr->GetTotalSegmentsInDirectory()).arg(nbrsegmslstr).arg(nbrsegmslstrsel). + arg(seglmersi->GetDirectoryName()).arg(seglmersi->GetTotalSegmentsInDirectory()).arg(nbrsegmmersi).arg(nbrsegmmersisel); } diff --git a/core/avhrrsatellite.h b/core/avhrrsatellite.h index 87e9516..2bb7881 100644 --- a/core/avhrrsatellite.h +++ b/core/avhrrsatellite.h @@ -147,7 +147,8 @@ class AVHRRSatellite : public QObject QList seglgeo; QList > > > segmentlistmapgeo; - QMap > > segmentlistmapgeomtgi1; + QMap > segmentlistmapgeomtgi1; + QDate selectiondate; private: @@ -156,8 +157,8 @@ class AVHRRSatellite : public QObject QDate seldate, int hoursbefore); void RemoveFromList(QList *sl); void CreateListfromXML(QDomDocument document); - void getFilenameParameters(int geosatindex, QString filename, QString &strspectrum, QString &strdate, int &filenbr); - void getFilenameParametersMTGI1(QString filename, QString &strdate, int &filenbr, int &seqnbr); + void getFilenameParameters(int geosatindex, QString filename, QString *strspectrum, QString *strdate, int *filenbr); + void getFilenameParametersMTGI1(QString filename, QString *strdate, int *filenbr, int *seqnbr); DatahubAccessManager hubmanager; QDate xmlselectdate; diff --git a/core/formgeostationary.cpp b/core/formgeostationary.cpp index fee758f..c9af69a 100644 --- a/core/formgeostationary.cpp +++ b/core/formgeostationary.cpp @@ -10,6 +10,7 @@ #include "internal.h" #include "nav_util.h" #include "qsgp4date.h" +#include #define REDCHANNEL 0 #define GREENCHANNEL 1 @@ -67,7 +68,6 @@ FormGeostationary::FormGeostationary(QWidget *parent, SatelliteList *satlist, AV treeWidget->header()->setSectionResizeMode(i, QHeaderView::ResizeToContents); } - connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(ontreeWidgetitemClicked(QTreeWidgetItem *, int))); QVBoxLayout *mylayout = new QVBoxLayout; mylayout->addWidget(treeWidget); @@ -77,13 +77,37 @@ FormGeostationary::FormGeostationary(QWidget *parent, SatelliteList *satlist, AV { QWidget *mywidget = new QWidget(); ui->tabGeostationary->addTab(mywidget,opts.geosatellites.at(i).fullname + " : " + QString("%1").arg(opts.geosatellites.at(i).longitude) + "°"); - //QTableWidget *tableWidget = new QTableWidget(4, 6); + QTreeWidget *treeWidget = new QTreeWidget; + + geotreewidgetlist.append(treeWidget); + treeWidget->setRootIsDecorated(false); + treeWidget->header()->setStretchLastSection(false); + treeWidget->setColumnCount(41 + 2); + QStringList header; + for(int i = 1; i < 42; i++) + { + QString tel = QString("%1").arg(i, 3, 10); + header.append(tel); + } + + treeWidget->setHeaderLabels( QStringList() << "Date/Time" << "Seq." << header ); + + treeWidget->header()->setMinimumSectionSize(5); + treeWidget->header()->resizeSections(QHeaderView::ResizeToContents); + treeWidget->setColumnWidth(0, 250); + + connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(ontreeWidgetitemClicked(QTreeWidgetItem *, int))); + QVBoxLayout *mylayout = new QVBoxLayout; + mylayout->addWidget(treeWidget); + mywidget->setLayout(mylayout); } } if(opts.geosatellites.count() > 0) + { ui->tabGeostationary->setCurrentIndex(0); + } } @@ -107,7 +131,7 @@ QStringList FormGeostationary::getGeostationarySegments(int geoindex, const QStr { QString st = *itc; if(meteosatdir.match(filepattern, *itc) && - st.mid(opts.geosatellites.at(geoindex).indexspectrumhrv, opts.geosatellites.at(geoindex).spectrumhrv.length()) == opts.geosatellites.at(geoindex).spectrumhrv) + st.mid(opts.geosatellites.at(geoindex).indexspectrumhrv, opts.geosatellites.at(geoindex).spectrumhrv.length()) == opts.geosatellites.at(geoindex).spectrumhrv) strlistout.append(*itc); itc++; } @@ -119,7 +143,7 @@ QStringList FormGeostationary::getGeostationarySegments(int geoindex, const QStr QString st = *itc; QString filespectrum = st.mid(opts.geosatellites.at(geoindex).indexspectrum, opts.geosatellites.at(geoindex).spectrumlist.at(0).length()); if(meteosatdir.match(filepattern, *itc) && - (filespectrum == spectrumvector.at(0) || filespectrum == spectrumvector.at(1) || filespectrum == spectrumvector.at(2))) + (filespectrum == spectrumvector.at(0) || filespectrum == spectrumvector.at(1) || filespectrum == spectrumvector.at(2))) strlistout.append(*itc); itc++; } @@ -133,6 +157,52 @@ QStringList FormGeostationary::getGeostationarySegments(int geoindex, const QStr return strlistout; } +QStringList FormGeostationary::getGeostationarySegmentsMTG(int geoindex, const QString imagetype, const QString filepath, int filenbr) +{ + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N__T_0070_0001.nc + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N__T_0070_0041.nc + + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N_JLS_T_0070_0001.nc + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N_JLS_T_0070_0041.nc + + qDebug() << QString("getGeostationarySegments type = %1 Filepath = %2 filenbr = %3").arg(imagetype).arg(filepath).arg(filenbr); + + QDir meteosatdir(filepath); + meteosatdir.setFilter(QDir::Files | QDir::NoSymLinks); + meteosatdir.setSorting(QDir::Name); + + QStringList strlist = meteosatdir.entryList(); + QStringList strlistout; + + QStringList::Iterator itc = strlist.begin(); + + while( itc != strlist.end() ) + { + QString st = *itc; + if((st.contains("BODY") && st.mid(135, 5) == "N_JLS" && st.mid(143, 4).toInt() == filenbr) || + (st.contains("BODY") && st.mid(135, 3) == "N__" && st.mid(140, 4).toInt() == filenbr) || + (st.contains("TRAIL") && st.mid(136, 5) == "N_JLS" && st.mid(144, 4).toInt() == filenbr) || + (st.contains("TRAIL") && st.mid(136, 3) == "N__" && st.mid(141, 4).toInt() == filenbr)) + { + strlistout.append(*itc); + } + itc++; + } + +// for (int j = 0; j < strlistout.size(); ++j) +// { +// qDebug() << QString("getGeostationarySegmentsMTG out ======= %1 %2 %3").arg(imagetype).arg(j).arg(strlistout.at(j)); +// } + + return strlistout; +} + QStringList FormGeostationary::globit(const QString filepath, const QString filepattern) { @@ -203,29 +273,111 @@ void FormGeostationary::PopulateTree() if(opts.geosatellites.at(i).shortname != "MTG-I1") PopulateTreeGeo(i); else if(opts.geosatellites.at(i).shortname == "MTG-I1") - PopulateTreeGeoMTGI1(); + PopulateTreeGeoMTGI1(i); } } -void FormGeostationary::PopulateTreeGeoMTGI1() +void FormGeostationary::PopulateTreeGeoMTGI1(int geoindex) { - QMap > > mapmtgi1; + int filenbr;// 1 --> 144 + int seqnbr; // 1 --> 41 + QStringList strlist; + int seqarray[41]; + QTreeWidgetItem *newitem; + QColor col; + bool seqok; + + QMap > mapmtgi1; mapmtgi1 = segs->segmentlistmapgeomtgi1; - QTableWidget *widget; + QTreeWidget *widget; + widget = geotreewidgetlist.at(geoindex); + widget->clear(); + + QMap >::const_iterator citfilenbr = mapmtgi1.constBegin(); + + while (citfilenbr != mapmtgi1.constEnd()) + { + filenbr = citfilenbr.key(); + //qDebug() << filenbr; + + for(int i = 0; i < 41; i++) + seqarray[i] = 0; + seqok = true; + + QMap mapseqnbr; + mapseqnbr = mapmtgi1.value(filenbr); + QMap< int, QFileInfo >::const_iterator citseqnbr = mapseqnbr.constBegin(); + while (citseqnbr != mapseqnbr.constEnd()) + { + seqnbr = citseqnbr.key(); + seqarray[seqnbr-1] = 1; + QFileInfo fileinfo = citseqnbr.value(); + //qDebug() << fileinfo.absoluteFilePath(); + ++citseqnbr; + } + + for(int i = 0; i < 41; i++) + { + if(seqarray[i] == 0) + { + seqok = false; + break; + } + } + + strlist.clear(); + QString strtime; + getTimeFromFilenbr(filenbr, &strtime); + + strlist << strtime << QString("%1").arg(filenbr); + + for(int i = 0; i < 41; i++) + { + strlist << QString("%1").arg(seqarray[i]); + } + + newitem = new QTreeWidgetItem( widget, strlist, 0 ); + + if(seqok) + col.setRgb(174, 225, 184); + else + col.setRgb(225, 171, 196); + + for(int i = 0; i < 43; i++) + newitem->setBackground( i, QBrush(col) ); + ++citfilenbr; + } +} + +void FormGeostationary::getTimeFromFilenbr(int filenbr, QString *strtime) +{ + double intpart; + double hrs = filenbr/6.0; + int hour; + double fractpart = modf(hrs, &intpart); + + QDate mydate = segs->selectiondate; + QString yeardir = mydate.toString("yyyyMMdd").mid(0, 4); + QString monthdir = mydate.toString("yyyyMMdd").mid(4, 2); + QString daydir = mydate.toString("yyyyMMdd").mid(6, 2); + + hour = (int)intpart; + double dmin = fractpart * 60.0; + int min = round(dmin); + + *strtime = QString("%1-%2-%3 %4:%5").arg(yeardir).arg(monthdir).arg(daydir).arg(hour, 2, 10, QChar('0')).arg(min, 2, 10, QChar('0')); } void FormGeostationary::PopulateTreeGeo(int geoindex) { QMap > > map; - QMap > > mapmtgi1; map = segs->segmentlistmapgeo.at(geoindex); - mapmtgi1 = segs->segmentlistmapgeomtgi1; QTreeWidget *widget; widget = geotreewidgetlist.at(geoindex); @@ -351,7 +503,7 @@ void FormGeostationary::PopulateTreeGeo(int geoindex) for(int i = 0; i < 18; i++) - newitem->setBackgroundColor( i, col ); + newitem->setBackground( i, QBrush(col) ); ++citdate; } @@ -376,6 +528,7 @@ void FormGeostationary::slotCreateGeoImage(QString type, QVector spectr // LUMlo=IR_016 + VIS008 + VIS006 QString tex; + QString tex1; SegmentListGeostationary *sl; @@ -387,12 +540,30 @@ void FormGeostationary::slotCreateGeoImage(QString type, QVector spectr sl = setActiveSegmentList(i); QTreeWidgetItem *it = treewidgetselected.at(0); tex = it->text(0); + tex1 = it->text(1); break; } } int geoindex = sl->getGeoSatelliteIndex(); - formtoolbox->createFilenamestring(opts.geosatellites.at(geoindex).shortname, tex, spectrumvector); + + if(opts.geosatellites.at(geoindex).shortname == "MTG-I1") { + CreateGeoImageMTG(type, spectrumvector, inversevector, histogrammethod, pseudocolor, tex + ";" + tex1, geoindex); + } + else { + CreateGeoImageMSG(type, spectrumvector, inversevector, histogrammethod, pseudocolor, tex, geoindex); + } + + +} + +void FormGeostationary::CreateGeoImageMSG(QString type, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor, QString tex, int geoindex) +{ + + SegmentListGeostationary *sl; + sl = setActiveSegmentList(geoindex); + + formtoolbox->createImageFilenamestring(opts.geosatellites.at(geoindex).shortname, tex, spectrumvector); sl->ResetSegments(); imageptrs->ResetPtrImage(); @@ -429,9 +600,6 @@ void FormGeostationary::slotCreateGeoImage(QString type, QVector spectr return; } - formimage->displayImage(IMAGE_GEOSTATIONARY); - formimage->adjustPicSize(false); - qDebug() << QString("FormGeostationary::CreateGeoImage kind = %1 areatype = %2").arg(type).arg(sl->areatype); if(opts.geosatellites.at(geoindex).protocol == "HDF" ) @@ -443,6 +611,20 @@ void FormGeostationary::slotCreateGeoImage(QString type, QVector spectr } +void FormGeostationary::CreateGeoImageMTG(QString type, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor, QString tex, int geoindex) +{ + SegmentListGeostationary *sl; + sl = setActiveSegmentList(geoindex); + + sl->setSpectrumVector(spectrumvector); + + imageptrs->ResetPtrImage(); + + CreateGeoImagenetCDFMTG(sl, type, tex, spectrumvector, inversevector, histogrammethod, pseudocolor); + + +} + SegmentListGeostationary *FormGeostationary::setActiveSegmentList(int geoindex) { SegmentListGeostationary *sl; @@ -563,6 +745,7 @@ void FormGeostationary::CreateGeoImageXRIT(SegmentListGeostationary *sl, QString MSG_header epiheader; MSG_header proheader; MSG_header header; + float subsatpoint; if(sl->getGeoSatellite() != eGeoSatellite::H8) { @@ -581,6 +764,10 @@ void FormGeostationary::CreateGeoImageXRIT(SegmentListGeostationary *sl, QString try { da.read_file(prologuefile, proheader, prodata); + //subsatpoint = proheader.image_navigation->subsatellite_longitude; + //qDebug() << "------> subsatpoint = " << subsatpoint; + //qDebug() << "reading prologue"; + //qDebug() << proheader.; } catch( std::runtime_error &run ) { @@ -701,7 +888,7 @@ void FormGeostationary::CreateGeoImageXRIT(SegmentListGeostationary *sl, QString filesequence = fileinfo.fileName().mid(opts.geosatellites.at(geoindex).indexfilenbr, opts.geosatellites.at(geoindex).lengthfilenbr).toInt()-1; filespectrum = fileinfo.fileName().mid(opts.geosatellites.at(geoindex).indexspectrum, opts.geosatellites.at(geoindex).spectrumlist.at(0).length()); filedate = fileinfo.fileName().mid(opts.geosatellites.at(geoindex).indexdate, opts.geosatellites.at(geoindex).lengthdate); - filedate.leftJustified(12, '0'); + filedate = filedate.leftJustified(12, '0'); sl->InsertPresent( spectrumvector, filespectrum, filesequence); @@ -720,7 +907,7 @@ void FormGeostationary::CreateGeoImageXRIT(SegmentListGeostationary *sl, QString filesequence = fileinfo.fileName().mid(opts.geosatellites.at(geoindex).indexfilenbrhrv, opts.geosatellites.at(geoindex).lengthfilenbrhrv).toInt()-1; filespectrum = fileinfo.fileName().mid(opts.geosatellites.at(geoindex).indexspectrumhrv, opts.geosatellites.at(geoindex).spectrumhrv.length()); filedate = fileinfo.fileName().mid(opts.geosatellites.at(geoindex).indexdatehrv, opts.geosatellites.at(geoindex).lengthdatehrv); - filedate.leftJustified(12, '0'); + filedate = filedate.leftJustified(12, '0'); sl->InsertPresent( spectrumvector, filespectrum, filesequence); @@ -857,13 +1044,19 @@ void FormGeostationary::CreateGeoImagenetCDF(SegmentListGeostationary *sl, QStri //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N__T_0070_0001.nc //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N__T_0070_0041.nc + + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N_JLS_T_0070_0001.nc //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N_JLS_T_0070_0041.nc //OR_ABI-L1b-RadF-M4C01_G16_s20161811455312_e20161811500122_c20161811500175.nc //01234567890123456789012345678901234567890123456789 + if((whichgeo == eGeoSatellite::GOES_16) && (type == "VIS_IR" || type == "VIS_IR Color")) filepattern = QString("OR_ABI-L1b-RadF-M????_G16_s") + filetiming_goes + QString("*.nc"); else if((whichgeo == eGeoSatellite::GOES_17) && (type == "VIS_IR" || type == "VIS_IR Color")) @@ -910,6 +1103,58 @@ void FormGeostationary::setTreeWidget(QTreeWidget *widget, bool state) } } +void FormGeostationary::CreateGeoImagenetCDFMTG(SegmentListGeostationary *sl, QString type, QString tex, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor) +{ + + QString filetiming_mtg; + QStringList llVIS_IR; + + eGeoSatellite whichgeo = sl->getGeoSatellite(); + int geoindex = sl->getGeoSatelliteIndex(); + + formtoolbox->setProgressMaximum(100); + + qDebug() << "====> tex = " << tex; + //"2017-08-10 19:45" + // 012345678901234567890 + //====> tex = "2017-09-20 11:00;66" + QDate now(tex.mid(0, 4).toInt(), tex.mid(5, 2).toInt(), tex.mid(8, 2).toInt()); + int filenbr = tex.mid(17, 2).toInt(); + + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N__T_0070_0001.nc + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N__T_0070_0041.nc + + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N_JLS_T_0070_0001.nc + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N_JLS_T_0070_0041.nc + + + if(type == "VIS_IR" || type == "VIS_IR Color") + { + llVIS_IR = this->getGeostationarySegmentsMTG(geoindex, type, sl->getImagePath(), filenbr); + qDebug() << QString("llVIS_IR count = %1").arg(llVIS_IR.count()); + if(llVIS_IR.count() == 0) + { + QApplication::restoreOverrideCursor(); + QMessageBox msgBox; + msgBox.setText("No segments found !"); + msgBox.exec(); + emit enabletoolboxbuttons(true); + return; + } + else + { + sl->setThreadParameters(llVIS_IR, spectrumvector, inversevector, histogrammethod, pseudocolor); + sl->ComposeImagenetCDFMTGInThread(llVIS_IR, spectrumvector, inversevector, histogrammethod, pseudocolor); + } + } +} + void FormGeostationary::SelectGeoWidgetItem(int geoindex, QTreeWidgetItem *item, int column ) { @@ -925,7 +1170,6 @@ void FormGeostationary::SelectGeoWidgetItem(int geoindex, QTreeWidgetItem *item, qDebug() << opts.geosatellites.at(geoindex).shortname + " " + (*item).text(0); imageptrs->ptrimageGeostationary->fill(Qt::black); - formimage->setupGeoOverlay(geoindex); //012345678901234567 //2017-07-04 08:00 @@ -947,8 +1191,9 @@ void FormGeostationary::ontreeWidgetitemClicked(QTreeWidgetItem *item, int colum void FormGeostationary::on_tabGeostationary_tabBarClicked(int index) { - // int activeindex = this->getActiveSegmentList()->getGeoSatelliteIndex(); - // formimage->setupGeoOverlay(index); + qDebug() << "FormGeostationary::on_tabGeostationary_tabBarClicked(int index) index = " << index; + + formimage->setupGeoOverlay(index); emit setbuttonlabels(index, false); } diff --git a/core/formgeostationary.h b/core/formgeostationary.h index e1ed3af..6924fd9 100644 --- a/core/formgeostationary.h +++ b/core/formgeostationary.h @@ -3,14 +3,16 @@ #include #include +#include "formmapcyl.h" #include "satellite.h" #include "avhrrsatellite.h" -#include "msgfileaccess.h" -#include "msgdataaccess.h" -#include "formtoolbox.h" +//#include "msgfileaccess.h" +//#include "msgdataaccess.h" #include "formimage.h" +//#include "formtoolbox.h" class FormImage; +class FormToolbox; namespace Ui { class FormGeostationary; @@ -32,19 +34,21 @@ class FormGeostationary : public QWidget SegmentListGeostationary *setActiveSegmentList(int geoindex); SegmentListGeostationary *getActiveSegmentList(); int getTabWidgetGeoIndex(); - //void ComposeGeoRGBRecipe(bandstorage &bs); - + void getTimeFromFilenbr(int filenbr, QString *strtime); ~FormGeostationary(); private: QStringList getGeostationarySegments(int geoindex, const QString imagetype, const QString filepath, QVector spectrumvector, QString filepattern); + QStringList getGeostationarySegmentsMTG(int geoindex, const QString imagetype, const QString filepath, int filenbr); void PopulateTreeGeo(int geoindex); - void PopulateTreeGeoMTGI1(); + void PopulateTreeGeoMTGI1(int geoindex); void CreateGeoImageXRIT(SegmentListGeostationary *sl, QString type, QString tex, QVector spectrumvector, QVector inversevector, int histogrammethod); void CreateGeoImageHDF(SegmentListGeostationary *sl, QString type, QString tex, QVector spectrumvector, QVector inversevector); void CreateGeoImagenetCDF(SegmentListGeostationary *sl, QString type, QString tex, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor); - + void CreateGeoImagenetCDFMTG(SegmentListGeostationary *sl, QString type, QString tex, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor); + void CreateGeoImageMSG(QString type, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor, QString tex, int geoindex); + void CreateGeoImageMTG(QString type, QVector spectrumvector, QVector inversevector,int histogrammethod, bool pseudocolor, QString tex, int geoindex); Ui::FormGeostationary *ui; AVHRRSatellite *segs; SatelliteList *sats; diff --git a/core/formimage.cpp b/core/formimage.cpp index 9da94ed..3ab1dfc 100644 --- a/core/formimage.cpp +++ b/core/formimage.cpp @@ -1,85 +1,46 @@ #include "formimage.h" -#include "segmentimage.h" -#include "options.h" -#include "gshhsdata.h" #include "pixgeoconversion.h" +#include "gshhsdata.h" -#include +#include +#include +#include +#include +#include +#include +#include extern Options opts; extern SegmentImage *imageptrs; extern gshhsData *gshhsdata; extern bool ptrimagebusy; -#include -#include - -#define MAP_X 3 -#define MAP_Y 3 - -void doCLAHE(quint16 *t) -{ - imageptrs->CLAHE(t, 3712, 3712, 0, 1023, 16, 16, 256, opts.clahecliplimit); -} - -void doCLAHEHRVFull(quint16 *t) -{ - imageptrs->CLAHE(t, 5568, 11136, 0, 1023, 16, 16, 256, opts.clahecliplimit); -} - -void doCLAHEHRVEurope(quint16 *t) +FormImage::FormImage(QWidget *parent, SatelliteList *satlist, AVHRRSatellite *seglist) : + QGraphicsView(parent), m_rotateAngle(0), m_ViewInitialized(false) { - imageptrs->CLAHE(t, 5568, 5*464, 0, 1023, 16, 16, 256, opts.clahecliplimit); -} + m_scene = new QGraphicsScene(this); + this->setScene(m_scene); + this->setBackgroundBrush(QBrush(QColor(38,38,38,255),Qt::SolidPattern)); + this->setDragMode(NoDrag); -FormImage::FormImage(QWidget *parent, SatelliteList *satlist, AVHRRSatellite *seglist ) : - QWidget(parent) -{ sats = satlist; segs = seglist; channelshown = IMAGE_GEOSTATIONARY; - zoomIncrement = 2; - maxZoomValue = 300; - minZoomValue = 4; - - zoomValueavhrr = opts.zoomfactoravhrr; - zoomValuemeteosat = opts.zoomfactormeteosat; - zoomValueprojection = opts.zoomfactorprojection; - zoomValueviirs = opts.zoomfactorviirs; - zoomValueolci = opts.zoomfactorolci; - zoomValueslstr = opts.zoomfactorslstr; - zoomValuemersi = opts.zoomfactormersi; - - scaleFactor = (double)getZoomValue()/100; - qDebug() << QString("FormImage::FormImage scalefactor = %1").arg(scaleFactor); - imageLabel = new ImageLabel(this, segs); - // imageLabel = new AspectRatioPixmapLabel; - imageLabel->setFormImagePtr(this); - imageLabel->setScaledContents(true); - - mainLayout = new QVBoxLayout; - mainLayout->addWidget(imageLabel); - this->setLayout(mainLayout); + m_image = NULL; overlaymeteosat = true; overlayprojection = true; overlayolci = true; - refreshoverlay = true; - changeinfraprojection = false; - - this->setSegmentType(SEG_NONE); metopcount = 0; noaacount = 0; - gaccount = 0; hrpcount = 0; - + gaccount = 0; metopAhrptcount = 0; metopBhrptcount = 0; noaa19hrptcount = 0; M01hrptcount = 0; M02hrptcount = 0; - viirsmcount = 0; viirsdnbcount = 0; viirsmcountnoaa20 = 0; @@ -87,386 +48,330 @@ FormImage::FormImage(QWidget *parent, SatelliteList *satlist, AVHRRSatellite *se olciefrcount = 0; olcierrcount = 0; slstrcount = 0; - txtInfo = ""; + mersicount = 0; - this->currentgeooverlay = 0; + this->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); this->setupGeoOverlay(0); - //setMouseTracking(true); - -} - -QLabel *FormImage::returnimageLabelptr() -{ - return imageLabel; } bool FormImage::toggleOverlayMeteosat() { - displayImage(channelshown); if(overlaymeteosat) overlaymeteosat = false; else overlaymeteosat = true; - this->update(); + m_scene->update(); return overlaymeteosat; } bool FormImage::toggleOverlayOLCI() { - displayImage(channelshown); if(overlayolci) overlayolci = false; else overlayolci = true; - this->update(); + m_scene->update(); return overlayolci; } bool FormImage::toggleOverlayGridOnOLCI() { - displayImage(channelshown); - this->update(); + m_scene->update(); return overlayolci; } bool FormImage::toggleOverlayProjection() { - displayImage(channelshown); - if(overlayprojection) + if(overlayprojection) overlayprojection = false; else overlayprojection = true; - this->update(); + m_scene->update(); return overlayprojection; } -void FormImage::setPixmapToLabel(bool settoolboxbuttons) +void FormImage::displayGeoImageInfo() { + for(int i = 0; i < opts.geosatellites.length(); i++) + { + if(segs->seglgeo[i]->bActiveSegmentList == true) + { + displayGeoImageInformation(opts.geosatellites[i].fullname); + } + } - // qDebug() << "FormImage::setPixmapToLabel(bool settoolboxbuttons) width = " << imageptrs->ptrimageMERSI->size().width() << " height = " - // << imageptrs->ptrimageMERSI->size().height() << " channelshown = " << channelshown; +} - refreshoverlay = true; +void FormImage::displayGeoImageInformation(QString satname) +{ + QString spectrum; + SegmentListGeostationary *slgeo = NULL; - emit allsegmentsreceivedbuttons(settoolboxbuttons); - emit setmapcylbuttons(true); + slgeo = segs->getActiveSegmentList(); - switch(channelshown) - { - case IMAGE_AVHRR_CH1: - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[0]) )); - formtoolbox->setOMimagesize(imageptrs->ptrimagecomp_ch[0]->width(), imageptrs->ptrimagecomp_ch[0]->height()); - break; - case IMAGE_AVHRR_CH2: - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[1]) )); - formtoolbox->setOMimagesize(imageptrs->ptrimagecomp_ch[1]->width(), imageptrs->ptrimagecomp_ch[1]->height()); - break; - case IMAGE_AVHRR_CH3: - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[2]) )); - formtoolbox->setOMimagesize(imageptrs->ptrimagecomp_ch[2]->width(), imageptrs->ptrimagecomp_ch[2]->height()); - break; - case IMAGE_AVHRR_CH4: - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[3]) )); - formtoolbox->setOMimagesize(imageptrs->ptrimagecomp_ch[3]->width(), imageptrs->ptrimagecomp_ch[3]->height()); - break; - case IMAGE_AVHRR_CH5: - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[4]) )); - formtoolbox->setOMimagesize(imageptrs->ptrimagecomp_ch[4]->width(), imageptrs->ptrimagecomp_ch[4]->height()); - break; - case IMAGE_AVHRR_COL: - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage(*(imageptrs->ptrimagecomp_col))); - formtoolbox->setOMimagesize(imageptrs->ptrimagecomp_col->width(), imageptrs->ptrimagecomp_col->height()); - break; - case IMAGE_AVHRR_EXPAND: - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrexpand_col))); - break; - case IMAGE_GEOSTATIONARY: - displayGeoImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageGeostationary))); - break; - case IMAGE_PROJECTION: - formtoolbox->writeInfoToTextEdit(""); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageProjection))); - break; - case IMAGE_VIIRSM: - displayVIIRSImageInfo(segmenttype); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageViirsM))); - formtoolbox->setOMimagesize(imageptrs->ptrimageViirsM->width(), imageptrs->ptrimageViirsM->height()); - break; - case IMAGE_VIIRSDNB: - displayVIIRSImageInfo(segmenttype); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageViirsDNB))); - formtoolbox->setOMimagesize(imageptrs->ptrimageViirsDNB->width(), imageptrs->ptrimageViirsDNB->height()); - break; - case IMAGE_OLCI: - displaySentinelImageInfo(SEG_OLCIEFR); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageOLCI))); - break; - case IMAGE_SLSTR: - displaySentinelImageInfo(SEG_SLSTR); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageSLSTR))); - break; - case IMAGE_MERSI: - displayMERSIImageInfo(SEG_MERSI); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageMERSI))); - formtoolbox->setOMimagesize(imageptrs->ptrimageMERSI->width(), imageptrs->ptrimageMERSI->height()); - break; - case IMAGE_NONE: - break; + QString type = slgeo->getKindofImage(); + QVector spectrumvector = slgeo->getSpectrumVector(); + if(spectrumvector.size() > 0) + spectrum = ( type == "VIS_IR" ? spectrumvector.at(0) : ""); + else + spectrum = ""; + + txtInfo = QString("" + "Info" + "" + "

Image Information

" + "

Satellite = %1
" + "Image type = %2 %3
" + "Image width = %4 height = %5

" + "").arg(satname).arg(type).arg(spectrum).arg(imageptrs->ptrimageGeostationary->width()).arg(imageptrs->ptrimageGeostationary->height()); + formtoolbox->writeInfoToTextEdit(txtInfo); +} +void FormImage::resetView() +{ + if(m_image == NULL){ + return; } - this->adjustImage(); - QApplication::processEvents(); + m_ViewInitialized = false; - qDebug() << QString("FormImage::setPixmapToLabel() channelshown = %1").arg(this->channelshown); + m_scene->clear(); + // m_image = NULL; //QImage(); + m_fileName.clear(); + m_rotateAngle = 0; + this->setDragMode(NoDrag); + this->resetTransform(); +} + +void FormImage::fitWindow() +{ + if(!m_ViewInitialized) + return; + if(m_image == NULL) + return; + + this->resetTransform(); + + qDebug() << "scene width = " << scene()->sceneRect().width() << " height = " << scene()->sceneRect().height(); + fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); + this->setWindowTitle(); } -void FormImage::setPixmapToLabelDNB(bool settoolboxbuttons) +void FormImage::originalSize() { - refreshoverlay = true; - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageViirsDNB))); - this->update(); + if(!m_ViewInitialized) + return; + if(m_image->isNull()) + return; + this->setDragMode(ScrollHandDrag); + this->resetTransform(); + this->centerOn(m_pixmapItem); + this->setWindowTitle(); } -void FormImage::displayImage(eImageType channel) +void FormImage::setWindowTitle() { + QTransform transf = this->transform(); + int zoomfactor = (int)(transf.m11()*100); + QString title = QString("EUMETCast Viewer ( %1 %)").arg(zoomfactor); + emit signalMainWindowTitleChanged(title); - // qDebug() << QString("FormImage::displayImage(eImageType channel) channel = %1").arg(channel); - // qDebug() << QString("FormImage ptrimagecomp[0] bytecount = %1").arg(imageptrs->ptrimagecomp_ch[0]->byteCount()); - // qDebug() << QString("FormImage ptrimageviirsm bytecount = %1").arg(imageptrs->ptrimageViirsM->byteCount()); - // qDebug() << QString("FormImage ptrimageviirsdnb bytecount = %1").arg(imageptrs->ptrimageViirsDNB->byteCount()); - // qDebug() << QString("FormImage ptrimageolci bytecount = %1").arg(imageptrs->ptrimageOLCI->byteCount()); - // qDebug() << QString("FormImage ptrimageslstr bytecount = %1").arg(imageptrs->ptrimageSLSTR->byteCount()); - // qDebug() << QString("FormImage ptrimagemersi bytecount = %1").arg(imageptrs->ptrimageMERSI->byteCount()); +} - this->channelshown = channel; +void FormImage::rotateView(const int nVal) +{ + if(m_image->isNull()){ + return; + } - QPixmap pm(800, 200); - pm.fill(Qt::red); - QPainter painter(&pm); + // rotate view + this->rotate(nVal); + //this->show(); // this necessary? - QFont f("Courier", 40, QFont::Bold); - painter.setFont(f); - painter.setPen(Qt::yellow); + // update angle + m_rotateAngle += nVal; // a=a+(-90)== -90 - if(ptrimagebusy) - { - QPixmap pm(800, 200); - pm.fill(Qt::red); - QPainter painter(&pm); + // reset angle + if(m_rotateAngle >= 360 || m_rotateAngle <= -360){ + m_rotateAngle =0; + } +} + +void FormImage::printView() +{ + if(!m_ViewInitialized) + return; + + if(m_image->isNull()){ + return; + } +#ifndef QT_NO_PRINTER + if (QPrintDialog(&printer).exec() == QDialog::Accepted) { + QPainter painter(&printer); + painter.setRenderHint(QPainter::Antialiasing); + m_scene->render(&painter); + } +#endif +} + +bool FormImage::saveViewToDisk(QString &strError) +{ + if(!m_ViewInitialized) + return false; + + if(m_image->isNull()){ + strError = QObject::tr("Save failed."); + return false; + } - QFont f("Courier", 40, QFont::Bold); - painter.setFont(f); - painter.setPen(Qt::yellow); + // save a copy + QImage imageCopy = *m_image; - painter.drawText(10, 100, "Calculating image busy"); + // Output file dialog + QString fileFormat = getImageFormat(m_fileName); + QString strFilePath = QFileDialog::getSaveFileName( + this, + tr("Save File"), + QDir::homePath(), + fileFormat); - imageLabel->setPixmap(pm); + + // If Cancel is pressed, getSaveFileName() returns a null string. + if(strFilePath==""){ + strError = QObject::tr(""); + return false; } - else + + // ensure output path has proper extension + if(!strFilePath.endsWith(fileFormat)) + strFilePath += "."+fileFormat; + + // save image in modified state + if(isModified()) { + QTransform t; + t.rotate(m_rotateAngle); + imageCopy = imageCopy.transformed(t, Qt::SmoothTransformation); + } + + // quality factor (-1 default, 100 max) + // note: -1 is about 4 times smaller than original, 100 is larger than original + if(!imageCopy.save(strFilePath,fileFormat.toLocal8Bit().constData(),100)){ + strError = QObject::tr("Save failed."); + return false; + } + return true; +} + +QString FormImage::getImageFormat(QString strFileName) +{ + QString str = strFileName.mid(strFileName.lastIndexOf(".")+1,-1); + if(str.toLower() == "tif") + str = "tiff"; + return str; +} + +// preserve fitWindow state on window resize +void FormImage::resizeEvent(QResizeEvent *event) +{ + if(!m_ViewInitialized) + return; + + QGraphicsView::resizeEvent(event); // call base implementation + this->centerOn(m_pixmapItem); + this->setWindowTitle(); +} + +// scale image on wheelEvent +void FormImage::wheelEvent(QWheelEvent *event) +{ + //if(!m_IsViewInitialized) + // return; + + this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + + // zoomIn factor + qreal factor = 1.15; + + // zoomOut factor + if(event->angleDelta().y() < 0) + factor = 1.0 / factor; + + // scale the View + this->scale(factor,factor); + //qDebug() << "viewport width = " << this->viewport()->width() << " height = " << this->viewport()->height(); + //qDebug() << "boundingsrect item width = " << this->m_pixmapItem->boundingRect().width() << " height = " << this->m_pixmapItem->boundingRect().height(); + //QRectF itemBR = this->m_pixmapItem->boundingRect(); + //QRectF itemsceneBR = this->m_pixmapItem->sceneBoundingRect(); + //qDebug() << "itemsceneBR width = " << itemsceneBR.width() << " height = " << itemsceneBR.height(); + //QPolygonF sceneBR = this->m_pixmapItem->mapToScene(itemBR); + //QPolygonF viewBR = this->m_pixmapItem->mapFromScene(sceneBR);// viewBR is your rect/point/whatever + //qDebug() << "sceneBR width = " << sceneBR.boundingRect().width() << " height = " << sceneBR.boundingRect().height(); + //qDebug() << "viewBR width = " << viewBR.boundingRect().width() << " height = " << viewBR.boundingRect().height(); + //qDebug() << "viewBR width = " << viewBR. .boundingRect().width() << " height = " << viewBR.boundingRect().height(); + //qDebug() << "angledelta.y() = " << event->angleDelta().y(); + + this->setWindowTitle(); + event->accept(); +} + +void FormImage::zoomIn() +{ + this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + qreal factor = 1.15; + this->scale(factor,factor); + this->setWindowTitle(); +} + +void FormImage::zoomOut() +{ + this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + qreal factor = 1.15; + factor = 1.0 / factor; + this->scale(factor,factor); + this->setWindowTitle(); +} + +void FormImage::slotcomposefinished(QString kindofimage, int index) +{ + qDebug() << "slotcomposefinished " << kindofimage << " index = " << index; + + this->setPixmapToScene(true); + + SegmentListGeostationary *sl = NULL; + sl = segs->getActiveSegmentList(); + + + // if(sl->getGeoSatellite() == eGeoSatellite::H8) + // { + // EnhanceDarkSpace(sl->getGeoSatelliteIndex()); + // imageGraphicsView->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageGeostationary))); + // refreshoverlay = true; + // } + + QApplication::restoreOverrideCursor(); + + if(opts.imageontextureOnMet) { - switch(channelshown) + if(sl->getKindofImage() == "HRV" || sl->getKindofImage() == "HRV Color") { - case IMAGE_NONE: - break; - - case IMAGE_AVHRR_CH1: - if(imageptrs->ptrimagecomp_ch[0]->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No AVHRR image"); - imageLabel->setPixmap(pm); - } - else - { - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[0]) )); - } - break; - case IMAGE_AVHRR_CH2: - if(imageptrs->ptrimagecomp_ch[1]->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No AVHRR image"); - imageLabel->setPixmap(pm); - } - else - { - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[1]) )); - } - break; - case IMAGE_AVHRR_CH3: - if(imageptrs->ptrimagecomp_ch[2]->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No AVHRR image"); - imageLabel->setPixmap(pm); - } - else - { - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[2]) )); - } - break; - case IMAGE_AVHRR_CH4: - if(imageptrs->ptrimagecomp_ch[3]->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No AVHRR image"); - imageLabel->setPixmap(pm); - } - else - { - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[3]) )); - } - break; - case IMAGE_AVHRR_CH5: - if(imageptrs->ptrimagecomp_ch[4]->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No AVHRR image"); - imageLabel->setPixmap(pm); - } - else - { - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_ch[4]) )); - } - break; - case IMAGE_AVHRR_COL: - if(imageptrs->ptrimagecomp_col->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No AVHRR image"); - imageLabel->setPixmap(pm); - } - else - { - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_col))); - } - break; - case IMAGE_AVHRR_EXPAND: - if(imageptrs->ptrexpand_col->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No AVHRR image"); - imageLabel->setPixmap(pm); - } - else - { - displayAVHRRImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrexpand_col))); - } - break; - case IMAGE_GEOSTATIONARY: - if(imageptrs->ptrimageGeostationary->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No geostationary image"); - imageLabel->setPixmap(pm); - } - else - { - displayGeoImageInfo(); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageGeostationary))); - } - break; - case IMAGE_PROJECTION: - if(imageptrs->ptrimageProjection->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No Projection image"); - imageLabel->setPixmap(pm); - } - else - { - //formtoolbox->writeInfoToTextEdit("Projection image"); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageProjection))); - } - break; - case IMAGE_VIIRSM: - if(imageptrs->ptrimageViirsM->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No VIIRS M image"); - imageLabel->setPixmap(pm); - } - else - { - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageViirsM))); - if(segmenttype == eSegmentType::SEG_VIIRSM) - displayVIIRSImageInfo(SEG_VIIRSM); - else if(segmenttype == eSegmentType::SEG_VIIRSMNOAA20) - displayVIIRSImageInfo(SEG_VIIRSMNOAA20); - } - break; - case IMAGE_VIIRSDNB: - if(imageptrs->ptrimageViirsDNB->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No VIIRS DNB image"); - imageLabel->setPixmap(pm); - } - else - { - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageViirsDNB))); - if(segmenttype == eSegmentType::SEG_VIIRSDNB) - displayVIIRSImageInfo(SEG_VIIRSDNB); - else if(segmenttype == eSegmentType::SEG_VIIRSDNBNOAA20) - displayVIIRSImageInfo(SEG_VIIRSDNBNOAA20); - } - break; - case IMAGE_OLCI: - if(imageptrs->ptrimageOLCI->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No OLCI image"); - imageLabel->setPixmap(pm); - } - else - { - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageOLCI))); - this->displaySentinelImageInfo(imageptrs->olcitype); - } - break; - case IMAGE_SLSTR: - if(imageptrs->ptrimageSLSTR->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No SLSTR image"); - imageLabel->setPixmap(pm); - } - else - { - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageSLSTR))); - this->displaySentinelImageInfo(SEG_SLSTR); - } - break; - case IMAGE_MERSI: - if(imageptrs->ptrimageMERSI->sizeInBytes() == 0) - { - painter.drawText(10, 100, "No MERSI image"); - imageLabel->setPixmap(pm); - } - else - { - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageMERSI))); - this->displayMERSIImageInfo(SEG_MERSI); - } - break; - - } - } - - refreshoverlay = true; + qDebug() << "all HRV received !!!!!!!!!!!!!!"; + emit allsegmentsreceivedbuttons(true); + } + else + { + qDebug() << "all VIS_IR received !!!!!!!!!!!!!!"; + emit render3dgeo(sl->getGeoSatelliteIndex()); + } + } + else + emit allsegmentsreceivedbuttons(true); + qDebug() << "end FormImage::slotcomposefinished()"; this->update(); - this->adjustImage(); - - - // qDebug() << QString("after FormImage::displayImage(eImageType channel) channel = %1").arg(channel); } @@ -553,7 +458,7 @@ void FormImage::MakeImage() qDebug() << QString("in FormImage::ComposeImage nbr of mersi segments selected = %1").arg(mersicount); if(opts.buttonMetop || opts.buttonNoaa || opts.buttonGAC || opts.buttonHRP || - opts.buttonMetopAhrpt || opts.buttonMetopBhrpt || opts.buttonNoaa19hrpt || opts.buttonM01hrpt || opts.buttonM02hrpt ) + opts.buttonMetopAhrpt || opts.buttonMetopBhrpt || opts.buttonNoaa19hrpt || opts.buttonM01hrpt || opts.buttonM02hrpt ) { if (metopcount + noaacount + hrpcount + gaccount + metopAhrptcount + metopBhrptcount + noaa19hrptcount + M01hrptcount + M02hrptcount > 0) { @@ -656,7 +561,7 @@ void FormImage::MakeImage() formtoolbox->setToolboxButtons(false); - this->displayImage(IMAGE_VIIRSM); + this->displayImage(IMAGE_VIIRSM, true); this->kindofimage = "VIIRSM"; this->setSegmentType(SEG_VIIRSM); bandlist = formtoolbox->getVIIRSMBandList(); @@ -675,7 +580,7 @@ void FormImage::MakeImage() segs->seglviirsdnb->graphvalues[i] = 0; - this->displayImage(IMAGE_VIIRSDNB); + this->displayImage(IMAGE_VIIRSDNB, true); this->kindofimage = "VIIRSDNB"; this->setSegmentType(SEG_VIIRSDNB); @@ -707,7 +612,7 @@ void FormImage::MakeImage() formtoolbox->setToolboxButtons(false); - this->displayImage(IMAGE_VIIRSM); + this->displayImage(IMAGE_VIIRSM, true); this->kindofimage = "VIIRSM"; this->setSegmentType(SEG_VIIRSMNOAA20); bandlist = formtoolbox->getVIIRSMBandList(); @@ -726,7 +631,7 @@ void FormImage::MakeImage() segs->seglviirsdnbnoaa20->graphvalues[i] = 0; - this->displayImage(IMAGE_VIIRSDNB); + this->displayImage(IMAGE_VIIRSDNB, true); this->kindofimage = "VIIRSDNB"; this->setSegmentType(SEG_VIIRSDNBNOAA20); @@ -778,7 +683,7 @@ void FormImage::MakeImage() formtoolbox->setToolboxButtons(false); imageptrs->olcitype = SEG_OLCIEFR; - this->displayImage(IMAGE_OLCI); + this->displayImage(IMAGE_OLCI, true); this->kindofimage = "OLCIEFR"; this->setSegmentType(SEG_OLCIEFR); @@ -844,7 +749,7 @@ void FormImage::MakeImage() formtoolbox->setToolboxButtons(false); imageptrs->olcitype = SEG_OLCIERR; - this->displayImage(IMAGE_OLCI); + this->displayImage(IMAGE_OLCI, true); this->kindofimage = "OLCIERR"; this->setSegmentType(SEG_OLCIERR); @@ -908,7 +813,7 @@ void FormImage::MakeImage() formtoolbox->setToolboxButtons(false); - this->displayImage(IMAGE_SLSTR); + this->displayImage(IMAGE_SLSTR, true); this->kindofimage = "SLSTR"; this->setSegmentType(SEG_SLSTR); @@ -969,7 +874,7 @@ void FormImage::MakeImage() formtoolbox->setToolboxButtons(false); - this->displayImage(IMAGE_MERSI); + this->displayImage(IMAGE_MERSI, true); this->kindofimage = "MERSI"; this->setSegmentType(SEG_MERSI); @@ -980,3993 +885,2966 @@ void FormImage::MakeImage() int histogrammethod = formtoolbox->getMERSIHistogrammethod(); bool normalized = false; - // in Workerthread + // in Workerthread segs->seglmersi->ComposeMERSIImage(bandlist, colorlist, invertlist, false, histogrammethod, normalized); } else return; } -bool FormImage::ShowVIIRSMImage() +void FormImage::setPixmapToScene(bool settoolboxbuttons) { - bool ret = false; - if(opts.buttonVIIRSM) - viirsmcount = segs->seglviirsm->NbrOfSegmentsSelected(); - else if(opts.buttonVIIRSMNOAA20) - viirsmcount = segs->seglviirsmnoaa20->NbrOfSegmentsSelected(); + qDebug() << "FormImage::setPixmapToScene(bool settoolboxbuttons) channelshown = " << channelshown; - QList bandlist; - QList colorlist; - QList invertlist; + resetView(); - qDebug() << QString("in FormImage::ShowVIIRSImage nbr of viirs segments selected = %1").arg(viirsmcount); + emit allsegmentsreceivedbuttons(settoolboxbuttons); + emit setmapcylbuttons(true); - if (viirsmcount > 0) + switch(channelshown) { + case IMAGE_AVHRR_CH1: + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[0]; + formtoolbox->setOMimagesize(m_image->width(), m_image->height()); + break; + case IMAGE_AVHRR_CH2: + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[1]; + formtoolbox->setOMimagesize(m_image->width(), m_image->height()); + break; + case IMAGE_AVHRR_CH3: + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[2]; + formtoolbox->setOMimagesize(m_image->width(), m_image->height()); + break; + case IMAGE_AVHRR_CH4: + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[3]; + formtoolbox->setOMimagesize(m_image->width(), m_image->height()); + break; + case IMAGE_AVHRR_CH5: + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[4]; + formtoolbox->setOMimagesize(m_image->width(), m_image->height()); + break; + case IMAGE_AVHRR_COL: + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_col; + formtoolbox->setOMimagesize(m_image->width(), m_image->height()); + break; + case IMAGE_AVHRR_EXPAND: + displayAVHRRImageInfo(); + m_image = imageptrs->ptrexpand_col; + break; + case IMAGE_GEOSTATIONARY: + displayGeoImageInfo(); + m_image = imageptrs->ptrimageGeostationary; + break; + case IMAGE_PROJECTION: + formtoolbox->writeInfoToTextEdit(""); + m_image = imageptrs->ptrimageProjection; + break; + case IMAGE_VIIRSM: + displayVIIRSImageInfo(segmenttype); + m_image = imageptrs->ptrimageViirsM; + formtoolbox->setOMimagesize(imageptrs->ptrimageViirsM->width(), imageptrs->ptrimageViirsM->height()); + break; + case IMAGE_VIIRSDNB: + displayVIIRSImageInfo(segmenttype); + m_image = imageptrs->ptrimageViirsDNB; + formtoolbox->setOMimagesize(imageptrs->ptrimageViirsDNB->width(), imageptrs->ptrimageViirsDNB->height()); + break; + case IMAGE_OLCI: + displaySentinelImageInfo(SEG_OLCIEFR); + m_image = imageptrs->ptrimageOLCI; + break; + case IMAGE_SLSTR: + displaySentinelImageInfo(SEG_SLSTR); + m_image = imageptrs->ptrimageSLSTR; + break; + case IMAGE_MERSI: + displayMERSIImageInfo(SEG_MERSI); + m_image = imageptrs->ptrimageMERSI; + formtoolbox->setOMimagesize(imageptrs->ptrimageMERSI->width(), imageptrs->ptrimageMERSI->height()); + break; + case IMAGE_NONE: + return; - ret = true; - displayImage(IMAGE_VIIRSM); + } - emit allsegmentsreceivedbuttons(false); + m_pixmap = QPixmap::fromImage(*m_image); + m_pixmapItem = m_scene->addPixmap(m_pixmap); + m_scene->setSceneRect(m_pixmap.rect()); + this->centerOn(m_pixmapItem); - this->kindofimage = "VIIRSM"; + m_ViewInitialized = true; - bandlist = formtoolbox->getVIIRSMBandList(); - colorlist = formtoolbox->getVIIRSMColorList(); - invertlist = formtoolbox->getVIIRSMInvertList(); + fitWindow(); + this->setDragMode(ScrollHandDrag); - if(opts.buttonVIIRSM) - segs->seglviirsm->ShowImageSerial(bandlist, colorlist, invertlist); - else if(opts.buttonVIIRSMNOAA20) - segs->seglviirsmnoaa20->ShowImageSerial(bandlist, colorlist, invertlist); - } - else - ret = false; - return ret; + QApplication::processEvents(); -} + qDebug() << QString("FormImage::setPixmapToScene() channelshown = %1").arg(this->channelshown); +} -bool FormImage::ShowOLCIefrImage(int histogrammethod, bool normalized) +void FormImage::displayImage(eImageType channel, bool resize) { - bool ret = false; - - olciefrcount = segs->seglolciefr->NbrOfSegmentsSelected(); - - QList bandlist; - QList colorlist; - QList invertlist; - - qDebug() << QString("in FormImage::ShowOLCIefrImage nbr of olci efr segments selected = %1").arg(olciefrcount); - if (olciefrcount > 0) - { + qDebug() << QString("FormImage::displayImage(eImageType channel) channel = %1").arg(channel); + // qDebug() << QString("FormImage ptrimagecomp[0] bytecount = %1").arg(imageptrs->ptrimagecomp_ch[0]->byteCount()); + // qDebug() << QString("FormImage ptrimageviirsm bytecount = %1").arg(imageptrs->ptrimageViirsM->byteCount()); + // qDebug() << QString("FormImage ptrimageviirsdnb bytecount = %1").arg(imageptrs->ptrimageViirsDNB->byteCount()); + // qDebug() << QString("FormImage ptrimageolci bytecount = %1").arg(imageptrs->ptrimageOLCI->byteCount()); + // qDebug() << QString("FormImage ptrimageslstr bytecount = %1").arg(imageptrs->ptrimageSLSTR->byteCount()); + // qDebug() << QString("FormImage ptrimagemersi bytecount = %1").arg(imageptrs->ptrimageMERSI->byteCount()); - // ret = true; - // displayImage(IMAGE_OLCI); + this->channelshown = channel; - // emit allsegmentsreceivedbuttons(false); + QPixmap pm(800, 200); + pm.fill(Qt::red); + QPainter painter(&pm); - this->kindofimage = "OLCIEFR"; + QFont f("Courier", 20, QFont::Bold); + painter.setFont(f); + painter.setPen(Qt::yellow); + QFontMetrics fm(f); - bandlist = formtoolbox->getOLCIBandList(); - colorlist = formtoolbox->getOLCIColorList(); - invertlist = formtoolbox->getOLCIInvertList(); + if(ptrimagebusy) + { + QString str("Calculating image busy"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + resetView(); - QStringList missing; - segs->seglolciefr->setHistogramMethod(histogrammethod, normalized); - if(segs->seglolciefr->CheckForOLCIFiles(bandlist, colorlist, missing) == false) // parameter false = no decompression of the files + switch(channelshown) { - formtoolbox->setToolboxButtons(true); - - emit setmapcylbuttons(true); + case IMAGE_NONE: + break; - QMessageBox msgBox; - QString txt = "In one or more segments, the following files are missing : \n"; - for(int i = 0; i < missing.count(); i++) + case IMAGE_AVHRR_CH1: + if(imageptrs->ptrimagecomp_ch[0]->sizeInBytes() == 0) { - txt.append(missing.at(i) + "\n"); + QString str("No AVHRR image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; } - msgBox.setText(txt); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - int ret = msgBox.exec(); - - switch (ret) { - case QMessageBox::Ok: - break; - default: - break; + else + { + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[0]; + m_pixmap = QPixmap::fromImage(*m_image); } - return false; - } - else - segs->seglolciefr->ComposeOLCIImage(bandlist, colorlist, invertlist, false, histogrammethod, normalized); - - } - else - ret = false; - - return ret; - -} + break; + case IMAGE_AVHRR_CH2: + if(imageptrs->ptrimagecomp_ch[1]->sizeInBytes() == 0) + { + QString str("No AVHRR image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[1]; + m_pixmap = QPixmap::fromImage(*m_image); + } + break; + case IMAGE_AVHRR_CH3: + if(imageptrs->ptrimagecomp_ch[2]->sizeInBytes() == 0) + { + QString str("No AVHRR image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[2]; + m_pixmap = QPixmap::fromImage(*m_image); + } + break; + case IMAGE_AVHRR_CH4: + if(imageptrs->ptrimagecomp_ch[3]->sizeInBytes() == 0) + { + QString str("No AVHRR image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[3]; + m_pixmap = QPixmap::fromImage(*m_image); + } + break; + case IMAGE_AVHRR_CH5: + if(imageptrs->ptrimagecomp_ch[4]->sizeInBytes() == 0) + { + QString str("No AVHRR image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_ch[4]; + m_pixmap = QPixmap::fromImage(*m_image); + } + break; + case IMAGE_AVHRR_COL: + if(imageptrs->ptrimagecomp_col->sizeInBytes() == 0) + { + QString str("No AVHRR image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + displayAVHRRImageInfo(); + m_image = imageptrs->ptrimagecomp_col; + m_pixmap = QPixmap::fromImage(*m_image); + } + break; + case IMAGE_AVHRR_EXPAND: + if(imageptrs->ptrexpand_col->sizeInBytes() == 0) + { + QString str("No AVHRR image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + displayAVHRRImageInfo(); + m_image = imageptrs->ptrexpand_col; + m_pixmap = QPixmap::fromImage(*m_image); + } + break; + case IMAGE_GEOSTATIONARY: + if(imageptrs->ptrimageGeostationary->sizeInBytes() == 0) + { + QString str("No geostationary image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + displayGeoImageInfo(); + m_image = imageptrs->ptrimageGeostationary; + m_pixmap = QPixmap::fromImage(*m_image); + } + break; + case IMAGE_PROJECTION: + if(imageptrs->ptrimageProjection->sizeInBytes() == 0) + { + QString str("No Projection image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + //formtoolbox->writeInfoToTextEdit("Projection image"); + m_image = imageptrs->ptrimageProjection; + m_pixmap = QPixmap::fromImage(*m_image); + } + break; + case IMAGE_VIIRSM: + if(imageptrs->ptrimageViirsM->sizeInBytes() == 0) + { + QString str("No VIIRS M image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + m_image = imageptrs->ptrimageViirsM; + m_pixmap = QPixmap::fromImage(*m_image); + if(segmenttype == eSegmentType::SEG_VIIRSM) + displayVIIRSImageInfo(SEG_VIIRSM); + else if(segmenttype == eSegmentType::SEG_VIIRSMNOAA20) + displayVIIRSImageInfo(SEG_VIIRSMNOAA20); + } + break; + case IMAGE_VIIRSDNB: + if(imageptrs->ptrimageViirsDNB->sizeInBytes() == 0) + { + QString str("No VIIRS DNB image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + m_image = imageptrs->ptrimageViirsDNB; + m_pixmap = QPixmap::fromImage(*m_image); + if(segmenttype == eSegmentType::SEG_VIIRSDNB) + displayVIIRSImageInfo(SEG_VIIRSDNB); + else if(segmenttype == eSegmentType::SEG_VIIRSDNBNOAA20) + displayVIIRSImageInfo(SEG_VIIRSDNBNOAA20); + } + break; + case IMAGE_OLCI: + if(imageptrs->ptrimageOLCI->sizeInBytes() == 0) + { + QString str("No OLCI image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + m_image = imageptrs->ptrimageOLCI; + m_pixmap = QPixmap::fromImage(*m_image); + this->displaySentinelImageInfo(imageptrs->olcitype); + } + break; + case IMAGE_SLSTR: + if(imageptrs->ptrimageSLSTR->sizeInBytes() == 0) + { + QString str("No SLSTR image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + m_image = imageptrs->ptrimageSLSTR; + m_pixmap = QPixmap::fromImage(*m_image); + this->displaySentinelImageInfo(SEG_SLSTR); + } + break; + case IMAGE_MERSI: + if(imageptrs->ptrimageMERSI->sizeInBytes() == 0) + { + QString str("No MERSI image"); + int pixelsWide = fm.horizontalAdvance(str); + painter.drawText((pm.width() - pixelsWide)/2, pm.height()/2, str); + m_pixmap = pm; + } + else + { + m_image = imageptrs->ptrimageMERSI; + m_pixmap = QPixmap::fromImage(*m_image); + this->displayMERSIImageInfo(SEG_MERSI); + } + break; -bool FormImage::ShowOLCIerrImage(int histogrammethod, bool normalized) -{ - bool ret = false; + } + } - olcierrcount = segs->seglolcierr->NbrOfSegmentsSelected(); + m_pixmapItem = m_scene->addPixmap(m_pixmap); + m_scene->setSceneRect(m_pixmap.rect()); + this->centerOn(m_pixmapItem); - QList bandlist; - QList colorlist; - QList invertlist; + m_ViewInitialized = true; - qDebug() << QString("in FormImage::ShowOLCIerrImage nbr of olci err segments selected = %1").arg(olcierrcount); + if(resize) + fitWindow(); + this->setDragMode(ScrollHandDrag); - if (olcierrcount > 0) - { +} - ret = true; - displayImage(IMAGE_OLCI); +void FormImage::displayAVHRRImageInfo() +{ + QString segtype; + eSegmentType type; + int nbrselected; - emit allsegmentsreceivedbuttons(false); + type = getSegmentType(); + switch(type) + { + case SEG_NONE: + segtype = "None"; + break; + case SEG_METOP: + segtype = "Metop"; + break; + case SEG_NOAA19: + segtype = "Noaa"; + break; + case SEG_HRP: + segtype = "HRP"; + break; + case SEG_GAC: + segtype = "GAC"; + break; + case SEG_HRPT_METOPA: + segtype = "Metop A HRPT"; + break; + case SEG_HRPT_METOPB: + segtype = "Metop B HRPT"; + break; + case SEG_HRPT_NOAA19: + segtype = "Noaa 19 HRPT"; + break; + case SEG_HRPT_M01: + segtype = "Metop B HRPT"; + break; + case SEG_HRPT_M02: + segtype = "Metop A HRPT"; + break; + default: + segtype = "NA"; + break; + } - this->kindofimage = "OLCIERR"; + if (type == SEG_NOAA19) + nbrselected = segs->seglnoaa->NbrOfSegmentsSelected(); + else if( type == SEG_METOP) + nbrselected = segs->seglmetop->NbrOfSegmentsSelected(); + else if( type == SEG_GAC) + nbrselected = segs->seglgac->NbrOfSegmentsSelected(); + else if( type == SEG_HRP) + nbrselected = segs->seglhrp->NbrOfSegmentsSelected(); + else if( type == SEG_HRPT_METOPA) + nbrselected = segs->seglmetopAhrpt->NbrOfSegmentsSelected(); + else if( type == SEG_HRPT_METOPB) + nbrselected = segs->seglmetopBhrpt->NbrOfSegmentsSelected(); + else if( type == SEG_HRPT_NOAA19) + nbrselected = segs->seglnoaa19hrpt->NbrOfSegmentsSelected(); + else if( type == SEG_HRPT_M01) + nbrselected = segs->seglM01hrpt->NbrOfSegmentsSelected(); + else if( type == SEG_HRPT_M02) + nbrselected = segs->seglM02hrpt->NbrOfSegmentsSelected(); - bandlist = formtoolbox->getOLCIBandList(); - colorlist = formtoolbox->getOLCIColorList(); - invertlist = formtoolbox->getOLCIInvertList(); + txtInfo = QString("" + "Info" + "" + "

Image Information

" + "

Segment type = %1
" + "Nbr of segments = %2
" + "Image width = %3 height = %4
" + "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimagecomp_col->width()).arg(imageptrs->ptrimagecomp_col->height()); - QStringList missing; - segs->seglolcierr->setHistogramMethod(histogrammethod, normalized); - if(segs->seglolcierr->CheckForOLCIFiles(bandlist, colorlist, missing) == false) - { - formtoolbox->setToolboxButtons(true); - emit setmapcylbuttons(true); + formtoolbox->writeInfoToTextEdit(txtInfo); - QMessageBox msgBox; - QString txt = "In one or more segments, the following files are missing : \n"; - for(int i = 0; i < missing.count(); i++) - { - txt.append(missing.at(i) + "\n"); - } - msgBox.setText(txt); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - int ret = msgBox.exec(); +} - switch (ret) { - case QMessageBox::Ok: - break; - default: - break; - } - return false; - } - else - segs->seglolcierr->ComposeOLCIImage(bandlist, colorlist, invertlist, false, histogrammethod, normalized); +//void FormImage::setupGeoOverlay(int geoindex) +//{ - } - else - ret = false; +// int col, save_col; +// int row, save_row; +// bool first = true; - return ret; +// double lat_deg; +// double lon_deg; +// int ret; +// double sub_lon; -} +// double fgf_x, fgf_y; -bool FormImage::ShowSLSTRImage(int histogrammethod) -{ - bool ret = false; +// pixgeoConversion pixconv; - slstrcount = segs->seglslstr->NbrOfSegmentsSelected(); +// sub_lon = opts.geosatellites.at(geoindex).longitude; - QList bandlist; - QList colorlist; - QList invertlist; +// for(int i = 0; i < 3; i++) +// this->geooverlay[i].clear(); - qDebug() << QString("in FormImage::ShowSLSTRImage nbr of slstr segments selected = %1").arg(slstrcount); +// double scale_x = 0.000056; +// double scale_y = -0.000056; +// double offset_x = -0.151844; +// double offset_y = 0.151844; +// int sat = 1; - if (slstrcount > 0) - { - - ret = true; - displayImage(IMAGE_SLSTR); - - emit allsegmentsreceivedbuttons(false); - - this->kindofimage = "SLSTR"; - - bandlist = formtoolbox->getSLSTRBandList(); - colorlist = formtoolbox->getSLSTRColorList(); - invertlist = formtoolbox->getSLSTRInvertList(); - segs->seglslstr->setHistogramMethod(histogrammethod); - segs->seglslstr->ComposeSLSTRImage(bandlist, colorlist, invertlist, false, formtoolbox->getSLSTRImageView()); - } - else - ret = false; +// for(int k = 0; k < 3; k++) +// { +// if(opts.gshhsglobe1On) +// { +// first = true; + +// for (int i=0; ivxp_data_overlay[k]->nFeatures; i++) +// { +// for (int j=0; jvxp_data_overlay[k]->pFeatures[i].nVerts; j++) +// { +// lat_deg = gshhsdata->vxp_data_overlay[k]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; +// lon_deg = gshhsdata->vxp_data_overlay[k]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; +// if (lon_deg > 180.0) +// lon_deg -= 360.0; + +// if(lon_deg < 90.0 || lon_deg > -90.0) +// { +// if(opts.geosatellites.at(geoindex).shortname == "GOES_16" || opts.geosatellites.at(geoindex).shortname == "GOES_17") +// { +// pixconv.earth_to_fgf_(&sat, &lon_deg, &lat_deg, &scale_x, &offset_x, &scale_y, &offset_y, &sub_lon, &fgf_x, &fgf_y); +// if(fgf_x >= 0 && fgf_x < opts.geosatellites.at(geoindex).imagewidth && fgf_y >= 0 && fgf_y < opts.geosatellites.at(geoindex).imageheight) +// { +// col = (int)fgf_x; +// row = (int)fgf_y; +// ret = 0; +// } +// else +// ret = 1; +// } +// else +// { +// ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, opts.geosatellites.at(geoindex).coff, +// opts.geosatellites.at(geoindex).loff, opts.geosatellites.at(geoindex).cfac, opts.geosatellites.at(geoindex).lfac, &col, &row); + +// } +// if(ret == 0) +// { +// if (first) +// { +// first = false; +// save_col = col; +// save_row = row; +// this->geooverlay[k].append(QVector2D(-1, -1)); +// } +// else +// { +// save_col = col; +// save_row = row; +// } + +// this->geooverlay[k].append(QVector2D(col, row)); + +// } +// else +// first = true; +// } +// } +// first = true; +// } +// } +// } +//} - return ret; +void FormImage::setupGeoOverlay(int geoindex) +{ + for(int i = 0; i < 3; i++) + this->geooverlay[i].clear(); -} -bool FormImage::ShowHistogramImageOLCI(int histogrammethod, bool normalized) -{ - int olciefrcount = segs->seglolciefr->NbrOfSegmentsSelected(); - int olcierrcount = segs->seglolcierr->NbrOfSegmentsSelected(); + if(opts.gshhsglobe1On) + setupGshhs(geoindex, 0); + if(opts.gshhsglobe2On) + setupGshhs(geoindex, 1); + if(opts.gshhsglobe3On) + setupGshhs(geoindex, 2); - if(olciefrcount > 0) - { - segs->seglolciefr->setHistogramMethod(histogrammethod, normalized); - segs->seglolciefr->ChangeHistogramMethod(); - return true; - } - else if(olcierrcount > 0) - { - segs->seglolcierr->setHistogramMethod(histogrammethod, normalized); - segs->seglolcierr->ChangeHistogramMethod(); - return true; - } - return false; } -bool FormImage::ShowHistogramImageSLSTR(int histogrammethod) +void FormImage::setupGshhs(int geoindex, int k) { - int slstrcount = segs->seglslstr->NbrOfSegmentsSelected(); + bool first = true; + double lat_deg; + double lon_deg; + int ret; + pixgeoConversion pixconv; + int col, save_col; + int row, save_row; + double sub_lon; + double fgf_x, fgf_y; - if(slstrcount > 0) - { - segs->seglslstr->setHistogramMethod(histogrammethod); - segs->seglslstr->ChangeHistogramMethod(); - return true; - } - else - return false; -} + double scale_x = 0.000056; + double scale_y = -0.000056; + double offset_x = -0.151844; + double offset_y = 0.151844; + int sat = 1; -bool FormImage::ShowVIIRSDNBImage() -{ - bool ret = false; + sub_lon = opts.geosatellites.at(geoindex).longitude; - viirsdnbcount = segs->seglviirsdnb->NbrOfSegmentsSelected(); + if(!(opts.geosatellites.at(geoindex).shortname == "GOES_16" || opts.geosatellites.at(geoindex).shortname == "GOES_17" || + opts.geosatellites.at(geoindex).shortname == "FY2H" || opts.geosatellites.at(geoindex).shortname == "FY2G")) + geoindex = 11; - qDebug() << QString("in FormImage::ShowVIIRSDNBImage nbr of viirs segments selected = %1").arg(viirsdnbcount); - if (viirsdnbcount > 0) + for (int i=0; ivxp_data_overlay[k]->nFeatures; i++) { - ret = true; - displayImage(IMAGE_VIIRSDNB); - - emit allsegmentsreceivedbuttons(false); + for (int j=0; jvxp_data_overlay[k]->pFeatures[i].nVerts; j++) + { + lat_deg = gshhsdata->vxp_data_overlay[k]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; + lon_deg = gshhsdata->vxp_data_overlay[k]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; + if (lon_deg > 180.0) + lon_deg -= 360.0; - this->kindofimage = "VIIRSDNB"; + if(lon_deg < 90.0 || lon_deg > -90.0) + { + if(opts.geosatellites.at(geoindex).shortname == "GOES_16" || opts.geosatellites.at(geoindex).shortname == "GOES_17") + { + pixconv.earth_to_fgf_(&sat, &lon_deg, &lat_deg, &scale_x, &offset_x, &scale_y, &offset_y, &sub_lon, &fgf_x, &fgf_y); + if(fgf_x >= 0 && fgf_x < opts.geosatellites.at(geoindex).imagewidth && fgf_y >= 0 && fgf_y < opts.geosatellites.at(geoindex).imageheight) + { + col = (int)fgf_x; + row = (int)fgf_y; + ret = 0; + } + else + ret = 1; + } + else + { + ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, opts.geosatellites.at(geoindex).coff, + opts.geosatellites.at(geoindex).loff, opts.geosatellites.at(geoindex).cfac, opts.geosatellites.at(geoindex).lfac, &col, &row); - segs->seglviirsdnb->ShowImageSerial(); - } - else - ret = false; + } + if(ret == 0) + { + if (first) + { + first = false; + save_col = col; + save_row = row; + this->geooverlay[k].append(QVector2D(-1, -1)); + } + else + { + save_col = col; + save_row = row; + } - return ret; + this->geooverlay[k].append(QVector2D(col, row)); + } + else + first = true; + } + } + first = true; + } } - -bool FormImage::ShowMERSIImage(int histogrammethod, bool normalized) +void FormImage::drawForeground(QPainter *painter, const QRectF &rect) { - bool ret = false; - - mersicount = segs->seglmersi->NbrOfSegmentsSelected(); - - QList bandlist; - QList colorlist; - QList invertlist; - - qDebug() << QString("in FormImage::ShowMERSIImage nbr of mersi segments selected = %1").arg(mersicount); - - if (mersicount > 0) - { - - ret = true; - displayImage(IMAGE_MERSI); - emit allsegmentsreceivedbuttons(false); + qDebug() << "BEFORE FormImage::drawForeground ViewInitialized = " << m_ViewInitialized; - this->kindofimage = "MERSI"; + if(!m_ViewInitialized) + return; - bandlist = formtoolbox->getMERSIBandList(); // 16 items - colorlist = formtoolbox->getMERSIColorList(); // 15 items - invertlist = formtoolbox->getMERSIInvertList(); + if(m_image == NULL) + return; - // qDebug()<< "FormImage::ShowMERSIImage() bandlist"; - // for(int i = 0; i < 16; i++) - // { - // qDebug() << bandlist.at(i); - // } + if(m_image->isNull()) + return; - // qDebug()<< "FormImage::ShowMERSIImage() colorlist"; - // for(int i = 0; i < 15; i++) - // { - // qDebug() << colorlist.at(i); - // } + drawOverlays(painter); - segs->seglmersi->setHistogramMethod(histogrammethod, normalized); - segs->seglmersi->ComposeMERSIImage(bandlist, colorlist, invertlist, false, histogrammethod, normalized); - } - else - ret = false; +// painter->translate(m_image->width()/2, m_image->height()/2); - return ret; -} +// int diameter = 3580; +// painter->setPen(QPen(QColor(255, 0, 0), 1)); +// painter->drawEllipse(QRect(-diameter / 2, -diameter / 2, diameter, diameter)); -void FormImage::mousePressEvent(QMouseEvent *e) -{ - if(e->button() == Qt::LeftButton) - { - mousepoint = e->pos(); - this->setCursor(Qt::ClosedHandCursor); - } -} +// diameter = 3650; +// painter->setPen(QPen(QColor(0, 255, 255), 1)); +// painter->drawEllipse(QRect(-diameter / 2, -diameter / 2, diameter, diameter)); -void FormImage::mouseMoveEvent(QMouseEvent *e) -{ - if(e->buttons() == Qt::LeftButton) - { - emit moveImage(e->pos(), mousepoint); - } -} +// diameter = 3615; +// painter->setPen(QPen(QColor(0, 0, 255), 30)); +// painter->drawEllipse(QRect(-diameter / 2, -diameter / 2, diameter, diameter)); -void FormImage::mouseReleaseEvent(QMouseEvent *) -{ - setCursor(Qt::ArrowCursor); -} -void FormImage::wheelEvent(QWheelEvent *event) -{ + qDebug() << "AFTER FormImage::drawForeground"; - //QTimer::singleShot(5100, this, SLOT(zoomOverlaySwitch())); - QPoint numDegrees = event->angleDelta() / 8; - QPoint numSteps = numDegrees / 15; - if(numSteps.y() > 0) - formwheelZoom(1); - if(numSteps.y() < 0) - formwheelZoom(-1); } -void FormImage::formwheelZoom(int d) +void FormImage::savePNGImage(QString fileName) { - if(d > 0){ - this->makeZoom(getZoomValue() + zoomIncrement); - } - if(d < 0){ - this->makeZoom(getZoomValue() - zoomIncrement); - } + QImage image_copy = m_image->copy(); + QPainter painter(&image_copy); + painter.setRenderHint(QPainter::SmoothPixmapTransform); -} -void FormImage::makeZoom(double f) -{ - if(f <= maxZoomValue && f >= minZoomValue) - { - setZoomValue(f); - scaleFactor = f/100; - //this->adjustImage(); + painter.begin(&image_copy); + //getScene()->render(&painter, m_image->rect() ); - QString windowTitleFormat = QString("EUMETCastView zoomLevel"); - windowTitleFormat.replace("zoomLevel", QString("%1%").arg((int)(f))); - this->topLevelWidget()->setWindowTitle(windowTitleFormat); - } -} + drawOverlays(&painter); -void FormImage::setZoomValue(int z) -{ - switch(channelshown) - { - case IMAGE_AVHRR_CH1: - case IMAGE_AVHRR_CH2: - case IMAGE_AVHRR_CH3: - case IMAGE_AVHRR_CH4: - case IMAGE_AVHRR_CH5: - case IMAGE_AVHRR_COL: - case IMAGE_AVHRR_EXPAND: - zoomValueavhrr = z; - opts.zoomfactoravhrr = z; - break; - case IMAGE_GEOSTATIONARY: - zoomValuemeteosat = z; - opts.zoomfactormeteosat = z; - break; - case IMAGE_PROJECTION: - zoomValueprojection = z; - opts.zoomfactorprojection = z; - break; - case IMAGE_VIIRSM: - case IMAGE_VIIRSDNB: - zoomValueviirs = z; - opts.zoomfactorviirs = z; - break; - case IMAGE_OLCI: - zoomValueolci = z; - opts.zoomfactorolci = z; - break; - case IMAGE_SLSTR: - zoomValueslstr = z; - opts.zoomfactorslstr = z; - break; - case IMAGE_MERSI: - zoomValuemersi = z; - opts.zoomfactormersi = z; - break; + painter.end(); - } -} + image_copy.save(fileName); -int FormImage::getZoomValue() -{ - int zoomValue; - switch(channelshown) - { - case IMAGE_AVHRR_CH1: - case IMAGE_AVHRR_CH2: - case IMAGE_AVHRR_CH3: - case IMAGE_AVHRR_CH4: - case IMAGE_AVHRR_CH5: - case IMAGE_AVHRR_COL: - case IMAGE_AVHRR_EXPAND: - zoomValue = zoomValueavhrr; - break; - case IMAGE_GEOSTATIONARY: - zoomValue = zoomValuemeteosat; - break; - case IMAGE_PROJECTION: - zoomValue = zoomValueprojection; - break; - case IMAGE_VIIRSM: - case IMAGE_VIIRSDNB: - zoomValue = zoomValueviirs; - break; - case IMAGE_OLCI: - zoomValue = zoomValueolci; - break; - case IMAGE_SLSTR: - zoomValue = zoomValueslstr; - break; - case IMAGE_MERSI: - zoomValue = zoomValuemersi; - break; - } - return zoomValue; } -/* -void FormImage::zoomOverlaySwitch() +void FormImage::drawOverlays(QPainter *painter) { - overlayzoommove = true; - this->update(); -} -*/ - -//void FormImage::paintEvent( QPaintEvent *event ) -//{ - -// if (imageLabel->pixmap() == 0) -// return; - -// QPixmap *pix; -// pix=(QPixmap *)imageLabel->pixmap(); - -// if(pix->height() == 0) -// return; - -// if (imageLabel->pixmap() == 0) -// return; - -//// QPixmap pixval; -//// pixval = imageLabel->pixmap(Qt::ReturnByValue); + qDebug() << "FormImage::drawOverlays(QPainter *painter)"; -//// if(pixval.height() == 0) -//// return; + painter->setPen(opts.geoimageoverlaycolor1); + //painter->drawRect(QRect(0, 0, 3711, 3711)); + QFont font = painter->font(); -// //pix=imageLabel->pixmap(); -// //pix=QPixmap::fromImage(*(imageptrs->ptrimageMeteosat)); -// QPainter painter(pix); -//// qDebug() << "FormImage::paintEvent( QPaintEvent * )"; - -//// if(channelshown >= 1 && channelshown <= 8) -//// { -//// QFont f("Courier", 40, QFont::Bold); -//// painter.setFont(f); -//// painter.setPen(Qt::yellow); -//// painter.drawText(10, 50, QString("%1 %2").arg(mousepoint.x()).arg(mousepoint.y())); -//// } + SegmentListGeostationary *slgeo = NULL; + slgeo = segs->getActiveSegmentList(); -// SegmentListGeostationary *slgeo = NULL; + if (channelshown == IMAGE_GEOSTATIONARY && overlaymeteosat) + { + if(slgeo != NULL) + { + if(this->m_image == NULL) + return; -// slgeo = segs->getActiveSegmentList(); + if(m_image->width() <= 3712) + font.setPixelSize(50); + else if(m_image->width() == 5568) + font.setPixelSize(100); + else if(m_image->width() > 9000) + font.setPixelSize(150); + else + font.setPixelSize(100); -// if(channelshown == IMAGE_GEOSTATIONARY) -// displayGeoImageInfo(); + painter->setFont(font); + painter->drawText(0, font.pixelSize(), slgeo->geosatname); + QStringList rowchosen = formtoolbox->getRowchosen(); + QVector spectrumvector = formtoolbox->getSpectrumVector(); + QVector inversevector = formtoolbox->getInverseVector(); +// painter->drawText(m_image->width() - (font.pixelSize() == 50 ? 200 : 600), font.pixelSize(), spectrumvector.at(0)); +// painter->drawText(m_image->width() - (font.pixelSize() == 50 ? 200 : 600), 2 * font.pixelSize(), spectrumvector.at(1)); +// painter->drawText(m_image->width() - (font.pixelSize() == 50 ? 200 : 600), 3 * font.pixelSize(), spectrumvector.at(2)); -// if (channelshown == IMAGE_GEOSTATIONARY && overlaymeteosat && refreshoverlay) -// { -// if(slgeo != NULL) -// { -// this->OverlayGeostationary(&painter, slgeo); -// refreshoverlay = false; -// } -// } -// if(channelshown == IMAGE_PROJECTION && overlayprojection && refreshoverlay) -// { -// this->OverlayProjection(&painter); -// refreshoverlay = false; -// } + QFontMetrics fm(font); + int pixelsWide = fm.horizontalAdvance(spectrumvector.at(0)); + int pixelsHigh = fm.height(); -// if(channelshown == IMAGE_OLCI && overlayolci && refreshoverlay) -// { -// this->OverlayOLCI(&painter); -// refreshoverlay = false; -// } + painter->drawText(m_image->width() - pixelsWide, font.pixelSize(), spectrumvector.at(0)); + painter->drawText(m_image->width() - pixelsWide, 2 * font.pixelSize(), spectrumvector.at(1)); + painter->drawText(m_image->width() - pixelsWide, 3 * font.pixelSize(), spectrumvector.at(2)); -// if(channelshown == IMAGE_PROJECTION && changeinfraprojection) -// { -// changeinfraprojection = false; -// } + // "2023-06-02 07:15" + if(!rowchosen.isEmpty()) + { + painter->drawText(0, 2 * font.pixelSize(), rowchosen[0] ); + } -// this->adjustImage(); + this->OverlayGeostationary(painter, slgeo); + } + } + if(channelshown == IMAGE_PROJECTION && overlayprojection) + { + this->OverlayProjection(painter); + } -//} + if(channelshown == IMAGE_OLCI && overlayolci) + { + this->OverlayOLCI(painter); + } +} -void FormImage::paintEvent( QPaintEvent *event ) +void FormImage::OverlayGeostationary(QPainter *paint, SegmentListGeostationary *sl) { + if(m_image == NULL){ + qDebug() << "m_image is null"; + return; + } - QPixmap pixval; - pixval = imageLabel->pixmap(Qt::ReturnByValue); + qDebug() << "FormImage::OverlayGeostationary(QPainter *paint, SegmentListGeostationary *sl) image width = " << m_image->width(); + // "getGeoSatellite = " << sl->getGeoSatellite(); - if(pixval.height() == 0) + if(sl == NULL) return; + pixgeoConversion pixconv; - //pix=imageLabel->pixmap(); - //pix=QPixmap::fromImage(*(imageptrs->ptrimageMeteosat)); - QPainter painter(&pixval); + int col, save_col; + int row, save_row; + bool first = true; -// qDebug() << "FormImage::paintEvent( QPaintEvent * )"; + double lat_deg; + double lon_deg; + int ret; + bool hrvimage; -// if(channelshown >= 1 && channelshown <= 8) -// { -// QFont f("Courier", 40, QFont::Bold); -// painter.setFont(f); -// painter.setPen(Qt::yellow); -// painter.drawText(10, 50, QString("%1 %2").arg(mousepoint.x()).arg(mousepoint.y())); -// } + long coff; + long loff; + double cfac; + double lfac; + int geoindex = sl->getGeoSatelliteIndex(); - SegmentListGeostationary *slgeo = NULL; + if(sl != NULL) + { + if(sl->getKindofImage() == "HRV" || sl->getKindofImage() == "HRV Color") + hrvimage = true; + else + hrvimage = false; - slgeo = segs->getActiveSegmentList(); + // if(sl->getGeoSatellite() == eGeoSatellite::H8) + // { + // QPoint pt(opts.geosatellites.at(geoindex).coff, opts.geosatellites.at(geoindex).loff); + // paint->setPen(qRgb(0, 0, 255)); + // paint->drawEllipse(pt, opts.geosatellites.at(geoindex).coff - 28, opts.geosatellites.at(geoindex).loff - 40); + // } + } + else + return; - if(channelshown == IMAGE_GEOSTATIONARY) - displayGeoImageInfo(); + double sub_lon = sl->geosatlon; + lat_deg = opts.obslat; + lon_deg = opts.obslon; + if (lon_deg > 180.0) + lon_deg -= 360.0; + coff = hrvimage ? opts.geosatellites.at(geoindex).coffhrv : opts.geosatellites.at(geoindex).coff; + loff = hrvimage ? opts.geosatellites.at(geoindex).loffhrv : opts.geosatellites.at(geoindex).loff; + cfac = hrvimage ? opts.geosatellites.at(geoindex).cfachrv : opts.geosatellites.at(geoindex).cfac; + lfac = hrvimage ? opts.geosatellites.at(geoindex).lfachrv : opts.geosatellites.at(geoindex).lfac; - if (channelshown == IMAGE_GEOSTATIONARY && overlaymeteosat && refreshoverlay) + if(sl->getGeoSatellite() == eGeoSatellite::MTG_I1) { - if(slgeo != NULL) + if(m_image->width() == 5568) { - this->OverlayGeostationary(&painter, slgeo); - refreshoverlay = false; + coff = coff/2; + loff = coff; + cfac = cfac/2.0; + lfac = cfac; + qDebug() << "coff = " << coff << " cfac = " << cfac; } } - if(channelshown == IMAGE_PROJECTION && overlayprojection && refreshoverlay) - { - this->OverlayProjection(&painter); - refreshoverlay = false; - } - if(channelshown == IMAGE_OLCI && overlayolci && refreshoverlay) - { - this->OverlayOLCI(&painter); - refreshoverlay = false; - } - if(channelshown == IMAGE_PROJECTION && changeinfraprojection) + ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, coff, loff, cfac, lfac, &col, &row); + if(ret == 0) { - changeinfraprojection = false; + if(hrvimage) + { + if (row > 11136 - sl->LowerNorthLineActual ) //LOWER + { + col = col - (11136 - sl->LowerWestColumnActual); + } + else //UPPER + { + col = col - (11136 - sl->UpperWestColumnActual - 1); + } + } + + QPoint pt(col, row); + QPoint ptleft(col-5, row); + QPoint ptright(col+5, row); + QPoint ptup(col, row-5); + QPoint ptdown(col, row+5); + + paint->setPen(qRgb(255, 0, 0)); + paint->drawLine(ptleft,ptright); + paint->drawLine(ptup,ptdown); + paint->drawEllipse(pt, 12, 12); } - imageLabel->setPixmap(pixval); + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - this->adjustImage(); + for(double lon = -180.0; lon < 180.0; lon+=10.0) + { + first = true; + { + for(double lat = -90.0; lat < 90.0; lat+=0.5) + { + ret =pixconv.geocoord2pixcoord(sub_lon, lat, lon, coff, loff, cfac, lfac, &col, &row); + if(hrvimage && sl->getGeoSatellite() != eGeoSatellite::FY2H && sl->getGeoSatellite() != eGeoSatellite::FY2G) + { + if (row > 11136 - sl->LowerNorthLineActual ) //LOWER + { + if( save_row <= 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->LowerWestColumnActual); + } + else //UPPER + { + if( save_row > 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->UpperWestColumnActual - 1); + } + } -} + if(ret == 0) + { + if (first) + { + first = false; + save_col = col; + save_row = row; + } + else + { + if(row < m_image->height() && col < m_image->width() && row > -1 && col > -1) + paint->drawLine(save_col, save_row, col, row); + save_col = col; + save_row = row; + } + } + else + first = true; -void FormImage::displayAVHRRImageInfo() -{ - QString segtype; - eSegmentType type; - int nbrselected; + } + } + } - type = getSegmentType(); - switch(type) + for(double lat = -80.0; lat < 81.0; lat+=10.0) { - case SEG_NONE: - segtype = "None"; - break; - case SEG_METOP: - segtype = "Metop"; - break; - case SEG_NOAA19: - segtype = "Noaa"; - break; - case SEG_HRP: - segtype = "HRP"; - break; - case SEG_GAC: - segtype = "GAC"; - break; - case SEG_HRPT_METOPA: - segtype = "Metop A HRPT"; - break; - case SEG_HRPT_METOPB: - segtype = "Metop B HRPT"; - break; - case SEG_HRPT_NOAA19: - segtype = "Noaa 19 HRPT"; - break; - case SEG_HRPT_M01: - segtype = "Metop B HRPT"; - break; - case SEG_HRPT_M02: - segtype = "Metop A HRPT"; - break; - default: - segtype = "NA"; - break; - } + first = true; + { + for(double lon = -180.0; lon < 180.0; lon+=1.0) + { + ret =pixconv.geocoord2pixcoord(sub_lon, lat, lon, coff, loff, cfac, lfac, &col, &row); + if(hrvimage && sl->getGeoSatellite() != eGeoSatellite::FY2H && sl->getGeoSatellite() != eGeoSatellite::FY2G) + { + if (row > 11136 - sl->LowerNorthLineActual ) //LOWER + { + if( save_row <= 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->LowerWestColumnActual); + } + else //UPPER + { + if( save_row > 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->UpperWestColumnActual - 1); + } + } - if (type == SEG_NOAA19) - nbrselected = segs->seglnoaa->NbrOfSegmentsSelected(); - else if( type == SEG_METOP) - nbrselected = segs->seglmetop->NbrOfSegmentsSelected(); - else if( type == SEG_GAC) - nbrselected = segs->seglgac->NbrOfSegmentsSelected(); - else if( type == SEG_HRP) - nbrselected = segs->seglhrp->NbrOfSegmentsSelected(); - else if( type == SEG_HRPT_METOPA) - nbrselected = segs->seglmetopAhrpt->NbrOfSegmentsSelected(); - else if( type == SEG_HRPT_METOPB) - nbrselected = segs->seglmetopBhrpt->NbrOfSegmentsSelected(); - else if( type == SEG_HRPT_NOAA19) - nbrselected = segs->seglnoaa19hrpt->NbrOfSegmentsSelected(); - else if( type == SEG_HRPT_M01) - nbrselected = segs->seglM01hrpt->NbrOfSegmentsSelected(); - else if( type == SEG_HRPT_M02) - nbrselected = segs->seglM02hrpt->NbrOfSegmentsSelected(); - txtInfo = QString("" - "Info" - "" - "

Image Information

" - "

Segment type = %1
" - "Nbr of segments = %2
" - "Image width = %3 height = %4
" - "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimagecomp_col->width()).arg(imageptrs->ptrimagecomp_col->height()); + if(ret == 0) + { + if (first) + { + first = false; + save_col = col; + save_row = row; + } + else + { + if(row < m_image->height() && col < m_image->width() && row > -1 && col > -1) + paint->drawLine(save_col, save_row, col, row); + save_col = col; + save_row = row; + } + } + else + first = true; + } + } + } - formtoolbox->writeInfoToTextEdit(txtInfo); + float factor = 1.0; + if(m_image->width() == 3712) + factor = 3.0; + else if(m_image->width() == 5568) + factor = 2.0; + else if(m_image->width() == 11136) + factor = 1.0; + else if(m_image->width() == 2288) // FY + factor = 1.0; + else if(m_image->width() == 9152) // FY - VIS + factor = 0.25; + else if(m_image->width() == 2784) // Electro + factor = 4.0; + + if(!hrvimage || (sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G)) + { + for(int k = 0; k < 3; k++) + { + if(k == 0) paint->setPen(opts.geoimageoverlaycolor1); //QColor(opts.projectionoverlaylonlatcolor)); + if(k == 1) paint->setPen(opts.geoimageoverlaycolor2); //QColor(opts.projectionoverlaylonlatcolor)); + if(k == 2) paint->setPen(opts.geoimageoverlaycolor3); //QColor(opts.projectionoverlaylonlatcolor)); + + for(int i = 0; i < this->geooverlay[k].count(); i++) + { + if (this->geooverlay[k].at(i).x() < 0) + { + first = true; + } + else if(first == true) + { + first = false; + save_col = (int)this->geooverlay[k].at(i).x()/factor; + save_row = (int)this->geooverlay[k].at(i).y()/factor; + } + else + { + col = this->geooverlay[k].at(i).x()/factor; + row = this->geooverlay[k].at(i).y()/factor; + if(row < m_image->height() && col < m_image->width()) + paint->drawLine(save_col, save_row, col, row); + save_col = (int)this->geooverlay[k].at(i).x()/factor; + save_row = (int)this->geooverlay[k].at(i).y()/factor; + } + } + } + } + else + OverlayGeostationaryHRV1(paint, sl, geoindex); } -void FormImage::displayVIIRSImageInfo(eSegmentType type) +void FormImage::OverlayGeostationaryHRV1(QPainter *paint, SegmentListGeostationary *sl, int geoindex) { - QString segtype; - int nbrselected; - float moonillum; - switch(type) - { - case SEG_NONE: - segtype = "None"; - break; - case SEG_VIIRSM: - segtype = "VIIRSM"; - nbrselected = segs->seglviirsm->NbrOfSegmentsSelected(); + long coff; + long loff; + double cfac; + double lfac; - break; - case SEG_VIIRSDNB: - segtype = "VIIRSDNB"; - nbrselected = segs->seglviirsdnb->NbrOfSegmentsSelected(); - moonillum = segs->seglviirsdnb->getMoonIllumination(); + int col = 0, save_col = 0; + int row = 0, save_row = 0; + bool first = true; - break; - case SEG_VIIRSMNOAA20: - segtype = "VIIRSMNOAA20"; - nbrselected = segs->seglviirsmnoaa20->NbrOfSegmentsSelected(); + double lat_deg; + double lon_deg; + int ret; - break; - case SEG_VIIRSDNBNOAA20: - segtype = "VIIRSDNBNOAA20"; - nbrselected = segs->seglviirsdnbnoaa20->NbrOfSegmentsSelected(); - moonillum = segs->seglviirsdnbnoaa20->getMoonIllumination(); + pixgeoConversion pixconv; - break; - default: - segtype = "NA"; - break; - } + //if(sl->LowerNorthLineActual == 0) + // return; + coff = opts.geosatellites.at(geoindex).coffhrv; + loff = opts.geosatellites.at(geoindex).loffhrv; + cfac = opts.geosatellites.at(geoindex).cfachrv; + lfac = opts.geosatellites.at(geoindex).lfachrv; - if(type == SEG_VIIRSM || type == SEG_VIIRSMNOAA20) + double sub_lon = sl->geosatlon; + + for(int index = 0; index < 3; index++) { - txtInfo = QString("" - "Info" - "" - "

Image Information

" - "

Segment type = %1
" - "Nbr of segments = %2
" - "Image width = %3 height = %4
" - "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageViirsM->width()).arg(imageptrs->ptrimageViirsM->height()); - formtoolbox->writeInfoToTextEdit(txtInfo); - - } else - if(type == SEG_VIIRSDNB || type == SEG_VIIRSDNBNOAA20) + first = true; + for(int i = 0; i < this->geooverlay[index].count(); i++) { - txtInfo = QString("" - "Info" - "" - "

Image Information

" - "

Segment type = %1
" - "Nbr of segments = %2
" - "Image width = %3 height = %4
" - "Moon illumination = %5 %

" - "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageViirsDNB->width()) - .arg(imageptrs->ptrimageViirsDNB->height()).arg(moonillum, 4, 'f', 2); - formtoolbox->writeInfoToTextEdit(txtInfo); - - } + col = (int)this->geooverlay[index].at(i).x(); + row = (int)this->geooverlay[index].at(i).y(); + if(sl->getGeoSatellite() != eGeoSatellite::FY2H && sl->getGeoSatellite() != eGeoSatellite::FY2G) + { + if (row > 11136 - sl->LowerNorthLineActual ) //LOWER + { + if( save_row <= 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->LowerWestColumnActual); + } + else //UPPER + { + if( save_row > 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->UpperWestColumnActual - 1); + } + } -} + if (this->geooverlay[index].at(i).x() < 0) + { + first = true; + } + else if(first == true) + { + first = false; + save_col = col; + save_row = row; + } + else + { + if(index == 0) + paint->setPen(opts.geoimageoverlaycolor1); + else if(index == 1) + paint->setPen(opts.geoimageoverlaycolor2); + else if(index == 2) + paint->setPen(opts.geoimageoverlaycolor3); -void FormImage::displayGeoImageInfo() -{ - for(int i = 0; i < opts.geosatellites.length(); i++) - { - if(segs->seglgeo[i]->bActiveSegmentList == true) - { - displayGeoImageInformation(opts.geosatellites[i].fullname); + if(row < m_image->height() && col < m_image->width() && row > -1 && col > -1) + paint->drawLine(save_col, save_row, col, row); + save_col = col; + save_row = row; + } } } -} - -void FormImage::displayGeoImageInformation(QString satname) -{ - QString spectrum; - SegmentListGeostationary *slgeo = NULL; - - slgeo = segs->getActiveSegmentList(); - - QString type = slgeo->getKindofImage(); - QVector spectrumvector = slgeo->getSpectrumVector(); - if(spectrumvector.size() > 0) - spectrum = ( type == "VIS_IR" ? spectrumvector.at(0) : ""); - else - spectrum = ""; - - txtInfo = QString("" - "Info" - "" - "

Image Information

" - "

Satellite = %1
" - "Image type = %2 %3
" - "Image width = %4 height = %5

" - "").arg(satname).arg(type).arg(spectrum).arg(imageptrs->ptrimageGeostationary->width()).arg(imageptrs->ptrimageGeostationary->height()); - formtoolbox->writeInfoToTextEdit(txtInfo); } -void FormImage::displaySentinelImageInfo(eSegmentType type) +void FormImage::OverlayGeostationaryHRV(QPainter *paint, SegmentListGeostationary *sl, int geoindex) { - QString segtype; - int nbrselected; - long nbrofsaturatedpixels; - - switch(type) - { - case SEG_NONE: - segtype = "None"; - break; - case SEG_OLCIEFR: - segtype = "OLCI efr"; - nbrselected = segs->seglolciefr->NbrOfSegmentsSelected(); - nbrofsaturatedpixels = segs->seglolciefr->NbrOfSaturatedPixels(); - break; - case SEG_OLCIERR: - segtype = "OLCI err"; - nbrselected = segs->seglolcierr->NbrOfSegmentsSelected(); - nbrofsaturatedpixels = segs->seglolcierr->NbrOfSaturatedPixels(); - break; - case SEG_SLSTR: - segtype = "SLSTR"; - nbrselected = segs->seglslstr->NbrOfSegmentsSelected(); - break; - default: - segtype = "NA"; - break; - } + long coff; + long loff; + double cfac; + double lfac; - if(type == SEG_OLCIEFR || type == SEG_OLCIERR) - { - txtInfo = QString("" - "Info" - "" - "

Image Information

" - "

Segment type = %1
" - "Nbr of segments = %2
" - "Image width = %3 height = %4
" - "Nbr of saturated pixels = %5
" - "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageOLCI->width()).arg(imageptrs->ptrimageOLCI->height()).arg(nbrofsaturatedpixels); - formtoolbox->writeInfoToTextEdit(txtInfo); - } - else if(type == SEG_SLSTR) - { - txtInfo = QString("" - "Info" - "" - "

Image Information

" - "

Segment type = %1
" - "Nbr of segments = %2
" - "Image width = %3 height = %4
" - "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageSLSTR->width()).arg(imageptrs->ptrimageSLSTR->height()); - formtoolbox->writeInfoToTextEdit(txtInfo); - } + int col, save_col; + int row, save_row; + bool first = true; -} -void FormImage::displayMERSIImageInfo(eSegmentType type) -{ - QString segtype; - int nbrselected; + double lat_deg; + double lon_deg; + int ret; - segtype = "MERSI"; - nbrselected = segs->seglmersi->NbrOfSegmentsSelected(); + pixgeoConversion pixconv; - txtInfo = QString("" - "Info" - "" - "

Image Information

" - "

Segment type = %1
" - "Nbr of segments = %2
" - "Image width = %3 height = %4
" - "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageMERSI->width()).arg(imageptrs->ptrimageMERSI->height()); - formtoolbox->writeInfoToTextEdit(txtInfo); + //if(sl->LowerNorthLineActual == 0) + // return; + coff = opts.geosatellites.at(geoindex).coffhrv; + loff = opts.geosatellites.at(geoindex).loffhrv; + cfac = opts.geosatellites.at(geoindex).cfachrv; + lfac = opts.geosatellites.at(geoindex).lfachrv; -} + double sub_lon = sl->geosatlon; -void FormImage::adjustPicSize(bool setwidth) -{ - // IMAGE_NONE = 0, - // IMAGE_AVHRR_CH1, - // IMAGE_AVHRR_CH2, - // IMAGE_AVHRR_CH3, - // IMAGE_AVHRR_CH4, - // IMAGE_AVHRR_CH5, - // IMAGE_AVHRR_COL, - // IMAGE_AVHRR_EXPAND, - // IMAGE_GEOSTATIONARY, - // IMAGE_PROJECTION, - // IMAGE_VIIRS_M, - // IMAGE_VIIRS_DNB, - // IMAGE_OLCI_EFR, - // IMAGE_OLCI_ERR, - // IMAGE_EQUIRECTANGLE - - double w,h,mw,mh,rw,rh,g=1; - if(channelshown >= 1 && channelshown <= 6) - { - w=imageptrs->ptrimagecomp_ch[0]->width(); - h=imageptrs->ptrimagecomp_ch[0]->height(); - } - else if(channelshown == IMAGE_AVHRR_EXPAND) - { - w=imageptrs->ptrexpand_col->width(); - h=imageptrs->ptrexpand_col->height(); - } - else if(channelshown == IMAGE_GEOSTATIONARY) - { - w=imageptrs->ptrimageGeostationary->width(); - h=imageptrs->ptrimageGeostationary->height(); - } - else if(channelshown == IMAGE_PROJECTION) - { - w=imageptrs->ptrimageProjection->width(); - h=imageptrs->ptrimageProjection->height(); - } - else if(channelshown == IMAGE_VIIRSM) - { - w=imageptrs->ptrimageViirsM->width(); - h=imageptrs->ptrimageViirsM->height(); - } - else if(channelshown == IMAGE_VIIRSDNB) - { - w=imageptrs->ptrimageViirsDNB->width(); - h=imageptrs->ptrimageViirsDNB->height(); - } - else if(channelshown == IMAGE_OLCI) - { - w=imageptrs->ptrimageOLCI->width(); - h=imageptrs->ptrimageOLCI->height(); - } - else if(channelshown == IMAGE_SLSTR) - { - w=imageptrs->ptrimageSLSTR->width(); - h=imageptrs->ptrimageSLSTR->height(); - } - else if(channelshown == IMAGE_MERSI) - { - w=imageptrs->ptrimageMERSI->width(); - h=imageptrs->ptrimageMERSI->height(); - } - else + if(opts.gshhsglobe1On) { - w = 0; - h = 0; - } - mw=this->parentWidget()->width(); - mh=this->parentWidget()->height(); - - rw=mw/w; - rh=mh/h; + first = true; - if(setwidth) // Fit Window width - { - g=rw; - } - else - { - if((rw>1 && rh>1) || (rw<1 && rh<1)) + for (int i=0; ivxp_data_overlay[0]->nFeatures; i++) { - if(rw>rh) - g = rh; - else - g = rw; - } - else if(rw<1 && rh>1) - g=rw; - else if(rw>1 && rh<1) - g=rh; - else - g=1; - - } + for (int j=0; jvxp_data_overlay[0]->pFeatures[i].nVerts; j++) + { + lat_deg = gshhsdata->vxp_data_overlay[0]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; + lon_deg = gshhsdata->vxp_data_overlay[0]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; + if (lon_deg > 180.0) + lon_deg -= 360.0; + if((lon_deg < 90.0 || lon_deg > -90.0)) + { + ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, coff, loff, cfac, lfac, &col, &row); + row+=5; //3; + col+=3; //2; - // qDebug() << QString("AdjustPicSize w = %1 h = %2 mw = %3 mh = %4 rw = %5 rh = %6 g = %7 setwidth = %8").arg(w).arg(h).arg(mw).arg(mh).arg(rw).arg(rh).arg(g).arg(setwidth); - scaleFactor = g; - setZoomValue( g*100 ); - this->adjustImage(); + if(ret == 0) + { + if(sl->getGeoSatellite() != eGeoSatellite::FY2H && sl->getGeoSatellite() != eGeoSatellite::FY2G) + { + if (row > 11136 - sl->LowerNorthLineActual ) //LOWER + { + if( save_row <= 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->LowerWestColumnActual); + } + else //UPPER + { + if( save_row > 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->UpperWestColumnActual - 1); + } + } + if (first) + { + first = false; + save_col = col; + save_row = row; + } + else + { + paint->setPen(opts.geoimageoverlaycolor1); + if(col < imageptrs->ptrimageGeostationary->width() && row < imageptrs->ptrimageGeostationary->height() && + col >= 0 && row >= 0) + paint->drawLine(save_col, save_row, col, row); + save_col = col; + save_row = row; + } + } + else + first = true; + } + } + first = true; + } + } -} + if(opts.gshhsglobe2On) + { + first = true; -//void FormImage::adjustImage() -//{ + for (int i=0; ivxp_data_overlay[1]->nFeatures; i++) + { + for (int j=0; jvxp_data_overlay[1]->pFeatures[i].nVerts; j++) + { + lat_deg = gshhsdata->vxp_data_overlay[1]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; + lon_deg = gshhsdata->vxp_data_overlay[1]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; + if (lon_deg > 180.0) + lon_deg -= 360.0; -// scaleFactor = (double)getZoomValue()/100; -// if(scaleFactor==1) -// { -// imageLabel->resize(imageLabel->pixmap()->size()); -// this->adjustSize(); -// } -// else -// { -// imageLabel->resize(imageLabel->pixmap()->size() * scaleFactor); -// this->resize(imageLabel->pixmap()->size() * scaleFactor); -// } - -// QString windowTitleFormat = QString("EUMETCastView zoomLevel"); -// windowTitleFormat.replace("zoomLevel", QString("%1%").arg((int)(getZoomValue()))); -// this->topLevelWidget()->setWindowTitle(windowTitleFormat); - -//} + if(lon_deg < 90.0 || lon_deg > -90.0) + { + ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, coff, loff, cfac, lfac, &col, &row); + row+=5; //3; + col+=3; //2; -void FormImage::adjustImage() -{ + if(ret == 0) + { + if(sl->getGeoSatellite() != eGeoSatellite::FY2H && sl->getGeoSatellite() != eGeoSatellite::FY2G) + { + if (row > 11136 - sl->LowerNorthLineActual ) //LOWER + { + if( save_row <= 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->LowerWestColumnActual); + } + else //UPPER + { + if( save_row > 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->UpperWestColumnActual - 1); + } + } - QSize pixmapsize = imageLabel->getPixmapSize(); - scaleFactor = (double)getZoomValue()/100; - if(scaleFactor==1) - { - imageLabel->resize(pixmapsize); - this->adjustSize(); - } - else - { - imageLabel->resize(pixmapsize * scaleFactor); - this->resize(pixmapsize * scaleFactor); + if (first) + { + first = false; + save_col = col; + save_row = row; + } + else + { + paint->setPen(opts.geoimageoverlaycolor2); + if(col < imageptrs->ptrimageGeostationary->width() && row < imageptrs->ptrimageGeostationary->height() && + col >= 0 && row >= 0) + paint->drawLine(save_col, save_row, col, row); + save_col = col; + save_row = row; + } + } + else + first = true; + } + } + first = true; + } } - QString windowTitleFormat = QString("EUMETCastView zoomLevel"); - windowTitleFormat.replace("zoomLevel", QString("%1%").arg((int)(getZoomValue()))); - this->topLevelWidget()->setWindowTitle(windowTitleFormat); - -} -void FormImage::slotUpdateGeosat() -{ - - qDebug() << "start FormImage::slotUpdateGeosat()"; - - refreshoverlay = true; - - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageGeostationary))); - this->adjustImage(); - emit allsegmentsreceivedbuttons(true); - - this->update(); - -} - -void FormImage::slotcomposefinished(QString kindofimage) -{ - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageGeostationary))); - refreshoverlay = true; + if(opts.gshhsglobe3On) + { + first = true; - SegmentListGeostationary *sl = NULL; - sl = segs->getActiveSegmentList(); + for (int i=0; ivxp_data_overlay[2]->nFeatures; i++) + { + for (int j=0; jvxp_data_overlay[2]->pFeatures[i].nVerts; j++) + { + lat_deg = gshhsdata->vxp_data_overlay[2]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; + lon_deg = gshhsdata->vxp_data_overlay[2]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; + if (lon_deg > 180.0) + lon_deg -= 360.0; + if(lon_deg < 90.0 || lon_deg > -90.0) + { - if(sl->getGeoSatellite() == eGeoSatellite::H8) - { - EnhanceDarkSpace(sl->getGeoSatelliteIndex()); - imageLabel->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimageGeostationary))); - refreshoverlay = true; - } + ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, coff, loff, cfac, lfac, &col, &row); + row+=5; //3; + col+=3; //2; - QApplication::restoreOverrideCursor(); + if(ret == 0) + { + if(sl->getGeoSatellite() != eGeoSatellite::FY2H && sl->getGeoSatellite() != eGeoSatellite::FY2G) + { + if (row > 11136 - sl->LowerNorthLineActual ) //LOWER + { + if( save_row <= 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->LowerWestColumnActual); + } + else //UPPER + { + if( save_row > 11136 - sl->LowerNorthLineActual ) + first = true; + col = col - (11136 - sl->UpperWestColumnActual - 1); + } + } - if(opts.imageontextureOnMet) - { - if(sl->getKindofImage() == "HRV" || sl->getKindofImage() == "HRV Color") - { - qDebug() << "all HRV received !!!!!!!!!!!!!!"; - emit allsegmentsreceivedbuttons(true); - } - else - { - qDebug() << "all VIS_IR received !!!!!!!!!!!!!!"; - emit render3dgeo(sl->getGeoSatelliteIndex()); + if (first) + { + first = false; + save_col = col; + save_row = row; + } + else + { + paint->setPen(opts.geoimageoverlaycolor3); + if(col < imageptrs->ptrimageGeostationary->width() && row < imageptrs->ptrimageGeostationary->height() && + col >= 0 && row >= 0) + paint->drawLine(save_col, save_row, col, row); + save_col = col; + save_row = row; + } + } + else + first = true; + } + } + first = true; } } - else - emit allsegmentsreceivedbuttons(true); - - qDebug() << "end FormImage::slotcomposefinished()"; - this->update(); + //this->update(); } -void FormImage::EnhanceDarkSpace(int geoindex) +void FormImage::OverlayProjection(QPainter *paint) { - QRgb *row_col; - QRgb rgb; - quint16 r,g, b; - double l2, el2_1, el2_2; - int x0, y0; - int maxhimred, minhimred; - int maxhimgreen, minhimgreen; - int maxhimblue, minhimblue; - long cnt = 0; - - maxhimred = 0; - minhimred = 65535; - maxhimgreen = 0; - minhimgreen = 65535; - maxhimblue = 0; - minhimblue = 65535; - - int ela = opts.geosatellites.at(geoindex).coff - 28; //- 28; - int elb = opts.geosatellites.at(geoindex).loff - 40; //- 40; - double ela2 = (double)(ela*ela); - double elb2 = (double)(elb*elb); - double eta1 = 1.003; - double eta2 = 1.005; - double ka1, ka2; - - for (int line = 0; line < 5500; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - - - // for (int pixelx = 0; pixelx < 5500; pixelx++) - // { - // y0 = line - 2750; - // x0 = pixelx - 2750; - // rgb = row_col[pixelx]; - - // double x2 = (double)(x0*x0); - // double y2 = (double)(y0*y0); - - //// ka = (eta - x2/ela2); - //// el2 = ka * elb2; - - //// if(y2 < el2) - //// row_col[pixelx] = qRgb(255, 0, 0); - - - // //eta = 1.1; - // ka = (eta - x2/ela2); - // el2 = ka * elb2; - - // if(y2 > el2 && (y2 - 80000) <= el2) - // { - // row_col[pixelx] = qRgb(0, 255, 0); - // //calchimawari(rgb, minhimred, maxhimred, minhimgreen, maxhimgreen, minhimblue, maxhimblue); - // } - // //else if((y2 <= el2) && ((el2 - 900000) < y2)) - // // row_col[pixelx] = qRgb(0, 255, 0); - - // } - + qDebug() << QString("FormImage::OverlayProjection(QPainter *paint, SegmentListGeostationary *sl) opts.currenttoolbox = %1").arg(opts.currenttoolbox); + if(!paint->isActive()) + return; - for (int pixelx = 0; pixelx < 5500; pixelx++) - { - y0 = line - 2750; - x0 = pixelx - 2750; - rgb = row_col[pixelx]; + double lat_deg; + double lon_deg; + bool bret; - double x2 = (double)(x0*x0); - double y2 = (double)(y0*y0); + double map_x, map_y; + double save_map_x, save_map_y; - ka1 = (eta1 - x2/ela2); - el2_1 = ka1 * elb2; + lat_deg = opts.obslat; + lon_deg = opts.obslon; + if (lon_deg > 180.0) + lon_deg -= 360.0; + if (opts.currenttoolbox == 0) // LCC + bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); + else if (opts.currenttoolbox == 1) // GVP + bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else if (opts.currenttoolbox == 2) //SG + bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else if (opts.currenttoolbox == 3) //OM + bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else + bret = false; - ka2 = (eta2 - x2/ela2); - el2_2 = ka2 * elb2; + if(bret) + { - if(y2 > el2_1) // || y2 > el2_2) - calchimawari(rgb, minhimred, maxhimred, minhimgreen, maxhimgreen, minhimblue, maxhimblue); + QPoint pt(map_x, map_y); + QPoint ptleft(map_x-5, map_y); + QPoint ptright(map_x+5, map_y); + QPoint ptup(map_x, map_y-5); + QPoint ptdown(map_x, map_y+5); - } + paint->setPen(qRgb(255, 0, 0)); + paint->drawLine(ptleft,ptright); + paint->drawLine(ptup,ptdown); + // QPoint pt(map_x-1, map_y-1); + // paint->setPen(qRgb(255, 0, 0)); + // paint->drawEllipse(pt, 2, 2); } - qDebug() << QString("Himawari min rgb = %1 %2 %3 max rgb = %4 %5 %6 cnt = %7").arg(minhimred).arg(minhimgreen).arg(minhimblue).arg(maxhimred).arg(maxhimgreen).arg(maxhimblue).arg(cnt); - - SetupContrastStretch(minhimred, 0, maxhimred, 255, minhimgreen, 0, maxhimgreen, 255, minhimblue, 0, maxhimblue, 255 ); + bool first = true; - for (int line = 0; line < 5500; line++) + if(opts.gshhsglobe1On) { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - - - for (int pixelx = 0; pixelx < 5500; pixelx++) + for (int i=0; ivxp_data_overlay[0]->nFeatures; i++) { - y0 = line - 2750; - x0 = pixelx - 2750; - rgb = row_col[pixelx]; - - double x2 = (double)(x0*x0); - double y2 = (double)(y0*y0); + for (int j=0; jvxp_data_overlay[0]->pFeatures[i].nVerts; j++) + { + lat_deg = gshhsdata->vxp_data_overlay[0]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; + lon_deg = gshhsdata->vxp_data_overlay[0]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; + if (lon_deg > 180.0) + lon_deg -= 360.0; - double ka2 = (eta2 - x2/ela2); - el2_2 = ka2 * elb2; + if (opts.currenttoolbox == 0) //LCC + bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); + else if (opts.currenttoolbox == 1) //GVP + bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); + else if (opts.currenttoolbox == 2) //SG + bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); + else if (opts.currenttoolbox == 3) //OM + bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); + else + bret = false; - if(y2 > el2_2) - { - row_col[pixelx] = ContrastStretch(rgb); + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + if(abs(save_map_y - map_y) < 100 && (abs(save_map_x - map_x) < 100)) + { + paint->setPen(QColor(opts.projectionoverlaycolor1)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + } + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; } + first = true; } } + first = true; -} - -QRgb FormImage::ContrastStretch(QRgb val) -{ - double resred, resgreen, resblue; - resred = double(qRed(val))*A1red + B1red; - resgreen = double(qGreen(val))*A1green + B1green; - resblue = double(qBlue(val))*A1blue + B1blue; - resred = resred > 255.0 ? 255 : quint16(resred); - resgreen = resgreen > 255.0 ? 255 : quint16(resgreen); - resblue = resblue > 255.0 ? 255 : quint16(resblue); - return qRgb(resred, resgreen, resblue); -} + if(opts.gshhsglobe2On) + { + for (int i=0; ivxp_data_overlay[1]->nFeatures; i++) + { + for (int j=0; jvxp_data_overlay[1]->pFeatures[i].nVerts; j++) + { + lat_deg = gshhsdata->vxp_data_overlay[1]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; + lon_deg = gshhsdata->vxp_data_overlay[1]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; + if (lon_deg > 180.0) + lon_deg -= 360.0; -void FormImage::SetupContrastStretch(quint16 x1r, quint16 y1r, quint16 x2r, quint16 y2r, quint16 x1g, quint16 y1g, quint16 x2g, quint16 y2g, quint16 x1b, quint16 y1b, quint16 x2b, quint16 y2b) -{ - double d_x1r = (double)x1r; - double d_x2r = (double)x2r; - double d_y1r = (double)y1r; - double d_y2r = (double)y2r; - - double d_x1g = (double)x1g; - double d_x2g = (double)x2g; - double d_y1g = (double)y1g; - double d_y2g = (double)y2g; - - double d_x1b = (double)x1b; - double d_x2b = (double)x2b; - double d_y1b = (double)y1b; - double d_y2b = (double)y2b; - - A1red = (d_y2r - d_y1r)/(d_x2r - d_x1r); - B1red = (d_y2r - (A1red*d_x2r)); - A1green = (d_y2g - d_y1g)/(d_x2g - d_x1g); - B1green = (d_y2g - (A1green*d_x2g)); - A1blue = (d_y2b - d_y1b)/(d_x2b - d_x1b); - B1blue = (d_y2b - (A1blue*d_x2b)); -} - - -void FormImage::calchimawari(QRgb rgb, int &minred, int &maxred, int &mingreen, int &maxgreen, int &minblue, int &maxblue) -{ - quint16 r,g,b; - - r = qRed(rgb); - g = qGreen(rgb); - b = qBlue(rgb); - - if(minred > r) - minred = r; - if(maxred < r) - maxred = r; - if(mingreen > g) - mingreen = g; - if(maxgreen < g) - maxgreen = g; - if(minblue > b) - minblue = b; - if(maxblue < b) - maxblue = b; - -} - -void FormImage::UpdateProjection() -{ - this->displayImage(IMAGE_PROJECTION); - this->refreshoverlay = true; - this->update(); -} + if (opts.currenttoolbox == 0) //LCC + bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); + else if (opts.currenttoolbox == 1) //GVP + bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else if (opts.currenttoolbox == 2) //SG + bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else if (opts.currenttoolbox == 3) //OM + bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else + bret = false; + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + if(abs(save_map_y - map_y) < 100 && (abs(save_map_x - map_x) < 100)) + { + paint->setPen(QColor(opts.projectionoverlaycolor2)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + } + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; + } + first = true; + } + } -QSize FormImage::getPictureSize() const -{ - QSize g; - if(!imageLabel->pixmap()->isNull()) - g = imageLabel->pixmap()->size(); - else - g = QSize(-1,-1); + first = true; - return g; -} + if(opts.gshhsglobe3On) + { + for (int i=0; ivxp_data_overlay[2]->nFeatures; i++) + { + for (int j=0; jvxp_data_overlay[2]->pFeatures[i].nVerts; j++) + { + lat_deg = gshhsdata->vxp_data_overlay[2]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; + lon_deg = gshhsdata->vxp_data_overlay[2]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; + if (lon_deg > 180.0) + lon_deg -= 360.0; -void FormImage::recalculateCLAHEAvhrr(QVector spectrumvector, QVector inversevector) -{ - quint16 *pixelsRed; - quint16 *pixelsGreen; - quint16 *pixelsBlue; + if (opts.currenttoolbox == 0) //LCC + bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); + else if (opts.currenttoolbox == 1) //GVP + bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else if (opts.currenttoolbox == 2) //SG + bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else if (opts.currenttoolbox == 3) //OM + bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else + bret = false; - size_t npix; + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + if(abs(save_map_y - map_y) < 100 && (abs(save_map_x - map_x) < 100)) + { + paint->setPen(QColor(opts.projectionoverlaycolor3)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + } + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; + } + first = true; + } + } - SegmentListMetop *sl = segs->seglmetop; - if(sl->GetSegsSelectedptr()->count() > 0) + if (opts.currenttoolbox == 0 && formtoolbox->GridOnProjLCC()) // LLC { - qDebug() << "segs->seglmetop count selected = " << sl->GetSegsSelectedptr()->count(); - qDebug() << "height = " << imageptrs->ptrimagecomp_col->height(); - qDebug() << "width = " << imageptrs->ptrimagecomp_col->width(); - qDebug() << this->kindofimage; - qDebug() << spectrumvector.at(0) << " " << spectrumvector.at(1) << " " << spectrumvector.at(2); - //npix = imageptrs->ptrimagecomp_col->height() * imageptrs->ptrimagecomp_col->width(); - //memcpy(pixelsRed, imageptrs->ptrimagecomp_ch[0], npix * sizeof(quint32)); + for(double lon = -180.0; lon < 180.0; lon+=10.0) + { + first = true; - } + //if(lon >= opts.mapextentwest && lon < opts.mapextenteast) + { + for(double lat = -90.0; lat < 90.0; lat+=0.5) + { + bret = imageptrs->lcc->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); -} + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; -void FormImage::recalculateCLAHEOLCI(QVector spectrumvector, QVector inversevector) -{ - quint16 *pixelsRed; - quint16 *pixelsGreen; - quint16 *pixelsBlue; + } + } + } - size_t npix; + for(double lat = -80.0; lat < 81.0; lat+=10.0) + { + first = true; + if(lat >= opts.mapextentsouth && lat < opts.mapextentnorth) + { + for(double lon = -180.0; lon < 180.0; lon+=1.0) + { + bret = imageptrs->lcc->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); - SegmentListOLCI *sl = segs->seglolciefr; - if(sl->GetSegsSelectedptr()->count() > 0) - { - qDebug() << "segs->seglolci count selected = " << sl->GetSegsSelectedptr()->count(); - qDebug() << "height = " << imageptrs->ptrimageOLCI->height(); - qDebug() << "width = " << imageptrs->ptrimagecomp_col->width(); - qDebug() << this->kindofimage; - qDebug() << spectrumvector.at(0) << " " << spectrumvector.at(1) << " " << spectrumvector.at(2); - //npix = imageptrs->ptrimagecomp_col->height() * imageptrs->ptrimagecomp_col->width(); - //memcpy(pixelsRed, imageptrs->ptrimagecomp_ch[0], npix * sizeof(quint32)); + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; + } + } + } } -} + if (opts.currenttoolbox == 1 && formtoolbox->GridOnProjGVP()) //GVP + { + for(double lon = -180.0; lon < 180.0; lon+=10.0) + { + first = true; + { + for(double lat = -90.0; lat < 90.0; lat+=0.5) + { + bret = imageptrs->gvp->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); -void FormImage::recalculateCLAHE(QVector spectrumvector, QVector inversevector) -{ + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; - QRgb *row_col; - quint16 cred, cgreen, cblue, c; - quint16 r,g, b; + } + } + } - SegmentListGeostationary *sl; + for(double lat = -80.0; lat < 81.0; lat+=10.0) + { + first = true; + { + for(double lon = -180.0; lon < 180.0; lon+=1.0) + { + bret = imageptrs->gvp->map_forward( lon*PI/180.0, lat*PI/180.0, map_x, map_y); - sl = segs->getActiveSegmentList(); - if(sl == NULL) - return; + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; + } + } + } + } - if (sl->getKindofImage() == "HRV Color") - return; - int geoindex = sl->getGeoSatelliteIndex(); - size_t npix; - size_t npixHRV; + if (opts.currenttoolbox == 2 && formtoolbox->GridOnProjSG() ) //SG + { + for(double lon = -180.0; lon < 180.0; lon+=10.0) + { + first = true; + { + for(double lat = -90.0; lat < 90.0; lat+=0.5) + { + bret = imageptrs->sg->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); - npix = opts.geosatellites.at(geoindex).imageheight * opts.geosatellites.at(geoindex).imagewidth; - if (sl->areatype == 1) - npixHRV = opts.geosatellites.at(geoindex).imageheighthrv1 * opts.geosatellites.at(geoindex).imagewidthhrv1; - else - npixHRV = opts.geosatellites.at(geoindex).imageheighthrv0 * opts.geosatellites.at(geoindex).imagewidthhrv0; - - - - QApplication::setOverrideCursor( Qt::WaitCursor ); // this might take time + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; - quint16 *pixelsRed; - quint16 *pixelsGreen; - quint16 *pixelsBlue; - quint16 *pixelsHRV; + } + } + } - qDebug() << QString("recalculateCLAHE() ; kind of image = %1").arg(sl->getKindofImage()); + for(double lat = -80.0; lat < 81.0; lat+=10.0) + { + first = true; + { + for(double lon = -180.0; lon < 180.0; lon+=1.0) + { + bret = imageptrs->sg->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); - if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) - { - pixelsRed = new quint16[npix]; - pixelsGreen = new quint16[npix]; - pixelsBlue = new quint16[npix]; + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; - for( int i = (sl->bisRSS ? 5 : 0); i < 8; i++) - { - if(sl->isPresentRed[i]) - memcpy(pixelsRed + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrRed[i], 464 * 3712 * sizeof(quint16)); - } - for( int i = (sl ->bisRSS ? 5 : 0); i < 8; i++) - { - if(sl->isPresentGreen[i]) - memcpy(pixelsGreen + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrGreen[i], 464 * 3712 * sizeof(quint16)); - } - for( int i = (sl ->bisRSS ? 5 : 0); i < 8; i++) - { - if(sl->isPresentBlue[i]) - memcpy(pixelsBlue + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrBlue[i], 464 * 3712 * sizeof(quint16)); + } + } } } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::GOMS3) - { - pixelsRed = new quint16[npix]; - pixelsGreen = new quint16[npix]; - pixelsBlue = new quint16[npix]; - for( int i = 0; i < 6; i++) - { - if(sl->isPresentRed[i]) - memcpy(pixelsRed + i * 464 * 2784, imageptrs->ptrRed[i], 464 * 2784 * sizeof(quint16)); - } - for( int i = 0; i < 6; i++) - { - if(sl->isPresentGreen[i]) - memcpy(pixelsGreen + i * 464 * 2784, imageptrs->ptrGreen[i], 464 * 2784 * sizeof(quint16)); - } - for( int i = 0; i < 6; i++) - { - if(sl->isPresentBlue[i]) - memcpy(pixelsBlue + i * 464 * 2784, imageptrs->ptrBlue[i], 464 * 2784 * sizeof(quint16)); - } - } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::H8) + if (opts.currenttoolbox == 3) //OM { + QPolygonF poly; + if(opts.buttonMERSI) + segs->seglmersi->GetContourPolygon(&poly); + else if(opts.buttonVIIRSM) + segs->seglviirsm->GetContourPolygon(&poly); + else if(opts.buttonVIIRSMNOAA20) + segs->seglviirsmnoaa20->GetContourPolygon(&poly); + else if(opts.buttonMetop) + segs->seglmetop->GetContourPolygonAVHRR(&poly); - pixelsRed = new quint16[npix]; - pixelsGreen = new quint16[npix]; - pixelsBlue = new quint16[npix]; - - for( int i = 0; i < 10; i++) - { - if(sl->isPresentRed[i]) - memcpy(pixelsRed + i * 550 * 5500, imageptrs->ptrRed[i], 550 * 5500 * sizeof(quint16)); - } - for( int i = 0; i < 10; i++) + for(int i = 0; i < poly.size(); i++) { - if(sl->isPresentGreen[i]) - memcpy(pixelsGreen + i * 550 * 5500, imageptrs->ptrGreen[i], 550 * 5500 * sizeof(quint16)); + bret = imageptrs->om->map_forward( poly.at(i).x()*PI/180, poly.at(i).y()*PI/180, map_x, map_y); + if(bret) + { + paint->setPen(QColor(255, 0, 255)); + paint->drawPoint(map_x, map_y); + } } - for( int i = 0; i < 10; i++) + + if(opts.sattrackinimage) { - if(sl->isPresentBlue[i]) - memcpy(pixelsBlue + i * 550 * 5500, imageptrs->ptrBlue[i], 550 * 5500 * sizeof(quint16)); + QPolygonF track; + if(opts.buttonMERSI) + segs->seglmersi->GetTrackPolygon(&track); + else if(opts.buttonVIIRSM) + segs->seglviirsm->GetTrackPolygon(&track); + else if(opts.buttonVIIRSMNOAA20) + segs->seglviirsmnoaa20->GetTrackPolygon(&track); + else if(opts.buttonMetop) + segs->seglmetop->GetTrackPolygonAVHRR(&track); + + first = true; + for(int i = 0; i < track.size(); i++) + { + bret = imageptrs->om->map_forward( track.at(i).x()*PI/180, track.at(i).y()*PI/180, map_x, map_y); + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(0, 0, 255)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + } } } - else if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18)) + + if (opts.currenttoolbox == 3 && formtoolbox->GridOnProjOM() ) //OM { - pixelsRed = new quint16[npix]; - pixelsGreen = new quint16[npix]; - pixelsBlue = new quint16[npix]; - memcpy(pixelsRed, imageptrs->ptrRed[0], npix * sizeof(quint16)); - memcpy(pixelsGreen, imageptrs->ptrGreen[0], npix * sizeof(quint16)); - memcpy(pixelsBlue, imageptrs->ptrBlue[0], npix * sizeof(quint16)); + first = true; - for(int i = 0; i < npix; i++) + for(double lon = -180.0; lon < 180.0; lon+=10.0) { - if(*(pixelsRed+i) == imageptrs->fillvalue[0] ) - *(pixelsRed + i) = 0; - if(*(pixelsGreen+i) == imageptrs->fillvalue[1] ) - *(pixelsGreen + i) = 0; - if(*(pixelsBlue+i) == imageptrs->fillvalue[2] ) - *(pixelsBlue + i) = 0; - if(imageptrs->ptrDQF[0][i] == 2) + first = true; { - *(pixelsRed+i) = 1023; - *(pixelsGreen+i) = 1023; - *(pixelsBlue+i) = 1023; + for(double lat = -80.0; lat < 81.0; lat+=0.5) + { + bret = imageptrs->om->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); + + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + // paint->drawPoint(map_x, map_y); + if(abs(save_map_x - map_x) < 200 && abs(save_map_y - map_y) < 200) + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; + + } } } - - } - else if(sl->getKindofImage() == "HRV" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) - { - pixelsHRV = new quint16[npixHRV]; - for( int i = 0, k = 0; i < (sl->bisRSS ? 5 : ( sl->areatype == 1 ? 24 : 5)); i++) + for(double lat = -80.0; lat < 81.0; lat+=10.0) { - k = (sl->bisRSS ? 19 + i : (sl->areatype == 1 ? i : 19 + i)); - if(sl->isPresentHRV[k]) + first = true; { - memcpy(pixelsHRV + i * 464 * 5568, imageptrs->ptrHRV[k], 464 * 5568 * sizeof(quint16)); + for(double lon = -180.0; lon < 180.0; lon+=1.0) + { + bret = imageptrs->om->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); + + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + //paint->drawPoint(map_x, map_y); + if(abs(save_map_x - map_x) < 200 && abs(save_map_y - map_y) < 200) + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; + + } } } + + + } - else if(sl->getKindofImage() == "HRV" && (sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G )) - { - pixelsHRV = new quint16[npixHRV]; - memcpy(pixelsHRV, imageptrs->ptrHRV[0], 9152 * 9152 * sizeof(quint16)); - } - else if(sl->getKindofImage() == "VIS_IR" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) - { - pixelsRed = new quint16[npix]; - for( int i = (sl->bisRSS ? 5 : 0); i < 8 ; i++) - { - if(sl->isPresentRed[i]) - memcpy(pixelsRed + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrRed[i], 464 * 3712 * sizeof(quint16)); - } - } - else if(sl->getKindofImage() == "VIS_IR" && sl->getGeoSatellite() == eGeoSatellite::GOMS3) - { - pixelsRed = new quint16[npix]; - for( int i = 0; i < 6 ; i++) - { - if(sl->isPresentRed[i]) - memcpy(pixelsRed + i * 464 * 2784, imageptrs->ptrRed[i], 464 * 2784 * sizeof(quint16)); - } - } - else if(sl->getKindofImage() == "VIS_IR" && (sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G )) - { - pixelsRed = new quint16[npix]; - memcpy(pixelsRed, imageptrs->ptrRed[0], npix * sizeof(quint16)); - } - else if(sl->getKindofImage() == "VIS_IR" && (sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18 )) - { - pixelsRed = new quint16[npix]; - memcpy(pixelsRed, imageptrs->ptrRed[0], npix * sizeof(quint16)); - for(int i = 0; i < npix; i++) - { - if(*(pixelsRed+i) == imageptrs->fillvalue[0] ) - *(pixelsRed + i) = 0; - if(imageptrs->ptrDQF[0][i] == 2) - *(pixelsRed+i) = 1023; - } - } - else if(sl->getKindofImage() == "VIS_IR" && sl->getGeoSatellite() == eGeoSatellite::H8) - { - pixelsRed = new quint16[npix]; - for( int i = 0; i < 10 ; i++) - { - if(sl->isPresentRed[i]) - memcpy(pixelsRed + i * 550 * 5500, imageptrs->ptrRed[i], 550 * 5500 * sizeof(quint16)); - } - } - int ret = 0; +} +void FormImage::OverlayOLCI(QPainter *paint) +{ + SegmentListOLCI *sl; + qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 0"; + int height = imageptrs->ptrimageOLCI->height(); + int width = imageptrs->ptrimageOLCI->width(); + if( height == 0 || width == 0) + return; - if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) - { - imageptrs->CLAHE(pixelsRed, 3712, (sl->bisRSS ? 3*464 : 3712), 0, 1023, 16, 16, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsGreen, 3712, (sl->bisRSS ? 3*464 : 3712), 0, 1023, 16, 16, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsBlue, 3712, (sl->bisRSS ? 3*464 : 3712), 0, 1023, 16, 16, 256, opts.clahecliplimit); - } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::GOMS3) - { - imageptrs->CLAHE(pixelsRed, 2784, 2784, 0, 1023, 16, 16, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsGreen, 2784, 2784, 0, 1023, 16, 16, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsBlue, 2784, 2784, 0, 1023, 16, 16, 256, opts.clahecliplimit); - } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::H8 ) - { - ret = imageptrs->CLAHE(pixelsRed, 5500, 5500, 0, 1023, 10, 10, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsGreen, 5500, 5500, 0, 1023, 10, 10, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsBlue, 5500, 5500, 0, 1023, 10, 10, 256, opts.clahecliplimit); - } - else if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18) ) - { - ret = imageptrs->CLAHE(pixelsRed, 5424, 5424, 0, 1023, 16, 16, 256, opts.clahecliplimit); - qDebug() << QString("pixelsRed ret = %1").arg(ret); - ret = imageptrs->CLAHE(pixelsGreen, 5424, 5424, 0, 1023, 16, 16, 256, opts.clahecliplimit); - qDebug() << QString("pixelsGreen ret = %1").arg(ret); - ret = imageptrs->CLAHE(pixelsBlue, 5424, 5424, 0, 1023, 16, 16, 256, opts.clahecliplimit); - qDebug() << QString("pixelsBlue ret = %1").arg(ret); - } - else if(sl->getKindofImage() == "HRV" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8)) - { - if(sl->bisRSS) - { - imageptrs->CLAHE(pixelsHRV, 5568, 5*464, 0, 1023, 16, 16, 256, opts.clahecliplimit); + qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 1"; + qDebug() << "opts.buttonOLCIefr = " << opts.buttonOLCIefr; + qDebug() << "opts.buttonOLCIerr = " << opts.buttonOLCIerr; + qDebug() << "opts.buttonSLSTR = " << opts.buttonSLSTR; - } - else - { - if(sl->areatype == 1) - { - imageptrs->CLAHE(pixelsHRV, 5568, 11136, 0, 1023, 16, 16, 256, opts.clahecliplimit); - } - else - { - imageptrs->CLAHE(pixelsHRV, 5568, 5*464, 0, 1023, 16, 16, 256, opts.clahecliplimit); - } - } - } - else if(sl->getKindofImage() == "HRV" && (sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G )) + if(opts.buttonOLCIefr) { - imageptrs->CLAHE(pixelsHRV, 9152, 9152, 0, 255, 16, 16, 256, opts.clahecliplimit); + if(segs->seglolciefr->GetSegmentlistptr()->count() == 0) + return; } - else if(sl->getKindofImage() == "VIS_IR") + else if(opts.buttonOLCIerr) { - if(sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8) - imageptrs->CLAHE(pixelsRed, 3712, (sl->bisRSS ? 3*464 : 3712), 0, 1023, 16, 16, 256, opts.clahecliplimit); - else if(sl->getGeoSatellite() == eGeoSatellite::GOMS3) - { - ret = imageptrs->CLAHE(pixelsRed, 2784, 464*6, 0, 1023, 16, 16, 256, opts.clahecliplimit); - } - else if(sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G) - imageptrs->CLAHE(pixelsRed, 2288, 2288, 0, 255, 16, 16, 256, opts.clahecliplimit); - else if(sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18) - imageptrs->CLAHE(pixelsRed, 5424, 5424, 0, 1023, 16, 16, 256, opts.clahecliplimit); - else if(sl->getGeoSatellite() == eGeoSatellite::H8) - imageptrs->CLAHE(pixelsRed, 5500, 5500, 0, 1023, 10, 10, 256, opts.clahecliplimit); + if(segs->seglolcierr->GetSegmentlistptr()->count() == 0) + return; } + else + return; + qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 2"; - qDebug() << "---> After CLAHE"; + if(opts.buttonOLCIefr) + sl = segs->seglolciefr; + else if(opts.buttonOLCIerr) + sl = segs->seglolcierr; + else return; - if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) - { - for(int i = 0; i < (sl->bisRSS ? 3 : 8); i++) - { - for (int line = 463; line >= 0; line--) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 3*464 : 3712) - i * 464 - line - 1); + long nbrpt = 0; - for (int pixelx = 3711; pixelx >= 0; pixelx--) - { - cred = *(pixelsRed + i * 464 * 3712 + line * 3712 + pixelx); - cgreen = *(pixelsGreen + i * 464 * 3712 + line * 3712 + pixelx); - cblue = *(pixelsBlue + i * 464 * 3712 + line * 3712 + pixelx); + qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 3"; + qDebug() << "FormImage::OverlayOLCI(QPainter *paint) ptrimageOLCI height = " << imageptrs->ptrimageOLCI->height(); + qDebug() << "opts.buttonOLCIefr = " << opts.buttonOLCIefr; + qDebug() << "opts.buttonOLCIerr = " << opts.buttonOLCIerr; + qDebug() << "opts.buttonSLSTR = " << opts.buttonSLSTR; + qDebug() << "segs->seglolciefr->GetSegmentlistptr()->count() = " << segs->seglolciefr->GetSegmentlistptr()->count(); + qDebug() << "segs->seglolcierr->GetSegmentlistptr()->count() = " << segs->seglolcierr->GetSegmentlistptr()->count(); + qDebug() << "segs->seglslstr->GetSegmentlistptr()->count() = " << segs->seglslstr->GetSegmentlistptr()->count(); + if(sl->GetSegsSelectedptr()->count() > 0) + { - r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); + qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 4"; - row_col[3711 - pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::H8) - { + qDebug() << "segs->seglolci count selected = " << sl->GetSegsSelectedptr()->count(); + qDebug() << "height = " << imageptrs->ptrimageOLCI->height(); + qDebug() << "width = " << imageptrs->ptrimageOLCI->width(); + qDebug() << this->kindofimage; - for(int i = 0; i < 10; i++) + QList::iterator segsel = sl->GetSegsSelectedptr()->begin(); + int heightinsegment = 0; + while ( segsel != sl->GetSegsSelectedptr()->end() ) { - for (int line = 0; line < 550; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 550 + line); - for (int pixelx = 0; pixelx < 5500; pixelx++) - { - cred = *(pixelsRed + i * 550 * 5500 + line * 5500 + pixelx); - cgreen = *(pixelsGreen + i * 550 * 5500 + line * 5500 + pixelx); - cblue = *(pixelsBlue + i * 550 * 5500 + line * 5500 + pixelx); + SegmentOLCI *segm = (SegmentOLCI *)(*segsel); + paint->setPen(QColor(opts.olciimageoverlaycolor)); + QPolygon copycoastline = segm->coastline.translated(0, heightinsegment); + paint->drawPoints(copycoastline); - r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); + // if(opts.gridonolciimage) + // { + // paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + // QPolygon copylatlonline = segm->latlonline.translated(0, heightinsegment); + // paint->drawPoints(copylatlonline); + // } - row_col[pixelx] = qRgb(r,g,b); - } - } + heightinsegment += segm->GetNbrOfLines(); + ++segsel; } } - else if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18)) - { - for (int line = 0; line < 5424; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - for (int pixelx = 0; pixelx < 5424; pixelx++) - { - cred = *(pixelsRed + line * 5424 + pixelx); - cgreen = *(pixelsGreen + line * 5424 + pixelx); - cblue = *(pixelsBlue + line * 5424 + pixelx); + qDebug() << "end FormImage::OverlayOLCI(QPainter *paint)"; - r = quint8(inversevector[0] ? 255 - (int)(cred/4) : (int)(cred/4)); - g = quint8(inversevector[1] ? 255 - (int)(cgreen/4) : (int)(cgreen/4)); - b = quint8(inversevector[2] ? 255 - (int)(cblue/4) : (int)(cblue/4)); +} - row_col[pixelx] = qRgb(r,g,b); - } - } +void FormImage::displayVIIRSImageInfo(eSegmentType type) +{ + QString segtype; + int nbrselected; + float moonillum; - } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::GOMS3) + switch(type) { + case SEG_NONE: + segtype = "None"; + break; + case SEG_VIIRSM: + segtype = "VIIRSM"; + nbrselected = segs->seglviirsm->NbrOfSegmentsSelected(); - for(int i = 0; i < 6; i++) - { - for (int line = 0; line < 464; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 464 + line); - for (int pixelx = 0; pixelx < 2784; pixelx++) - { - cred = *(pixelsRed + i * 464 * 2784 + line * 2784 + pixelx); - cgreen = *(pixelsGreen + i * 464 * 2784 + line * 2784 + pixelx); - cblue = *(pixelsBlue + i * 464 * 2784 + line * 2784 + pixelx); + break; + case SEG_VIIRSDNB: + segtype = "VIIRSDNB"; + nbrselected = segs->seglviirsdnb->NbrOfSegmentsSelected(); + moonillum = segs->seglviirsdnb->getMoonIllumination(); - r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); - - row_col[pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getKindofImage() == "HRV") - { - if(sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8) - { - for(int i = 0; i < (sl->bisRSS ? 5 : (sl->areatype == 1 ? 24 : 5)); i++) - { - for (int line = 463; line >= 0; line--) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 5 : (sl->areatype == 1 ? 24 : 5))*464 - i * 464 - line - 1); - for (int pixelx = 5567; pixelx >= 0; pixelx--) - { - c = *(pixelsHRV + i * 464 * 5568 + line * 5568 + pixelx); - r = quint8(inversevector[0] ? 255 - c/4 : c/4); - g = quint8(inversevector[0] ? 255 - c/4 : c/4); - b = quint8(inversevector[0] ? 255 - c/4 : c/4); + break; + case SEG_VIIRSMNOAA20: + segtype = "VIIRSMNOAA20"; + nbrselected = segs->seglviirsmnoaa20->NbrOfSegmentsSelected(); - row_col[5567-pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G) - { - for (int line = 0; line < 9152; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - for (int pixelx = 0; pixelx < 9152; pixelx++) - { - c = *(pixelsHRV + line * 9152 + pixelx); + break; + case SEG_VIIRSDNBNOAA20: + segtype = "VIIRSDNBNOAA20"; + nbrselected = segs->seglviirsdnbnoaa20->NbrOfSegmentsSelected(); + moonillum = segs->seglviirsdnbnoaa20->getMoonIllumination(); - r = quint8(inversevector[0] ? 255 - c : c); - g = quint8(inversevector[0] ? 255 - c : c); - b = quint8(inversevector[0] ? 255 - c : c); - row_col[pixelx] = qRgb(r,g,b); - } - } - } + break; + default: + segtype = "NA"; + break; } - else if(sl->getKindofImage() == "VIS_IR") - { - if(sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 ) - { - for(int i = 0 ; i < (sl->bisRSS ? 3 : 8); i++) - { - for (int line = 463; line >= 0; line--) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 3*464 : 3712) - i * 464 - line - 1); - for (int pixelx = 3711; pixelx >= 0; pixelx--) - { - c = *(pixelsRed + i * 464 * 3712 + line * 3712 + pixelx); - - r = quint8(inversevector[0] ? 255 - c/4 : c/4); - g = quint8(inversevector[0] ? 255 - c/4 : c/4); - b = quint8(inversevector[0] ? 255 - c/4 : c/4); - - row_col[3711 - pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::GOMS3) - { - for(int i = 0 ; i < 6; i++) - { - //for (int line = 463; line >= 0; line--) - for (int line = 0; line < 464; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 464 + line); - for (int pixelx = 0; pixelx < 2784; pixelx++) - { - c = *(pixelsRed + i * 464 * 2784 + line * 2784 + pixelx); - // if(i == 0 && line == 300) - // qDebug() << pixelx << " " << c; - r = quint8(inversevector[0] ? 255 - c/4 : c/4); - g = quint8(inversevector[0] ? 255 - c/4 : c/4); - b = quint8(inversevector[0] ? 255 - c/4 : c/4); + if(type == SEG_VIIRSM || type == SEG_VIIRSMNOAA20) + { + txtInfo = QString("" + "Info" + "" + "

Image Information

" + "

Segment type = %1
" + "Nbr of segments = %2
" + "Image width = %3 height = %4
" + "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageViirsM->width()).arg(imageptrs->ptrimageViirsM->height()); + formtoolbox->writeInfoToTextEdit(txtInfo); - row_col[pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::H8 ) + } else + if(type == SEG_VIIRSDNB || type == SEG_VIIRSDNBNOAA20) { - qDebug() << "in if(sl->getGeoSatellite() == eGeoSatellite::H8 )"; - - for(int i = 0 ; i < 10; i++) - { - //for (int line = 549; line >= 0; line--) - for (int line = 0; line < 550; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 550 + line); - for (int pixelx = 0; pixelx < 5500; pixelx++) - { - c = *(pixelsRed + i * 550 * 5500 + line * 5500 + pixelx); - - r = quint8(inversevector[0] ? 255 - c/4 : c/4); - g = quint8(inversevector[0] ? 255 - c/4 : c/4); - b = quint8(inversevector[0] ? 255 - c/4 : c/4); + txtInfo = QString("" + "Info" + "" + "

Image Information

" + "

Segment type = %1
" + "Nbr of segments = %2
" + "Image width = %3 height = %4
" + "Moon illumination = %5 %

" + "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageViirsDNB->width()) + .arg(imageptrs->ptrimageViirsDNB->height()).arg(moonillum, 4, 'f', 2); + formtoolbox->writeInfoToTextEdit(txtInfo); - row_col[pixelx] = qRgb(r,g,b); - } - } - } } - else if(sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G) - { - qDebug() << "recalculate CLAHE ; VIS_IR and FY2H/G move to ptrImageGeostationary"; - - for (int line = 0; line < 2288; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - for (int pixelx = 0; pixelx < 2288; pixelx++) - { - c = *(pixelsRed + line * 2288 + pixelx); - - r = quint8(inversevector[0] ? 255 - c : c); - g = quint8(inversevector[0] ? 255 - c : c); - b = quint8(inversevector[0] ? 255 - c : c); - row_col[pixelx] = qRgb(r,g,b); - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18) - { - qDebug() << "recalculate CLAHE ; VIS_IR and GOES_16/_17 move to ptrImageGeostationary"; - for (int line = 0; line < 5424; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - for (int pixelx = 0; pixelx < 5424; pixelx++) - { - c = *(pixelsRed + line * 5424 + pixelx); +} - r = quint8(inversevector[0] ? 255 - (int)(c/4) : (int)(c/4)); - g = quint8(inversevector[0] ? 255 - (int)(c/4) : (int)(c/4)); - b = quint8(inversevector[0] ? 255 - (int)(c/4) : (int)(c/4)); +void FormImage::displaySentinelImageInfo(eSegmentType type) +{ + QString segtype; + int nbrselected; + long nbrofsaturatedpixels; - row_col[pixelx] = qRgb(r,g,b); - } - } - } + switch(type) + { + case SEG_NONE: + segtype = "None"; + break; + case SEG_OLCIEFR: + segtype = "OLCI efr"; + nbrselected = segs->seglolciefr->NbrOfSegmentsSelected(); + nbrofsaturatedpixels = segs->seglolciefr->NbrOfSaturatedPixels(); + break; + case SEG_OLCIERR: + segtype = "OLCI err"; + nbrselected = segs->seglolcierr->NbrOfSegmentsSelected(); + nbrofsaturatedpixels = segs->seglolcierr->NbrOfSaturatedPixels(); + break; + case SEG_SLSTR: + segtype = "SLSTR"; + nbrselected = segs->seglslstr->NbrOfSegmentsSelected(); + break; + default: + segtype = "NA"; + break; } - if(sl->getKindofImage() == "VIS_IR Color" ) - { - delete [] pixelsRed; - delete [] pixelsGreen; - delete [] pixelsBlue; - } - else if(sl->getKindofImage() == "HRV") + if(type == SEG_OLCIEFR || type == SEG_OLCIERR) { - delete [] pixelsHRV; + txtInfo = QString("" + "Info" + "" + "

Image Information

" + "

Segment type = %1
" + "Nbr of segments = %2
" + "Image width = %3 height = %4
" + "Nbr of saturated pixels = %5
" + "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageOLCI->width()).arg(imageptrs->ptrimageOLCI->height()).arg(nbrofsaturatedpixels); + formtoolbox->writeInfoToTextEdit(txtInfo); } - else + else if(type == SEG_SLSTR) { - delete [] pixelsRed; + txtInfo = QString("" + "Info" + "" + "

Image Information

" + "

Segment type = %1
" + "Nbr of segments = %2
" + "Image width = %3 height = %4
" + "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageSLSTR->width()).arg(imageptrs->ptrimageSLSTR->height()); + formtoolbox->writeInfoToTextEdit(txtInfo); } - if(sl->getKindofImage() != "HRV" && sl->getKindofImage() != "HRV Color") - if(opts.imageontextureOnMet) - emit render3dgeo(sl->getGeoSatelliteIndex()); - - QApplication::restoreOverrideCursor(); } -void FormImage::recalculateCLAHE1(QVector spectrumvector, QVector inversevector) +void FormImage::displayMERSIImageInfo(eSegmentType type) { + QString segtype; + int nbrselected; - QRgb *row_col; - quint16 cred, cgreen, cblue, c; - quint16 r,g, b; + segtype = "MERSI"; + nbrselected = segs->seglmersi->NbrOfSegmentsSelected(); - SegmentListGeostationary *sl; + txtInfo = QString("" + "Info" + "" + "

Image Information

" + "

Segment type = %1
" + "Nbr of segments = %2
" + "Image width = %3 height = %4
" + "").arg(segtype).arg(nbrselected).arg(imageptrs->ptrimageMERSI->width()).arg(imageptrs->ptrimageMERSI->height()); + formtoolbox->writeInfoToTextEdit(txtInfo); - sl = segs->getActiveSegmentList(); - if(sl == NULL) - return; +} - if (sl->getKindofImage() == "HRV Color") - return; +bool FormImage::ShowVIIRSMImage() +{ + bool ret = false; - int geoindex = sl->getGeoSatelliteIndex(); - size_t npix; - size_t npixHRV; + if(opts.buttonVIIRSM) + viirsmcount = segs->seglviirsm->NbrOfSegmentsSelected(); + else if(opts.buttonVIIRSMNOAA20) + viirsmcount = segs->seglviirsmnoaa20->NbrOfSegmentsSelected(); - npix = opts.geosatellites.at(geoindex).imageheight * opts.geosatellites.at(geoindex).imagewidth; - if (sl->areatype == 1) - npixHRV = opts.geosatellites.at(geoindex).imageheighthrv1 * opts.geosatellites.at(geoindex).imagewidthhrv1; - else - npixHRV = opts.geosatellites.at(geoindex).imageheighthrv0 * opts.geosatellites.at(geoindex).imagewidthhrv0; + QList bandlist; + QList colorlist; + QList invertlist; - QApplication::setOverrideCursor( Qt::WaitCursor ); // this might take time + qDebug() << QString("in FormImage::ShowVIIRSImage nbr of viirs segments selected = %1").arg(viirsmcount); - quint16 *pixelsRed; - quint16 *pixelsGreen; - quint16 *pixelsBlue; - quint16 *pixelsHRV; + if (viirsmcount > 0) + { - qDebug() << QString("recalculateCLAHE() ; kind of image = %1").arg(sl->getKindofImage()); + ret = true; + displayImage(IMAGE_VIIRSM, true); - if(sl->getKindofImage() == "VIS_IR") - { - pixelsRed = new quint16[npix]; - int segmentlengthtot = opts.geosatellites.at(geoindex).imagewidth * opts.geosatellites.at(geoindex).segmentlength; - for( int i = (opts.geosatellites.at(geoindex).rss ? opts.geosatellites.at(geoindex).startsegmentnbrtype0 : 0); i < opts.geosatellites.at(geoindex).maxsegments ; i++) - { - qDebug() << QString(" i = %1 segmentlengthtot = %2 ispresent : %3").arg(i).arg(segmentlengthtot).arg(sl->isPresentRed[i]); - if(sl->isPresentRed[i] || opts.geosatellites.at(geoindex).imageheight == opts.geosatellites.at(geoindex).segmentlength) - memcpy(pixelsRed + (opts.geosatellites.at(geoindex).rss ? i - opts.geosatellites.at(geoindex).startsegmentnbrtype0 : i) * segmentlengthtot, imageptrs->ptrRed[i], segmentlengthtot * sizeof(quint16)); - } + emit allsegmentsreceivedbuttons(false); - } - else if(sl->getKindofImage() == "VIS_IR Color") - { - pixelsRed = new quint16[npix]; - pixelsGreen = new quint16[npix]; - pixelsBlue = new quint16[npix]; - int segmentlengthtot = opts.geosatellites.at(geoindex).imagewidth * opts.geosatellites.at(geoindex).segmentlength; + this->kindofimage = "VIIRSM"; - for( int i = (opts.geosatellites.at(geoindex).rss ? opts.geosatellites.at(geoindex).startsegmentnbrtype0 : 0); i < opts.geosatellites.at(geoindex).maxsegments ; i++) - { - if(sl->isPresentRed[i] || opts.geosatellites.at(geoindex).imageheight == opts.geosatellites.at(geoindex).segmentlength) - memcpy(pixelsRed + (opts.geosatellites.at(geoindex).rss ? i - opts.geosatellites.at(geoindex).startsegmentnbrtype0 : i) * segmentlengthtot, imageptrs->ptrRed[i], segmentlengthtot * sizeof(quint16)); - } - for( int i = (opts.geosatellites.at(geoindex).rss ? opts.geosatellites.at(geoindex).startsegmentnbrtype0 : 0); i < opts.geosatellites.at(geoindex).maxsegments ; i++) - { - if(sl->isPresentGreen[i] || opts.geosatellites.at(geoindex).imageheight == opts.geosatellites.at(geoindex).segmentlength) - memcpy(pixelsGreen + (opts.geosatellites.at(geoindex).rss ? i - opts.geosatellites.at(geoindex).startsegmentnbrtype0 : i) * segmentlengthtot, imageptrs->ptrGreen[i], segmentlengthtot * sizeof(quint16)); - } - for( int i = (opts.geosatellites.at(geoindex).rss ? opts.geosatellites.at(geoindex).startsegmentnbrtype0 : 0); i < opts.geosatellites.at(geoindex).maxsegments ; i++) - { - if(sl->isPresentBlue[i] || opts.geosatellites.at(geoindex).imageheight == opts.geosatellites.at(geoindex).segmentlength) - memcpy(pixelsBlue + (opts.geosatellites.at(geoindex).rss ? i - opts.geosatellites.at(geoindex).startsegmentnbrtype0 : i) * segmentlengthtot, imageptrs->ptrBlue[i], segmentlengthtot * sizeof(quint16)); - } + bandlist = formtoolbox->getVIIRSMBandList(); + colorlist = formtoolbox->getVIIRSMColorList(); + invertlist = formtoolbox->getVIIRSMInvertList(); + if(opts.buttonVIIRSM) + segs->seglviirsm->ShowImageSerial(bandlist, colorlist, invertlist); + else if(opts.buttonVIIRSMNOAA20) + segs->seglviirsmnoaa20->ShowImageSerial(bandlist, colorlist, invertlist); } - else if(sl->getKindofImage() == "HRV") - { - pixelsHRV = new quint16[npixHRV]; - int segmentlengthtot; - if(sl->areatype == 0) - segmentlengthtot = opts.geosatellites.at(geoindex).imagewidthhrv0 * opts.geosatellites.at(geoindex).segmentlengthhrv; - else - segmentlengthtot = opts.geosatellites.at(geoindex).imagewidthhrv1 * opts.geosatellites.at(geoindex).segmentlengthhrv; + else + ret = false; + return ret; - for( int i = 0, k = 0; i < (opts.geosatellites.at(geoindex).rss ? opts.geosatellites.at(geoindex).startsegmentnbrtype0 : ( sl->areatype == 1 ? opts.geosatellites.at(geoindex).maxsegmentshrv : opts.geosatellites.at(geoindex).startsegmentnbrtype0)); i++) - { - k = (opts.geosatellites.at(geoindex).rss ? opts.geosatellites.at(geoindex).startsegmentnbrhrvtype0 + i : (sl->areatype == 1 ? i : opts.geosatellites.at(geoindex).startsegmentnbrhrvtype0 + i)); - if(opts.geosatellites.at(geoindex).imageheighthrv0 == opts.geosatellites.at(geoindex).segmentlengthhrv) k = 0; - if(sl->isPresentHRV[k] || opts.geosatellites.at(geoindex).imageheighthrv0 == opts.geosatellites.at(geoindex).segmentlengthhrv) - { - memcpy(pixelsHRV + i * segmentlengthtot, imageptrs->ptrHRV[k], segmentlengthtot * sizeof(quint16)); - } - } +} - } +bool FormImage::ShowVIIRSDNBImage() +{ + bool ret = false; + + viirsdnbcount = segs->seglviirsdnb->NbrOfSegmentsSelected(); - if(sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18) + qDebug() << QString("in FormImage::ShowVIIRSDNBImage nbr of viirs segments selected = %1").arg(viirsdnbcount); + if (viirsdnbcount > 0) { - if(sl->getKindofImage() == "VIS_IR Color") - { - for(int i = 0; i < npix; i++) - { - if(*(pixelsRed+i) == imageptrs->fillvalue[0] ) - *(pixelsRed + i) = 0; - if(*(pixelsGreen+i) == imageptrs->fillvalue[1] ) - *(pixelsGreen + i) = 0; - if(*(pixelsBlue+i) == imageptrs->fillvalue[2] ) - *(pixelsBlue + i) = 0; - if(imageptrs->ptrDQF[0][i] == 2) - { - *(pixelsRed+i) = 1023; - *(pixelsGreen+i) = 1023; - *(pixelsBlue+i) = 1023; - } - } - } - else if(sl->getKindofImage() == "VIS_IR") - { + ret = true; + displayImage(IMAGE_VIIRSDNB, true); + emit allsegmentsreceivedbuttons(false); - for(int i = 0; i < npix; i++) - { - if(*(pixelsRed+i) == imageptrs->fillvalue[0] ) - *(pixelsRed + i) = 0; - if(imageptrs->ptrDQF[0][i] == 2) - *(pixelsRed+i) = 1023; - } - } + this->kindofimage = "VIIRSDNB"; + + segs->seglviirsdnb->ShowImageSerial(); } + else + ret = false; + + return ret; +} +bool FormImage::ShowOLCIefrImage(int histogrammethod, bool normalized) +{ + bool ret = false; - int ret = 0; - int segmentheight; - int nbrsegments; + olciefrcount = segs->seglolciefr->NbrOfSegmentsSelected(); - if(opts.geosatellites.at(geoindex).rss) - segmentheight = (opts.geosatellites.at(geoindex).maxsegments - opts.geosatellites.at(geoindex).startsegmentnbrtype0) * opts.geosatellites.at(geoindex).segmentlength; - else - segmentheight = opts.geosatellites.at(geoindex).maxsegments * opts.geosatellites.at(geoindex).segmentlength; + QList bandlist; + QList colorlist; + QList invertlist; + qDebug() << QString("in FormImage::ShowOLCIefrImage nbr of olci efr segments selected = %1").arg(olciefrcount); - if(sl->getKindofImage() == "VIS_IR Color") - { - imageptrs->CLAHE(pixelsRed, opts.geosatellites.at(geoindex).imagewidth, segmentheight, 0, 1023, opts.geosatellites.at(geoindex).clahecontextregionx, opts.geosatellites.at(geoindex).clahecontextregiony, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsGreen, opts.geosatellites.at(geoindex).imagewidth, segmentheight, 0, 1023, opts.geosatellites.at(geoindex).clahecontextregionx, opts.geosatellites.at(geoindex).clahecontextregiony, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsBlue, opts.geosatellites.at(geoindex).imagewidth, segmentheight, 0, 1023, opts.geosatellites.at(geoindex).clahecontextregionx, opts.geosatellites.at(geoindex).clahecontextregiony, 256, opts.clahecliplimit); - } - else if(sl->getKindofImage() == "VIS_IR") - { - imageptrs->CLAHE(pixelsRed, opts.geosatellites.at(geoindex).imagewidth, segmentheight, 0, 1023, opts.geosatellites.at(geoindex).clahecontextregionx, opts.geosatellites.at(geoindex).clahecontextregiony, 256, opts.clahecliplimit); - } - else if(sl->getKindofImage() == "HRV") + if (olciefrcount > 0) { - if(opts.geosatellites.at(geoindex).rss) - segmentheight = (opts.geosatellites.at(geoindex).maxsegmentshrv - opts.geosatellites.at(geoindex).startsegmentnbrhrvtype0) * opts.geosatellites.at(geoindex).segmentlengthhrv; - else - segmentheight = opts.geosatellites.at(geoindex).maxsegmentshrv * opts.geosatellites.at(geoindex).segmentlengthhrv; - if(sl->areatype == 1) - imageptrs->CLAHE(pixelsHRV, opts.geosatellites.at(geoindex).imagewidthhrv1, opts.geosatellites.at(geoindex).imageheighthrv1, 0, 1023, opts.geosatellites.at(geoindex).clahecontextregionx, opts.geosatellites.at(geoindex).clahecontextregiony, 256, opts.clahecliplimit); - else - imageptrs->CLAHE(pixelsRed, opts.geosatellites.at(geoindex).imagewidthhrv0, segmentheight, 0, 1023, opts.geosatellites.at(geoindex).clahecontextregionx, opts.geosatellites.at(geoindex).clahecontextregiony, 256, opts.clahecliplimit); + // ret = true; + // displayImage(IMAGE_OLCI); - } + // emit allsegmentsreceivedbuttons(false); - qDebug() << "---> After CLAHE"; + this->kindofimage = "OLCIEFR"; - if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) - { - for(int i = 0; i < (sl->bisRSS ? 3 : 8); i++) - { - for (int line = 463; line >= 0; line--) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 3*464 : 3712) - i * 464 - line - 1); + bandlist = formtoolbox->getOLCIBandList(); + colorlist = formtoolbox->getOLCIColorList(); + invertlist = formtoolbox->getOLCIInvertList(); - for (int pixelx = 3711; pixelx >= 0; pixelx--) - { - cred = *(pixelsRed + i * 464 * 3712 + line * 3712 + pixelx); - cgreen = *(pixelsGreen + i * 464 * 3712 + line * 3712 + pixelx); - cblue = *(pixelsBlue + i * 464 * 3712 + line * 3712 + pixelx); + QStringList missing; + segs->seglolciefr->setHistogramMethod(histogrammethod, normalized); + if(segs->seglolciefr->CheckForOLCIFiles(bandlist, colorlist, missing) == false) // parameter false = no decompression of the files + { + formtoolbox->setToolboxButtons(true); + emit setmapcylbuttons(true); - r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); + QMessageBox msgBox; + QString txt = "In one or more segments, the following files are missing : \n"; + for(int i = 0; i < missing.count(); i++) + { + txt.append(missing.at(i) + "\n"); + } + msgBox.setText(txt); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Warning); + int ret = msgBox.exec(); - row_col[3711 - pixelx] = qRgb(r,g,b); - } + switch (ret) { + case QMessageBox::Ok: + break; + default: + break; } + return false; } + else + segs->seglolciefr->ComposeOLCIImage(bandlist, colorlist, invertlist, false, histogrammethod, normalized); + } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::H8) - { + else + ret = false; - for(int i = 0; i < 10; i++) - { - for (int line = 0; line < 550; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 550 + line); - for (int pixelx = 0; pixelx < 5500; pixelx++) - { - cred = *(pixelsRed + i * 550 * 5500 + line * 5500 + pixelx); - cgreen = *(pixelsGreen + i * 550 * 5500 + line * 5500 + pixelx); - cblue = *(pixelsBlue + i * 550 * 5500 + line * 5500 + pixelx); + return ret; - r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); +} - row_col[pixelx] = qRgb(r,g,b); - } - } - } - } +bool FormImage::ShowOLCIerrImage(int histogrammethod, bool normalized) +{ + bool ret = false; - // bool scandirection = true; - // if(sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 ) - // scandirection = false; - // if(sl->getKindofImage() == "VIS_IR Color") - // { - // if(opts.geosatellites.at(geoindex).rss) - // nbrsegments = opts.geosatellites.at(geoindex).maxsegments - opts.geosatellites.at(geoindex).startsegmentnbrtype0; - // else - // nbrsegments = opts.geosatellites.at(geoindex).maxsegments; - - // segmentheight = nbrsegments * opts.geosatellites.at(geoindex).segmentlength; - - // for(int i = 0; i < nbrsegments; i++) - // { - // if(scandirection == false) - // { - // for (int line = opts.geosatellites.at(geoindex).segmentlength; line >= 0; line--) - // { - // row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(segmentheight - i * opts.geosatellites.at(geoindex).segmentlength - line - 1); - - // for (int pixelx = opts.geosatellites.at(geoindex).imagewidth; pixelx >= 0; pixelx--) - // { - // int segmentpixels = opts.geosatellites.at(geoindex).segmentlength * opts.geosatellites.at(geoindex).imagewidth; - // cred = *(pixelsRed + i * segmentpixels + line * opts.geosatellites.at(geoindex).imagewidth + pixelx); - // cgreen = *(pixelsGreen + i * segmentpixels + line * opts.geosatellites.at(geoindex).imagewidth + pixelx); - // cblue = *(pixelsBlue + i * segmentpixels + line * opts.geosatellites.at(geoindex).imagewidth + pixelx); - - // r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - // g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - // b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); - - // row_col[opts.geosatellites.at(geoindex).imagewidth - pixelx] = qRgb(r,g,b); - // } - // } - - // } - // else - // { - // for (int line = 0; line < opts.geosatellites.at(geoindex).segmentlength; line++) - // { - // row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * opts.geosatellites.at(geoindex).segmentlength + line); - - // for (int pixelx = 0; pixelx < opts.geosatellites.at(geoindex).imagewidth; pixelx++) - // { - // int segmentpixels = opts.geosatellites.at(geoindex).segmentlength * opts.geosatellites.at(geoindex).imagewidth; - // cred = *(pixelsRed + i * segmentpixels + line * opts.geosatellites.at(geoindex).imagewidth + pixelx); - // cgreen = *(pixelsGreen + i * segmentpixels + line * opts.geosatellites.at(geoindex).imagewidth + pixelx); - // cblue = *(pixelsBlue + i * segmentpixels + line * opts.geosatellites.at(geoindex).imagewidth + pixelx); - - // r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - // g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - // b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); - - // row_col[pixelx] = qRgb(r,g,b); - // } - // } - // } - // } - // } + olcierrcount = segs->seglolcierr->NbrOfSegmentsSelected(); - /* - if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) + QList bandlist; + QList colorlist; + QList invertlist; + + qDebug() << QString("in FormImage::ShowOLCIerrImage nbr of olci err segments selected = %1").arg(olcierrcount); + + if (olcierrcount > 0) { - for(int i = 0; i < (sl->bisRSS ? 3 : 8); i++) - { - for (int line = 463; line >= 0; line--) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 3*464 : 3712) - i * 464 - line - 1); - for (int pixelx = 3711; pixelx >= 0; pixelx--) - { - cred = *(pixelsRed + i * 464 * 3712 + line * 3712 + pixelx); - cgreen = *(pixelsGreen + i * 464 * 3712 + line * 3712 + pixelx); - cblue = *(pixelsBlue + i * 464 * 3712 + line * 3712 + pixelx); + ret = true; + displayImage(IMAGE_OLCI, true); + emit allsegmentsreceivedbuttons(false); - r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); + this->kindofimage = "OLCIERR"; - row_col[3711 - pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::H8) - { + bandlist = formtoolbox->getOLCIBandList(); + colorlist = formtoolbox->getOLCIColorList(); + invertlist = formtoolbox->getOLCIInvertList(); - for(int i = 0; i < 10; i++) + QStringList missing; + segs->seglolcierr->setHistogramMethod(histogrammethod, normalized); + if(segs->seglolcierr->CheckForOLCIFiles(bandlist, colorlist, missing) == false) { - for (int line = 0; line < 550; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 550 + line); - for (int pixelx = 0; pixelx < 5500; pixelx++) - { - cred = *(pixelsRed + i * 550 * 5500 + line * 5500 + pixelx); - cgreen = *(pixelsGreen + i * 550 * 5500 + line * 5500 + pixelx); - cblue = *(pixelsBlue + i * 550 * 5500 + line * 5500 + pixelx); + formtoolbox->setToolboxButtons(true); - r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); + emit setmapcylbuttons(true); - row_col[pixelx] = qRgb(r,g,b); - } + QMessageBox msgBox; + QString txt = "In one or more segments, the following files are missing : \n"; + for(int i = 0; i < missing.count(); i++) + { + txt.append(missing.at(i) + "\n"); } + msgBox.setText(txt); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Warning); + int ret = msgBox.exec(); + + switch (ret) { + case QMessageBox::Ok: + break; + default: + break; + } + return false; } + else + segs->seglolcierr->ComposeOLCIImage(bandlist, colorlist, invertlist, false, histogrammethod, normalized); + } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::GOES_16) - { + else + ret = false; - for (int line = 0; line < 5424; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - for (int pixelx = 0; pixelx < 5424; pixelx++) - { - cred = *(pixelsRed + line * 5424 + pixelx); - cgreen = *(pixelsGreen + line * 5424 + pixelx); - cblue = *(pixelsBlue + line * 5424 + pixelx); + return ret; - r = quint8(inversevector[0] ? 255 - (int)(cred/4) : (int)(cred/4)); - g = quint8(inversevector[1] ? 255 - (int)(cgreen/4) : (int)(cgreen/4)); - b = quint8(inversevector[2] ? 255 - (int)(cblue/4) : (int)(cblue/4)); +} - row_col[pixelx] = qRgb(r,g,b); - } - } +bool FormImage::ShowSLSTRImage(int histogrammethod) +{ + bool ret = false; - } - else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::GOMS3) - { + slstrcount = segs->seglslstr->NbrOfSegmentsSelected(); - for(int i = 0; i < 6; i++) - { - for (int line = 0; line < 464; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 464 + line); - for (int pixelx = 0; pixelx < 2784; pixelx++) - { - cred = *(pixelsRed + i * 464 * 2784 + line * 2784 + pixelx); - cgreen = *(pixelsGreen + i * 464 * 2784 + line * 2784 + pixelx); - cblue = *(pixelsBlue + i * 464 * 2784 + line * 2784 + pixelx); + QList bandlist; + QList colorlist; + QList invertlist; - r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); - g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); - b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); + qDebug() << QString("in FormImage::ShowSLSTRImage nbr of slstr segments selected = %1").arg(slstrcount); - row_col[pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getKindofImage() == "HRV") + if (slstrcount > 0) { - if(sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8) - { - for(int i = 0; i < (sl->bisRSS ? 5 : (sl->areatype == 1 ? 24 : 5)); i++) - { - for (int line = 463; line >= 0; line--) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 5 : (sl->areatype == 1 ? 24 : 5))*464 - i * 464 - line - 1); - for (int pixelx = 5567; pixelx >= 0; pixelx--) - { - c = *(pixelsHRV + i * 464 * 5568 + line * 5568 + pixelx); - r = quint8(inversevector[0] ? 255 - c/4 : c/4); - g = quint8(inversevector[0] ? 255 - c/4 : c/4); - b = quint8(inversevector[0] ? 255 - c/4 : c/4); - row_col[5567-pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::FY2E || sl->getGeoSatellite() == eGeoSatellite::FY2G) - { - for (int line = 0; line < 9152; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - for (int pixelx = 0; pixelx < 9152; pixelx++) - { - c = *(pixelsHRV + line * 9152 + pixelx); + ret = true; + displayImage(IMAGE_SLSTR, true); - r = quint8(inversevector[0] ? 255 - c : c); - g = quint8(inversevector[0] ? 255 - c : c); - b = quint8(inversevector[0] ? 255 - c : c); - row_col[pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getKindofImage() == "VIS_IR") - { - if(sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 ) - { - for(int i = 0 ; i < (sl->bisRSS ? 3 : 8); i++) - { - for (int line = 463; line >= 0; line--) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 3*464 : 3712) - i * 464 - line - 1); - for (int pixelx = 3711; pixelx >= 0; pixelx--) - { - c = *(pixelsRed + i * 464 * 3712 + line * 3712 + pixelx); + emit allsegmentsreceivedbuttons(false); - r = quint8(inversevector[0] ? 255 - c/4 : c/4); - g = quint8(inversevector[0] ? 255 - c/4 : c/4); - b = quint8(inversevector[0] ? 255 - c/4 : c/4); + this->kindofimage = "SLSTR"; - row_col[3711 - pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::GOES_15) - { - for(int i = 0 ; i < 7; i++) - { - //for (int line = 463; line >= 0; line--) - for (int line = 0; line < 464; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 464 + line); - for (int pixelx = 0; pixelx < 2816; pixelx++) - { - c = *(pixelsRed + i * 464 * 2816 + line * 2816 + pixelx); + bandlist = formtoolbox->getSLSTRBandList(); + colorlist = formtoolbox->getSLSTRColorList(); + invertlist = formtoolbox->getSLSTRInvertList(); + segs->seglslstr->setHistogramMethod(histogrammethod); + segs->seglslstr->ComposeSLSTRImage(bandlist, colorlist, invertlist, false, formtoolbox->getSLSTRImageView()); + } + else + ret = false; - r = quint8(inversevector[0] ? 255 - c/4 : c/4); - g = quint8(inversevector[0] ? 255 - c/4 : c/4); - b = quint8(inversevector[0] ? 255 - c/4 : c/4); + return ret; - row_col[pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::GOMS3) - { - for(int i = 0 ; i < 6; i++) - { - //for (int line = 463; line >= 0; line--) - for (int line = 0; line < 464; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 464 + line); - for (int pixelx = 0; pixelx < 2784; pixelx++) - { - c = *(pixelsRed + i * 464 * 2784 + line * 2784 + pixelx); +} -// if(i == 0 && line == 300) -// qDebug() << pixelx << " " << c; +bool FormImage::ShowMERSIImage(int histogrammethod, bool normalized) +{ + bool ret = false; - r = quint8(inversevector[0] ? 255 - c/4 : c/4); - g = quint8(inversevector[0] ? 255 - c/4 : c/4); - b = quint8(inversevector[0] ? 255 - c/4 : c/4); + mersicount = segs->seglmersi->NbrOfSegmentsSelected(); - row_col[pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::H8 ) - { - qDebug() << "in if(sl->getGeoSatellite() == eGeoSatellite::H8 )"; + QList bandlist; + QList colorlist; + QList invertlist; - for(int i = 0 ; i < 10; i++) - { - //for (int line = 549; line >= 0; line--) - for (int line = 0; line < 550; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 550 + line); - for (int pixelx = 0; pixelx < 5500; pixelx++) - { - c = *(pixelsRed + i * 550 * 5500 + line * 5500 + pixelx); + qDebug() << QString("in FormImage::ShowMERSIImage nbr of mersi segments selected = %1").arg(mersicount); - r = quint8(inversevector[0] ? 255 - c/4 : c/4); - g = quint8(inversevector[0] ? 255 - c/4 : c/4); - b = quint8(inversevector[0] ? 255 - c/4 : c/4); + if (mersicount > 0) + { - row_col[pixelx] = qRgb(r,g,b); - } - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::FY2E || sl->getGeoSatellite() == eGeoSatellite::FY2G) - { - for (int line = 0; line < 2288; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - for (int pixelx = 0; pixelx < 2288; pixelx++) - { - c = *(pixelsRed + line * 2288 + pixelx); + ret = true; + displayImage(IMAGE_MERSI, true); - r = quint8(inversevector[0] ? 255 - c : c); - g = quint8(inversevector[0] ? 255 - c : c); - b = quint8(inversevector[0] ? 255 - c : c); + emit allsegmentsreceivedbuttons(false); - row_col[pixelx] = qRgb(r,g,b); - } - } - } - else if(sl->getGeoSatellite() == eGeoSatellite::GOES_16) - { - for (int line = 0; line < 5424; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - for (int pixelx = 0; pixelx < 5424; pixelx++) - { - c = *(pixelsRed + line * 5424 + pixelx); + this->kindofimage = "MERSI"; - r = quint8(inversevector[0] ? 255 - (int)(c/4) : (int)(c/4)); - g = quint8(inversevector[0] ? 255 - (int)(c/4) : (int)(c/4)); - b = quint8(inversevector[0] ? 255 - (int)(c/4) : (int)(c/4)); + bandlist = formtoolbox->getMERSIBandList(); // 16 items + colorlist = formtoolbox->getMERSIColorList(); // 15 items + invertlist = formtoolbox->getMERSIInvertList(); - row_col[pixelx] = qRgb(r,g,b); - } - } - } - } + // qDebug()<< "FormImage::ShowMERSIImage() bandlist"; + // for(int i = 0; i < 16; i++) + // { + // qDebug() << bandlist.at(i); + // } -*/ + // qDebug()<< "FormImage::ShowMERSIImage() colorlist"; + // for(int i = 0; i < 15; i++) + // { + // qDebug() << colorlist.at(i); + // } - if(sl->getKindofImage() == "VIS_IR Color" ) - { - delete [] pixelsRed; - delete [] pixelsGreen; - delete [] pixelsBlue; - } - else if(sl->getKindofImage() == "HRV") - { - delete [] pixelsHRV; + segs->seglmersi->setHistogramMethod(histogrammethod, normalized); + segs->seglmersi->ComposeMERSIImage(bandlist, colorlist, invertlist, false, histogrammethod, normalized); } else - { - delete [] pixelsRed; - } + ret = false; - if(sl->getKindofImage() != "HRV" && sl->getKindofImage() != "HRV Color") - if(opts.imageontextureOnMet) - emit render3dgeo(sl->getGeoSatelliteIndex()); - - QApplication::restoreOverrideCursor(); + return ret; } -void FormImage::CLAHERGBRecipe(float cliplimit) +void FormImage::recalculateCLAHE(QVector spectrumvector, QVector inversevector) { + QRgb *row_col; - quint16 red, green, blue; - int npix = 3712 * 3712; - quint16 *pixelsRed = new quint16[npix]; - quint16 *pixelsGreen = new quint16[npix]; - quint16 *pixelsBlue = new quint16[npix]; + quint16 cred, cgreen, cblue, c; + quint16 r,g, b; - qDebug() << "ptrimageGeostationary width = " << imageptrs->ptrimageGeostationary->width(); - if(imageptrs->ptrimageGeostationary->width() != 3712) + SegmentListGeostationary *sl; + + sl = segs->getActiveSegmentList(); + if(sl == NULL) return; - for (int line = 0; line < 3712; line++) - { - for (int pixelx = 0; pixelx < 3712; pixelx++) - { - int i_image = line * 3712 + pixelx; - pixelsRed[i_image] = imageptrs->ptrimageRGBRecipeRed[i_image]; - pixelsGreen[i_image] = imageptrs->ptrimageRGBRecipeGreen[i_image]; - pixelsBlue[i_image] = imageptrs->ptrimageRGBRecipeBlue[i_image]; - } - } - imageptrs->CLAHE(pixelsRed, 3712, 3712, 0, 255, 16, 16, 256, cliplimit); - imageptrs->CLAHE(pixelsGreen, 3712, 3712, 0, 255, 16, 16, 256, cliplimit); - imageptrs->CLAHE(pixelsBlue, 3712, 3712, 0, 255, 16, 16, 256, cliplimit); + if (sl->getKindofImage() == "HRV Color") + return; + int geoindex = sl->getGeoSatelliteIndex(); + size_t npix; + size_t npixHRV; - for (int line = 0; line < 3712; line++) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); - for (int pixelx = 0; pixelx < 3712; pixelx++) - { - int i_image = line * 3712 + pixelx; + npix = opts.geosatellites.at(geoindex).imageheight * opts.geosatellites.at(geoindex).imagewidth; + if (sl->areatype == 1) + npixHRV = opts.geosatellites.at(geoindex).imageheighthrv1 * opts.geosatellites.at(geoindex).imagewidthhrv1; + else + npixHRV = opts.geosatellites.at(geoindex).imageheighthrv0 * opts.geosatellites.at(geoindex).imagewidthhrv0; - red = pixelsRed[i_image]; - green = pixelsGreen[i_image]; - blue = pixelsBlue[i_image]; - row_col[pixelx] = qRgb((int)red, (int)green, (int)blue); - } - } + if(sl->getGeoSatellite() == eGeoSatellite::MTG_I1) + return; - delete [] pixelsRed; - delete [] pixelsGreen; - delete [] pixelsBlue; -} + if(imageptrs->ptrRed[0] == NULL) + return; + QApplication::setOverrideCursor( Qt::WaitCursor ); // this might take time -void FormImage::CLAHEprojection() -{ quint16 *pixelsRed; quint16 *pixelsGreen; quint16 *pixelsBlue; - QRgb *scan; - QRgb rgb; - int projwidth = imageptrs->ptrimageProjection->width(); - int projheight = imageptrs->ptrimageProjection->height(); - - qDebug() << "FormImage::CLAHEprojection()"; - - QApplication::setOverrideCursor( Qt::WaitCursor ); // this might take time + quint16 *pixelsHRV; - pixelsRed = new quint16[projwidth * projheight]; - pixelsGreen = new quint16[projwidth * projheight]; - pixelsBlue = new quint16[projwidth * projheight]; + qDebug() << QString("recalculateCLAHE() ; kind of image = %1").arg(sl->getKindofImage()); - for(int line = 0; line < projheight; line++) + if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) { - scan = (QRgb *)imageptrs->ptrimageProjection->scanLine(line); + pixelsRed = new quint16[npix]; + pixelsGreen = new quint16[npix]; + pixelsBlue = new quint16[npix]; - for(int pixelx = 0; pixelx < projwidth; pixelx++) + for( int i = (sl->bisRSS ? 5 : 0); i < 8; i++) { - rgb = scan[pixelx]; - pixelsRed[line * projwidth + pixelx] = qRed(rgb); - pixelsGreen[line * projwidth + pixelx] = qGreen(rgb); - pixelsBlue[line * projwidth + pixelx] = qBlue(rgb); - + if(sl->isPresentRed[i]) + memcpy(pixelsRed + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrRed[i], 464 * 3712 * sizeof(quint16)); } - } - - imageptrs->CLAHE(pixelsRed, projwidth, projheight, 0, 1023, 16, 16, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsGreen, projwidth, projheight, 0, 1023, 16, 16, 256, opts.clahecliplimit); - imageptrs->CLAHE(pixelsBlue, projwidth, projheight, 0, 1023, 16, 16, 256, opts.clahecliplimit); - - - - for(int line = 0; line < projheight; line++) - { - scan = (QRgb *)imageptrs->ptrimageProjection->scanLine(line); - - for(int pixelx = 0; pixelx < projwidth; pixelx++) + for( int i = (sl ->bisRSS ? 5 : 0); i < 8; i++) { - rgb = qRgb(pixelsRed[line * projwidth + pixelx], - pixelsGreen[line * projwidth + pixelx], - pixelsBlue[line * projwidth + pixelx]); - scan[pixelx] = rgb; - + if(sl->isPresentGreen[i]) + memcpy(pixelsGreen + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrGreen[i], 464 * 3712 * sizeof(quint16)); } - } - - this->UpdateProjection(); - - QApplication::restoreOverrideCursor(); - - delete [] pixelsRed; - delete [] pixelsGreen; - delete [] pixelsBlue; -} - - -void FormImage::fillptrimage(quint16 *pix) -{ - QRgb *row_col; - quint16 c; - int r,g, b; - - qDebug() << "in fillptrimage"; - for(int i = 0; i < 8; i++) - { - for (int line = 463; line >= 0; line--) + for( int i = (sl ->bisRSS ? 5 : 0); i < 8; i++) { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(3711 - i * 464 - line); - for (int pixelx = 3711; pixelx >= 0; pixelx--) - { - c = *(pix + i * 464 * 3712 + line * 3712 + pixelx); - - r = quint8(c/4); - g = quint8(c/4); - b = quint8(c/4); - - row_col[3711 - pixelx] = qRgb(r,g,b); - } + if(sl->isPresentBlue[i]) + memcpy(pixelsBlue + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrBlue[i], 464 * 3712 * sizeof(quint16)); } } -} - -void FormImage::fillptrimageHRV(quint16 *pixHRV) -{ - QRgb *row_col; - quint16 c; - int r,g, b; - qDebug() << "in fillptrimageHRV"; - for(int i = 0; i < (segs->seglgeo[0]->areatype == 1 ? 24 : 5); i++) + if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::MTG_I1)) { - for (int line = 463; line >= 0; line--) - { - row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((segs->seglgeo[0]->areatype == 1 ? 24 : 5)*464 - i * 464 - line); - for (int pixelx = 5567; pixelx >= 0; pixelx--) - { - c = *(pixHRV + i * 464 * 5568 + line * 5568 + pixelx); - - r = quint8(c/4); - g = quint8(c/4); - b = quint8(c/4); + pixelsRed = new quint16[npix]; + pixelsGreen = new quint16[npix]; + pixelsBlue = new quint16[npix]; - row_col[5567 - pixelx] = qRgb(r,g,b); - } + for( int i = (sl->bisRSS ? 5 : 0); i < 8; i++) + { + if(sl->isPresentRed[i]) + memcpy(pixelsRed + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrRed[i], 464 * 3712 * sizeof(quint16)); } - } -} - -void FormImage::OverlayGeostationary(QPainter *paint, SegmentListGeostationary *sl) -{ - - qDebug() << "FormImage::OverlayGeostationary(QPainter *paint, SegmentListGeostationary *sl)"; - - if (imageLabel->pixmap() == 0) - return; - if(sl == NULL) - return; - - pixgeoConversion pixconv; - - int col, save_col; - int row, save_row; - bool first = true; - - double lat_deg; - double lon_deg; - int ret; - bool hrvimage; - - long coff; - long loff; - double cfac; - double lfac; - - int geoindex = sl->getGeoSatelliteIndex(); - - if(sl != NULL) - { - if(sl->getKindofImage() == "HRV" || sl->getKindofImage() == "HRV Color") - hrvimage = true; - else - hrvimage = false; - - // if(sl->getGeoSatellite() == eGeoSatellite::H8) - // { - // QPoint pt(opts.geosatellites.at(geoindex).coff, opts.geosatellites.at(geoindex).loff); - // paint->setPen(qRgb(0, 0, 255)); - // paint->drawEllipse(pt, opts.geosatellites.at(geoindex).coff - 28, opts.geosatellites.at(geoindex).loff - 40); - // } - } - else - return; - - double sub_lon = sl->geosatlon; - lat_deg = opts.obslat; - lon_deg = opts.obslon; - if (lon_deg > 180.0) - lon_deg -= 360.0; - - coff = hrvimage ? opts.geosatellites.at(geoindex).coffhrv : opts.geosatellites.at(geoindex).coff; - loff = hrvimage ? opts.geosatellites.at(geoindex).loffhrv : opts.geosatellites.at(geoindex).loff; - cfac = hrvimage ? opts.geosatellites.at(geoindex).cfachrv : opts.geosatellites.at(geoindex).cfac; - lfac = hrvimage ? opts.geosatellites.at(geoindex).lfachrv : opts.geosatellites.at(geoindex).lfac; - - - ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, coff, loff, cfac, lfac, &col, &row); - if(ret == 0) - { - if(hrvimage) + for( int i = (sl ->bisRSS ? 5 : 0); i < 8; i++) { - if (row > 11136 - sl->LowerNorthLineActual ) //LOWER - { - col = col - (11136 - sl->LowerWestColumnActual); - } - else //UPPER - { - col = col - (11136 - sl->UpperWestColumnActual - 1); - } + if(sl->isPresentGreen[i]) + memcpy(pixelsGreen + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrGreen[i], 464 * 3712 * sizeof(quint16)); } - - QPoint pt(col, row); - QPoint ptleft(col-5, row); - QPoint ptright(col+5, row); - QPoint ptup(col, row-5); - QPoint ptdown(col, row+5); - - paint->setPen(qRgb(255, 0, 0)); - paint->drawLine(ptleft,ptright); - paint->drawLine(ptup,ptdown); - //paint->drawEllipse(pt, 2, 2); - } - - - if(!hrvimage) - { - for(int i = 0; i < this->geooverlay.count(); i++) + for( int i = (sl ->bisRSS ? 5 : 0); i < 8; i++) { - if (this->geooverlay.at(i).x() < 0) - { - first = true; - } - else if(first == true) - { - first = false; - save_col = (int)this->geooverlay.at(i).x(); - save_row = (int)this->geooverlay.at(i).y(); - } - else - { - paint->setPen(opts.geoimageoverlaycolor1); - paint->drawLine(save_col, save_row, (int)this->geooverlay.at(i).x(), (int)this->geooverlay.at(i).y()); - save_col = (int)this->geooverlay.at(i).x(); - save_row = (int)this->geooverlay.at(i).y(); - } + if(sl->isPresentBlue[i]) + memcpy(pixelsBlue + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrBlue[i], 464 * 3712 * sizeof(quint16)); } } - else - OverlayGeostationaryHRV(paint, sl, geoindex); -} - -void FormImage::OverlayGeostationaryHRV(QPainter *paint, SegmentListGeostationary *sl, int geoindex) -{ - - long coff; - long loff; - double cfac; - double lfac; - - int col, save_col; - int row, save_row; - bool first = true; - - double lat_deg; - double lon_deg; - int ret; - - pixgeoConversion pixconv; - - //if(sl->LowerNorthLineActual == 0) - // return; - - coff = opts.geosatellites.at(geoindex).coffhrv; - loff = opts.geosatellites.at(geoindex).loffhrv; - cfac = opts.geosatellites.at(geoindex).cfachrv; - lfac = opts.geosatellites.at(geoindex).lfachrv; - - double sub_lon = sl->geosatlon; - - - if(opts.gshhsglobe1On) - { - first = true; - - for (int i=0; ivxp_data_overlay[0]->nFeatures; i++) - { - for (int j=0; jvxp_data_overlay[0]->pFeatures[i].nVerts; j++) - { - lat_deg = gshhsdata->vxp_data_overlay[0]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; - lon_deg = gshhsdata->vxp_data_overlay[0]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; - if (lon_deg > 180.0) - lon_deg -= 360.0; - - if((lon_deg < 90.0 || lon_deg > -90.0)) - { - ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, coff, loff, cfac, lfac, &col, &row); - row+=5; //3; - col+=3; //2; - - if(ret == 0) - { - if(sl->getGeoSatellite() != eGeoSatellite::FY2H && sl->getGeoSatellite() != eGeoSatellite::FY2G) - { - if (row > 11136 - sl->LowerNorthLineActual ) //LOWER - { - if( save_row <= 11136 - sl->LowerNorthLineActual ) - first = true; - col = col - (11136 - sl->LowerWestColumnActual); - } - else //UPPER - { - if( save_row > 11136 - sl->LowerNorthLineActual ) - first = true; - col = col - (11136 - sl->UpperWestColumnActual - 1); - } - } - - if (first) - { - first = false; - save_col = col; - save_row = row; - } - else - { - paint->setPen(opts.geoimageoverlaycolor1); - paint->drawLine(save_col, save_row, col, row); - save_col = col; - save_row = row; - } - } - else - first = true; - } - } - first = true; - } - } - - if(opts.gshhsglobe2On) - { - first = true; - - for (int i=0; ivxp_data_overlay[1]->nFeatures; i++) - { - for (int j=0; jvxp_data_overlay[1]->pFeatures[i].nVerts; j++) - { - lat_deg = gshhsdata->vxp_data_overlay[1]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; - lon_deg = gshhsdata->vxp_data_overlay[1]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; - if (lon_deg > 180.0) - lon_deg -= 360.0; - - if(lon_deg < 90.0 || lon_deg > -90.0) - { - ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, coff, loff, cfac, lfac, &col, &row); - row+=5; //3; - col+=3; //2; - - if(ret == 0) - { - if(sl->getGeoSatellite() != eGeoSatellite::FY2H && sl->getGeoSatellite() != eGeoSatellite::FY2G) - { - if (row > 11136 - sl->LowerNorthLineActual ) //LOWER - { - if( save_row <= 11136 - sl->LowerNorthLineActual ) - first = true; - col = col - (11136 - sl->LowerWestColumnActual); - } - else //UPPER - { - if( save_row > 11136 - sl->LowerNorthLineActual ) - first = true; - col = col - (11136 - sl->UpperWestColumnActual - 1); - } - } - - if (first) - { - first = false; - save_col = col; - save_row = row; - } - else - { - paint->setPen(opts.geoimageoverlaycolor2); - paint->drawLine(save_col, save_row, col, row); - save_col = col; - save_row = row; - } - } - else - first = true; - } - } - first = true; - } - } - - if(opts.gshhsglobe3On) - { - first = true; - - for (int i=0; ivxp_data_overlay[2]->nFeatures; i++) - { - for (int j=0; jvxp_data_overlay[2]->pFeatures[i].nVerts; j++) - { - lat_deg = gshhsdata->vxp_data_overlay[2]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; - lon_deg = gshhsdata->vxp_data_overlay[2]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; - if (lon_deg > 180.0) - lon_deg -= 360.0; - - if(lon_deg < 90.0 || lon_deg > -90.0) - { - - ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, coff, loff, cfac, lfac, &col, &row); - row+=5; //3; - col+=3; //2; - - if(ret == 0) - { - if(sl->getGeoSatellite() != eGeoSatellite::FY2H && sl->getGeoSatellite() != eGeoSatellite::FY2G) - { - if (row > 11136 - sl->LowerNorthLineActual ) //LOWER - { - if( save_row <= 11136 - sl->LowerNorthLineActual ) - first = true; - col = col - (11136 - sl->LowerWestColumnActual); - } - else //UPPER - { - if( save_row > 11136 - sl->LowerNorthLineActual ) - first = true; - col = col - (11136 - sl->UpperWestColumnActual - 1); - } - } - - if (first) - { - first = false; - save_col = col; - save_row = row; - } - else - { - paint->setPen(opts.geoimageoverlaycolor3); - paint->drawLine(save_col, save_row, col, row); - save_col = col; - save_row = row; - } - } - else - first = true; - } - } - first = true; - } - } - - //this->update(); -} - -void FormImage::setupGeoOverlay(int geoindex) -{ - - int col, save_col; - int row, save_row; - bool first = true; - - double lat_deg; - double lon_deg; - int ret; - double sub_lon; - - double fgf_x, fgf_y; - - pixgeoConversion pixconv; - - sub_lon = opts.geosatellites.at(geoindex).longitude; - - this->geooverlay.clear(); - - double scale_x = 0.000056; - double scale_y = -0.000056; - double offset_x = -0.151844; - double offset_y = 0.151844; - int sat = 1; - - for(int k = 0; k < 2; k++) - { - if(opts.gshhsglobe1On) - { - first = true; - - for (int i=0; ivxp_data_overlay[k]->nFeatures; i++) - { - for (int j=0; jvxp_data_overlay[k]->pFeatures[i].nVerts; j++) - { - lat_deg = gshhsdata->vxp_data_overlay[k]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; - lon_deg = gshhsdata->vxp_data_overlay[k]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; - if (lon_deg > 180.0) - lon_deg -= 360.0; - - if(lon_deg < 90.0 || lon_deg > -90.0) - { - if(opts.geosatellites.at(geoindex).shortname == "GOES_16" || opts.geosatellites.at(geoindex).shortname == "GOES_17") - { - pixconv.earth_to_fgf_(&sat, &lon_deg, &lat_deg, &scale_x, &offset_x, &scale_y, &offset_y, &sub_lon, &fgf_x, &fgf_y); - if(fgf_x >= 0 && fgf_x < opts.geosatellites.at(geoindex).imagewidth && fgf_y >= 0 && fgf_y < opts.geosatellites.at(geoindex).imageheight) - { - col = (int)fgf_x; - row = (int)fgf_y; - ret = 0; - } - else - ret = 1; - } - else - { - ret = pixconv.geocoord2pixcoord(sub_lon, lat_deg, lon_deg, opts.geosatellites.at(geoindex).coff, - opts.geosatellites.at(geoindex).loff, opts.geosatellites.at(geoindex).cfac, opts.geosatellites.at(geoindex).lfac, &col, &row); - - } - if(ret == 0) - { - if (first) - { - first = false; - save_col = col; - save_row = row; - this->geooverlay.append(QVector2D(-1, -1)); - } - else - { - save_col = col; - save_row = row; - } - - this->geooverlay.append(QVector2D(col, row)); - - } - else - first = true; - } - } - first = true; - } - } - } - - qDebug() << QString("geooverlay length = %1").arg(this->geooverlay.count()); - -} - - - -/* -void FormImage::OverlayAVHRRImage(QPainter *paint) -{ - QList *slmetop = segs->seglmetop->GetSegsSelectedptr(); - - int cnt = slmetop->count(); - - QList::iterator segsel = slmetop->begin(); - while ( segsel != slmetop->end() ) - { - SegmentMetop *segm = (SegmentMetop *)(*segsel); - - for(int x = 1; x < 103; x++) - { - for(int y = 1; y < 1080;y++) - { - if(segm->earth_loc_lon[y-1][x-1] < opts.obslon && opts.obslon < segm->earth_loc_lon[y-1][x] && - segm->earth_loc_lon[y][x-1] < opts.obslon && opts.obslon < segm->earth_loc_lon[y][x]) // && - //segm->earth_loc_lat[y-1][x-1] > opts.obslat && opts.obslat > segm->earth_loc_lat[y][x-1] && - //segm->earth_loc_lat[y-1][x] > opts.obslat && opts.obslat > segm->earth_loc_lat[y][x]) - { - QPoint pt(x, y); - paint->setPen(qRgb(255, 0, 0)); - paint->drawEllipse(pt, 2, 2); - } - - } - } - ++segsel; - } - - //slmetop->earth_loc_lon[1080][103] -} -*/ - -void FormImage::OverlayProjection(QPainter *paint) -{ - qDebug() << QString("FormImage::OverlayProjection(QPainter *paint, SegmentListGeostationary *sl) opts.currenttoolbox = %1").arg(opts.currenttoolbox); - if(!paint->isActive()) - return; - - double lat_deg; - double lon_deg; - bool bret; - - double map_x, map_y; - double save_map_x, save_map_y; - - lat_deg = opts.obslat; - lon_deg = opts.obslon; - if (lon_deg > 180.0) - lon_deg -= 360.0; - - if (opts.currenttoolbox == 0) // LCC - bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); - else if (opts.currenttoolbox == 1) // GVP - bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else if (opts.currenttoolbox == 2) //SG - bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else if (opts.currenttoolbox == 3) //OM - bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else - bret = false; - - if(bret) - { - - QPoint pt(map_x, map_y); - QPoint ptleft(map_x-5, map_y); - QPoint ptright(map_x+5, map_y); - QPoint ptup(map_x, map_y-5); - QPoint ptdown(map_x, map_y+5); - - paint->setPen(qRgb(255, 0, 0)); - paint->drawLine(ptleft,ptright); - paint->drawLine(ptup,ptdown); - - // QPoint pt(map_x-1, map_y-1); - // paint->setPen(qRgb(255, 0, 0)); - // paint->drawEllipse(pt, 2, 2); - } - - bool first = true; - - if(opts.gshhsglobe1On) - { - for (int i=0; ivxp_data_overlay[0]->nFeatures; i++) - { - for (int j=0; jvxp_data_overlay[0]->pFeatures[i].nVerts; j++) - { - lat_deg = gshhsdata->vxp_data_overlay[0]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; - lon_deg = gshhsdata->vxp_data_overlay[0]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; - if (lon_deg > 180.0) - lon_deg -= 360.0; - - if (opts.currenttoolbox == 0) //LCC - bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); - else if (opts.currenttoolbox == 1) //GVP - bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); - else if (opts.currenttoolbox == 2) //SG - bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); - else if (opts.currenttoolbox == 3) //OM - bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); - else - bret = false; - - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - if(abs(save_map_y - map_y) < 100 && (abs(save_map_x - map_x) < 100)) - { - paint->setPen(QColor(opts.projectionoverlaycolor1)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - } - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; - } - first = true; - } - } - - first = true; - - if(opts.gshhsglobe2On) - { - for (int i=0; ivxp_data_overlay[1]->nFeatures; i++) - { - for (int j=0; jvxp_data_overlay[1]->pFeatures[i].nVerts; j++) - { - lat_deg = gshhsdata->vxp_data_overlay[1]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; - lon_deg = gshhsdata->vxp_data_overlay[1]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; - if (lon_deg > 180.0) - lon_deg -= 360.0; - - if (opts.currenttoolbox == 0) //LCC - bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); - else if (opts.currenttoolbox == 1) //GVP - bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else if (opts.currenttoolbox == 2) //SG - bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else if (opts.currenttoolbox == 3) //OM - bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else - bret = false; - - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - if(abs(save_map_y - map_y) < 100 && (abs(save_map_x - map_x) < 100)) - { - paint->setPen(QColor(opts.projectionoverlaycolor2)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - } - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; - } - first = true; - } - } - - first = true; - - if(opts.gshhsglobe3On) - { - for (int i=0; ivxp_data_overlay[2]->nFeatures; i++) - { - for (int j=0; jvxp_data_overlay[2]->pFeatures[i].nVerts; j++) - { - lat_deg = gshhsdata->vxp_data_overlay[2]->pFeatures[i].pLonLat[j].latmicro*1.0e-6; - lon_deg = gshhsdata->vxp_data_overlay[2]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6; - if (lon_deg > 180.0) - lon_deg -= 360.0; - - if (opts.currenttoolbox == 0) //LCC - bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); - else if (opts.currenttoolbox == 1) //GVP - bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else if (opts.currenttoolbox == 2) //SG - bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else if (opts.currenttoolbox == 3) //OM - bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else - bret = false; - - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - if(abs(save_map_y - map_y) < 100 && (abs(save_map_x - map_x) < 100)) - { - paint->setPen(QColor(opts.projectionoverlaycolor3)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - } - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; - } - first = true; - } - } - - if (opts.currenttoolbox == 0 && formtoolbox->GridOnProjLCC()) // LLC - { - for(double lon = -180.0; lon < 180.0; lon+=10.0) - { - first = true; - - //if(lon >= opts.mapextentwest && lon < opts.mapextenteast) - { - for(double lat = -90.0; lat < 90.0; lat+=0.5) - { - bret = imageptrs->lcc->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); - - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; - - } - } - } - - for(double lat = -80.0; lat < 81.0; lat+=10.0) - { - first = true; - if(lat >= opts.mapextentsouth && lat < opts.mapextentnorth) - { - for(double lon = -180.0; lon < 180.0; lon+=1.0) - { - bret = imageptrs->lcc->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); - - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; - - } - } - } - } - - if (opts.currenttoolbox == 1 && formtoolbox->GridOnProjGVP()) //GVP + else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::GOMS3) { - for(double lon = -180.0; lon < 180.0; lon+=10.0) - { - first = true; - { - for(double lat = -90.0; lat < 90.0; lat+=0.5) - { - bret = imageptrs->gvp->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); - - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; + pixelsRed = new quint16[npix]; + pixelsGreen = new quint16[npix]; + pixelsBlue = new quint16[npix]; - } - } + for( int i = 0; i < 6; i++) + { + if(sl->isPresentRed[i]) + memcpy(pixelsRed + i * 464 * 2784, imageptrs->ptrRed[i], 464 * 2784 * sizeof(quint16)); } - - for(double lat = -80.0; lat < 81.0; lat+=10.0) + for( int i = 0; i < 6; i++) { - first = true; - { - for(double lon = -180.0; lon < 180.0; lon+=1.0) - { - bret = imageptrs->gvp->map_forward( lon*PI/180.0, lat*PI/180.0, map_x, map_y); + if(sl->isPresentGreen[i]) + memcpy(pixelsGreen + i * 464 * 2784, imageptrs->ptrGreen[i], 464 * 2784 * sizeof(quint16)); + } + for( int i = 0; i < 6; i++) + { + if(sl->isPresentBlue[i]) + memcpy(pixelsBlue + i * 464 * 2784, imageptrs->ptrBlue[i], 464 * 2784 * sizeof(quint16)); + } + } + else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::H8) + { - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; + pixelsRed = new quint16[npix]; + pixelsGreen = new quint16[npix]; + pixelsBlue = new quint16[npix]; - } - } + for( int i = 0; i < 10; i++) + { + if(sl->isPresentRed[i]) + memcpy(pixelsRed + i * 550 * 5500, imageptrs->ptrRed[i], 550 * 5500 * sizeof(quint16)); + } + for( int i = 0; i < 10; i++) + { + if(sl->isPresentGreen[i]) + memcpy(pixelsGreen + i * 550 * 5500, imageptrs->ptrGreen[i], 550 * 5500 * sizeof(quint16)); + } + for( int i = 0; i < 10; i++) + { + if(sl->isPresentBlue[i]) + memcpy(pixelsBlue + i * 550 * 5500, imageptrs->ptrBlue[i], 550 * 5500 * sizeof(quint16)); } } + else if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18)) + { + pixelsRed = new quint16[npix]; + pixelsGreen = new quint16[npix]; + pixelsBlue = new quint16[npix]; + memcpy(pixelsRed, imageptrs->ptrRed[0], npix * sizeof(quint16)); + memcpy(pixelsGreen, imageptrs->ptrGreen[0], npix * sizeof(quint16)); + memcpy(pixelsBlue, imageptrs->ptrBlue[0], npix * sizeof(quint16)); - if (opts.currenttoolbox == 2 && formtoolbox->GridOnProjSG() ) //SG - { - for(double lon = -180.0; lon < 180.0; lon+=10.0) + for(int i = 0; i < npix; i++) { - first = true; + if(*(pixelsRed+i) == imageptrs->fillvalue[0] ) + *(pixelsRed + i) = 0; + if(*(pixelsGreen+i) == imageptrs->fillvalue[1] ) + *(pixelsGreen + i) = 0; + if(*(pixelsBlue+i) == imageptrs->fillvalue[2] ) + *(pixelsBlue + i) = 0; + if(imageptrs->ptrDQF[0][i] == 2) { - for(double lat = -90.0; lat < 90.0; lat+=0.5) - { - bret = imageptrs->sg->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); - - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; - - } + *(pixelsRed+i) = 1023; + *(pixelsGreen+i) = 1023; + *(pixelsBlue+i) = 1023; } } - for(double lat = -80.0; lat < 81.0; lat+=10.0) + } + else if(sl->getKindofImage() == "HRV" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) + { + pixelsHRV = new quint16[npixHRV]; + for( int i = 0, k = 0; i < (sl->bisRSS ? 5 : ( sl->areatype == 1 ? 24 : 5)); i++) { - first = true; + k = (sl->bisRSS ? 19 + i : (sl->areatype == 1 ? i : 19 + i)); + if(sl->isPresentHRV[k]) { - for(double lon = -180.0; lon < 180.0; lon+=1.0) - { - bret = imageptrs->sg->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); - - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; - - } + memcpy(pixelsHRV + i * 464 * 5568, imageptrs->ptrHRV[k], 464 * 5568 * sizeof(quint16)); } } } - - if (opts.currenttoolbox == 3) //OM + else if(sl->getKindofImage() == "HRV" && (sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G )) { - QPolygonF poly; - if(opts.buttonMERSI) - segs->seglmersi->GetContourPolygon(&poly); - else if(opts.buttonVIIRSM) - segs->seglviirsm->GetContourPolygon(&poly); - else if(opts.buttonVIIRSMNOAA20) - segs->seglviirsmnoaa20->GetContourPolygon(&poly); - else if(opts.buttonMetop) - segs->seglmetop->GetContourPolygonAVHRR(&poly); - - for(int i = 0; i < poly.size(); i++) + pixelsHRV = new quint16[npixHRV]; + memcpy(pixelsHRV, imageptrs->ptrHRV[0], 9152 * 9152 * sizeof(quint16)); + } + else if(sl->getKindofImage() == "VIS_IR" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) + { + pixelsRed = new quint16[npix]; + for( int i = (sl->bisRSS ? 5 : 0); i < 8 ; i++) { - bret = imageptrs->om->map_forward( poly.at(i).x()*PI/180, poly.at(i).y()*PI/180, map_x, map_y); - if(bret) - { - paint->setPen(QColor(255, 0, 255)); - paint->drawPoint(map_x, map_y); - } + if(sl->isPresentRed[i]) + memcpy(pixelsRed + (sl->bisRSS ? i - 5 : i) * 464 * 3712, imageptrs->ptrRed[i], 464 * 3712 * sizeof(quint16)); + } + } + else if(sl->getKindofImage() == "VIS_IR" && sl->getGeoSatellite() == eGeoSatellite::GOMS3) + { + pixelsRed = new quint16[npix]; + for( int i = 0; i < 6 ; i++) + { + if(sl->isPresentRed[i]) + memcpy(pixelsRed + i * 464 * 2784, imageptrs->ptrRed[i], 464 * 2784 * sizeof(quint16)); } + } + else if(sl->getKindofImage() == "VIS_IR" && (sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G )) + { + pixelsRed = new quint16[npix]; + memcpy(pixelsRed, imageptrs->ptrRed[0], npix * sizeof(quint16)); + } + else if(sl->getKindofImage() == "VIS_IR" && (sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18 )) + { + pixelsRed = new quint16[npix]; + memcpy(pixelsRed, imageptrs->ptrRed[0], npix * sizeof(quint16)); - if(opts.sattrackinimage) + for(int i = 0; i < npix; i++) { - QPolygonF track; - if(opts.buttonMERSI) - segs->seglmersi->GetTrackPolygon(&track); - else if(opts.buttonVIIRSM) - segs->seglviirsm->GetTrackPolygon(&track); - else if(opts.buttonVIIRSMNOAA20) - segs->seglviirsmnoaa20->GetTrackPolygon(&track); - else if(opts.buttonMetop) - segs->seglmetop->GetTrackPolygonAVHRR(&track); + if(*(pixelsRed+i) == imageptrs->fillvalue[0] ) + *(pixelsRed + i) = 0; + if(imageptrs->ptrDQF[0][i] == 2) + *(pixelsRed+i) = 1023; + } + } + else if(sl->getKindofImage() == "VIS_IR" && sl->getGeoSatellite() == eGeoSatellite::H8) + { + pixelsRed = new quint16[npix]; + for( int i = 0; i < 10 ; i++) + { + if(sl->isPresentRed[i]) + memcpy(pixelsRed + i * 550 * 5500, imageptrs->ptrRed[i], 550 * 5500 * sizeof(quint16)); + } + } - first = true; - for(int i = 0; i < track.size(); i++) + int ret = 0; + + + if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) + { + imageptrs->CLAHE(pixelsRed, 3712, (sl->bisRSS ? 3*464 : 3712), 0, 1023, 16, 16, 256, opts.clahecliplimit); + imageptrs->CLAHE(pixelsGreen, 3712, (sl->bisRSS ? 3*464 : 3712), 0, 1023, 16, 16, 256, opts.clahecliplimit); + imageptrs->CLAHE(pixelsBlue, 3712, (sl->bisRSS ? 3*464 : 3712), 0, 1023, 16, 16, 256, opts.clahecliplimit); + } + else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::GOMS3) + { + imageptrs->CLAHE(pixelsRed, 2784, 2784, 0, 1023, 16, 16, 256, opts.clahecliplimit); + imageptrs->CLAHE(pixelsGreen, 2784, 2784, 0, 1023, 16, 16, 256, opts.clahecliplimit); + imageptrs->CLAHE(pixelsBlue, 2784, 2784, 0, 1023, 16, 16, 256, opts.clahecliplimit); + } + else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::H8 ) + { + ret = imageptrs->CLAHE(pixelsRed, 5500, 5500, 0, 1023, 10, 10, 256, opts.clahecliplimit); + imageptrs->CLAHE(pixelsGreen, 5500, 5500, 0, 1023, 10, 10, 256, opts.clahecliplimit); + imageptrs->CLAHE(pixelsBlue, 5500, 5500, 0, 1023, 10, 10, 256, opts.clahecliplimit); + } + else if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18) ) + { + ret = imageptrs->CLAHE(pixelsRed, 5424, 5424, 0, 1023, 16, 16, 256, opts.clahecliplimit); + qDebug() << QString("pixelsRed ret = %1").arg(ret); + ret = imageptrs->CLAHE(pixelsGreen, 5424, 5424, 0, 1023, 16, 16, 256, opts.clahecliplimit); + qDebug() << QString("pixelsGreen ret = %1").arg(ret); + ret = imageptrs->CLAHE(pixelsBlue, 5424, 5424, 0, 1023, 16, 16, 256, opts.clahecliplimit); + qDebug() << QString("pixelsBlue ret = %1").arg(ret); + } + else if(sl->getKindofImage() == "HRV" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8)) + { + if(sl->bisRSS) + { + imageptrs->CLAHE(pixelsHRV, 5568, 5*464, 0, 1023, 16, 16, 256, opts.clahecliplimit); + + } + else + { + if(sl->areatype == 1) { - bret = imageptrs->om->map_forward( track.at(i).x()*PI/180, track.at(i).y()*PI/180, map_x, map_y); - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - paint->setPen(QColor(0, 0, 255)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - save_map_x = map_x; - save_map_y = map_y; - } - } + imageptrs->CLAHE(pixelsHRV, 5568, 11136, 0, 1023, 16, 16, 256, opts.clahecliplimit); + } + else + { + imageptrs->CLAHE(pixelsHRV, 5568, 5*464, 0, 1023, 16, 16, 256, opts.clahecliplimit); } } } - - if (opts.currenttoolbox == 3 && formtoolbox->GridOnProjOM() ) //OM + else if(sl->getKindofImage() == "HRV" && (sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G )) + { + imageptrs->CLAHE(pixelsHRV, 9152, 9152, 0, 255, 16, 16, 256, opts.clahecliplimit); + } + else if(sl->getKindofImage() == "VIS_IR") { + if(sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8) + imageptrs->CLAHE(pixelsRed, 3712, (sl->bisRSS ? 3*464 : 3712), 0, 1023, 16, 16, 256, opts.clahecliplimit); + else if(sl->getGeoSatellite() == eGeoSatellite::GOMS3) + { + ret = imageptrs->CLAHE(pixelsRed, 2784, 464*6, 0, 1023, 16, 16, 256, opts.clahecliplimit); + } + else if(sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G) + imageptrs->CLAHE(pixelsRed, 2288, 2288, 0, 255, 16, 16, 256, opts.clahecliplimit); + else if(sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18) + imageptrs->CLAHE(pixelsRed, 5424, 5424, 0, 1023, 16, 16, 256, opts.clahecliplimit); + else if(sl->getGeoSatellite() == eGeoSatellite::H8) + imageptrs->CLAHE(pixelsRed, 5500, 5500, 0, 1023, 10, 10, 256, opts.clahecliplimit); + } - first = true; + qDebug() << "---> After CLAHE"; - for(double lon = -180.0; lon < 180.0; lon+=10.0) + if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 )) + { + for(int i = 0; i < (sl->bisRSS ? 3 : 8); i++) { - first = true; + for (int line = 463; line >= 0; line--) { - for(double lat = -80.0; lat < 81.0; lat+=0.5) + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 3*464 : 3712) - i * 464 - line - 1); + + for (int pixelx = 3711; pixelx >= 0; pixelx--) { - bret = imageptrs->om->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); + cred = *(pixelsRed + i * 464 * 3712 + line * 3712 + pixelx); + cgreen = *(pixelsGreen + i * 464 * 3712 + line * 3712 + pixelx); + cblue = *(pixelsBlue + i * 464 * 3712 + line * 3712 + pixelx); - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - // paint->drawPoint(map_x, map_y); - if(abs(save_map_x - map_x) < 200 && abs(save_map_y - map_y) < 200) - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; + r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); + g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); + b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); + + row_col[3711 - pixelx] = qRgb(r,g,b); } } } - for(double lat = -80.0; lat < 81.0; lat+=10.0) + } + else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::H8) + { + + for(int i = 0; i < 10; i++) { - first = true; + for (int line = 0; line < 550; line++) { - for(double lon = -180.0; lon < 180.0; lon+=1.0) + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 550 + line); + for (int pixelx = 0; pixelx < 5500; pixelx++) { - bret = imageptrs->om->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); + cred = *(pixelsRed + i * 550 * 5500 + line * 5500 + pixelx); + cgreen = *(pixelsGreen + i * 550 * 5500 + line * 5500 + pixelx); + cblue = *(pixelsBlue + i * 550 * 5500 + line * 5500 + pixelx); - if(bret) - { - if (first) - { - first = false; - save_map_x = map_x; - save_map_y = map_y; - } - else - { - paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - //paint->drawPoint(map_x, map_y); - if(abs(save_map_x - map_x) < 200 && abs(save_map_y - map_y) < 200) - paint->drawLine(save_map_x, save_map_y, map_x, map_y); - save_map_x = map_x; - save_map_y = map_y; - } - } - else - first = true; + r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); + g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); + b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); + row_col[pixelx] = qRgb(r,g,b); } } } - - - - } - - -} - -void FormImage::OverlayOLCI(QPainter *paint) -{ - SegmentListOLCI *sl; - qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 0"; - int height = imageptrs->ptrimageOLCI->height(); - int width = imageptrs->ptrimageOLCI->width(); - if( height == 0 || width == 0) - return; - - qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 1"; - qDebug() << "opts.buttonOLCIefr = " << opts.buttonOLCIefr; - qDebug() << "opts.buttonOLCIerr = " << opts.buttonOLCIerr; - qDebug() << "opts.buttonSLSTR = " << opts.buttonSLSTR; - - if(opts.buttonOLCIefr) - { - if(segs->seglolciefr->GetSegmentlistptr()->count() == 0) - return; } - else if(opts.buttonOLCIerr) + else if(sl->getKindofImage() == "VIS_IR Color" && (sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18)) { - if(segs->seglolcierr->GetSegmentlistptr()->count() == 0) - return; - } - else - return; - qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 2"; - if(opts.buttonOLCIefr) - sl = segs->seglolciefr; - else if(opts.buttonOLCIerr) - sl = segs->seglolcierr; - else return; + for (int line = 0; line < 5424; line++) + { + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); + for (int pixelx = 0; pixelx < 5424; pixelx++) + { + cred = *(pixelsRed + line * 5424 + pixelx); + cgreen = *(pixelsGreen + line * 5424 + pixelx); + cblue = *(pixelsBlue + line * 5424 + pixelx); - long nbrpt = 0; + r = quint8(inversevector[0] ? 255 - (int)(cred/4) : (int)(cred/4)); + g = quint8(inversevector[1] ? 255 - (int)(cgreen/4) : (int)(cgreen/4)); + b = quint8(inversevector[2] ? 255 - (int)(cblue/4) : (int)(cblue/4)); - qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 3"; - qDebug() << "FormImage::OverlayOLCI(QPainter *paint) ptrimageOLCI height = " << imageptrs->ptrimageOLCI->height(); - qDebug() << "opts.buttonOLCIefr = " << opts.buttonOLCIefr; - qDebug() << "opts.buttonOLCIerr = " << opts.buttonOLCIerr; - qDebug() << "opts.buttonSLSTR = " << opts.buttonSLSTR; - qDebug() << "segs->seglolciefr->GetSegmentlistptr()->count() = " << segs->seglolciefr->GetSegmentlistptr()->count(); - qDebug() << "segs->seglolcierr->GetSegmentlistptr()->count() = " << segs->seglolcierr->GetSegmentlistptr()->count(); - qDebug() << "segs->seglslstr->GetSegmentlistptr()->count() = " << segs->seglslstr->GetSegmentlistptr()->count(); + row_col[pixelx] = qRgb(r,g,b); + } + } - if(sl->GetSegsSelectedptr()->count() > 0) + } + else if(sl->getKindofImage() == "VIS_IR Color" && sl->getGeoSatellite() == eGeoSatellite::GOMS3) { - qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 4"; - - qDebug() << "segs->seglolci count selected = " << sl->GetSegsSelectedptr()->count(); - qDebug() << "height = " << imageptrs->ptrimageOLCI->height(); - qDebug() << "width = " << imageptrs->ptrimageOLCI->width(); - qDebug() << this->kindofimage; - - QList::iterator segsel = sl->GetSegsSelectedptr()->begin(); - int heightinsegment = 0; - while ( segsel != sl->GetSegsSelectedptr()->end() ) + for(int i = 0; i < 6; i++) { - SegmentOLCI *segm = (SegmentOLCI *)(*segsel); - paint->setPen(QColor(opts.olciimageoverlaycolor)); - QPolygon copycoastline = segm->coastline.translated(0, heightinsegment); - paint->drawPoints(copycoastline); + for (int line = 0; line < 464; line++) + { + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 464 + line); + for (int pixelx = 0; pixelx < 2784; pixelx++) + { + cred = *(pixelsRed + i * 464 * 2784 + line * 2784 + pixelx); + cgreen = *(pixelsGreen + i * 464 * 2784 + line * 2784 + pixelx); + cblue = *(pixelsBlue + i * 464 * 2784 + line * 2784 + pixelx); - // if(opts.gridonolciimage) - // { - // paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); - // QPolygon copylatlonline = segm->latlonline.translated(0, heightinsegment); - // paint->drawPoints(copylatlonline); - // } + r = quint8(inversevector[0] ? 255 - cred/4 : cred/4); + g = quint8(inversevector[1] ? 255 - cgreen/4 : cgreen/4); + b = quint8(inversevector[2] ? 255 - cblue/4 : cblue/4); - heightinsegment += segm->GetNbrOfLines(); - ++segsel; + row_col[pixelx] = qRgb(r,g,b); + } + } } } + else if(sl->getKindofImage() == "HRV") + { + if(sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8) + { + for(int i = 0; i < (sl->bisRSS ? 5 : (sl->areatype == 1 ? 24 : 5)); i++) + { + for (int line = 463; line >= 0; line--) + { + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 5 : (sl->areatype == 1 ? 24 : 5))*464 - i * 464 - line - 1); + for (int pixelx = 5567; pixelx >= 0; pixelx--) + { + c = *(pixelsHRV + i * 464 * 5568 + line * 5568 + pixelx); + r = quint8(inversevector[0] ? 255 - c/4 : c/4); + g = quint8(inversevector[0] ? 255 - c/4 : c/4); + b = quint8(inversevector[0] ? 255 - c/4 : c/4); - qDebug() << "end FormImage::OverlayOLCI(QPainter *paint)"; - -} - -void FormImage::ToInfraColorProjection() -{ - QRgb *row; - float btemp; - - float mintemp; - float maxtemp; - - int height = imageptrs->ptrimageProjection->height(); - int width = imageptrs->ptrimageProjection->width(); - - dockinfrascales->getMinMaxTemp(&mintemp, &maxtemp); - - qDebug() << QString("FormImage::ToInfraColorProjection() min temp = %1 max temp = %2").arg(mintemp).arg(maxtemp); - - float delta = maxtemp - mintemp; - - float min = 9999999.0; - float max = 0.0; - int valcount = 0; - - for(int y = 0; y < height; y++) - { - for(int x = 0; x < width; x++) - { - if(imageptrs->ptrProjectionBrightnessTemp.isNull()) - return; - btemp = imageptrs->ptrProjectionBrightnessTemp[y * width + x]; - float fval = (btemp - mintemp)/delta; - int val = qRound(fval*255.0); - if(btemp > 0) - { - if(btemp>=max) - max=btemp; - if(btemp<=min) - min=btemp; + row_col[5567-pixelx] = qRgb(r,g,b); + } + } } - } - } - - delta = max - min; - - qDebug() << QString("----> ToInfraColorProjection() min = %1 max = %2 valcount = %3").arg(min).arg(max).arg(valcount); - - - for(int y = 0; y < height; y++) - { - row = (QRgb*)imageptrs->ptrimageProjection->scanLine(y); - - for(int x = 0; x < width; x++) + else if(sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G) { - //quint8 greyval = imageptrs->ptrProjectionInfra[y * width + x]; - - if(imageptrs->ptrProjectionBrightnessTemp.isNull()) - return; - btemp = imageptrs->ptrProjectionBrightnessTemp[y * width + x]; - float fval = (btemp - min)/delta; - if(btemp > 0) + for (int line = 0; line < 9152; line++) { - row[x] = dockinfrascales->getColor(fval).rgb(); - } + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); + for (int pixelx = 0; pixelx < 9152; pixelx++) + { + c = *(pixelsHRV + line * 9152 + pixelx); + r = quint8(inversevector[0] ? 255 - c : c); + g = quint8(inversevector[0] ? 255 - c : c); + b = quint8(inversevector[0] ? 255 - c : c); + row_col[pixelx] = qRgb(r,g,b); + } + } } } - - changeinfraprojection = true; -} - -void FormImage::FromInfraColorProjection() -{ - QRgb *row; - float temp; - int height = imageptrs->ptrimageProjection->height(); - int width = imageptrs->ptrimageProjection->width(); - - for(int y = 0; y < height; y++) + else if(sl->getKindofImage() == "VIS_IR") { - row = (QRgb*)imageptrs->ptrimageProjection->scanLine(y); - - for(int x = 0; x < width; x++) + if(sl->getGeoSatellite() == eGeoSatellite::MET_11 || sl->getGeoSatellite() == eGeoSatellite::MET_10 || sl->getGeoSatellite() == eGeoSatellite::MET_9 || sl->getGeoSatellite() == eGeoSatellite::MET_8 ) { - quint8 val = imageptrs->ptrProjectionInfra[y * width + x]; - row[x] = qRgb(val, val, val); - } - } - - changeinfraprojection = true; - -} - - -void FormImage::test() -{ + for(int i = 0 ; i < (sl->bisRSS ? 3 : 8); i++) + { + for (int line = 463; line >= 0; line--) + { + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((sl->bisRSS ? 3*464 : 3712) - i * 464 - line - 1); + for (int pixelx = 3711; pixelx >= 0; pixelx--) + { + c = *(pixelsRed + i * 464 * 3712 + line * 3712 + pixelx); - pixgeoConversion pixconv; + r = quint8(inversevector[0] ? 255 - c/4 : c/4); + g = quint8(inversevector[0] ? 255 - c/4 : c/4); + b = quint8(inversevector[0] ? 255 - c/4 : c/4); + row_col[3711 - pixelx] = qRgb(r,g,b); + } + } + } + } + else if(sl->getGeoSatellite() == eGeoSatellite::GOMS3) + { + for(int i = 0 ; i < 6; i++) + { + //for (int line = 463; line >= 0; line--) + for (int line = 0; line < 464; line++) + { + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 464 + line); + for (int pixelx = 0; pixelx < 2784; pixelx++) + { + c = *(pixelsRed + i * 464 * 2784 + line * 2784 + pixelx); - int col; - int row; + // if(i == 0 && line == 300) + // qDebug() << pixelx << " " << c; - double radius; - QVector3D pos; - double lat_rad; - double lon_rad; - QRgb rgbval = qRgb(0, 255, 0); + r = quint8(inversevector[0] ? 255 - c/4 : c/4); + g = quint8(inversevector[0] ? 255 - c/4 : c/4); + b = quint8(inversevector[0] ? 255 - c/4 : c/4); + row_col[pixelx] = qRgb(r,g,b); + } + } + } + } + else if(sl->getGeoSatellite() == eGeoSatellite::H8 ) + { + qDebug() << "in if(sl->getGeoSatellite() == eGeoSatellite::H8 )"; - pos.setX(4024.915); - pos.setY(304.966); - pos.setZ(4921.832); + for(int i = 0 ; i < 10; i++) + { + //for (int line = 549; line >= 0; line--) + for (int line = 0; line < 550; line++) + { + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(i * 550 + line); + for (int pixelx = 0; pixelx < 5500; pixelx++) + { + c = *(pixelsRed + i * 550 * 5500 + line * 5500 + pixelx); - long count = 0; + r = quint8(inversevector[0] ? 255 - c/4 : c/4); + g = quint8(inversevector[0] ? 255 - c/4 : c/4); + b = quint8(inversevector[0] ? 255 - c/4 : c/4); - for (int i=0; ivxp_data[0]->nFeatures; i++) - { - for (int j=0; jvxp_data[0]->pFeatures[i].nVerts; j++) + row_col[pixelx] = qRgb(r,g,b); + } + } + } + } + else if(sl->getGeoSatellite() == eGeoSatellite::FY2H || sl->getGeoSatellite() == eGeoSatellite::FY2G) { - count++; - - pos.setX(gshhsdata->vxp_data[0]->pFeatures[i].pVerts[j].x()); - pos.setY(gshhsdata->vxp_data[0]->pFeatures[i].pVerts[j].y()); - pos.setZ(gshhsdata->vxp_data[0]->pFeatures[i].pVerts[j].z()); - //Pos2LatLonAlt(&lat_rad, &lon_rad, &radius, pos); - qDebug() << QString("count %1 lat %2 lon %3").arg(count).arg(gshhsdata->vxp_data[0]->pFeatures[i].pLonLat[j].latmicro*1.0e-6).arg(gshhsdata->vxp_data[0]->pFeatures[i].pLonLat[j].lonmicro*1.0e-6); + qDebug() << "recalculate CLAHE ; VIS_IR and FY2H/G move to ptrImageGeostationary"; + for (int line = 0; line < 2288; line++) + { + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); + for (int pixelx = 0; pixelx < 2288; pixelx++) + { + c = *(pixelsRed + line * 2288 + pixelx); - // int ret = pixconv.geocoord2pixcoord(50.833, 4.333,coff,loff, &col, &row); + r = quint8(inversevector[0] ? 255 - c : c); + g = quint8(inversevector[0] ? 255 - c : c); + b = quint8(inversevector[0] ? 255 - c : c); - // int ret = pixconv.geocoord2pixcoord(rad2deg(lat_rad), rad2deg(lon_rad),coff,loff, &col, &row); - //qDebug() << QString("ret = %1 lat = %2 lon = %3 col = %4 row = %5").arg(ret).arg(lat_rad).arg(lon_rad).arg(col).arg(row); + row_col[pixelx] = qRgb(r,g,b); + } + } + } + else if(sl->getGeoSatellite() == eGeoSatellite::GOES_16 || sl->getGeoSatellite() == eGeoSatellite::GOES_17 || sl->getGeoSatellite() == eGeoSatellite::GOES_18) + { + qDebug() << "recalculate CLAHE ; VIS_IR and GOES_16/_17 move to ptrImageGeostationary"; - //if(ret == 0) + for (int line = 0; line < 5424; line++) { - // this->imageLabel->setp - //imageptrs->ptrimageMeteosat->setPixel(col, row, value); // QRgb(0, 0, 0) ); + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); + for (int pixelx = 0; pixelx < 5424; pixelx++) + { + c = *(pixelsRed + line * 5424 + pixelx); + r = quint8(inversevector[0] ? 255 - (int)(c/4) : (int)(c/4)); + g = quint8(inversevector[0] ? 255 - (int)(c/4) : (int)(c/4)); + b = quint8(inversevector[0] ? 255 - (int)(c/4) : (int)(c/4)); + row_col[pixelx] = qRgb(r,g,b); + } } - } } -} - -void FormImage::slotRefreshOverlay() -{ - this->displayImage(this->channelshown); -} - -void FormImage::slotRepaintProjectionImage() -{ - changeinfraprojection = true; - this->displayImage(this->channelshown); -} - -bool FormImage::SaveAsPNG48bits(bool mapto65535) -{ - QString filestr; - - filestr.append("./"); - - if (this->channelshown == IMAGE_OLCI) + if(sl->getKindofImage() == "VIS_IR Color" ) { - filestr += "olci_image.png"; + delete [] pixelsRed; + delete [] pixelsGreen; + delete [] pixelsBlue; + } + else if(sl->getKindofImage() == "HRV") + { + delete [] pixelsHRV; } - else return(false); - - - QString fileName = QFileDialog::getSaveFileName(this, - tr("Save image"), filestr, - tr("*.png")); - if (fileName.isEmpty()) - return(false); else { - QApplication::setOverrideCursor(Qt::WaitCursor); - if(fileName.mid(fileName.length()-4) != ".png" && fileName.mid(fileName.length()-4) != ".PNG") - fileName.append(".png"); - - int olciefrcount = segs->seglolciefr->NbrOfSegmentsSelected(); - int olcierrcount = segs->seglolcierr->NbrOfSegmentsSelected(); - - if(olciefrcount > 0) - { - segs->seglolciefr->Compose48bitPNG(fileName, mapto65535); - QApplication::restoreOverrideCursor(); - } - else if(olcierrcount > 0) - { - segs->seglolcierr->Compose48bitPNG(fileName, mapto65535); - QApplication::restoreOverrideCursor(); - } - else - { - QApplication::restoreOverrideCursor(); - return(false); - } - - + delete [] pixelsRed; } - return(true); + if(sl->getKindofImage() != "HRV" && sl->getKindofImage() != "HRV Color") + if(opts.imageontextureOnMet) + emit render3dgeo(sl->getGeoSatelliteIndex()); + + QApplication::restoreOverrideCursor(); } -FormImage::~FormImage() +void FormImage::slotUpdateGeosat() { -} + qDebug() << "start FormImage::slotUpdateGeosat()"; -////////////////////////////////////////////////////////////////////////////////// -ImageLabel::ImageLabel(QWidget *parent, AVHRRSatellite *seglist) : QLabel(parent) -{ - segs = seglist; - mousepos.setX(0); - mousepos.setY(0); + this->displayImage(IMAGE_GEOSTATIONARY, true); + emit allsegmentsreceivedbuttons(true); - setMouseTracking(true); + this->update(); } -void ImageLabel::mouseMoveEvent(QMouseEvent *event) +void FormImage::CLAHERGBRecipe(float cliplimit) { - double lon, lat; - float flon, flat; + QRgb *row_col; + quint16 red, green, blue; + int npix = 3712 * 3712; + quint16 *pixelsRed = new quint16[npix]; + quint16 *pixelsGreen = new quint16[npix]; + quint16 *pixelsBlue = new quint16[npix]; - bool bret; - double factorheight = (double)this->originalpixmapsize.height()/(double)this->scaledpixmapsize.height(); - double factorwidth = (double)this->originalpixmapsize.width()/(double)this->scaledpixmapsize.width(); - double xpos = (double)event->pos().x() * factorwidth; - double ypos = (double)event->pos().y() * factorheight; - - mousepos.setX(event->pos().x()); - mousepos.setY(event->pos().y()); - if(xpos >= this->originalpixmapsize.width() || ypos >= this->originalpixmapsize.height() ) + qDebug() << "ptrimageGeostationary width = " << imageptrs->ptrimageGeostationary->width(); + if(imageptrs->ptrimageGeostationary->width() != 3712) return; - formimage->update(); - - if(formimage->getPictureSize() != QSize(-1,-1)) + for (int line = 0; line < 3712; line++) { - if(formimage->channelshown == IMAGE_PROJECTION) + for (int pixelx = 0; pixelx < 3712; pixelx++) { - if (opts.currenttoolbox == 0) //LCC - bret = imageptrs->lcc->map_inverse(xpos, ypos, lon, lat); - else if (opts.currenttoolbox == 1) //GVP - bret = imageptrs->gvp->map_inverse(xpos, ypos, lon, lat); - else if (opts.currenttoolbox == 2) //SG - bret = imageptrs->sg->map_inverse(xpos, ypos, lon, lat); - else if (opts.currenttoolbox == 3) //OM - bret = imageptrs->om->map_inverse(xpos, ypos, lon, lat); - else - bret = false; - - if(bret) - emit coordinateChanged(QString("longitude = %1 latitude = %2 ") - .arg(lon*180.0/PI, 0, 'f', 2).arg(lat*180.0/PI, 0, 'f', 2)); + int i_image = line * 3712 + pixelx; + pixelsRed[i_image] = imageptrs->ptrimageRGBRecipeRed[i_image]; + pixelsGreen[i_image] = imageptrs->ptrimageRGBRecipeGreen[i_image]; + pixelsBlue[i_image] = imageptrs->ptrimageRGBRecipeBlue[i_image]; } - else if(formimage->channelshown == IMAGE_OLCI) - { - if(segs->seglolciefr->GetSegsSelectedptr()->count() > 0) - bret = segs->seglolciefr->searchLatLon(qRound(xpos), qRound(ypos), flon, flat); - else if(segs->seglolcierr->GetSegsSelectedptr()->count() > 0) - bret = segs->seglolcierr->searchLatLon(qRound(xpos), qRound(ypos), flon, flat); - else - bret = false; + } - if(bret) - emit coordinateChanged(QString("longitude = %1 latitude = %2 ") - .arg(flon, 0, 'f', 2).arg(flat, 0, 'f', 2)); + imageptrs->CLAHE(pixelsRed, 3712, 3712, 0, 255, 16, 16, 256, cliplimit); + imageptrs->CLAHE(pixelsGreen, 3712, 3712, 0, 255, 16, 16, 256, cliplimit); + imageptrs->CLAHE(pixelsBlue, 3712, 3712, 0, 255, 16, 16, 256, cliplimit); - } - else + for (int line = 0; line < 3712; line++) + { + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); + for (int pixelx = 0; pixelx < 3712; pixelx++) { - //formimage - emit coordinateChanged(QString("%1 %2 ").arg(mousepos.x()).arg(mousepos.y())); + int i_image = line * 3712 + pixelx; + + red = pixelsRed[i_image]; + green = pixelsGreen[i_image]; + blue = pixelsBlue[i_image]; + + row_col[pixelx] = qRgb((int)red, (int)green, (int)blue); } } - else - { - emit coordinateChanged(" "); - } - - QLabel::mouseMoveEvent(event); -} -void ImageLabel::setPixmap ( const QPixmap & p) -{ - this->originalpixmapsize = p.size(); - this->scaledpixmapsize = p.size(); - QLabel::setPixmap(p); -} -void ImageLabel::resize(const QSize &s) -{ - this->scaledpixmapsize = s; - QLabel::resize(s); + delete [] pixelsRed; + delete [] pixelsGreen; + delete [] pixelsBlue; } - -/////////////////////////////////////////////////////////////////////////////////////// - -//AspectRatioPixmapLabel::AspectRatioPixmapLabel(QWidget *parent) : -// QLabel(parent) -//{ -// this->setMinimumSize(1,1); -// setScaledContents(false); -//} - -//void AspectRatioPixmapLabel::setPixmap ( const QPixmap & p) -//{ -// pix = p; -// QLabel::setPixmap(scaledPixmap()); -//} - -//int AspectRatioPixmapLabel::heightForWidth( int width ) const -//{ -// return pix.isNull() ? this->height() : ((qreal)pix.height()*width)/pix.width(); -//} - -//QSize AspectRatioPixmapLabel::sizeHint() const -//{ -// int w = this->width(); -// return QSize( w, heightForWidth(w) ); -//} - -//QPixmap AspectRatioPixmapLabel::scaledPixmap() const -//{ -// return pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); -//} - -//void AspectRatioPixmapLabel::resizeEvent(QResizeEvent * e) -//{ -// if(!pix.isNull()) -// QLabel::setPixmap(scaledPixmap()); -//} -////////////////////////////////////////////////////////////////////////////////////// -/// \brief AspectRatioPixmapLabel::AspectRatioPixmapLabel -/// \param pixmap -/// \param parent -/// -//AspectRatioPixmapLabel::AspectRatioPixmapLabel(const QPixmap &pixmap, QWidget *parent) : -// QLabel(parent) -//{ -// QLabel::setPixmap(pixmap); -// setScaledContents(true); -// QSizePolicy policy(QSizePolicy::Maximum, QSizePolicy::Maximum); -// policy.setHeightForWidth(true); -// this->setSizePolicy(policy); -//} - -//int AspectRatioPixmapLabel::heightForWidth(int width) const -//{ -// if (width > pixmap()->width()) { -// return pixmap()->height(); -// } else { -// return ((qreal)pixmap()->height()*width)/pixmap()->width(); -// } -//} diff --git a/core/formimage.h b/core/formimage.h index 85c4ded..92b9979 100644 --- a/core/formimage.h +++ b/core/formimage.h @@ -1,82 +1,115 @@ #ifndef FORMIMAGE_H #define FORMIMAGE_H -#include -#include - -#include "satellite.h" +#include +#include +#include +#include +#include +#include #include "avhrrsatellite.h" -#include "generalverticalperspective.h" #include "formtoolbox.h" -#include "forminfrascales.h" class FormToolbox; -class FormInfraScales; -class ImageLabel; -class AspectRatioPixmapLabel; -class FormImage : public QWidget +class FormImage : public QGraphicsView { Q_OBJECT + public: explicit FormImage(QWidget *parent = 0, SatelliteList *satlist=0, AVHRRSatellite *seglist=0); - QLabel *returnimageLabelptr(); + void MakeImage(); + + void resetView(); + void fitWindow(); + void originalSize(); + void rotateView(const int nVal); + void printView(); + bool saveViewToDisk(QString &strError); + inline bool isModified() { return m_rotateAngle!=0; } + inline int getRotateAngle(){ return m_rotateAngle; } + QString getImageFormat(QString strFileName); + QPixmap *getPixmap() { return &m_pixmap; } + QGraphicsScene *getScene() { return m_scene; } + QGraphicsPixmapItem *getPixmapItem() { return m_pixmapItem; } + void setFormImagePtr(FormImage *ptr) { formimage = ptr; } + //QSize getPixmapSize() { return scaledpixmapsize; } + void SetFormToolbox(FormToolbox *ptr) { formtoolbox = ptr; } + void setKindOfImage(QString koi) { kindofimage = koi; } + void setChannelShown(eImageType channel) { channelshown = channel; } + QString getKindOfImage() { return kindofimage; } + void displayImage(eImageType channel, bool resize); + void setupGeoOverlay(int geoindex); + void setupGshhs(int geoindex, int k); + void setWindowTitle(); + void setSegmentType(eSegmentType st) { segmenttype = st; } + eSegmentType getSegmentType() { return segmenttype; } + void drawOverlays(QPainter *painter); + void savePNGImage(QString fileName); + void zoomIn(); + void zoomOut(); + + bool toggleOverlayMeteosat(); + bool toggleOverlayProjection(); + bool toggleOverlayOLCI(); + bool toggleOverlayGridOnOLCI(); + bool ShowVIIRSMImage(); bool ShowVIIRSDNBImage(); bool ShowOLCIefrImage(int histogrammethod, bool normalized); bool ShowOLCIerrImage(int histogrammethod, bool normalized); bool ShowSLSTRImage(int histogrammethod); bool ShowMERSIImage(int histogrammethod, bool normalized); - QSize getPictureSize() const; + + void CLAHERGBRecipe(float cliplimit); + void recalculateCLAHE(QVector spectrumvector, QVector inversevector); - void recalculateCLAHE1(QVector spectrumvector, QVector inversevector); - void recalculateCLAHEAvhrr(QVector spectrumvector, QVector inversevector); - void recalculateCLAHEOLCI(QVector spectrumvector, QVector inversevector); - void CLAHEprojection(); + + void setViewInitialized(bool init) { qDebug() << "setViewInitialized = " << init; this->m_ViewInitialized = init; } + + eImageType channelshown; // which button channel + + QString txtInfo; + +private: + + void displayGeoImageInfo(); + void displayGeoImageInformation(QString satname); + void OverlayGeostationary(QPainter *paint, SegmentListGeostationary *sl); void OverlayGeostationaryHRV(QPainter *paint, SegmentListGeostationary *sl, int geoindex); + void OverlayGeostationaryHRV1(QPainter *paint, SegmentListGeostationary *sl, int geoindex); void OverlayProjection(QPainter *paint); void OverlayOLCI(QPainter *paint); - void ToInfraColorProjection(); - void FromInfraColorProjection(); - bool getOverlayMeteosat() { return overlaymeteosat; } - bool getOverlayProjection() { return overlayprojection; } - bool getOverlayOLCI() { return overlayolci; } - bool toggleOverlayMeteosat(); - bool toggleOverlayProjection(); - bool toggleOverlayOLCI(); - bool toggleOverlayGridOnOLCI(); - void SetFormToolbox(FormToolbox *ptr) { formtoolbox = ptr; } - void SetDockWidgetInfraScales(FormInfraScales *ptr) { dockinfrascales = ptr; } - void showInfraScales() { changeinfraprojection = true; } - void displayImage(eImageType channel); - void test(); - void setKindOfImage(QString koi) { kindofimage = koi; } - QString getKindOfImage() { return kindofimage; } + void displayAVHRRImageInfo(); + void displayVIIRSImageInfo(eSegmentType type); + void displaySentinelImageInfo(eSegmentType type); + void displayMERSIImageInfo(eSegmentType type); - void setSegmentType(eSegmentType st) { segmenttype = st; } - eSegmentType getSegmentType() { return segmenttype; } + mutable QImage *m_image; + //QImage *m_image; + QPixmap m_pixmap; + QGraphicsPixmapItem *m_pixmapItem; + QGraphicsScene *m_scene; + int m_rotateAngle; + bool m_ViewInitialized; + QString m_fileName; + FormImage *formimage; + FormToolbox *formtoolbox; - void setZoomValue(int z); - int getZoomValue(); - void makeZoom(double f); - inline void zoomIn(){makeZoom(getZoomValue() + zoomIncrement);} - inline void zoomOut(){makeZoom(getZoomValue() - zoomIncrement);} - inline void normalSize(){makeZoom(100);} + QString kindofimage; + eSegmentType segmenttype; + SatelliteList *sats; + AVHRRSatellite *segs; - void adjustImage(); - void adjustPicSize(bool setwidth); - bool ShowHistogramImageOLCI(int histogrammethod, bool normalized); - bool ShowHistogramImageSLSTR(int histogrammethod); + bool overlaymeteosat; + bool overlayprojection; + bool overlayolci; - void UpdateProjection(); - bool SaveAsPNG48bits(bool mapto65535); - void setupGeoOverlay(int geoindex); - void CLAHERGBRecipe(float cliplimit); int metopcount; int noaacount; @@ -98,126 +131,34 @@ class FormImage : public QWidget int slstrcount; int mersicount; - QVector geooverlay; - - - eImageType channelshown; // which button channel - QString txtInfo; - bool refreshoverlay; - ImageLabel *imageLabel; - - ~FormImage(); - -private: - - void displayAVHRRImageInfo(); - void displayVIIRSImageInfo(eSegmentType type); - void displaySentinelImageInfo(eSegmentType type); - void displayGeoImageInfo(); - void displayGeoImageInformation(QString satname); - void displayMERSIImageInfo(eSegmentType type); - void EnhanceDarkSpace(int geoindex); - void calchimawari(QRgb rgb, int &minred, int &maxred, int &mingreen, int &maxgreen, int &minblue, int &maxblue); - QRgb ContrastStretch(QRgb val); - void SetupContrastStretch(quint16 x1r, quint16 y1r, quint16 x2r, quint16 y2r, quint16 x1g, quint16 y1g, quint16 x2g, quint16 y2g, quint16 x1b, quint16 y1b, quint16 x2b, quint16 y2b); - - SatelliteList *sats; - AVHRRSatellite *segs; - FormToolbox *formtoolbox; - FormInfraScales *dockinfrascales; - - //double metop_gamma_ch[5], noaa_gamma_ch[5], gac_gamma_ch[5], hrp_gamma_ch[5]; - //double metop_gammaEqual_ch[5], noaa_gammaEqual_ch[5], gac_gammaEqual_ch[5], hrp_gammaEqual_ch[5]; - bool metop_inverse_ch[5], noaa_inverse_ch[5], gac_inverse_ch[5], hrp_inverse_ch[5]; - //bool metop_inverseEqual_ch[5], noaa_inverseEqual_ch[5], gac_inverseEqual_ch[5], hrp_inverseEqual_ch[5]; - - //AspectRatioPixmapLabel *imageLabel; + QVector geooverlay[3]; - QVBoxLayout *mainLayout; - double scaleFactor; - bool overlaymeteosat; - bool overlayprojection; - bool overlayolci; - bool changeinfraprojection; - - QString kindofimage; - eSegmentType segmenttype; - - int zoomValueavhrr; - int zoomValuemeteosat; - int zoomValueprojection; - int zoomValueviirs; - int zoomValueolci; - int zoomValueslstr; - int zoomValuemersi; - int zoomIncrement; - int maxZoomValue; - int minZoomValue; - - void fillptrimage(quint16 *pix); - void fillptrimageHRV(quint16 *pixHRV); - void formwheelZoom(int d); - - int currentgeooverlay; - double A1red, B1red; - double A1green, B1green; - double A1blue, B1blue; - QPoint mousepoint; - -signals: - void moveImage(QPoint, QPoint); - void picSizeChanged(); - void pixmapChanged(); - void wheelZoom(int); - void render3dgeo(int geoindex); - void allsegmentsreceivedbuttons(bool); - void setmapcylbuttons(bool stat); +#ifndef QT_NO_PRINTER + QPrinter printer; +#endif public slots: void slotMakeImage(); - - void setPixmapToLabel(bool settoolboxbuttons); - void setPixmapToLabelDNB(bool settoolboxbuttons); + void slotcomposefinished(QString kindofimage, int index); + void setPixmapToScene(bool settoolboxbuttons); void slotUpdateGeosat(); - void slotcomposefinished(QString kindofimage); - void slotRefreshOverlay(); - void slotRepaintProjectionImage(); -protected: - void paintEvent(QPaintEvent *); - void wheelEvent(QWheelEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); -}; -class ImageLabel : public QLabel -{ - Q_OBJECT -public: - explicit ImageLabel(QWidget *parent=0, AVHRRSatellite *seglist=0); - void setFormImagePtr(FormImage *ptr) { formimage = ptr; } - void resize(const QSize&); - QPoint getMousePosition() { return mousepos; } - QSize getPixmapSize() { return scaledpixmapsize; } - -public slots: - void setPixmap ( const QPixmap & ); protected: - void mouseMoveEvent(QMouseEvent *); -private: - QSize originalpixmapsize; - QSize scaledpixmapsize; - FormImage *formimage; - AVHRRSatellite *segs; - QPoint mousepos; + virtual void wheelEvent(QWheelEvent * event); + virtual void resizeEvent(QResizeEvent * event); + virtual void drawForeground(QPainter *painter, const QRectF &rect); signals: - void coordinateChanged(QString str); + void render3dgeo(int geoindex); + void allsegmentsreceivedbuttons(bool); + void setmapcylbuttons(bool stat); + void signalMainWindowTitleChanged(QString); }; + #endif // FORMIMAGE_H diff --git a/core/formtoolbox.cpp b/core/formtoolbox.cpp index 0427ed9..4bf762c 100644 --- a/core/formtoolbox.cpp +++ b/core/formtoolbox.cpp @@ -34,14 +34,13 @@ class SignalsBlocker bool _b; }; -FormToolbox::FormToolbox(QWidget *parent, FormImage *p_formimage, FormGeostationary *p_formgeostationary, FormInfraScales *p_forminfrascales, AVHRRSatellite *seglist) : +FormToolbox::FormToolbox(QWidget *parent, FormImage *p_formimage, FormGeostationary *p_formgeostationary, AVHRRSatellite *seglist) : QWidget(parent), ui(new Ui::FormToolbox) { ui->setupUi(this); formimage = p_formimage; formgeostationary = p_formgeostationary; - forminfrascales = p_forminfrascales; formmovie = NULL; segs = seglist; filenamecreated = ""; @@ -414,6 +413,7 @@ FormToolbox::FormToolbox(QWidget *parent, FormImage *p_formimage, FormGeostation QListWidgetItem* item = new QListWidgetItem(imageptrs->rgbrecipes.at(i).Name, ui->lstRGB); } + rowchosen.clear(); } void FormToolbox::setFormMovie(FormMovie *formmovie) @@ -563,11 +563,11 @@ bool FormToolbox::eventFilter(QObject *target, QEvent *event) } -void FormToolbox::setValuePrgBar(int val) -{ - ui->pbProgress->setValue(val); - //this->update(); -} +//void FormToolbox::setValuePrgBar(int val) +//{ +// ui->pbProgress->setValue(val); +// //this->update(); +//} void FormToolbox::setValueProgressBar(int val) { @@ -1471,42 +1471,42 @@ void FormToolbox::on_btnCol_clicked() { formimage->setKindOfImage("AVHRR Color"); currentAVHRRimage = IMAGE_AVHRR_COL; - formimage->displayImage(currentAVHRRimage); + formimage->displayImage(currentAVHRRimage, true); } void FormToolbox::on_btnCh1_clicked() { formimage->setKindOfImage("Chan 1"); currentAVHRRimage = IMAGE_AVHRR_CH1; - formimage->displayImage(currentAVHRRimage); + formimage->displayImage(currentAVHRRimage, true); } void FormToolbox::on_btnCh2_clicked() { formimage->setKindOfImage("Chan 2"); currentAVHRRimage = IMAGE_AVHRR_CH2; - formimage->displayImage(currentAVHRRimage); + formimage->displayImage(currentAVHRRimage, true); } void FormToolbox::on_btnCh3_clicked() { formimage->setKindOfImage("Chan 3"); currentAVHRRimage = IMAGE_AVHRR_CH3; - formimage->displayImage(currentAVHRRimage); + formimage->displayImage(currentAVHRRimage, true); } void FormToolbox::on_btnCh4_clicked() { formimage->setKindOfImage("Chan 4"); currentAVHRRimage = IMAGE_AVHRR_CH4; - formimage->displayImage(currentAVHRRimage); + formimage->displayImage(currentAVHRRimage, true); } void FormToolbox::on_btnCh5_clicked() { formimage->setKindOfImage("Chan 5"); currentAVHRRimage = IMAGE_AVHRR_CH5; - formimage->displayImage(currentAVHRRimage); + formimage->displayImage(currentAVHRRimage, true); } void FormToolbox::on_btnExpandImage_clicked() @@ -1515,14 +1515,14 @@ void FormToolbox::on_btnExpandImage_clicked() return; formimage->setKindOfImage("Expanded " + formimage->getKindOfImage()); imageptrs->ExpandImage(formimage->channelshown); - formimage->displayImage(IMAGE_AVHRR_EXPAND); + formimage->displayImage(IMAGE_AVHRR_EXPAND, true); } void FormToolbox::on_btnRotate180_clicked() { imageptrs->RotateImage(); - formimage->returnimageLabelptr()->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_col))); - formimage->adjustImage(); +// formimage->returnimageGraphicsViewptr()->setPixmap(QPixmap::fromImage( *(imageptrs->ptrimagecomp_col))); +// formimage->adjustImage(); } void FormToolbox::on_btnOverlayMeteosat_clicked() @@ -1672,9 +1672,7 @@ void FormToolbox::on_btnCLAHEGeostationary_clicked() void FormToolbox::on_btnCLAHEavhhr_clicked() { - formimage->recalculateCLAHEAvhrr(spectrumvector, inversevector); - - //segs->nb->p->ptrbaChannel[5]. +// formimage->recalculateCLAHEAvhrr(spectrumvector, inversevector); qDebug() << "CLAHE"; } @@ -1864,35 +1862,6 @@ void FormToolbox::setToolboxButtonLabels(int geoindex) qDebug() << QString("FormToolbox::setToolboxButtonLabels geoindex = %1").arg(geoindex); - // ui->btnCh1->setEnabled(false); - // ui->btnCh2->setEnabled(false); - // ui->btnCh3->setEnabled(false); - // ui->btnCh4->setEnabled(false); - // ui->btnCh5->setEnabled(false); - // ui->btnCol->setEnabled(false); - - // ui->btnGeoColor->setEnabled(false); - // ui->btnGeo1->setEnabled(false); - // ui->btnGeo2->setEnabled(false); - // ui->btnGeo3->setEnabled(false); - // ui->btnGeo4->setEnabled(false); - // ui->btnGeo5->setEnabled(false); - // ui->btnGeo6->setEnabled(false); - // ui->btnGeo7->setEnabled(false); - // ui->btnGeo8->setEnabled(false); - // ui->btnGeo9->setEnabled(false); - // ui->btnGeo10->setEnabled(false); - // ui->btnGeo11->setEnabled(false); - // ui->btnGeo12->setEnabled(false); - // ui->btnGeo13->setEnabled(false); - // ui->btnGeo14->setEnabled(false); - // ui->btnGeo15->setEnabled(false); - // ui->btnGeo16->setEnabled(false); - - // ui->btnHRV->setEnabled(false); - // ui->cmbHRVtype->setEnabled(false); - // ui->chkColorHRV->setEnabled(false); - ui->btnGeo1->setText(""); ui->btnGeo2->setText(""); ui->btnGeo3->setText(""); @@ -2195,18 +2164,28 @@ void FormToolbox::on_btnGeo16_clicked() onButtonChannel(ui->btnGeo16->text(), ui->chkInverseGeo16->isChecked()); } - +void FormToolbox::setProgressMaximum(int max) +{ + ui->pbProgress->setMaximum(max); +} void FormToolbox::onButtonChannel( QString channel, bool bInverse) { qDebug() << QString("onButtonChannel( QString channel, bool bInverse) ; channel = %1").arg(channel); + QApplication::setOverrideCursor(Qt::WaitCursor); // restore in FormImage::slotUpdateGeosat() ui->pbProgress->reset(); - ui->pbProgress->setMaximum(opts.geosatellites.at(geoindex).maxsegments); + // if(opts.geosatellites.at(geoindex).shortname == "MTG-I1") + // ui->pbProgress->setMaximum(100); + // else + // ui->pbProgress->setMaximum(opts.geosatellites.at(geoindex).maxsegments); + + ui->pbProgress->setMaximum(100); segs->seglgeo[geoindex]->areatype = ui->cmbHRVtype->currentIndex(); segs->seglgeo[geoindex]->setKindofImage("VIS_IR"); formimage->setKindOfImage("VIS_IR"); + formimage->setChannelShown(IMAGE_GEOSTATIONARY); setToolboxButtons(false); @@ -2252,9 +2231,9 @@ void FormToolbox::on_btnGeoColor_clicked() QApplication::setOverrideCursor(Qt::WaitCursor); // restore in FormImage::slotUpdateGeosat() ui->pbProgress->reset(); - if(geoindex == (int)eGeoSatellite::MET_11 || geoindex == (int)eGeoSatellite::MET_9 || geoindex == (int)eGeoSatellite::MET_8) + if(geoindex == (int)eGeoSatellite::MET_10 || geoindex == (int)eGeoSatellite::MET_9 || geoindex == (int)eGeoSatellite::MET_8) ui->pbProgress->setMaximum(8+8+8); - else if(geoindex == (int)eGeoSatellite::MET_10) + else if(geoindex == (int)eGeoSatellite::MET_11) ui->pbProgress->setMaximum(3+3+3); else if(geoindex == (int)eGeoSatellite::GOMS3) ui->pbProgress->setMaximum(6+6+6); @@ -2264,6 +2243,8 @@ void FormToolbox::on_btnGeoColor_clicked() ui->pbProgress->setMaximum(10+10+10); else if(geoindex == (int)eGeoSatellite::GOES_16 || geoindex == (int)eGeoSatellite::GOES_17 || geoindex == (int)eGeoSatellite::GOES_18) ui->pbProgress->setMaximum(100); + else if(geoindex == (int)eGeoSatellite::MTG_I1) + ui->pbProgress->setMaximum(40 + 40 + 40); onButtonColorHRV("VIS_IR Color"); @@ -2277,14 +2258,13 @@ void FormToolbox::on_btnRecipes_clicked() if(ui->lstRGB->currentRow() == -1) return; - if(!(geoindex == (int)eGeoSatellite::MET_11 || geoindex == (int)eGeoSatellite::MET_10 || geoindex == (int)eGeoSatellite::MET_9 || geoindex == (int)eGeoSatellite::MET_8)) + if(!(geoindex == (int)eGeoSatellite::MET_11 || geoindex == (int)eGeoSatellite::MET_10 || + geoindex == (int)eGeoSatellite::MET_9 || geoindex == (int)eGeoSatellite::MET_8 || geoindex == (int)eGeoSatellite::MTG_I1)) return; + imageptrs->ResetPtrImage(); QApplication::setOverrideCursor(Qt::WaitCursor); // restore in FormImage::slotUpdateGeosat() - formimage->displayImage(IMAGE_GEOSTATIONARY); - formimage->adjustPicSize(true); - ui->pbProgress->reset(); ui->pbProgress->setMaximum(100); @@ -2292,15 +2272,17 @@ void FormToolbox::on_btnRecipes_clicked() segs->seglgeo[geoindex]->setKindofImage("VIS_IR"); formimage->setKindOfImage("VIS_IR"); - + QString recipename = imageptrs->rgbrecipes[ui->lstRGB->currentRow()].Name; + this->spectrumvector[0] = recipename; + this->spectrumvector[1] = ""; + this->spectrumvector[2] = ""; setToolboxButtons(false); emit switchstackedwidget(3); emit creatergbrecipe(ui->lstRGB->currentRow()); - formimage->displayImage(IMAGE_GEOSTATIONARY); - formimage->adjustPicSize(true); + formimage->displayImage(IMAGE_GEOSTATIONARY, true); setToolboxButtons(true); QApplication::restoreOverrideCursor(); // restore in FormImage::slotUpdateGeosat() @@ -2359,46 +2341,48 @@ void FormToolbox::on_btnHRV_clicked() ui->pbProgress->reset(); - if(geoindex == (int)eGeoSatellite::MET_11 || geoindex == (int)eGeoSatellite::MET_9 || geoindex == (int)eGeoSatellite::MET_8) - { - if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == false) - ui->pbProgress->setMaximum(5); - if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == true) - ui->pbProgress->setMaximum(8+8+8+5); - if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == false) - ui->pbProgress->setMaximum(24); - if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == true) - ui->pbProgress->setMaximum(8+8+8+24); - } +// if(geoindex == (int)eGeoSatellite::MET_11 || geoindex == (int)eGeoSatellite::MET_9 || geoindex == (int)eGeoSatellite::MET_8) +// { +// if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == false) +// ui->pbProgress->setMaximum(5); +// if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == true) +// ui->pbProgress->setMaximum(8+8+8+5); +// if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == false) +// ui->pbProgress->setMaximum(24); +// if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == true) +// ui->pbProgress->setMaximum(8+8+8+24); +// } + +// if(geoindex == (int)eGeoSatellite::MET_10) +// { +// if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == false) +// ui->pbProgress->setMaximum(5); +// if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == true) +// ui->pbProgress->setMaximum(3+3+3+5); +// if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == false) +// ui->pbProgress->setMaximum(0); +// if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == true) +// ui->pbProgress->setMaximum(0); +// } + +// if(geoindex == (int)eGeoSatellite::GOMS3) +// { +// if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == false) +// ui->pbProgress->setMaximum(6); +// if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == true) +// ui->pbProgress->setMaximum(0); +// if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == false) +// ui->pbProgress->setMaximum(0); +// if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == true) +// ui->pbProgress->setMaximum(0); +// } + +// if(geoindex == (int)eGeoSatellite::FY2H || geoindex == (int)eGeoSatellite::FY2G) +// { +// ui->pbProgress->setMaximum(100); +// } - if(geoindex == (int)eGeoSatellite::MET_10) - { - if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == false) - ui->pbProgress->setMaximum(5); - if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == true) - ui->pbProgress->setMaximum(3+3+3+5); - if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == false) - ui->pbProgress->setMaximum(0); - if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == true) - ui->pbProgress->setMaximum(0); - } - - if(geoindex == (int)eGeoSatellite::GOMS3) - { - if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == false) - ui->pbProgress->setMaximum(6); - if(ui->cmbHRVtype->currentIndex() == 0 && ui->chkColorHRV->isChecked() == true) - ui->pbProgress->setMaximum(0); - if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == false) - ui->pbProgress->setMaximum(0); - if(ui->cmbHRVtype->currentIndex() == 1 && ui->chkColorHRV->isChecked() == true) - ui->pbProgress->setMaximum(0); - } - - if(geoindex == (int)eGeoSatellite::FY2H || geoindex == (int)eGeoSatellite::FY2G) - { - ui->pbProgress->setMaximum(100); - } + ui->pbProgress->setMaximum(100); if(geoindex == (int)eGeoSatellite::MET_11 || geoindex == (int)eGeoSatellite::MET_10 || geoindex == (int)eGeoSatellite::MET_9 || geoindex == (int)eGeoSatellite::MET_8) { @@ -2420,6 +2404,9 @@ void FormToolbox::on_btnHRV_clicked() void FormToolbox::onButtonColorHRV(QString type) { + qDebug() << "FormToolbox::onButtonColorHRV(QString type)"; + + formimage->setViewInitialized(false); segs->seglgeo[0]->areatype = ui->cmbHRVtype->currentIndex(); segs->seglgeo[1]->areatype = ui->cmbHRVtype->currentIndex(); @@ -2431,9 +2418,7 @@ void FormToolbox::onButtonColorHRV(QString type) formimage->setKindOfImage(type); - formimage->displayImage(IMAGE_GEOSTATIONARY); - formimage->adjustPicSize(false); - + formimage->setChannelShown(IMAGE_GEOSTATIONARY); setToolboxButtons(false); @@ -2495,7 +2480,7 @@ void FormToolbox::onButtonColorHRV(QString type) inversevector[ui->comboGeo11->currentIndex()-1] = ui->chkInverseGeo11->isChecked(); } } - else if (geoindex == (int)eGeoSatellite::FY2H || geoindex == (int)eGeoSatellite::FY2G) + else if (geoindex == (int)eGeoSatellite::FY2H || geoindex == (int)eGeoSatellite::FY2G) // no color images for VIS1KM { if(ui->comboGeo1->currentIndex() > 0) { @@ -2522,8 +2507,11 @@ void FormToolbox::onButtonColorHRV(QString type) spectrumvector[ui->comboGeo5->currentIndex()-1] = "VIS"; inversevector[ui->comboGeo5->currentIndex()-1] = ui->chkInverseGeo5->isChecked(); } + spectrumvector[0] = "VIS1KM"; + spectrumvector[1] = ""; + spectrumvector[2] = ""; } - else if (geoindex == (int)eGeoSatellite::GOMS3) + else if (geoindex == (int)eGeoSatellite::GOMS3) // no HRV button { if(ui->comboGeo1->currentIndex() > 0) { @@ -2730,6 +2718,89 @@ void FormToolbox::onButtonColorHRV(QString type) } } } + else if(geoindex == (int)eGeoSatellite::MTG_I1 ) + { + if(ui->comboGeo1->currentIndex() > 0) + { + spectrumvector[ui->comboGeo1->currentIndex()-1] = "vis_04"; + inversevector[ui->comboGeo1->currentIndex()-1] = ui->chkInverseGeo1->isChecked(); + } + if(ui->comboGeo2->currentIndex() > 0) + { + spectrumvector[ui->comboGeo2->currentIndex()-1] = "vis_05"; + inversevector[ui->comboGeo2->currentIndex()-1] = ui->chkInverseGeo2->isChecked(); + } + if(ui->comboGeo3->currentIndex() > 0) + { + spectrumvector[ui->comboGeo3->currentIndex()-1] = "vis_06"; + inversevector[ui->comboGeo3->currentIndex()-1] = ui->chkInverseGeo3->isChecked(); + } + if(ui->comboGeo4->currentIndex() > 0) + { + spectrumvector[ui->comboGeo4->currentIndex()-1] = "vis_08"; + inversevector[ui->comboGeo4->currentIndex()-1] = ui->chkInverseGeo4->isChecked(); + } + if(ui->comboGeo5->currentIndex() > 0) + { + spectrumvector[ui->comboGeo5->currentIndex()-1] = "vis_09"; + inversevector[ui->comboGeo5->currentIndex()-1] = ui->chkInverseGeo5->isChecked(); + } + if(ui->comboGeo6->currentIndex() > 0) + { + spectrumvector[ui->comboGeo6->currentIndex()-1] = "nir_13"; + inversevector[ui->comboGeo6->currentIndex()-1] = ui->chkInverseGeo6->isChecked(); + } + if(ui->comboGeo7->currentIndex() > 0) + { + spectrumvector[ui->comboGeo7->currentIndex()-1] = "nir_16"; + inversevector[ui->comboGeo7->currentIndex()-1] = ui->chkInverseGeo7->isChecked(); + } + if(ui->comboGeo8->currentIndex() > 0) + { + spectrumvector[ui->comboGeo8->currentIndex()-1] = "nir_22"; + inversevector[ui->comboGeo8->currentIndex()-1] = ui->chkInverseGeo8->isChecked(); + } + if(ui->comboGeo9->currentIndex() > 0) + { + spectrumvector[ui->comboGeo9->currentIndex()-1] = "ir_38"; + inversevector[ui->comboGeo9->currentIndex()-1] = ui->chkInverseGeo9->isChecked(); + } + if(ui->comboGeo10->currentIndex() > 0) + { + spectrumvector[ui->comboGeo10->currentIndex()-1] = "wv_63"; + inversevector[ui->comboGeo10->currentIndex()-1] = ui->chkInverseGeo10->isChecked(); + } + if(ui->comboGeo11->currentIndex() > 0) + { + spectrumvector[ui->comboGeo11->currentIndex()-1] = "wv_73"; + inversevector[ui->comboGeo11->currentIndex()-1] = ui->chkInverseGeo11->isChecked(); + } + if(ui->comboGeo12->currentIndex() > 0) + { + spectrumvector[ui->comboGeo12->currentIndex()-1] = "ir_87"; + inversevector[ui->comboGeo12->currentIndex()-1] = ui->chkInverseGeo12->isChecked(); + } + if(ui->comboGeo13->currentIndex() > 0) + { + spectrumvector[ui->comboGeo13->currentIndex()-1] = "ir_97"; + inversevector[ui->comboGeo13->currentIndex()-1] = ui->chkInverseGeo13->isChecked(); + } + if(ui->comboGeo14->currentIndex() > 0) + { + spectrumvector[ui->comboGeo14->currentIndex()-1] = "ir_105"; + inversevector[ui->comboGeo14->currentIndex()-1] = ui->chkInverseGeo14->isChecked(); + } + if(ui->comboGeo15->currentIndex() > 0) + { + spectrumvector[ui->comboGeo15->currentIndex()-1] = "ir_123"; + inversevector[ui->comboGeo15->currentIndex()-1] = ui->chkInverseGeo15->isChecked(); + } + if(ui->comboGeo16->currentIndex() > 0) + { + spectrumvector[ui->comboGeo16->currentIndex()-1] = "ir_133"; + inversevector[ui->comboGeo16->currentIndex()-1] = ui->chkInverseGeo16->isChecked(); + } + } qDebug() << "spectrumvektor = " << spectrumvector << " ; inversevector = " << inversevector; @@ -2816,41 +2887,33 @@ void FormToolbox::on_tabWidget_currentChanged(int index) { qDebug() << "on_tabWidget_currentChanged(int index) index = " << index; - - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - this->writeInfoToTextEdit(" "); if (index == TAB_AVHRR) //AVHHR { - formimage->displayImage(currentAVHRRimage); + formimage->displayImage(currentAVHRRimage, true); } else if (index == TAB_VIIRS) // VIIRS { if(ui->tabWidgetVIIRS->currentIndex() == 0) - formimage->displayImage(IMAGE_VIIRSM); + formimage->displayImage(IMAGE_VIIRSM, true); else - formimage->displayImage(IMAGE_VIIRSDNB); + formimage->displayImage(IMAGE_VIIRSDNB, true); } else if (index == TAB_MERSI) // MERSI { - formimage->displayImage(IMAGE_MERSI); + formimage->displayImage(IMAGE_MERSI, true); } else if (index == TAB_SENTINEL) // OLCI or SLSTR { if(ui->tabWidgetSentinel->currentIndex() == 0) - formimage->displayImage(IMAGE_OLCI); + formimage->displayImage(IMAGE_OLCI, true); else - formimage->displayImage((IMAGE_SLSTR)); + formimage->displayImage((IMAGE_SLSTR), true); } else if (index == TAB_GEOSTATIONARY) // Geostationary { - formimage->displayImage(IMAGE_GEOSTATIONARY); + formimage->displayImage(IMAGE_GEOSTATIONARY, true); } else if (index == TAB_PROJECTION) // Projection { @@ -2865,8 +2928,7 @@ void FormToolbox::on_tabWidget_currentChanged(int index) else imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, this->currentProjectionType, ui->spbOMwidth->value(), ui->spbOMheight->value()); - formimage->UpdateProjection(); - formimage->adjustPicSize(false); + formimage->displayImage(IMAGE_PROJECTION, true); } // opts.currenttabwidget = ui->tabWidget->currentIndex(); @@ -2878,16 +2940,10 @@ void FormToolbox::on_tabWidgetVIIRS_currentChanged(int index) qDebug() << "on_tabWidgetVIIRS_currentChanged(int index) index = " << index; - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - if (index == 0) //VIIRSM - formimage->displayImage(IMAGE_VIIRSM); + formimage->displayImage(IMAGE_VIIRSM, true); else if (index == 1) //VIIRSDNB - formimage->displayImage(IMAGE_VIIRSDNB); + formimage->displayImage(IMAGE_VIIRSDNB, true); } void FormToolbox::on_tabWidgetSentinel_currentChanged(int index) @@ -2895,16 +2951,10 @@ void FormToolbox::on_tabWidgetSentinel_currentChanged(int index) qDebug() << "on_tabWidgetSentinel_currentChanged(int index) index = " << index; - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - if (index == 0) //OLCI - formimage->displayImage(IMAGE_OLCI); + formimage->displayImage(IMAGE_OLCI, true); else if (index == 1) //SLSTR - formimage->displayImage(IMAGE_SLSTR); + formimage->displayImage(IMAGE_SLSTR, true); } void FormToolbox::on_chkShowLambert_stateChanged(int arg1) @@ -2957,7 +3007,8 @@ void FormToolbox::on_spbScaleX_valueChanged(double arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); + } } @@ -2968,7 +3019,8 @@ void FormToolbox::on_spbScaleY_valueChanged(double arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); + } } @@ -2979,7 +3031,7 @@ void FormToolbox::on_spbGVPlat_valueChanged(double arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->gvp->Initialize(ui->spbGVPlon->value(), ui->spbGVPlat->value(), ui->spbGVPheight->value(), ui->spbGVPscale->value(), ui->spbGVPFalseEasting->value(), ui->spbGVPFalseNorthing->value(),imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); formmovie->setGVPlat(arg1); } @@ -2991,7 +3043,7 @@ void FormToolbox::on_spbGVPlon_valueChanged(double arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->gvp->Initialize(ui->spbGVPlon->value(), ui->spbGVPlat->value(), ui->spbGVPheight->value(), ui->spbGVPscale->value(), ui->spbGVPFalseEasting->value(), ui->spbGVPFalseNorthing->value(),imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); formmovie->setGVPlon(arg1); } @@ -3003,7 +3055,7 @@ void FormToolbox::on_spbGVPheight_valueChanged(int arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->gvp->Initialize(ui->spbGVPlon->value(), ui->spbGVPlat->value(), ui->spbGVPheight->value(), ui->spbGVPscale->value(), ui->spbGVPFalseEasting->value(), ui->spbGVPFalseNorthing->value(),imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); formmovie->setGVPheight(arg1); } @@ -3016,7 +3068,7 @@ void FormToolbox::on_spbGVPFalseEasting_valueChanged(double arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->gvp->Initialize(ui->spbGVPlon->value(), ui->spbGVPlat->value(), ui->spbGVPheight->value(), ui->spbGVPscale->value(), ui->spbGVPFalseEasting->value(), ui->spbGVPFalseNorthing->value(), imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); formmovie->setGVPFalseEasting(arg1); } @@ -3029,7 +3081,7 @@ void FormToolbox::on_spbGVPFalseNorthing_valueChanged(double arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->gvp->Initialize(ui->spbGVPlon->value(), ui->spbGVPlat->value(), ui->spbGVPheight->value(), ui->spbGVPscale->value(), ui->spbGVPFalseEasting->value(), ui->spbGVPFalseNorthing->value(),imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); formmovie->setGVPFalseNorthing(arg1); } @@ -3043,7 +3095,7 @@ void FormToolbox::on_spbGVPscale_valueChanged(double arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->gvp->Initialize(ui->spbGVPlon->value(), ui->spbGVPlat->value(), ui->spbGVPheight->value(), ui->spbGVPscale->value(), ui->spbGVPFalseEasting->value(), ui->spbGVPFalseNorthing->value(),imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); formmovie->setGVPscale(arg1); } } @@ -3138,12 +3190,6 @@ void FormToolbox::on_btnCreatePerspective_clicked() int width = imageptrs->ptrimageProjection->width(); int height = imageptrs->ptrimageProjection->height(); - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - if(ui->rdbAVHRRin->isChecked()) { @@ -3164,12 +3210,10 @@ void FormToolbox::on_btnCreatePerspective_clicked() currentProjectionType = PROJ_VIIRSM; - ui->btnGVPFalseColor->setChecked(false); if(opts.buttonVIIRSM) imageptrs->gvp->CreateMapFromVIIRS(eSegmentType::SEG_VIIRSM, false); else if(opts.buttonVIIRSMNOAA20) imageptrs->gvp->CreateMapFromVIIRS(eSegmentType::SEG_VIIRSMNOAA20, false); - initializeScales(); } else if(ui->rdbVIIRSDNBin->isChecked()) @@ -3205,38 +3249,11 @@ void FormToolbox::on_btnCreatePerspective_clicked() if(ui->rdbCombine->isChecked()) delete imageptrs->ptrimageProjectionCopy; - formimage->setPixmapToLabel(true); + formimage->setPixmapToScene(true); QApplication::restoreOverrideCursor(); } -void FormToolbox::initializeScales() -{ - QList blist = this->getVIIRSMBandList(); - if(blist.at(12) || blist.at(13) || blist.at(14) || blist.at(15) || blist.at(16)) - { - copyProjectionImage(); - - forminfrascales->initializeLowHigh(); - forminfrascales->setMinMaxTemp( segs->seglviirsm->getMinBrightnessTempProjection(), segs->seglviirsm->getMaxBrightnessTempProjection()); - - qDebug() << QString("setMinMaxTemp %1 %2").arg(segs->seglviirsm->getMinBrightnessTempProjection()).arg(segs->seglviirsm->getMaxBrightnessTempProjection()); - - QList ilist = this->getVIIRSMInvertList(); - if(blist.at(12)) - forminfrascales->setInverse(ilist.at(11)); - else if(blist.at(13)) - forminfrascales->setInverse(ilist.at(12)); - else if(blist.at(14)) - forminfrascales->setInverse(ilist.at(13)); - else if(blist.at(15)) - forminfrascales->setInverse(ilist.at(14)); - else if(blist.at(16)) - forminfrascales->setInverse(ilist.at(15)); - } - -} - void FormToolbox::copyProjectionImage() { int width = imageptrs->ptrimageProjection->width(); @@ -3366,12 +3383,6 @@ void FormToolbox::on_btnCreateLambert_clicked() int width = imageptrs->ptrimageProjection->width(); int height = imageptrs->ptrimageProjection->height(); - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); if(ui->rdbAVHRRin->isChecked()) { @@ -3390,14 +3401,12 @@ void FormToolbox::on_btnCreateLambert_clicked() } } - ui->btnLCCFalseColor->setChecked(false); currentProjectionType = PROJ_VIIRSM; if(opts.buttonVIIRSM) imageptrs->lcc->CreateMapFromVIIRS(eSegmentType::SEG_VIIRSM, false); else if(opts.buttonVIIRSMNOAA20) imageptrs->lcc->CreateMapFromVIIRS(eSegmentType::SEG_VIIRSMNOAA20, false); - initializeScales(); } else if(ui->rdbVIIRSDNBin->isChecked()) { @@ -3431,7 +3440,7 @@ void FormToolbox::on_btnCreateLambert_clicked() if(ui->rdbCombine->isChecked()) delete imageptrs->ptrimageProjectionCopy; - formimage->setPixmapToLabel(true); + formimage->setPixmapToScene(true); QApplication::restoreOverrideCursor(); } @@ -3512,12 +3521,6 @@ void FormToolbox::on_btnCreateStereo_clicked() int width = imageptrs->ptrimageProjection->width(); int height = imageptrs->ptrimageProjection->height(); - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - if(ui->rdbAVHRRin->isChecked()) { currentProjectionType = PROJ_AVHRR; @@ -3535,15 +3538,12 @@ void FormToolbox::on_btnCreateStereo_clicked() } } - ui->btnSGFalseColor->setChecked(false); - currentProjectionType = PROJ_VIIRSM; if(opts.buttonVIIRSM) imageptrs->sg->CreateMapFromVIIRS(eSegmentType::SEG_VIIRSM, false); else if(opts.buttonVIIRSMNOAA20) imageptrs->sg->CreateMapFromVIIRS(eSegmentType::SEG_VIIRSMNOAA20, false); - initializeScales(); - } + } else if(ui->rdbVIIRSDNBin->isChecked()) { currentProjectionType = PROJ_VIIRSDNB; @@ -3576,7 +3576,7 @@ void FormToolbox::on_btnCreateStereo_clicked() if(ui->rdbCombine->isChecked()) delete imageptrs->ptrimageProjectionCopy; - formimage->setPixmapToLabel(true); + formimage->setPixmapToScene(true); QApplication::restoreOverrideCursor(); } @@ -3649,7 +3649,7 @@ void FormToolbox::on_btnCreateOM_clicked() imageptrs->om->CreateMapFromAVHRR(eSegmentType::SEG_METOP, ui->cmbInputAVHRRChannel->currentIndex()); } - formimage->setPixmapToLabel(true); + formimage->setPixmapToScene(true); QApplication::restoreOverrideCursor(); } @@ -3661,7 +3661,7 @@ void FormToolbox::on_spbParallel1_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3673,7 +3673,7 @@ void FormToolbox::on_spbParallel2_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3687,7 +3687,7 @@ void FormToolbox::on_spbCentral_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3702,7 +3702,7 @@ void FormToolbox::on_spbLatOrigin_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3726,7 +3726,7 @@ void FormToolbox::on_spbSouth_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3748,7 +3748,7 @@ void FormToolbox::on_spbNorth_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3772,7 +3772,7 @@ void FormToolbox::on_spbWest_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3798,7 +3798,7 @@ void FormToolbox::on_spbEast_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3847,9 +3847,6 @@ void FormToolbox::on_toolBox_currentChanged(int index) ui->comboPOI->blockSignals(true); ui->comboPOI->clear(); - // if(!dockinfrascales->isHidden()) - // dockinfrascales->hide(); - imageptrs->ptrProjectionInfra.reset(); imageptrs->ptrProjectionBrightnessTemp.reset(); @@ -3884,36 +3881,23 @@ void FormToolbox::on_toolBox_currentChanged(int index) } ui->comboPOI->blockSignals(false); - formimage->UpdateProjection(); - formimage->adjustPicSize(false); + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::on_btnGVPClearMap_clicked() { - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - imageptrs->ptrimageProjection->fill(qRgba(0, 0, 0, 250)); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::on_btnLCCClearMap_clicked() { - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); imageptrs->ptrimageProjection->fill(qRgba(0, 0, 0, 250)); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } @@ -3937,7 +3921,7 @@ void FormToolbox::on_btnLCCMapNorth_clicked() { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3962,7 +3946,7 @@ void FormToolbox::on_btnLCCMapSouth_clicked() { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -3996,7 +3980,7 @@ void FormToolbox::on_btnLCCMapWest_clicked() { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -4030,7 +4014,7 @@ void FormToolbox::on_btnLCCMapEast_clicked() { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -4042,7 +4026,7 @@ void FormToolbox::on_spbSGlat_valueChanged(double arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -4053,7 +4037,7 @@ void FormToolbox::on_spbSGlon_valueChanged(double arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -4064,7 +4048,7 @@ void FormToolbox::on_spbSGScale_valueChanged(double arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -4091,7 +4075,7 @@ void FormToolbox::on_spbSGPanHorizon_valueChanged(int arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -4102,7 +4086,7 @@ void FormToolbox::on_spbSGPanVert_valueChanged(int arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -4113,21 +4097,15 @@ void FormToolbox::on_spbSGRadius_valueChanged(double arg1) if(imageptrs->ptrimageProjection->width() > 0) { imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), imageptrs->ptrimageProjection->width(), imageptrs->ptrimageProjection->height(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } } void FormToolbox::on_btnSGClearMap_clicked() { - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - imageptrs->ptrimageProjection->fill(qRgba(0, 0, 0, 250)); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } @@ -4139,7 +4117,7 @@ void FormToolbox::on_spbLCCCorrX_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value()*1000, ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -4151,7 +4129,7 @@ void FormToolbox::on_spbLCCCorrY_valueChanged(int arg1) { imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value()*1000, ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } @@ -4318,12 +4296,6 @@ void FormToolbox::on_btnUpdateVIIRSImage_clicked() return; } - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - ui->pbProgress->reset(); formimage->ShowVIIRSMImage(); } @@ -4356,10 +4328,6 @@ void FormToolbox::on_btnUpdateOLCIImage_clicked() if(segs->seglolciefr->NbrOfSegmentsSelected() > 0) { - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - ui->pbProgress->reset(); formimage->ShowOLCIefrImage(ui->cmbHistogramOLCI->currentIndex(), ui->rdbOLCINormalized); } @@ -4369,10 +4337,6 @@ void FormToolbox::on_btnUpdateOLCIImage_clicked() if(segs->seglolcierr->NbrOfSegmentsSelected() > 0) { - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - ui->pbProgress->reset(); formimage->ShowOLCIerrImage(ui->cmbHistogramOLCI->currentIndex(), ui->rdbOLCINormalized); } @@ -4403,11 +4367,6 @@ void FormToolbox::on_btnUpdateSLSTRImage_clicked() { if(segs->seglslstr->NbrOfSegmentsSelected() > 0) { - - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - ui->pbProgress->reset(); formimage->ShowSLSTRImage(ui->cmbHistogramSLSTR->currentIndex()); } @@ -4437,12 +4396,6 @@ void FormToolbox::on_btnUpdateMERSIImage_clicked() return; } - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - ui->pbProgress->reset(); formimage->ShowMERSIImage(ui->cmbHistogramMERSI->currentIndex(), false); } @@ -4496,7 +4449,7 @@ void FormToolbox::on_sliCLAHE_RGBRecipe_sliderMoved(int position) ui->lblCLAHE_RGBRecipe->setText(QString("%1").arg(float(position)/10, 0, 'f', 1)); } -void FormToolbox::createFilenamestring(QString sat, QString d, QVector spectrum) +void FormToolbox::createImageFilenamestring(QString sat, QString d, QVector spectrum) { QString outstring; outstring.append(sat + "_" + d.mid(0, 4) + d.mid(5, 2) + d.mid(8, 2) + d.mid(13, 2) + d.mid(16, 2)); @@ -4534,7 +4487,7 @@ void FormToolbox::on_cbProjResolutions_currentIndexChanged(int index) ui->spbLCCMapHeight->setValue(resolutionY.at(index-1)); imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } else if(ui->toolBox->currentIndex() == 1) { @@ -4547,14 +4500,14 @@ void FormToolbox::on_cbProjResolutions_currentIndexChanged(int index) formmovie->setGVPMapWidth(ui->spbGVPMapWidth->value()); formmovie->setGVPMapHeight(ui->spbGVPMapHeight->value()); } - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } else if(ui->toolBox->currentIndex() == 2) { ui->spbSGMapWidth->setValue(resolutionX.at(index-1)); ui->spbSGMapHeight->setValue(resolutionY.at(index-1)); imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), ui->spbSGMapWidth->value(), ui->spbSGMapHeight->value(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } QApplication::restoreOverrideCursor(); @@ -5236,14 +5189,15 @@ void FormToolbox::on_comboPOI_currentIndexChanged(int index) setLCCParameters(index); imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } else if(ui->toolBox->currentIndex() == 1) // GVP { setGVPParameters(index); imageptrs->gvp->Initialize(ui->spbGVPlon->value(), ui->spbGVPlat->value(), ui->spbGVPheight->value(), ui->spbGVPscale->value(), ui->spbGVPFalseEasting->value(), ui->spbGVPFalseNorthing->value(), ui->spbGVPMapWidth->value(), ui->spbGVPMapHeight->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); + if(formmovie) { formmovie->setGVPlat(ui->spbGVPlat->value()); @@ -5261,31 +5215,31 @@ void FormToolbox::on_comboPOI_currentIndexChanged(int index) { setSGParameters(index); imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), ui->spbSGMapWidth->value(), ui->spbSGMapHeight->value(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } } void FormToolbox::on_chkLCCGridOnProj_clicked() { - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::on_chkGVPGridOnProj_clicked() { formmovie->setGVPDisplayGrid(ui->chkGVPGridOnProj->isChecked()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::on_chkSGGridOnProj_clicked() { - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::on_chkOMGridOnProj_clicked() { qDebug() << "FormToolbox::on_chkOMGridOnProjection_clicked()"; - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::on_btnAddPOI_clicked() @@ -5491,142 +5445,7 @@ void FormToolbox::on_btnAddMConfig_clicked() } -void FormToolbox::on_btnGVPFalseColor_clicked() -{ - if(imageptrs->ptrProjectionInfra.isNull()) - { - QMessageBox msgBox; - msgBox.setText("Only for VIIRS channels M12 to M16."); - msgBox.exec(); - - ui->btnGVPFalseColor->setChecked(false); - return; - } - - if(forminfrascales->isHidden()) - { - QList blist = this->getVIIRSMBandList(); - // if(formimage->getSegmentType() == eSegmentType::SEG_VIIRSM && - if(ui->rdbVIIRSMin->isChecked() && - (blist.at(12) == true || blist.at(13) == true || blist.at(14) == true || blist.at(15) == true || blist.at(16) == true )) - { - ui->btnGVPFalseColor->setChecked(true); - forminfrascales->show(); - forminfrascales->initializeLowHigh(); - formimage->ToInfraColorProjection(); - formimage->displayImage(IMAGE_PROJECTION); - } - else - { - QMessageBox msgBox; - msgBox.setText("Only for VIIRS channels M12 to M16."); - msgBox.exec(); - ui->btnGVPFalseColor->setChecked(false); - } - } - else - { - ui->btnGVPFalseColor->setChecked(false); - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - - formimage->FromInfraColorProjection(); - formimage->displayImage(IMAGE_PROJECTION); - } - -} - -void FormToolbox::on_btnLCCFalseColor_clicked() -{ - if(imageptrs->ptrProjectionInfra.isNull()) - { - ui->btnLCCFalseColor->setChecked(false); - return; - } - - if(forminfrascales->isHidden()) - { - QList blist = this->getVIIRSMBandList(); - // if(formimage->getSegmentType() == eSegmentType::SEG_VIIRSM && - if(ui->rdbVIIRSMin->isChecked() && - (blist.at(12) == true || blist.at(13) == true || blist.at(14) == true || blist.at(15) == true || blist.at(16) == true )) - { - ui->btnLCCFalseColor->setChecked(true); - forminfrascales->show(); - forminfrascales->initializeLowHigh(); - formimage->ToInfraColorProjection(); - formimage->displayImage(IMAGE_PROJECTION); - } - else - { - QMessageBox msgBox; - msgBox.setText("Only for VIIRS channels M12 to M16."); - msgBox.exec(); - ui->btnLCCFalseColor->setChecked(false); - } - } - else - { - ui->btnLCCFalseColor->setChecked(false); - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - - formimage->FromInfraColorProjection(); - formimage->displayImage(IMAGE_PROJECTION); - } - -} - -void FormToolbox::on_btnSGFalseColor_clicked() -{ - if(imageptrs->ptrProjectionInfra.isNull()) - { - ui->btnSGFalseColor->setChecked(false); - return; - } - - if(forminfrascales->isHidden()) - { - QList blist = this->getVIIRSMBandList(); - // if(formimage->getSegmentType() == eSegmentType::SEG_VIIRSM && - if(ui->rdbVIIRSMin->isChecked() && - (blist.at(12) == true || blist.at(13) == true || blist.at(14) == true || blist.at(15) == true || blist.at(16) == true )) - { - ui->btnSGFalseColor->setChecked(true); - forminfrascales->show(); - forminfrascales->initializeLowHigh(); - formimage->ToInfraColorProjection(); - formimage->displayImage(IMAGE_PROJECTION); - } - else - { - QMessageBox msgBox; - msgBox.setText("Only for VIIRS channels M12 to M16."); - msgBox.exec(); - ui->btnSGFalseColor->setChecked(false); - } - } - else - { - ui->btnSGFalseColor->setChecked(false); - if(!forminfrascales->isHidden()) - forminfrascales->hide(); - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - - formimage->FromInfraColorProjection(); - formimage->displayImage(IMAGE_PROJECTION); - } - -} void FormToolbox::slotDisplayDNBGraph() { @@ -5789,26 +5608,16 @@ void FormToolbox::on_cmbHistogram_activated(int index) { if(segs->seglolciefr->NbrOfSegmentsSelected() > 0) { - - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - ui->pbProgress->reset(); - formimage->ShowHistogramImageOLCI(ui->cmbHistogramOLCI->currentIndex(), ui->rdbOLCINormalized->isChecked()); +// formimage->ShowHistogramImageOLCI(ui->cmbHistogramOLCI->currentIndex(), ui->rdbOLCINormalized->isChecked()); } } else if(opts.buttonOLCIerr) { if(segs->seglolcierr->NbrOfSegmentsSelected() > 0) { - - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - ui->pbProgress->reset(); - formimage->ShowHistogramImageOLCI(ui->cmbHistogramOLCI->currentIndex(), ui->rdbOLCINormalized->isChecked()); +// formimage->ShowHistogramImageOLCI(ui->cmbHistogramOLCI->currentIndex(), ui->rdbOLCINormalized->isChecked()); } } @@ -5828,7 +5637,7 @@ void FormToolbox::on_cmbHistogramAVHRR_activated(int index) segs->seglM01hrpt->setHistogramMethod(ui->cmbHistogramAVHRR->currentIndex()); segs->seglM02hrpt->setHistogramMethod(ui->cmbHistogramAVHRR->currentIndex()); - formimage->MakeImage(); +// formimage->MakeImage(); } void FormToolbox::on_cmbHistogramSLSTR_activated(int index) @@ -5839,13 +5648,8 @@ void FormToolbox::on_cmbHistogramSLSTR_activated(int index) { if(segs->seglslstr->NbrOfSegmentsSelected() > 0) { - - ui->btnGVPFalseColor->setChecked(false); - ui->btnSGFalseColor->setChecked(false); - ui->btnLCCFalseColor->setChecked(false); - ui->pbProgress->reset(); - formimage->ShowHistogramImageSLSTR(ui->cmbHistogramSLSTR->currentIndex()); +// formimage->ShowHistogramImageSLSTR(ui->cmbHistogramSLSTR->currentIndex()); } } } @@ -5912,11 +5716,11 @@ void FormToolbox::setAllWhatsThis() void FormToolbox::on_btnSaveAsPNG48bits_clicked() { - if(!formimage->SaveAsPNG48bits(ui->rdbMapTo65535->isChecked())) - { - QMessageBox::information( this, "Save 48bit PNG", - "There is no input file !" ); - } +// if(!formimage->SaveAsPNG48bits(ui->rdbMapTo65535->isChecked())) +// { +// QMessageBox::information( this, "Save 48bit PNG", +// "There is no input file !" ); +// } } @@ -6123,7 +5927,9 @@ void FormToolbox::on_btnCLAHE_RGBRecipe_clicked() QApplication::processEvents(); qDebug() << QString("ui->sliCLAHE_RGBRecipe value = %1").arg((float)ui->sliCLAHE_RGBRecipe->value()/10.0); formimage->CLAHERGBRecipe((float)ui->sliCLAHE_RGBRecipe->value()/10.0); - formimage->slotUpdateGeosat(); + formimage->displayImage(IMAGE_GEOSTATIONARY, true); + this->setToolboxButtons(true); + QApplication::restoreOverrideCursor(); } @@ -6235,8 +6041,7 @@ void FormToolbox::on_rdbVIIRSMin_clicked() if( this->getToolboxIndex() == 3) imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, this->currentProjectionType, ui->spbOMwidth->value(), ui->spbOMheight->value()); - formimage->UpdateProjection(); - + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::on_rdbVIIRSDNBin_clicked() @@ -6260,7 +6065,7 @@ void FormToolbox::on_rdbMERSIin_clicked() if( this->getToolboxIndex() == 3) imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, this->currentProjectionType, ui->spbOMwidth->value(), ui->spbOMheight->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::on_rdbMeteosatin_clicked() @@ -6271,7 +6076,7 @@ void FormToolbox::on_rdbMeteosatin_clicked() void FormToolbox::on_btnOMClearMap_clicked() { imageptrs->ptrimageProjection->fill(qRgba(0, 0, 0, 250)); - formimage->displayImage(IMAGE_PROJECTION); + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::slotChangeAspectRatio(QPoint vec) @@ -6287,13 +6092,13 @@ void FormToolbox::slotChangeAspectRatio(QPoint vec) void FormToolbox::on_spbOMwidth_valueChanged(int arg1) { imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, this->currentProjectionType, ui->spbOMwidth->value(), ui->spbOMheight->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } void FormToolbox::on_spbOMheight_valueChanged(int arg1) { imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, this->currentProjectionType, ui->spbOMwidth->value(), ui->spbOMheight->value()); - formimage->UpdateProjection(); + formimage->displayImage(IMAGE_PROJECTION, true); } int FormToolbox::getGVPMapWidth() @@ -6341,3 +6146,10 @@ int FormToolbox::getGVPFalseNorthing() return ui->spbGVPFalseNorthing->value(); } + +void FormToolbox::on_cbProjResolutions_activated(int index) +{ + formimage->displayImage(IMAGE_PROJECTION, true); +} + + diff --git a/core/formtoolbox.h b/core/formtoolbox.h index 35e0409..ac117da 100644 --- a/core/formtoolbox.h +++ b/core/formtoolbox.h @@ -5,9 +5,8 @@ #include #include #include "formimage.h" -#include "formmapcyl.h" +//#include "formmapcyl.h" #include "formgeostationary.h" -#include "forminfrascales.h" #include "formmovie.h" namespace Ui { @@ -16,7 +15,6 @@ namespace Ui { class FormImage; class FormGeostationary; -class FormInfraScales; class FormMovie; class FormToolbox : public QWidget @@ -24,7 +22,7 @@ class FormToolbox : public QWidget Q_OBJECT public: - explicit FormToolbox(QWidget *parent = 0, FormImage *p_formimage = 0, FormGeostationary *p_formgeostationary = 0, FormInfraScales *p_forminfrascales = 0, AVHRRSatellite *seglist = 0); + explicit FormToolbox(QWidget *parent = 0, FormImage *p_formimage = 0, FormGeostationary *p_formgeostationary = 0, AVHRRSatellite *seglist = 0); int getTabWidgetIndex(); int getToolboxIndex(); int getTabWidgetVIIRSIndex(); @@ -34,6 +32,9 @@ class FormToolbox : public QWidget void setGeoIndex(int geo) { this->geoindex = geo; } void getOMimagesize(int *width, int *height ); void setOMimagesize(int width, int height); + QVector getSpectrumVector() { return spectrumvector; }; + QVector getInverseVector() { return inversevector; }; + QList getVIIRSMBandList(); QList getVIIRSMColorList(); @@ -54,6 +55,8 @@ class FormToolbox : public QWidget QList getMERSIInvertList(); int getMERSIHistogrammethod(); + + int getGVPMapWidth(); int getGVPMapHeight(); float getGVPLat(); @@ -71,8 +74,8 @@ class FormToolbox : public QWidget void setTabWidgetVIIRSIndex(int index); void setTabWidgetSentinelIndex(int index); void writeInfoToTextEdit(QString info); - void createFilenamestring(QString sat, QString d, QVector spectrum); - QString returnFilenamestring() { return filenamecreated; } + void createImageFilenamestring(QString sat, QString d, QVector spectrum); + QString returnImageFilenamestring() { return filenamecreated; } bool comboColVIIRSOK(); bool comboColOLCIOK(); bool comboColSLSTROK(); @@ -88,10 +91,9 @@ class FormToolbox : public QWidget void setSLSTRConfigsettings(); void setMERSIConfigsettings(); void setComboGeo(int geoindex); - void setValuePrgBar(int val); void setFormMovie(FormMovie *formmovie); - - + void setProgressMaximum(int max); + QStringList getRowchosen() { return rowchosen; } eProjectionType currentProjectionType; @@ -100,7 +102,6 @@ class FormToolbox : public QWidget private: Ui::FormToolbox *ui; FormImage *formimage; - FormInfraScales *forminfrascales; FormGeostationary *formgeostationary; FormMovie *formmovie; QCPColorMap *colorMap; @@ -126,7 +127,6 @@ class FormToolbox : public QWidget void setRadioButtonsSLSTRToFalse(); void copyProjectionImage(); bool checkSegmentDateTime(); - void initializeScales(); void setLogValue(int deg, double rad); void fitCurve(); void setAllWhatsThis(); @@ -155,7 +155,7 @@ public slots: void setButtons(int geoindex, bool state); void slotDisplayDNBGraph(); - void slotChangeAspectRatio(QPoint); + void slotChangeAspectRatio(QPoint); signals: void getgeosatchannel(QString, QVector, QVector, int, bool); @@ -289,9 +289,9 @@ private slots: void on_tabWidgetVIIRS_currentChanged(int index); void on_tabWidgetSentinel_currentChanged(int index); - void on_btnGVPFalseColor_clicked(); - void on_btnLCCFalseColor_clicked(); - void on_btnSGFalseColor_clicked(); +// void on_btnGVPFalseColor_clicked(); +// void on_btnLCCFalseColor_clicked(); +// void on_btnSGFalseColor_clicked(); void on_rdbOLCINormalized_toggled(bool checked); void on_cmbHistogram_activated(int index); @@ -341,6 +341,7 @@ private slots: void on_spbOMheight_valueChanged(int arg1); void on_spbGVPFalseNorthing_valueChanged(double arg1); void on_spbGVPFalseEasting_valueChanged(double arg1); + void on_cbProjResolutions_activated(int index); }; diff --git a/core/formtoolbox.ui b/core/formtoolbox.ui index af97641..dd85a74 100644 --- a/core/formtoolbox.ui +++ b/core/formtoolbox.ui @@ -49,7 +49,7 @@ QTabWidget::West - 5 + 4 Qt::ElideNone @@ -1119,7 +1119,7 @@ - 1 + 0 @@ -7431,14 +7431,14 @@ - 1 + 0 0 0 - 373 + 557 592 @@ -8121,16 +8121,6 @@ - - - - False Color - - - true - - - @@ -8255,8 +8245,8 @@ 0 0 - 574 - 428 + 486 + 336 @@ -8582,16 +8572,6 @@ - - - - False Color - - - true - - - @@ -8899,16 +8879,6 @@ - - - - False Color - - - true - - - @@ -9068,8 +9038,8 @@ 0 0 - 574 - 428 + 467 + 229 diff --git a/core/mainwindow.cpp b/core/mainwindow.cpp index 79a73fa..4791f39 100644 --- a/core/mainwindow.cpp +++ b/core/mainwindow.cpp @@ -42,15 +42,10 @@ MainWindow::MainWindow(QWidget *parent) : globe = new Globe(this, satlist, seglist); formimage = new FormImage(this, satlist, seglist); - imagescrollarea = new ImageScrollArea(); - imagescrollarea->setBackgroundRole(QPalette::Dark); - imagescrollarea->setWidget(formimage); - formgeostationary->SetFormImage(formimage); - connect(formimage, SIGNAL(moveImage(QPoint,QPoint)), this, SLOT(moveImage(QPoint,QPoint))); for(int i = 0; i < opts.geosatellites.count(); i++) - connect(seglist->seglgeo[i], SIGNAL(signalcomposefinished(QString)), formimage, SLOT(slotcomposefinished(QString))); + connect(seglist->seglgeo[i], SIGNAL(signalcomposefinished(QString, int)), formimage, SLOT(slotcomposefinished(QString, int))); imageptrs->gvp = new GeneralVerticalPerspective(this, seglist); imageptrs->lcc = new LambertConformalConic(this, seglist); @@ -62,8 +57,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow::setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); QMainWindow::setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); - forminfrascales = new FormInfraScales(); - formtoolbox = new FormToolbox(this, formimage, formgeostationary, forminfrascales, seglist); + formtoolbox = new FormToolbox(this, formimage, formgeostationary, seglist); formimage->SetFormToolbox(formtoolbox); formgeostationary->SetFormToolBox(formtoolbox); @@ -99,16 +93,10 @@ MainWindow::MainWindow(QWidget *parent) : createDockWidget(); - forminfrascales->setFormImage(formimage); - - addDockWidget(Qt::BottomDockWidgetArea, forminfrascales); - forminfrascales->hide(); - - formimage->SetDockWidgetInfraScales(forminfrascales); ui->stackedWidget->addWidget(formglobecyl); // index 2 - ui->stackedWidget->addWidget(imagescrollarea); // index 3 + ui->stackedWidget->addWidget(formimage); //imagescrollarea); // index 3 formmovie = new FormMovie(this); formmovie->SetFormToolbox(formtoolbox); @@ -118,44 +106,44 @@ MainWindow::MainWindow(QWidget *parent) : ui->stackedWidget->setCurrentIndex(0); - connect(seglist->seglmetop, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglnoaa, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglhrp, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglgac, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - - connect(seglist->seglmetopAhrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglmetopBhrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglnoaa19hrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglM01hrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglM02hrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - - connect(seglist->seglviirsm, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglviirsdnb, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglviirsmnoaa20, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglviirsdnbnoaa20, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglolciefr, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglolcierr, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglslstr, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglmersi, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - - connect(seglist->seglmetop, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglnoaa, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglhrp, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglgac, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - - connect(seglist->seglmetopAhrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglmetopBhrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglnoaa19hrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglM01hrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglM02hrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - - connect(seglist->seglviirsm, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglviirsdnb, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglviirsmnoaa20, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglviirsdnbnoaa20, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglolciefr, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglolcierr, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); - connect(seglist->seglmersi, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); + connect(seglist->seglmetop, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglnoaa, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglhrp, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglgac, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + + connect(seglist->seglmetopAhrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglmetopBhrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglnoaa19hrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglM01hrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglM02hrpt, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + + connect(seglist->seglviirsm, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglviirsdnb, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglviirsmnoaa20, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglviirsdnbnoaa20, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglolciefr, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglolcierr, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglslstr, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglmersi, SIGNAL(segmentlistfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + + connect(seglist->seglmetop, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglnoaa, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglhrp, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglgac, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + + connect(seglist->seglmetopAhrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglmetopBhrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglnoaa19hrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglM01hrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglM02hrpt, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + + connect(seglist->seglviirsm, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglviirsdnb, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglviirsmnoaa20, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglviirsdnbnoaa20, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglolciefr, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglolcierr, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); + connect(seglist->seglmersi, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToScene(bool))); connect(seglist, SIGNAL(signalXMLProgress(QString, int, bool)), formglobecyl, SLOT(slotShowXMLProgress(QString, int, bool))); @@ -177,7 +165,7 @@ MainWindow::MainWindow(QWidget *parent) : connect( formimage, SIGNAL(render3dgeo(int)), globe, SLOT(Render3DGeo(int))); connect( formimage, SIGNAL(allsegmentsreceivedbuttons(bool)), formtoolbox, SLOT(setToolboxButtons(bool))); connect( formimage, SIGNAL(setmapcylbuttons(bool)), formglobecyl, SLOT(slotSetMapCylButtons(bool))); - connect( formimage->imageLabel, SIGNAL(coordinateChanged(QString)), this, SLOT(updateStatusBarCoordinate(QString))); + //connect( formimage, SIGNAL(coordinateChanged(QString)), this, SLOT(updateStatusBarCoordinate(QString))); connect( globe, SIGNAL(renderingglobefinished(bool)), formtoolbox, SLOT(setToolboxButtons(bool))); @@ -192,6 +180,8 @@ MainWindow::MainWindow(QWidget *parent) : connect( imageptrs->om, SIGNAL(aspectratioChanged(QPoint)), formtoolbox, SLOT(slotChangeAspectRatio(QPoint))); + connect( formimage, SIGNAL(signalMainWindowTitleChanged(QString)), this, SLOT(slotMainWindowTitleChanged(QString))); + formtoolbox->setChannelIndex(); setWindowTitle(tr("EUMETCast Viewer")); @@ -209,6 +199,16 @@ MainWindow::MainWindow(QWidget *parent) : qDebug() << QString("HDF5 library %1.%2.%3").arg(majnum).arg(minnum).arg(relnum); + char envvar[] = "HDF5_PLUGIN_PATH"; + + // Make sure envar actually exists + if(!getenv(envvar)){ + fprintf(stderr, "The environment variable %s was not found.\n", envvar); + fprintf(stderr, "setting environment variable.\n"); + setenv(envvar, ".", 1); + } + + restoreGeometry(opts.mainwindowgeometry); restoreState(opts.mainwindowstate); //QMainWindow::resizeDocks({dockwidget}, {1000}, Qt::Horizontal); @@ -285,8 +285,6 @@ void MainWindow::closeEvent(QCloseEvent *event) qDebug() << "Width of toolbox = " << formtoolbox->width(); - //forminfrascales->close(); - delete timer; delete formtoolbox; delete formephem; @@ -381,7 +379,7 @@ void MainWindow::on_actionPreferences_triggered() DialogPreferences *pref=new DialogPreferences(this); pref->setAttribute(Qt::WA_DeleteOnClose); pref->show(); - connect(pref,SIGNAL(finished(int)), formimage, SLOT(slotRefreshOverlay())); + //connect(pref,SIGNAL(finished(int)), formimage, SLOT(slotRefreshOverlay())); connect(pref,SIGNAL(finished(int)), this, SLOT(slotPreferencesFinished(int))); } @@ -419,7 +417,7 @@ void MainWindow::on_actionAbout_triggered() void MainWindow::on_actionNormalSize_triggered() { - formimage->normalSize(); + formimage->originalSize(); } void MainWindow::on_actionZoomin_triggered() @@ -439,17 +437,12 @@ void MainWindow::on_actionWhatsthis_triggered() void MainWindow::on_actionFitWindow_triggered() { - formimage->adjustPicSize(false); + formimage->fitWindow(); qDebug() << QString("mainwindow x = %1 y = %2").arg(this->width()).arg(this->height()); qDebug() << QString("formtoolbox x = %1 y = %2").arg(formtoolbox->width()).arg(formtoolbox->height()); qDebug() << QString("=======> totaal x = %1 y = %2").arg(this->width() - formtoolbox->width()).arg(this->height()); } -void MainWindow::on_actionFitWindowWidth_triggered() -{ - formimage->adjustPicSize(true); -} - void MainWindow::setupStatusBar() { timeLabel = new QLabel; @@ -515,29 +508,29 @@ void MainWindow::on_actionImage_triggered() if(index == -1 || index == TAB_AVHRR) { - formimage->displayImage(IMAGE_AVHRR_COL); + formimage->displayImage(IMAGE_AVHRR_COL, true); } else if(index == TAB_VIIRS) { if(indexviirs == 0) - formimage->displayImage(IMAGE_VIIRSM); //VIIRSM image + formimage->displayImage(IMAGE_VIIRSM, true); //VIIRSM image else - formimage->displayImage(IMAGE_VIIRSDNB); //VIIRSDNB image + formimage->displayImage(IMAGE_VIIRSDNB, true); //VIIRSDNB image } else if(index == TAB_SENTINEL) { if(indexsentinel == 0) - formimage->displayImage(IMAGE_OLCI); //OLCI image + formimage->displayImage(IMAGE_OLCI, true); //OLCI image else - formimage->displayImage(IMAGE_SLSTR); //SLSTR image + formimage->displayImage(IMAGE_SLSTR, true); //SLSTR image } else if(index == TAB_MERSI) { - formimage->displayImage(IMAGE_MERSI); //MERSI image + formimage->displayImage(IMAGE_MERSI, true); //MERSI image } else if(index == TAB_GEOSTATIONARY) { - formimage->displayImage(IMAGE_GEOSTATIONARY); //Geostationary image + formimage->displayImage(IMAGE_GEOSTATIONARY, true); //Geostationary image } else if(index == TAB_PROJECTION) { @@ -547,7 +540,7 @@ void MainWindow::on_actionImage_triggered() formtoolbox->getOMimagesize(&w, &h); imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, formtoolbox->getCurrentProjectionType(), w, h); } - formimage->UpdateProjection(); +// formimage->UpdateProjection(); // formimage->displayImage(IMAGE_PROJECTION); //Projection image } @@ -581,14 +574,14 @@ void MainWindow::on_actionShowToolbox_triggered() void MainWindow::on_actionCreatePNG_triggered() { - QString filestr; + QString filestr = ""; filestr.append("./"); if (formimage->channelshown == IMAGE_GEOSTATIONARY) { - filestr += formtoolbox->returnFilenamestring(); + filestr += formtoolbox->returnImageFilenamestring(); } @@ -603,66 +596,65 @@ void MainWindow::on_actionCreatePNG_triggered() if(fileName.mid(fileName.length()-4) != ".jpg" && fileName.mid(fileName.length()-4) != ".jpg" && fileName.mid(fileName.length()-4) != ".png" && fileName.mid(fileName.length()-4) != ".PNG") fileName.append(".jpg"); - //pm = formimage->returnimageLabelptr()->pixmap(); - QPixmap pixmapVal = formimage->returnimageLabelptr()->pixmap(Qt::ReturnByValue); - if(!forminfrascales->isHidden()) - { - QImage imresult(pixmapVal.width(), pixmapVal.height() + 80, QImage::Format_RGB32); +// QPixmap *pixmapVal = formimage->getPixmap(); +// pixmapVal->save(fileName); - QImage im = pixmapVal.toImage(); - QPainter painter(&imresult); +// QImage im(3712, 3712, QImage::Format_ARGB32); +// QPainter painter(&im); +// painter.setRenderHint(QPainter::SmoothPixmapTransform); - QImage scales = forminfrascales->getScalesImage(im.width()); - //QImage scales(im.width(), 80, im.format()); - //scales.fill(Qt::blue); - painter.drawImage(0, 0, im); - painter.drawImage(0, imresult.height()-80, scales); +// painter.begin(&im); +// formimage->getScene()->render(&painter, im.rect() ); //, rectbuffer()); +// formimage->drawOverlays(&painter); +// painter.end(); - painter.end(); - imresult.save(fileName); - } - else - { - pixmapVal.save(fileName); - } +// im.save(fileName); + +// QGraphicsView* view = new QGraphicsView(formimage->getScene(),this); +// QString fileName = "file_name.png"; +// QPixmap pixMap = view->grab(view->sceneRect().toRect()); +// pixMap.save(fileName); + //Uses QWidget::grab function to create a pixmap and paints the QGraphicsView inside it. + + formimage->savePNGImage(fileName); QApplication::restoreOverrideCursor(); } } -void MainWindow::moveImage(QPoint d, QPoint e) -{ - int width = imagescrollarea->width(); - int height = imagescrollarea->height(); +//void MainWindow::moveImage(QPoint d, QPoint e) +//{ +// int width = imagescrollarea->width(); +// int height = imagescrollarea->height(); - QPoint mousePos = d; +// QPoint mousePos = d; - int deltaX = e.x() - mousePos.x(); - int deltaY = e.y() - mousePos.y(); +// int deltaX = e.x() - mousePos.x(); +// int deltaY = e.y() - mousePos.y(); - if (mousePos.y() <= 4 && imagescrollarea->verticalScrollBar()->value() < imagescrollarea->verticalScrollBar()->maximum() - 10) { - // wrap mouse from top to bottom - mousePos.setY(height - 5); - } else if (mousePos.y() >= height - 4 && imagescrollarea->verticalScrollBar()->value() > 10) { - // wrap mouse from bottom to top - mousePos.setY(5); - } +// if (mousePos.y() <= 4 && imagescrollarea->verticalScrollBar()->value() < imagescrollarea->verticalScrollBar()->maximum() - 10) { +// // wrap mouse from top to bottom +// mousePos.setY(height - 5); +// } else if (mousePos.y() >= height - 4 && imagescrollarea->verticalScrollBar()->value() > 10) { +// // wrap mouse from bottom to top +// mousePos.setY(5); +// } - if (mousePos.x() <= 4 && imagescrollarea->horizontalScrollBar()->value() < imagescrollarea->horizontalScrollBar()->maximum() - 10) { - // wrap mouse from left to right - mousePos.setX(width - 5); - } else if (mousePos.x() >= width - 4 && imagescrollarea->horizontalScrollBar()->value() > 10) { - // wrap mouse from right to left - mousePos.setX(5); - } +// if (mousePos.x() <= 4 && imagescrollarea->horizontalScrollBar()->value() < imagescrollarea->horizontalScrollBar()->maximum() - 10) { +// // wrap mouse from left to right +// mousePos.setX(width - 5); +// } else if (mousePos.x() >= width - 4 && imagescrollarea->horizontalScrollBar()->value() > 10) { +// // wrap mouse from right to left +// mousePos.setX(5); +// } - imagescrollarea->horizontalScrollBar()->setValue(imagescrollarea->horizontalScrollBar()->value() + deltaX); - imagescrollarea->verticalScrollBar()->setValue(imagescrollarea->verticalScrollBar()->value() + deltaY); +// imagescrollarea->horizontalScrollBar()->setValue(imagescrollarea->horizontalScrollBar()->value() + deltaX); +// imagescrollarea->verticalScrollBar()->setValue(imagescrollarea->verticalScrollBar()->value() + deltaY); -} +//} void MainWindow::updateWindowTitle() { @@ -670,7 +662,7 @@ void MainWindow::updateWindowTitle() //windowTitleFormat.replace("imageName", fileUtils->getFileName()); //windowTitleFormat.replace("pos", QString("%1").arg(fileUtils->getCurrentPosition()+1)); //windowTitleFormat.replace("amount", QString("%1").arg(fileUtils->getFilesAmount())); - windowTitleFormat.replace("zoomLevel", QString("%1%").arg(formimage->getZoomValue())); +// windowTitleFormat.replace("zoomLevel", QString("%1%").arg(formimage->getZoomValue())); this->setWindowTitle(windowTitleFormat); } diff --git a/core/mainwindow.h b/core/mainwindow.h index f8e3f7b..1871057 100644 --- a/core/mainwindow.h +++ b/core/mainwindow.h @@ -21,7 +21,7 @@ #include "mapcyl.h" #include "globe.h" #include "formimage.h" -#include "imagescrollarea.h" +//#include "imagescrollarea.h" #include "segmentimage.h" #include "segmentlistgeostationary.h" @@ -31,7 +31,6 @@ namespace Ui { class MainWindow; } -class InfraScales; class MainWindow : public QMainWindow { @@ -43,6 +42,7 @@ class MainWindow : public QMainWindow SatelliteList *satlist; AVHRRSatellite *seglist; //void LoadXMLfromDatahub(); + void setMainWindowTitle(QString title) { setWindowTitle(title); }; ~MainWindow(); @@ -57,7 +57,7 @@ class MainWindow : public QMainWindow FormEphem *formephem; FormMapCyl *formglobecyl; FormImage *formimage; - ImageScrollArea *imagescrollarea; +// ImageScrollArea *imagescrollarea; QDockWidget *dockwidget; FormToolbox *formtoolbox; FormGeostationary *formgeostationary; @@ -67,8 +67,6 @@ class MainWindow : public QMainWindow MapFieldCyl *mapcyl; Globe *globe; - FormInfraScales *forminfrascales; - QTimer *timer; QLabel *timeLabel; QLabel *formulaLabel; @@ -95,10 +93,9 @@ private slots: void on_actionMeteosat_triggered(); void on_actionNormalSize_triggered(); void on_actionFitWindow_triggered(); - void on_actionFitWindowWidth_triggered(); void on_actionZoomin_triggered(); void on_actionZoomout_triggered(); - void moveImage(QPoint, QPoint); + //void moveImage(QPoint, QPoint); void slotSwitchStackedWindow(int); void slotPreferencesFinished(int result); @@ -107,6 +104,7 @@ private slots: // void OLCIfileDownloaded(QString instrumentshortname); // void SLSTRfileDownloaded(QString instrumentshortname); // void XMLfileDownloaded(); + void slotMainWindowTitleChanged(QString title) { setWindowTitle(title); } public slots: diff --git a/core/mainwindow.ui b/core/mainwindow.ui index 66f3452..d0ab029 100644 --- a/core/mainwindow.ui +++ b/core/mainwindow.ui @@ -53,7 +53,6 @@ - @@ -252,18 +251,6 @@ Zoom out - - - - :/icons/zoom-fit-best-width.png:/icons/zoom-fit-best-width.png - - - Fit Window Width - - - Fit Window Width - - diff --git a/core/nav_util.cpp b/core/nav_util.cpp index 082af54..535b7cb 100644 --- a/core/nav_util.cpp +++ b/core/nav_util.cpp @@ -58,21 +58,26 @@ int snu_line_column_to_lat_lon(unsigned int line, unsigned int column, float *la cos_y2 = cos_y * cos_y; sin_y2 = sin_y * sin_y; +// s_d = pow(42164. * cos_x * cos_y, 2) - +// (cos_y2 + 1.006803 * sin_y2) * 1737121856.; + s_d = pow(42164. * cos_x * cos_y, 2) - - (cos_y2 + 1.006803 * sin_y2) * 1737121856.; + (cos_y2 + 1.006739501 * sin_y2) * 1737122264.; if (s_d < 0.) return -1; s_d = sqrt(s_d); - s_n = (42164. * cos_x * cos_y - s_d) / (cos_y2 + 1.006803 * sin_y2); +// s_n = (42164. * cos_x * cos_y - s_d) / (cos_y2 + 1.006803 * sin_y2); + s_n = (42164. * cos_x * cos_y - s_d) / (cos_y2 + 1.006739501 * sin_y2); s_1 = 42164. - s_n * cos_x * cos_y; s_2 = s_n * sin_x * cos_y; s_3 = -s_n * sin_y; s_xy = sqrt(s_1 * s_1 + s_2 * s_2); - *lat = atan(1.006803 * s_3 / s_xy); +// *lat = atan(1.006803 * s_3 / s_xy); + *lat = atan(1.006739501 * s_3 / s_xy); *lon = atan(s_2 / s_1) + lon0*D2R; *lat *= R2D; diff --git a/core/options.cpp b/core/options.cpp index 343ea60..661fe24 100644 --- a/core/options.cpp +++ b/core/options.cpp @@ -1562,9 +1562,14 @@ void Options::CreateGeoSatelliteIni() //MTG-I1 //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N__T_0070_0001.nc //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N__T_0070_0041.nc - //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N_JLS_T_0070_0001 + + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920113515_GTT_DEV_20170920113008_20170920113015_N_JLS_T_0070_0001.nc //W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-TRAIL---NC4E_C_EUMT_20170920114422_GTT_DEV_20170920113008_20170920113922_N_JLS_T_0070_0041.nc geosatellites[11].fullname = "Meteosat Third Gen"; @@ -1576,13 +1581,13 @@ void Options::CreateGeoSatelliteIni() geosatellites[11].rss = false; geosatellites[11].searchstring = "W_XX"; geosatellites[11].indexsearchstring = 0; - geosatellites[11].filepattern = "W_XX-EUMETSAT-Darmstadt*"; - geosatellites[11].imagewidth = 5500; - geosatellites[11].imageheight = 5500; - geosatellites[11].imagewidthhrv0 = 0; - geosatellites[11].imageheighthrv0 = 0; - geosatellites[11].imagewidthhrv1 = 0; - geosatellites[11].imageheighthrv1 = 0; + geosatellites[11].filepattern = "W_XX-EUMETSAT*"; + geosatellites[11].imagewidth = 5568; + geosatellites[11].imageheight = 5568; + geosatellites[11].imagewidthhrv0 = 11136; + geosatellites[11].imageheighthrv0 = 11136; + geosatellites[11].imagewidthhrv1 = 22272; + geosatellites[11].imageheighthrv1 = 22272; geosatellites[11].indexspectrum = 0; geosatellites[11].indexfilenbr = 0; @@ -1613,18 +1618,20 @@ void Options::CreateGeoSatelliteIni() geosatellites[11].prologfile = false; geosatellites[11].epilogfile = false; - geosatellites[11].coff = 2750; - geosatellites[11].loff = 2750; - geosatellites[11].cfac = 1172050000.; - geosatellites[11].lfac = 1172050000.; + geosatellites[11].coff = 5568; + geosatellites[11].loff = 5568; + geosatellites[11].cfac = 1172050000. * 2; + geosatellites[11].lfac = 1172050000. * 2; geosatellites[11].coffhrv = 0; geosatellites[11].loffhrv = 0; geosatellites[11].cfachrv = 0.; geosatellites[11].lfachrv = 0.; - geosatellites[11].spectrumlist << "VIS 0.4" << "VIS 0.5" << "VIS 0.6" << "VIS 0.8" << "VIS 0.9" << "NIR 1.3" << "NIR 1.6" << "NIR 2.2" << "IR 3.8" << "WV 6.3" << "WV 7.3" << "IR 8.7" << "IR 9.7" << "IR 10.5" << "IR 12.3" << "IR 13.3"; - geosatellites[11].spectrumvalueslist << "0.44" << "0.51" << "0.64" << "0.86" << "0.91" << "1.38" << "1.61" << "2.25" << "3.80" << "6.30" << "7.35" << "8.70" << "9.66" << "10.5" << "12.3" << "13.3"; + geosatellites[11].spectrumlist << "vis_04" << "vis_05" << "vis_06" << "vis_08" << "vis_09" << "nir_13" << "nir_16" + << "nir_22" << "ir_38" << "wv_63" << "wv_73" << "ir_87" << "ir_97" << "ir_105" << "ir_123" << "ir_133"; + geosatellites[11].spectrumvalueslist << "0.44" << "0.51" << "0.64" << "0.86" << "0.91" << "1.38" << "1.61" + << "2.25" << "3.80" << "6.30" << "7.35" << "8.70" << "9.66" << "10.5" << "12.3" << "13.3"; settingsgeo.beginWriteArray("geos"); for (int i = 0; i < this->geosatellites.size(); ++i) { diff --git a/core/options.h b/core/options.h index bced252..95a7312 100644 --- a/core/options.h +++ b/core/options.h @@ -83,8 +83,6 @@ struct GeoSatellites qlonglong loffhrv; double cfachrv; double lfachrv; - - }; class Options diff --git a/core/pixgeoconversion.cpp b/core/pixgeoconversion.cpp index b9188ec..319f667 100644 --- a/core/pixgeoconversion.cpp +++ b/core/pixgeoconversion.cpp @@ -492,7 +492,7 @@ int pixgeoConversion::pixcoord2geocoord(double sub_lon_deg, int column, int row, // qDebug() << "column = " << column << " sa = " << sa; /* produce error values */ - if ( sa <= 1000000.0 ) { + if ( sa <= 400000.0 ) { *latitude = -999.999; *longitude = -999.999; return (-1); diff --git a/core/poi.cpp b/core/poi.cpp index 280f7c6..e70e549 100644 --- a/core/poi.cpp +++ b/core/poi.cpp @@ -385,39 +385,39 @@ void Poi::Initialize() strlInverseGeo15.clear(); strlInverseGeo16.clear(); - strlComboGeo1 << "3" << "3" << "3" << "3" << "3" << "3" << "3" << "3" << "3" << "3" << "0"; - strlComboGeo2 << "2" << "2" << "2" << "2" << "2" << "2" << "2" << "2" << "1" << "1" << "3"; - strlComboGeo3 << "1" << "1" << "1" << "1" << "1" << "1" << "1" << "1" << "2" << "2" << "2"; - strlComboGeo4 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo5 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "1" << "0" << "1"; - strlComboGeo6 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo7 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo8 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo9 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo10 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo11 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo12 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo13 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo14 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo15 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlComboGeo16 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - - strlInverseGeo1 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo2 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo3 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo4 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo5 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo6 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo7 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo8 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo9 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo10 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo11 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo12 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo13 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo14 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo15 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; - strlInverseGeo16 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo1 << "3" << "3" << "3" << "3" << "3" << "3" << "3" << "3" << "3" << "3" << "0" << "3"; + strlComboGeo2 << "2" << "2" << "2" << "2" << "2" << "2" << "2" << "2" << "1" << "1" << "3" << "2"; + strlComboGeo3 << "1" << "1" << "1" << "1" << "1" << "1" << "1" << "1" << "2" << "2" << "2" << "1"; + strlComboGeo4 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo5 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "1" << "0" << "1" << "0"; + strlComboGeo6 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo7 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo8 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo9 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo10 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo11 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo12 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo13 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo14 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo15 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlComboGeo16 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + + strlInverseGeo1 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo2 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo3 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo4 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo5 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo6 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo7 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo8 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo9 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo10 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo11 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo12 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo13 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo14 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo15 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; + strlInverseGeo16 << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; } else diff --git a/core/segmentimage.cpp b/core/segmentimage.cpp index aeefd43..a2296c2 100644 --- a/core/segmentimage.cpp +++ b/core/segmentimage.cpp @@ -17,7 +17,7 @@ SegmentImage::SegmentImage() ptrimagecomp_col = new QImage(); ptrexpand_col = new QImage(); - ptrimageGeostationary = new QImage(3712, 3712, QImage::Format_ARGB32); + ptrimageGeostationary = new QImage(); //3712, 3712, QImage::Format_ARGB32); ptrimageGeostationary->fill(Qt::black); ptrimageProjection = new QImage(); ptrimageProjectionCopy = new QImage(); @@ -43,6 +43,14 @@ SegmentImage::SegmentImage() ptrBlue[i] = NULL; } + for( int i = 0; i < 3; i++) + { + for( int j = 0; j < 40; j++) + { + ptrMTG[i][j] = NULL; + } + } + for( int i = 0; i < 24; i++) { ptrHRV[i] = NULL; @@ -75,6 +83,7 @@ SegmentImage::SegmentImage() // << "Night Microphysics RGB"; //} + void SegmentImage::SetupRGBrecipes() { //0 "Airmass RGB" diff --git a/core/segmentimage.h b/core/segmentimage.h index 77c1f8c..e5dbec0 100644 --- a/core/segmentimage.h +++ b/core/segmentimage.h @@ -109,6 +109,7 @@ class SegmentImage QImage *ptrimageMERSI; eSegmentType olcitype; + QImage *ptrimagebitmap; QImage *ptrimageGeostationary; QImage *ptrimageProjection; @@ -160,11 +161,33 @@ class SegmentImage int maxRadianceIndex[5]; int minRadianceIndexNormalized[3]; int maxRadianceIndexNormalized[3]; + int minRadianceIndexMTG[3][40]; + int maxRadianceIndexMTG[3][40]; + quint16 *ptrRed[10]; quint16 *ptrGreen[10]; quint16 *ptrBlue[10]; + quint16 *ptrMTG[3][40]; + int mtg_start_position_row[3][40]; + int mtg_end_position_row[3][40]; + int mtg_start_position_column[3][40]; + int mtg_end_position_column[3][40]; + + int mtg_nbr_of_rows[3][40]; + int mtg_nbr_of_columns[3][40]; + + quint16 mtg_stat_min[3][40]; + quint16 mtg_stat_max[3][40]; + long mtg_active_pixels[3][40]; + + quint16 mtg_total_number_of_rows[3]; + quint16 mtg_total_number_of_columns[3]; + + quint16 mtg_histogram[3][40][4096]; + + quint16 *ptrHRV[24]; qint8 *ptrDQF[3]; void CalcSatAngles(); diff --git a/core/segmentlist.cpp b/core/segmentlist.cpp index a9e8413..4f01c12 100644 --- a/core/segmentlist.cpp +++ b/core/segmentlist.cpp @@ -652,6 +652,8 @@ bool SegmentList::ComposeAVHRRImage() bool SegmentList::ComposeAVHRRImageInThread() { + qDebug() << "SegmentList::ComposeAVHRRImageInThread()"; + QApplication::setOverrideCursor( Qt::WaitCursor ); //restore in finished() emit progressCounter(0); @@ -941,6 +943,8 @@ void SegmentList::ComposeGVProjection(int inputchannel) { qDebug() << "SegmentList::ComposeGVProjection()"; + int segsel = NbrOfSegmentsSelected(); + QList::iterator segit = segsselected.begin(); while ( segit != segsselected.end() ) { @@ -948,6 +952,7 @@ void SegmentList::ComposeGVProjection(int inputchannel) emit segmentprojectionfinished(false); ++segit; } + emit progressCounter(100); } @@ -962,6 +967,7 @@ void SegmentList::ComposeLCCProjection(int inputchannel) emit segmentprojectionfinished(false); ++segit; } + emit progressCounter(100); } @@ -975,6 +981,7 @@ void SegmentList::ComposeSGProjection(int inputchannel) emit segmentprojectionfinished(false); ++segit; } + emit progressCounter(100); } @@ -988,6 +995,7 @@ void SegmentList::ComposeOMProjection(int inputchannel) emit segmentprojectionfinished(false); ++segit; } + emit progressCounter(100); } diff --git a/core/segmentlistgeostationary.cpp b/core/segmentlistgeostationary.cpp index 8363e97..d74a5cb 100644 --- a/core/segmentlistgeostationary.cpp +++ b/core/segmentlistgeostationary.cpp @@ -32,17 +32,19 @@ #include "MSG_HRIT.h" #include +#define ERR(e) {printf("Error: %s\n", nc_strerror(e));} + #define BYTE_SWAP4(x) \ - (((x & 0xFF000000) >> 24) | \ - ((x & 0x00FF0000) >> 8) | \ - ((x & 0x0000FF00) << 8) | \ - ((x & 0x000000FF) << 24)) +(((x & 0xFF000000) >> 24) | \ + ((x & 0x00FF0000) >> 8) | \ + ((x & 0x0000FF00) << 8) | \ + ((x & 0x000000FF) << 24)) #define BYTE_SWAP2(x) \ (((x & 0xFF00) >> 8) | \ ((x & 0x00FF) << 8)) -quint16 _htons(quint16 x) { + quint16 _htons(quint16 x) { if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { return x; } @@ -115,6 +117,11 @@ void SegmentListGeostationary::doComposeGeostationarynetCDFInThread(SegmentListG sm->ComposeSegmentImagenetCDFInThread(); //strlist, spectrumvector, inversevector, histogrammethod); } +void SegmentListGeostationary::doComposeGeostationarynetCDFMTGInThread(SegmentListGeostationary *sm) //, QStringList strlist, QVector spectrumvector, QVector inversevector, int histogrammethod) +{ + sm->ComposeSegmentImagenetCDFMTGInThreadConcurrent(); +} + void SegmentListGeostationary::doComposeGeoRGBRecipe(SegmentListGeostationary *sm, int recipe) { sm->ComposeGeoRGBRecipeInThread(recipe); @@ -151,32 +158,33 @@ SegmentListGeostationary::SegmentListGeostationary(QObject *parent, int geoindex eGeoSatellite SegmentListGeostationary::getGeoSatellite() { - if(str_GeoSatellite == "MET_11") - return eGeoSatellite::MET_11; - if(str_GeoSatellite == "MET_10") - return eGeoSatellite::MET_10; - else if(str_GeoSatellite == "MET_9") - return eGeoSatellite::MET_9; - else if(str_GeoSatellite == "MET_8") - return eGeoSatellite::MET_8; - else if(str_GeoSatellite == "GOMS3") - return eGeoSatellite::GOMS3; - else if(str_GeoSatellite == "FY2H") - return eGeoSatellite::FY2H; - else if(str_GeoSatellite == "FY2G") - return eGeoSatellite::FY2G; - else if(str_GeoSatellite == "GOES_18") - return eGeoSatellite::GOES_18; - else if(str_GeoSatellite == "GOES_16") - return eGeoSatellite::GOES_16; - else if(str_GeoSatellite == "GOES_17") - return eGeoSatellite::GOES_17; - else if(str_GeoSatellite == "H8") - return eGeoSatellite::H8; - else if(str_GeoSatellite == "MTG_I1") - return eGeoSatellite::MTG_I1; - else - return eGeoSatellite::NOGEO; + return m_GeoSatellite; + // if(str_GeoSatellite == "MET_11") + // return eGeoSatellite::MET_11; + // if(str_GeoSatellite == "MET_10") + // return eGeoSatellite::MET_10; + // else if(str_GeoSatellite == "MET_9") + // return eGeoSatellite::MET_9; + // else if(str_GeoSatellite == "MET_8") + // return eGeoSatellite::MET_8; + // else if(str_GeoSatellite == "GOMS3") + // return eGeoSatellite::GOMS3; + // else if(str_GeoSatellite == "FY2H") + // return eGeoSatellite::FY2H; + // else if(str_GeoSatellite == "FY2G") + // return eGeoSatellite::FY2G; + // else if(str_GeoSatellite == "GOES_18") + // return eGeoSatellite::GOES_18; + // else if(str_GeoSatellite == "GOES_16") + // return eGeoSatellite::GOES_16; + // else if(str_GeoSatellite == "GOES_17") + // return eGeoSatellite::GOES_17; + // else if(str_GeoSatellite == "H8") + // return eGeoSatellite::H8; + // else if(str_GeoSatellite == "MTG_I1") + // return eGeoSatellite::MTG_I1; + // else + // return eGeoSatellite::NOGEO; } QString SegmentListGeostationary::getSeviribandfromChannel(int channel) @@ -269,6 +277,10 @@ void SegmentListGeostationary::setGeoSatellite(int geoindex, QString strgeo) { this->m_GeoSatellite = eGeoSatellite::H8; } + else if(strgeo == "MTG-I1") + { + this->m_GeoSatellite = eGeoSatellite::MTG_I1; + } } void SegmentListGeostationary::ResetSegments() @@ -293,6 +305,8 @@ void SegmentListGeostationary::ResetSegments() void SegmentListGeostationary::getFilenameParameters(QFileInfo fileinfo, QString &filespectrum, QString &filedate, int &filesequence) { + qDebug() << "SegmentListGeostationary::getFilenameParameters"; + int index = opts.geosatellites.at(this->geoindex).indexspectrumhrv; int length = opts.geosatellites.at(this->geoindex).spectrumhrv.length(); QString spectrum = fileinfo.fileName().mid(index, length); @@ -428,6 +442,18 @@ bool SegmentListGeostationary::ComposeImagenetCDFInThread(QStringList strlist, Q return true; } +bool SegmentListGeostationary::ComposeImagenetCDFMTGInThread(QStringList strlist, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor) +{ + + qDebug() << QString("SegmentListGeostationary::ComposeImagenetCDFMTGInThread spectrumvector = %2 %3 %4").arg(spectrumvector.at(0)).arg(spectrumvector.at(1)).arg(spectrumvector.at(2)); + + + QApplication::setOverrideCursor(( Qt::WaitCursor)); + setThreadParameters(strlist, spectrumvector, inversevector, histogrammethod, pseudocolor); + QtConcurrent::run(doComposeGeostationarynetCDFMTGInThread, this); + return true; +} + /* bool SegmentListGeostationary::ComposeImageHDFSerial(QFileInfo fileinfo, QVector spectrumvector, QVector inversevector) { @@ -476,8 +502,8 @@ void SegmentListGeostationary::InsertPresent( QVector spectrumvector, Q { qDebug() << QString("InsertPresent ; spectrum %1 %2 %3 filespectrum %4 fileseq %5").arg(spectrumvector[0]).arg(spectrumvector[1]).arg(spectrumvector[2]).arg(filespectrum).arg(filesequence); if(m_GeoSatellite == eGeoSatellite::MET_11 || m_GeoSatellite == eGeoSatellite::MET_10 || m_GeoSatellite == eGeoSatellite::MET_9 || - m_GeoSatellite == eGeoSatellite::MET_8 || m_GeoSatellite == eGeoSatellite::H8 || m_GeoSatellite == eGeoSatellite::GOES_16 || - m_GeoSatellite == eGeoSatellite::GOES_17 || m_GeoSatellite == eGeoSatellite::GOES_18 || m_GeoSatellite == eGeoSatellite::GOMS3) + m_GeoSatellite == eGeoSatellite::MET_8 || m_GeoSatellite == eGeoSatellite::H8 || m_GeoSatellite == eGeoSatellite::GOES_16 || + m_GeoSatellite == eGeoSatellite::GOES_17 || m_GeoSatellite == eGeoSatellite::GOES_18 || m_GeoSatellite == eGeoSatellite::GOMS3) { if(spectrumvector.at(0) == filespectrum) { @@ -525,7 +551,7 @@ void SegmentListGeostationary::ComposeSegmentImageXRIT( QString filepath, int ch this->getFilenameParameters(fileinfo, filespectrum, filedate, filesequence); qDebug() << QString("-------> SegmentListGeostationary::ComposeSegmentImageXRIT() filespectrum = %1 filedate = %2 filesequence = %3 filepath = %4") - .arg(filespectrum).arg(filedate).arg(filesequence).arg(filepath); + .arg(filespectrum).arg(filedate).arg(filesequence).arg(filepath); //QByteArray ba = filepath.toLatin1(); //const char *c_segname = ba.data(); @@ -534,7 +560,7 @@ void SegmentListGeostationary::ComposeSegmentImageXRIT( QString filepath, int ch if (hrit.fail()) { std::cerr << "Cannot open input hrit file " - << filepath.toStdString() << std::endl; + << filepath.toStdString() << std::endl; return; } @@ -546,8 +572,8 @@ void SegmentListGeostationary::ComposeSegmentImageXRIT( QString filepath, int ch if (header->segment_id->data_field_format == MSG_NO_FORMAT) { - qDebug() << "Product dumped in binary format. " << (int)header->segment_id->data_field_format; - //return; + qDebug() << "Product dumped in binary format. " << (int)header->segment_id->data_field_format; + //return; } int planned_end_segment = header->segment_id->planned_end_segment_sequence_number; @@ -595,6 +621,7 @@ void SegmentListGeostationary::ComposeSegmentImageXRIT( QString filepath, int ch } } + for(int line = 0; line < nlin; line++) { //qDebug() << QString("filesequence = %1 ; nlin * totalsegs - 1 - startLine[filesequence] - line = %2").arg(filesequence).arg(nlin * totalsegs - 1 - startLine[filesequence] - line); @@ -602,7 +629,6 @@ void SegmentListGeostationary::ComposeSegmentImageXRIT( QString filepath, int ch for (int pixelx = 0 ; pixelx < npix; pixelx++) { c = *(pixels + line * npix + pixelx); - if (filespectrum == "HRV") { *(imageptrs->ptrHRV[filesequence] + line * npix + pixelx) = c; @@ -639,14 +665,14 @@ void SegmentListGeostationary::ComposeSegmentImageXRIT( QString filepath, int ch { qDebug() << "-----> HRV | HRV Color and allHRVColorSegmentsReceived"; this->ComposeHRV(); - emit signalcomposefinished(kindofimage); + emit signalcomposefinished(kindofimage, geoindex); } if((kindofimage == "VIS_IR" || kindofimage == "VIS_IR Color") && allVIS_IRSegmentsReceived()) { qDebug() << "-----> VIS_IR Color | VIS_IR | HRV and allSegmentsReceived"; this->ComposeVISIR(); - emit signalcomposefinished(kindofimage); + emit signalcomposefinished(kindofimage, geoindex); } delete header; @@ -657,8 +683,8 @@ void SegmentListGeostationary::ComposeSegmentImageXRIT( QString filepath, int ch void SegmentListGeostationary::ComposeSegmentImageXRITHimawari( QString filepath, int channelindex, QVector spectrumvector, QVector inversevector ) { -//IMG_DK01B04_201510090000_001.bz2 -//012345678901234567890123456789 + //IMG_DK01B04_201510090000_001.bz2 + //012345678901234567890123456789 MSG_header *header; MSG_data *msgdat; @@ -713,7 +739,7 @@ void SegmentListGeostationary::ComposeSegmentImageXRITHimawari( QString filepath if (hrit.fail()) { std::cerr << "Cannot open input Himawari file " - << filepath.toStdString() << std::endl; + << filepath.toStdString() << std::endl; return; } @@ -723,8 +749,8 @@ void SegmentListGeostationary::ComposeSegmentImageXRITHimawari( QString filepath if (header->segment_id->data_field_format == MSG_NO_FORMAT) { - qDebug() << "Product dumped in binary format."; - return; + qDebug() << "Product dumped in binary format."; + return; } int planned_end_segment = 10; @@ -798,7 +824,7 @@ void SegmentListGeostationary::ComposeSegmentImageXRITHimawari( QString filepath if(allVIS_IRSegmentsReceived()) { ComposeVISIRHimawari(); - emit signalcomposefinished(kindofimage); + emit signalcomposefinished(kindofimage, geoindex); } delete header; @@ -1272,18 +1298,18 @@ void SegmentListGeostationary::ComposeSegmentImageHDFInThread(QStringList fileli else if(kindofimage == "VIS_IR Color") { if((h5_status[0] = H5Dread (nomchannel_id[0], H5T_NATIVE_INT16_g, H5S_ALL, H5S_ALL, - H5P_DEFAULT, imageptrs->ptrRed[0])) < 0) + H5P_DEFAULT, imageptrs->ptrRed[0])) < 0) qDebug() << "Unable to read NOMChannel" << filelist.at(0).mid(40, 3) << " dataset"; if((h5_status[1] = H5Dread (nomchannel_id[1], H5T_NATIVE_INT16_g, H5S_ALL, H5S_ALL, - H5P_DEFAULT, imageptrs->ptrGreen[0])) < 0) + H5P_DEFAULT, imageptrs->ptrGreen[0])) < 0) qDebug() << "Unable to read NOMChannel" << filelist.at(1).mid(40, 3) << " dataset"; if((h5_status[2] = H5Dread (nomchannel_id[2], H5T_NATIVE_INT16_g, H5S_ALL, H5S_ALL, - H5P_DEFAULT, imageptrs->ptrBlue[0])) < 0) + H5P_DEFAULT, imageptrs->ptrBlue[0])) < 0) qDebug() << "Unable to read NOMChannel" << filelist.at(2).mid(40, 3) << " dataset"; } else if(kindofimage == "HRV") { if((h5_status[0] = H5Dread (nomchannel_id[0], H5T_NATIVE_INT16_g, H5S_ALL, H5S_ALL, - H5P_DEFAULT, imageptrs->ptrHRV[0])) < 0) + H5P_DEFAULT, imageptrs->ptrHRV[0])) < 0) qDebug() << "Unable to read NOMChannelVIS1KM dataset"; } @@ -1445,7 +1471,7 @@ void SegmentListGeostationary::ComposeSegmentImageHDFInThread(QStringList fileli H5Fclose(h5_file_id[j]); } - emit signalcomposefinished(kindofimage); + emit signalcomposefinished(kindofimage, geoindex); } @@ -1494,7 +1520,7 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis arrayncfile[j] = ncfile[j].toUtf8(); pncfile[j] = arrayncfile[j].constData(); - qDebug() << "Starting netCDF file " + ncfile[j]; + //qDebug() << "Starting netCDF file " + ncfile[j]; retval = nc_open(pncfile[j], NC_NOWRITE, &ncfileid[j]); if(retval != NC_NOERR) qDebug() << "error opening netCDF file " << this->segmentfilelist.at(j); @@ -1550,7 +1576,7 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis { CalculateMinMax(j, xdim, ydim, imageptrs->ptrRed[0], fillvalue[0]); CalculateLUTGeo(j); - normalizeMinMaxGOES16(xdim, ydim, imageptrs->ptrRed[0], stat_min[0], stat_max[0], fillvalue[0], 1023); + normalizeMinMax(xdim, ydim, imageptrs->ptrRed[0], stat_min[0], stat_max[0], fillvalue[0], 1023); } } else if(j==1) { @@ -1564,7 +1590,7 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis { CalculateMinMax(j, xdim, ydim, imageptrs->ptrGreen[0], fillvalue[1]); CalculateLUTGeo(j); - normalizeMinMaxGOES16(xdim, ydim, imageptrs->ptrGreen[0], stat_min[1], stat_max[1], fillvalue[1], 1023); + normalizeMinMax(xdim, ydim, imageptrs->ptrGreen[0], stat_min[1], stat_max[1], fillvalue[1], 1023); } } else if(j == 2) { @@ -1578,7 +1604,7 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis { CalculateMinMax(j, xdim, ydim, imageptrs->ptrBlue[0], fillvalue[2]); CalculateLUTGeo(j); - normalizeMinMaxGOES16(xdim, ydim, imageptrs->ptrBlue[0], stat_min[2], stat_max[2], fillvalue[2], 1023); + normalizeMinMax(xdim, ydim, imageptrs->ptrBlue[0], stat_min[2], stat_max[2], fillvalue[2], 1023); } } @@ -1589,36 +1615,36 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis cnt_dqf3 = 0; -// retval = nc_inq_varid(ncfileid[j], "DQF", &varid); -// if (retval != NC_NOERR) qDebug() << "error reading DQF id"; + // retval = nc_inq_varid(ncfileid[j], "DQF", &varid); + // if (retval != NC_NOERR) qDebug() << "error reading DQF id"; -// imageptrs->ptrDQF[j] = new qint8[xdim * ydim]; -// memset(imageptrs->ptrDQF[j], 0, xdim * ydim * sizeof(qint8)); -// retval = nc_get_var(ncfileid[j], varid, imageptrs->ptrDQF[0]); -// if (retval != NC_NOERR) -// qDebug() << "error reading DQF values"; -// else -// { -// qDebug() << "No errors reading DQF values"; -// for(int i = 0; i < xdim * ydim; i++) -// { -// if( imageptrs->ptrDQF[j][i] == 0) -// cnt_dqf0++; -// else if( imageptrs->ptrDQF[j][i] == 1) -// cnt_dqf1++; -// else if( imageptrs->ptrDQF[j][i] == 2) -// cnt_dqf2++; -// else if( imageptrs->ptrDQF[j][i] == 3) -// cnt_dqf3++; + // imageptrs->ptrDQF[j] = new qint8[xdim * ydim]; + // memset(imageptrs->ptrDQF[j], 0, xdim * ydim * sizeof(qint8)); + // retval = nc_get_var(ncfileid[j], varid, imageptrs->ptrDQF[0]); + // if (retval != NC_NOERR) + // qDebug() << "error reading DQF values"; + // else + // { + // qDebug() << "No errors reading DQF values"; + // for(int i = 0; i < xdim * ydim; i++) + // { + // if( imageptrs->ptrDQF[j][i] == 0) + // cnt_dqf0++; + // else if( imageptrs->ptrDQF[j][i] == 1) + // cnt_dqf1++; + // else if( imageptrs->ptrDQF[j][i] == 2) + // cnt_dqf2++; + // else if( imageptrs->ptrDQF[j][i] == 3) + // cnt_dqf3++; -// } -// qDebug() << QString("# DQF 0 = %1").arg(cnt_dqf0); -// qDebug() << QString("# DQF 1 = %1").arg(cnt_dqf1); -// qDebug() << QString("# DQF 2 = %1").arg(cnt_dqf2); -// qDebug() << QString("# DQF 3 = %1").arg(cnt_dqf3); + // } + // qDebug() << QString("# DQF 0 = %1").arg(cnt_dqf0); + // qDebug() << QString("# DQF 1 = %1").arg(cnt_dqf1); + // qDebug() << QString("# DQF 2 = %1").arg(cnt_dqf2); + // qDebug() << QString("# DQF 3 = %1").arg(cnt_dqf3); -// } + // } @@ -1677,7 +1703,7 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis quint16 indexoutrc = 0, indexoutgc = 0, indexoutbc = 0; int r = 0, g = 0, b = 0; QRgb *row_col; -// qint8 dqfvalue[3]; + // qint8 dqfvalue[3]; imageptrs->InitializeImageGeostationary(xdim, ydim); im = imageptrs->ptrimageGeostationary; @@ -1721,9 +1747,9 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis gc = *(imageptrs->ptrGreen[0] + line * xdim + pixelx); bc = *(imageptrs->ptrBlue[0] + line * xdim + pixelx); -// dqfvalue[0] = *(imageptrs->ptrDQF[0] + line * xdim + pixelx); -// dqfvalue[1] = *(imageptrs->ptrDQF[1] + line * xdim + pixelx); -// dqfvalue[2] = *(imageptrs->ptrDQF[2] + line * xdim + pixelx); + // dqfvalue[0] = *(imageptrs->ptrDQF[0] + line * xdim + pixelx); + // dqfvalue[1] = *(imageptrs->ptrDQF[1] + line * xdim + pixelx); + // dqfvalue[2] = *(imageptrs->ptrDQF[2] + line * xdim + pixelx); if(this->histogrammethod == CMB_HISTO_NONE_95) { @@ -1737,20 +1763,27 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis else if(this->histogrammethod == CMB_HISTO_NONE_100) { if(rc != fillvalue[0]) - indexoutrc = rc; - if(gc != fillvalue[1]) - indexoutgc = gc; - if(bc != fillvalue[2]) - indexoutbc = bc; + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(rc - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); + indexoutgc = (quint16)qMin(qMax(qRound(1023.0 * (float)(gc - this->stat_min[1] ) / (float)(this->stat_max[1] - this->stat_min[1])), 0), 1023); + indexoutbc = (quint16)qMin(qMax(qRound(1023.0 * (float)(bc - this->stat_min[2] ) / (float)(this->stat_max[2] - this->stat_min[2])), 0), 1023); + } } else if(this->histogrammethod == CMB_HISTO_EQUALIZE) { - if( rc != fillvalue[0]) indexoutrc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[0][rc]), 0), 1023); - if( gc != fillvalue[1]) indexoutgc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[1][gc]), 0), 1023); - if( bc != fillvalue[2]) indexoutbc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[2][bc]), 0), 1023); + if( rc != fillvalue[0]) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(rc - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); + indexoutgc = (quint16)qMin(qMax(qRound(1023.0 * (float)(gc - this->stat_min[1] ) / (float)(this->stat_max[1] - this->stat_min[1])), 0), 1023); + indexoutbc = (quint16)qMin(qMax(qRound(1023.0 * (float)(bc - this->stat_min[2] ) / (float)(this->stat_max[2] - this->stat_min[2])), 0), 1023); + + indexoutrc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[0][rc]), 0), 1023); + indexoutgc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[1][gc]), 0), 1023); + indexoutbc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[2][bc]), 0), 1023); + } } -// if( (rc == fillvalue[0] && dqfvalue[0] == -1) || (gc == fillvalue[1] && dqfvalue[1] == -1) || (bc == fillvalue[2] && dqfvalue[2] == -1)) + // if( (rc == fillvalue[0] && dqfvalue[0] == -1) || (gc == fillvalue[1] && dqfvalue[1] == -1) || (bc == fillvalue[2] && dqfvalue[2] == -1)) if( (rc == fillvalue[0]) || (gc == fillvalue[1]) || (bc == fillvalue[2])) { r = 0; @@ -1768,7 +1801,7 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis else if(kindofimage == "VIS_IR") { rc = *(imageptrs->ptrRed[0] + line * xdim + pixelx); -// dqfvalue[0] = *(imageptrs->ptrDQF[0] + line * xdim + pixelx); + // dqfvalue[0] = *(imageptrs->ptrDQF[0] + line * xdim + pixelx); if(this->histogrammethod == CMB_HISTO_NONE_95) { @@ -1778,11 +1811,15 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis else if(this->histogrammethod == CMB_HISTO_NONE_100) { if(rc != fillvalue[0]) - indexoutrc = rc; + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(rc - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); } else if(this->histogrammethod == CMB_HISTO_EQUALIZE) { - if( rc != fillvalue[0]) indexoutrc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[0][rc]), 0), 1023); + if( rc != fillvalue[0]) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(rc - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); + indexoutrc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[0][indexoutrc]), 0), 1023); + } } if( rc == fillvalue[0] ) //&& dqfvalue[0] == -1) @@ -1818,180 +1855,1705 @@ void SegmentListGeostationary::ComposeSegmentImagenetCDFInThread() //(QStringLis emit this->progressCounter(100); - emit signalcomposefinished(kindofimage); + emit signalcomposefinished(kindofimage, geoindex); } +void SegmentListGeostationary::ComposeSegmentImagenetCDFMTGInThread() +{ + QString ncfile; + QByteArray arrayncfile; + const char* pncfile; + int ncfileid; + int grp_data; + int grp_channel; + int grp_measured; + int grp_spectrum; -void SegmentListGeostationary::CalculateLUTGeo(int colorindex) -{ - qDebug() << "start SegmentListGeostationary::CalculateLUTGeo()"; - long stats_ch[3][1024]; + int retval; + int varid; + QImage *im; + float max_radiance_value_of_valid_pixels[3]; + float mean_radiance_value_of_valid_pixels[3]; + float min_radiance_value_of_valid_pixels[3]; - for(int k = 0; k < 3; k++) + emit this->progressCounter(10); + + nc_type rh_type; + int rh_ndims; + int rh_dimids[NC_MAX_VAR_DIMS]; + int rh_natts; + size_t xdim=0, ydim=0; + float scale_factor[3]; + float add_offset[3]; + quint16 fillvalue[3]; + float nominal_satellite_subpoint_lon; + bool trailfilefound = false; + + ushort end_position_row; + ushort end_position_column; + ushort start_position_row; + ushort start_position_column; + ushort total_number_of_rows; + ushort total_number_of_columns; + + double gamma = opts.meteosatgamma; + double gammafactor = 255 / pow(255, gamma); + quint16 valgamma; + quint8 valcontrast; + + + ushort *effective_radiance_data; + int geoindex = this->getGeoSatelliteIndex(); + + QStringList spectrumlist = opts.geosatellites.at(geoindex).spectrumlist; + effective_radiance_data = NULL; + + + qDebug() << "Start SegmentListGeostationary::ComposeSegmentImagenetCDFMTGInThread() size = " << this->segmentfilelist.size(); + qDebug() << "Spectrum vector count = " << this->spectrumvector.count() << " kindofimage = " << kindofimage; + if(this->histogrammethod == CMB_HISTO_NONE_95) + qDebug() << "histgrammethod = CMB_HISTO_NONE_95"; + else if(this->histogrammethod == CMB_HISTO_NONE_100) + qDebug() << "histgrammethod = CMB_HISTO_NONE_100"; + else if(this->histogrammethod == CMB_HISTO_EQUALIZE) + qDebug() << "histgrammethod = CMB_HISTO_EQUALIZE"; + + QElapsedTimer timer; + timer.start(); + + // in include file we have the following definition : quint 16 imageptrs->ptrRed[10]; + // ptrBlue and ptrGreen are not used + for(int j = 0; j < this->segmentfilelist.size(); j++) { - for (int j = 0; j < 1024; j++) + if(this->segmentfilelist.at(j).contains("TRAIL")) { - stats_ch[k][j] = 0; + trailfilefound = true; + ncfile = this->getImagePath() + "/" + this->segmentfilelist.at(j); + arrayncfile = ncfile.toUtf8(); + pncfile = arrayncfile.constData(); + + //qDebug() << "Starting netCDF file " + ncfile; + retval = nc_open(pncfile, NC_NOWRITE, &ncfileid); + if(retval != NC_NOERR) qDebug() << "error opening netCDF file " << this->segmentfilelist.at(j); + + retval = nc_inq_ncid(ncfileid, "data", &grp_data); + if(retval != NC_NOERR) qDebug() << "error opening data group"; + + for(int i = 0; i < (kindofimage == "VIS_IR Color" ? 3 : 1); i++) + { + + QString strspectrum = "data/" + this->spectrumvector.at(i); + QByteArray ba = strspectrum.toLocal8Bit(); + const char *c_channel = ba.data(); + retval = nc_inq_grp_full_ncid(ncfileid, c_channel, &grp_spectrum); + if(retval != NC_NOERR) qDebug() << "error opening " << strspectrum; + + if ((retval = nc_inq_varid(grp_spectrum, "number_of_rows", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_spectrum, varid, &total_number_of_rows))) + ERR(retval); + if ((retval = nc_inq_varid(grp_spectrum, "number_of_columns", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_spectrum, varid, &total_number_of_columns))) + ERR(retval); + imageptrs->mtg_total_number_of_columns[i] = total_number_of_columns; + imageptrs->mtg_total_number_of_rows[i] = total_number_of_rows; + imageptrs->ptrRed[i] = new quint16[total_number_of_columns * total_number_of_rows]; + + qDebug() << QString("Total number of rows = %1, columns = %2").arg(total_number_of_rows).arg(total_number_of_columns); + } } } - quint16 pixel; - for (int line = 0; line < number_of_lines; line++) + for(int j = 0; j < this->segmentfilelist.size(); j++) { - for (int pixelx = 0; pixelx < number_of_columns; pixelx++) + if(this->segmentfilelist.at(j).contains("BODY")) { - if(colorindex == 0) - pixel = *(imageptrs->ptrRed[0] + line * number_of_columns + pixelx); - else if(colorindex == 1) - pixel = *(imageptrs->ptrGreen[0] + line * number_of_columns + pixelx); - else if(colorindex == 2) - pixel = *(imageptrs->ptrBlue[0] + line * number_of_columns + pixelx); - else - pixel = 0; + ncfile = this->getImagePath() + "/" + this->segmentfilelist.at(j); + arrayncfile = ncfile.toUtf8(); + pncfile = arrayncfile.constData(); + int ind = ncfile.indexOf(".nc"); + QString findex = ncfile.mid(ind - 4, 4); - quint16 indexout = (quint16)qMin(qMax(qRound(1023.0 * (float)(pixel - this->stat_min[colorindex])/(float)(this->stat_max[colorindex] - this->stat_min[colorindex])), 0), 1023); - stats_ch[colorindex][indexout]++; + qDebug() << "Starting netCDF file : " + findex; + // Starting netCDF file : /media/hugo/Data-Linux/MTG_examples/compressed_full_TD-360/2017/09/20/W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920120515_GTT_DEV_20170920120008_20170920120015_N_JLS_T_0073_0001.nc + retval = nc_open(pncfile, NC_NOWRITE, &ncfileid); + if(retval != NC_NOERR) qDebug() << "error opening netCDF file " << this->segmentfilelist.at(j); + + retval = nc_inq_ncid(ncfileid, "data", &grp_data); + if(retval != NC_NOERR) qDebug() << "error opening data group"; + + for(int i = 0; i < (kindofimage == "VIS_IR Color" ? 3 : 1); i++) + { + //qDebug() << "reading radiance from channel " << this->spectrumvector.at(i); + + QString strmeasured = "data/" + this->spectrumvector.at(i) + "/measured"; + QByteArray ba = strmeasured.toLocal8Bit(); + const char *c_channel = ba.data(); + retval = nc_inq_grp_full_ncid(ncfileid, c_channel, &grp_measured); + if(retval != NC_NOERR) qDebug() << "error opening " << strmeasured; + + + if ((retval = nc_inq_varid(grp_measured, "start_position_row", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_measured, varid, &start_position_row))) + ERR(retval); + if ((retval = nc_inq_varid(grp_measured, "start_position_column", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_measured, varid, &start_position_column))) + ERR(retval); + if ((retval = nc_inq_varid(grp_measured, "end_position_row", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_measured, varid, &end_position_row))) + ERR(retval); + if ((retval = nc_inq_varid(grp_measured, "end_position_column", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_measured, varid, &end_position_column))) + ERR(retval); + // if(retval == 0 && i == 0) + // { + // qDebug() << QString("start position row = %1 column = %2").arg(start_position_row).arg(start_position_column); + // qDebug() << QString("end position row = %1 column = %2").arg(end_position_row).arg(end_position_column); + // qDebug() << QString("nbr of rows = %1 column = %2").arg(end_position_row - start_position_row + 1).arg( + // end_position_column - start_position_column + 1); + // } + + imageptrs->mtg_start_position_row[i][j] = start_position_row; + imageptrs->mtg_end_position_row[i][j] = end_position_row; + + imageptrs->mtg_start_position_column[i][j] = start_position_column; + imageptrs->mtg_end_position_column[i][j] = end_position_column; + + + int nbr_rows = end_position_row - start_position_row + 1; + int nbr_col = end_position_column - start_position_column + 1; + + effective_radiance_data = new quint16[nbr_rows * nbr_col]; + + retval = nc_inq_varid(grp_measured, "effective_radiance", &varid); + if(retval != NC_NOERR) qDebug() << "error opening effective radiance from channel " << strmeasured; + retval = nc_get_att_ushort(grp_measured, varid, "_FillValue", &fillvalue[i]); + if (retval != NC_NOERR) qDebug() << "error reading _FillValue"; + imageptrs->fillvalue[i] = fillvalue[i]; + //qDebug() << QString("FillValue for color %1 = %2").arg(i).arg(fillvalue[i]); + + + retval = nc_get_var_ushort(grp_measured, varid, effective_radiance_data); + if(retval != NC_NOERR) qDebug() << "error reading effective radiance from channel " << strmeasured; + + // if(i == 0) + // qDebug() << "copy to ptrRed start_position = " << (start_position_row - 1) * nbr_col; + memcpy(imageptrs->ptrRed[i] + nbr_col * (start_position_row - 1), effective_radiance_data, sizeof(quint16)*nbr_rows*nbr_col); + + if(effective_radiance_data != NULL) + delete [] effective_radiance_data; + + } + retval = nc_close(ncfileid); + if (retval != NC_NOERR) qDebug() << "error closing file " << ncfile; } + } + //qDebug() << "===> The reading of 41 files took " << timer.restart() << "milliseconds"; - // for(int i = 0; i < 1024; i++) + quint16 pix[3]; + + // long count_no_fillvalue[3]; + + // count_no_fillvalue[0]= 0; + // count_no_fillvalue[1]= 0; + // count_no_fillvalue[2]= 0; + + // for(int line = 0; line < this->total_number_of_rows[0]; line++) // { - // qDebug() << QString("stats_ch[0][%1] = %2 ; stats_norm_ch[0][%3] = %4").arg(i).arg(stats_ch[0][i]).arg(i).arg(stats_norm_ch[0][i]); + // for (int pixelx = 0 ; pixelx < this->total_number_of_columns[0]; pixelx++) + // { + // for(int k = 0; k < 3; k++) + // { + // pix[k] = *(imageptrs->ptrRed[k] + line * this->total_number_of_columns[0] + pixelx); + // if(pix[k] != imageptrs->fillvalue[k]) + // count_no_fillvalue[k]++; + // } + // } // } + // qDebug() << "count_no_fillvalue 0 = " << count_no_fillvalue[0]; + // qDebug() << "count_no_fillvalue 1 = " << count_no_fillvalue[1]; + // qDebug() << "count_no_fillvalue 2 = " << count_no_fillvalue[2]; - // float scale = 256.0 / (NbrOfSegmentLinesSelected() * earth_views); // scale factor ,so the values in LUT are from 0 to MAX_VALUE - double newscale = (double)(1024.0 / this->active_pixels[colorindex]); + for(int j = 0; j < (kindofimage == "VIS_IR Color" ? 3 : 1); j++) + { + CalculateMinMax(j, imageptrs->mtg_total_number_of_columns[j], imageptrs->mtg_total_number_of_rows[j], imageptrs->ptrRed[j], imageptrs->fillvalue[j]); + CalculateLUTGeoMTG(j); + } - qDebug() << QString("newscale = %1 active pixels = %2").arg(newscale).arg(this->active_pixels[colorindex]); + //qDebug() << "===> MinMax + LUT took " << timer.restart() << "milliseconds"; - unsigned long long sum_ch[3]; + for(int i = 0; i < 3; i++) + { + qDebug() << QString("stat_min[%1] = %2 stat_max[%3] = %4").arg(i).arg(stat_min[i]).arg(i).arg(stat_max[i]); + } - for (int i=0; i < 3; i++) + for (int j = 0; j < 4096; j=j+20) { - sum_ch[i] = 0; + qDebug() << "LUT " << j << " " << imageptrs->lut_ch[0][j]; } + qDebug() << QString("minRadianceIndex [%1] = %2 maxRadianceIndex [%3] = %4 active_pixels = %5") + .arg(0).arg(imageptrs->minRadianceIndex[0]).arg(0).arg(imageptrs->maxRadianceIndex[0]) + .arg(this->active_pixels[0]); - bool okmin, okmax; - okmin = false; - okmax = false; + quint16 rc, gc, bc; + quint16 true_green; + quint16 indexoutrc = 0, indexoutgc = 0, indexoutbc = 0; + int r = 0, g = 0, b = 0; + QRgb *row_col; - // min/maxRadianceIndex = index of 95% ( 2.5% of 1024 = 25, 97.5% of 1024 = 997 ) - for( int i = 0; i < 1024; i++) + imageptrs->InitializeImageGeostationary(imageptrs->mtg_total_number_of_columns[0], imageptrs->mtg_total_number_of_rows[0]); + im = imageptrs->ptrimageGeostationary; + + int progcounter = 30; + emit this->progressCounter(progcounter); + + + + for(int line = 0; line < imageptrs->mtg_total_number_of_rows[0]; line++) { - sum_ch[colorindex] += stats_ch[colorindex][i]; - imageptrs->lut_ch[colorindex][i] = (quint16)((double)sum_ch[colorindex] * newscale); - imageptrs->lut_ch[colorindex][i] = ( imageptrs->lut_ch[colorindex][i] > 1023 ? 1023 : imageptrs->lut_ch[colorindex][i]); - if(imageptrs->lut_ch[colorindex][i] > 25 && okmin == false) + row_col = (QRgb*)im->scanLine(line); + + for (int pixelx = 0; pixelx < imageptrs->mtg_total_number_of_columns[0]; pixelx++) { - okmin = true; - imageptrs->minRadianceIndex[colorindex] = i; + if(kindofimage == "VIS_IR Color") + { + rc = *(imageptrs->ptrRed[0] + (imageptrs->mtg_total_number_of_rows[0] - 1 - line) * imageptrs->mtg_total_number_of_columns[0] + pixelx); + gc = *(imageptrs->ptrRed[1] + (imageptrs->mtg_total_number_of_rows[0] - 1 - line) * imageptrs->mtg_total_number_of_columns[0] + pixelx); + bc = *(imageptrs->ptrRed[2] + (imageptrs->mtg_total_number_of_rows[0] - 1 - line) * imageptrs->mtg_total_number_of_columns[0] + pixelx); + + if(this->histogrammethod == CMB_HISTO_NONE_95) + { + if(rc != imageptrs->fillvalue[0]) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(rc - imageptrs->minRadianceIndex[0] ) / (float)(imageptrs->maxRadianceIndex[0] - imageptrs->minRadianceIndex[0])), 0), 1023); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + if(gc != imageptrs->fillvalue[1]) + { + indexoutgc = (quint16)qMin(qMax(qRound(1023.0 * (float)(gc - imageptrs->minRadianceIndex[1] ) / (float)(imageptrs->maxRadianceIndex[1] - imageptrs->minRadianceIndex[1])), 0), 1023); + valgamma = pow( indexoutgc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + g = quint8(valcontrast); + if (g > 255) + g = 255; + } + if(bc != imageptrs->fillvalue[2]) + { + indexoutbc = (quint16)qMin(qMax(qRound(1023.0 * (float)(bc - imageptrs->minRadianceIndex[2] ) / (float)(imageptrs->maxRadianceIndex[2] - imageptrs->minRadianceIndex[2])), 0), 1023); + valgamma = pow( indexoutbc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + b = quint8(valcontrast); + if (b > 255) + b = 255; + } + } + else if(this->histogrammethod == CMB_HISTO_NONE_100) + { + if(rc != imageptrs->fillvalue[0]) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(rc - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + if(gc != imageptrs->fillvalue[1]) + { + indexoutgc = (quint16)qMin(qMax(qRound(1023.0 * (float)(gc - this->stat_min[1] ) / (float)(this->stat_max[1] - this->stat_min[1])), 0), 1023); + valgamma = pow( indexoutgc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + g = quint8(valcontrast); + if (g > 255) + g = 255; + } + if(bc != imageptrs->fillvalue[2]) + { + indexoutbc = (quint16)qMin(qMax(qRound(1023.0 * (float)(bc - this->stat_min[2] ) / (float)(this->stat_max[2] - this->stat_min[2])), 0), 1023); + valgamma = pow( indexoutbc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + b = quint8(valcontrast); + if (b > 255) + b = 255; + } + } + else if(this->histogrammethod == CMB_HISTO_EQUALIZE) + { + if( rc != imageptrs->fillvalue[0]) + { + indexoutrc = (quint16)qMin(qMax(qRound(4095.0 * (float)(rc - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 4095); + indexoutrc = (quint16)(qMin(qMax(qRound((float)imageptrs->lut_ch[0][indexoutrc]/4.0), 0), 1023)); + Q_ASSERT(indexoutrc < 1024); + + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + if( gc != imageptrs->fillvalue[1]) + { + indexoutgc = (quint16)qMin(qMax(qRound(4095.0 * (float)(gc - this->stat_min[1] ) / (float)(this->stat_max[1] - this->stat_min[1])), 0), 4095); + indexoutgc = (quint16)(qMin(qMax(qRound((float)imageptrs->lut_ch[1][indexoutgc]/4.0), 0), 1023)); + Q_ASSERT(indexoutgc < 1024); + + valgamma = pow( indexoutgc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + g = quint8(valcontrast); + if (g > 255) + g = 255; + } + if( bc != imageptrs->fillvalue[2]) + { + indexoutbc = (quint16)qMin(qMax(qRound(4095.0 * (float)(bc - this->stat_min[2] ) / (float)(this->stat_max[2] - this->stat_min[2])), 0), 4095); + indexoutbc = (quint16)(qMin(qMax(qRound((float)imageptrs->lut_ch[2][indexoutbc]/4.0), 0), 1023)); + Q_ASSERT(indexoutbc < 1024); + valgamma = pow( indexoutbc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + b = quint8(valcontrast); + if (b > 255) + b = 255; + } + } + + if(rc == imageptrs->fillvalue[0]) r = 0; + if(gc == imageptrs->fillvalue[1]) g = 0; + if(bc == imageptrs->fillvalue[2]) b = 0; + + r = quint16(this->inversevector[0] ? (255 - r) : r); + g = quint16(this->inversevector[1] ? (255 - g) : g); + b = quint16(this->inversevector[2] ? (255 - b) : b); + + row_col[pixelx] = qRgb(r,g,b); + + } + else if(kindofimage == "VIS_IR") + { + rc = *(imageptrs->ptrRed[0] + (imageptrs->mtg_total_number_of_rows[0] - 1 - line) * imageptrs->mtg_total_number_of_columns[0] + pixelx); + + if(this->histogrammethod == CMB_HISTO_NONE_95) + { + if(rc != imageptrs->fillvalue[0]) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(rc - imageptrs->minRadianceIndex[0] ) / (float)(imageptrs->maxRadianceIndex[0] - imageptrs->minRadianceIndex[0])), 0), 1023); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + } + else if(this->histogrammethod == CMB_HISTO_NONE_100) + { + if(rc != imageptrs->fillvalue[0]) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(rc - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); + + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + } + else if(this->histogrammethod == CMB_HISTO_EQUALIZE) + { + if( rc != imageptrs->fillvalue[0]) + { + indexoutrc = (quint16)qMin(qMax(qRound(4095.0 * (float)(rc - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 4095); + indexoutrc = (quint16)(qMin(qMax(qRound((float)imageptrs->lut_ch[0][indexoutrc]/4.0), 0), 1023)); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + } + + // if(rc == imageptrs->fillvalue[0]) + // r = 0; + // else + // r = quint16(this->inversevector[0] ? (255 - r) : r); + // g = r; + // b = r; + // row_col[pixelx] = qRgb(r,g,b); + + if(rc != imageptrs->fillvalue[0]) + { + r = quint16(this->inversevector[0] ? (255 - r) : r); + g = r; + b = r; + row_col[pixelx] = qRgb(r,g,b); + } + + + } } - if(imageptrs->lut_ch[colorindex][i] > 997 && okmax == false) + if(line % 280 == 0) { - okmax = true; - imageptrs->maxRadianceIndex[colorindex] = i; + progcounter++; + emit this->progressCounter(progcounter); } } - // for(int i = 0; i < 1024; i++) - // { - // qDebug() << QString("stats_ch[0][%1] = %2 lut_ch[0][%3] = %4").arg(i).arg(stats_ch[0][i]).arg(i).arg(imageptrs->lut_ch[0][i]); - // } + delete [] imageptrs->ptrRed[0]; + + if(kindofimage == "VIS_IR Color") + { + delete [] imageptrs->ptrRed[1]; + delete [] imageptrs->ptrRed[2]; + } + imageptrs->ptrRed[0] = NULL; + imageptrs->ptrRed[1] = NULL; + imageptrs->ptrRed[2] = NULL; + + + qDebug() << "===> The image process for NO concurrent took " << timer.elapsed() << "milliseconds"; + + emit signalcomposefinished(kindofimage, geoindex); + emit this->progressCounter(100); + + qDebug() << "****************************************"; - qDebug() << QString("minRadianceIndex [%1] = %2 maxRadianceIndex [%3] = %4").arg(colorindex).arg(imageptrs->minRadianceIndex[colorindex]).arg(colorindex).arg(imageptrs->maxRadianceIndex[colorindex]); } -void SegmentListGeostationary::CalculateLUTGeo(int colorindex, quint16 *ptr, quint16 fillvalue) +void SegmentListGeostationary::ComposeSegmentImagenetCDFMTGInThreadConcurrent() { - qDebug() << "start SegmentListGeostationary::CalculateLUTGeo() number_of_lines " << number_of_lines << " columns " << number_of_columns; - long stats_ch[3][1024]; - for(int k = 0; k < 3; k++) + QString ncfile; + QByteArray arrayncfile; + const char* pncfile; + int ncfileid; + int grp_data; + int grp_channel; + int grp_measured; + int grp_spectrum; + + int retval; + int varid; + + float max_radiance_value_of_valid_pixels[3]; + float mean_radiance_value_of_valid_pixels[3]; + float min_radiance_value_of_valid_pixels[3]; + + emit this->progressCounter(10); + + nc_type rh_type; + int rh_ndims; + int rh_dimids[NC_MAX_VAR_DIMS]; + int rh_natts; + size_t xdim=0, ydim=0; + float scale_factor[3]; + float add_offset[3]; + quint16 fillvalue[3]; + float nominal_satellite_subpoint_lon; + bool trailfilefound = false; + + ushort end_position_row; + ushort end_position_column; + ushort start_position_row; + ushort start_position_column; + ushort total_number_of_rows; + ushort total_number_of_columns; + + double gamma = opts.meteosatgamma; + double gammafactor = 255 / pow(255, gamma); + quint16 valgamma; + quint16 valcontrast; + int progcounter = 0; + + + int geoindex = this->getGeoSatelliteIndex(); + + QStringList spectrumlist = opts.geosatellites.at(geoindex).spectrumlist; + + emit this->progressCounter(0); + + qDebug() << "Start SegmentListGeostationary::ComposeSegmentImagenetCDFMTGInThreadMultiple() size = " << this->segmentfilelist.size(); + qDebug() << "Spectrum vector count = " << this->spectrumvector.count() << " kindofimage = " << kindofimage; + if(this->histogrammethod == CMB_HISTO_NONE_95) + qDebug() << "histgrammethod = CMB_HISTO_NONE_95"; + else if(this->histogrammethod == CMB_HISTO_NONE_100) + qDebug() << "histgrammethod = CMB_HISTO_NONE_100"; + else if(this->histogrammethod == CMB_HISTO_EQUALIZE) + qDebug() << "histgrammethod = CMB_HISTO_EQUALIZE"; + + QElapsedTimer timer; + timer.start(); + + // in include file we have the following definition : quint 16 imageptrs->ptrRed[10]; + // ptrBlue and ptrGreen are not used + for(int j = 0; j < this->segmentfilelist.size(); j++) { - for (int j = 0; j < 1024; j++) + if(this->segmentfilelist.at(j).contains("TRAIL")) { - stats_ch[k][j] = 0; + trailfilefound = true; + ncfile = this->getImagePath() + "/" + this->segmentfilelist.at(j); + arrayncfile = ncfile.toUtf8(); + pncfile = arrayncfile.constData(); + + //qDebug() << "Starting netCDF file " + ncfile; + retval = nc_open(pncfile, NC_NOWRITE, &ncfileid); + if(retval != NC_NOERR) qDebug() << "error opening netCDF file " << this->segmentfilelist.at(j); + + retval = nc_inq_ncid(ncfileid, "data", &grp_data); + if(retval != NC_NOERR) qDebug() << "error opening data group"; + + for(int i = 0; i < (kindofimage == "VIS_IR Color" ? 3 : 1); i++) + { + + QString strspectrum = "data/" + this->spectrumvector.at(i); + QByteArray ba = strspectrum.toLocal8Bit(); + const char *c_channel = ba.data(); + retval = nc_inq_grp_full_ncid(ncfileid, c_channel, &grp_spectrum); + if(retval != NC_NOERR) qDebug() << "error opening " << strspectrum; + + if ((retval = nc_inq_varid(grp_spectrum, "number_of_rows", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_spectrum, varid, &total_number_of_rows))) + ERR(retval); + if ((retval = nc_inq_varid(grp_spectrum, "number_of_columns", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_spectrum, varid, &total_number_of_columns))) + ERR(retval); + imageptrs->mtg_total_number_of_columns[i] = total_number_of_columns; + imageptrs->mtg_total_number_of_rows[i] = total_number_of_rows; + + qDebug() << QString("Total number of rows = %1, columns = %2").arg(total_number_of_rows).arg(total_number_of_columns); + } } } - quint16 pixel; + emit this->progressCounter(10); + + for(int j = 0; j < this->segmentfilelist.size(); j++) + { + if(this->segmentfilelist.at(j).contains("BODY")) + { + ncfile = this->getImagePath() + "/" + this->segmentfilelist.at(j); + arrayncfile = ncfile.toUtf8(); + pncfile = arrayncfile.constData(); + + //qDebug() << "Starting netCDF file " + ncfile; + // Starting netCDF file : /media/hugo/Data-Linux/MTG_examples/compressed_full_TD-360/2017/09/20/W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920120515_GTT_DEV_20170920120008_20170920120015_N_JLS_T_0073_0001.nc + int ind = ncfile.indexOf(".nc"); + int findex = ncfile.mid(ind - 4, 4).toInt(); + + retval = nc_open(pncfile, NC_NOWRITE, &ncfileid); + if(retval != NC_NOERR) qDebug() << "error opening netCDF file " << this->segmentfilelist.at(j); + + retval = nc_inq_ncid(ncfileid, "data", &grp_data); + if(retval != NC_NOERR) qDebug() << "error opening data group"; + + for(int i = 0; i < (kindofimage == "VIS_IR Color" ? 3 : 1); i++) + { + //qDebug() << "reading radiance from channel " << this->spectrumvector.at(i); + + QString strmeasured = "data/" + this->spectrumvector.at(i) + "/measured"; + QByteArray ba = strmeasured.toLocal8Bit(); + const char *c_channel = ba.data(); + retval = nc_inq_grp_full_ncid(ncfileid, c_channel, &grp_measured); + if(retval != NC_NOERR) qDebug() << "error opening " << strmeasured; + + + if ((retval = nc_inq_varid(grp_measured, "start_position_row", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_measured, varid, &start_position_row))) + ERR(retval); + if ((retval = nc_inq_varid(grp_measured, "start_position_column", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_measured, varid, &start_position_column))) + ERR(retval); + if ((retval = nc_inq_varid(grp_measured, "end_position_row", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_measured, varid, &end_position_row))) + ERR(retval); + if ((retval = nc_inq_varid(grp_measured, "end_position_column", &varid))) + ERR(retval); + if ((retval = nc_get_var_ushort(grp_measured, varid, &end_position_column))) + ERR(retval); + // if(retval == 0 && i == 0) + // { + // qDebug() << QString("start position row = %1 column = %2").arg(start_position_row).arg(start_position_column); + // qDebug() << QString("end position row = %1 column = %2").arg(end_position_row).arg(end_position_column); + // qDebug() << QString("nbr of rows = %1 column = %2").arg(end_position_row - start_position_row + 1).arg( + // end_position_column - start_position_column + 1); + // } + + imageptrs->mtg_start_position_row[i][j] = start_position_row; + imageptrs->mtg_end_position_row[i][j] = end_position_row; + + imageptrs->mtg_start_position_column[i][j] = start_position_column; + imageptrs->mtg_end_position_column[i][j] = end_position_column; + + imageptrs->mtg_nbr_of_rows[i][j] = end_position_row - start_position_row + 1; + imageptrs->mtg_nbr_of_columns[i][j] = end_position_column - start_position_column + 1; + + imageptrs->ptrMTG[i][j] = new quint16[imageptrs->mtg_nbr_of_rows[i][j] * imageptrs->mtg_nbr_of_columns[i][j]]; + + retval = nc_inq_varid(grp_measured, "effective_radiance", &varid); + if(retval != NC_NOERR) qDebug() << "error opening effective radiance from channel " << strmeasured; + retval = nc_get_att_ushort(grp_measured, varid, "_FillValue", &fillvalue[i]); + if (retval != NC_NOERR) qDebug() << "error reading _FillValue"; + imageptrs->fillvalue[i] = fillvalue[i]; + //qDebug() << QString("FillValue for color %1 = %2").arg(i).arg(fillvalue[i]); + + + retval = nc_get_var_ushort(grp_measured, varid, imageptrs->ptrMTG[i][findex - 1]); + if(retval != NC_NOERR) qDebug() << "error reading effective radiance from channel " << strmeasured << " findex = " << findex; + //qDebug() << "reading to i = " << i << " findex = " << findex - 1; + + // if(i == 0) + // qDebug() << "copy to ptrRed start_position = " << (start_position_row - 1) * nbr_col; + //memcpy(imageptrs->ptrRed[i] + nbr_col * (start_position_row - 1), effective_radiance_data, sizeof(quint16)*nbr_rows*nbr_col); + + + } + retval = nc_close(ncfileid); + if (retval != NC_NOERR) qDebug() << "error closing file " << ncfile; + } + + } + + emit this->progressCounter(30); + + QVector vec; + + for(int i = 0; i < 40; i++) + { + vec.append(i); + + } + + auto callbackMethod = std::bind(this->concurrentMinMax, this, std::placeholders::_1); + QtConcurrent::blockingMap(vec, callbackMethod); + + emit this->progressCounter(40); + + for(int i = 0; i < 3; i++) + { + stat_min[i] = 65535; + stat_max[i] = 0; + } + + for(int i = 0; i < (this->kindofimage == "VIS_IR Color" ? 3 : 1); i++) { + for (int j = 0; j < 40; j++) + { + quint16 val = imageptrs->mtg_stat_min[i][j]; + if(val != imageptrs->fillvalue[i]) + { + if(val < stat_min[i]) + stat_min[i] = val; + } + val = imageptrs->mtg_stat_max[i][j]; + if(val != 0) + { + if(val > stat_max[i]) + stat_max[i] = val; + } + } + } + + + auto callbackMethod1 = std::bind(this->concurrentLUTGeoMTG, this, std::placeholders::_1); + QtConcurrent::blockingMap(vec, callbackMethod1); + + emit this->progressCounter(50); + + for(int colorindex = 0; colorindex < (this->kindofimage == "VIS_IR Color" ? 3 : 1); colorindex++) { + this->active_pixels[colorindex] = 0; + for (int index = 0; index < 40; index++) + { + this->active_pixels[colorindex] += imageptrs->mtg_active_pixels[colorindex][index]; + } + } + + // for(int i = 0; i < (this->kindofimage == "VIS_IR Color" ? 3 : 1); i++) + // { + // qDebug() << QString("stat_min[%1] = %2 stat_max[%3] = %4 active_pixels[%5] = %6").arg(i).arg(stat_min[i]).arg(i).arg(stat_max[i]).arg(i).arg(this->active_pixels[i]); + // } + + double newscale; + long histogram[3][4096]; + + for (int i = 0; i < 4096; i++) { + for(int colorindex = 0; colorindex < (this->kindofimage == "VIS_IR Color" ? 3 : 1); colorindex++) { + histogram[colorindex][i] = 0; + } + } + + for(int colorindex = 0; colorindex < (this->kindofimage == "VIS_IR Color" ? 3 : 1); colorindex++) { + for (int index = 0; index < 40; index++) { + for (int i = 0; i < 4096; i++) { + histogram[colorindex][i] += imageptrs->mtg_histogram[colorindex][index][i]; + } + } + } + + // for (int j = 0; j < 100; j++) + // { + // qDebug() << "histogram " << j << " " << histogram[0][j]; + // } + + emit this->progressCounter(60); + + for(int colorindex = 0; colorindex < (this->kindofimage == "VIS_IR Color" ? 3 : 1); colorindex++) + { + newscale = (double)(4096.0 / (double)this->active_pixels[colorindex]); + + qDebug() << QString("newscale = %1 active pixels = %2").arg(newscale).arg(this->active_pixels[colorindex]); + + + unsigned long long sum_ch = 0; + bool okmin, okmax; + + okmin = false; + okmax = false; + + imageptrs->minRadianceIndex[colorindex] = 65535; + imageptrs->maxRadianceIndex[colorindex] = 65535; + + // min/maxRadianceIndex = index of 95% ( 2.5% of 1024 = 25, 97.5% of 1024 = 997 ) + // min/maxRadianceIndex = index of 95% ( 2.5% of 4096 = 102, 97.5% of 4096 = 3993 ) + + for( int i = 0; i < 4096; i++) + { + sum_ch += histogram[colorindex][i]; + imageptrs->lut_ch[colorindex][i] = (quint16)((double)sum_ch * newscale); + imageptrs->lut_ch[colorindex][i] = (imageptrs->lut_ch[colorindex][i] > 4095 ? 4095 : imageptrs->lut_ch[colorindex][i]); + // qDebug() << QString("stats_ch[0][%1] = %2 lut_ch[0][%3] = %4").arg(i).arg(stats_ch[0][i]).arg(i).arg(imageptrs->lut_ch[0][i]); + if(imageptrs->lut_ch[colorindex][i] > 102 && okmin == false) + { + okmin = true; + imageptrs->minRadianceIndex[colorindex] = i; + } + if(imageptrs->lut_ch[colorindex][i] > 3993 && okmax == false) + { + okmax = true; + imageptrs->maxRadianceIndex[colorindex] = i; + } + } + + // for (int j = 0; j < 1024; j++) + // { + // qDebug() << "LUT " << j << " " << imageptrs->lut_ch[colorindex][j]; + // } + + qDebug() << QString("minRadianceIndex [%1] = %2 maxRadianceIndex [%3] = %4 active_pixels = %5") + .arg(colorindex).arg(imageptrs->minRadianceIndex[colorindex]).arg(colorindex).arg(imageptrs->maxRadianceIndex[colorindex]) + .arg(this->active_pixels[colorindex]); + + } + + + imageptrs->InitializeImageGeostationary(imageptrs->mtg_total_number_of_columns[0], imageptrs->mtg_total_number_of_rows[0]); + + emit this->progressCounter(80); + + + this->SetupContrastStretch( 0, 0, 1023, 255); + + auto callbackMethod2 = std::bind(this->concurrentImageMTG, this, std::placeholders::_1); + QtConcurrent::blockingMap(vec, callbackMethod2); + + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 40; j++) + { + if(imageptrs->ptrMTG[i][j] != NULL) + { + delete [] imageptrs->ptrMTG[i][j]; + imageptrs->ptrMTG[i][j] = NULL; + } + } + } + + + qDebug() << "===> The image process for concurrent took " << timer.elapsed() << "milliseconds"; + + + emit signalcomposefinished(kindofimage, geoindex); + emit this->progressCounter(100); + + + return; +} + + +int SegmentListGeostationary::concurrentMinMax(SegmentListGeostationary *sm, const int &index) +{ + + for(int j = 0; j < (sm->kindofimage == "VIS_IR Color" ? 3 : 1); j++) + { + sm->CalculateMinMaxMTG(j, index); + } + + qDebug() << "de nbr is " << index << " " << imageptrs->mtg_stat_min[0][index] << " " << imageptrs->mtg_stat_max[0][index]; + + return(index); + +} + +int SegmentListGeostationary::concurrentLUTGeoMTG(SegmentListGeostationary *sm, const int &index) +{ + for(int j = 0; j < (sm->kindofimage == "VIS_IR Color" ? 3 : 1); j++) + { + sm->CalculateLUTGeoMTGConcurrent(j, index); + } + + return(index); +} + +int SegmentListGeostationary::concurrentImageMTG(SegmentListGeostationary *sm, const int &index) +{ + sm->CalculateImageMTGConcurrent(index); + return(index); +} + + +void SegmentListGeostationary::CalculateLUTGeo(int colorindex) +{ + qDebug() << "start SegmentListGeostationary::CalculateLUTGeo()"; + long histogram[1024]; + + for (int j = 0; j < 1024; j++) + { + histogram[j] = 0; + } + + quint16 pixel; + for (int line = 0; line < number_of_lines; line++) + { + for (int pixelx = 0; pixelx < number_of_columns; pixelx++) + { + if(colorindex == 0) + pixel = *(imageptrs->ptrRed[0] + line * number_of_columns + pixelx); + else if(colorindex == 1) + pixel = *(imageptrs->ptrGreen[0] + line * number_of_columns + pixelx); + else if(colorindex == 2) + pixel = *(imageptrs->ptrBlue[0] + line * number_of_columns + pixelx); + else + pixel = 0; + + + quint16 indexout = (quint16)qMin(qMax(qRound(1023.0 * (float)(pixel - this->stat_min[colorindex])/(float)(this->stat_max[colorindex] - this->stat_min[colorindex])), 0), 1023); + histogram[indexout]++; + } + } + + + // for(int i = 0; i < 1024; i++) + // { + // qDebug() << QString("stats_ch[0][%1] = %2 ; stats_norm_ch[0][%3] = %4").arg(i).arg(stats_ch[0][i]).arg(i).arg(stats_norm_ch[0][i]); + // } + + + // float scale = 256.0 / (NbrOfSegmentLinesSelected() * earth_views); // scale factor ,so the values in LUT are from 0 to MAX_VALUE + double newscale = (double)(1024.0 / this->active_pixels[colorindex]); + + qDebug() << QString("newscale = %1 active pixels = %2").arg(newscale).arg(this->active_pixels[colorindex]); + + unsigned long long sum_ch = 0; + + bool okmin, okmax; + + okmin = false; + okmax = false; + + // min/maxRadianceIndex = index of 95% ( 2.5% of 1024 = 25, 97.5% of 1024 = 997 ) + for( int i = 0; i < 1024; i++) + { + sum_ch += histogram[i]; + imageptrs->lut_ch[colorindex][i] = (quint16)((double)sum_ch * newscale); + imageptrs->lut_ch[colorindex][i] = ( imageptrs->lut_ch[colorindex][i] > 1023 ? 1023 : imageptrs->lut_ch[colorindex][i]); + if(imageptrs->lut_ch[colorindex][i] > 25 && okmin == false) + { + okmin = true; + imageptrs->minRadianceIndex[colorindex] = i; + } + if(imageptrs->lut_ch[colorindex][i] > 997 && okmax == false) + { + okmax = true; + imageptrs->maxRadianceIndex[colorindex] = i; + } + } + + + // for(int i = 0; i < 1024; i++) + // { + // qDebug() << QString("stats_ch[0][%1] = %2 lut_ch[0][%3] = %4").arg(i).arg(stats_ch[0][i]).arg(i).arg(imageptrs->lut_ch[0][i]); + // } + + + qDebug() << QString("minRadianceIndex [%1] = %2 maxRadianceIndex [%3] = %4").arg(colorindex).arg(imageptrs->minRadianceIndex[colorindex]).arg(colorindex).arg(imageptrs->maxRadianceIndex[colorindex]); +} + +void SegmentListGeostationary::CalculateLUTGeo(int colorindex, quint16 *ptr, quint16 fillvalue) +{ + qDebug() << "start SegmentListGeostationary::CalculateLUTGeo()"; + long histogram[1024]; + + for (int j = 0; j < 1024; j++) + { + histogram[j] = 0; + } + + quint16 pixel; for (int line = 0; line < opts.geosatellites[geoindex].imageheight; line++) { for (int pixelx = 0; pixelx < opts.geosatellites[geoindex].imagewidth; pixelx++) { pixel = ptr[line * number_of_columns + pixelx]; - if(pixel != fillvalue) + if(pixel != fillvalue && pixel > 25) { quint16 indexout = (quint16)qMin(qMax(qRound(1023.0 * (float)(pixel - this->stat_min[colorindex])/(float)(this->stat_max[colorindex] - this->stat_min[colorindex])), 0), 1023); - stats_ch[colorindex][indexout]++; + //quint16 indexout = pixel; + histogram[indexout]++; + } + } + } + + //double newscale = (double)(1024.0 / (3712*3712)); // scale factor ,so the values in LUT are from 0 to MAX_VALUE + double newscale = (double)(1024.0 / (double)this->active_pixels[colorindex]); + + qDebug() << QString("newscale = %1 active pixels = %2").arg(newscale).arg(this->active_pixels[colorindex]); + + unsigned long long sum_ch = 0; + bool okmin, okmax; + + okmin = false; + okmax = false; + + // min/maxRadianceIndex = index of 95% ( 2.5% of 1024 = 25, 97.5% of 1024 = 997 ) + for( int i = 0; i < 1024; i++) + { + sum_ch += histogram[i]; + imageptrs->lut_ch[colorindex][i] = (quint16)((double)sum_ch * newscale); + imageptrs->lut_ch[colorindex][i] = ( imageptrs->lut_ch[colorindex][i] > 1023 ? 1023 : imageptrs->lut_ch[colorindex][i]); + // qDebug() << QString("stats_ch[0][%1] = %2 lut_ch[0][%3] = %4").arg(i).arg(stats_ch[0][i]).arg(i).arg(imageptrs->lut_ch[0][i]); + if(imageptrs->lut_ch[colorindex][i] > 25 && okmin == false) + { + okmin = true; + imageptrs->minRadianceIndex[colorindex] = i; + } + if(imageptrs->lut_ch[colorindex][i] > 997 && okmax == false) + { + okmax = true; + imageptrs->maxRadianceIndex[colorindex] = i; + } + } + + + + // for(int i = 0; i < 1024; i++) + // { + // qDebug() << QString("stats_ch[0][%1] = %2 sum_ch[0][%3] = %4").arg(i).arg(stats_ch[0][i]).arg(i).arg(sum_ch[0]); + // } + + + qDebug() << QString("minRadianceIndex [%1] = %2 maxRadianceIndex [%3] = %4").arg(colorindex).arg(imageptrs->minRadianceIndex[colorindex]).arg(colorindex).arg(imageptrs->maxRadianceIndex[colorindex]); +} + +void SegmentListGeostationary::CalculateLUTGeoMTG(int colorindex) +{ + qDebug() << "start SegmentListGeostationary::CalculateLUTGeoMTG()"; + long histogram[4096]; + + for (int j = 0; j < 4096; j++) + { + histogram[j] = 0; + } + + quint16 pixel; + for (int line = 0; line < imageptrs->mtg_total_number_of_rows[0]; line++) + { + for (int pixelx = 0; pixelx < imageptrs->mtg_total_number_of_columns[0]; pixelx++) + { + if(colorindex == 0) + pixel = *(imageptrs->ptrRed[0] + line * imageptrs->mtg_total_number_of_columns[0] + pixelx); + else if(colorindex == 1) + pixel = *(imageptrs->ptrRed[1] + line * imageptrs->mtg_total_number_of_columns[0] + pixelx); + else if(colorindex == 2) + pixel = *(imageptrs->ptrRed[2] + line * imageptrs->mtg_total_number_of_columns[0] + pixelx); + else + pixel = imageptrs->fillvalue[colorindex]; + + if(pixel != imageptrs->fillvalue[colorindex]) + { + quint16 indexout = (quint16)qMin(qMax(qRound(4095.0 * (float)(pixel - this->stat_min[colorindex])/(float)(this->stat_max[colorindex] - this->stat_min[colorindex])), 0), 4095); + //quint16 indexout = pixel; + histogram[indexout]++; + } + } + } + + // for (int j = 0; j < 4096; j=j+20) + // { + // qDebug() << "histogram " << j << " " << histogram[j]; + // } + + + // float scale = 256.0 / (NbrOfSegmentLinesSelected() * earth_views); // scale factor ,so the values in LUT are from 0 to MAX_VALUE + double newscale = (double)(4096.0 / (double)this->active_pixels[colorindex]); + + qDebug() << QString("newscale = %1 active pixels = %2").arg(newscale).arg(this->active_pixels[colorindex]); + + unsigned long long sum_ch = 0; + bool okmin, okmax; + + okmin = false; + okmax = false; + + // min/maxRadianceIndex = index of 95% ( 2.5% of 1024 = 25, 97.5% of 1024 = 997 ) + // min/maxRadianceIndex = index of 95% ( 2.5% of 4096 = 102, 97.5% of 4096 = 3993 ) + for( int i = 0; i < 4096; i++) + { + sum_ch += histogram[i]; + imageptrs->lut_ch[colorindex][i] = (quint16)((double)sum_ch * newscale); + imageptrs->lut_ch[colorindex][i] = ( imageptrs->lut_ch[colorindex][i] > 4095 ? 4095 : imageptrs->lut_ch[colorindex][i]); + if(imageptrs->lut_ch[colorindex][i] > 102 && okmin == false) + { + okmin = true; + imageptrs->minRadianceIndex[colorindex] = i; + } + if(imageptrs->lut_ch[colorindex][i] > 3993 && okmax == false) + { + okmax = true; + imageptrs->maxRadianceIndex[colorindex] = i; + } + } + + qDebug() << QString("minRadianceIndex [%1] = %2 maxRadianceIndex [%3] = %4").arg(colorindex).arg(imageptrs->minRadianceIndex[colorindex]).arg(colorindex).arg(imageptrs->maxRadianceIndex[colorindex]); +} + + + +void SegmentListGeostationary::CalculateLUTGeoMTGConcurrent(int colorindex, int index) +{ + + //qDebug() << "start SegmentListGeostationary::CalculateLUTGeoMTGConcurrent() colorindex = " << colorindex << " index = " << index; + + //assert(colorindex == 0); + + quint16 *ptr = imageptrs->ptrMTG[colorindex][index]; + + for (int j = 0; j < 4096; j++) + { + imageptrs->mtg_histogram[colorindex][index][j] = 0; + } + + quint16 pixel; + for (int line = 0; line < imageptrs->mtg_nbr_of_rows[colorindex][index]; line++) + { + for (int pixelx = 0; pixelx < imageptrs->mtg_nbr_of_columns[colorindex][index]; pixelx++) + { + pixel = ptr[line * imageptrs->mtg_nbr_of_columns[colorindex][index] + pixelx]; + if(pixel != imageptrs->fillvalue[colorindex]) + { + quint16 indexout = (quint16)qMin(qMax(qRound(4095.0 * (float)(pixel - this->stat_min[colorindex]) / + (float)(this->stat_max[colorindex] - this->stat_min[colorindex])), 0), 4095); + imageptrs->mtg_histogram[colorindex][index][indexout]++; + } + } + } + + return; + +} + +void SegmentListGeostationary::CalculateImageMTGConcurrent(int index) +{ + quint16 pixel[3]; + quint16 indexoutpixel[3]; + quint8 pixelout[3]; + QRgb *row_col; + QImage *im; + quint16 valgamma; + quint8 valcontrast; + double gamma = opts.meteosatgamma; + double gammafactor = 1023 / pow(1023, gamma); + + im = imageptrs->ptrimageGeostationary; + + int linelocal = 0; + //qDebug() << QString("index = %1 start_row = %2 end_row = %3").arg(index).arg(imageptrs->mtg_start_position_row[0][index] - 1).arg(imageptrs->mtg_end_position_row[0][index]); + + for(int line = imageptrs->mtg_start_position_row[0][index] - 1; line < imageptrs->mtg_end_position_row[0][index]; line++) + { + row_col = (QRgb*)im->scanLine(imageptrs->mtg_total_number_of_rows[0] - 1 - line); + + for (int pixelx = imageptrs->mtg_start_position_column[0][index] - 1; pixelx < imageptrs->mtg_end_position_column[0][index]; pixelx++) + { + for(int colorindex = 0; colorindex < (this->kindofimage == "VIS_IR Color" ? 3 : 1); colorindex++) + { + pixel[colorindex] = *(imageptrs->ptrMTG[colorindex][index] + ((imageptrs->mtg_nbr_of_columns[colorindex][index]) * linelocal) + pixelx); + + if(this->histogrammethod == CMB_HISTO_NONE_95) + { + if(pixel[colorindex] != imageptrs->fillvalue[colorindex]) + { + indexoutpixel[colorindex] = (quint16)qMin(qMax(qRound(1023.0 * (float)(pixel[colorindex] - imageptrs->minRadianceIndex[colorindex] ) / (float)(imageptrs->maxRadianceIndex[colorindex] - imageptrs->minRadianceIndex[colorindex])), 0), 1023); + valgamma = pow( indexoutpixel[colorindex], gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + pixelout[colorindex] = (valcontrast); + } + } + else if(this->histogrammethod == CMB_HISTO_NONE_100) + { + if(pixel[colorindex] != imageptrs->fillvalue[colorindex]) + { + indexoutpixel[colorindex] = (quint16)qMin(qMax(qRound(1023.0 * (float)(pixel[colorindex] - this->stat_min[colorindex] ) / (float)(this->stat_max[colorindex] - this->stat_min[colorindex])), 0), 1023); + valgamma = pow( indexoutpixel[colorindex], gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + pixelout[colorindex] = (valcontrast); + } + } + else if(this->histogrammethod == CMB_HISTO_EQUALIZE) + { + if( pixel[colorindex] != imageptrs->fillvalue[colorindex]) + { + indexoutpixel[colorindex] = (quint16)qMin(qMax(qRound(4095.0 * (float)(pixel[colorindex] - this->stat_min[colorindex] ) / (float)(this->stat_max[colorindex] - this->stat_min[colorindex])), 0), 4095); + indexoutpixel[colorindex] = (quint16)(qMin(qMax(qRound((float)imageptrs->lut_ch[colorindex][indexoutpixel[colorindex]]/4.0), 0), 1023)); + valgamma = pow( indexoutpixel[colorindex], gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + pixelout[colorindex] = (valcontrast); + } + } + + + } + + if(this->kindofimage == "VIS_IR") + { + if(pixel[0] != imageptrs->fillvalue[0]) + { + pixelout[0] = quint16(this->inversevector[0] ? (255 - pixelout[0]) : pixelout[0]); + pixelout[1] = pixelout[0]; + pixelout[2] = pixelout[0]; + row_col[pixelx] = qRgb(pixelout[0], pixelout[1], pixelout[2]); + } + } + else if(this->kindofimage == "VIS_IR Color") + { + if(pixel[0] != imageptrs->fillvalue[0]) + { + pixelout[0] = quint16(this->inversevector[0] ? (255 - pixelout[0]) : pixelout[0]); + pixelout[1] = quint16(this->inversevector[1] ? (255 - pixelout[1]) : pixelout[1]); + pixelout[2] = quint16(this->inversevector[2] ? (255 - pixelout[2]) : pixelout[2]); + row_col[pixelx] = qRgb(pixelout[0], pixelout[1], pixelout[2]); + } + } + + } + + linelocal++; + } +} + +void SegmentListGeostationary::CalculateLUTGeoMTG256(int colorindex) +{ + qDebug() << "start SegmentListGeostationary::CalculateLUTGeoMTG()"; + long histogram[256]; + + for (int j = 0; j < 256; j++) + { + histogram[j] = 0; + } + + quint16 pixel; + for (int line = 0; line < imageptrs->mtg_total_number_of_rows[0]; line++) + { + for (int pixelx = 0; pixelx < imageptrs->mtg_total_number_of_columns[0]; pixelx++) + { + if(colorindex == 0) + pixel = *(imageptrs->ptrRed[0] + line * imageptrs->mtg_total_number_of_columns[0] + pixelx); + else if(colorindex == 1) + pixel = *(imageptrs->ptrRed[1] + line * imageptrs->mtg_total_number_of_columns[0] + pixelx); + else if(colorindex == 2) + pixel = *(imageptrs->ptrRed[2] + line * imageptrs->mtg_total_number_of_columns[0] + pixelx); + else + pixel = imageptrs->fillvalue[colorindex]; + + if(pixel != imageptrs->fillvalue[colorindex]) + { + //quint16 indexout = (quint16)qMin(qMax(qRound(255.0 * (float)(pixel - this->stat_min[colorindex])/(float)(this->stat_max[colorindex] - this->stat_min[colorindex])), 0), 255); + quint16 indexout = (quint16)(pixel/16); + histogram[indexout]++; + } + } + } + + + // float scale = 256.0 / (NbrOfSegmentLinesSelected() * earth_views); // scale factor ,so the values in LUT are from 0 to MAX_VALUE + double newscale = (double)(256.0 / (double)this->active_pixels[colorindex]); + + qDebug() << QString("newscale = %1 active pixels = %2").arg(newscale).arg(this->active_pixels[colorindex]); + + unsigned long long sum_ch = 0; + bool okmin, okmax; + + okmin = false; + okmax = false; + + // min/maxRadianceIndex = index of 95% ( 2.5% of 256 = 102, 97.5% of 256 = 3993 ) + for( int i = 0; i < 256; i++) + { + sum_ch += histogram[i]; + imageptrs->lut_ch[colorindex][i] = (quint16)((double)sum_ch * newscale); + imageptrs->lut_ch[colorindex][i] = ( imageptrs->lut_ch[colorindex][i] > 255 ? 255 : imageptrs->lut_ch[colorindex][i]); + if(imageptrs->lut_ch[colorindex][i] > 6 && okmin == false) + { + okmin = true; + imageptrs->minRadianceIndex[colorindex] = i; + } + if(imageptrs->lut_ch[colorindex][i] > 250 && okmax == false) + { + okmax = true; + imageptrs->maxRadianceIndex[colorindex] = i; + } + } + + for( int i = 0; i < 256; i++) + { + qDebug() << QString("lut_ch[%1][%2] = %3").arg(colorindex).arg(i).arg(imageptrs->lut_ch[colorindex][i]); + } + + qDebug() << QString("minRadianceIndex [%1] = %2 maxRadianceIndex [%3] = %4").arg(colorindex).arg(imageptrs->minRadianceIndex[colorindex]).arg(colorindex).arg(imageptrs->maxRadianceIndex[colorindex]); +} + + +void SegmentListGeostationary::ComposeVISIR() +{ + + QRgb *row_col; + QRgb *row_col_bitmap; + quint16 cred, cgreen, cblue; + quint16 r,g, b; + quint16 indexoutrc, indexoutgc, indexoutbc; + + double gamma = opts.meteosatgamma; + double gammafactor = 1023 / pow(1023, gamma); + quint16 valgamma; + quint8 valcontrast; + + qDebug() << "==========start ComposeVISIR =================="; + + int width = opts.geosatellites[geoindex].imagewidth; + int height = opts.geosatellites[geoindex].imageheight; + size_t nbrpix = width*height; + int nbroflinespersegment = 464; + + quint16 *pixelsRed; + quint16 *pixelsGreen; + quint16 *pixelsBlue; + + pixelsRed = new quint16[nbrpix]; + if(kindofimage == "VIS_IR Color") + { + pixelsGreen = new quint16[nbrpix]; + pixelsBlue = new quint16[nbrpix]; + } + + for( int i = (bisRSS ? 5 : 0); i < opts.geosatellites[geoindex].maxsegments + (bisRSS ? 5 : 0); i++) + { + if(isPresentRed[i]) + memcpy(pixelsRed + (bisRSS ? i - 5 : i) * nbroflinespersegment * opts.geosatellites[geoindex].imagewidth, imageptrs->ptrRed[i], nbroflinespersegment * opts.geosatellites[geoindex].imagewidth * sizeof(quint16)); + } + if(kindofimage == "VIS_IR Color") + { + for( int i = (bisRSS ? 5 : 0); i < opts.geosatellites[geoindex].maxsegments + (bisRSS ? 5 : 0); i++) + { + if(isPresentGreen[i]) + memcpy(pixelsGreen + (bisRSS ? i - 5 : i) * nbroflinespersegment * opts.geosatellites[geoindex].imagewidth, imageptrs->ptrGreen[i], nbroflinespersegment * opts.geosatellites[geoindex].imagewidth * sizeof(quint16)); + } + for( int i = (bisRSS ? 5 : 0); i < opts.geosatellites[geoindex].maxsegments + (bisRSS ? 5 : 0); i++) + { + if(isPresentBlue[i]) + memcpy(pixelsBlue + (bisRSS ? i - 5 : i) * nbroflinespersegment * opts.geosatellites[geoindex].imagewidth, imageptrs->ptrBlue[i], nbroflinespersegment * opts.geosatellites[geoindex].imagewidth * sizeof(quint16)); + } + + } + + CalculateMinMax(0, width, height, pixelsRed, 0); + CalculateLUTGeo(0, pixelsRed, 0); + if(kindofimage == "VIS_IR Color") + { + CalculateMinMax(1, width, height, pixelsGreen, 0); + CalculateLUTGeo(1, pixelsGreen, 0); + CalculateMinMax(2, width, height, pixelsBlue, 0); + CalculateLUTGeo(2, pixelsBlue, 0); + } + + // for(int i = 0; i < 1024; i++) + // { + // qDebug() << QString("lut_ch [%1] = %2 ; %3 ; %4").arg(i).arg(imageptrs->lut_ch[0][i]).arg(imageptrs->lut_ch[1][i]).arg(imageptrs->lut_ch[0][i]); + // } + + // quint16 nindexred, nindexgreen, nindexblue; + + QImage *im = CalculateBitMap(); + + unsigned int i_image; + + for (int line = opts.geosatellites[geoindex].maxsegments*nbroflinespersegment - 1; line >= 0; line--) + { + if(m_GeoSatellite == eGeoSatellite::GOMS3) + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(line); + else + { + row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(opts.geosatellites[geoindex].imageheight - 1 - line); + row_col_bitmap = (QRgb*)imageptrs->ptrimagebitmap->scanLine(opts.geosatellites[geoindex].imageheight - 1 - line); + } + + for (int pixelx = opts.geosatellites[geoindex].imagewidth - 1 ; pixelx >= 0; pixelx--) + { + i_image = line * opts.geosatellites[geoindex].imagewidth + pixelx; + if(kindofimage == "VIS_IR Color") + { + cred = *(pixelsRed + line * opts.geosatellites[geoindex].imagewidth + pixelx); + cgreen = *(pixelsGreen+ line * opts.geosatellites[geoindex].imagewidth + pixelx); + cblue = *(pixelsBlue+ line * opts.geosatellites[geoindex].imagewidth + pixelx); + + if(this->histogrammethod == CMB_HISTO_NONE_95) + { + if(cred < 65528) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cred - imageptrs->minRadianceIndex[0] ) / (float)(imageptrs->maxRadianceIndex[0] - imageptrs->minRadianceIndex[0])), 0), 1023); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + else { + r = 0; + } + + if(cgreen < 65528) + { + indexoutgc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cgreen - imageptrs->minRadianceIndex[1] ) / (float)(imageptrs->maxRadianceIndex[1] - imageptrs->minRadianceIndex[1])), 0), 1023); + valgamma = pow( indexoutgc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + g = quint8(valcontrast); + if (g > 255) + g = 255; + } + else { + g = 0; + } + if(cblue < 65528) + { + indexoutbc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cblue - imageptrs->minRadianceIndex[2] ) / (float)(imageptrs->maxRadianceIndex[2] - imageptrs->minRadianceIndex[2])), 0), 1023); + valgamma = pow( indexoutbc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + b = quint8(valcontrast); + if (b > 255) + b = 255; + } + else { + b = 0; + } + } + else if(this->histogrammethod == CMB_HISTO_NONE_100) + { + if(cred < 65528) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cred - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + else { + r = 0; + } + if(cgreen < 65528) + { + indexoutgc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cgreen - this->stat_min[1] ) / (float)(this->stat_max[1] - this->stat_min[1])), 0), 1023); + valgamma = pow( indexoutgc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + g = quint8(valcontrast); + if (g > 255) + g = 255; + } + else { + g = 0; + } + if(cblue < 65528) + { + indexoutbc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cblue - this->stat_min[2] ) / (float)(this->stat_max[2] - this->stat_min[2])), 0), 1023); + valgamma = pow( indexoutbc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + b = quint8(valcontrast); + if (b > 255) + b = 255; + } + else { + b = 0; + } + } + else if(this->histogrammethod == CMB_HISTO_EQUALIZE) + { + if( cred < 65528) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cred - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); + indexoutrc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[0][indexoutrc]), 0), 1023); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + else { + r = 0; + } + + if( cgreen < 65528) + { + indexoutgc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cgreen - this->stat_min[1] ) / (float)(this->stat_max[1] - this->stat_min[1])), 0), 1023); + indexoutgc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[1][indexoutgc]), 0), 1023); + valgamma = pow( indexoutgc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + g = quint8(valcontrast); + if (g > 255) + g = 255; + } + else { + g = 0; + } + if( cblue < 65528) + { + indexoutbc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cblue - this->stat_min[2] ) / (float)(this->stat_max[2] - this->stat_min[2])), 0), 1023); + indexoutbc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[2][indexoutbc]), 0), 1023); + valgamma = pow( indexoutbc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + b = quint8(valcontrast); + if (b > 255) + b = 255; + } + else { + b = 0; + } + + } + + if(m_GeoSatellite == eGeoSatellite::GOMS3 ) + row_col[pixelx] = qRgb(r,g,b); + else + { + if(qRed(row_col_bitmap[opts.geosatellites[geoindex].imagewidth - 1 - pixelx]) == 0) + { + r = 0; + g = 0; + b = 0; + } + else if(qRed(row_col_bitmap[opts.geosatellites[geoindex].imagewidth - 1 - pixelx]) == 255) + { + r = quint16(this->inversevector[0] ? (r == 255 ? 0 : r) : r); + g = quint16(this->inversevector[1] ? (g == 255 ? 0 : g) : g);; + b = quint16(this->inversevector[2] ? (b == 255 ? 0 : b) : b);; + } + else + { + r = quint16(this->inversevector[0] ? (255 - r) : r); + g = quint16(this->inversevector[1] ? (255 - g) : g); + b = quint16(this->inversevector[2] ? (255 - b) : b); + } + row_col[opts.geosatellites[geoindex].imagewidth - 1 - pixelx] = qRgb(r,g,b); + } + + + } + else if(kindofimage == "VIS_IR") + { + cred = *(pixelsRed + line * opts.geosatellites[geoindex].imagewidth + pixelx); + + if(this->histogrammethod == CMB_HISTO_NONE_95) + { + if(cred < 65528) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cred - imageptrs->minRadianceIndex[0] ) / (float)(imageptrs->maxRadianceIndex[0] - imageptrs->minRadianceIndex[0])), 0), 1023); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + } + else if(this->histogrammethod == CMB_HISTO_NONE_100) + { + if(cred < 65528) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cred - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + } + else // if(this->histogrammethod == CMB_HISTO_EQUALIZE) + { + if( cred < 65528) + { + indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cred - this->stat_min[0] ) / (float)(this->stat_max[0] - this->stat_min[0])), 0), 1023); + indexoutrc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[0][indexoutrc]), 0), 1023); + valgamma = pow( indexoutrc, gamma) * gammafactor; + if (valgamma > 1023) + valgamma = 1023; + + valcontrast = ContrastStretch(valgamma); + r = quint8(valcontrast); + if (r > 255) + r = 255; + } + } + + g = r; + b = r; + + if(m_GeoSatellite == eGeoSatellite::GOMS3 ) + row_col[pixelx] = qRgb(r,g,b); + else + { + if(qRed(row_col_bitmap[opts.geosatellites[geoindex].imagewidth - 1 - pixelx]) == 0) + { + r = 0; + g = 0; + b = 0; + } + else if(qRed(row_col_bitmap[opts.geosatellites[geoindex].imagewidth - 1 - pixelx]) == 255) + { + r = quint16(this->inversevector[0] ? (r == 255 ? 0 : r) : r); + g = r; + b = r; + } + else + { + r = quint16(this->inversevector[0] ? (255 - r) : r); + g = r; + b = r; + } + + row_col[opts.geosatellites[geoindex].imagewidth - 1 - pixelx] = qRgb(r,g,b); + } } } } - - - - //double newscale = 256.0 / (3712*3712); // scale factor ,so the values in LUT are from 0 to MAX_VALUE - double newscale = (double)(1024.0 / this->active_pixels[colorindex]); - - qDebug() << QString("newscale = %1 active pixels = %2").arg(newscale).arg(this->active_pixels[colorindex]); - - unsigned long long sum_ch[3]; - - for (int i=0; i < 3; i++) + if(im != NULL) { - sum_ch[i] = 0; + delete im; + im = NULL; } - - bool okmin, okmax; - - okmin = false; - okmax = false; - - // min/maxRadianceIndex = index of 95% ( 2.5% of 1024 = 25, 97.5% of 1024 = 997 ) - for( int i = 0; i < 1024; i++) + delete [] pixelsRed; + if(kindofimage == "VIS_IR Color") { - sum_ch[colorindex] += stats_ch[colorindex][i]; - imageptrs->lut_ch[colorindex][i] = (quint16)((double)sum_ch[colorindex] * newscale); - imageptrs->lut_ch[colorindex][i] = ( imageptrs->lut_ch[colorindex][i] > 1023 ? 1023 : imageptrs->lut_ch[colorindex][i]); -// qDebug() << QString("stats_ch[0][%1] = %2 lut_ch[0][%3] = %4").arg(i).arg(stats_ch[0][i]).arg(i).arg(imageptrs->lut_ch[0][i]); - if(imageptrs->lut_ch[colorindex][i] > 25 && okmin == false) - { - okmin = true; - imageptrs->minRadianceIndex[colorindex] = i; - } - if(imageptrs->lut_ch[colorindex][i] > 997 && okmax == false) - { - okmax = true; - imageptrs->maxRadianceIndex[colorindex] = i; - } + delete [] pixelsGreen; + delete [] pixelsBlue; } -// for(int i = 0; i < 1024; i++) -// { -// qDebug() << QString("stats_ch[0][%1] = %2").arg(i).arg(stats_ch[0][i]); -// } - - -// for(int i = 0; i < 1024; i++) -// { -// qDebug() << QString("stats_ch[0][%1] = %2 sum_ch[0][%3] = %4").arg(i).arg(stats_ch[0][i]).arg(i).arg(sum_ch[0][i]); -// } - - - qDebug() << QString("minRadianceIndex [%1] = %2 maxRadianceIndex [%3] = %4").arg(colorindex).arg(imageptrs->minRadianceIndex[colorindex]).arg(colorindex).arg(imageptrs->maxRadianceIndex[colorindex]); } -void SegmentListGeostationary::ComposeVISIR() +void SegmentListGeostationary::ComposeVISIR_Alt() { QRgb *row_col; @@ -2006,10 +3568,10 @@ void SegmentListGeostationary::ComposeVISIR() size_t nbrpix = width*height; int nbroflinespersegment = 464; -// if(m_GeoSatellite == eGeoSatellite::GOES_15) -// nbroflinespersegment = 580; -// else -// nbroflinespersegment = 464; + // if(m_GeoSatellite == eGeoSatellite::GOES_15) + // nbroflinespersegment = 580; + // else + // nbroflinespersegment = 464; quint16 *pixelsRed; quint16 *pixelsGreen; @@ -2042,17 +3604,34 @@ void SegmentListGeostationary::ComposeVISIR() } + int fillValue[3]; + fillValue[0] = 0; + fillValue[1] = 0; + fillValue[2] = 0; + CalculateMinMax(0, width, height, pixelsRed, 0); - CalculateLUTGeo(0, pixelsRed, 0); + normalizeMinMax(width, height,pixelsRed, this->stat_min[0], this->stat_max[0], fillValue[0], 255 ); + + // CalculateLUTGeo(0, pixelsRed, 0); if(kindofimage == "VIS_IR Color") { CalculateMinMax(1, width, height, pixelsGreen, 0); - CalculateLUTGeo(1, pixelsGreen, 0); + normalizeMinMax(width, height,pixelsGreen, this->stat_min[1], this->stat_max[1], fillValue[1], 255 ); + // CalculateLUTGeo(1, pixelsGreen, 0); CalculateMinMax(2, width, height, pixelsBlue, 0); - CalculateLUTGeo(2, pixelsBlue, 0); + normalizeMinMax(width, height,pixelsBlue, this->stat_min[2], this->stat_max[2], fillValue[2], 255 ); + // CalculateLUTGeo(2, pixelsBlue, 0); + } + + imageptrs->CLAHE(pixelsRed, 3712, 3712, this->stat_min[0], this->stat_max[0], 16, 16, 255, 3.5); + if(kindofimage == "VIS_IR Color") + { + imageptrs->CLAHE(pixelsGreen, 3712, 3712, this->stat_min[1], this->stat_max[1], 16, 16, 255, 3.5); + imageptrs->CLAHE(pixelsBlue, 3712, 3712, this->stat_min[2], this->stat_max[2], 16, 16, 255, 3.5); } long count_cred = 0; + quint16 nindexred, nindexgreen, nindexblue; for (int line = opts.geosatellites[geoindex].maxsegments*nbroflinespersegment - 1; line >= 0; line--) { @@ -2070,32 +3649,8 @@ void SegmentListGeostationary::ComposeVISIR() cgreen = *(pixelsGreen+ line * opts.geosatellites[geoindex].imagewidth + pixelx); cblue = *(pixelsBlue+ line * opts.geosatellites[geoindex].imagewidth + pixelx); - if(this->histogrammethod == CMB_HISTO_NONE_95) - { - if(cred != 65535) - indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cred - imageptrs->minRadianceIndex[0] ) / (float)(imageptrs->maxRadianceIndex[0] - imageptrs->minRadianceIndex[0])), 0), 1023); - if(cgreen != 65535) - indexoutgc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cgreen - imageptrs->minRadianceIndex[1] ) / (float)(imageptrs->maxRadianceIndex[1] - imageptrs->minRadianceIndex[1])), 0), 1023); - if(cblue != 65535) - indexoutbc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cblue - imageptrs->minRadianceIndex[2] ) / (float)(imageptrs->maxRadianceIndex[2] - imageptrs->minRadianceIndex[2])), 0), 1023); - } - else if(this->histogrammethod == CMB_HISTO_NONE_100) - { - if(cred != 65535) - indexoutrc = cred; - if(cgreen != 65535) - indexoutgc = cgreen; - if(cblue != 65535) - indexoutbc = cblue; - } - else if(this->histogrammethod == CMB_HISTO_EQUALIZE) - { - if( cred != 65535) indexoutrc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[0][cred]), 0), 1023); - if( cgreen != 65535) indexoutgc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[1][cgreen]), 0), 1023); - if( cblue != 65535) indexoutbc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[2][cblue]), 0), 1023); - } -// if( (cred == 65535) || (cgreen == 65535) || (cblue == 65535)) + // if( (cred == 65535) || (cgreen == 65535) || (cblue == 65535)) if( (cred == 0) || (cgreen == 0) || (cblue == 0)) { r = 0; @@ -2104,34 +3659,16 @@ void SegmentListGeostationary::ComposeVISIR() } else { - r = quint16(this->inversevector[0] ? (1023 - indexoutrc)/4 : indexoutrc/4); - g = quint16(this->inversevector[1] ? (1023 - indexoutgc)/4 : indexoutgc/4); - b = quint16(this->inversevector[2] ? (1023 - indexoutbc)/4 : indexoutbc/4); + r = quint16(this->inversevector[0] ? 255 - cred : cred); + g = quint16(this->inversevector[1] ? 255 - cgreen : cgreen); + b = quint16(this->inversevector[2] ? 255 - cblue : cblue); } } else if(kindofimage == "VIS_IR") { cred = *(pixelsRed + line * opts.geosatellites[geoindex].imagewidth + pixelx); - if(cred == 65535) - count_cred++; - - if(this->histogrammethod == CMB_HISTO_NONE_95) - { - if(cred != 65535) - indexoutrc = (quint16)qMin(qMax(qRound(1023.0 * (float)(cred - imageptrs->minRadianceIndex[0] ) / (float)(imageptrs->maxRadianceIndex[0] - imageptrs->minRadianceIndex[0])), 0), 1023); - } - else if(this->histogrammethod == CMB_HISTO_NONE_100) - { - if(cred != 65535) - indexoutrc = cred; - } - else if(this->histogrammethod == CMB_HISTO_EQUALIZE) - { - if( cred != 65535) indexoutrc = (quint16)qMin(qMax(qRound((float)imageptrs->lut_ch[0][cred]), 0), 1023); - } -// if( cred == 65535) if( cred == 0) { r = 0; @@ -2140,7 +3677,7 @@ void SegmentListGeostationary::ComposeVISIR() } else { - r = quint16(this->inversevector[0] ? (1023 - indexoutrc)/4 : indexoutrc/4); + r = quint16(this->inversevector[0] ? 255 - cred : cred); g = r; b = r; } @@ -2168,18 +3705,18 @@ void SegmentListGeostationary::ComposeVISIRHimawari() { -// if(kindofimage == "VIS_IR") -// CalculateMinMaxHimawari(5500, 550, imageptrs->ptrRed[filesequence], minvalueRed[filesequence], maxvalueRed[filesequence]); -// else if(kindofimage == "VIS_IR Color") -// { -// if(channelindex == 0) -// CalculateMinMaxHimawari(5500, 550, imageptrs->ptrRed[filesequence], minvalueRed[filesequence], maxvalueRed[filesequence]); -// else if(channelindex == 1) -// CalculateMinMaxHimawari(5500, 550, imageptrs->ptrGreen[filesequence], minvalueGreen[filesequence], maxvalueGreen[filesequence]); -// else if(channelindex == 2) -// CalculateMinMaxHimawari(5500, 550, imageptrs->ptrBlue[filesequence], minvalueBlue[filesequence], maxvalueBlue[filesequence]); + // if(kindofimage == "VIS_IR") + // CalculateMinMaxHimawari(5500, 550, imageptrs->ptrRed[filesequence], minvalueRed[filesequence], maxvalueRed[filesequence]); + // else if(kindofimage == "VIS_IR Color") + // { + // if(channelindex == 0) + // CalculateMinMaxHimawari(5500, 550, imageptrs->ptrRed[filesequence], minvalueRed[filesequence], maxvalueRed[filesequence]); + // else if(channelindex == 1) + // CalculateMinMaxHimawari(5500, 550, imageptrs->ptrGreen[filesequence], minvalueGreen[filesequence], maxvalueGreen[filesequence]); + // else if(channelindex == 2) + // CalculateMinMaxHimawari(5500, 550, imageptrs->ptrBlue[filesequence], minvalueBlue[filesequence], maxvalueBlue[filesequence]); -// } + // } QRgb *row_col; @@ -2344,67 +3881,30 @@ void SegmentListGeostationary::ComposeHRV() } } - // Bottom of earth -// if(kindofimage == "HRV Color") -// { -// QImage testimage(3712, 3*464, QImage::Format_ARGB32); -// for(int y = 3*464-1; y >= 0; y--) -// { -// row_col = (QRgb*)testimage.scanLine(3*464-1-y); - -// for(int x = 3712-1; x >= 0; x--) -// { -// cred = *(pixelsRed + y*3712 + x); -// cgreen = *(pixelsGreen + y*3712 + x); -// cblue = *(pixelsBlue + y*3712 + x); -// row_col[3712-1-x] = qRgb(ContrastStretch(cred), ContrastStretch(cgreen), ContrastStretch(cblue)); -// } -// } - -// testimage.save("testimage.png"); -// } - - - + emit this->progressCounter(10); if(kindofimage == "HRV Color") { - imageptrs->CLAHE(pixelsRed, 3712, 3712, 0, 1023, 16, 16, 256, 4); - imageptrs->CLAHE(pixelsGreen, 3712, 3712, 0, 1023, 16, 16, 256, 4); - imageptrs->CLAHE(pixelsBlue, 3712, 3712, 0, 1023, 16, 16, 256, 4); + imageptrs->CLAHE(pixelsRed, 3712, 3712, 0, 1023, 16, 16, 256, 3); + imageptrs->CLAHE(pixelsGreen, 3712, 3712, 0, 1023, 16, 16, 256, 3); + imageptrs->CLAHE(pixelsBlue, 3712, 3712, 0, 1023, 16, 16, 256, 3); } - // top of the world -// if(kindofimage == "HRV Color") -// { -// QImage testimage(3712, 3*464, QImage::Format_ARGB32); -// for(int y = 3*464-1; y >= 0; y--) -// { -// row_col = (QRgb*)testimage.scanLine(3*464-1-y); - -// for(int x = 0; x < 3712; x++) -// { -// cred = *(pixelsRed + (8-3)*464*3712 + y*3712 + x); -// cgreen = *(pixelsGreen + (8-3)*464*3712 + y*3712 + x); -// cblue = *(pixelsBlue + (8-3)*464*3712 + y*3712 + x); -// row_col[3712 - x - 1] = qRgb(ContrastStretch(cred), ContrastStretch(cgreen), ContrastStretch(cblue)); -// } -// } - -// testimage.save("testimage1.png"); -// } + emit this->progressCounter(20); if(opts.geosatellites.at(geoindex).rss) imageptrs->CLAHE(pixelsHRV, 5568, 5*464, 0, 1023, 16, 16, 256, 4); else { if(this->areatype == 1) - imageptrs->CLAHE(pixelsHRV, 5568, 11136, 0, 1023, 16, 16, 256, 4); + imageptrs->CLAHE(pixelsHRV, 5568, 11136, 0, 1023, 16, 16, 256, 3); else - imageptrs->CLAHE(pixelsHRV, 5568, 5*464, 0, 1023, 16, 16, 256, 4); + imageptrs->CLAHE(pixelsHRV, 5568, 5*464, 0, 1023, 16, 16, 256, 3); } + emit this->progressCounter(50); + for (int line = (opts.geosatellites.at(geoindex).rss ? 5 : (this->areatype == 1 ? 24 : 5))*464 - 1; line >= 0; line--) { row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine((opts.geosatellites.at(geoindex).rss ? 5 : (this->areatype == 1 ? 24 : 5))*464 - 1 - line); @@ -2644,8 +4144,8 @@ bool SegmentListGeostationary::allVIS_IRSegmentsReceived() } else if(m_GeoSatellite == eGeoSatellite::FY2H || m_GeoSatellite == eGeoSatellite::FY2G) { - if (isPresentRed[0] && issegmentcomposedRed[0] == true) - pbCounter++; + if (isPresentRed[0] && issegmentcomposedRed[0] == true) + pbCounter++; } else if(m_GeoSatellite == eGeoSatellite::H8) { @@ -2761,21 +4261,21 @@ bool SegmentListGeostationary::allVIS_IRSegmentsReceived() } } else if(m_GeoSatellite == eGeoSatellite::FY2H || m_GeoSatellite == eGeoSatellite::FY2G || m_GeoSatellite == eGeoSatellite::GOES_16 - || m_GeoSatellite == eGeoSatellite::GOES_17 || m_GeoSatellite == eGeoSatellite::GOES_18) + || m_GeoSatellite == eGeoSatellite::GOES_17 || m_GeoSatellite == eGeoSatellite::GOES_18) { if (isPresentRed[0] && issegmentcomposedRed[0] == false) - return false; + return false; } else if(m_GeoSatellite == eGeoSatellite::H8) { -// qDebug() << "======================================="; -// for(int i = 0; i < 10; i++) -// { -// qDebug() << QString("%1 isPresentRed = %2 issegmentcomposedRed = %3").arg(i).arg(isPresentRed[i]).arg(issegmentcomposedRed[i]); + // qDebug() << "======================================="; + // for(int i = 0; i < 10; i++) + // { + // qDebug() << QString("%1 isPresentRed = %2 issegmentcomposedRed = %3").arg(i).arg(isPresentRed[i]).arg(issegmentcomposedRed[i]); -// } -// qDebug() << "======================================="; + // } + // qDebug() << "======================================="; for(int i = 0; i < 10; i++) { if (isPresentRed[i] && issegmentcomposedRed[i] == false) @@ -2806,12 +4306,44 @@ bool SegmentListGeostationary::allVIS_IRSegmentsReceived() return true; } +//void SegmentListGeostationary::CalculateMinMaxMTG(int colorindex, int index) +//{ +// qDebug() << QString("CalculateMinMaxMTG colorindex = %1 index = %2").arg(colorindex).arg(index); +//} + +void SegmentListGeostationary::CalculateMinMaxMTG(int colorindex, int index) +{ + imageptrs->mtg_active_pixels[colorindex][index] = 0; + + imageptrs->mtg_stat_min[colorindex][index] = imageptrs->fillvalue[colorindex]; + imageptrs->mtg_stat_max[colorindex][index] = 0; + + quint16 *ptr = imageptrs->ptrMTG[colorindex][index]; + for (int j = 0; j < imageptrs->mtg_nbr_of_rows[colorindex][index]; j++) { + for (int i = 0; i < imageptrs->mtg_nbr_of_columns[colorindex][index]; i++) + { + quint16 val = ptr[j * imageptrs->mtg_nbr_of_columns[colorindex][index] + i]; + if(val != imageptrs->fillvalue[colorindex]) + { + if(val >= imageptrs->mtg_stat_max[colorindex][index]) + imageptrs->mtg_stat_max[colorindex][index] = val; + if(val < imageptrs->mtg_stat_min[colorindex][index]) + imageptrs->mtg_stat_min[colorindex][index] = val; + + imageptrs->mtg_active_pixels[colorindex][index]++; + } + } + } + +} + void SegmentListGeostationary::CalculateMinMax(int width, int height, quint16 *ptr, quint16 &stat_min, quint16 &stat_max) { stat_min = 65535; stat_max = 0; + long count_zero = 0; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) @@ -2824,6 +4356,8 @@ void SegmentListGeostationary::CalculateMinMax(int width, int height, quint16 *p if(val < stat_min) stat_min = val; } + else + count_zero++; } } @@ -2837,7 +4371,7 @@ void SegmentListGeostationary::CalculateMinMax(int colorindex, int width, int he this->active_pixels[colorindex] = 0; - qDebug() << QString("start CalculateMinMax"); + qDebug() << QString("start CalculateMinMax colorindex = %1").arg(colorindex); for (int j = 0; j < height; j++) { @@ -2845,8 +4379,8 @@ void SegmentListGeostationary::CalculateMinMax(int colorindex, int width, int he { quint16 val = ptr[j * width + i]; - if(colorindex == 0 && j == 0 && i < 100) - qDebug() << val; + // if(colorindex == 0 && j == 1000 && i < 300) + // qDebug() << val; if(val != fillvalue) { @@ -2854,19 +4388,20 @@ void SegmentListGeostationary::CalculateMinMax(int colorindex, int width, int he this->stat_max[colorindex] = val; if(val < this->stat_min[colorindex]) this->stat_min[colorindex] = val; + this->active_pixels[colorindex]++; } else - cnt++; + cnt++; } } qDebug() << QString("CalculateMinMax color = %1 stat_min = %2 stat_max = %3 active pixels = %4 pixels with fillvalue = %5") - .arg(colorindex).arg(stat_min[colorindex]).arg(stat_max[colorindex]).arg(this->active_pixels[colorindex]).arg(cnt); + .arg(colorindex).arg(stat_min[colorindex]).arg(stat_max[colorindex]).arg(this->active_pixels[colorindex]).arg(cnt); } -void SegmentListGeostationary::normalizeMinMaxGOES16(int width, int height, quint16 *ptr, quint16 &stat_min, quint16 &stat_max, int &fillvalue, int maxvalue) +void SegmentListGeostationary::normalizeMinMax(int width, int height, quint16 *ptr, quint16 &stat_min, quint16 &stat_max, int &fillvalue, int maxvalue) { @@ -2886,7 +4421,6 @@ void SegmentListGeostationary::normalizeMinMaxGOES16(int width, int height, quin stat_min = 0; stat_max = maxvalue; -// fillvalue = 4096; } @@ -2953,7 +4487,7 @@ quint16 SegmentListGeostationary::ContrastStretch(quint16 val) { double res; res = double(val)*A1 + B1; - return (res > 255.0 ? 255 : quint16(res)); + return (res > 255.0 ? 255 : (res < 0 ? 0 : quint16(res))); } void SegmentListGeostationary::SetupContrastStretch(quint16 x1, quint16 y1, quint16 x2, quint16 y2) @@ -3113,6 +4647,8 @@ void SegmentListGeostationary::ComposeGeoRGBRecipeInThread(int recipe) double slope, offset; bool toint; + lon0 = prodata.prologue->image_description.ProjectionDescription.LongitudeOfSSP; + for(int i = 0; i < uniquebandlist.length(); i++) { @@ -3159,17 +4695,17 @@ void SegmentListGeostationary::ComposeGeoRGBRecipeInThread(int recipe) t = (jtime - (jtime_start2 + jtime_end2) / 2.) / ((jtime_end2 - jtime_start2) / 2.); X = prodata.prologue->sat_status.Orbit.OrbitPoliniomal[i].X[0] + - prodata.prologue->sat_status.Orbit.OrbitPoliniomal[i].X[1] * t; + prodata.prologue->sat_status.Orbit.OrbitPoliniomal[i].X[1] * t; Y = prodata.prologue->sat_status.Orbit.OrbitPoliniomal[i].Y[0] + - prodata.prologue->sat_status.Orbit.OrbitPoliniomal[i].Y[1] * t; + prodata.prologue->sat_status.Orbit.OrbitPoliniomal[i].Y[1] * t; Z = prodata.prologue->sat_status.Orbit.OrbitPoliniomal[i].Z[0] + - prodata.prologue->sat_status.Orbit.OrbitPoliniomal[i].Z[1] * t; + prodata.prologue->sat_status.Orbit.OrbitPoliniomal[i].Z[1] * t; /*------------------------------------------------------------------------- * Compute latitude and longitude and solar and sensor zenith and azimuth * angles. *-----------------------------------------------------------------------*/ - double lon0 = prodata.prologue->image_description.ProjectionDescription.LongitudeOfSSP; + lon0 = prodata.prologue->image_description.ProjectionDescription.LongitudeOfSSP; qDebug() << "longitude SSP = " << lon0; double mu0; @@ -3217,8 +4753,8 @@ void SegmentListGeostationary::ComposeGeoRGBRecipeInThread(int recipe) } } - //PrintResults(sza, "sza"); - //PrintResults(vza, "vza"); + // PrintResults(sza, "sza"); + // PrintResults(vza, "vza"); } emit progressCounter(30); @@ -3254,8 +4790,8 @@ void SegmentListGeostationary::ComposeGeoRGBRecipeInThread(int recipe) if(bands[j].spectral_channel_nbr == imageptrs->rgbrecipes[recipe].Colorvector.at(colorindex).spectral_channel_nbr.at(i)) { qDebug() << colorindex << " " << imageptrs->rgbrecipes[recipe].Colorvector.at(colorindex).channels.at(i) << " " << - imageptrs->rgbrecipes[recipe].Colorvector.at(colorindex).spectral_channel_nbr.at(i) << " " << - imageptrs->rgbrecipes[recipe].Colorvector.at(colorindex).subtract.at(i); + imageptrs->rgbrecipes[recipe].Colorvector.at(colorindex).spectral_channel_nbr.at(i) << " " << + imageptrs->rgbrecipes[recipe].Colorvector.at(colorindex).subtract.at(i); for (int line = 0; line < 3712; line++) { for (int pixelx = 0; pixelx < 3712; pixelx++) @@ -3424,43 +4960,43 @@ void SegmentListGeostationary::ComposeGeoRGBRecipeInThread(int recipe) qDebug() << QString("%1 resultmin = %2 resultmax = %3").arg(colorindex).arg(resultmin[colorindex]).arg(resultmax[colorindex]); -// for (int line = 0; line < 3712; line++) -// { -// row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(3711 - line); -// for (int pixelx = 0; pixelx < 3712; pixelx++) -// { -// int i_image = line * 3712 + pixelx; - -// if(result[0][i_image] == FILL_VALUE_F || result[1][i_image] == FILL_VALUE_F || result[2][i_image] == FILL_VALUE_F ) -// { -// red = 0.0; -// green = 0.0; -// blue = 0.0; -// } -// else -// { -// if(imageptrs->rgbrecipes[recipe].Colorvector.at(0).inverse.at(0)) -// red = 255.0 - 255.0 * pow((result[0][i_image] - resultmin[0]) / (resultmax[0] - resultmin[0]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(0).gamma); -// else -// red = 255.0 * pow((result[0][i_image] - resultmin[0]) / (resultmax[0] - resultmin[0]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(0).gamma); -// if(imageptrs->rgbrecipes[recipe].Colorvector.at(1).inverse.at(0)) -// green = 255.0 - 255.0 * pow((result[1][i_image] - resultmin[1]) / (resultmax[1] - resultmin[1]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(1).gamma); -// else -// green = 255.0 * pow((result[1][i_image] - resultmin[1]) / (resultmax[1] - resultmin[1]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(1).gamma); -// if(imageptrs->rgbrecipes[recipe].Colorvector.at(2).inverse.at(0)) -// blue = 255 - 255.0 * pow((result[2][i_image] - resultmin[2]) / (resultmax[2] - resultmin[2]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(2).gamma); -// else -// blue = 255.0 * pow((result[2][i_image] - resultmin[2]) / (resultmax[2] - resultmin[2]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(2).gamma); -// } -// int i_image1 = (3711 - line) * 3712 + (3711 - pixelx); - -// imageptrs->ptrimageRGBRecipeRed[i_image1] = (quint8)red; -// imageptrs->ptrimageRGBRecipeGreen[i_image1] = (quint8)green; -// imageptrs->ptrimageRGBRecipeBlue[i_image1] = (quint8)blue; - -// row_col[3711 - pixelx] = qRgb((int)red, (int)green, (int)blue); -// } -// } + // for (int line = 0; line < 3712; line++) + // { + // row_col = (QRgb*)imageptrs->ptrimageGeostationary->scanLine(3711 - line); + // for (int pixelx = 0; pixelx < 3712; pixelx++) + // { + // int i_image = line * 3712 + pixelx; + + // if(result[0][i_image] == FILL_VALUE_F || result[1][i_image] == FILL_VALUE_F || result[2][i_image] == FILL_VALUE_F ) + // { + // red = 0.0; + // green = 0.0; + // blue = 0.0; + // } + // else + // { + // if(imageptrs->rgbrecipes[recipe].Colorvector.at(0).inverse.at(0)) + // red = 255.0 - 255.0 * pow((result[0][i_image] - resultmin[0]) / (resultmax[0] - resultmin[0]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(0).gamma); + // else + // red = 255.0 * pow((result[0][i_image] - resultmin[0]) / (resultmax[0] - resultmin[0]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(0).gamma); + // if(imageptrs->rgbrecipes[recipe].Colorvector.at(1).inverse.at(0)) + // green = 255.0 - 255.0 * pow((result[1][i_image] - resultmin[1]) / (resultmax[1] - resultmin[1]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(1).gamma); + // else + // green = 255.0 * pow((result[1][i_image] - resultmin[1]) / (resultmax[1] - resultmin[1]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(1).gamma); + // if(imageptrs->rgbrecipes[recipe].Colorvector.at(2).inverse.at(0)) + // blue = 255 - 255.0 * pow((result[2][i_image] - resultmin[2]) / (resultmax[2] - resultmin[2]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(2).gamma); + // else + // blue = 255.0 * pow((result[2][i_image] - resultmin[2]) / (resultmax[2] - resultmin[2]), 1.0/imageptrs->rgbrecipes[recipe].Colorvector.at(2).gamma); + // } + // int i_image1 = (3711 - line) * 3712 + (3711 - pixelx); + + // imageptrs->ptrimageRGBRecipeRed[i_image1] = (quint8)red; + // imageptrs->ptrimageRGBRecipeGreen[i_image1] = (quint8)green; + // imageptrs->ptrimageRGBRecipeBlue[i_image1] = (quint8)blue; + + // row_col[3711 - pixelx] = qRgb((int)red, (int)green, (int)blue); + // } + // } for (int line = (opts.geosatellites.at(geoindex).rss ? 5 * 464 : 0); line < 3712; line++) @@ -3503,16 +5039,16 @@ void SegmentListGeostationary::ComposeGeoRGBRecipeInThread(int recipe) qDebug() << "Kind of image = " << kindofimage; - emit signalcomposefinished(kindofimage); + emit signalcomposefinished(kindofimage, geoindex); emit progressCounter(100); ////////////////////////////////////////////////// // Cleaup ////////////////////////////////////////////////// -// delete [] pixelsRed; -// delete [] pixelsGreen; -// delete [] pixelsBlue; + // delete [] pixelsRed; + // delete [] pixelsGreen; + // delete [] pixelsBlue; for(int i = 0; i < uniquebandlist.length(); i++) { @@ -3543,9 +5079,9 @@ void SegmentListGeostationary::ComposeGeoRGBRecipeInThread(int recipe) void SegmentListGeostationary::ComposeDayMicrophysicsRGB(bandstorage &bs, double julian_day) { -// Red VIS008 0 --> 100 % Gamma 1.0 -// Green IR3.9Refl 0 --> 60 % Gamma 2.5 -// Blue IR10.8 203 --> 323 K Gamma 1.0 + // Red VIS008 0 --> 100 % Gamma 1.0 + // Green IR3.9Refl 0 --> 60 % Gamma 2.5 + // Blue IR10.8 203 --> 323 K Gamma 1.0 //VIS006 1 //VIS008 2 @@ -3708,7 +5244,7 @@ void SegmentListGeostationary::ComposeDayMicrophysicsRGB(bandstorage &bs, double if (rad039[i_image] != FILL_VALUE_F && rad039[i_image] > 0 && vza[i_image] < 89.0) { result[0][i_image] = ref008[i_image]; -// result[1][i_image] = 100 * (rad039[i_image] - r_therm[i_image]) / (toarad[i_image] - r_therm[i_image]); + // result[1][i_image] = 100 * (rad039[i_image] - r_therm[i_image]) / (toarad[i_image] - r_therm[i_image]); result[1][i_image] = 100 * (rad039[i_image] - r_therm[i_image]); // / cos(vza[i_image] * D2R); result[2][i_image] = bt108[i_image]; } @@ -4167,17 +5703,17 @@ void SegmentListGeostationary::Printbands() cout << endl; } -// cout << "sza " << endl; -// for (int i = 1000; i < 1000 + 10; ++i) -// { -// for (int j = 1856; j < 1856 + 10; ++j) -// { -// int i_image = i * 3712 + j; + // cout << "sza " << endl; + // for (int i = 1000; i < 1000 + 10; ++i) + // { + // for (int j = 1856; j < 1856 + 10; ++j) + // { + // int i_image = i * 3712 + j; -// cout << sza[i_image] << " "; -// } -// cout << endl; -// } + // cout << sza[i_image] << " "; + // } + // cout << endl; + // } } @@ -4203,12 +5739,14 @@ void SegmentListGeostationary::PrintResults() void SegmentListGeostationary::PrintResults(float *ptr, QString title) { + int fromY = 1856; + int fromX = 20; cout << title.toStdString() << endl; - for (int i = 1000; i < 1000 + 10; ++i) + for (int y = fromY; y < fromY + 10; ++y) { - for (int j = 1856; j < 1856 + 10; ++j) + for (int x = fromX; x < fromX + 30; ++x) { - int i_image = i * 3712 + j; + int i_image = y * 3712 + x; cout << ptr[i_image] << " "; } @@ -4220,180 +5758,259 @@ void SegmentListGeostationary::PrintResults(float *ptr, QString title) void SegmentListGeostationary::CalculateGeoRadiances(bandstorage &bs) { - qDebug() << QString("ComposeGeoRGBRecipe %1 %2").arg(bs.listindex).arg(bs.productid2); - - MsgFileAccess fac(bs.directory, "H", bs.productid1, bs.productid2, bs.timing); - MsgDataAccess da; - MSG_header header; - - da.scan(fac, header); - MSG_SAMPLE compmin = 0xffff, compmax = 0; - for (size_t j = 0; j < da.segnames.size(); ++j) - { - cout << "Segment " << j << ": "; - MSG_data* d = da.segment(j); - MSG_SAMPLE min = 0xffff, max = 0; - if (!d) - { - cout << "missing.\n"; - continue; - } else { - for (size_t k = 0; k < da.npixperseg; ++k) - { - if(d->image->data[k] > 0) - { - bands[bs.listindex].data[j*da.npixperseg + k] = d->image->data[k]; - if (d->image->data[k] < min) min = d->image->data[k]; - if (d->image->data[k] > max) max = d->image->data[k]; - } - } - cout << "min " << min << " max " << max << endl; - } - if (min < compmin) compmin = min; - if (max > compmax) compmax = max; - } - cout << "compmin = " << compmin << " compmax = " << compmax << endl; - bands[bs.listindex].min = (float)compmin; - bands[bs.listindex].max = (float)compmax; - - - /*------------------------------------------------------------------------- + qDebug() << QString("ComposeGeoRGBRecipe %1 %2").arg(bs.listindex).arg(bs.productid2); + + MsgFileAccess fac(bs.directory, "H", bs.productid1, bs.productid2, bs.timing); + MsgDataAccess da; + MSG_header header; + + da.scan(fac, header); + MSG_SAMPLE compmin = 0xffff, compmax = 0; + for (size_t j = 0; j < da.segnames.size(); ++j) + { + cout << "Segment " << j << ": "; + MSG_data* d = da.segment(j); + MSG_SAMPLE min = 0xffff, max = 0; + if (!d) + { + cout << "missing.\n"; + continue; + } else { + for (size_t k = 0; k < da.npixperseg; ++k) + { + if(d->image->data[k] > 0) + { + bands[bs.listindex].data[j*da.npixperseg + k] = d->image->data[k]; + if (d->image->data[k] < min) min = d->image->data[k]; + if (d->image->data[k] > max) max = d->image->data[k]; + } + } + cout << "min " << min << " max " << max << endl; + } + if (min < compmin) compmin = min; + if (max > compmax) compmax = max; + } + cout << "compmin = " << compmin << " compmax = " << compmax << endl; + bands[bs.listindex].min = (float)compmin; + bands[bs.listindex].max = (float)compmax; + + + /*------------------------------------------------------------------------- * Compute radiance for the bands requested. * * Ref: PDF_TEN_05105_MSG_IMG_DATA, Page 26 *-----------------------------------------------------------------------*/ - double slope, offset; - bool toint; - - if(bands[bs.listindex].units == SEVIRI_UNIT_RAD) // mW*pow(m,-2)*pow(sr,-1)*pow(pow(cm,-1)), -1) - { - bands[bs.listindex].min = std::numeric_limits::max(); - bands[bs.listindex].max = std::numeric_limits::min(); - for (int j = 0; j < 3712; ++j) - { - for (int k = 0; k < 3712; ++k) - { - int i_image = j * 3712 + k; - - if (bands[bs.listindex].data[i_image] != FILL_VALUE_F && bands[bs.listindex].data[i_image] > 0) - { - bands[bs.listindex].data[i_image] = bands[bs.listindex].data[i_image] * bs.slope + bs.offset; - bands[bs.listindex].data[i_image] = bands[bs.listindex].data[i_image] < 0 ? 0 : bands[bs.listindex].data[i_image]; - if(bands[bs.listindex].data[i_image] < bands[bs.listindex].min) bands[bs.listindex].min = bands[bs.listindex].data[i_image]; - if(bands[bs.listindex].data[i_image] > bands[bs.listindex].max) bands[bs.listindex].max = bands[bs.listindex].data[i_image]; - } - } - } - } - - - if(bands[bs.listindex].units == SEVIRI_UNIT_RAD) - { - qDebug() << QString("Radiances %1 minimum = %2 maximum = %3").arg(bands[bs.listindex].productid2).arg(bands[bs.listindex].min).arg(bands[bs.listindex].max); - } - - /*------------------------------------------------------------------------- + double slope, offset; + bool toint; + + if(bands[bs.listindex].units == SEVIRI_UNIT_RAD) // mW*pow(m,-2)*pow(sr,-1)*pow(pow(cm,-1)), -1) + { + bands[bs.listindex].min = std::numeric_limits::max(); + bands[bs.listindex].max = std::numeric_limits::min(); + for (int j = 0; j < 3712; ++j) + { + for (int k = 0; k < 3712; ++k) + { + int i_image = j * 3712 + k; + + if (bands[bs.listindex].data[i_image] != FILL_VALUE_F && bands[bs.listindex].data[i_image] > 0) + { + bands[bs.listindex].data[i_image] = bands[bs.listindex].data[i_image] * bs.slope + bs.offset; + bands[bs.listindex].data[i_image] = bands[bs.listindex].data[i_image] < 0 ? 0 : bands[bs.listindex].data[i_image]; + if(bands[bs.listindex].data[i_image] < bands[bs.listindex].min) bands[bs.listindex].min = bands[bs.listindex].data[i_image]; + if(bands[bs.listindex].data[i_image] > bands[bs.listindex].max) bands[bs.listindex].max = bands[bs.listindex].data[i_image]; + } + } + } + } + + + if(bands[bs.listindex].units == SEVIRI_UNIT_RAD) + { + qDebug() << QString("Radiances %1 minimum = %2 maximum = %3").arg(bands[bs.listindex].productid2).arg(bands[bs.listindex].min).arg(bands[bs.listindex].max); + } + + /*------------------------------------------------------------------------- * Compute reflectance or bidirectional reflectance factor (BRF) for the * bands requested. * * Ref: PDF_MSG_SEVIRI_RAD2REFL, Page 8 *-----------------------------------------------------------------------*/ - //double dd = 1. / sqrt(snu_solar_distance_factor2(day_of_year)); // distance earth-sun - //double a = PI * dd * dd; - double a = PI / snu_solar_distance_factor2(bs.day_of_year); + //double dd = 1. / sqrt(snu_solar_distance_factor2(day_of_year)); // distance earth-sun + //double a = PI * dd * dd; + double a = PI / snu_solar_distance_factor2(bs.day_of_year); - int satid = (int)header.segment_id->spacecraft_id - 321 ; + int satid = (int)header.segment_id->spacecraft_id - 321 ; - if (bands[bs.listindex].units == SEVIRI_UNIT_REF || bands[bs.listindex].units == SEVIRI_UNIT_BRF) - { - bands[bs.listindex].min = std::numeric_limits::max(); - bands[bs.listindex].max = std::numeric_limits::min(); + if (bands[bs.listindex].units == SEVIRI_UNIT_REF || bands[bs.listindex].units == SEVIRI_UNIT_BRF) + { + bands[bs.listindex].min = std::numeric_limits::max(); + bands[bs.listindex].max = std::numeric_limits::min(); - double b = a / band_solar_irradiance[satid][bands[bs.listindex].spectral_channel_nbr - 1]; + double b = a / band_solar_irradiance[satid][bands[bs.listindex].spectral_channel_nbr - 1]; - for (int j = 0; j < 3712; ++j) - { - for (int k = 0; k < 3712; ++k) - { - int i_image = j * 3712 + k; + for (int j = 0; j < 3712; ++j) + { + for (int k = 0; k < 3712; ++k) + { + int i_image = j * 3712 + k; - if (bands[bs.listindex].units == SEVIRI_UNIT_BRF && bands[bs.listindex].data[i_image] != FILL_VALUE_F && bands[bs.listindex].data[i_image] > 0) - { - if(sza[i_image] >= 0. && sza[i_image] < 89.0) - { - double R = bands[bs.listindex].data[i_image] * bs.slope + bs.offset; + if (bands[bs.listindex].units == SEVIRI_UNIT_BRF && bands[bs.listindex].data[i_image] != FILL_VALUE_F && bands[bs.listindex].data[i_image] > 0) + { + if(sza[i_image] >= 0. && sza[i_image] < 89.0) + { + double R = bands[bs.listindex].data[i_image] * bs.slope + bs.offset; - bands[bs.listindex].data[i_image] = b * R; + bands[bs.listindex].data[i_image] = b * R; - if (bands[bs.listindex].units == SEVIRI_UNIT_BRF) - bands[bs.listindex].data[i_image] /= cos(sza[i_image] * D2R); + if (bands[bs.listindex].units == SEVIRI_UNIT_BRF) + bands[bs.listindex].data[i_image] /= cos(sza[i_image] * D2R); - bands[bs.listindex].data[i_image] = bands[bs.listindex].data[i_image] < 0.0 ? 0.0 : bands[bs.listindex].data[i_image]; + bands[bs.listindex].data[i_image] = bands[bs.listindex].data[i_image] < 0.0 ? 0.0 : bands[bs.listindex].data[i_image]; - if(bands[bs.listindex].data[i_image] < bands[bs.listindex].min) bands[bs.listindex].min = bands[bs.listindex].data[i_image]; - if(bands[bs.listindex].data[i_image] > bands[bs.listindex].max) bands[bs.listindex].max = bands[bs.listindex].data[i_image]; - } - else - bands[bs.listindex].data[i_image] = FILL_VALUE_F; - } - else if (bands[bs.listindex].units == SEVIRI_UNIT_REF && bands[bs.listindex].data[i_image] != FILL_VALUE_F && bands[bs.listindex].data[i_image] > 0) - { - double R = bands[bs.listindex].data[i_image] * bs.slope + bs.offset; + if(bands[bs.listindex].data[i_image] < bands[bs.listindex].min) bands[bs.listindex].min = bands[bs.listindex].data[i_image]; + if(bands[bs.listindex].data[i_image] > bands[bs.listindex].max) bands[bs.listindex].max = bands[bs.listindex].data[i_image]; + } + else + bands[bs.listindex].data[i_image] = FILL_VALUE_F; + } + else if (bands[bs.listindex].units == SEVIRI_UNIT_REF && bands[bs.listindex].data[i_image] != FILL_VALUE_F && bands[bs.listindex].data[i_image] > 0) + { + double R = bands[bs.listindex].data[i_image] * bs.slope + bs.offset; - bands[bs.listindex].data[i_image] = b * R; + bands[bs.listindex].data[i_image] = b * R; - if(bands[bs.listindex].data[i_image] < bands[bs.listindex].min) bands[bs.listindex].min = bands[bs.listindex].data[i_image]; - if(bands[bs.listindex].data[i_image] > bands[bs.listindex].max) bands[bs.listindex].max = bands[bs.listindex].data[i_image]; - } - } - } - } + if(bands[bs.listindex].data[i_image] < bands[bs.listindex].min) bands[bs.listindex].min = bands[bs.listindex].data[i_image]; + if(bands[bs.listindex].data[i_image] > bands[bs.listindex].max) bands[bs.listindex].max = bands[bs.listindex].data[i_image]; + } + } + } + } - const double c1 = 1.19104e-5; // [mW m^-2 sr^-1 (cm^-1)^-4 - const double c2 = 1.43877; // K (cm^-1)^-1 + const double c1 = 1.19104e-5; // [mW m^-2 sr^-1 (cm^-1)^-4 + const double c2 = 1.43877; // K (cm^-1)^-1 - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * Compute brightness temperature for the bands requested. * * Ref: PDF_TEN_05105_MSG_IMG_DATA, Page 26 * Ref: The Conversion from Effective Radiances * to Equivalent Brightness Temperatures (EUM/MET/TEN/11/0569) *-----------------------------------------------------------------------*/ - if (bands[bs.listindex].units == SEVIRI_UNIT_BT) - { - bands[bs.listindex].min = std::numeric_limits::max(); - bands[bs.listindex].max = std::numeric_limits::min(); + if (bands[bs.listindex].units == SEVIRI_UNIT_BT) + { + bands[bs.listindex].min = std::numeric_limits::max(); + bands[bs.listindex].max = std::numeric_limits::min(); - qDebug() << bands[bs.listindex].spectral_channel_nbr << " " << bands[bs.listindex].productid2 << " slope = " << bs.slope << " offset = " << bs.offset; - /* + qDebug() << bands[bs.listindex].spectral_channel_nbr << " " << bands[bs.listindex].productid2 << " slope = " << bs.slope << " offset = " << bs.offset; + /* nu = 1.e4 / channel_center_wavelength[d->image.band_ids[bs.listindex] - 1]; */ - double nu = bt_nu_c[satid][bands[bs.listindex].spectral_channel_nbr - 1]; - double nu3 = nu * nu * nu; + double nu = bt_nu_c[satid][bands[bs.listindex].spectral_channel_nbr - 1]; + double nu3 = nu * nu * nu; + + double a = bt_A[satid][bands[bs.listindex].spectral_channel_nbr - 1]; + double b = bt_B[satid][bands[bs.listindex].spectral_channel_nbr - 1]; + + for (int j = 0; j < 3712; ++j) + { + for (int k = 0; k < 3712; ++k) + { + int i_image = j * 3712 + k; + + if (bands[bs.listindex].data[i_image] != FILL_VALUE_F && bands[bs.listindex].data[i_image] > 0) + { + double L = bands[bs.listindex].data[i_image] * bs.slope + bs.offset; + + bands[bs.listindex].data[i_image] = (c2 * nu / log(1. + nu3 * c1 / L) - b) / a; + + if(bands[bs.listindex].data[i_image] < bands[bs.listindex].min) bands[bs.listindex].min = bands[bs.listindex].data[i_image]; + if(bands[bs.listindex].data[i_image] > bands[bs.listindex].max) bands[bs.listindex].max = bands[bs.listindex].data[i_image]; + } + } + } + } + + qDebug() << QString("%1 minimum = %2 maximum = %3").arg(bands[bs.listindex].productid2).arg(bands[bs.listindex].min).arg(bands[bs.listindex].max); + +} - double a = bt_A[satid][bands[bs.listindex].spectral_channel_nbr - 1]; - double b = bt_B[satid][bands[bs.listindex].spectral_channel_nbr - 1]; +void SegmentListGeostationary::CalculateLonLat() +{ + unsigned int i_image; + int totalpixels = 3712 * 3712; + + lon = new float[totalpixels]; + lat = new float[totalpixels]; + snu_init_array_f(lon, totalpixels, FILL_VALUE_F); + snu_init_array_f(lat, totalpixels, FILL_VALUE_F); + + pixgeoConversion pixconv; + + double templat; + double templon; + + +// for (int y = 0; y < 3712; ++y) +// { +// for (int x = 0; x < 3712; ++x) +// { +// i_image = y * 3712 + x; + +// if(pixconv.pixcoord2geocoord( lon0, x, y, nav_scaling_factors_vir.COFF, nav_scaling_factors_vir.LOFF, +// nav_scaling_factors_vir.CFAC, nav_scaling_factors_vir.LFAC, &templat, &templon) == 0) +// { +// lat[i_image] = templat; +// lon[i_image] = templon; +// } +// else +// { +// lat[i_image] = FILL_VALUE_F; +// lon[i_image] = FILL_VALUE_F; + +// } +// } +// } + + + for (int y = 0; y < 3712; ++y) + { + for (int x = 0; x < 3712; ++x) + { + i_image = y * 3712 + x; + + snu_line_column_to_lat_lon(y, x, &lat[i_image], &lon[i_image], lon0, &nav_scaling_factors_vir); + } + } + + +} - for (int j = 0; j < 3712; ++j) - { - for (int k = 0; k < 3712; ++k) - { - int i_image = j * 3712 + k; +QImage *SegmentListGeostationary::CalculateBitMap() +{ + imageptrs->ptrimagebitmap = new QImage(imageptrs->ptrimageGeostationary->width(), imageptrs->ptrimageGeostationary->height(), QImage::Format_ARGB32); + QPainter painter(imageptrs->ptrimagebitmap); + + painter.translate(imageptrs->ptrimageGeostationary->width()/2, imageptrs->ptrimageGeostationary->height()/2); - if (bands[bs.listindex].data[i_image] != FILL_VALUE_F && bands[bs.listindex].data[i_image] > 0) - { - double L = bands[bs.listindex].data[i_image] * bs.slope + bs.offset; - bands[bs.listindex].data[i_image] = (c2 * nu / log(1. + nu3 * c1 / L) - b) / a; + int diameter = 3630; // 3615; + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::red); + painter.drawEllipse(QRect(-diameter / 2, -diameter / 2, diameter, diameter)); - if(bands[bs.listindex].data[i_image] < bands[bs.listindex].min) bands[bs.listindex].min = bands[bs.listindex].data[i_image]; - if(bands[bs.listindex].data[i_image] > bands[bs.listindex].max) bands[bs.listindex].max = bands[bs.listindex].data[i_image]; - } - } - } - } + diameter = 3600; // 3615; + //painter.setPen(QPen(QColor(1,1,1))); + painter.setBrush(QColor(1,1,1)); + painter.drawEllipse(QRect(-diameter / 2, -diameter / 2, diameter, diameter)); - qDebug() << QString("%1 minimum = %2 maximum = %3").arg(bands[bs.listindex].productid2).arg(bands[bs.listindex].min).arg(bands[bs.listindex].max); + QRgb *row; + row = (QRgb *)imageptrs->ptrimagebitmap->scanLine(200); + for(int x = 0; x < 3712; x++) + { + qDebug() << QString("val = %1").arg(qRed(row[x])); + } + return(imageptrs->ptrimagebitmap); } diff --git a/core/segmentlistgeostationary.h b/core/segmentlistgeostationary.h index 6adbce6..6db9108 100644 --- a/core/segmentlistgeostationary.h +++ b/core/segmentlistgeostationary.h @@ -38,12 +38,13 @@ class SegmentListGeostationary : public QObject //bool ComposeImageHDFSerial(QFileInfo fileinfo, QVector spectrumvector, QVector inversevector); bool ComposeImageHDFInThread(QStringList strlist, QVector spectrumvector, QVector inversevector); bool ComposeImagenetCDFInThread(QStringList strlist, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor); + bool ComposeImagenetCDFMTGInThread(QStringList strlist, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor); void displayMinMax(); void CalculateMinMax(int width, int height, quint16 *ptr, quint16 &stat_min, quint16 &stat_max); void CalculateMinMax(int colorindex, int width, int height, quint16 *ptr, quint16 fillvalue); void CalculateMinMaxHimawari(int width, int height, quint16 *ptr, quint16 &stat_min, quint16 &stat_max); - void normalizeMinMaxGOES16(int width, int height, quint16 *ptr, quint16 &stat_min, quint16 &stat_max, int &fillvalue, int maxvalue); + void normalizeMinMax(int width, int height, quint16 *ptr, quint16 &stat_min, quint16 &stat_max, int &fillvalue, int maxvalue); QString getKindofImage() { return kindofimage; } QString getImagePath() { return imagepath; } @@ -58,6 +59,8 @@ class SegmentListGeostationary : public QObject void ComposeSegmentImageHDF(QFileInfo fileinfo, int channelindex, QVector spectrumvector, QVector inversevector ); void ComposeSegmentImageHDFInThread(QStringList filelist, QVector spectrumvector, QVector inversevector ); void ComposeSegmentImagenetCDFInThread(); + void ComposeSegmentImagenetCDFMTGInThread(); + void ComposeSegmentImagenetCDFMTGInThreadConcurrent(); void SetupContrastStretch(quint16 x1, quint16 y1, quint16 x2, quint16 y2); quint16 ContrastStretch(quint16 val); void InsertPresent( QVector spectrumvector, QString filespectrum, int filesequence); @@ -71,6 +74,14 @@ class SegmentListGeostationary : public QObject void setGeoSatellite(int geoindex, QString strgeo); void CalculateLUTGeo(int colorindex); void CalculateLUTGeo(int colorindex, quint16 *ptr, quint16 fillvalue); + void CalculateLUTGeoMTG(int colorindex); + void CalculateLUTGeoMTG256(int colorindex); + + void CalculateMinMaxMTG(int colorindex, int index); + void CalculateLUTGeoMTGConcurrent(int colorindex, int index); + void CalculateImageMTGConcurrent(int index); + + void ComposeGeoRGBRecipe(int recipe, QString tex); void ComposeGeoRGBRecipeInThread(int recipe); @@ -78,6 +89,7 @@ class SegmentListGeostationary : public QObject static void doComposeGeostationaryXRITHimawari(SegmentListGeostationary *sm, QString segment_path, int channelindex, QVector spectrumvector, QVector inversevector); static void doComposeGeostationaryHDFInThread(SegmentListGeostationary *sm, QStringList filelist, QVector spectrumvector, QVector inversevector); static void doComposeGeostationarynetCDFInThread(SegmentListGeostationary *sm); + static void doComposeGeostationarynetCDFMTGInThread(SegmentListGeostationary *sm); static void doComposeGeoRGBRecipe(SegmentListGeostationary *sm, int recipe); void CalculateGeoRadiances(bandstorage &bs); void setThreadParameters(QStringList strlist, QVector spectrumvector, QVector inversevector, int histogrammethod, bool pseudocolor); @@ -122,6 +134,7 @@ class SegmentListGeostationary : public QObject void ComposeHRV(); void ComposeVISIR(); + void ComposeVISIR_Alt(); void ComposeVISIRHimawari(); void getFilenameParameters(QFileInfo fileinfo, QString &filespectrum, QString &filedate, int &filesequence); void Printbands(); @@ -130,6 +143,14 @@ class SegmentListGeostationary : public QObject void GetRadBT(int unit, int channel, bandstorage &bs, float *container); QString getSeviribandfromChannel(int channel); + void CalcImage(); + static int concurrentMinMax(SegmentListGeostationary *sm, const int &index); + static int concurrentLUTGeoMTG(SegmentListGeostationary *sm, const int &index); + static int concurrentImageMTG(SegmentListGeostationary *sm, const int &index); + + void CalculateLonLat(); + QImage *CalculateBitMap(); + quint16 stat_min[3]; quint16 stat_max[3]; @@ -158,19 +179,31 @@ class SegmentListGeostationary : public QObject float *lat; float *lon; + double lon0; + float *sza; /* image of solar zenith angle (degrees: 0.0 -- 180.0) */ float *saa; /* image of solar azimuth angle (degrees: 0.0 -- 360.0) */ float *vza; /* image of viewing zenith angle (degrees: 0.0 -- 180.0) */ float *vaa; /* image of viewing azimuth angle (degrees: 0.0 -- 360.0) */ QString tex; int satid; +// quint16 total_number_of_rows[3]; +// quint16 total_number_of_columns[3]; + +// quint16 start_position_row[3][40]; +// quint16 end_position_row[3][40]; +// quint16 start_position_column[3][40]; +// quint16 end_position_column[3][40]; + + + signals: void progressCounter(int val); - void signalcomposefinished(QString kindofimage); + void signalcomposefinished(QString kindofimage, int index); public slots: