Merge pull request #851 from trevorsandy/AUTOMATE_EDGE_COLOURS

Set high-contrast stud style colour preferences optional
This commit is contained in:
Leonardo Zide 2023-04-23 20:27:53 -07:00 committed by GitHub
commit 929d91394c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 217 additions and 111 deletions

View file

@ -64,9 +64,13 @@ void lcPreferences::LoadDefaults()
mPreviewViewSphereSize = lcGetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE);
mPreviewViewSphereLocation = static_cast<lcViewSphereLocation>(lcGetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION));
mDrawPreviewAxis = lcGetProfileInt(LC_PROFILE_PREVIEW_DRAW_AXES);
mStudCylinderColorEnabled = lcGetProfileInt(LC_PROFILE_STUD_CYLINDER_COLOR_ENABLED);
mStudCylinderColor = lcGetProfileInt(LC_PROFILE_STUD_CYLINDER_COLOR);
mPartEdgeColorEnabled = lcGetProfileInt(LC_PROFILE_PART_EDGE_COLOR_ENABLED);
mPartEdgeColor = lcGetProfileInt(LC_PROFILE_PART_EDGE_COLOR);
mBlackEdgeColorEnabled = lcGetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR_ENABLED);
mBlackEdgeColor = lcGetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR);
mDarkEdgeColorEnabled = lcGetProfileInt(LC_PROFILE_DARK_EDGE_COLOR_ENABLED);
mDarkEdgeColor = lcGetProfileInt(LC_PROFILE_DARK_EDGE_COLOR);
mPartEdgeContrast = lcGetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST);
mPartColorValueLDIndex = lcGetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX);
@ -124,9 +128,13 @@ void lcPreferences::SaveDefaults()
lcSetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE, mPreviewViewSphereSize);
lcSetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION, static_cast<int>(mPreviewViewSphereLocation));
lcSetProfileInt(LC_PROFILE_PREVIEW_DRAW_AXES, mDrawPreviewAxis);
lcSetProfileInt(LC_PROFILE_STUD_CYLINDER_COLOR_ENABLED, mStudCylinderColorEnabled);
lcSetProfileInt(LC_PROFILE_STUD_CYLINDER_COLOR, mStudCylinderColor);
lcSetProfileInt(LC_PROFILE_PART_EDGE_COLOR_ENABLED, mPartEdgeColorEnabled);
lcSetProfileInt(LC_PROFILE_PART_EDGE_COLOR, mPartEdgeColor);
lcSetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR_ENABLED, mBlackEdgeColorEnabled);
lcSetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR, mBlackEdgeColor);
lcSetProfileInt(LC_PROFILE_DARK_EDGE_COLOR_ENABLED, mDarkEdgeColorEnabled);
lcSetProfileInt(LC_PROFILE_DARK_EDGE_COLOR, mDarkEdgeColor);
lcSetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST, mPartEdgeContrast);
lcSetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX, mPartColorValueLDIndex);
@ -373,9 +381,13 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
Options.Viewpoint = lcViewpoint::Count;
Options.FadeStepsColor = Preferences.mFadeStepsColor;
Options.HighlightColor = Preferences.mHighlightNewPartsColor;
Options.StudCylinderColorEnabled = Preferences.mStudCylinderColorEnabled;
Options.StudCylinderColor = Preferences.mStudCylinderColor;
Options.PartEdgeColorEnabled = Preferences.mPartEdgeColorEnabled;
Options.PartEdgeColor = Preferences.mPartEdgeColor;
Options.BlackEdgeColorEnabled = Preferences.mBlackEdgeColorEnabled;
Options.BlackEdgeColor = Preferences.mBlackEdgeColor;
Options.DarkEdgeColorEnabled = Preferences.mDarkEdgeColorEnabled;
Options.DarkEdgeColor = Preferences.mDarkEdgeColor;
Options.PartEdgeContrast = Preferences.mPartEdgeContrast;
Options.PartColorValueLDIndex = Preferences.mPartColorValueLDIndex;
@ -627,76 +639,28 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
Options.ParseOK = false;
}
}
else if (Option == QLatin1String("-nscc") || Option == QLatin1String("--disable-stud-cylinder-color"))
Options.StudCylinderColorEnabled = false;
else if (Option == QLatin1String("-scc") || Option == QLatin1String("--stud-cylinder-color"))
{
if (ParseColor(Options.StudCylinderColor))
{
if (!lcIsHighContrast(Options.StudStyle))
{
Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
ParseColor(Options.StudCylinderColor);
else if (Option == QLatin1String("-nec") || Option == QLatin1String("--disable-edge-color"))
Options.PartEdgeColorEnabled = false;
else if (Option == QLatin1String("-ec") || Option == QLatin1String("--edge-color"))
{
if (ParseColor(Options.PartEdgeColor))
{
if (!lcIsHighContrast(Options.StudStyle))
{
Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
ParseColor(Options.PartEdgeColor);
else if (Option == QLatin1String("-nbec") || Option == QLatin1String("--disable-black-edge-color"))
Options.BlackEdgeColorEnabled = false;
else if (Option == QLatin1String("-bec") || Option == QLatin1String("--black-edge-color"))
{
if (ParseColor(Options.BlackEdgeColor))
{
if (!lcIsHighContrast(Options.StudStyle))
{
Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
ParseColor(Options.BlackEdgeColor);
else if (Option == QLatin1String("-ndec") || Option == QLatin1String("--disable-dark-edge-color"))
Options.DarkEdgeColorEnabled = false;
else if (Option == QLatin1String("-dec") || Option == QLatin1String("--dark-edge-color"))
{
if (ParseColor(Options.DarkEdgeColor))
{
if (!lcIsHighContrast(Options.StudStyle))
{
Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
ParseColor(Options.DarkEdgeColor);
else if (Option == QLatin1String("-aec") || Option == QLatin1String("--automate-edge-color"))
{
Options.AutomateEdgeColor = true;
}
else if (Option == QLatin1String("-cc") || Option == QLatin1String("--color-contrast"))
{
if (ParseFloat(Options.PartEdgeContrast, 0.0f, 1.0f))
{
if (!Options.AutomateEdgeColor)
{
Options.StdErr += tr("Automate edge color is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
ParseFloat(Options.PartEdgeContrast, 0.0f, 1.0f);
else if (Option == QLatin1String("-ldv") || Option == QLatin1String("--light-dark-value"))
{
if (ParseFloat(Options.PartColorValueLDIndex, 0.0f, 1.0f))
{
if (!Options.AutomateEdgeColor)
{
Options.StdErr += tr("Automate edge color is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
ParseFloat(Options.PartColorValueLDIndex, 0.0f, 1.0f);
else if (Option == QLatin1String("--fade-steps"))
Options.FadeSteps = true;
else if (Option == QLatin1String("--no-fade-steps"))
@ -823,9 +787,13 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
Options.StdOut += tr(" --shading <wireframe|flat|default|full>: Select shading mode for rendering.\n");
Options.StdOut += tr(" --line-width <width>: Set the width of the edge lines.\n");
Options.StdOut += tr(" --aa-samples <count>: AntiAliasing sample size (1, 2, 4, or 8).\n");
Options.StdOut += tr(" -nscc, --disable-stud-cylinder-color: Disable high contrast stud cylinder color.\n");
Options.StdOut += tr(" -scc, --stud-cylinder-color <#AARRGGBB>: High contrast stud cylinder color.\n");
Options.StdOut += tr(" -nec, --disable-edge-color: Disable high contrast edge color.\n");
Options.StdOut += tr(" -ec, --edge-color <#AARRGGBB>: High contrast edge color.\n");
Options.StdOut += tr(" -nbec, --disable-black-edge-color: Disable high contrast edge color for black parts.\n");
Options.StdOut += tr(" -bec, --black-edge-color <#AARRGGBB>: High contrast edge color for black parts.\n");
Options.StdOut += tr(" -ndec, --disable-dark-edge-color: Disable high contrast edge color for dark color parts.\n");
Options.StdOut += tr(" -dec, --dark-edge-color <#AARRGGBB>: High contrast edge color for dark color parts.\n");
Options.StdOut += tr(" -aec, --automate-edge-color: Enable automatically adjusted edge colors.\n");
Options.StdOut += tr(" -cc, --color-contrast <float>: Color contrast value between 0.0 and 1.0.\n");
@ -852,6 +820,46 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
Options.StdErr += tr("High contrast stud and edge color settings are ignored when -aec or --automate-edge-color is set.\n");
}
if (!Options.AutomateEdgeColor && !Preferences.mAutomateEdgeColor)
{
QString const Message = tr("Automate edge color is required for the '%1' option but is not enabled.\n");
if (Options.PartEdgeContrast != Preferences.mPartEdgeContrast)
Options.StdErr += Message.arg(QString("--color-contrast %1").arg(Options.PartEdgeContrast));
if (Options.PartColorValueLDIndex != Preferences.mPartColorValueLDIndex)
Options.StdErr += Message.arg(QString("--light-dark-value %1").arg(Options.PartColorValueLDIndex));
}
if (!lcIsHighContrast(Options.StudStyle) && !lcIsHighContrast(static_cast<lcStudStyle>(lcGetProfileInt(LC_PROFILE_STUD_STYLE))))
{
QString const Message = tr("High contrast stud style is required for the '%1' option but is not enabled.\n");
if (Options.StudCylinderColorEnabled != Preferences.mStudCylinderColorEnabled)
Options.StdErr += Message.arg(QLatin1String("--disable-stud-cylinder-color"));
if (Options.StudCylinderColor != Preferences.mStudCylinderColor)
Options.StdErr += Message.arg(QString("--stud-cylinder-color %1").arg(Options.StudCylinderColor));
if (Options.PartEdgeColorEnabled != Preferences.mPartEdgeColorEnabled)
Options.StdErr += Message.arg(QLatin1String("--disable-edge-color"));
if (Options.PartEdgeColor != Preferences.mPartEdgeColor)
Options.StdErr += Message.arg(QString("--edge-color %1").arg(Options.PartEdgeColor));
if (Options.BlackEdgeColorEnabled != Preferences.mBlackEdgeColorEnabled)
Options.StdErr += Message.arg(QLatin1String("--disable-black-edge-color"));
if (Options.BlackEdgeColor != Preferences.mBlackEdgeColor)
Options.StdErr += Message.arg(QString("--black-edge-color %1").arg(Options.BlackEdgeColor));
if (Options.DarkEdgeColorEnabled != Preferences.mDarkEdgeColorEnabled)
Options.StdErr += Message.arg(QLatin1String("--disable-dark-edge-color"));
if (Options.DarkEdgeColor != Preferences.mDarkEdgeColor)
Options.StdErr += Message.arg(QString("--dark-edge-color %1").arg(Options.DarkEdgeColor));
}
if (!Options.CameraName.isEmpty())
{
if (Options.Viewpoint != lcViewpoint::Count)
@ -953,15 +961,19 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
mPreferences.mShadingMode = Options.ShadingMode;
mPreferences.mLineWidth = Options.LineWidth;
mPreferences.mStudCylinderColorEnabled = Options.StudCylinderColorEnabled;
mPreferences.mStudCylinderColor = Options.StudCylinderColor;
mPreferences.mPartEdgeColorEnabled = Options.PartEdgeColorEnabled;
mPreferences.mPartEdgeColor = Options.PartEdgeColor;
mPreferences.mBlackEdgeColorEnabled = Options.BlackEdgeColorEnabled;
mPreferences.mBlackEdgeColor = Options.BlackEdgeColor;
mPreferences.mDarkEdgeColorEnabled = Options.DarkEdgeColorEnabled;
mPreferences.mDarkEdgeColor = Options.DarkEdgeColor;
mPreferences.mPartEdgeContrast = Options.PartEdgeContrast;
mPreferences.mPartColorValueLDIndex = Options.PartColorValueLDIndex;
mPreferences.mAutomateEdgeColor = Options.AutomateEdgeColor;
lcGetPiecesLibrary()->SetStudStyle(Options.StudStyle, false);
lcGetPiecesLibrary()->SetStudStyle(Options.StudStyle, false, Options.StudCylinderColorEnabled);
if (!SaveAndExit)
gMainWindow->CreateWidgets();
@ -1285,16 +1297,22 @@ void lcApplication::ShowPreferencesDialog()
bool LanguageChanged = Options.Language != lcGetProfileString(LC_PROFILE_LANGUAGE);
bool LibraryChanged = Options.LibraryPath != lcGetProfileString(LC_PROFILE_PARTS_LIBRARY);
bool ColorsChanged = Options.ColorConfigPath != lcGetProfileString(LC_PROFILE_COLOR_CONFIG);
bool ColorConfigChanged = Options.ColorConfigPath != lcGetProfileString(LC_PROFILE_COLOR_CONFIG);
bool AAChanged = CurrentAASamples != Options.AASamples;
bool StudStyleChanged = CurrentStudStyle != Options.StudStyle;
bool AutomateEdgeColorChanged = Options.Preferences.mAutomateEdgeColor != mPreferences.mAutomateEdgeColor;
AutomateEdgeColorChanged |= Options.Preferences.mStudCylinderColor != mPreferences.mStudCylinderColor;
AutomateEdgeColorChanged |= Options.Preferences.mPartEdgeColor != mPreferences.mPartEdgeColor;
AutomateEdgeColorChanged |= Options.Preferences.mBlackEdgeColor != mPreferences.mBlackEdgeColor;
AutomateEdgeColorChanged |= Options.Preferences.mDarkEdgeColor != mPreferences.mDarkEdgeColor;
AutomateEdgeColorChanged |= Options.Preferences.mPartEdgeContrast != mPreferences.mPartEdgeContrast;
AutomateEdgeColorChanged |= Options.Preferences.mPartColorValueLDIndex != mPreferences.mPartColorValueLDIndex;
bool StudCylinderColorEnabledChanged = Options.Preferences.mStudCylinderColorEnabled != mPreferences.mStudCylinderColorEnabled;
bool EdgeColorSettingsChanged = Options.Preferences.mAutomateEdgeColor != mPreferences.mAutomateEdgeColor;
EdgeColorSettingsChanged |= Options.Preferences.mPartEdgeContrast != mPreferences.mPartEdgeContrast;
EdgeColorSettingsChanged |= Options.Preferences.mPartColorValueLDIndex != mPreferences.mPartColorValueLDIndex;
EdgeColorSettingsChanged |= Options.Preferences.mStudCylinderColorEnabled != mPreferences.mStudCylinderColorEnabled;
EdgeColorSettingsChanged |= Options.Preferences.mStudCylinderColor != mPreferences.mStudCylinderColor;
EdgeColorSettingsChanged |= Options.Preferences.mPartEdgeColorEnabled != mPreferences.mPartEdgeColorEnabled;
EdgeColorSettingsChanged |= Options.Preferences.mPartEdgeColor != mPreferences.mPartEdgeColor;
EdgeColorSettingsChanged |= Options.Preferences.mBlackEdgeColorEnabled != mPreferences.mBlackEdgeColorEnabled;
EdgeColorSettingsChanged |= Options.Preferences.mBlackEdgeColor != mPreferences.mBlackEdgeColor;
EdgeColorSettingsChanged |= Options.Preferences.mDarkEdgeColorEnabled != mPreferences.mDarkEdgeColorEnabled;
EdgeColorSettingsChanged |= Options.Preferences.mDarkEdgeColor != mPreferences.mDarkEdgeColor;
mPreferences = Options.Preferences;
@ -1351,15 +1369,16 @@ void lcApplication::ShowPreferencesDialog()
}
}
if (StudStyleChanged)
if (StudStyleChanged || StudCylinderColorEnabledChanged)
{
lcSetProfileInt(LC_PROFILE_STUD_STYLE, static_cast<int>(Options.StudStyle));
lcGetPiecesLibrary()->SetStudStyle(Options.StudStyle, true);
lcGetPiecesLibrary()->SetStudStyle(Options.StudStyle, true, Options.Preferences.mStudCylinderColorEnabled);
}
else if (ColorsChanged || AutomateEdgeColorChanged)
else if (ColorConfigChanged || EdgeColorSettingsChanged)
{
if (ColorsChanged)
if (ColorConfigChanged)
lcSetProfileString(LC_PROFILE_COLOR_CONFIG, Options.ColorConfigPath);
lcGetPiecesLibrary()->LoadColors();
}

View file

@ -90,9 +90,13 @@ public:
lcViewSphereLocation mPreviewViewSphereLocation;
int mDrawPreviewAxis;
bool mStudCylinderColorEnabled;
quint32 mStudCylinderColor;
bool mPartEdgeColorEnabled;
quint32 mPartEdgeColor;
bool mBlackEdgeColorEnabled;
quint32 mBlackEdgeColor;
bool mDarkEdgeColorEnabled;
quint32 mDarkEdgeColor;
float mPartEdgeContrast;
float mPartColorValueLDIndex;
@ -134,9 +138,13 @@ struct lcCommandLineOptions
float PartColorValueLDIndex;
lcVector2 ZPlanes;
lcViewpoint Viewpoint;
bool StudCylinderColorEnabled;
quint32 StudCylinderColor;
bool PartEdgeColorEnabled;
quint32 PartEdgeColor;
bool BlackEdgeColorEnabled;
quint32 BlackEdgeColor;
bool DarkEdgeColorEnabled;
quint32 DarkEdgeColor;
quint32 FadeStepsColor;
quint32 HighlightColor;

View file

@ -52,13 +52,13 @@ static void lcAdjustStudStyleColors(std::vector<lcColor>& Colors, lcStudStyle St
}
else
{
if (Color.Code == 4242)
if (Color.Code == LC_STUD_CYLINDER_COLOR_CODE)
continue;
else if (Color.Code == 0)
else if (Preferences.mBlackEdgeColorEnabled && Color.Code == 0)
Color.Edge = BlackEdge;
else if (ValueLuminescence < LightDarkControl)
else if (Preferences.mDarkEdgeColorEnabled && ValueLuminescence < LightDarkControl)
Color.Edge = DarkEdge;
else
else if (Preferences.mPartEdgeColorEnabled)
Color.Edge = Edge;
}
}
@ -206,7 +206,7 @@ bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle)
if (Valid)
lcAdjustStudStyleColors(Colors, StudStyle);
bool FoundMain = false, FoundEdge = false, FoundStud = false, FoundNoColor = false;
bool FoundMain = false, FoundEdge = false, FoundStudCylinder = false, FoundNoColor = false;
for (const lcColor& Color : Colors)
{
@ -220,8 +220,8 @@ bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle)
FoundEdge = true;
break;
case 4242:
FoundStud = true;
case LC_STUD_CYLINDER_COLOR_CODE:
FoundStudCylinder = true;
break;
case LC_COLOR_NOCOLOR:
@ -272,12 +272,12 @@ bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle)
Colors.push_back(EdgeColor);
}
if (!FoundStud)
if (!FoundStudCylinder)
{
const lcPreferences& Preferences = lcGetPreferences();
lcColor StudCylinderColor;
StudCylinderColor.Code = 4242;
StudCylinderColor.Code = LC_STUD_CYLINDER_COLOR_CODE;
StudCylinderColor.Translucent = false;
StudCylinderColor.Group = LC_NUM_COLORGROUPS;
StudCylinderColor.Value = lcVector4FromColor(Preferences.mStudCylinderColor);

View file

@ -6,6 +6,7 @@
#define LC_MAX_COLOR_NAME 64
#define LC_COLOR_DIRECT 0x80000000
#define LC_COLOR_NOCOLOR 0xffffffff
#define LC_STUD_CYLINDER_COLOR_CODE 4242
struct lcColor
{

View file

@ -5,9 +5,13 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH
:QDialog(Parent)
{
const lcPreferences& Preferences = lcGetPreferences();
mStudCylinderColorEnabled = Preferences.mStudCylinderColorEnabled;
mStudCylinderColor = Preferences.mStudCylinderColor;
mPartEdgeColorEnabled = Preferences.mPartEdgeColorEnabled;
mPartEdgeColor = Preferences.mPartEdgeColor;
mBlackEdgeColorEnabled = Preferences.mBlackEdgeColorEnabled;
mBlackEdgeColor = Preferences.mBlackEdgeColor;
mDarkEdgeColorEnabled = Preferences.mDarkEdgeColorEnabled;
mDarkEdgeColor = Preferences.mDarkEdgeColor;
mPartEdgeContrast = Preferences.mPartEdgeContrast;
mPartColorValueLDIndex = Preferences.mPartColorValueLDIndex;
@ -80,55 +84,75 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH
Button->setToolTip(ButtonColor.name().toUpper());
};
QLabel* StudCylinderColorLabel = new QLabel(tr("Stud Cylinder Color:"), this);
StudCylinderColorEnabledBox = new QCheckBox(tr("Stud Cylinder Color:"), this);
StudCylinderColorEnabledBox->setChecked(mStudCylinderColorEnabled);
connect(StudCylinderColorEnabledBox, SIGNAL(clicked()), this, SLOT(ColorCheckBoxClicked()));
StudCylinderColorButton = new QToolButton(this);
StudCylinderColorButton->setEnabled(mStudCylinderColorEnabled);
SetButtonPixmap(mStudCylinderColor, StudCylinderColorButton);
connect(StudCylinderColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetStudCylinderColorButton = new QToolButton(this);
ResetStudCylinderColorButton->setText(tr("Reset"));;
ResetStudCylinderColorButton->setText(tr("Reset"));
ResetStudCylinderColorButton->setEnabled(mStudCylinderColorEnabled);
connect(ResetStudCylinderColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
HighContrastColorLayout->addWidget(StudCylinderColorLabel,0,0);
HighContrastColorLayout->addWidget(StudCylinderColorEnabledBox,0,0);
HighContrastColorLayout->addWidget(StudCylinderColorButton,0,1);
HighContrastColorLayout->addWidget(ResetStudCylinderColorButton,0,2);
QLabel* PartEdgeColorLabel = new QLabel(tr("Parts Edge Color:"), this);
PartEdgeColorEnabledBox = new QCheckBox(tr("Parts Edge Color:"), this);
PartEdgeColorEnabledBox->setChecked(mPartEdgeColorEnabled);
connect(PartEdgeColorEnabledBox, SIGNAL(clicked()), this, SLOT(ColorCheckBoxClicked()));
PartEdgeColorButton = new QToolButton(this);
PartEdgeColorButton->setEnabled(mPartEdgeColorEnabled);
SetButtonPixmap(mPartEdgeColor, PartEdgeColorButton);
connect(PartEdgeColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetPartEdgeColorButton = new QToolButton(this);
ResetPartEdgeColorButton->setText(tr("Reset"));
ResetPartEdgeColorButton->setEnabled(mPartEdgeColorEnabled);
connect(ResetPartEdgeColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
HighContrastColorLayout->addWidget(PartEdgeColorLabel,1,0);
HighContrastColorLayout->addWidget(PartEdgeColorEnabledBox,1,0);
HighContrastColorLayout->addWidget(PartEdgeColorButton,1,1);
HighContrastColorLayout->addWidget(ResetPartEdgeColorButton,1,2);
QLabel* BlackEdgeColorLabel = new QLabel(tr("Black Parts Edge Color:"), this);
BlackEdgeColorEnabledBox = new QCheckBox(tr("Black Parts Edge Color:"), this);
BlackEdgeColorEnabledBox->setChecked(mBlackEdgeColorEnabled);
connect(BlackEdgeColorEnabledBox, SIGNAL(clicked()), this, SLOT(ColorCheckBoxClicked()));
BlackEdgeColorButton = new QToolButton(this);
BlackEdgeColorButton->setEnabled(mBlackEdgeColorEnabled);
SetButtonPixmap(mBlackEdgeColor, BlackEdgeColorButton);
connect(BlackEdgeColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetBlackEdgeColorButton = new QToolButton(this);
ResetBlackEdgeColorButton->setText(tr("Reset"));
ResetBlackEdgeColorButton->setEnabled(mBlackEdgeColorEnabled);
connect(ResetBlackEdgeColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
HighContrastColorLayout->addWidget(BlackEdgeColorLabel,2,0);
HighContrastColorLayout->addWidget(BlackEdgeColorEnabledBox,2,0);
HighContrastColorLayout->addWidget(BlackEdgeColorButton,2,1);
HighContrastColorLayout->addWidget(ResetBlackEdgeColorButton,2,2);
QLabel* DarkEdgeColorLabel = new QLabel(tr("Dark Parts Edge Color:"), this);
DarkEdgeColorEnabledBox = new QCheckBox(tr("Dark Parts Edge Color:"), this);
DarkEdgeColorEnabledBox->setChecked(mDarkEdgeColorEnabled);
connect(DarkEdgeColorEnabledBox, SIGNAL(clicked()), this, SLOT(ColorCheckBoxClicked()));
DarkEdgeColorButton = new QToolButton(this);
DarkEdgeColorButton->setEnabled(mDarkEdgeColorEnabled);
SetButtonPixmap(mDarkEdgeColor, DarkEdgeColorButton);
connect(DarkEdgeColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetDarkEdgeColorButton = new QToolButton(this);
ResetDarkEdgeColorButton->setText(tr("Reset"));
ResetDarkEdgeColorButton->setEnabled(mDarkEdgeColorEnabled);
connect(ResetDarkEdgeColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
HighContrastColorLayout->addWidget(DarkEdgeColorLabel,3,0);
HighContrastColorLayout->addWidget(DarkEdgeColorEnabledBox,3,0);
HighContrastColorLayout->addWidget(DarkEdgeColorButton,3,1);
HighContrastColorLayout->addWidget(ResetDarkEdgeColorButton,3,2);
@ -140,6 +164,35 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH
setMinimumSize(220,100);
}
void lcAutomateEdgeColorDialog::ColorCheckBoxClicked()
{
QObject* CheckBox = sender();
if (CheckBox == StudCylinderColorEnabledBox)
{
mStudCylinderColorEnabled = StudCylinderColorEnabledBox->isChecked();
StudCylinderColorButton->setEnabled(mStudCylinderColorEnabled);
ResetStudCylinderColorButton->setEnabled(mStudCylinderColorEnabled);
}
else if (CheckBox == PartEdgeColorEnabledBox)
{
mPartEdgeColorEnabled = PartEdgeColorEnabledBox->isChecked();
PartEdgeColorButton->setEnabled(mPartEdgeColorEnabled);
ResetPartEdgeColorButton->setEnabled(mPartEdgeColorEnabled);
}
else if (CheckBox == BlackEdgeColorEnabledBox)
{
mBlackEdgeColorEnabled = BlackEdgeColorEnabledBox->isChecked();
BlackEdgeColorButton->setEnabled(mBlackEdgeColorEnabled);
ResetBlackEdgeColorButton->setEnabled(mBlackEdgeColorEnabled);
}
else if (CheckBox == DarkEdgeColorEnabledBox)
{
mDarkEdgeColorEnabled = DarkEdgeColorEnabledBox->isChecked();
DarkEdgeColorButton->setEnabled(mDarkEdgeColorEnabled);
ResetDarkEdgeColorButton->setEnabled(mDarkEdgeColorEnabled);
}
}
void lcAutomateEdgeColorDialog::SliderValueChanged(int Value)
{
if (sender() == PartEdgeContrastSlider)

View file

@ -7,10 +7,14 @@ class lcAutomateEdgeColorDialog : public QDialog
Q_OBJECT
public:
lcAutomateEdgeColorDialog(QWidget *Parent, bool ShowHighContrastDialog);
bool mStudCylinderColorEnabled;
quint32 mStudCylinderColor;
bool mPartEdgeColorEnabled;
quint32 mPartEdgeColor;
quint32 mDarkEdgeColor;
bool mBlackEdgeColorEnabled;
quint32 mBlackEdgeColor;
bool mDarkEdgeColorEnabled;
quint32 mDarkEdgeColor;
float mPartEdgeContrast;
float mPartColorValueLDIndex;
@ -18,6 +22,7 @@ protected slots:
void SliderValueChanged(int);
void ResetSliderButtonClicked();
void ColorButtonClicked();
void ColorCheckBoxClicked();
void ResetColorButtonClicked();
protected:
@ -30,6 +35,11 @@ protected:
QToolButton* ResetPartEdgeContrastButton;
QToolButton* ResetPartColorValueLDIndexButton;
QCheckBox* StudCylinderColorEnabledBox;
QCheckBox* PartEdgeColorEnabledBox;
QCheckBox* BlackEdgeColorEnabledBox;
QCheckBox* DarkEdgeColorEnabledBox;
QToolButton* StudCylinderColorButton;
QToolButton* PartEdgeColorButton;
QToolButton* BlackEdgeColorButton;

View file

@ -44,6 +44,7 @@ lcPiecesLibrary::lcPiecesLibrary()
mHasUnofficial = false;
mCancelLoading = false;
mStudStyle = static_cast<lcStudStyle>(lcGetProfileInt(LC_PROFILE_STUD_STYLE));
mStudCylinderColorEnabled = lcGetProfileInt(LC_PROFILE_STUD_CYLINDER_COLOR_ENABLED);
}
lcPiecesLibrary::~lcPiecesLibrary()
@ -335,7 +336,7 @@ void lcPiecesLibrary::UpdateStudStyleSource()
mZipFiles[static_cast<int>(lcZipFileType::StudStyle)].reset();
if (mStudStyle == lcStudStyle::Plain)
if (mStudStyle == lcStudStyle::Plain || (mStudStyle >= lcStudStyle::HighContrast && !mStudCylinderColorEnabled))
return;
const QLatin1String FileNames[] =
@ -1121,7 +1122,7 @@ bool lcPiecesLibrary::LoadCachePiece(PieceInfo* Info)
if (MeshData.ReadBuffer((char*)&Flags, sizeof(Flags)) == 0)
return false;
if (Flags != static_cast<qint32>(mStudStyle))
if (Flags != static_cast<qint32>(mStudStyle) + static_cast<qint32>(mStudCylinderColorEnabled))
return false;
lcMesh* Mesh = new lcMesh;
@ -1141,7 +1142,7 @@ bool lcPiecesLibrary::SaveCachePiece(PieceInfo* Info)
{
lcMemFile MeshData;
const qint32 Flags = static_cast<qint32>(mStudStyle);
const qint32 Flags = static_cast<qint32>(mStudStyle) + static_cast<qint32>(mStudCylinderColorEnabled);
if (MeshData.WriteBuffer((char*)&Flags, sizeof(Flags)) == 0)
return false;
@ -1550,13 +1551,15 @@ bool lcPiecesLibrary::SupportsStudStyle() const
return true;
}
void lcPiecesLibrary::SetStudStyle(lcStudStyle StudStyle, bool Reload)
void lcPiecesLibrary::SetStudStyle(lcStudStyle StudStyle, bool Reload, bool StudCylinderColorEnabled)
{
if (mStudStyle == StudStyle)
if (mStudStyle == StudStyle && mStudCylinderColorEnabled == StudCylinderColorEnabled)
return;
mStudStyle = StudStyle;
mStudCylinderColorEnabled = StudCylinderColorEnabled;
LoadColors();
UpdateStudStyleSource();

View file

@ -1,7 +1,6 @@
#pragma once
#include "lc_context.h"
#include "lc_mesh.h"
#include "lc_math.h"
#include "lc_array.h"
#include "lc_meshloader.h"
@ -164,7 +163,7 @@ public:
bool LoadPrimitive(lcLibraryPrimitive* Primitive);
bool SupportsStudStyle() const;
void SetStudStyle(lcStudStyle StudStyle, bool Reload);
void SetStudStyle(lcStudStyle StudStyle, bool Reload, bool StudCylinderColorEnabled);
lcStudStyle GetStudStyle() const
{
@ -235,6 +234,7 @@ protected:
QMutex mTextureMutex;
lcStudStyle mStudStyle;
bool mStudCylinderColorEnabled;
QString mCachePath;
qint64 mArchiveCheckSum[4];

View file

@ -148,12 +148,16 @@ 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", "StudCylinderColorEnabled", true), // LC_PROFILE_STUD_CYLINDER_COLOR_ENABLED
lcProfileEntry("Settings", "StudCylinderColor", LC_RGBA(27, 42, 52, 255)), // LC_PROFILE_STUD_CYLINDER_COLOR
lcProfileEntry("Settings", "PartEdgeColorEnabled", true), // LC_PROFILE_PART_EDGE_COLOR_ENABLED
lcProfileEntry("Settings", "PartEdgeColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_PART_EDGE_COLOR
lcProfileEntry("Settings", "BlackEdgeColorEnabled", true), // LC_PROFILE_BLACK_EDGE_COLOR_ENABLED
lcProfileEntry("Settings", "BlackEdgeColor", LC_RGBA(255, 255, 255, 255)), // LC_PROFILE_BLACK_EDGE_COLOR
lcProfileEntry("Settings", "DarkEdgeColorEnabled", true), // LC_PROFILE_DARK_EDGE_COLOR_ENABLED
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", "mPartColorValueLDIndex", 0.5f), // LC_PROFILE_PART_COLOR_VALUE_LD_INDEX
lcProfileEntry("Settings", "PartColorValueLDIndex", 0.5f), // LC_PROFILE_PART_COLOR_VALUE_LD_INDEX
lcProfileEntry("Settings", "AutomateEdgeColor", 0) // LC_PROFILE_AUTOMATE_EDGE_COLOR
};

View file

@ -96,9 +96,13 @@ enum LC_PROFILE_KEY
LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION,
LC_PROFILE_PREVIEW_DRAW_AXES,
LC_PROFILE_STUD_CYLINDER_COLOR_ENABLED,
LC_PROFILE_STUD_CYLINDER_COLOR,
LC_PROFILE_PART_EDGE_COLOR_ENABLED,
LC_PROFILE_PART_EDGE_COLOR,
LC_PROFILE_BLACK_EDGE_COLOR_ENABLED,
LC_PROFILE_BLACK_EDGE_COLOR,
LC_PROFILE_DARK_EDGE_COLOR_ENABLED,
LC_PROFILE_DARK_EDGE_COLOR,
LC_PROFILE_PART_EDGE_CONTRAST,
LC_PROFILE_PART_COLOR_VALUE_LD_INDEX,

View file

@ -636,9 +636,13 @@ void lcQPreferencesDialog::AutomateEdgeColor()
lcAutomateEdgeColorDialog Dialog(this, sender() == ui->HighContrastButton);
if (Dialog.exec() == QDialog::Accepted)
{
mOptions->Preferences.mStudCylinderColorEnabled = Dialog.mStudCylinderColorEnabled;
mOptions->Preferences.mStudCylinderColor = Dialog.mStudCylinderColor;
mOptions->Preferences.mPartEdgeColorEnabled = Dialog.mPartEdgeColorEnabled;
mOptions->Preferences.mPartEdgeColor = Dialog.mPartEdgeColor;
mOptions->Preferences.mBlackEdgeColorEnabled = Dialog.mBlackEdgeColorEnabled;
mOptions->Preferences.mBlackEdgeColor = Dialog.mBlackEdgeColor;
mOptions->Preferences.mDarkEdgeColorEnabled = Dialog.mDarkEdgeColorEnabled;
mOptions->Preferences.mDarkEdgeColor = Dialog.mDarkEdgeColor;
mOptions->Preferences.mPartEdgeContrast = Dialog.mPartEdgeContrast;
mOptions->Preferences.mPartColorValueLDIndex = Dialog.mPartColorValueLDIndex;