Skip to content

Commit e96768b

Browse files
authored
Merge pull request #746 from firelab/GUI-Redesign-someFixes
Small Fixes for test build of Qt6 GUI
2 parents 08a856f + a37f3c5 commit e96768b

8 files changed

Lines changed: 159 additions & 68 deletions

File tree

src/gui/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ int main(int argc, char *argv[])
3636
MainWindow* w = nullptr;
3737
try {
3838
w = new MainWindow;
39+
w->setMinimumSize(800, 600);
40+
w->resize(800, 600);
3941
} catch (...) {
4042
return 1;
4143
}
4244

4345
// Set the Splash Screen
4446
QPixmap pix(":wn-splash.png");
45-
QSplashScreen *splash = new QSplashScreen(pix.scaled(1200, 320, Qt::KeepAspectRatioByExpanding));
47+
QSplashScreen *splash = new QSplashScreen(pix.scaled(600, 160, Qt::KeepAspectRatioByExpanding));
4648

4749
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(splash);
4850
splash->setGraphicsEffect(effect);

src/gui/mainWindow.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ MainWindow::MainWindow(QWidget *parent)
9393

9494
connectSignals();
9595

96+
ui->treeWidget->blockSignals(true);
9697
ui->treeWidget->topLevelItem(0)->setSelected(true);
97-
ui->inputsStackedWidget->setCurrentIndex(1); // setSelected shows the blank page, have to have this to show proper page
98+
ui->inputsStackedWidget->setCurrentIndex(1);
99+
ui->treeWidget->blockSignals(false);
98100

99101
int nCPUs = QThread::idealThreadCount();
100102
ui->availableProcessorsLabel->setText("Available Processors: " + QString::number(nCPUs));
@@ -305,6 +307,8 @@ void MainWindow::cancelSolve()
305307

306308
void MainWindow::treeWidgetItemSelectionChanged()
307309
{
310+
webEngineView->page()->runJavaScript("stopRectangleDrawing();");
311+
308312
int column = ui->treeWidget->currentColumn();
309313
int pageIndex = ui->treeWidget->selectedItems().first()->data(column, Qt::UserRole).toInt(); // assume 0 since no multi selection
310314
ui->inputsStackedWidget->setCurrentIndex(pageIndex);
@@ -1335,6 +1339,22 @@ bool MainWindow::setOutputFlags(NinjaArmyH* ninjaArmy,
13351339
return false;
13361340
}
13371341

1342+
ninjaErr = NinjaSetAsciiAaigridOutFlag(ninjaArmy, i, ui->fireBehaviorGroupBox->isChecked(), papszOptions);
1343+
//ninjaErr = NinjaSetAsciiAaigridOutFlag(ninjaArmy, i+10, ui->fireBehaviorGroupBox->isChecked(), papszOptions); // test error handling
1344+
if (ninjaErr != NINJA_SUCCESS)
1345+
{
1346+
qDebug() << "NinjaSetAsciiAaigridOutFlag: ninjaErr =" << ninjaErr;
1347+
return false;
1348+
}
1349+
1350+
ninjaErr = NinjaSetAsciiProjOutFlag(ninjaArmy, i, ui->fireBehaviorGroupBox->isChecked(), papszOptions);
1351+
//ninjaErr = NinjaSetAsciiProjOutFlag(ninjaArmy, i+10, ui->fireBehaviorGroupBox->isChecked(), papszOptions); // test error handling
1352+
if (ninjaErr != NINJA_SUCCESS)
1353+
{
1354+
qDebug() << "NinjaSetAsciiProjOutFlag: ninjaErr =" << ninjaErr;
1355+
return false;
1356+
}
1357+
13381358
ninjaErr = NinjaSetAsciiResolution(ninjaArmy, i, ui->fireBehaviorMeshResolutionSpinBox->value(), ui->fireBehaviorMeshResolutionComboBox->itemData(ui->fireBehaviorMeshResolutionComboBox->currentIndex()).toString().toUtf8().constData(), papszOptions);
13391359
//ninjaErr = NinjaSetAsciiResolution(ninjaArmy, i+10, ui->fireBehaviorMeshResolutionSpinBox->value(), ui->fireBehaviorMeshResolutionComboBox->itemData(ui->fireBehaviorMeshResolutionComboBox->currentIndex()).toString().toUtf8().constData(), papszOptions); // test error handling // hrm, ninjaCom isn't triggering for this one, though the error returns, leading to it hanging without a proper message.
13401360
//ninjaErr = NinjaSetAsciiResolution(ninjaArmy, i, ui->fireBehaviorMeshResolutionSpinBox->value(), "fudge", papszOptions); // test error handling

src/gui/mapBridge.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ void MapBridge::receiveBoundingBox(const QString &jsonCoords)
4545
double east = obj["east"].toDouble();
4646
double west = obj["west"].toDouble();
4747

48-
qDebug() << "Bounding box received:";
49-
qDebug() << "North:" << north << "South:" << south;
50-
qDebug() << "East:" << east << "West:" << west;
51-
5248
emit boundingBoxReceived(north, south, east, west);
5349
}
5450

src/gui/pointInitializationInput.cpp

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ void PointInitializationInput::weatherStationDataDownloadButtonClicked()
407407
futureWatcher->setFuture(future);
408408

409409
connect(futureWatcher, &QFutureWatcher<int>::finished, this, &PointInitializationInput::fetchStationDataFinished);
410+
connect(progress, &QProgressDialog::canceled, this, &PointInitializationInput::fetchStationDataFinished);
410411
}
411412

412413
int PointInitializationInput::fetchStationFromBbox(NinjaToolsH* ninjaTools,
@@ -547,27 +548,38 @@ int PointInitializationInput::fetchStationByName(NinjaToolsH* ninjaTools,
547548

548549
void PointInitializationInput::fetchStationDataFinished()
549550
{
550-
// get the return value of the QtConcurrent::run() function
551-
int result = futureWatcher->future().result();
551+
if(!futureWatcher)
552+
{
553+
return;
554+
}
552555

553-
if(result == NINJA_SUCCESS)
556+
if(progress && progress->wasCanceled())
554557
{
555-
emit writeToConsoleSignal("Finished fetching station data.", Qt::darkGreen);
558+
futureWatcher->waitForFinished();
559+
}
560+
else
561+
{
562+
// get the return value of the QtConcurrent::run() function
563+
int result = futureWatcher->future().result();
556564

557-
if (progress)
565+
if(result == NINJA_SUCCESS)
558566
{
559-
progress->close();
560-
progress->deleteLater();
561-
progress = nullptr;
562-
}
567+
emit writeToConsoleSignal("Finished fetching station data.", Qt::darkGreen);
563568

564-
ui->inputsStackedWidget->setCurrentIndex(7);
569+
if (progress)
570+
{
571+
progress->close();
572+
progress->deleteLater();
573+
progress = nullptr;
574+
}
565575

566-
} else
567-
{
568-
emit writeToConsoleSignal("Failed to fetch station data.");
569-
}
576+
ui->inputsStackedWidget->setCurrentIndex(7);
570577

578+
} else
579+
{
580+
emit writeToConsoleSignal("Failed to fetch station data.");
581+
}
582+
}
571583
// delete the futureWatcher every time, whether success or failure
572584
if (futureWatcher)
573585
{

src/gui/surfaceInput.cpp

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -361,49 +361,62 @@ void SurfaceInput::startFetchDEM(QVector<double> boundingBox, std::string demFil
361361
futureWatcher->setFuture(future);
362362

363363
connect(futureWatcher, &QFutureWatcher<int>::finished, this, &SurfaceInput::fetchDEMFinished);
364+
connect(progress, &QProgressDialog::canceled, this, &SurfaceInput::fetchDEMFinished);
364365
}
365366

366367
void SurfaceInput::fetchDEMFinished()
367368
{
368-
// get the return value of the QtConcurrent::run() function
369-
int result = futureWatcher->future().result();
369+
if(!futureWatcher)
370+
{
371+
return;
372+
}
370373

371-
if(result == NINJA_SUCCESS)
374+
if(progress && progress->wasCanceled())
375+
{
376+
futureWatcher->waitForFinished();
377+
}
378+
else
372379
{
373-
emit writeToConsoleSignal("Finished fetching DEM file.", Qt::darkGreen);
380+
// get the return value of the QtConcurrent::run() function
381+
int result = futureWatcher->future().result();
374382

375-
bool retVal = loadDemMetadata(pendingDownloadDemFilePath);
376-
if(retVal == true)
383+
if(result == NINJA_SUCCESS)
377384
{
378-
ui->elevationInputFileLineEdit->setProperty("fullpath", pendingDownloadDemFilePath);
379-
ui->elevationInputFileLineEdit->setText(QFileInfo(pendingDownloadDemFilePath).fileName());
380-
ui->elevationInputFileLineEdit->setToolTip(pendingDownloadDemFilePath);
381-
ui->inputsStackedWidget->setCurrentIndex(3);
385+
emit writeToConsoleSignal("Finished fetching DEM file.", Qt::darkGreen);
386+
387+
bool retVal = loadDemMetadata(pendingDownloadDemFilePath);
388+
if(retVal == true)
389+
{
390+
ui->elevationInputFileLineEdit->setProperty("fullpath", pendingDownloadDemFilePath);
391+
ui->elevationInputFileLineEdit->setText(QFileInfo(pendingDownloadDemFilePath).fileName());
392+
ui->elevationInputFileLineEdit->setToolTip(pendingDownloadDemFilePath);
393+
ui->inputsStackedWidget->setCurrentIndex(3);
394+
}
395+
//else // if(retVal == false)
396+
//{
397+
// // message is handled in loadDemMetadata()
398+
// // don't want to return here, need to wrap up all the other todos of this function or things won't close properly
399+
// //return;
400+
//}
401+
402+
if(progress)
403+
{
404+
progress->close();
405+
progress->deleteLater();
406+
progress = nullptr;
407+
}
382408
}
383-
//else // if(retVal == false)
384-
//{
385-
// // message is handled in loadDemMetadata()
386-
// // don't want to return here, need to wrap up all the other todos of this function or things won't close properly
387-
// //return;
388-
//}
389-
390-
if(progress)
409+
else
391410
{
392-
progress->close();
393-
progress->deleteLater();
394-
progress = nullptr;
411+
emit writeToConsoleSignal("Failed to fetch DEM file.");
395412
}
396-
}
397-
else
398-
{
399-
emit writeToConsoleSignal("Failed to fetch DEM file.");
400-
}
401413

402-
// delete the futureWatcher every time, whether success or failure
403-
if(futureWatcher)
404-
{
405-
futureWatcher->deleteLater();
406-
futureWatcher = nullptr;
414+
// delete the futureWatcher every time, whether success or failure
415+
if(futureWatcher)
416+
{
417+
futureWatcher->deleteLater();
418+
futureWatcher = nullptr;
419+
}
407420
}
408421
}
409422

@@ -719,6 +732,8 @@ int SurfaceInput::fetchDEMFile(QVector<double> boundingBox, std::string demFile,
719732

720733
bool SurfaceInput::loadDemMetadata(const QString demFilePath)
721734
{
735+
CPLSetConfigOption( "GDAL_PAM_ENABLED", "OFF" );
736+
722737
double adfGeoTransform[6];
723738
GDALDataset *poInputDS;
724739

@@ -794,6 +809,8 @@ bool SurfaceInput::loadDemMetadata(const QString demFilePath)
794809

795810
GDALClose((GDALDatasetH)poInputDS);
796811

812+
CPLSetConfigOption( "GDAL_PAM_ENABLED", "ON" );
813+
797814
return true;
798815
}
799816

src/gui/weatherModelInput.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void WeatherModelInput::weatherModelDownloadButtonClicked()
109109

110110
connect(futureWatcher, &QFutureWatcher<int>::finished,
111111
this, &WeatherModelInput::weatherModelDownloadFinished);
112+
connect(progress, &QProgressDialog::canceled, this, &WeatherModelInput::weatherModelDownloadFinished);
112113
}
113114

114115
void WeatherModelInput::updateProgressMessage(const QString message)
@@ -278,29 +279,41 @@ int WeatherModelInput::fetchPastcastWeather(
278279

279280
void WeatherModelInput::weatherModelDownloadFinished()
280281
{
281-
// get the return value of the QtConcurrent::run() function
282-
int result = futureWatcher->future().result();
282+
if(!futureWatcher)
283+
{
284+
return;
285+
}
283286

284-
if(result == NINJA_SUCCESS)
287+
if(progress && progress->wasCanceled())
288+
{
289+
futureWatcher->waitForFinished();
290+
}
291+
else
285292
{
286-
emit writeToConsoleSignal("Finished fetching weather model data.", Qt::darkGreen);
293+
// get the return value of the QtConcurrent::run() function
294+
int result = futureWatcher->future().result();
287295

288-
if (progress)
296+
if(result == NINJA_SUCCESS)
289297
{
290-
progress->close();
291-
progress->deleteLater();
292-
progress = nullptr;
298+
emit writeToConsoleSignal("Finished fetching weather model data.", Qt::darkGreen);
299+
300+
if (progress)
301+
{
302+
progress->close();
303+
progress->deleteLater();
304+
progress = nullptr;
305+
}
306+
} else
307+
{
308+
emit writeToConsoleSignal("Failed to fetch weather model data.");
293309
}
294-
} else
295-
{
296-
emit writeToConsoleSignal("Failed to fetch weather model data.");
297-
}
298310

299-
// delete the futureWatcher every time, whether success or failure
300-
if (futureWatcher)
301-
{
302-
futureWatcher->deleteLater();
303-
futureWatcher = nullptr;
311+
// delete the futureWatcher every time, whether success or failure
312+
if (futureWatcher)
313+
{
314+
futureWatcher->deleteLater();
315+
futureWatcher = nullptr;
316+
}
304317
}
305318
}
306319

src/ninja/windninja.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,6 +2042,31 @@ WINDNINJADLL_EXPORT NinjaErr NinjaSetAsciiOutFlag
20422042
}
20432043
}
20442044

2045+
WINDNINJADLL_EXPORT NinjaErr NinjaSetAsciiAaigridOutFlag
2046+
( NinjaArmyH * army, const int nIndex, const bool flag, char ** papszOptions )
2047+
{
2048+
if( NULL != army )
2049+
{
2050+
return reinterpret_cast<ninjaArmy*>( army )->setAsciiAaigridOutFlag( nIndex, flag );
2051+
}
2052+
else
2053+
{
2054+
return NINJA_E_NULL_PTR;
2055+
}
2056+
}
2057+
2058+
WINDNINJADLL_EXPORT NinjaErr NinjaSetAsciiProjOutFlag
2059+
( NinjaArmyH * army, const int nIndex, const bool flag, char ** papszOptions )
2060+
{
2061+
if( NULL != army )
2062+
{
2063+
return reinterpret_cast<ninjaArmy*>( army )->setAsciiProjOutFlag( nIndex, flag );
2064+
}
2065+
else
2066+
{
2067+
return NINJA_E_NULL_PTR;
2068+
}
2069+
}
20452070

20462071
/**
20472072
* \brief Set the resolution of the raster output for a simulation.

src/ninja/windninja.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ typedef int NinjaErr;
342342
WINDNINJADLL_EXPORT NinjaErr NinjaSetAsciiOutFlag
343343
( NinjaArmyH * ninjaArmy, const int nIndex, const bool flag, char ** papszOptions );
344344

345+
WINDNINJADLL_EXPORT NinjaErr NinjaSetAsciiAaigridOutFlag
346+
( NinjaArmyH * ninjaArmy, const int nIndex, const bool flag, char ** papszOptions );
347+
348+
WINDNINJADLL_EXPORT NinjaErr NinjaSetAsciiProjOutFlag
349+
( NinjaArmyH * ninjaArmy, const int nIndex, const bool flag, char ** papszOptions );
350+
345351
WINDNINJADLL_EXPORT NinjaErr NinjaSetAsciiResolution
346352
( NinjaArmyH * ninjaArmy, const int nIndex, const double resolution,
347353
const char * units, char ** options );

0 commit comments

Comments
 (0)