Remove configurable gamma setting and fix colour reset action

This commit is contained in:
Trevor SANDY 2021-01-25 21:18:43 +01:00
parent feeb034ff9
commit 7f06b93e1e
9 changed files with 18 additions and 48 deletions

View file

@ -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;

View file

@ -78,7 +78,6 @@ public:
quint32 mBlackEdgeColor;
quint32 mDarkEdgeColor;
float mPartEdgeContrast;
float mPartEdgeGamma;
float mPartColorValueLDIndex;
bool mAutomateEdgeColor;
};

View file

@ -220,18 +220,18 @@ static void lcAdjustStudStyleColors(std::vector<lcColor>& 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);
}

View file

@ -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);

View file

@ -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;

View file

@ -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)
{

View file

@ -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
};

View file

@ -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,

View file

@ -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;
}
}