Skip to content

Commit

Permalink
Insert display model - fade colour for display step #704
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Apr 22, 2023
1 parent 8619ad1 commit 341f460
Show file tree
Hide file tree
Showing 17 changed files with 207 additions and 92 deletions.
2 changes: 1 addition & 1 deletion builds/linux/obs/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 19, 2020
# Copyright (C) 2017 - 2023 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.6.3284
pkgver=2.4.6.3285
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 19, 2020
# Copyright (C) 2017 - 2023 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.6.3284
pkgver=2.4.6.3285
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/alldeps/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lpub3d (2.4.6.3284) debian; urgency=medium
lpub3d (2.4.6.3285) debian; urgency=medium

* LPub3D version 2.4.6.173.3284_20230422 for Linux
* LPub3D version 2.4.6.174.3285_20230422 for Linux

-- Trevor SANDY <[email protected]> Sat, 22 Apr 2023 04:46:30 +0200
-- Trevor SANDY <[email protected]> Sat, 22 Apr 2023 08:38:42 +0200
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/debian/lpub3d.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.6.3284
Version: 2.4.6.3285
Maintainer: Trevor SANDY <[email protected]>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/alldeps/lpub3d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.6.3284
Version: 2.4.6.3285
Release: <B_CNT>%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -797,7 +797,7 @@ update-desktop-database || true
%endif

%changelog
* Sat Apr 22 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3284
* Sat Apr 22 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3285
- LPub3D 2.4.4 enhancements and fixes - see RELEASE_NOTES for details

* Tue May 31 2022 - trevor dot sandy at gmail dot com 2.4.4.2670
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lpub3d (2.4.6.3284) debian; urgency=medium
lpub3d (2.4.6.3285) debian; urgency=medium

* LPub3D version 2.4.6.173.3284_20230422 for Linux
* LPub3D version 2.4.6.174.3285_20230422 for Linux

-- Trevor SANDY <[email protected]> Sat, 22 Apr 2023 04:46:31 +0200
-- Trevor SANDY <[email protected]> Sat, 22 Apr 2023 08:38:43 +0200
2 changes: 1 addition & 1 deletion builds/linux/obs/debian/lpub3d.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.6.3284
Version: 2.4.6.3285
Maintainer: Trevor SANDY <[email protected]>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/lpub3d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.6.3284
Version: 2.4.6.3285
Release: 1%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -313,7 +313,7 @@ update-desktop-database || true
%endif

%changelog
* Sat Apr 22 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3284
* Sat Apr 22 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3285
- LPub3D 2.4.4 enhancements and fixes - see RELEASE_NOTES for details

* Tue May 31 2022 - trevor dot sandy at gmail dot com 2.4.4.2670
Expand Down
2 changes: 1 addition & 1 deletion builds/utilities/version.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2 4 6 173 3284 6433633e9
2 4 6 174 3285 8619ad1ce
6 changes: 3 additions & 3 deletions gitversion.pri
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ equals(GIT_DIR, undefined) {

# Check if we do not have a valid version number (i.e. no version tag found)
isEmpty(GIT_VERSION) {
GIT_REVISION = 173
GIT_REVISION = 174
GIT_SHA = $$system($$GIT_BASE_COMMAND rev-parse --short HEAD 2> $$NULL_DEVICE)
GIT_COMMIT = $$system($$GIT_BASE_COMMAND rev-list --count HEAD 2> $$NULL_DEVICE)
GIT_VERSION = v$${VERSION}-$${GIT_REVISION}-$${GIT_SHA}
Expand Down Expand Up @@ -69,7 +69,7 @@ equals(GIT_DIR, undefined) {
# Get commit count
GIT_COMMIT = $$system($$GIT_BASE_COMMAND rev-list --count HEAD 2> $$NULL_DEVICE)
isEmpty(GIT_COMMIT) {
GIT_COMMIT = 3284
GIT_COMMIT = 3285
message("~~~ ERROR! GIT_COMMIT NOT DEFINED, USING $$GIT_COMMIT ~~~")
}

Expand Down Expand Up @@ -117,7 +117,7 @@ if (equals(USE_GIT_VER_FILE, true)|equals(USE_VERSION_INFO_VAR, true)) {
GIT_VERSION = $$cat($$GIT_VER_FILE, lines)
} else {
message("~~~ ERROR! $$GIT_DIR_ENV VERSION_INFO FILE $$GIT_VER_FILE NOT FOUND ~~~")
GIT_VERSION = $${VERSION}.173.3284.6433633e9
GIT_VERSION = $${VERSION}.174.3285.8619ad1ce
message("~~~ GIT_DIR [$$GIT_DIR_ENV, USING VERSION] $$GIT_VERSION ~~~")
GIT_VERSION ~= s/\./" "
}
Expand Down
2 changes: 1 addition & 1 deletion lclib/common/lc_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
else if (Token == QLatin1String("!COLOUR"))
{
if (!lcLoadColorEntry(OriginalLine.toLatin1().constData(), lcGetPiecesLibrary()->GetStudStyle()))
emit gui->messageSig(LOG_ERROR,QString("Could not colour meta %1.")
emit gui->messageSig(LOG_ERROR,QString("Could not load COLOUR command %1.")
.arg(OriginalLine));
}
/*** LPub3D Mod end ***/
Expand Down
2 changes: 1 addition & 1 deletion mainApp/docs/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LPub3D 2.4.6.173.3284 (22 04 2023 04:46:32)
LPub3D 2.4.6.174.3285 (22 04 2023 08:38:43)

Features, enhancements, fixes and changes
------------
Expand Down
2 changes: 1 addition & 1 deletion mainApp/docs/RELEASE_NOTES.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<table class="tg">
<tr>
<th class="tg-0pky">
<h4><a id="LPub3D_0"></a>LPub3D 2.4.6.173.3284 (22 04 2023 04:46:32)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.6.174.3285 (22 04 2023 08:38:43)</h4>
<hr>
<p>
<span class="tg-1pky">LPub3D Official release.</span><br>
Expand Down
4 changes: 2 additions & 2 deletions mainApp/extras/LPub3D_Npp_UDL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
;;
;; Author......: Trevor SANDY
;; Name........: LPub3D_Npp_UDL.xml
;; Version.....: 2.4.6.173.3284
;; Last Update.: Sat, 22 Apr 2023 04:46:31 +0200
;; Version.....: 2.4.6.174.3285
;; Last Update.: Sat, 22 Apr 2023 08:38:43 +0200
;; License.....: GPLv3
;; Homepage....: https://trevorsandy.github.io/lpub3d
;; Copyright (C) 2021 - 2023 by Trevor SANDY
Expand Down
8 changes: 4 additions & 4 deletions mainApp/lpub_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ bool LPub::setFadeStepsFromCommand()

result.clear();
topLevelModel = top;
fadeRx.setPattern("FADE_STEPS COLOR\\s*(?:GLOBAL)?\\s*\"(\\w+)\"");
Gui::stepContains(topLevelModel,fadeRx,result,1);
fadeRx.setPattern("FADE_STEPS COLOR\\s*(?:GLOBAL)?\\s*(\")?(\\w+)(?(1)\1|)[^\n]*");
Gui::stepContains(topLevelModel,fadeRx,result,2);
if (!result.isEmpty()) {
QColor ParsedColor = LDrawColor::color(result);
bool fadeStepsUseColorCompare = Preferences::fadeStepsUseColour;
Expand Down Expand Up @@ -667,9 +667,9 @@ bool LPub::setHighlightStepFromCommand()

result.clear();
topLevelModel = top;
highlightRx.setPattern("HIGHLIGHT_STEP COLOR\\s*(?:GLOBAL)?\\s*\"(0x|#)([\\da-fA-F]+)\"");
highlightRx.setPattern("HIGHLIGHT_STEP COLOR\\s*(?:GLOBAL)?\\s*(\")?(0x|#)([\\da-fA-F]+)(?(1)\1|)[^\n]*");
if (Gui::stepContains(topLevelModel,highlightRx,result)) {
result = QString("%1%2").arg(highlightRx.cap(1),highlightRx.cap(2));
result = QString("%1%2").arg(highlightRx.cap(1),highlightRx.cap(3));
QColor ParsedColor = QColor(result);
QString highlightStepColourCompare = Preferences::highlightStepColour;
Preferences::highlightStepColour = ParsedColor.isValid() ? result : Preferences::validFadeStepsColour;
Expand Down
130 changes: 104 additions & 26 deletions mainApp/step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,37 +704,56 @@ int Step::createCsi(
QStringList Step::configureModelStep(const QStringList &csiParts, Where &current/*topOfStep*/) {

QStringList configuredCsiParts, stepColourList;
bool enableFadeSteps = (Preferences::enableFadeSteps || csiStepMeta.fadeSteps.enable.value());
bool enableHighlightStep = (Preferences::enableHighlightStep || csiStepMeta.highlightStep.enable.value());
bool highlightFirstStep = Preferences::highlightFirstStep;

bool fadeStepsUseColour = Preferences::fadeStepsUseColour;
int fadeStepsOpacity = Preferences::fadeStepsOpacity;
bool enableFadeSteps = (/* Preferences::enableFadeSteps || */csiStepMeta.fadeSteps.enable.value());
bool enableHighlightStep = (/* Preferences::enableHighlightStep || */csiStepMeta.highlightStep.enable.value());

bool highlightFirstStep = Preferences::highlightFirstStep;

QString fadeColour = LDrawColor::code(Preferences::validFadeStepsColour);
if (Gui::m_fadeStepsSetup) {
bool fadeStepsUseColour = Preferences::fadeStepsUseColour;
int fadeStepsOpacity = Preferences::fadeStepsOpacity;
if (Gui::m_fadeStepsSetup || csiStepMeta.fadeSteps.setup.value()) {
fadeColour = csiStepMeta.fadeSteps.color.value().color;
fadeStepsOpacity = csiStepMeta.fadeSteps.opacity.value();
fadeStepsUseColour = csiStepMeta.fadeSteps.color.value().useColor;
}

QString highlightColour = Preferences::highlightStepColour;
int highlightStepLineWidth = Preferences::highlightStepLineWidth;
if (Gui::m_highlightStepSetup) {
if (Gui::m_highlightStepSetup || csiStepMeta.highlightStep.setup.value()) {
highlightStepLineWidth = csiStepMeta.highlightStep.lineWidth.value();
highlightColour = csiStepMeta.highlightStep.color.value();
}

bool FadeMetaAdded = false;

bool SilhouetteMetaAdded = false;

int stepNum = displayStep >= DT_MODEL_DEFAULT ? -1 : stepNumber.number;
bool doFadeStep = false;

bool doSilhouette = false;

int stepNum = 0;

if (displayStep) {
if ((highlightFirstStep = displayStep == DT_MODEL_CUSTOM))
stepNum = stepNumber.number > 1 ? stepNumber.number : static_cast<int>(displayStep);
else
stepNum = -1;
} else {
stepNum = stepNumber.number;
}

if (csiParts.size() > 0 && (highlightFirstStep ? true : stepNum > 1)) {

// retrieve the previous step position
int prevStepPosition = lpub->ldrawFile.getPrevStepPosition(current.modelName,current.lineNumber,stepNum);
if (prevStepPosition == 0 && Gui::savePrevStepPosition > 0)
prevStepPosition = Gui::savePrevStepPosition;
int prevStepPosition = 0;
if (!displayStep) {
prevStepPosition = lpub->ldrawFile.getPrevStepPosition(current.modelName,current.lineNumber, stepNum);
if (prevStepPosition == 0 && Gui::savePrevStepPosition > 0)
prevStepPosition = Gui::savePrevStepPosition;
}

//#ifdef QT_DEBUG_MODE
// emit messageSig(LOG_DEBUG, QString("Configure StepNum: %1, PrevStepPos: %2, StepPos: %3, ModelSize: %4, ModelName: %5")
Expand All @@ -760,8 +779,62 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
int updatePosition = index + 1;

QString csiLine = csiParts[index];

split(csiLine, argv);

// parse displayModel step
if (displayStep) {
if (argv.size() >= 2 && argv[0] == "0") {
bool ok;
if (enableFadeSteps && (argv[1] == "!FADE" || argv[1] == "FADE")) {
if (argv.size() == 2) {
doFadeStep = !doFadeStep;
} else if (argv.size() >= 3) {
doFadeStep = true;
if (argv.size() == 3) {
int opacity = argv[2].toInt(&ok);
if (ok)
fadeStepsOpacity = opacity;
else
emit lpub->messageSig(LOG_WARNING, QObject::tr("Specified fade opacity value is invalid [%1] ").arg(argv[2]));
} else
if (argv.size() == 4) {
QColor colour(argv[3]);
if (colour.isValid())
fadeColour = argv[3];
else
emit lpub->messageSig(LOG_WARNING, QObject::tr("Specified fade colour is invalid [%1] ").arg(argv[3]));
}
}
}

if (enableHighlightStep && (argv[1] == "!SILHOUETTE" || argv[1] == "SILHOUETTE")) {
if (argv.size() == 2) {
doSilhouette = !doSilhouette;
} else if (argv.size() >= 3) {
doSilhouette = true;
if (argv.size() == 3) {
QColor colour(argv[2]);
if (colour.isValid())
highlightColour = argv[2];
else
emit lpub->messageSig(LOG_WARNING, QObject::tr("Specified highlight colour is invalid [%1] ").arg(argv[2]));
} else
if (argv.size() == 4) {
int width = argv[2].toDouble(&ok);
if (ok)
highlightStepLineWidth = width;
QColor colour(argv[3]);
if (colour.isValid())
highlightColour = argv[3];
else
emit lpub->messageSig(LOG_WARNING, QObject::tr("Specified highlight colour is invalid [%1] ").arg(argv[3]));
}
}
}
}
}

// determine line type
if (argv.size() && argv[0].size() == 1 && argv[0] >= "1" && argv[0] <= "5") {
type_1_5_line = true;
Expand Down Expand Up @@ -791,10 +864,10 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
}

// write fade step entries
if ((highlightFirstStep ? stepNum > 1 : true) && enableFadeSteps && (updatePosition <= prevStepPosition)) {
if ((highlightFirstStep ? stepNum > 1 : true) && enableFadeSteps && (doFadeStep || updatePosition <= prevStepPosition)) {
if (type_1_5_line) {
// Insert opening fade meta
if (!FadeMetaAdded && enableFadeSteps){
if (!displayStep && !FadeMetaAdded && enableFadeSteps){
configuredCsiParts.insert(index,QString("0 !FADE %1").arg(fadeStepsOpacity));
FadeMetaAdded = true;
}
Expand Down Expand Up @@ -831,10 +904,10 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
}

// write highlight entries
if (enableHighlightStep && (updatePosition > prevStepPosition)) {
if (enableHighlightStep && (doSilhouette || updatePosition > prevStepPosition)) {
if (type_1_5_line) {
// Insert opening silhouette meta
if (!SilhouetteMetaAdded && enableHighlightStep){
if (!displayStep && !SilhouetteMetaAdded && enableHighlightStep){
configuredCsiParts.append(QString("0 !SILHOUETTE %1 %2")
.arg(highlightStepLineWidth)
.arg(highlightColour));
Expand Down Expand Up @@ -883,25 +956,30 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
configuredCsiParts << csiLine;

// Insert closing fade meta
if (updatePosition == prevStepPosition) {
if (FadeMetaAdded)
configuredCsiParts.append(QString("0 !FADE"));
}
if (!displayStep) {
if (updatePosition == prevStepPosition) {
if (FadeMetaAdded)
configuredCsiParts.append(QString("0 !FADE"));
}

// Insert closing silhouette meta
if (index+1 == csiParts.size()) {
if (SilhouetteMetaAdded)
configuredCsiParts.append(QString("0 !SILHOUETTE"));
// Insert closing silhouette meta
if (index+1 == csiParts.size()) {
if (SilhouetteMetaAdded)
configuredCsiParts.append(QString("0 !SILHOUETTE"));
}
}
}

// save the current step position
lpub->ldrawFile.setPrevStepPosition(current.modelName,stepNum,type_1_5_line_count);
if (!displayStep)
lpub->ldrawFile.setPrevStepPosition(current.modelName,stepNum,type_1_5_line_count);

} else {

// save the current step position
lpub->ldrawFile.setPrevStepPosition(current.modelName,stepNum,csiParts.size());
if (!displayStep)
lpub->ldrawFile.setPrevStepPosition(current.modelName,stepNum,csiParts.size());

return csiParts;

}
Expand Down Expand Up @@ -1706,7 +1784,7 @@ int Step::sizeit(

if ( ! pliPerStep ) {
sharable = false;
}
}

square[callout->tbl[XX]][callout->tbl[YY]] = i + 1;
int size = callout->submodelStack().size();
Expand Down
Loading

0 comments on commit 341f460

Please sign in to comment.