diff --git a/CHANGELOG.md b/CHANGELOG.md index 9548c89..668289a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 4.1.0 - 2022-07-23 + +### Changed + +- Changed equation used to calculate index of refraction for use switched from + one provided in Stanley Gedzelman's paper Simulatin Rainbows and Halos in + Color to a polynomial fitted to data provided by Warren and Brandt in their + paper Optical Constants of Ice from The Ultraviolet to The Microwave, which + is what HaloPoint 2.0 used to use +- HaloRay now remembers which folder you opened last when loading or saving + files like simulation parameter files or images, and opens the file dialog + picker in that same folder the next time + ## 4.0.1 - 2021-08-26 ### Fixed diff --git a/README.md b/README.md index 56810eb..0a8a576 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,7 @@ HaloRay.exe -platform windows:dpiawareness=2 HaloRay writes a log file to help in troubleshooting. On Windows you can find it in `%LOCALAPPDATA%\Temp\haloray\haloray.log` where -`%LOCALAPPDATA` is usually equal to `C:\Users\\AppData\Local` +`%LOCALAPPDATA%` is usually equal to `C:\Users\\AppData\Local` On Linux the log file is in `/tmp/haloray/haloray.log` diff --git a/appveyor.yml b/appveyor.yml index 76cf0fc..ddb97ee 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: "4.0.1-{build}" +version: "4.1.0-{build}" branches: only: - master @@ -24,6 +24,6 @@ deploy: description: "" skip_tags: true auth_token: - secure: qxadIRLRDKo8Tji0y+kZ03BIbNPJzdmp2HkzE6+G5lp1xtRCoeSpp6c4m4KU99D4 + secure: eMwk/VxPE6NFjxlZpAAFZuf66bhTSGr53RDKw4DYPFhKomd2jybUE1y2dHQDAjgG on: branch: master diff --git a/src/haloray-core/gui/mainWindow.cpp b/src/haloray-core/gui/mainWindow.cpp index 44e1790..68610bb 100644 --- a/src/haloray-core/gui/mainWindow.cpp +++ b/src/haloray-core/gui/mainWindow.cpp @@ -98,39 +98,43 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_previousTimedIt auto defaultFilename = QString("haloray_%1.png") .arg(currentTime) .replace(":", "-"); + auto defaultFilePath = getLatestAccessedFolder().absoluteFilePath(defaultFilename); QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), - defaultFilename, + defaultFilePath, tr("Images (*.png)")); - if (!filename.isNull()) - { - image.save(filename, "PNG", 50); - } + if (filename.isNull()) return; + + image.save(filename, "PNG", 50); + updateLatestAccessedFolder(filename); }); connect(m_saveSimulationAction, &QAction::triggered, [this]() { auto currentTime = QDateTime::currentDateTimeUtc().toString(Qt::DateFormat::ISODate); auto defaultFilename = QString("haloray_sim_%1.ini") .arg(currentTime) .replace(":", "-"); + auto defaultFilePath = getLatestAccessedFolder().absoluteFilePath(defaultFilename); QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), - defaultFilename, + defaultFilePath, tr("Simulation files (*.ini)")); if (filename.isNull()) return; StateSaver::SaveState(filename, m_engine, m_crystalRepository.get()); + updateLatestAccessedFolder(filename); }); connect(m_loadSimulationAction, &QAction::triggered, [this]() { QString filename = QFileDialog::getOpenFileName(this, tr("Open file"), - QString(), + getLatestAccessedFolder().absolutePath(), tr("Simulation files (*.ini)")); if (filename.isNull()) return; StateSaver::LoadState(filename, m_simulationStateModel, m_crystalModel); + updateLatestAccessedFolder(filename); }); connect(m_openCrystalPreviewWindow, &QAction::triggered, [this]() { auto previewWindow = new CrystalPreviewWindow(m_crystalModel, m_crystalSettingsWidget->getCurrentPopulationIndex(), this); @@ -273,4 +277,24 @@ void HaloRay::MainWindow::restartSimulation() m_openGLWidget->update(); } +QDir MainWindow::getLatestAccessedFolder() const +{ + QSettings settings; + QString pathString = settings.value("filedialog/latestFolder", QString()).toString(); + QDir dir(pathString); + if (dir.exists()) { + return dir; + } + + return QDir(); +} + +void MainWindow::updateLatestAccessedFolder(QString fileOrDirPath) +{ + QFileInfo fileInfo(fileOrDirPath); + QString path = fileInfo.absoluteDir().path(); + QSettings settings; + settings.setValue("filedialog/latestFolder", path); +} + } diff --git a/src/haloray-core/gui/mainWindow.h b/src/haloray-core/gui/mainWindow.h index 66aebc2..63c8292 100644 --- a/src/haloray-core/gui/mainWindow.h +++ b/src/haloray-core/gui/mainWindow.h @@ -4,11 +4,11 @@ #include #include "gui/models/simulationStateModel.h" - class QDoubleSpinBox; class QProgressBar; class QScrollArea; class QAction; +class QDir; namespace HaloRay { @@ -39,6 +39,9 @@ class MainWindow : public QMainWindow void setupRenderTimer(); void restartSimulation(); + QDir getLatestAccessedFolder() const; + void updateLatestAccessedFolder(QString fileOrDirPath); + GeneralSettingsWidget *m_generalSettingsWidget; CrystalSettingsWidget *m_crystalSettingsWidget; ViewSettingsWidget *m_viewSettingsWidget; diff --git a/src/haloray-core/resources/shaders/raytrace.glsl b/src/haloray-core/resources/shaders/raytrace.glsl index 341800d..d0cab77 100644 --- a/src/haloray-core/resources/shaders/raytrace.glsl +++ b/src/haloray-core/resources/shaders/raytrace.glsl @@ -208,8 +208,10 @@ float zFit_1931(float wave) float getIceIOR(float wavelength) { - // Eq. from Simulating rainbows and halos in color by Stanley Gedzelman - return 1.3203 - 0.0000333 * wavelength; + // The index of refraction is based on a second degree polynomial fitted to data from + // "Optical constants of ice from the ultraviolet to the microwave" by Warren and Brandt + // The raw data is available here: https://atmos.uw.edu/ice_optical_constants/ + return 9.35698756194051e-8 * wavelength * wavelength - 1.42326056729702e-4 * wavelength + 1.36093233643442; } uint selectFirstTriangle(vec3 rayDirection) diff --git a/src/main/main.cpp b/src/main/main.cpp index e0a0ea4..cfc4686 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -101,6 +101,9 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(haloray); initializeLogging(); + QCoreApplication::setOrganizationName("Other Computer Software"); + QCoreApplication::setApplicationName("HaloRay"); + QGuiApplication::setAttribute(Qt::AA_UseDesktopOpenGL); QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);