Automate edge colours cleanup

This commit is contained in:
Trevor SANDY 2021-01-25 08:34:22 +01:00
parent daf459d670
commit 512785de36
9 changed files with 84 additions and 82 deletions

View file

@ -62,7 +62,7 @@ void lcPreferences::LoadDefaults()
mStudEdgeColor = lcGetProfileInt(LC_PROFILE_STUD_EDGE_COLOR);
mPartEdgeContrast = lcGetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST);
mPartEdgeGamma = lcGetProfileFloat(LC_PROFILE_PART_EDGE_GAMMA);
mPartColorToneIndex = lcGetProfileFloat(LC_PROFILE_PART_COLOR_TONE_INDEX);
mPartColorValueLDIndex = lcGetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX);
mAutomateEdgeColor = lcGetProfileInt(LC_PROFILE_AUTOMATE_EDGE_COLOR);
}
@ -113,7 +113,7 @@ void lcPreferences::SaveDefaults()
lcSetProfileInt(LC_PROFILE_STUD_EDGE_COLOR, mStudEdgeColor);
lcSetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST, mPartEdgeContrast);
lcSetProfileFloat(LC_PROFILE_PART_EDGE_GAMMA, mPartEdgeGamma);
lcSetProfileFloat(LC_PROFILE_PART_COLOR_TONE_INDEX, mPartColorToneIndex);
lcSetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX, mPartColorValueLDIndex);
lcSetProfileInt(LC_PROFILE_AUTOMATE_EDGE_COLOR, mAutomateEdgeColor);
}
@ -1158,15 +1158,15 @@ void lcApplication::ShowPreferencesDialog()
bool ColorsChanged = Options.ColorConfigPath != lcGetProfileString(LC_PROFILE_COLOR_CONFIG);
bool AAChanged = CurrentAASamples != Options.AASamples;
bool StudStyleChanged = CurrentStudStyle != Options.StudStyle;
bool AutomateEdgeColorChanged = Options.Preferences.mAutomateEdgeColor != lcGetProfileInt(LC_PROFILE_AUTOMATE_EDGE_COLOR);
bool AutomateEdgeColorChanged = Options.Preferences.mAutomateEdgeColor != bool(lcGetProfileInt(LC_PROFILE_AUTOMATE_EDGE_COLOR));
bool StudColorChanged = Options.Preferences.mStudColor != quint32(lcGetProfileInt(LC_PROFILE_STUD_COLOR));
bool StudEdgeColorChanged = Options.Preferences.mStudEdgeColor != quint32(lcGetProfileInt(LC_PROFILE_STUD_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 PartColorToneIndexChanged = Options.Preferences.mPartColorToneIndex != lcGetProfileFloat(LC_PROFILE_PART_COLOR_TONE_INDEX);
if (!StudStyleChanged)
StudStyleChanged = (StudColorChanged || StudEdgeColorChanged || PartEdgeContrastChanged || PartEdgeGammaChanged || PartColorToneIndexChanged);
/*** LPub3D Mod - ***/
bool PartColorValueLDIndexChanged = Options.Preferences.mPartColorValueLDIndex != lcGetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX);
if (!AutomateEdgeColorChanged)
AutomateEdgeColorChanged = (StudColorChanged || StudEdgeColorChanged || PartEdgeContrastChanged || PartEdgeGammaChanged || PartColorValueLDIndexChanged);
mPreferences = Options.Preferences;
mPreferences.SaveDefaults();

View file

@ -77,7 +77,7 @@ public:
quint32 mStudEdgeColor;
float mPartEdgeContrast;
float mPartEdgeGamma;
float mPartColorToneIndex;
float mPartColorValueLDIndex;
bool mAutomateEdgeColor;
};

View file

@ -226,7 +226,7 @@ static void lcAdjustStudStyleColors(std::vector<lcColor>& Colors, lcStudStyle St
float ValueLuminescence = 0.2126f * r + 0.7152f * g + 0.0722f * b;
if (LC_GAMMA_APPLY(ValueLuminescence, lcGetPreferences().mPartEdgeGamma) > (lcGetPreferences().mPartColorToneIndex))
if (LC_GAMMA_APPLY(ValueLuminescence, lcGetPreferences().mPartEdgeGamma) > (lcGetPreferences().mPartColorValueLDIndex))
EdgeLuminescence = ValueLuminescence - (ValueLuminescence * lcGetPreferences().mPartEdgeContrast);
else
EdgeLuminescence = (1.0f - ValueLuminescence) * lcGetPreferences().mPartEdgeContrast + ValueLuminescence;
@ -461,18 +461,25 @@ bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle)
if (!FoundStud)
{
lcColor StudColor;
lcVector4 Value = lcVector4(LC_RGBA_RED(lcGetPreferences().mStudColor),
LC_RGBA_GREEN(lcGetPreferences().mStudColor),
LC_RGBA_BLUE(lcGetPreferences().mStudColor),
LC_RGBA_ALPHA(lcGetPreferences().mStudColor)) / 255.0f;
lcVector4 Edge = lcVector4(LC_RGBA_RED(lcGetPreferences().mStudEdgeColor),
LC_RGBA_GREEN(lcGetPreferences().mStudEdgeColor),
LC_RGBA_BLUE(lcGetPreferences().mStudEdgeColor),
LC_RGBA_ALPHA(lcGetPreferences().mStudEdgeColor)) / 255.0f;
StudColor.Code = 4242;
StudColor.Translucent = false;
StudColor.Group = LC_NUM_COLORGROUPS;
StudColor.Value[0] = 27.0f / 255.0f;
StudColor.Value[1] = 42.0f / 255.0f;
StudColor.Value[2] = 52.0f / 255.0f;
StudColor.Value[3] = 1.0f;
StudColor.Edge[0] = 0.0f;
StudColor.Edge[1] = 0.0f;
StudColor.Edge[2] = 0.0f;
StudColor.Edge[3] = 1.0f;
StudColor.Value[0] = Value[0];
StudColor.Value[1] = Value[1];
StudColor.Value[2] = Value[2];
StudColor.Value[3] = Value[3];
StudColor.Edge[0] = Edge[0];
StudColor.Edge[1] = Edge[1];
StudColor.Edge[2] = Edge[2];
StudColor.Edge[3] = Edge[3];
strcpy(StudColor.Name, "Stud Style Black");
strcpy(StudColor.SafeName, "Stud_Style_Black");

View file

@ -10,22 +10,22 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent)
mStudEdgeColor = lcGetPreferences().mStudEdgeColor;
mPartEdgeContrast = lcGetPreferences().mPartEdgeContrast;
mPartEdgeGamma = lcGetPreferences().mPartEdgeGamma;
mPartColorToneIndex = lcGetPreferences().mPartColorToneIndex;
mPartColorValueLDIndex = lcGetPreferences().mPartColorValueLDIndex;
setWindowTitle(QString("Edge Color Preferences"));
QVBoxLayout* mainLayout = new QVBoxLayout(this);
setWindowTitle(tr("Color Preferences"));
QVBoxLayout* MainLayout = new QVBoxLayout(this);
QGroupBox* EdgeSettingsBox = new QGroupBox("Part Edge Color Settings",this);
mainLayout->addWidget(EdgeSettingsBox);
QGroupBox* EdgeSettingsBox = new QGroupBox(tr("Edge Colors"), this);
MainLayout->addWidget(EdgeSettingsBox);
QGridLayout* EdgeSettingsLayout = new QGridLayout(EdgeSettingsBox);
EdgeSettingsBox->setLayout(EdgeSettingsLayout);
QLabel* PartEdgeContrastLabel = new QLabel(tr("Contrast:"), this);
PartEdgeContrast = new QLabel(this);
PartEdgeContrastSlider = new QSlider(Qt::Horizontal, this);
PartEdgeContrastSlider->setRange(0, 10);
PartEdgeContrastSlider->setValue(mPartEdgeContrast * 10);
PartEdgeContrastSlider->setToolTip(tr("Set the amount of contrast - 0.5 is midway."));
PartEdgeContrastSlider->setRange(0, 100);
PartEdgeContrastSlider->setValue(mPartEdgeContrast * 100);
PartEdgeContrastSlider->setToolTip(tr("Set the amount of contrast - 0.50 is midway."));
connect(PartEdgeContrastSlider, SIGNAL(valueChanged(int)), this, SLOT(SliderValueChanged(int)));
emit PartEdgeContrastSlider->valueChanged(PartEdgeContrastSlider->value());
@ -33,12 +33,12 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent)
EdgeSettingsLayout->addWidget(PartEdgeContrastSlider,0,1);
EdgeSettingsLayout->addWidget(PartEdgeContrast,0,2);
QLabel* PartEdgeGammaLabel = new QLabel(tr("Brightness:"), this);
QLabel* PartEdgeGammaLabel = new QLabel(tr("Gamma:"), this);
PartEdgeGamma = new QLabel(this);
PartEdgeGammaSlider = new QSlider(Qt::Horizontal, this);
PartEdgeGammaSlider->setRange(0, 20);
PartEdgeGammaSlider->setValue(qRound((mPartEdgeGamma - MIN_GAMMA) * 10));
PartEdgeGammaSlider->setToolTip(tr("Set the brightness (gamma) - the normal range is 1.8 to 2.8."));
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());
@ -46,21 +46,21 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent)
EdgeSettingsLayout->addWidget(PartEdgeGammaSlider,1,1);
EdgeSettingsLayout->addWidget(PartEdgeGamma,1,2);
QLabel* PartColorToneIndexLabel = new QLabel(tr("Tone Index:"), this);
PartColorToneIndex = new QLabel(this);
PartColorToneIndexSlider = new QSlider(Qt::Horizontal, this);
PartColorToneIndexSlider->setRange(0, 10);
PartColorToneIndexSlider->setValue(mPartColorToneIndex * 10);
PartColorToneIndexSlider->setToolTip(tr("Set to classify where colors are either light or dark - e.g. Dark Bluish Gray (72) is classified as a light color at 0.4."));
connect(PartColorToneIndexSlider, SIGNAL(valueChanged(int)), this, SLOT(SliderValueChanged(int)));
emit PartColorToneIndexSlider->valueChanged(PartColorToneIndexSlider->value());
QLabel* PartColorValueLDIndexLabel = new QLabel(tr("Value L/D Index:"), this);
PartColorValueLDIndex = new QLabel(this);
PartColorValueLDIndexSlider = new QSlider(Qt::Horizontal, this);
PartColorValueLDIndexSlider->setRange(0, 100);
PartColorValueLDIndexSlider->setValue(mPartColorValueLDIndex * 100);
PartColorValueLDIndexSlider->setToolTip(tr("Set to classify where color values are light or dark - e.g. Dark Bluish Gray (72) is light at 0.39."));
connect(PartColorValueLDIndexSlider, SIGNAL(valueChanged(int)), this, SLOT(SliderValueChanged(int)));
emit PartColorValueLDIndexSlider->valueChanged(PartColorValueLDIndexSlider->value());
EdgeSettingsLayout->addWidget(PartColorToneIndexLabel,2,0);
EdgeSettingsLayout->addWidget(PartColorToneIndexSlider,2,1);
EdgeSettingsLayout->addWidget(PartColorToneIndex,2,2);
EdgeSettingsLayout->addWidget(PartColorValueLDIndexLabel,2,0);
EdgeSettingsLayout->addWidget(PartColorValueLDIndexSlider,2,1);
EdgeSettingsLayout->addWidget(PartColorValueLDIndex,2,2);
QGroupBox* StudColorBox = new QGroupBox("High Contrast Style", this);
mainLayout->addWidget(StudColorBox);
QGroupBox* StudColorBox = new QGroupBox(tr("High Contrast Studs"), this);
MainLayout->addWidget(StudColorBox);
QGridLayout* StudColorLayout = new QGridLayout(StudColorBox);
StudColorBox->setLayout(StudColorLayout);
@ -101,9 +101,8 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent)
StudColorLayout->addWidget(StudEdgeColorButton,1,1);
StudColorLayout->addWidget(ResetStudEdgeColorButton,1,2);
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this);
mainLayout->addWidget(buttonBox);
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
MainLayout->addWidget(buttonBox);
QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
@ -112,21 +111,20 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent)
void lcAutomateEdgeColorDialog::SliderValueChanged(int Value)
{
float Result;
if (sender() == PartEdgeContrastSlider)
{
Result = Value * 0.1f;
PartEdgeContrast->setText(QString::number(Result));
mPartEdgeContrast = Value * 0.01f;
PartEdgeContrast->setText(QString::number(mPartEdgeContrast, 'f', 2));
}
else if (sender() == PartEdgeGammaSlider)
{
Result = (Value * 0.1f) + MIN_GAMMA;
PartEdgeGamma->setText(QString::number(Result));
mPartEdgeGamma = (Value * 0.01f) + MIN_GAMMA;
PartEdgeGamma->setText(QString::number(mPartEdgeGamma, 'f', 2));
}
else if (sender() == PartColorToneIndexSlider)
else if (sender() == PartColorValueLDIndexSlider)
{
Result = Value * 0.1f;
PartColorToneIndex->setText(QString::number(Result));
mPartColorValueLDIndex = Value * 0.01f;
PartColorValueLDIndex->setText(QString::number(mPartColorValueLDIndex, 'f', 2));
}
}
@ -150,46 +148,43 @@ void lcAutomateEdgeColorDialog::ColorButtonClicked()
else
return;
QColor oldColor = QColor(LC_RGBA_RED(*Color), LC_RGBA_GREEN(*Color), LC_RGBA_BLUE(*Color), LC_RGBA_ALPHA(*Color));
QColor NewColor = QColorDialog::getColor(oldColor, this, Title, DialogOptions);
QColor OldColor = QColor(LC_RGBA_RED(*Color), LC_RGBA_GREEN(*Color), LC_RGBA_BLUE(*Color), LC_RGBA_ALPHA(*Color));
QColor NewColor = QColorDialog::getColor(OldColor, this, Title, DialogOptions);
if (NewColor == oldColor || !NewColor.isValid())
if (NewColor == OldColor || !NewColor.isValid())
return;
*Color = LC_RGBA(NewColor.red(), NewColor.green(), NewColor.blue(), NewColor.alpha());
QPixmap pix(12, 12);
QPixmap Pix(12, 12);
NewColor.setAlpha(255);
pix.fill(NewColor);
((QToolButton*)Button)->setIcon(pix);
Pix.fill(NewColor);
((QToolButton*)Button)->setIcon(Pix);
((QToolButton*)Button)->setToolTip(NewColor.name().toUpper());
}
void lcAutomateEdgeColorDialog::ResetColorButtonClicked()
{
quint32* Color = nullptr;
QPixmap pix(12, 12);
QPixmap Pix(12, 12);
QColor ResetColor;
if (sender() == StudColorButton)
{
*Color = LC_RGBA(5, 19, 29, 128);
if (mStudColor == *Color)
return;
Color = &mStudColor;
*Color = LC_RGBA(27, 42, 52, 255);
ResetColor = QColor(LC_RGBA_RED(*Color), LC_RGBA_GREEN(*Color), LC_RGBA_BLUE(*Color), LC_RGBA_ALPHA(*Color));
pix.fill(ResetColor);
StudColorButton->setIcon(pix);
Pix.fill(ResetColor);
StudColorButton->setIcon(Pix);
StudColorButton->setToolTip(ResetColor.name().toUpper());
}
else if (sender() == StudEdgeColorButton)
{
*Color = LC_RGBA(255, 255, 255, 255);
if (mStudEdgeColor == *Color)
return;
Color = &mStudEdgeColor;
*Color = LC_RGBA(0, 0, 0, 255);
ResetColor = QColor(LC_RGBA_RED(*Color), LC_RGBA_GREEN(*Color), LC_RGBA_BLUE(*Color), LC_RGBA_ALPHA(*Color));
pix.fill(ResetColor);
StudEdgeColorButton->setIcon(pix);
Pix.fill(ResetColor);
StudEdgeColorButton->setIcon(Pix);
StudEdgeColorButton->setToolTip(ResetColor.name().toUpper());
}
}

View file

@ -11,7 +11,7 @@ public:
quint32 mStudEdgeColor;
float mPartEdgeContrast;
float mPartEdgeGamma;
float mPartColorToneIndex;
float mPartColorValueLDIndex;
protected slots:
void SliderValueChanged(int);
@ -20,7 +20,7 @@ protected slots:
protected:
QSlider* PartEdgeGammaSlider;
QSlider* PartColorToneIndexSlider;
QSlider* PartColorValueLDIndexSlider;
QSlider* PartEdgeContrastSlider;
QToolButton* StudColorButton;
@ -30,6 +30,6 @@ protected:
QLabel* PartEdgeContrast;
QLabel* PartEdgeGamma;
QLabel* PartColorToneIndex;
QLabel* PartColorValueLDIndex;
};

View file

@ -140,11 +140,11 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] =
lcProfileEntry("Settings", "PreviewViewSphereLocation", (int)lcViewSphereLocation::TopRight), // LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION
lcProfileEntry("Settings", "DrawPreviewAxis", 0), // LC_PROFILE_PREVIEW_DRAW_AXES
lcProfileEntry("Settings", "StudColor", LC_RGBA(5, 19, 29, 255)), // LC_PROFILE_STUD_COLOR
lcProfileEntry("Settings", "StudColor", LC_RGBA(27, 42, 52, 255)), // LC_PROFILE_STUD_COLOR
lcProfileEntry("Settings", "StudEdgeColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_STUD_EDGE_COLOR
lcProfileEntry("Settings", "PartEdgeContrast", 0.5f), // LC_PROFILE_PART_EDGE_CONTRAST
lcProfileEntry("Settings", "PartEdgeGamma", 1.8f), // LC_PROFILE_PART_EDGE_GAMMA
lcProfileEntry("Settings", "PartColorToneIndex", 0.5f), // LC_PROFILE_PART_COLOR_TONE_INDEX
lcProfileEntry("Settings", "PartEdgeContrast", 0.50f), // LC_PROFILE_PART_EDGE_CONTRAST
lcProfileEntry("Settings", "PartEdgeGamma", 2.20f), // LC_PROFILE_PART_EDGE_GAMMA
lcProfileEntry("Settings", "PartColorValueLDIndex", 0.50f), // LC_PROFILE_PART_COLOR_VALUE_LD_INDEX
lcProfileEntry("Settings", "AutomateEdgeColor", 0) // LC_PROFILE_AUTOMATE_EDGE_COLOR
};

View file

@ -92,7 +92,7 @@ enum LC_PROFILE_KEY
LC_PROFILE_STUD_EDGE_COLOR,
LC_PROFILE_PART_EDGE_CONTRAST,
LC_PROFILE_PART_EDGE_GAMMA,
LC_PROFILE_PART_COLOR_TONE_INDEX,
LC_PROFILE_PART_COLOR_VALUE_LD_INDEX,
LC_PROFILE_AUTOMATE_EDGE_COLOR,
LC_NUM_PROFILE_KEYS

View file

@ -566,7 +566,7 @@ void lcQPreferencesDialog::AutomateEdgeColor()
mOptions->Preferences.mStudEdgeColor = Dialog.mStudEdgeColor;
mOptions->Preferences.mPartEdgeContrast = Dialog.mPartEdgeContrast;
mOptions->Preferences.mPartEdgeGamma = Dialog.mPartEdgeGamma;
mOptions->Preferences.mPartColorToneIndex = Dialog.mPartColorToneIndex;
mOptions->Preferences.mPartColorValueLDIndex = Dialog.mPartColorValueLDIndex;
}
}

View file

@ -547,7 +547,7 @@
<item row="7" column="0">
<widget class="QCheckBox" name="AutomateEdgeColor">
<property name="text">
<string>Automate Edge Color:</string>
<string>Automate edge color:</string>
</property>
</widget>
</item>