From 7f06b93e1ebb0a152c6fb2e65f9725083b416333 Mon Sep 17 00:00:00 2001 From: Trevor SANDY Date: Mon, 25 Jan 2021 21:18:43 +0100 Subject: [PATCH] Remove configurable gamma setting and fix colour reset action --- common/lc_application.cpp | 5 +---- common/lc_application.h | 1 - common/lc_colors.cpp | 10 ++++----- common/lc_edgecolordialog.cpp | 39 ++++++++--------------------------- common/lc_edgecolordialog.h | 3 --- common/lc_math.h | 5 +++-- common/lc_profile.cpp | 1 - common/lc_profile.h | 1 - qt/lc_qpreferencesdialog.cpp | 1 - 9 files changed, 18 insertions(+), 48 deletions(-) diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 054c2f1f..dd7e8471 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -63,7 +63,6 @@ void lcPreferences::LoadDefaults() mBlackEdgeColor = lcGetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR); mDarkEdgeColor = lcGetProfileInt(LC_PROFILE_DARK_EDGE_COLOR); mPartEdgeContrast = lcGetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST); - mPartEdgeGamma = lcGetProfileFloat(LC_PROFILE_PART_EDGE_GAMMA); mPartColorValueLDIndex = lcGetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX); mAutomateEdgeColor = lcGetProfileInt(LC_PROFILE_AUTOMATE_EDGE_COLOR); } @@ -116,7 +115,6 @@ void lcPreferences::SaveDefaults() lcSetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR, mBlackEdgeColor); lcSetProfileInt(LC_PROFILE_DARK_EDGE_COLOR, mDarkEdgeColor); lcSetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST, mPartEdgeContrast); - lcSetProfileFloat(LC_PROFILE_PART_EDGE_GAMMA, mPartEdgeGamma); lcSetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX, mPartColorValueLDIndex); lcSetProfileInt(LC_PROFILE_AUTOMATE_EDGE_COLOR, mAutomateEdgeColor); } @@ -1168,11 +1166,10 @@ void lcApplication::ShowPreferencesDialog() bool BlackEdgeColorChanged = Options.Preferences.mBlackEdgeColor != quint32(lcGetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR)); bool DarkEdgeColorChanged = Options.Preferences.mDarkEdgeColor != quint32(lcGetProfileInt(LC_PROFILE_DARK_EDGE_COLOR)); bool PartEdgeContrastChanged = Options.Preferences.mPartEdgeContrast != lcGetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST); - bool PartEdgeGammaChanged = Options.Preferences.mPartEdgeGamma != lcGetProfileFloat(LC_PROFILE_PART_EDGE_GAMMA); bool PartColorValueLDIndexChanged = Options.Preferences.mPartColorValueLDIndex != lcGetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX); if (!AutomateEdgeColorChanged) - AutomateEdgeColorChanged = (StudColorChanged || StudEdgeColorChanged || BlackEdgeColorChanged || DarkEdgeColorChanged || PartEdgeContrastChanged || PartEdgeGammaChanged || PartColorValueLDIndexChanged); + AutomateEdgeColorChanged = (StudColorChanged || StudEdgeColorChanged || BlackEdgeColorChanged || DarkEdgeColorChanged || PartEdgeContrastChanged || PartColorValueLDIndexChanged); mPreferences = Options.Preferences; diff --git a/common/lc_application.h b/common/lc_application.h index 4c6c4ca8..940d791d 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -78,7 +78,6 @@ public: quint32 mBlackEdgeColor; quint32 mDarkEdgeColor; float mPartEdgeContrast; - float mPartEdgeGamma; float mPartColorValueLDIndex; bool mAutomateEdgeColor; }; diff --git a/common/lc_colors.cpp b/common/lc_colors.cpp index 1f97afb1..08da7b07 100644 --- a/common/lc_colors.cpp +++ b/common/lc_colors.cpp @@ -220,18 +220,18 @@ static void lcAdjustStudStyleColors(std::vector& Colors, lcStudStyle St continue; float EdgeLuminescence = 0.0f; - float r = LC_GAMMA_ADJUST(Color.Value[0], lcGetPreferences().mPartEdgeGamma); - float g = LC_GAMMA_ADJUST(Color.Value[1], lcGetPreferences().mPartEdgeGamma); - float b = LC_GAMMA_ADJUST(Color.Value[2], lcGetPreferences().mPartEdgeGamma); + float r = LC_GAMMA_ADJUST(Color.Value[0]); + float g = LC_GAMMA_ADJUST(Color.Value[1]); + float b = LC_GAMMA_ADJUST(Color.Value[2]); float ValueLuminescence = 0.2126f * r + 0.7152f * g + 0.0722f * b; - if (LC_GAMMA_APPLY(ValueLuminescence, lcGetPreferences().mPartEdgeGamma) > (lcGetPreferences().mPartColorValueLDIndex)) + if (LC_GAMMA_APPLY(ValueLuminescence) > (lcGetPreferences().mPartColorValueLDIndex)) EdgeLuminescence = ValueLuminescence - (ValueLuminescence * lcGetPreferences().mPartEdgeContrast); else EdgeLuminescence = (1.0f - ValueLuminescence) * lcGetPreferences().mPartEdgeContrast + ValueLuminescence; - EdgeLuminescence = LC_GAMMA_APPLY(EdgeLuminescence, lcGetPreferences().mPartEdgeGamma); + EdgeLuminescence = LC_GAMMA_APPLY(EdgeLuminescence); Color.Edge = lcVector4(EdgeLuminescence, EdgeLuminescence, EdgeLuminescence, 1.0f); } diff --git a/common/lc_edgecolordialog.cpp b/common/lc_edgecolordialog.cpp index 6bd8b0df..c849cf12 100644 --- a/common/lc_edgecolordialog.cpp +++ b/common/lc_edgecolordialog.cpp @@ -1,8 +1,6 @@ #include "lc_edgecolordialog.h" #include "lc_application.h" -#define MIN_GAMMA 1.0f - lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowHighContrastDialog) :QDialog(Parent) { @@ -12,7 +10,6 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH mDarkEdgeColor = lcGetPreferences().mDarkEdgeColor; mPartEdgeContrast = lcGetPreferences().mPartEdgeContrast; - mPartEdgeGamma = lcGetPreferences().mPartEdgeGamma; mPartColorValueLDIndex = lcGetPreferences().mPartColorValueLDIndex; setWindowTitle(tr("Color Preferences")); @@ -37,20 +34,7 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH EdgeSettingsLayout->addWidget(PartEdgeContrastSlider,0,1); EdgeSettingsLayout->addWidget(PartEdgeContrast,0,2); - QLabel* PartEdgeGammaLabel = new QLabel(tr("Gamma:"), this); - PartEdgeGamma = new QLabel(this); - PartEdgeGammaSlider = new QSlider(Qt::Horizontal, this); - PartEdgeGammaSlider->setRange(0, 200); - PartEdgeGammaSlider->setValue(qRound((mPartEdgeGamma - MIN_GAMMA) * 100)); - PartEdgeGammaSlider->setToolTip(tr("Set the gamma (brightness) - normal range is 1.80 to 2.80.")); - connect(PartEdgeGammaSlider, SIGNAL(valueChanged(int)), this, SLOT(SliderValueChanged(int))); - emit PartEdgeGammaSlider->valueChanged(PartEdgeGammaSlider->value()); - - EdgeSettingsLayout->addWidget(PartEdgeGammaLabel,1,0); - EdgeSettingsLayout->addWidget(PartEdgeGammaSlider,1,1); - EdgeSettingsLayout->addWidget(PartEdgeGamma,1,2); - - QLabel* PartColorValueLDIndexLabel = new QLabel(tr("Value L/D Index:"), this); + QLabel* PartColorValueLDIndexLabel = new QLabel(tr("Light/Dark Value:"), this); PartColorValueLDIndex = new QLabel(this); PartColorValueLDIndexSlider = new QSlider(Qt::Horizontal, this); PartColorValueLDIndexSlider->setRange(0, 100); @@ -59,9 +43,9 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH connect(PartColorValueLDIndexSlider, SIGNAL(valueChanged(int)), this, SLOT(SliderValueChanged(int))); emit PartColorValueLDIndexSlider->valueChanged(PartColorValueLDIndexSlider->value()); - EdgeSettingsLayout->addWidget(PartColorValueLDIndexLabel,2,0); - EdgeSettingsLayout->addWidget(PartColorValueLDIndexSlider,2,1); - EdgeSettingsLayout->addWidget(PartColorValueLDIndex,2,2); + EdgeSettingsLayout->addWidget(PartColorValueLDIndexLabel,1,0); + EdgeSettingsLayout->addWidget(PartColorValueLDIndexSlider,1,1); + EdgeSettingsLayout->addWidget(PartColorValueLDIndex,1,2); QGroupBox* StudColorBox = new QGroupBox(tr("High Contrast Studs"), this); StudColorBox->setVisible(ShowHighContrastDialog); @@ -149,11 +133,6 @@ void lcAutomateEdgeColorDialog::SliderValueChanged(int Value) mPartEdgeContrast = Value * 0.01f; PartEdgeContrast->setText(QString::number(mPartEdgeContrast, 'f', 2)); } - else if (sender() == PartEdgeGammaSlider) - { - mPartEdgeGamma = (Value * 0.01f) + MIN_GAMMA; - PartEdgeGamma->setText(QString::number(mPartEdgeGamma, 'f', 2)); - } else if (sender() == PartColorValueLDIndexSlider) { mPartColorValueLDIndex = Value * 0.01f; @@ -212,7 +191,7 @@ void lcAutomateEdgeColorDialog::ResetColorButtonClicked() QPixmap Pix(12, 12); QColor ResetColor; - if (sender() == StudColorButton) + if (sender() == ResetStudColorButton) { Color = &mStudColor; *Color = LC_RGBA(27, 42, 52, 255); @@ -221,7 +200,7 @@ void lcAutomateEdgeColorDialog::ResetColorButtonClicked() StudColorButton->setIcon(Pix); StudColorButton->setToolTip(ResetColor.name().toUpper()); } - else if (sender() == StudEdgeColorButton) + else if (sender() == ResetStudEdgeColorButton) { Color = &mStudEdgeColor; *Color = LC_RGBA(0, 0, 0, 255); @@ -230,16 +209,16 @@ void lcAutomateEdgeColorDialog::ResetColorButtonClicked() StudEdgeColorButton->setIcon(Pix); StudEdgeColorButton->setToolTip(ResetColor.name().toUpper()); } - else if (sender() == BlackEdgeColorButton) + else if (sender() == ResetBlackEdgeColorButton) { Color = &mBlackEdgeColor; - *Color = LC_RGBA(0, 0, 0, 255); + *Color = LC_RGBA(255, 255, 255, 255); ResetColor = QColor(LC_RGBA_RED(*Color), LC_RGBA_GREEN(*Color), LC_RGBA_BLUE(*Color), LC_RGBA_ALPHA(*Color)); Pix.fill(ResetColor); BlackEdgeColorButton->setIcon(Pix); BlackEdgeColorButton->setToolTip(ResetColor.name().toUpper()); } - else if (sender() == DarkEdgeColorButton) + else if (sender() == ResetDarkEdgeColorButton) { Color = &mDarkEdgeColor; *Color = LC_RGBA(27, 42, 52, 255); diff --git a/common/lc_edgecolordialog.h b/common/lc_edgecolordialog.h index 35e46b77..1d0e6853 100644 --- a/common/lc_edgecolordialog.h +++ b/common/lc_edgecolordialog.h @@ -12,7 +12,6 @@ public: quint32 mDarkEdgeColor; quint32 mBlackEdgeColor; float mPartEdgeContrast; - float mPartEdgeGamma; float mPartColorValueLDIndex; protected slots: @@ -21,12 +20,10 @@ protected slots: void ResetColorButtonClicked(); protected: - QSlider* PartEdgeGammaSlider; QSlider* PartColorValueLDIndexSlider; QSlider* PartEdgeContrastSlider; QLabel* PartEdgeContrast; - QLabel* PartEdgeGamma; QLabel* PartColorValueLDIndex; QToolButton* StudColorButton; diff --git a/common/lc_math.h b/common/lc_math.h index 0e075830..169a32f4 100644 --- a/common/lc_math.h +++ b/common/lc_math.h @@ -14,8 +14,9 @@ #define LC_RGBA_GREEN(rgba) ((quint8)(((rgba) >> 8) & 0xff)) #define LC_RGBA_BLUE(rgba) ((quint8)(((rgba) >> 16) & 0xff)) #define LC_RGBA_ALPHA(rgba) ((quint8)(((rgba) >> 24) & 0xff)) -#define LC_GAMMA_ADJUST(v,g) (powf(v, g)) -#define LC_GAMMA_APPLY(v,g) (powf(v, 1.0f/g)) +#define LC_GAMMA (2.20f) +#define LC_GAMMA_ADJUST(v) (powf(v, LC_GAMMA)) +#define LC_GAMMA_APPLY(v) (powf(v, 1.0f/LC_GAMMA)) inline quint32 lcRGBAFromQColor(const QColor& Color) { diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index ef2cb912..829e1548 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -145,7 +145,6 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = lcProfileEntry("Settings", "BlackEdgeColor", LC_RGBA(255, 255, 255, 255)), // LC_PROFILE_BLACK_EDGE_COLOR lcProfileEntry("Settings", "DarkEdgeColor", LC_RGBA(27, 42, 52, 255)), // LC_PROFILE_DARK_EDGE_COLOR lcProfileEntry("Settings", "PartEdgeContrast", 0.5f), // LC_PROFILE_PART_EDGE_CONTRAST - lcProfileEntry("Settings", "PartEdgeGamma", 1.8f), // LC_PROFILE_PART_EDGE_GAMMA lcProfileEntry("Settings", "mPartColorValueLDIndex", 0.5f), // LC_PROFILE_PART_COLOR_VALUE_LD_INDEX lcProfileEntry("Settings", "AutomateEdgeColor", 0) // LC_PROFILE_AUTOMATE_EDGE_COLOR }; diff --git a/common/lc_profile.h b/common/lc_profile.h index c8c347ae..16d3b667 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -93,7 +93,6 @@ enum LC_PROFILE_KEY LC_PROFILE_BLACK_EDGE_COLOR, LC_PROFILE_DARK_EDGE_COLOR, LC_PROFILE_PART_EDGE_CONTRAST, - LC_PROFILE_PART_EDGE_GAMMA, LC_PROFILE_PART_COLOR_VALUE_LD_INDEX, LC_PROFILE_AUTOMATE_EDGE_COLOR, diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index b80c1383..5cf873b5 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -573,7 +573,6 @@ void lcQPreferencesDialog::AutomateEdgeColor() mOptions->Preferences.mBlackEdgeColor = Dialog.mBlackEdgeColor; mOptions->Preferences.mDarkEdgeColor = Dialog.mDarkEdgeColor; mOptions->Preferences.mPartEdgeContrast = Dialog.mPartEdgeContrast; - mOptions->Preferences.mPartEdgeGamma = Dialog.mPartEdgeGamma; mOptions->Preferences.mPartColorValueLDIndex = Dialog.mPartColorValueLDIndex; } }