From d1d3bf2294cc9d1759ebd569f76d6a9e733a4f43 Mon Sep 17 00:00:00 2001 From: Trevor SANDY Date: Tue, 26 Jan 2021 20:59:37 +0100 Subject: [PATCH] Enable automate edge colour and high contrast options from command line --- common/lc_application.cpp | 98 +++++++++++++++++++++++++++++++++++++++ common/lc_application.h | 7 +++ docs/leocad.1 | 39 +++++++++++++++- 3 files changed, 142 insertions(+), 2 deletions(-) diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 15a320cf..b3a735ae 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -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 : Select shading mode for rendering.\n"); Options.StdOut += tr(" --line-width : Set the with of the edge lines.\n"); Options.StdOut += tr(" --aa-samples : 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 : Color contrast value between 0.0 and 1.0.\n"); + Options.StdOut += tr(" -ldv, --light-dark-value : Light/Dark color value between 0.0 and 1.0.\n"); Options.StdOut += tr(" -obj, --export-wavefront : Export the model to Wavefront OBJ format.\n"); Options.StdOut += tr(" -3ds, --export-3ds : Export the model to 3D Studio 3DS format.\n"); Options.StdOut += tr(" -dae, --export-collada : 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>& 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) diff --git a/common/lc_application.h b/common/lc_application.h index 2c71a10e..1bdbff22 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -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; diff --git a/docs/leocad.1 b/docs/leocad.1 index 216df884..94cb98a1 100644 --- a/docs/leocad.1 +++ b/docs/leocad.1 @@ -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