Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #49

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL Network Quick QuickControls
if (ALP_ENABLE_POSITIONING)
find_package(Qt6 REQUIRED COMPONENTS Positioning)
endif()
if (ALP_UNITTESTS)
find_package(Qt6 REQUIRED COMPONENTS Test)
endif()

include(FetchContent)
FetchContent_Declare(alpine_height_data
Expand All @@ -80,6 +77,7 @@ FetchContent_Declare(alpineapp_fonts
URL_HASH MD5=681612d5ad33731c512ce056d2ca2297
SOURCE_DIR ${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/alpineapp_fonts
)

FetchContent_MakeAvailable(alpine_height_data alpineapp_fonts)

if (ANDROID)
Expand All @@ -92,19 +90,23 @@ if (ANDROID)
include(${android_openssl_SOURCE_DIR}/android_openssl.cmake)
endif()



########################################### projects #################################################
add_subdirectory(nucleus)
add_subdirectory(gl_engine)
add_subdirectory(plain_renderer)
add_subdirectory(app)

if (ALP_UNITTESTS)
find_package(Qt6 REQUIRED COMPONENTS Test)
FetchContent_Declare(catch2
DOWNLOAD_EXTRACT_TIMESTAMP true
URL https://github.com/catchorg/Catch2/archive/refs/tags/v3.4.0.tar.gz
URL_HASH MD5=2c802a4938ed842e2942c60d1d231bb7
SOURCE_DIR ${CMAKE_SOURCE_DIR}/extern/Catch2
)
FetchContent_MakeAvailable(catch2)
if (EMSCRIPTEN AND ALP_ENABLE_THREADING)
target_compile_options(Catch2 PRIVATE -pthread)
endif()

function(alp_setup_unittest)
if (ANDROID)
install(TARGETS ${ARGV0}
Expand Down
28 changes: 28 additions & 0 deletions COPYRIGHT_NOTICES
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
This software includes code from:

-------------------------------------------------------------------------------
mourner/suncalc
-------------------------------------------------------------------------------
Copyright (c) 2014, Vladimir Agafonkin
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
80 changes: 80 additions & 0 deletions app/AppSettings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*****************************************************************************
* Alpine Terrain Renderer
* Copyright (C) 2023 Gerald Kimmersdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

#include <QSettings>

#include "AppSettings.h"

AppSettings::AppSettings(QObject* parent, std::shared_ptr<nucleus::utils::UrlModifier> url_modifier)
:QObject(parent), m_url_modifier(url_modifier)
{
#ifdef ALP_ENABLE_TRACK_OBJECT_LIFECYCLE
qDebug() << "AppSettings()";
#endif
QSettings settings;
m_datetime = settings.value("app/datetime", QDateTime::currentDateTime()).toDateTime();
m_gl_sundir_date_link = settings.value("app/gl_sundir_date_link", true).toBool();
m_render_quality = settings.value("app/render_quality", 0.5f).toFloat();
load_from_url();
}

AppSettings::~AppSettings() {
QSettings settings;
settings.setValue("app/datetime", m_datetime);
settings.setValue("app/gl_sundir_date_link", m_gl_sundir_date_link);
settings.setValue("app/render_quality", m_render_quality);
settings.sync();
#ifdef ALP_ENABLE_TRACK_OBJECT_LIFECYCLE
qDebug() << "~AppSettings()";
#endif
}

void AppSettings::load_from_url() {
auto option_string = m_url_modifier->get_query_item(URL_PARAMETER_KEY_DATETIME);
if (!option_string.isEmpty()) {
m_datetime = nucleus::utils::UrlModifier::urlsafe_string_to_qdatetime(option_string);
}
option_string = m_url_modifier->get_query_item(URL_PARAMETER_KEY_QUALITY);
if (!option_string.isEmpty()) {
m_render_quality = option_string.toFloat();
}
}

void AppSettings::set_datetime(const QDateTime& new_datetime) {
if (m_datetime != new_datetime) {
m_datetime = new_datetime;
m_url_modifier->set_query_item(
URL_PARAMETER_KEY_DATETIME,
nucleus::utils::UrlModifier::qdatetime_to_urlsafe_string(m_datetime));
emit datetime_changed(m_datetime);
}
}

void AppSettings::set_gl_sundir_date_link(bool new_value) {
if (m_gl_sundir_date_link != new_value) {
m_gl_sundir_date_link = new_value;
emit gl_sundir_date_link_changed(m_gl_sundir_date_link);
}
}

void AppSettings::set_render_quality(float new_value) {
if (qFuzzyCompare(m_render_quality, new_value)) return;
m_render_quality = new_value;
m_url_modifier->set_query_item(URL_PARAMETER_KEY_QUALITY, QString::number(m_render_quality));
emit render_quality_changed(m_render_quality);
}
71 changes: 71 additions & 0 deletions app/AppSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*****************************************************************************
* Alpine Terrain Renderer
* Copyright (C) 2023 Gerald Kimmersdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

#pragma once

#include "qdatetime.h"
#include <QObject>
#include <QDateTime>

#include "nucleus/utils/UrlModifier.h"

// This class contains properties which are specific for the rendering APP.
// NOTE: The idea is to unclutter the TerrainRenderItem a little bit. The two
// objects are still tightly coupled. Better options are very much welcome, but might
// require significant refactorization.
class AppSettings : public QObject {
Q_OBJECT
Q_PROPERTY(QDateTime datetime READ datetime WRITE set_datetime NOTIFY datetime_changed)
Q_PROPERTY(bool gl_sundir_date_link READ gl_sundir_date_link WRITE set_gl_sundir_date_link NOTIFY gl_sundir_date_link_changed)
Q_PROPERTY(float render_quality READ render_quality WRITE set_render_quality NOTIFY render_quality_changed)

signals:
void datetime_changed(const QDateTime& new_datetime);
void gl_sundir_date_link_changed(bool new_value);
void render_quality_changed(float new_value);

public:

// Constructs settings object and loads the properties from QSettings
AppSettings(QObject* parent, std::shared_ptr<nucleus::utils::UrlModifier> url_modifier);
~AppSettings();

const QDateTime& datetime() const { return m_datetime; }
void set_datetime(const QDateTime& new_datetime);

bool gl_sundir_date_link() const { return m_gl_sundir_date_link; }
void set_gl_sundir_date_link(bool new_value);

float render_quality() const { return m_render_quality; }
void set_render_quality(float new_value);

private:
// Stores date and time for the current rendering (in use for eg. Shadows)
QDateTime m_datetime;
// if true the sun light direction will be evaluated based on m_datetime
bool m_gl_sundir_date_link;
// Value which defines the quality of tiles being fetched (values from [0.1-2.0] make sense)
float m_render_quality;

// Parents instance of UrlModififer
std::shared_ptr<nucleus::utils::UrlModifier> m_url_modifier;
// Loads settings from given url_manager
void load_from_url();


};
4 changes: 3 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ qt_add_executable(alpineapp
GnssInformation.h GnssInformation.cpp
TerrainRenderer.h TerrainRenderer.cpp
HotReloader.h HotReloader.cpp
TimerFrontendManager.h TimerFrontendManager.cpp
AppSettings.h AppSettings.cpp
timing/TimerFrontendManager.h timing/TimerFrontendManager.cpp
timing/TimerFrontendObject.h timing/TimerFrontendObject.cpp
)

qt_add_qml_module(alpineapp
Expand Down
27 changes: 8 additions & 19 deletions app/GeneralSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ SetPanel {
// when creating the this component, values are read from the renderer
// after that we establish a binding, so this component can set values on the renderer
frame_rate_slider.value = map.frame_limit
lod_slider.value = map.render_quality
lod_slider.value = map.settings.render_quality
fov_slider.value = map.field_of_view
cache_size_slider.value = map.tile_cache_size

map.frame_limit = Qt.binding(function() { return frame_rate_slider.value })
map.render_quality = Qt.binding(function() { return lod_slider.value })
map.settings.render_quality = Qt.binding(function() { return lod_slider.value })
map.field_of_view = Qt.binding(function() { return fov_slider.value })
map.tile_cache_size = Qt.binding(function() { return cache_size_slider.value })
datetimegroup.initializePropertys();
Expand All @@ -48,7 +48,7 @@ SetPanel {
property bool initialized: false;

function initializePropertys() {
var jdt = new Date(map.selected_datetime);
var jdt = new Date(map.settings.datetime);
currentTime.value = jdt.getHours() + jdt.getMinutes() / 60;
currentDate.selectedDate = jdt;
initialized = true;
Expand All @@ -59,7 +59,7 @@ SetPanel {
let jsDate = currentDate.selectedDate;
jsDate.setHours(currentTime.hours);
jsDate.setMinutes(currentTime.minutes);
map.selected_datetime = jsDate;
map.settings.datetime = jsDate;
}

Label { text: qsTr("Date:") }
Expand All @@ -77,7 +77,6 @@ SetPanel {
id: currentTime;
from: 0.0; to: 24.0; stepSize: 1 / (60 / 15); // in 15 min steps
onMoved: {
//console.log("because of Time");
datetimegroup.updateMapDateTimeProperty();
}
formatCallback: function (value) {
Expand All @@ -94,28 +93,18 @@ SetPanel {
text: "Link GL Sun Configuration"
Layout.fillWidth: true;
Layout.columnSpan: 2;
checked: map.link_gl_sundirection;
onCheckStateChanged: map.link_gl_sundirection = this.checked;
checked: map.settings.gl_sundir_date_link;
onCheckStateChanged: map.settings.gl_sundir_date_link = this.checked;
}

Label { text: qsTr("Sun Angles:"); visible: map.link_gl_sundirection; }
Label { text: qsTr("Sun Angles:"); visible: map.settings.gl_sundir_date_link; }
Label {
visible: map.link_gl_sundirection;
visible: map.settings.gl_sundir_date_link;
text: {
return "Az(" + map.sun_angles.x.toFixed(2) + "°) , Ze(" + map.sun_angles.y.toFixed(2) + "°)";
}
}

Label {
Layout.columnSpan: 2;
color: "red";
text: "The sun calculation for now is just an approximation which is partly valid for the 01.08.2023 around Großglockner!"
wrapMode: Label.WordWrap
Layout.fillWidth: true;
}



}

SetGroup {
Expand Down
3 changes: 2 additions & 1 deletion app/TerrainRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
* Alpine Terrain Renderer
* Copyright (C) 2023 Adam Celarek
* Copyright (C) 2023 Gerald Kimmersdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -54,7 +55,7 @@ void TerrainRenderer::synchronize(QQuickFramebufferObject *item)
m_window = item->window();
TerrainRendererItem* i = static_cast<TerrainRendererItem*>(item);
// m_controller->camera_controller()->set_virtual_resolution_factor(i->render_quality());
m_glWindow->set_permissible_screen_space_error(1.0 / i->render_quality());
m_glWindow->set_permissible_screen_space_error(1.0 / i->settings()->render_quality());
m_controller->camera_controller()->set_viewport({ i->width(), i->height() });
m_controller->camera_controller()->set_field_of_view(i->field_of_view());

Expand Down
Loading
Loading