Skip to content

Commit

Permalink
Overlay moon on Himawari-9 images
Browse files Browse the repository at this point in the history
  • Loading branch information
hvanruys committed Jan 28, 2024
1 parent 96d0b83 commit b672947
Show file tree
Hide file tree
Showing 14 changed files with 483 additions and 134 deletions.
1 change: 1 addition & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ set(PROJECT_SOURCES_CPP
nav_util.cpp
ColorSpace.cpp
Conversion.cpp
moon.cpp
mainwindow.ui
dialogpreferences.ui
formephem.ui
Expand Down
3 changes: 2 additions & 1 deletion core/formephem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ void FormEphem::getSegmentsForCalendar()

NewSegmentOverviewItem();

emit signalDirectoriesRead();
emit signalDirectoriesRead(ui->calendar->selectedDate());
emit signalSetScrollBarMaximum();
}

void FormEphem::NewSegmentOverviewItem()
Expand Down
3 changes: 2 additions & 1 deletion core/formephem.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public slots:

signals:
void signalSegmenttype( const QString &text );
void signalDirectoriesRead();
void signalDirectoriesRead(QDate);
void signalSetScrollBarMaximum();
void signalDatagram(QByteArray);


Expand Down
283 changes: 182 additions & 101 deletions core/formgeostationary.cpp

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions core/formgeostationary.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,14 @@ class FormGeostationary : public QWidget
void CreateGeoImages(QString type, QVector<QString> spectrumvector, QVector<bool> inversevector, int histogrammethod, bool pseudocolor, QString tex, int geoindex);
void CreateGeoImageMTG(QString type, QVector<QString> spectrumvector, QVector<bool> inversevector,int histogrammethod, bool pseudocolor, QString tex, int geoindex);

inline double MapToMinus180To180Range(double Degrees);


Ui::FormGeostationary *ui;
AVHRRSatellite *segs;
FormToolbox *formtoolbox;
FormImage *formimage;
QList<QTreeWidget *> geotreewidgetlist;
QList<double> geolonlist;



public slots:
void PopulateTree();
void PopulateTree(QDate seldate);
void slotCreateGeoImage(QString type, QVector<QString> spectrumvector, QVector<bool> inversevector, int histogrammethod, bool pseudocolor);
void slotCreateRGBrecipe(int recipe);

Expand Down
42 changes: 37 additions & 5 deletions core/formimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "satellite.h"
#include "ColorSpace.h"
#include "Conversion.h"
#include "AA+.h"
#include "moon.h"

#include <QDebug>
#include <QMessageBox>
Expand Down Expand Up @@ -40,6 +40,7 @@ FormImage::FormImage(QWidget *parent, AVHRRSatellite *seglist) :
overlaymeteosat = true;
overlayprojection = true;
overlayolci = true;
overlaymoon = true;

metopcount = 0;
noaacount = 0;
Expand Down Expand Up @@ -74,6 +75,16 @@ bool FormImage::toggleOverlayMeteosat()
return overlaymeteosat;
}

bool FormImage::toggleOverlayMoon()
{
if(overlaymoon)
overlaymoon = false;
else
overlaymoon = true;
m_scene->update();
return overlaymoon;
}

bool FormImage::toggleOverlayOLCI()
{
if(overlayolci)
Expand Down Expand Up @@ -2568,11 +2579,32 @@ void FormImage::OverlayGeostationaryH9(QPainter *paint, SegmentListGeostationary
first = true;
}

QPoint pt(opts.geosatellites.at(geoindex).coff, opts.geosatellites.at(geoindex).loff);
paint->setPen(Qt::red);
paint->drawEllipse(pt, opts.geosatellites.at(geoindex).coff - 28, opts.geosatellites.at(geoindex).loff - 40);

// QPoint pt(opts.geosatellites.at(geoindex).coff, opts.geosatellites.at(geoindex).loff);
// paint->setPen(Qt::red);
// paint->drawEllipse(pt, opts.geosatellites.at(geoindex).coff - 28, opts.geosatellites.at(geoindex).loff - 40);

moonCalc obj;
float scale = 313.873;

paint->setPen(Qt::yellow);
if(overlaymoon)
{
for(int i = 0; i < 144; i++)
{
if(obj.moonIsVisible(i) > 0)
{
int h, m;
obj.getTimeFromIndex(i, &h, &m);
qDebug() << "h = " << h << " m = " << m << " moon is visible = " << obj.moonIsVisible(i) << " moonCoordX = " << obj.moonCoordX[i] << " moonCoordY = " << obj.moonCoordY[i];
paint->drawEllipse(obj.moonCoordX[i] - 0.25*scale, obj.moonCoordY[i] - 0.25*scale, 0.5*scale, 0.5*scale);
QFont serifFont("Times", 20, QFont::Bold);
paint->setFont(serifFont);
QString txt = QString("%1:%2").arg(h, 2, 'f', 0, '0').arg(m, 2, 'f', 0, '0');
paint->drawText(obj.moonCoordX[i] - 20, obj.moonCoordY[i], txt);
}
}
}
// paint->setPen(Qt::red);
// paint->drawRect(28, 38, 5453-10, 5444-20);
// paint->drawEllipse(28, 38, 5453-10, 5444-20);

Expand Down
2 changes: 2 additions & 0 deletions core/formimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class FormImage : public QGraphicsView
bool toggleOverlayMeteosat();
bool toggleOverlayProjection();
bool toggleOverlayOLCI();
bool toggleOverlayMoon();
bool toggleOverlayGridOnOLCI();

bool ShowVIIRSMImage();
Expand Down Expand Up @@ -120,6 +121,7 @@ class FormImage : public QGraphicsView
bool overlaymeteosat;
bool overlayprojection;
bool overlayolci;
bool overlaymoon;


int metopcount;
Expand Down
12 changes: 12 additions & 0 deletions core/formtoolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ FormToolbox::FormToolbox(QWidget *parent, FormImage *p_formimage, FormGeostation

ui->btnOverlayMeteosat->setText("Overlay On");
ui->btnOverlayOLCI->setText("Overlay On");
ui->btnOverlayMoon->setText("Moon On");
ui->btnOverlayProjectionGVP->setText("Overlay On");
ui->btnOverlayProjectionLCC->setText("Overlay On");
ui->btnOverlayProjectionSG->setText(("Overlay On"));
Expand Down Expand Up @@ -1560,6 +1561,15 @@ void FormToolbox::on_btnOverlayMeteosat_clicked()
ui->btnOverlayMeteosat->setText("Overlay Off");
}

void FormToolbox::on_btnOverlayMoon_clicked()
{
if(formimage->toggleOverlayMoon())
ui->btnOverlayMoon->setText("Moon On");
else
ui->btnOverlayMoon->setText("Moon Off");

}

void FormToolbox::on_btnOverlayOLCI_clicked()
{
if(formimage->toggleOverlayOLCI())
Expand Down Expand Up @@ -6283,3 +6293,5 @@ void FormToolbox::on_btnUpdateAVHRRImage_clicked()

}



1 change: 1 addition & 0 deletions core/formtoolbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ private slots:
void on_cbProjResolutions_activated(int index);
void on_hslRed_valueChanged(int value);
void on_btnUpdateAVHRRImage_clicked();
void on_btnOverlayMoon_clicked();
};


Expand Down
39 changes: 23 additions & 16 deletions core/formtoolbox.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6753,6 +6753,27 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnTextureMet">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="toolTip">
<string>Meteosat image on texture</string>
</property>
<property name="text">
<string>Texture Off</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_144">
<property name="orientation">
Expand Down Expand Up @@ -6987,23 +7008,9 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="btnTextureMet">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="toolTip">
<string>Meteosat image on texture</string>
</property>
<widget class="QPushButton" name="btnOverlayMoon">
<property name="text">
<string>Texture Off</string>
<string>Moon</string>
</property>
</widget>
</item>
Expand Down
6 changes: 4 additions & 2 deletions core/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ MainWindow::MainWindow(QWidget *parent) :
formephem = new FormEphem(this, seglist);
ui->stackedWidget->addWidget(formephem); // index 0


//formtoolbox = NULL;

formgeostationary = new FormGeostationary(this, seglist);
Expand Down Expand Up @@ -152,13 +153,14 @@ MainWindow::MainWindow(QWidget *parent) :

connect(seglist, SIGNAL(signalXMLProgress(QString, int, bool)), formglobecyl, SLOT(slotShowXMLProgress(QString, int, bool)));


connect( formglobecyl, SIGNAL(signalSegmentChanged(QString)), this, SLOT(updateStatusBarIndicator(QString)) );
connect( ui->stackedWidget, SIGNAL(currentChanged(int)),formglobecyl, SLOT(updatesatmap(int)) );
connect( formephem,SIGNAL(signalDirectoriesRead()), formgeostationary, SLOT(PopulateTree()) );
connect( formephem,SIGNAL(signalDirectoriesRead(QDate)), formgeostationary, SLOT(PopulateTree(QDate)) );
connect( seglist,SIGNAL(signalAddedSegmentlist()), formephem, SLOT(showSegmentsAdded()));
connect( seglist,SIGNAL(signalAddedSegmentlist()), formglobecyl, SLOT(slotShowSegmentCount()));

connect( formephem,SIGNAL(signalDirectoriesRead()), formglobecyl, SLOT(setScrollBarMaximum()));
connect( formephem,SIGNAL(signalSetScrollBarMaximum()), formglobecyl, SLOT(setScrollBarMaximum()));
connect( formglobecyl, SIGNAL(signalMakeImage()), formimage, SLOT(slotMakeImage()));

if(opts.doOpenGL)
Expand Down
Loading

0 comments on commit b672947

Please sign in to comment.