Merge pull request #611 from trevorsandy/AUTOMATE_EDGE_COLOURS

Automate edge colours
This commit is contained in:
Leonardo Zide 2021-01-26 14:39:49 -08:00 committed by GitHub
commit 486cf42fbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 284 additions and 148 deletions

View file

@ -58,8 +58,8 @@ 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);
mStudColor = lcGetProfileInt(LC_PROFILE_STUD_COLOR);
mStudEdgeColor = lcGetProfileInt(LC_PROFILE_STUD_EDGE_COLOR);
mStudCylinderColor = lcGetProfileInt(LC_PROFILE_STUD_CYLINDER_COLOR);
mPartEdgeColor = lcGetProfileInt(LC_PROFILE_PART_EDGE_COLOR);
mBlackEdgeColor = lcGetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR);
mDarkEdgeColor = lcGetProfileInt(LC_PROFILE_DARK_EDGE_COLOR);
mPartEdgeContrast = lcGetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST);
@ -110,8 +110,8 @@ 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_COLOR, mStudColor);
lcSetProfileInt(LC_PROFILE_STUD_EDGE_COLOR, mStudEdgeColor);
lcSetProfileInt(LC_PROFILE_STUD_CYLINDER_COLOR, mStudCylinderColor);
lcSetProfileInt(LC_PROFILE_PART_EDGE_COLOR, mPartEdgeColor);
lcSetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR, mBlackEdgeColor);
lcSetProfileInt(LC_PROFILE_DARK_EDGE_COLOR, mDarkEdgeColor);
lcSetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST, mPartEdgeContrast);
@ -366,6 +366,13 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
Options.Viewpoint = lcViewpoint::Count;
Options.FadeStepsColor = mPreferences.mFadeStepsColor;
Options.HighlightColor = mPreferences.mHighlightNewPartsColor;
Options.StudCylinderColor = mPreferences.mStudCylinderColor;
Options.PartEdgeColor = mPreferences.mPartEdgeColor;
Options.BlackEdgeColor = mPreferences.mBlackEdgeColor;
Options.DarkEdgeColor = mPreferences.mDarkEdgeColor;
Options.PartEdgeContrast = mPreferences.mPartEdgeContrast;
Options.PartColorValueLDIndex = mPreferences.mPartColorValueLDIndex;
Options.AutomateEdgeColor = mPreferences.mAutomateEdgeColor;
QStringList Arguments = arguments();
@ -613,6 +620,76 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
Options.ParseOK = false;
}
}
else if (Option == QLatin1String("-scc") || Option == QLatin1String("--stud-cylinder-color"))
{
if (ParseColor(Options.StudCylinderColor))
{
if (Options.StudStyle < lcStudStyle::HighContrast)
{
Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
else if (Option == QLatin1String("-ec") || Option == QLatin1String("--edge-color"))
{
if (ParseColor(Options.PartEdgeColor))
{
if (Options.StudStyle < lcStudStyle::HighContrast)
{
Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
else if (Option == QLatin1String("-bec") || Option == QLatin1String("--black-edge-color"))
{
if (ParseColor(Options.BlackEdgeColor))
{
if (Options.StudStyle < lcStudStyle::HighContrast)
{
Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
else if (Option == QLatin1String("-dec") || Option == QLatin1String("--dark-edge-color"))
{
if (ParseColor(Options.DarkEdgeColor))
{
if (Options.StudStyle < lcStudStyle::HighContrast)
{
Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option);
Options.ParseOK = false;
}
}
}
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;
}
}
}
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;
}
}
}
else if (Option == QLatin1String("--fade-steps"))
Options.FadeSteps = true;
else if (Option == QLatin1String("--no-fade-steps"))
@ -734,6 +811,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 with of the edge lines.\n");
Options.StdOut += tr(" --aa-samples <count>: AntiAliasing sample size (1, 2, 4, or 8).\n");
Options.StdOut += tr(" -scc, --stud-cylinder-color <#AARRGGBB>: High contrast stud cylinder color.\n");
Options.StdOut += tr(" -ec, --edge-color <#AARRGGBB>: High contrast edge color.\n");
Options.StdOut += tr(" -bec, --black-edge-color <#AARRGGBB>: High contrast edge color for black 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");
Options.StdOut += tr(" -ldv, --light-dark-value <float>: Light/Dark color value between 0.0 and 1.0.\n");
Options.StdOut += tr(" -obj, --export-wavefront <outfile.obj>: Export the model to Wavefront OBJ format.\n");
Options.StdOut += tr(" -3ds, --export-3ds <outfile.3ds>: Export the model to 3D Studio 3DS format.\n");
Options.StdOut += tr(" -dae, --export-collada <outfile.dae>: Export the model to COLLADA DAE format.\n");
@ -750,6 +834,12 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
}
}
if (Options.AutomateEdgeColor && Options.StudStyle > lcStudStyle::FlattenedLogo)
{
Options.StdErr += tr("Automate edge color and high contrast stud style cannot be enabled at the same time.\n");
Options.ParseOK = false;
}
if (!Options.CameraName.isEmpty())
{
if (Options.Viewpoint != lcViewpoint::Count)
@ -849,6 +939,14 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
}
}
mPreferences.mStudCylinderColor = Options.StudCylinderColor;
mPreferences.mPartEdgeColor = Options.PartEdgeColor;
mPreferences.mBlackEdgeColor = Options.BlackEdgeColor;
mPreferences.mDarkEdgeColor = Options.DarkEdgeColor;
mPreferences.mPartEdgeContrast = Options.PartEdgeContrast;
mPreferences.mPartColorValueLDIndex = Options.PartColorValueLDIndex;
mPreferences.mAutomateEdgeColor = Options.AutomateEdgeColor;
lcGetPiecesLibrary()->SetStudStyle(Options.StudStyle, false);
if (!SaveAndExit)
@ -1161,8 +1259,8 @@ void lcApplication::ShowPreferencesDialog()
bool AAChanged = CurrentAASamples != Options.AASamples;
bool StudStyleChanged = CurrentStudStyle != Options.StudStyle;
bool AutomateEdgeColorChanged = Options.Preferences.mAutomateEdgeColor != mPreferences.mAutomateEdgeColor;
AutomateEdgeColorChanged |= Options.Preferences.mStudColor != mPreferences.mStudColor;
AutomateEdgeColorChanged |= Options.Preferences.mStudEdgeColor != mPreferences.mStudEdgeColor;
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;

View file

@ -73,8 +73,8 @@ public:
lcViewSphereLocation mPreviewViewSphereLocation;
int mDrawPreviewAxis;
quint32 mStudColor;
quint32 mStudEdgeColor;
quint32 mStudCylinderColor;
quint32 mPartEdgeColor;
quint32 mBlackEdgeColor;
quint32 mDarkEdgeColor;
float mPartEdgeContrast;
@ -100,6 +100,7 @@ struct lcCommandLineOptions
bool SetHighlightColor;
bool FadeSteps;
bool ImageHighlight;
bool AutomateEdgeColor;
int ImageWidth;
int ImageHeight;
int AASamples;
@ -109,8 +110,14 @@ struct lcCommandLineOptions
lcVector3 CameraPosition[3];
lcVector2 CameraLatLon;
float FoV;
float PartEdgeContrast;
float PartColorValueLDIndex;
lcVector2 ZPlanes;
lcViewpoint Viewpoint;
quint32 StudCylinderColor;
quint32 PartEdgeColor;
quint32 BlackEdgeColor;
quint32 DarkEdgeColor;
quint32 FadeStepsColor;
quint32 HighlightColor;
QString ImageName;

View file

@ -213,21 +213,21 @@ int lcGetBrickLinkColor(int ColorIndex)
static void lcAdjustStudStyleColors(std::vector<lcColor>& Colors, lcStudStyle StudStyle)
{
const lcPreferences& Preferences = lcGetPreferences();
if (!Preferences.mAutomateEdgeColor && StudStyle != lcStudStyle::HighContrast && StudStyle != lcStudStyle::HighContrastLogo)
return;
const float LDIndex = LC_SRGB_TO_LINEAR(Preferences.mPartColorValueLDIndex);
const lcVector4 Edge = lcVector4FromColor(Preferences.mPartEdgeColor);
const lcVector4 DarkEdge = lcVector4FromColor(Preferences.mDarkEdgeColor);
const lcVector4 BlackEdge = lcVector4FromColor(Preferences.mBlackEdgeColor);
if (Preferences.mAutomateEdgeColor)
for (lcColor& Color : Colors)
{
for (lcColor& Color : Colors)
float ValueLuminescence = lcLuminescenceFromRGBA(Color.Value);
if (Preferences.mAutomateEdgeColor)
{
if (Color.Code == 4242)
continue;
float EdgeLuminescence = 0.0f;
float r = LC_SRGB_TO_LINEAR(Color.Value[0]);
float g = LC_SRGB_TO_LINEAR(Color.Value[1]);
float b = LC_SRGB_TO_LINEAR(Color.Value[2]);
float ValueLuminescence = 0.2126f * r + 0.7152f * g + 0.0722f * b;
if (ValueLuminescence > LDIndex)
EdgeLuminescence = ValueLuminescence - (ValueLuminescence * Preferences.mPartEdgeContrast);
@ -238,26 +238,17 @@ static void lcAdjustStudStyleColors(std::vector<lcColor>& Colors, lcStudStyle St
Color.Edge = lcVector4(EdgeLuminescence, EdgeLuminescence, EdgeLuminescence, 1.0f);
}
return;
}
if (StudStyle != lcStudStyle::HighContrast && StudStyle != lcStudStyle::HighContrastLogo)
return;
const lcVector4 Edge = lcVector4FromColor(Preferences.mStudEdgeColor);
const lcVector4 DarkEdge = lcVector4FromColor(Preferences.mDarkEdgeColor);
const lcVector4 BlackEdge = lcVector4FromColor(Preferences.mBlackEdgeColor);
for (lcColor& Color : Colors)
{
const lcVector4 FillColor = Color.Value * 255.0f;
if (30.0f * FillColor[0] + 59.0f * FillColor[1] + 11.0f * FillColor[2] <= 3600.0f)
Color.Edge = DarkEdge;
else if (Color.Code == 0)
Color.Edge = BlackEdge;
else
Color.Edge = Edge;
{
if (Color.Code == 4242)
continue;
else if (Color.Code == 0)
Color.Edge = BlackEdge;
else if (ValueLuminescence < LDIndex)
Color.Edge = DarkEdge;
else
Color.Edge = Edge;
}
}
}
@ -355,7 +346,7 @@ static std::vector<lcColor> lcParseColorFile(lcFile& File)
Color.Group = LC_COLORGROUP_SPECIAL;
}
else if (!strcmp(Token, "CHROME") || !strcmp(Token, "PEARLESCENT") || !strcmp(Token, "RUBBER") ||
!strcmp(Token, "MATTE_METALIC") || !strcmp(Token, "METAL") || !strcmp(Token, "LUMINANCE"))
!strcmp(Token, "MATTE_METALIC") || !strcmp(Token, "METAL") || !strcmp(Token, "LUMINANCE"))
{
Color.Group = LC_COLORGROUP_SPECIAL;
}
@ -468,17 +459,17 @@ bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle)
if (!FoundStud)
{
const lcPreferences& Preferences = lcGetPreferences();
lcColor StudColor;
lcColor StudCylinderColor;
StudColor.Code = 4242;
StudColor.Translucent = false;
StudColor.Group = LC_NUM_COLORGROUPS;
StudColor.Value = lcVector4FromColor(Preferences.mStudColor);
StudColor.Edge = lcVector4FromColor(Preferences.mStudEdgeColor);
strcpy(StudColor.Name, "Stud Style Black");
strcpy(StudColor.SafeName, "Stud_Style_Black");
StudCylinderColor.Code = 4242;
StudCylinderColor.Translucent = false;
StudCylinderColor.Group = LC_NUM_COLORGROUPS;
StudCylinderColor.Value = lcVector4FromColor(Preferences.mStudCylinderColor);
StudCylinderColor.Edge = lcVector4FromColor(Preferences.mPartEdgeColor);
strcpy(StudCylinderColor.Name, "Stud Cylinder Color");
strcpy(StudCylinderColor.SafeName, "Stud_Cylinder_Color");
Colors.push_back(StudColor);
Colors.push_back(StudCylinderColor);
}
for (lcColor& Color : gColorList)

View file

@ -4,41 +4,46 @@
lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowHighContrastDialog)
:QDialog(Parent)
{
mStudColor = lcGetPreferences().mStudColor;
mStudEdgeColor = lcGetPreferences().mStudEdgeColor;
mBlackEdgeColor = lcGetPreferences().mBlackEdgeColor;
mDarkEdgeColor = lcGetPreferences().mDarkEdgeColor;
mPartEdgeContrast = lcGetPreferences().mPartEdgeContrast;
mPartColorValueLDIndex = lcGetPreferences().mPartColorValueLDIndex;
const lcPreferences& Preferences = lcGetPreferences();
mStudCylinderColor = Preferences.mStudCylinderColor;
mPartEdgeColor = Preferences.mPartEdgeColor;
mBlackEdgeColor = Preferences.mBlackEdgeColor;
mDarkEdgeColor = Preferences.mDarkEdgeColor;
mPartEdgeContrast = Preferences.mPartEdgeContrast;
mPartColorValueLDIndex = Preferences.mPartColorValueLDIndex;
setWindowTitle(tr("Color Preferences"));
QVBoxLayout* MainLayout = new QVBoxLayout(this);
QGroupBox* EdgeSettingsBox = new QGroupBox(tr("Edge Colors"), this);
EdgeSettingsBox->setVisible(!ShowHighContrastDialog);
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, 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());
int LDIndexRow = 0;
PartEdgeContrast = nullptr;
PartEdgeContrastSlider = nullptr;
if (!ShowHighContrastDialog)
{
LDIndexRow = 1;
QLabel* PartEdgeContrastLabel = new QLabel(tr("Contrast:"), this);
PartEdgeContrast = new QLabel(this);
PartEdgeContrastSlider = new QSlider(Qt::Horizontal, this);
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());
ResetPartEdgeContrastButton = new QToolButton(this);
ResetPartEdgeContrastButton->setText(tr("..."));
ResetPartEdgeContrastButton->setToolTip(tr("Reset"));
connect(ResetPartEdgeContrastButton, SIGNAL(clicked()), this, SLOT(ResetSliderButtonClicked()));
ResetPartEdgeContrastButton = new QToolButton(this);
ResetPartEdgeContrastButton->setText(tr("Reset"));
connect(ResetPartEdgeContrastButton, SIGNAL(clicked()), this, SLOT(ResetSliderButtonClicked()));
EdgeSettingsLayout->addWidget(PartEdgeContrastLabel,0,0);
EdgeSettingsLayout->addWidget(PartEdgeContrastSlider,0,1);
EdgeSettingsLayout->addWidget(PartEdgeContrast,0,2);
EdgeSettingsLayout->addWidget(ResetPartEdgeContrastButton,0,3);
EdgeSettingsLayout->addWidget(PartEdgeContrastLabel,0,0);
EdgeSettingsLayout->addWidget(PartEdgeContrastSlider,0,1);
EdgeSettingsLayout->addWidget(PartEdgeContrast,0,2);
EdgeSettingsLayout->addWidget(ResetPartEdgeContrastButton,0,3);
}
QLabel* PartColorValueLDIndexLabel = new QLabel(tr("Light/Dark Value:"), this);
PartColorValueLDIndex = new QLabel(this);
@ -50,20 +55,19 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH
emit PartColorValueLDIndexSlider->valueChanged(PartColorValueLDIndexSlider->value());
ResetPartColorValueLDIndexButton = new QToolButton(this);
ResetPartColorValueLDIndexButton->setText(tr("..."));
ResetPartColorValueLDIndexButton->setToolTip(tr("Reset"));
ResetPartColorValueLDIndexButton->setText(tr("Reset"));
connect(ResetPartColorValueLDIndexButton, SIGNAL(clicked()), this, SLOT(ResetSliderButtonClicked()));
EdgeSettingsLayout->addWidget(PartColorValueLDIndexLabel,1,0);
EdgeSettingsLayout->addWidget(PartColorValueLDIndexSlider,1,1);
EdgeSettingsLayout->addWidget(PartColorValueLDIndex,1,2);
EdgeSettingsLayout->addWidget(ResetPartColorValueLDIndexButton,1,3);
EdgeSettingsLayout->addWidget(PartColorValueLDIndexLabel,LDIndexRow,0);
EdgeSettingsLayout->addWidget(PartColorValueLDIndexSlider,LDIndexRow,1);
EdgeSettingsLayout->addWidget(PartColorValueLDIndex,LDIndexRow,2);
EdgeSettingsLayout->addWidget(ResetPartColorValueLDIndexButton,LDIndexRow,3);
QGroupBox* StudColorBox = new QGroupBox(tr("High Contrast Studs"), this);
StudColorBox->setVisible(ShowHighContrastDialog);
MainLayout->addWidget(StudColorBox);
QGridLayout* StudColorLayout = new QGridLayout(StudColorBox);
StudColorBox->setLayout(StudColorLayout);
QGroupBox* HighContrastColorBox = new QGroupBox(tr("High Contrast"), this);
HighContrastColorBox->setVisible(ShowHighContrastDialog);
MainLayout->addWidget(HighContrastColorBox);
QGridLayout* HighContrastColorLayout = new QGridLayout(HighContrastColorBox);
HighContrastColorBox->setLayout(HighContrastColorLayout);
auto SetButtonPixmap = [](quint32 Color, QToolButton* Button)
{
@ -74,33 +78,31 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH
Button->setToolTip(ButtonColor.name().toUpper());
};
QLabel* StudColorLabel = new QLabel(tr("Stud Color:"), this);
StudColorButton = new QToolButton(this);
SetButtonPixmap(mStudColor, StudColorButton);
connect(StudColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
QLabel* StudCylinderColorLabel = new QLabel(tr("Stud Cylinder Color:"), this);
StudCylinderColorButton = new QToolButton(this);
SetButtonPixmap(mStudCylinderColor, StudCylinderColorButton);
connect(StudCylinderColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetStudColorButton = new QToolButton(this);
ResetStudColorButton->setText(tr("..."));
ResetStudColorButton->setToolTip(tr("Reset"));
connect(ResetStudColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
ResetStudCylinderColorButton = new QToolButton(this);
ResetStudCylinderColorButton->setText(tr("Reset"));;
connect(ResetStudCylinderColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
StudColorLayout->addWidget(StudColorLabel,0,0);
StudColorLayout->addWidget(StudColorButton,0,1);
StudColorLayout->addWidget(ResetStudColorButton,0,2);
HighContrastColorLayout->addWidget(StudCylinderColorLabel,0,0);
HighContrastColorLayout->addWidget(StudCylinderColorButton,0,1);
HighContrastColorLayout->addWidget(ResetStudCylinderColorButton,0,2);
QLabel* StudEdgeColorLabel = new QLabel(tr("Stud Edge Color:"), this);
StudEdgeColorButton = new QToolButton(this);
SetButtonPixmap(mStudEdgeColor, StudEdgeColorButton);
connect(StudEdgeColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
QLabel* PartEdgeColorLabel = new QLabel(tr("Parts Edge Color:"), this);
PartEdgeColorButton = new QToolButton(this);
SetButtonPixmap(mPartEdgeColor, PartEdgeColorButton);
connect(PartEdgeColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetStudEdgeColorButton = new QToolButton(this);
ResetStudEdgeColorButton->setText(tr("..."));
ResetStudEdgeColorButton->setToolTip(tr("Reset"));
connect(ResetStudEdgeColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
ResetPartEdgeColorButton = new QToolButton(this);
ResetPartEdgeColorButton->setText(tr("Reset"));
connect(ResetPartEdgeColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
StudColorLayout->addWidget(StudEdgeColorLabel,1,0);
StudColorLayout->addWidget(StudEdgeColorButton,1,1);
StudColorLayout->addWidget(ResetStudEdgeColorButton,1,2);
HighContrastColorLayout->addWidget(PartEdgeColorLabel,1,0);
HighContrastColorLayout->addWidget(PartEdgeColorButton,1,1);
HighContrastColorLayout->addWidget(ResetPartEdgeColorButton,1,2);
QLabel* BlackEdgeColorLabel = new QLabel(tr("Black Parts Edge Color:"), this);
BlackEdgeColorButton = new QToolButton(this);
@ -108,13 +110,12 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH
connect(BlackEdgeColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetBlackEdgeColorButton = new QToolButton(this);
ResetBlackEdgeColorButton->setText(tr("..."));
ResetBlackEdgeColorButton->setToolTip(tr("Reset"));
ResetBlackEdgeColorButton->setText(tr("Reset"));
connect(ResetBlackEdgeColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
StudColorLayout->addWidget(BlackEdgeColorLabel,2,0);
StudColorLayout->addWidget(BlackEdgeColorButton,2,1);
StudColorLayout->addWidget(ResetBlackEdgeColorButton,2,2);
HighContrastColorLayout->addWidget(BlackEdgeColorLabel,2,0);
HighContrastColorLayout->addWidget(BlackEdgeColorButton,2,1);
HighContrastColorLayout->addWidget(ResetBlackEdgeColorButton,2,2);
QLabel* DarkEdgeColorLabel = new QLabel(tr("Dark Parts Edge Color:"), this);
DarkEdgeColorButton = new QToolButton(this);
@ -122,13 +123,12 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowH
connect(DarkEdgeColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetDarkEdgeColorButton = new QToolButton(this);
ResetDarkEdgeColorButton->setText(tr("..."));
ResetDarkEdgeColorButton->setToolTip(tr("Reset"));
ResetDarkEdgeColorButton->setText(tr("Reset"));
connect(ResetDarkEdgeColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
StudColorLayout->addWidget(DarkEdgeColorLabel,3,0);
StudColorLayout->addWidget(DarkEdgeColorButton,3,1);
StudColorLayout->addWidget(ResetDarkEdgeColorButton,3,2);
HighContrastColorLayout->addWidget(DarkEdgeColorLabel,3,0);
HighContrastColorLayout->addWidget(DarkEdgeColorButton,3,1);
HighContrastColorLayout->addWidget(ResetDarkEdgeColorButton,3,2);
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
MainLayout->addWidget(buttonBox);
@ -159,23 +159,22 @@ void lcAutomateEdgeColorDialog::ColorButtonClicked()
quint32* Color = nullptr;
QColorDialog::ColorDialogOptions DialogOptions;
if (Button == StudColorButton)
if (Button == StudCylinderColorButton)
{
Title = tr("Select Stud Color");
Color = &mStudColor;
Title = tr("Select Stud Cylinder Color");
Color = &mStudCylinderColor;
}
else if (Button == StudEdgeColorButton)
else if (Button == PartEdgeColorButton)
{
Title = tr("Select Stud Edge Color");
Color = &mStudEdgeColor;
Title = tr("Select Part Edge Color");
Color = &mPartEdgeColor;
}
else if (Button == BlackEdgeColorButton)
{
if (lcGetPreferences().mAutomateEdgeColor)
{
QMessageBox msgBox;
msgBox.setText("Automate edge colour appears to be enabled.<br>"
"Black parts edge color setting will not be accessible.");
msgBox.setText("Automate edge color appears to be enabled.<br>Black parts edge color will not be accessible.<br>Do you want to continue ?");
if (msgBox.exec() != QMessageBox::Accepted)
return;
}
@ -187,8 +186,7 @@ void lcAutomateEdgeColorDialog::ColorButtonClicked()
if (lcGetPreferences().mAutomateEdgeColor)
{
QMessageBox msgBox;
msgBox.setText("Automate edge colour appears to be enabled.<br>"
"Dark parts edge color setting will not be accessible.");
msgBox.setText("Automate edge color appears to be enabled.<br>Dark parts edge color will not be accessible.<br>Do you want to continue ?");
if (msgBox.exec() != QMessageBox::Accepted)
return;
}
@ -218,12 +216,10 @@ void lcAutomateEdgeColorDialog::ResetSliderButtonClicked()
if (sender() == ResetPartEdgeContrastButton)
{
PartEdgeContrastSlider->setValue(0.5f * 100);
emit PartEdgeContrastSlider->valueChanged(PartEdgeContrastSlider->value());
}
else if (sender() == ResetPartColorValueLDIndexButton)
{
PartColorValueLDIndexSlider->setValue(0.5f * 100);
emit PartColorValueLDIndexSlider->valueChanged(PartColorValueLDIndexSlider->value());
}
}
@ -233,23 +229,23 @@ void lcAutomateEdgeColorDialog::ResetColorButtonClicked()
QPixmap Pix(12, 12);
QColor ResetColor;
if (sender() == ResetStudColorButton)
if (sender() == ResetStudCylinderColorButton)
{
Color = &mStudColor;
Color = &mStudCylinderColor;
*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);
StudColorButton->setToolTip(ResetColor.name().toUpper());
StudCylinderColorButton->setIcon(Pix);
StudCylinderColorButton->setToolTip(ResetColor.name().toUpper());
}
else if (sender() == ResetStudEdgeColorButton)
else if (sender() == ResetPartEdgeColorButton)
{
Color = &mStudEdgeColor;
Color = &mPartEdgeColor;
*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);
StudEdgeColorButton->setToolTip(ResetColor.name().toUpper());
PartEdgeColorButton->setIcon(Pix);
PartEdgeColorButton->setToolTip(ResetColor.name().toUpper());
}
else if (sender() == ResetBlackEdgeColorButton)
{

View file

@ -7,8 +7,8 @@ class lcAutomateEdgeColorDialog : public QDialog
Q_OBJECT
public:
lcAutomateEdgeColorDialog(QWidget *Parent, bool ShowHighContrastDialog);
quint32 mStudColor;
quint32 mStudEdgeColor;
quint32 mStudCylinderColor;
quint32 mPartEdgeColor;
quint32 mDarkEdgeColor;
quint32 mBlackEdgeColor;
float mPartEdgeContrast;
@ -30,13 +30,13 @@ protected:
QToolButton* ResetPartEdgeContrastButton;
QToolButton* ResetPartColorValueLDIndexButton;
QToolButton* StudColorButton;
QToolButton* StudEdgeColorButton;
QToolButton* StudCylinderColorButton;
QToolButton* PartEdgeColorButton;
QToolButton* BlackEdgeColorButton;
QToolButton* DarkEdgeColorButton;
QToolButton* ResetStudColorButton;
QToolButton* ResetStudEdgeColorButton;
QToolButton* ResetStudCylinderColorButton;
QToolButton* ResetPartEdgeColorButton;
QToolButton* ResetBlackEdgeColorButton;
QToolButton* ResetDarkEdgeColorButton;
};

View file

@ -651,6 +651,15 @@ inline quint32 lcColorFromVector3(const lcVector3& Color)
return LC_RGB(Color[0] * 255, Color[1] * 255, Color[2] * 255);
}
inline float lcLuminescenceFromRGBA(lcVector4& Value)
{
float r = LC_SRGB_TO_LINEAR(Value[0]);
float g = LC_SRGB_TO_LINEAR(Value[1]);
float b = LC_SRGB_TO_LINEAR(Value[2]);
return 0.2126f * r + 0.7152f * g + 0.0722f * b;
}
inline lcVector3 lcMul(const lcVector3& a, const lcMatrix33& b)
{
return b.r[0] * a[0] + b.r[1] * a[1] + b.r[2] * a[2];

View file

@ -140,8 +140,8 @@ 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(27, 42, 52, 255)), // LC_PROFILE_STUD_COLOR
lcProfileEntry("Settings", "StudEdgeColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_STUD_EDGE_COLOR
lcProfileEntry("Settings", "StudCylinderColor", LC_RGBA(27, 42, 52, 255)), // LC_PROFILE_STUD_CYLINDER_COLOR
lcProfileEntry("Settings", "PartEdgeColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_PART_EDGE_COLOR
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

View file

@ -88,8 +88,8 @@ enum LC_PROFILE_KEY
LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION,
LC_PROFILE_PREVIEW_DRAW_AXES,
LC_PROFILE_STUD_COLOR,
LC_PROFILE_STUD_EDGE_COLOR,
LC_PROFILE_STUD_CYLINDER_COLOR,
LC_PROFILE_PART_EDGE_COLOR,
LC_PROFILE_BLACK_EDGE_COLOR,
LC_PROFILE_DARK_EDGE_COLOR,
LC_PROFILE_PART_EDGE_CONTRAST,

View file

@ -1,4 +1,4 @@
.TH LEOCAD 1 "20 January 2021"
.TH LEOCAD 1 "26 January 2021"
.\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection
.\" other params are allowed: see man(7), man(1)
.SH NAME
@ -68,7 +68,7 @@ Sets the active camera to \fIcamera\fR.
.TP
\fB\-ss \fIid\fR,\ \fB\-\-stud\-style\ \fIid
.br
Set the stud style. Valid values 0=No style, 1=LDraw single wire, 2=LDraw double wire, 3=LDraw raised floating, 4=LDraw raised rounded, 5=LDraw subtle rounded, 6=LEGO no logo, 7=LEGO single wire. Stud style 1 - 5 require stud logo primitives which are in the unofficial parts library from \fILDraw.org\fR.
Set the stud style. Valid values 0=Plain, 1=Thin Lines Logo, 2=Outline Logo, 3=Sharp Top Logo, 4=Rounded Top Logo, 5=Flattened Logo, 6=High Contrast, 7=High Contrast with Logo.
.TP
\fB\-\-viewpoint \fRfront\ |\ back\ |\ left\ |\ right\ |\ top\ |\ bottom\ |\ home
@ -136,6 +136,41 @@ Set the with of the edge lines.
.BI "\-\-aa\-samples " count
AntiAliasing sample size (1, 2, 4, or 8).
.TP
\fB\-scc \fI#AARRGGBB\fR,\ \fB\-\-stud\-cylinder\-color\ \fI#AARRGGBB
.br
High contrast stud cylinder color.
.TP
\fB\-ec \fI#AARRGGBB\fR,\ \fB\-\-edge\-color\ \fI#AARRGGBB
.br
High contrast edge color.
.TP
\fB\-bec \fI#AARRGGBB\fR,\ \fB\-\-black\-edge\-color\ \fI#AARRGGBB
.br
High contrast edge color for black parts.
.TP
\fB\-dec \fI#AARRGGBB\fR,\ \fB\-\-dark\-edge\-color\ \fI#AARRGGBB
.br
High contrast edge color for dark color parts.
.TP
\fB\-aec,\ \fB\-\-automate\-edge\-color
.br
Enable automatically adjusted edge colors.\
.TP
\fB\-cc \fIfloat\fR,\ \fB\-\-color\-contrast\ \ffloat
.br
Set the near and far clipping planes used to render images (1 <= \fInear\fR < \fIfar\fR).
.TP
\fB\-ldv \fIfloat\fR,\ \fB\-\-light\-dark\-value\ \ffloat
.br
Set the value to indicate a light or dark color.
.TP
\fB\-obj \fR[\fIoutfile.obj\fR]
.br

View file

@ -569,8 +569,8 @@ void lcQPreferencesDialog::AutomateEdgeColor()
lcAutomateEdgeColorDialog Dialog(this, sender() == ui->HighContrastButton);
if (Dialog.exec() == QDialog::Accepted)
{
mOptions->Preferences.mStudColor = Dialog.mStudColor;
mOptions->Preferences.mStudEdgeColor = Dialog.mStudEdgeColor;
mOptions->Preferences.mStudCylinderColor = Dialog.mStudCylinderColor;
mOptions->Preferences.mPartEdgeColor = Dialog.mPartEdgeColor;
mOptions->Preferences.mBlackEdgeColor = Dialog.mBlackEdgeColor;
mOptions->Preferences.mDarkEdgeColor = Dialog.mDarkEdgeColor;
mOptions->Preferences.mPartEdgeContrast = Dialog.mPartEdgeContrast;