Skip to content

Commit

Permalink
Blender LDraw Render - code cleanup #416
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed May 28, 2023
1 parent f12ad7a commit ce0d636
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 119 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.3382
pkgver=2.4.6.3383
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.3382
pkgver=2.4.6.3383
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.3382) debian; urgency=medium
lpub3d (2.4.6.3383) debian; urgency=medium

* LPub3D version 2.4.6.271.3382_20230528 for Linux
* LPub3D version 2.4.6.272.3383_20230528 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Sun, 28 May 2023 18:24:55 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Sun, 28 May 2023 18:26:57 +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.3382
Version: 2.4.6.3383
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.3382
Version: 2.4.6.3383
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
* Sun May 28 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3382
* Sun May 28 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3383
- 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.3382) debian; urgency=medium
lpub3d (2.4.6.3383) debian; urgency=medium

* LPub3D version 2.4.6.271.3382_20230528 for Linux
* LPub3D version 2.4.6.272.3383_20230528 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Sun, 28 May 2023 18:24:57 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Sun, 28 May 2023 18:26:58 +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.3382
Version: 2.4.6.3383
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.3382
Version: 2.4.6.3383
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
* Sun May 28 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3382
* Sun May 28 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3383
- 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 271 3382 90e16db6e
2 4 6 272 3383 f12ad7a6f
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 = 271
GIT_REVISION = 272
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 = 3382
GIT_COMMIT = 3383
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}.271.3382.90e16db6e
GIT_VERSION = $${VERSION}.272.3383.f12ad7a6f
message("~~~ GIT_DIR [$$GIT_DIR_ENV, USING VERSION] $$GIT_VERSION ~~~")
GIT_VERSION ~= s/\./" "
}
Expand Down
172 changes: 85 additions & 87 deletions mainApp/blenderpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ void BlenderPreferences::configureBlenderAddon(bool testBlender)
}
//E. Add jsonArray to jsonDocument
jsonDoc.setArray(jsonArray);
//F. Create a QByteArray and fill it with QJsonDocument (json compact format)
//F. Fill QByteArray with QJsonDocument (json compact format)
addonPathsAndModuleNames = jsonDoc.toJson(QJsonDocument::Compact);
}

Expand Down Expand Up @@ -1273,73 +1273,6 @@ bool BlenderPreferences::extractBlenderAddon(const QString &blenderDir)
return proceed;
}

void BlenderPreferences::settingChanged(const QString &value)
{
bool change = false;

QLineEdit *lineEdit = qobject_cast<QLineEdit *>(sender());
if (lineEdit) {
int i = lineEdit->property("ControlID").toInt();
if (mImportMMActBox->isChecked()) {
change = mBlenderSettingsMM[i].value != value;
} else {
change = mBlenderSettings[i].value != value;
}
}

change |= settingsModified(false/*update*/);
emit settingChangedSig(change);
}

void BlenderPreferences::settingChanged(int index)
{
int i = -1;
bool change = false;
QString item;

if (index > -1) {
QComboBox *comboBox = qobject_cast<QComboBox *>(sender());
if (comboBox) {
i = comboBox->property("ControlID").toInt();
item = comboBox->itemData(index).toString();
}
} else {
QCheckBox *checkBox = qobject_cast<QCheckBox *>(sender());
if (checkBox) {
i = checkBox->property("ControlID").toInt();
item = QString::number(checkBox->isChecked());
}
}

if (i > -1) {
if (mImportMMActBox->isChecked()) {
change = mBlenderSettingsMM[i].value != item;
} else {
change = mBlenderSettings[i].value != item;
}
}

change |= settingsModified(false/*update*/);
emit settingChangedSig(change);
}

void BlenderPreferences::pathChanged()
{
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(sender());
if (lineEdit) {
bool change = false;
const int i = lineEdit->property("ControlID").toInt();
const QString &path = QDir::toNativeSeparators(lineEdit->text()).toLower();

if (i != LBL_BLENDER_PATH) {
change = QDir::toNativeSeparators(mBlenderPaths[i].value).toLower() != path;
}

change |= settingsModified(false/*update*/);
emit settingChangedSig(change);
}
}

bool BlenderPreferences::getBlenderAddon(const QString &blenderDir)
{
enum BlenderAddOnUpdate
Expand Down Expand Up @@ -1477,7 +1410,7 @@ bool BlenderPreferences::getBlenderAddon(const QString &blenderDir)
}
}

// Remove old addon archive if exist
// Remove old extracted addon if exist
if (QFileInfo(blenderAddonDir).exists()) {
bool result = true;
QDir dir(blenderAddonDir);
Expand Down Expand Up @@ -1631,6 +1564,73 @@ void BlenderPreferences::showResult()
emit gui->messageSig(hasError ? LOG_NOTICE : LOG_INFO, message);
}

void BlenderPreferences::settingChanged(const QString &value)
{
bool change = false;

QLineEdit *lineEdit = qobject_cast<QLineEdit *>(sender());
if (lineEdit) {
int i = lineEdit->property("ControlID").toInt();
if (mImportMMActBox->isChecked()) {
change = mBlenderSettingsMM[i].value != value;
} else {
change = mBlenderSettings[i].value != value;
}
}

change |= settingsModified(false/*update*/);
emit settingChangedSig(change);
}

void BlenderPreferences::settingChanged(int index)
{
int i = -1;
bool change = false;
QString item;

if (index > -1) {
QComboBox *comboBox = qobject_cast<QComboBox *>(sender());
if (comboBox) {
i = comboBox->property("ControlID").toInt();
item = comboBox->itemData(index).toString();
}
} else {
QCheckBox *checkBox = qobject_cast<QCheckBox *>(sender());
if (checkBox) {
i = checkBox->property("ControlID").toInt();
item = QString::number(checkBox->isChecked());
}
}

if (i > -1) {
if (mImportMMActBox->isChecked()) {
change = mBlenderSettingsMM[i].value != item;
} else {
change = mBlenderSettings[i].value != item;
}
}

change |= settingsModified(false/*update*/);
emit settingChangedSig(change);
}

void BlenderPreferences::pathChanged()
{
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(sender());
if (lineEdit) {
bool change = false;
const int i = lineEdit->property("ControlID").toInt();
const QString &path = QDir::toNativeSeparators(lineEdit->text()).toLower();

if (i != LBL_BLENDER_PATH) {
change = QDir::toNativeSeparators(mBlenderPaths[i].value).toLower() != path;
}

change |= settingsModified(false/*update*/);
emit settingChangedSig(change);
}
}

void BlenderPreferences::getStandardOutput()
{
QString const logFile = QString("%1/Blender/stdout-blender-addon-install").arg(Preferences::lpub3d3rdPartyConfigDir);
Expand All @@ -1647,11 +1647,10 @@ void BlenderPreferences::getStandardOutput()
if (Preferences::useSystemEditor) {
QDesktopServices::openUrl(QUrl("file:///"+logFile, QUrl::TolerantMode));
} else {
const QString _title = tr("%1 Blender Addon Standard Output").arg(VER_PRODUCTNAME_STR);
ParmsWindow *parmsWindow = new ParmsWindow(mContent);
parmsWindow->setWindowTitle(_title);
parmsWindow->displayParmsFile(logFile);
const QString _title = tr("%1 Blender addon standard output").arg(VER_PRODUCTNAME_STR);
const QString _status = tr("View Blender standard output");
parmsWindow->setWindowTitle(tr(_title.toLatin1(),_status.toLatin1()));
parmsWindow->show();
}
}
Expand Down Expand Up @@ -2498,26 +2497,26 @@ void BlenderPreferences::enableImportModule()
initPathsAndSettings();
}

int BlenderPreferences::numSettings(bool mDefaultSettings)
int BlenderPreferences::numSettings(bool defaultSettings)
{
int size = 0;
if (!mBlenderSettings[0].key.isEmpty() || mDefaultSettings)
if (!mBlenderSettings[0].key.isEmpty() || defaultSettings)
size = sizeof(mBlenderSettings)/sizeof(mBlenderSettings[0]);
return size;
}

int BlenderPreferences::numSettingsMM(bool mDefaultSettings)
int BlenderPreferences::numSettingsMM(bool defaultSettings)
{
int size = 0;
if (!mBlenderSettingsMM[0].key.isEmpty() || mDefaultSettings)
if (!mBlenderSettingsMM[0].key.isEmpty() || defaultSettings)
size = sizeof(mBlenderSettingsMM)/sizeof(mBlenderSettingsMM[0]);
return size;
}

int BlenderPreferences::numPaths(bool mDefaultSettings)
int BlenderPreferences::numPaths(bool defaultSettings)
{
int size = 0;
if (!mBlenderPaths[0].key.isEmpty() || mDefaultSettings)
if (!mBlenderPaths[0].key.isEmpty() || defaultSettings)
size = sizeof(mBlenderPaths)/sizeof(mBlenderPaths[0]);
return size;
}
Expand Down Expand Up @@ -2802,9 +2801,8 @@ bool BlenderPreferences::promptAccept()
return false;
}

void BlenderPreferences::loadDefaultParameters(QByteArray& Buffer, int Which)
void BlenderPreferences::loadDefaultParameters(QByteArray& buffer, int which)
{

/*
# File: BlenderLDrawParameters.lst
#
Expand Down Expand Up @@ -3059,13 +3057,13 @@ void BlenderPreferences::loadDefaultParameters(QByteArray& Buffer, int Which)
"lighted_brick, 54869.dat, 1.000, 0.052, 0.017, 1.0\n"
};

Buffer.clear();
if (Which == PARAMS_CUSTOM_COLOURS)
Buffer.append(DefaultCustomColours, sizeof(DefaultCustomColours));
else if (Which == PARAMS_SLOPED_BRICKS)
Buffer.append(DefaultSlopedBricks, sizeof(DefaultSlopedBricks));
else if (Which == PARAMS_LIGHTED_BRICKS)
Buffer.append(DefaultLightedBricks, sizeof(DefaultLightedBricks));
buffer.clear();
if (which == PARAMS_CUSTOM_COLOURS)
buffer.append(DefaultCustomColours, sizeof(DefaultCustomColours));
else if (which == PARAMS_SLOPED_BRICKS)
buffer.append(DefaultSlopedBricks, sizeof(DefaultSlopedBricks));
else if (which == PARAMS_LIGHTED_BRICKS)
buffer.append(DefaultLightedBricks, sizeof(DefaultLightedBricks));
}

bool BlenderPreferences::exportParameterFile(){
Expand Down
Loading

0 comments on commit ce0d636

Please sign in to comment.