Skip to content

Commit

Permalink
Insert display model - fade submodel 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 341f460 commit 9cf45da
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 56 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.3285
pkgver=2.4.6.3286
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.3285
pkgver=2.4.6.3286
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.3285) debian; urgency=medium
lpub3d (2.4.6.3286) debian; urgency=medium

* LPub3D version 2.4.6.174.3285_20230422 for Linux
* LPub3D version 2.4.6.175.3286_20230422 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Sat, 22 Apr 2023 08:38:42 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Sat, 22 Apr 2023 08:39:07 +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.3285
Version: 2.4.6.3286
Maintainer: Trevor SANDY <trevor.sandy@gmail.com>
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.3285
Version: 2.4.6.3286
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.3285
* Sat Apr 22 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3286
- 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.3285) debian; urgency=medium
lpub3d (2.4.6.3286) debian; urgency=medium

* LPub3D version 2.4.6.174.3285_20230422 for Linux
* LPub3D version 2.4.6.175.3286_20230422 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Sat, 22 Apr 2023 08:38:43 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Sat, 22 Apr 2023 08:39:09 +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.3285
Version: 2.4.6.3286
Maintainer: Trevor SANDY <trevor.sandy@gmail.com>
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.3285
Version: 2.4.6.3286
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.3285
* Sat Apr 22 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3286
- 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 174 3285 8619ad1ce
2 4 6 175 3286 341f460cd
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 = 174
GIT_REVISION = 175
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 = 3285
GIT_COMMIT = 3286
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}.174.3285.8619ad1ce
GIT_VERSION = $${VERSION}.175.3286.341f460cd
message("~~~ GIT_DIR [$$GIT_DIR_ENV, USING VERSION] $$GIT_VERSION ~~~")
GIT_VERSION ~= s/\./" "
}
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.174.3285 (22 04 2023 08:38:43)
LPub3D 2.4.6.175.3286 (22 04 2023 08:39:09)

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.174.3285 (22 04 2023 08:38:43)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.6.175.3286 (22 04 2023 08:39:09)</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.174.3285
;; Last Update.: Sat, 22 Apr 2023 08:38:43 +0200
;; Version.....: 2.4.6.175.3286
;; Last Update.: Sat, 22 Apr 2023 08:39:09 +0200
;; License.....: GPLv3
;; Homepage....: https://trevorsandy.github.io/lpub3d
;; Copyright (C) 2021 - 2023 by Trevor SANDY
Expand Down
105 changes: 71 additions & 34 deletions mainApp/step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,9 @@ int Step::createCsi(
* The csiFile entries are only parts with not formatting or meta commands so it is
* well suited to provide the delta between steps.
*/
QStringList Step::configureModelStep(const QStringList &csiParts, Where &current/*topOfStep*/) {

QStringList configuredCsiParts, stepColourList;
QStringList Step::configureModelStep(const QStringList &csiParts, Where &current/*topOfStep*/)
{
QStringList processedCsiParts, stepColourList;

bool enableFadeSteps = (/* Preferences::enableFadeSteps || */csiStepMeta.fadeSteps.enable.value());
bool enableHighlightStep = (/* Preferences::enableHighlightStep || */csiStepMeta.highlightStep.enable.value());
Expand All @@ -714,16 +714,16 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
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;
fadeColour = LDrawColor::code(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 || csiStepMeta.highlightStep.setup.value()) {
highlightStepLineWidth = csiStepMeta.highlightStep.lineWidth.value();
highlightColour = csiStepMeta.highlightStep.color.value();
highlightStepLineWidth = csiStepMeta.highlightStep.lineWidth.value();
highlightColour = csiStepMeta.highlightStep.color.value();
}

bool FadeMetaAdded = false;
Expand All @@ -745,7 +745,10 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
stepNum = stepNumber.number;
}

if (csiParts.size() > 0 && (highlightFirstStep ? true : stepNum > 1)) {
std::function<void(const QStringList&)> processCsiParts;
processCsiParts = [&](const QStringList &csiParts)
{
QStringList parts = csiParts;

// retrieve the previous step position
int prevStepPosition = 0;
Expand All @@ -759,7 +762,7 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
// emit messageSig(LOG_DEBUG, QString("Configure StepNum: %1, PrevStepPos: %2, StepPos: %3, ModelSize: %4, ModelName: %5")
// .arg(stepNum)
// .arg(prevStepPosition)
// .arg(csiParts.size())
// .arg(parts.size())
// .arg(lpub->ldrawFile.size(current.modelName))
// .arg(current.modelName));
//#endif
Expand All @@ -768,7 +771,7 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current

int type_1_5_line_count = 0;

for (int index = 0; index < csiParts.size(); index++) {
for (int index = 0; index < parts.size(); index++) {

bool type_1_line = false;
bool type_1_5_line = false;
Expand All @@ -778,17 +781,17 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current

int updatePosition = index + 1;

QString csiLine = csiParts[index];
QString csiLine = parts[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 (enableFadeSteps && (argv[1] == QStringLiteral("!FADE") || argv[1] == QStringLiteral("FADE"))) {
if (argv.size() == 2) {
doFadeStep = !doFadeStep;
doFadeStep = !doFadeStep;
} else if (argv.size() >= 3) {
doFadeStep = true;
if (argv.size() == 3) {
Expand All @@ -808,7 +811,7 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
}
}

if (enableHighlightStep && (argv[1] == "!SILHOUETTE" || argv[1] == "SILHOUETTE")) {
if (enableHighlightStep && (argv[1] == QStringLiteral("!SILHOUETTE") || argv[1] == QStringLiteral("SILHOUETTE"))) {
if (argv.size() == 2) {
doSilhouette = !doSilhouette;
} else if (argv.size() >= 3) {
Expand Down Expand Up @@ -851,14 +854,44 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
if (type_1_line) {
// set part name and extension
fileNameStr = QString(argv[argv.size()-1]).toLower();
extension = QFileInfo(fileNameStr).suffix();
extension = QFileInfo(fileNameStr).suffix();

// check if is color part
is_colour_part = LDrawColourParts::isLDrawColourPart(fileNameStr);

// check if is submodel
is_submodel_file = lpub->ldrawFile.isSubmodel(fileNameStr);

// process submodel parts if display step
if (displayStep && is_submodel_file) {
QStringList const &contents = lpub->ldrawFile.contents(fileNameStr);
if (contents.size()) {
// remove the submodel line from the parts list
parts.takeAt(index);
int j = index;
for (int i = 0; i < contents.size(); i++) {
QString const &line = contents.at(i);
bool validLine = false;
if(line.isEmpty())
continue;
if ((validLine = line[0] != "0"))
parts.insert(j, line);
else if ((validLine = line.startsWith("0 !FADE")))
parts.insert(j, line);
else if ((validLine = line.startsWith("0 !SILHOUETTE")))
parts.insert(j, line);
if (validLine) {
// return the previous index to reprocess the current line in csiLine
if (j == index)
index--;
// inserting top-down so increment index to insert after current
j++;
}
}
}
// finished processing the subfile so return to previous index
continue;
}
//if (is_colour_part)
// emit messageSig(LOG_NOTICE, "Static color part - " + fileNameStr);
}
Expand All @@ -867,8 +900,8 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
if ((highlightFirstStep ? stepNum > 1 : true) && enableFadeSteps && (doFadeStep || updatePosition <= prevStepPosition)) {
if (type_1_5_line) {
// Insert opening fade meta
if (!displayStep && !FadeMetaAdded && enableFadeSteps){
configuredCsiParts.insert(index,QString("0 !FADE %1").arg(fadeStepsOpacity));
if (!displayStep && !FadeMetaAdded && enableFadeSteps) {
processedCsiParts.insert(index,QString("0 !FADE %1").arg(fadeStepsOpacity));
FadeMetaAdded = true;
}
if (argv[1] != LDRAW_EDGE_MATERIAL_COLOUR &&
Expand All @@ -890,7 +923,7 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
}
}
// process subfiles naming
if (is_submodel_file) {
if (!displayStep && is_submodel_file) {
if (extension.isEmpty()) {
fileNameStr = fileNameStr.append(QString("%1.ldr").arg(FADE_SFX));
} else {
Expand All @@ -907,10 +940,8 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
if (enableHighlightStep && (doSilhouette || updatePosition > prevStepPosition)) {
if (type_1_5_line) {
// Insert opening silhouette meta
if (!displayStep && !SilhouetteMetaAdded && enableHighlightStep){
configuredCsiParts.append(QString("0 !SILHOUETTE %1 %2")
.arg(highlightStepLineWidth)
.arg(highlightColour));
if (!displayStep && !SilhouetteMetaAdded && enableHighlightStep) {
processedCsiParts.append(QString("0 !SILHOUETTE %1 %2").arg(highlightStepLineWidth).arg(highlightColour));
SilhouetteMetaAdded = true;
}
if (argv[1] != LDRAW_EDGE_MATERIAL_COLOUR &&
Expand All @@ -932,7 +963,7 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
}
}
// process subfiles naming
if (is_submodel_file) {
if (!displayStep && is_submodel_file) {
if (extension.isEmpty()) {
fileNameStr = fileNameStr.append(QString("%1.ldr").arg(HIGHLIGHT_SFX));
} else {
Expand All @@ -953,26 +984,32 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
csiLine = argv.join(" ");

// current step parts
configuredCsiParts << csiLine;
processedCsiParts << csiLine;

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

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

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

if (csiParts.size() && (enableFadeSteps || enableHighlightStep) && (highlightFirstStep ? true : stepNum > 1)) {

QFuture<void> processFuture = QtConcurrent::run([&] () { processCsiParts(csiParts); });
processFuture.waitForFinished();

} else {

Expand All @@ -987,16 +1024,16 @@ QStringList Step::configureModelStep(const QStringList &csiParts, Where &current
// add the fade color list to the header of the CsiParts list
if (!stepColourList.isEmpty()) {
stepColourList.removeDuplicates(); // remove dupes
configuredCsiParts.prepend("0");
processedCsiParts.prepend("0");

for (int i = 0; i < stepColourList.size(); ++i)
configuredCsiParts.prepend(stepColourList.at(i));
processedCsiParts.prepend(stepColourList.at(i));

configuredCsiParts.prepend(QString("0 // %1 step custom colours").arg(VER_PRODUCTNAME_STR));
configuredCsiParts.prepend("0");
processedCsiParts.prepend(QString("0 // %1 step custom colours").arg(VER_PRODUCTNAME_STR));
processedCsiParts.prepend("0");
}

return configuredCsiParts;
return processedCsiParts;
}


Expand All @@ -1007,7 +1044,7 @@ bool Step::loadTheViewer() {
viewerOptions->ImageHeight = csiPixmap.height();
if (! renderer->LoadViewer(viewerOptions)) {
emit gui->messageSig(LOG_ERROR,QString("Could not load Visual Editor with CSI key: %1")
.arg(viewerStepKey));
.arg(viewerStepKey));
return false;
}
}
Expand Down

0 comments on commit 9cf45da

Please sign in to comment.