1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Added hillshading lightening setting

This commit is contained in:
Martin Tůma 2024-06-15 11:24:50 +02:00
parent 8730206939
commit 96fe90cc3f
7 changed files with 16 additions and 1 deletions

View File

@ -2609,6 +2609,7 @@ void GUI::writeSettings()
WRITE(demUsername, _options.demUsername); WRITE(demUsername, _options.demUsername);
WRITE(demPassword, _options.demPassword); WRITE(demPassword, _options.demPassword);
WRITE(hillshadingAlpha, _options.hillshadingAlpha); WRITE(hillshadingAlpha, _options.hillshadingAlpha);
WRITE(hillshadingLightening, _options.hillshadingLightening);
WRITE(hillshadingBlur, _options.hillshadingBlur); WRITE(hillshadingBlur, _options.hillshadingBlur);
WRITE(hillshadingAzimuth, _options.hillshadingAzimuth); WRITE(hillshadingAzimuth, _options.hillshadingAzimuth);
WRITE(hillshadingAltitude, _options.hillshadingAltitude); WRITE(hillshadingAltitude, _options.hillshadingAltitude);
@ -2914,6 +2915,7 @@ void GUI::readSettings(QString &activeMap, QStringList &disabledPOIs,
_options.demUsername = READ(demUsername).toString(); _options.demUsername = READ(demUsername).toString();
_options.demPassword = READ(demPassword).toString(); _options.demPassword = READ(demPassword).toString();
_options.hillshadingAlpha = READ(hillshadingAlpha).toInt(); _options.hillshadingAlpha = READ(hillshadingAlpha).toInt();
_options.hillshadingLightening = READ(hillshadingLightening).toDouble();
_options.hillshadingBlur = READ(hillshadingBlur).toInt(); _options.hillshadingBlur = READ(hillshadingBlur).toInt();
_options.hillshadingAzimuth = READ(hillshadingAzimuth).toInt(); _options.hillshadingAzimuth = READ(hillshadingAzimuth).toInt();
_options.hillshadingAltitude = READ(hillshadingAltitude).toInt(); _options.hillshadingAltitude = READ(hillshadingAltitude).toInt();
@ -3017,6 +3019,7 @@ void GUI::loadOptions()
HillShading::setAzimuth(_options.hillshadingAzimuth); HillShading::setAzimuth(_options.hillshadingAzimuth);
HillShading::setAltitude(_options.hillshadingAltitude); HillShading::setAltitude(_options.hillshadingAltitude);
HillShading::setZFactor(_options.hillshadingZFactor); HillShading::setZFactor(_options.hillshadingZFactor);
HillShading::setLightening(_options.hillshadingLightening);
_poi->setRadius(_options.poiRadius); _poi->setRadius(_options.poiRadius);
@ -3158,6 +3161,7 @@ void GUI::updateOptions(const Options &options)
SET_HS_OPTION(hillshadingAzimuth, setAzimuth); SET_HS_OPTION(hillshadingAzimuth, setAzimuth);
SET_HS_OPTION(hillshadingAltitude, setAltitude); SET_HS_OPTION(hillshadingAltitude, setAltitude);
SET_HS_OPTION(hillshadingZFactor, setZFactor); SET_HS_OPTION(hillshadingZFactor, setZFactor);
SET_HS_OPTION(hillshadingLightening, setLightening);
if (options.connectionTimeout != _options.connectionTimeout) if (options.connectionTimeout != _options.connectionTimeout)
Downloader::setTimeout(options.connectionTimeout); Downloader::setTimeout(options.connectionTimeout);

View File

@ -621,6 +621,8 @@ QWidget *OptionsDialog::createDEMPage()
_hillshadingAlpha = new PercentSlider(); _hillshadingAlpha = new PercentSlider();
_hillshadingAlpha->setValue(qRound((_options.hillshadingAlpha / 255.0) _hillshadingAlpha->setValue(qRound((_options.hillshadingAlpha / 255.0)
* 100)); * 100));
_hillshadingLightening = new PercentSlider();
_hillshadingLightening->setValue(_options.hillshadingLightening * 100);
_hillshadingBlur = new QSpinBox(); _hillshadingBlur = new QSpinBox();
_hillshadingBlur->setMaximum(10); _hillshadingBlur->setMaximum(10);
_hillshadingBlur->setSuffix(UNIT_SPACE + tr("px")); _hillshadingBlur->setSuffix(UNIT_SPACE + tr("px"));
@ -640,6 +642,7 @@ QWidget *OptionsDialog::createDEMPage()
QFormLayout *hillshadingLayout = new QFormLayout(); QFormLayout *hillshadingLayout = new QFormLayout();
hillshadingLayout->addRow(tr("Opacity:"), _hillshadingAlpha); hillshadingLayout->addRow(tr("Opacity:"), _hillshadingAlpha);
hillshadingLayout->addRow(tr("Lightening:"), _hillshadingLightening);
hillshadingLayout->addRow(tr("Blur radius:"), _hillshadingBlur); hillshadingLayout->addRow(tr("Blur radius:"), _hillshadingBlur);
hillshadingLayout->addItem(new QSpacerItem(10, 10)); hillshadingLayout->addItem(new QSpacerItem(10, 10));
hillshadingLayout->addRow(tr("Azimuth:"), _hillshadingAzimuth); hillshadingLayout->addRow(tr("Azimuth:"), _hillshadingAzimuth);
@ -987,6 +990,7 @@ void OptionsDialog::accept()
_options.demPassword = _demAuth->password(); _options.demPassword = _demAuth->password();
_options.hillshadingAlpha = qRound((_hillshadingAlpha->value() / 100.0) _options.hillshadingAlpha = qRound((_hillshadingAlpha->value() / 100.0)
* 255); * 255);
_options.hillshadingLightening = _hillshadingLightening->value() / 100.0;
_options.hillshadingBlur = _hillshadingBlur->value(); _options.hillshadingBlur = _hillshadingBlur->value();
_options.hillshadingAzimuth = _hillshadingAzimuth->value(); _options.hillshadingAzimuth = _hillshadingAzimuth->value();
_options.hillshadingAltitude = _hillshadingAltitude->value(); _options.hillshadingAltitude = _hillshadingAltitude->value();

View File

@ -77,6 +77,7 @@ struct Options {
int hillshadingAzimuth; int hillshadingAzimuth;
int hillshadingAltitude; int hillshadingAltitude;
double hillshadingZFactor; double hillshadingZFactor;
double hillshadingLightening;
// Position // Position
QString plugin; QString plugin;
QMap<QString, QVariantMap> pluginParams; QMap<QString, QVariantMap> pluginParams;
@ -182,6 +183,7 @@ private:
QLineEdit *_demURL; QLineEdit *_demURL;
AuthenticationWidget *_demAuth; AuthenticationWidget *_demAuth;
PercentSlider *_hillshadingAlpha; PercentSlider *_hillshadingAlpha;
PercentSlider *_hillshadingLightening;
QSpinBox *_hillshadingBlur; QSpinBox *_hillshadingBlur;
QSpinBox *_hillshadingAzimuth; QSpinBox *_hillshadingAzimuth;
QSpinBox *_hillshadingAltitude; QSpinBox *_hillshadingAltitude;

View File

@ -245,6 +245,7 @@ SETTING(demAuthentication, "demAuthentication", false );
SETTING(demUsername, "demUsername", "" ); SETTING(demUsername, "demUsername", "" );
SETTING(demPassword, "demPassword", "" ); SETTING(demPassword, "demPassword", "" );
SETTING(hillshadingAlpha, "hillshadingAlpha", 102 ); SETTING(hillshadingAlpha, "hillshadingAlpha", 102 );
SETTING(hillshadingLightening,"hillshadingLightening", 0.2 );
SETTING(hillshadingBlur, "hillshadingBlur", 3 ); SETTING(hillshadingBlur, "hillshadingBlur", 3 );
SETTING(hillshadingAzimuth, "hillshadingAzimuth", 315 ); SETTING(hillshadingAzimuth, "hillshadingAzimuth", 315 );
SETTING(hillshadingAltitude, "hillshadingAltitude", 45 ); SETTING(hillshadingAltitude, "hillshadingAltitude", 45 );

View File

@ -197,6 +197,7 @@ public:
static const Setting demUsername; static const Setting demUsername;
static const Setting demPassword; static const Setting demPassword;
static const Setting hillshadingAlpha; static const Setting hillshadingAlpha;
static const Setting hillshadingLightening;
static const Setting hillshadingBlur; static const Setting hillshadingBlur;
static const Setting hillshadingAzimuth; static const Setting hillshadingAzimuth;
static const Setting hillshadingAltitude; static const Setting hillshadingAltitude;

View File

@ -31,6 +31,7 @@ int HillShading::_blur = 3;
int HillShading::_azimuth = 315; int HillShading::_azimuth = 315;
int HillShading::_altitude = 45; int HillShading::_altitude = 45;
double HillShading::_z = 0.6; double HillShading::_z = 0.6;
double HillShading::_l = 0.2;
static void getConstants(double azimuth, double elevation, Constants &c) static void getConstants(double azimuth, double elevation, Constants &c)
{ {
@ -92,7 +93,7 @@ QImage HillShading::render(const MatrixD &m, int extend)
if (std::isnan(L)) if (std::isnan(L))
pixel = 0; pixel = 0;
else { else {
L = sqrt(L * 0.8 + 0.2); L = sqrt(L * (1.0 - _l) + _l);
quint8 val = (L < 0) ? 0 : L * _alpha; quint8 val = (L < 0) ? 0 : L * _alpha;
pixel = (_alpha - val)<<24; pixel = (_alpha - val)<<24;
} }

View File

@ -16,6 +16,7 @@ public:
static void setAzimuth(int azimuth) {_azimuth = azimuth;} static void setAzimuth(int azimuth) {_azimuth = azimuth;}
static void setAltitude(int altitude) {_altitude = altitude;} static void setAltitude(int altitude) {_altitude = altitude;}
static void setZFactor(double z) {_z = z;} static void setZFactor(double z) {_z = z;}
static void setLightening(double b) {_l = b;}
private: private:
static int _alpha; static int _alpha;
@ -23,6 +24,7 @@ private:
static int _azimuth; static int _azimuth;
static int _altitude; static int _altitude;
static double _z; static double _z;
static double _l;
}; };
#endif // HILLSHADING_H #endif // HILLSHADING_H