Skip to content

Commit

Permalink
Insert display model - count instances #704
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Apr 22, 2023
1 parent 224db21 commit 7184601
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 42 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.3276
pkgver=2.4.6.3277
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.3276
pkgver=2.4.6.3277
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.3276) debian; urgency=medium
lpub3d (2.4.6.3277) debian; urgency=medium

* LPub3D version 2.4.6.165.3276_20230422 for Linux
* LPub3D version 2.4.6.166.3277_20230422 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Sat, 22 Apr 2023 03:45:32 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Sat, 22 Apr 2023 03:45:54 +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.3276
Version: 2.4.6.3277
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.3276
Version: 2.4.6.3277
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.3276
* Sat Apr 22 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3277
- 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.3276) debian; urgency=medium
lpub3d (2.4.6.3277) debian; urgency=medium

* LPub3D version 2.4.6.165.3276_20230422 for Linux
* LPub3D version 2.4.6.166.3277_20230422 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Sat, 22 Apr 2023 03:45:34 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Sat, 22 Apr 2023 03:45:56 +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.3276
Version: 2.4.6.3277
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.3276
Version: 2.4.6.3277
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.3276
* Sat Apr 22 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3277
- 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 165 3276 52e719d7a
2 4 6 166 3277 224db2114
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 = 165
GIT_REVISION = 166
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 = 3276
GIT_COMMIT = 3277
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}.165.3276.52e719d7a
GIT_VERSION = $${VERSION}.166.3277.224db2114
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.165.3276 (22 04 2023 03:45:34)
LPub3D 2.4.6.166.3277 (22 04 2023 03:45:56)

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.165.3276 (22 04 2023 03:45:34)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.6.166.3277 (22 04 2023 03:45:56)</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.165.3276
;; Last Update.: Sat, 22 Apr 2023 03:45:34 +0200
;; Version.....: 2.4.6.166.3277
;; Last Update.: Sat, 22 Apr 2023 03:45:56 +0200
;; License.....: GPLv3
;; Homepage....: https://trevorsandy.github.io/lpub3d
;; Copyright (C) 2021 - 2023 by Trevor SANDY
Expand Down
20 changes: 13 additions & 7 deletions mainApp/ldrawfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3002,6 +3002,8 @@ void LDrawFile::countInstances(

//lpub3d ignore part - so set ignore step
if (tokens.size() > 1 && tokens[0] == "0") {
if (!displayModel)
displayModel = line.contains(_fileRegExp[DMS_RX]);
if (tokens[1] == "!LPUB" || tokens[1] == "LPUB") {
// pli part meta commands
if (tokens.size() == 5) {
Expand All @@ -3011,7 +3013,7 @@ void LDrawFile::countInstances(
stepIgnore = true;
}
// build modification - commands
else if (tokens[2] == "BUILD_MOD") {
else if (!displayModel && tokens[2] == "BUILD_MOD") {
if (tokens[3] == "BEGIN") {
if (! Preferences::buildModEnabled) {
buildModIgnore = true;
Expand Down Expand Up @@ -3070,8 +3072,8 @@ void LDrawFile::countInstances(
}
} else if (tokens.size() == 4 && tokens[0] == "0" &&
(tokens[1] == "!LPUB" || tokens[1] == "LPUB") &&
tokens[2] == "CALLOUT" &&
tokens[3] == "END") {
tokens[2] == "CALLOUT" &&
tokens[3] == "END") {
callout = false;
break;
}
Expand Down Expand Up @@ -3105,10 +3107,12 @@ void LDrawFile::countInstances(
// no step
} else if (tokens.size() == 3 &&
(tokens[2] == "NOSTEP" || tokens[2] == "NOFILE")) {
noStep = true;
noStep = true;
displayModel = false;
// LDraw step or rotstep - so check if parts added
} else if (tokens.size() >= 2 &&
(tokens[1] == "STEP" || tokens[1] == "ROTSTEP")) {
displayModel = false;
if (! noStep) {
if (partsAdded) {
// parts added - increment step
Expand Down Expand Up @@ -3143,7 +3147,7 @@ void LDrawFile::countInstances(
} // step or rotstep
// check if subfile and process
} else if (tokens.size() == 15 && tokens[0] >= "1" && tokens[0] <= "5") {
if (! stepIgnore && ! buildModIgnore) {
if (! displayModel && ! stepIgnore && ! buildModIgnore) {
buildModPartCount++;
if (contains(tokens[14],false/*searchAll*/)) {
// add contains 'child' index to parent list
Expand Down Expand Up @@ -3181,6 +3185,8 @@ void LDrawFile::countInstances(
++f->_instances;
}
} // callout

displayModel = false;
} // subfile end

f->_beenCounted = true;
Expand Down Expand Up @@ -5749,8 +5755,8 @@ LDrawFile::LDrawFile() : ldrawMutex(QMutex::Recursive)
<< QRegExp("^0\\s+!?LDCAD\\s+GROUP_DEF.*\\s+\\[LID=(\\d+)\\]\\s+\\[GID=([\\d\\w]+)\\]\\s+\\[name=(.[^\\]]+)\\].*$",Qt::CaseInsensitive) // LDG_RX - LDCad Group
<< QRegExp("^0\\s+!?LDCAD\\s+(CONTENT|PATH_POINT|PATH_SKIN|GENERATED)[^\n]*") // LDC_RX - LDCad Generated Content
<< QRegExp("^0\\s+!?(?:LPUB)*\\s?(STEP|ROTSTEP|MULTI_STEP BEGIN|CALLOUT BEGIN|BUILD_MOD BEGIN|0 ROTATION)[^\n]*") // EOH_RX - End of Header
<< QRegExp("^0\\s+!?(?:LPUB)*\\s?(INSERT DISPLAY_MODEL)[^\n]*") // DMS_RX - Display Model Step
<< QRegExp("^0\\s+!?(?:LPUB)*\\s?(STEP|ROTSTEP)[^\n]*") // LDS_RX - LDraw Step
<< QRegExp("^0\\s+!?(?:LPUB)*\\s?(INSERT DISPLAY_MODEL)[^\n]*") // DMS_RX - Display Model Step
<< QRegExp("^0\\s+!?(?:LPUB)*\\s?(STEP|ROTSTEP|NOSTEP|NOFILE)[^\n]*") // LDS_RX - LDraw Step boundry
;
}

Expand Down
19 changes: 11 additions & 8 deletions mainApp/metaitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,17 +430,20 @@ int MetaItem::countInstancesInStep(Meta *meta, const QString &modelName){
return instanceCount;
}

int MetaItem::countInstancesInModel(Meta *meta, const QString &modelName){
int MetaItem::countInstancesInModel(Meta *meta, const QString &modelName) {

int numLines;
Where walk(modelName,1);
if (lpub->ldrawFile.isDisplayModel(modelName))
return 0;

/* submodelStack tells us where this submodel is referenced in the
parent file so we use it to target the correct SUBMODEL*/
int numLines;
Where walk(modelName,1);

SubmodelStack tos = meta->submodelStack[meta->submodelStack.size() - 1];
Where subModel(tos.modelName,0);
lpub->ldrawFile.skipHeader(subModel.modelName,subModel.lineNumber);
/* submodelStack tells us where this submodel is referenced in the
parent file so we use it to target the correct SUBMODEL*/

SubmodelStack tos = meta->submodelStack[meta->submodelStack.size() - 1];
Where subModel(tos.modelName,0);
lpub->ldrawFile.skipHeader(subModel.modelName,subModel.lineNumber);

/* Scan the lines following this line, to see if there is another
* submodel just like this one that needs to be added as multiplier.
Expand Down
10 changes: 5 additions & 5 deletions mainApp/traverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1813,14 +1813,14 @@ int Gui::drawPage(

// get the default number of submodel instances in the model file
instances = lpub->ldrawFile.instances(opts.current.modelName, opts.isMirrored);
if (countInstances)
if (!opts.displayModel && countInstances)
displayInstanceCount = instances > 1 || steps->meta.LPub.page.countInstanceOverride.value() > 1;
// count the instances - use steps->meta (vs. steps->groupStepMeta) to access current submodelStack
//
// lpub->ldrawFile.instances() configuration is CountAtTop - the historic LPub count scheme. However,
// the updated countInstances routine's configuration is CountAtModel - this is the default options set
// and configurable in Project globals
if (displayInstanceCount) {
if (!opts.displayModel && displayInstanceCount) {
// manually override the count instance value using 0 !LPUB SUBMODEL_INSTANCE_COUNT_OVERRIDE
if (steps->groupStepMeta.LPub.page.countInstanceOverride.value())
instances = steps->groupStepMeta.LPub.page.countInstanceOverride.value();
Expand Down Expand Up @@ -2564,12 +2564,12 @@ int Gui::drawPage(

// get the number of submodel instances in the model file
int instances = lpub->ldrawFile.instances(opts.current.modelName, opts.isMirrored);
if (countInstances)
if (!opts.displayModel && countInstances)
displayInstanceCount = instances > 1 || steps->meta.LPub.page.countInstanceOverride.value() > 1;
// lpub->ldrawFile.instances() configuration is CountAtTop - the historic LPub count scheme. However,
// the updated countInstances routine's configuration is CountAtModel - this is the default options set
// and configurable in Project globals
if (displayInstanceCount) {
if (!opts.displayModel && displayInstanceCount) {
// manually override the count instance value using 0 !LPUB SUBMODEL_INSTANCE_COUNT_OVERRIDE
if (steps->meta.LPub.page.countInstanceOverride.value())
instances = steps->meta.LPub.page.countInstanceOverride.value();
Expand All @@ -2582,7 +2582,7 @@ int Gui::drawPage(
}

// update the page if submodel instances greater than 1
if (instances > 1) {
if (!opts.displayModel && instances > 1) {
Page *page = dynamic_cast<Page *>(steps);
if (page) {
page->instances = instances;
Expand Down

0 comments on commit 7184601

Please sign in to comment.