Skip to content

Commit 80a8cf9

Browse files
authored
Merge pull request #698 from firelab/GUI-Redesign-Demo
Changes to the GUI for Demo
2 parents cbb4080 + a2702d7 commit 80a8cf9

4 files changed

Lines changed: 156 additions & 116 deletions

File tree

data/map.html

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,22 @@
347347
return container;
348348
};
349349

350+
let kmzTimeSeriesImg = null;
351+
let kmzTimeSeriesImgUrl = null;
352+
350353
async function loadKmzFromBase64(kmlData, timeSeries) {
351354
// Setup & Cleanup
352355
clearWindNinjaOutputTree();
356+
clearInitializationOutputTree();
357+
358+
if (kmzTimeSeriesImg) {
359+
kmzTimeSeriesImg.remove();
360+
kmzTimeSeriesImg = null;
361+
}
362+
if (kmzTimeSeriesImgUrl) {
363+
URL.revokeObjectURL(kmzTimeSeriesImgUrl);
364+
kmzTimeSeriesImgUrl = null;
365+
}
353366

354367
const binary = atob(kmlData);
355368
const bytes = new Uint8Array(binary.length);
@@ -380,6 +393,9 @@
380393
const kmlLegendLayer = L.layerGroup([kmlLayer]);
381394
const layerName = entry.name;
382395

396+
let timeSeriesImg = null;
397+
let timeSeriesImgUrl = null;
398+
383399
const legendControl = L.control({ position: 'bottomright' });
384400
kmzLegendControls.push(legendControl);
385401

@@ -397,20 +413,35 @@
397413
img.style.cssText = 'display: block; max-width: 150px; height: auto;';
398414
container.appendChild(img);
399415

400-
// Legend Time Series
401-
if (timeSeries && legendEntries.length > 1) {
402-
const blob2 = await legendEntries[1].async('blob');
403-
const url2 = URL.createObjectURL(blob2);
404-
const img2 = new Image();
405-
img2.src = url2;
406-
img2.style.cssText = `
407-
position: absolute; top: 10px; left: 50%;
408-
transform: translateX(-50%); max-width: 90%;
409-
height: auto; z-index: 600;
416+
if (timeSeries && legendEntries.length > 1 && !timeSeriesImg) {
417+
const blob = await legendEntries[1].async('blob');
418+
timeSeriesImgUrl = URL.createObjectURL(blob);
419+
420+
timeSeriesImg = new Image();
421+
timeSeriesImg.src = timeSeriesImgUrl;
422+
timeSeriesImg.style.cssText = `
423+
position: absolute;
424+
top: 10px;
425+
left: 50%;
426+
transform: translateX(-50%);
427+
max-width: 90%;
428+
height: auto;
429+
z-index: 600;
410430
`;
411-
map.getContainer().appendChild(img2);
412-
}
431+
432+
map.getContainer().appendChild(timeSeriesImg);
433+
}
413434
})();
435+
kmlLegendLayer.on('remove', () => {
436+
if (timeSeriesImg) {
437+
timeSeriesImg.remove();
438+
timeSeriesImg = null;
439+
}
440+
if (timeSeriesImgUrl) {
441+
URL.revokeObjectURL(timeSeriesImgUrl);
442+
timeSeriesImgUrl = null;
443+
}
444+
});
414445
}
415446
return container;
416447
};

src/gui/mainWindow.cpp

Lines changed: 104 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,116 +1599,116 @@ void MainWindow::plotKmzOutputs()
15991599

16001600
void MainWindow::writeSettings()
16011601
{
1602-
writeToConsole("Saving settings...");
1603-
1604-
QSettings settings(QSettings::UserScope, "Firelab", "WindNinja");
1605-
settings.setDefaultFormat(QSettings::IniFormat);
1606-
//qDebug() << "settings filename =" << settings.fileName();
1607-
1608-
//input file path
1609-
settings.setValue("inputFileDir", ui->elevationInputFileLineEdit->property("fullpath"));
1610-
1611-
//momentum flag
1612-
settings.setValue("momentumFlag", ui->momentumSolverCheckBox->isChecked());
1613-
//veg choice
1614-
settings.setValue("vegChoice", ui->vegetationComboBox->currentIndex());
1615-
//mesh choice
1616-
settings.setValue("meshChoice", ui->meshResolutionComboBox->currentIndex());
1617-
//mesh units
1618-
settings.setValue("meshUnits", ui->meshResolutionUnitsComboBox->currentIndex());
1619-
//number of processors
1620-
settings.setValue("nProcessors", ui->numberOfProcessorsSpinBox->value());
1621-
1622-
//time zone
1623-
//settings.setValue("timeZone", ui->timeZoneComboBox->currentIndex());
1624-
1625-
//settings.setValue("pointFile", tree->point->stationFileName );
1626-
1627-
//if(ui->meshResolutionComboBox->currentIndex() == 3) // custom res
1628-
//{
1629-
// settings.setValue("customRes", ui->meshResolutionSpinBox->value());
1630-
//}
1631-
// need to write it every time, the past value will get left there without getting updated otherwise, doesn't delete past settings values
1632-
settings.setValue("customRes", ui->meshResolutionSpinBox->value());
1633-
1634-
writeToConsole("Settings saved.");
1602+
// writeToConsole("Saving settings...");
1603+
1604+
// QSettings settings(QSettings::UserScope, "Firelab", "WindNinja");
1605+
// settings.setDefaultFormat(QSettings::IniFormat);
1606+
// //qDebug() << "settings filename =" << settings.fileName();
1607+
1608+
// //input file path
1609+
// settings.setValue("inputFileDir", ui->elevationInputFileLineEdit->property("fullpath"));
1610+
1611+
// //momentum flag
1612+
// settings.setValue("momentumFlag", ui->momentumSolverCheckBox->isChecked());
1613+
// //veg choice
1614+
// settings.setValue("vegChoice", ui->vegetationComboBox->currentIndex());
1615+
// //mesh choice
1616+
// settings.setValue("meshChoice", ui->meshResolutionComboBox->currentIndex());
1617+
// //mesh units
1618+
// settings.setValue("meshUnits", ui->meshResolutionUnitsComboBox->currentIndex());
1619+
// //number of processors
1620+
// settings.setValue("nProcessors", ui->numberOfProcessorsSpinBox->value());
1621+
1622+
// //time zone
1623+
// //settings.setValue("timeZone", ui->timeZoneComboBox->currentIndex());
1624+
1625+
// //settings.setValue("pointFile", tree->point->stationFileName );
1626+
1627+
// //if(ui->meshResolutionComboBox->currentIndex() == 3) // custom res
1628+
// //{
1629+
// // settings.setValue("customRes", ui->meshResolutionSpinBox->value());
1630+
// //}
1631+
// // need to write it every time, the past value will get left there without getting updated otherwise, doesn't delete past settings values
1632+
// settings.setValue("customRes", ui->meshResolutionSpinBox->value());
1633+
1634+
// writeToConsole("Settings saved.");
16351635
}
16361636

16371637
void MainWindow::readSettings()
16381638
{
1639-
QSettings settings(QSettings::UserScope, "Firelab", "WindNinja");
1640-
settings.setDefaultFormat(QSettings::IniFormat);
1639+
// QSettings settings(QSettings::UserScope, "Firelab", "WindNinja");
1640+
// settings.setDefaultFormat(QSettings::IniFormat);
16411641

1642-
if(settings.contains("inputFileDir"))
1643-
{
1644-
if(QFile::exists(settings.value("inputFileDir").toString()))
1645-
{
1646-
ui->elevationInputFileLineEdit->setText(settings.value("inputFileDir").toString());
1647-
}
1648-
}
1649-
else
1650-
{
1651-
// std::string oTmpPath = FindNinjaRootDir();
1652-
// inputFileDir = CPLFormFilename(oTmpPath.c_str(), "etc/windninja/example-files", NULL);
1653-
}
1642+
// if(settings.contains("inputFileDir"))
1643+
// {
1644+
// if(QFile::exists(settings.value("inputFileDir").toString()))
1645+
// {
1646+
// ui->elevationInputFileLineEdit->setText(settings.value("inputFileDir").toString());
1647+
// }
1648+
// }
1649+
// else
1650+
// {
1651+
// // std::string oTmpPath = FindNinjaRootDir();
1652+
// // inputFileDir = CPLFormFilename(oTmpPath.c_str(), "etc/windninja/example-files", NULL);
1653+
// }
16541654

1655-
// TODO: some of the following might be overriding the values computed by inputFileDir, when the other way around might be better
1656-
if(settings.contains("momentumFlag"))
1657-
{
1658-
bool momentumFlag = settings.value("momentumFlag").toBool();
1659-
if(momentumFlag == true)
1660-
{
1661-
ui->momentumSolverCheckBox->setChecked(true);
1662-
emit momentumSolverCheckBoxClicked();
1663-
}
1664-
}
1665-
if(settings.contains("vegChoice"))
1666-
{
1667-
ui->vegetationComboBox->setCurrentIndex(settings.value("vegChoice").toInt());
1668-
}
1669-
if(settings.contains("meshUnits")) // putting this after loading meshChoice results in overwriting the value by an extra set of units
1670-
{
1671-
ui->meshResolutionUnitsComboBox->setCurrentIndex(settings.value("meshUnits").toInt());
1672-
}
1673-
if(settings.contains("meshChoice"))
1674-
{
1675-
int choice = settings.value("meshChoice").toInt();
1676-
ui->meshResolutionComboBox->setCurrentIndex(choice);
1677-
if(choice == 3)
1678-
{
1679-
if(!settings.contains("customRes"))
1680-
{
1681-
qDebug() << "Error. WindNinja settings does not contain \"customRes\"";
1682-
}
1683-
ui->meshResolutionSpinBox->setValue(settings.value("customRes").toDouble());
1684-
}
1685-
}
1686-
if(settings.contains("nProcessors"))
1687-
{
1688-
ui->numberOfProcessorsSpinBox->setValue(settings.value("nProcessors").toInt());
1689-
}
1690-
// won't we want the timezone of the dem every time, to avoid accidentally doing a weird combination of time zones?
1691-
if(settings.contains("timeZone"))
1692-
{
1693-
// QString v = settings.value("timeZone").toString();
1694-
// int index = tree->surface->timeZone->tzComboBox->findText(v);
1695-
// if(index == -1)
1696-
// tree->surface->timeZone->tzCheckBox->setChecked( true );
1697-
// index = tree->surface->timeZone->tzComboBox->findText(v);
1698-
// if( index == 0 )
1699-
// tree->surface->timeZone->tzComboBox->setCurrentIndex(index + 1);
1700-
// true->surface->timeZone->tzComboBox->setCurrentIndex(index);
1701-
}
1702-
else
1703-
{
1704-
// tree->surface->timeZone->tzComboBox->setCurrentIndex(2);
1705-
// tree->surface->timeZone->tzComboBox->setCurrentIndex(1);
1706-
}
1707-
if(settings.contains("pointFile"))
1708-
{
1709-
// QString f = settings.value("pointFile").toString();
1710-
// tree->point->stationFileName = f;
1711-
}
1655+
// // TODO: some of the following might be overriding the values computed by inputFileDir, when the other way around might be better
1656+
// if(settings.contains("momentumFlag"))
1657+
// {
1658+
// bool momentumFlag = settings.value("momentumFlag").toBool();
1659+
// if(momentumFlag == true)
1660+
// {
1661+
// ui->momentumSolverCheckBox->setChecked(true);
1662+
// emit momentumSolverCheckBoxClicked();
1663+
// }
1664+
// }
1665+
// if(settings.contains("vegChoice"))
1666+
// {
1667+
// ui->vegetationComboBox->setCurrentIndex(settings.value("vegChoice").toInt());
1668+
// }
1669+
// if(settings.contains("meshUnits")) // putting this after loading meshChoice results in overwriting the value by an extra set of units
1670+
// {
1671+
// ui->meshResolutionUnitsComboBox->setCurrentIndex(settings.value("meshUnits").toInt());
1672+
// }
1673+
// if(settings.contains("meshChoice"))
1674+
// {
1675+
// int choice = settings.value("meshChoice").toInt();
1676+
// ui->meshResolutionComboBox->setCurrentIndex(choice);
1677+
// if(choice == 3)
1678+
// {
1679+
// if(!settings.contains("customRes"))
1680+
// {
1681+
// qDebug() << "Error. WindNinja settings does not contain \"customRes\"";
1682+
// }
1683+
// ui->meshResolutionSpinBox->setValue(settings.value("customRes").toDouble());
1684+
// }
1685+
// }
1686+
// if(settings.contains("nProcessors"))
1687+
// {
1688+
// ui->numberOfProcessorsSpinBox->setValue(settings.value("nProcessors").toInt());
1689+
// }
1690+
// // won't we want the timezone of the dem every time, to avoid accidentally doing a weird combination of time zones?
1691+
// if(settings.contains("timeZone"))
1692+
// {
1693+
// // QString v = settings.value("timeZone").toString();
1694+
// // int index = tree->surface->timeZone->tzComboBox->findText(v);
1695+
// // if(index == -1)
1696+
// // tree->surface->timeZone->tzCheckBox->setChecked( true );
1697+
// // index = tree->surface->timeZone->tzComboBox->findText(v);
1698+
// // if( index == 0 )
1699+
// // tree->surface->timeZone->tzComboBox->setCurrentIndex(index + 1);
1700+
// // true->surface->timeZone->tzComboBox->setCurrentIndex(index);
1701+
// }
1702+
// else
1703+
// {
1704+
// // tree->surface->timeZone->tzComboBox->setCurrentIndex(2);
1705+
// // tree->surface->timeZone->tzComboBox->setCurrentIndex(1);
1706+
// }
1707+
// if(settings.contains("pointFile"))
1708+
// {
1709+
// // QString f = settings.value("pointFile").toString();
1710+
// // tree->point->stationFileName = f;
1711+
// }
17121712
}
17131713

17141714
void MainWindow::showEvent(QShowEvent *event)

src/gui/weatherModelInput.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ WeatherModelInput::WeatherModelInput(Ui::MainWindow* ui, QObject* parent)
5353
connect(ui->weatherModelTimeSelectAllButton, &QPushButton::clicked, this, &WeatherModelInput::weatherModelTimeSelectAllButtonClicked);
5454
connect(ui->weatherModelTimeSelectNoneButton, &QPushButton::clicked, this, &WeatherModelInput::weatherModelTimeSelectNoneButtonClicked);
5555
connect(ui->timeZoneComboBox, &QComboBox::currentTextChanged, this, &WeatherModelInput::updatePastcastDateTimeEdits);
56+
//connect(ui->timeZoneComboBox, &QComboBox::currentTextChanged, this, &WeatherModelInput::updateTreeViewTime);
5657

5758
connect(this, &WeatherModelInput::updateProgressMessageSignal, this, &WeatherModelInput::updateProgressMessage, Qt::QueuedConnection);
5859
}
@@ -495,6 +496,13 @@ void WeatherModelInput::updatePastcastDateTimeEdits()
495496
ui->pastcastEndDateTimeEdit->setDateTime(demTime);
496497
}
497498

499+
void WeatherModelInput::updateTreeViewTime()
500+
{
501+
ui->weatherModelFileTreeView->clearSelection();
502+
timeModel->clear();
503+
emit updateState();
504+
}
505+
498506
void WeatherModelInput::initNinjaTools()
499507
{
500508
ninjaTools = NinjaMakeTools();

src/gui/weatherModelInput.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ private slots:
6666
void weatherModelComboBoxCurrentIndexChanged(int index);
6767
void weatherModelDownloadFinished();
6868
void updateProgressMessage(const QString message);
69+
void updateTreeViewTime();
6970

7071
private:
7172
NinjaToolsH* ninjaTools;

0 commit comments

Comments
 (0)