Skip to content

Commit

Permalink
Blender LDraw Render - default colour #416
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed May 12, 2023
1 parent 90611a0 commit 4e198d1
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 53 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.3373
pkgver=2.4.6.3374
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.3373
pkgver=2.4.6.3374
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.3373) debian; urgency=medium
lpub3d (2.4.6.3374) debian; urgency=medium

* LPub3D version 2.4.6.262.3373_20230512 for Linux
* LPub3D version 2.4.6.263.3374_20230512 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Fri, 12 May 2023 06:02:10 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Fri, 12 May 2023 06:02:38 +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.3373
Version: 2.4.6.3374
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.3373
Version: 2.4.6.3374
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
* Fri May 12 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3373
* Fri May 12 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3374
- 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.3373) debian; urgency=medium
lpub3d (2.4.6.3374) debian; urgency=medium

* LPub3D version 2.4.6.262.3373_20230512 for Linux
* LPub3D version 2.4.6.263.3374_20230512 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Fri, 12 May 2023 06:02:11 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Fri, 12 May 2023 06:02:39 +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.3373
Version: 2.4.6.3374
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.3373
Version: 2.4.6.3374
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
* Fri May 12 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3373
* Fri May 12 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3374
- 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 262 3373 f13df7c62
2 4 6 263 3374 90611a0b9
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 = 262
GIT_REVISION = 263
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 = 3373
GIT_COMMIT = 3374
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}.262.3373.f13df7c62
GIT_VERSION = $${VERSION}.263.3374.90611a0b9
message("~~~ GIT_DIR [$$GIT_DIR_ENV, USING VERSION] $$GIT_VERSION ~~~")
GIT_VERSION ~= s/\./" "
}
Expand Down
75 changes: 45 additions & 30 deletions mainApp/blenderpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ BlenderPreferences::BlenderSettings BlenderPreferences::mDefaultSettings [NUM_S

/*26/0 LBL_BEVEL_WIDTH */ {"bevelwidth", "0.5", QObject::tr("Bevel Width"), QObject::tr("Width of the bevelled edges")},
/*27/1 LBL_CAMERA_BORDER_PERCENT */ {"cameraborderpercentage", "5.0", QObject::tr("Camera Border Percent"), QObject::tr("When positioning the camera, include a (percentage) border around the model in the render")},
/*28/2 LBL_DEFAULT_COLOUR */ {"defaultcolour", "4", QObject::tr("Default Colour"), QObject::tr("Sets the default part colour")},
/*28/2 LBL_DEFAULT_COLOUR */ {"defaultcolour", "16", QObject::tr("Default Colour"), QObject::tr("Sets the default part colour using LDraw colour code")},
/*29/3 LBL_GAPS_SIZE */ {"gapwidth", "0.01", QObject::tr("Gap Width"), QObject::tr("Amount of gap space between each part")},
/*20/4 LBL_IMAGE_WIDTH */ {"resolutionwidth", "800", QObject::tr("Image Width"), QObject::tr("Sets the rendered image width in pixels.")},
/*31/5 LBL_IMAGE_HEIGHT */ {"resolutionheight", "600", QObject::tr("Image Height"), QObject::tr("Sets the rendered image height in pixels.")},
Expand Down Expand Up @@ -665,7 +665,7 @@ void BlenderPreferences::initPathsAndSettings()
lineEdit->setToolTip(mBlenderSettings[i].tooltip);
mLineEditList << lineEdit;
if (i == LBL_DEFAULT_COLOUR)
setDefaultColor(mBlenderSettings[LBL_DEFAULT_COLOUR].value.toInt());
setDefaultColor(lcGetColorIndex(mBlenderSettings[LBL_DEFAULT_COLOUR].value.toInt()));
mSettingsSubform->addRow(label,lineEdit);
} else { // QComboBoxes
QComboBox *comboBox = new QComboBox(mSettingsBox);
Expand Down Expand Up @@ -1293,7 +1293,7 @@ void BlenderPreferences::settingChanged(int index)
QComboBox *comboBox = qobject_cast<QComboBox *>(sender());
if (comboBox) {
i = comboBox->property("ControlID").toInt();
item = comboBox->itemData(index).toString()/*comboBox->itemText(index)*/;
item = comboBox->itemData(index).toString();
}
} else {
QCheckBox *checkBox = qobject_cast<QCheckBox *>(sender());
Expand Down Expand Up @@ -1920,27 +1920,30 @@ bool BlenderPreferences::settingsModified(bool update, const QString &module)
_oldValue = width;
_width = gAddonPreferences->mLineEditList[j]->text().toDouble(&ok);
if (ok) {
width = int(_width);
if (update)
if (update) {
width = int(_width);
mBlenderSettingsMM[i].value = QString::number(width);
}
modified |= itemChanged(_oldValue, _width);
}
} else if (j == RESOLUTION_HEIGHT_EDIT) {
_oldValue = height;
_height = gAddonPreferences->mLineEditList[j]->text().toDouble(&ok);
if (ok) {
height = int(_height);
if (update)
if (update) {
height = int(_height);
mBlenderSettingsMM[i].value = QString::number(height);
}
modified |= itemChanged(_oldValue, _height);
}
} else if (j == LBL_RENDER_PERCENTAGE_MM) {
_oldValue = renderPercentage;
_renderPercentage = gAddonPreferences->mLineEditList[j]->text().toInt(&ok);
if (ok) {
renderPercentage = double(_renderPercentage / 100);
if (update)
if (update) {
renderPercentage = double(_renderPercentage / 100);
mBlenderSettingsMM[i].value = QString::number(_renderPercentage);
}
modified |= itemChanged(_oldValue, renderPercentage);
}
} else {
Expand Down Expand Up @@ -1989,36 +1992,48 @@ bool BlenderPreferences::settingsModified(bool update, const QString &module)
_oldValue = width;
_width = gAddonPreferences->mLineEditList[j]->text().toDouble(&ok);
if (ok) {
width = int(_width);
if (update)
if (update) {
width = int(_width);
mBlenderSettings[i].value = QString::number(width);
}
modified |= itemChanged(_oldValue, _width);
}
} else if (j == IMAGE_HEIGHT_EDIT) {
_oldValue = height;
_height = gAddonPreferences->mLineEditList[j]->text().toDouble(&ok);
if (ok) {
height = int(_height);
if (update)
if (update) {
height = int(_height);
mBlenderSettings[i].value = QString::number(height);
}
modified |= itemChanged(_oldValue, _height);
}
} else if (j == LBL_RENDER_PERCENTAGE) {
_oldValue = renderPercentage;
_renderPercentage = gAddonPreferences->mLineEditList[j]->text().toInt(&ok);
if (ok) {
renderPercentage = double(_renderPercentage / 100);
if (update)
if (ok) {
if (update) {
renderPercentage = double(_renderPercentage / 100);
mBlenderSettings[i].value = QString::number(_renderPercentage);
}
modified |= itemChanged(_oldValue, renderPercentage);
}
} else {
_oldValue = mBlenderSettings[i].value.toDouble();
_value = j == DEFAULT_COLOUR_EDIT ? gAddonPreferences->mLineEditList[j]->property("ColourID").toDouble(&ok)
: gAddonPreferences->mLineEditList[j]->text().toDouble(&ok);
if (j == DEFAULT_COLOUR_EDIT) {
_oldValue = lcGetColorIndex(mBlenderSettings[i].value.toInt()); // colour code
_value = gAddonPreferences->mLineEditList[j]->property("ColorIndex").toInt(&ok);
} else {
_oldValue = mBlenderSettings[i].value.toDouble();
_value = gAddonPreferences->mLineEditList[j]->text().toDouble(&ok);
}
if (ok) {
if (update)
mBlenderSettings[i].value = QString::number(j == DEFAULT_COLOUR_EDIT ? int(_value) : _value);
if (update) {
if (j == DEFAULT_COLOUR_EDIT) {
mBlenderSettings[i].value = QString::number(lcGetColorCode(qint32(_value)));
} else {
mBlenderSettings[i].value = QString::number(_value);
}
}
modified |= itemChanged(_oldValue, _value);
}
}
Expand Down Expand Up @@ -2057,7 +2072,7 @@ void BlenderPreferences::resetSettings()
mConfigured = !Preferences::blenderImportModule.isEmpty();

mBlenderPaths[LBL_BLENDER_PATH].value = Preferences::blenderExe;
mBlenderVersion = Preferences::blenderVersion;
mBlenderVersion = Preferences::blenderVersion;
mAddonVersion = Preferences::blenderAddonVersion;

mBlenderVersionEdit->setText(mBlenderVersion);
Expand Down Expand Up @@ -2085,7 +2100,7 @@ void BlenderPreferences::resetSettings()
else if (j == RENDER_PERCENTAGE_EDIT)
mLineEditList[j]->setText(QString::number(mRenderPercentage * 100));
else if (j == DEFAULT_COLOUR_EDIT)
setDefaultColor(mBlenderSettings[LBL_DEFAULT_COLOUR].value.toInt());
setDefaultColor(lcGetColorIndex(mBlenderSettings[LBL_DEFAULT_COLOUR].value.toInt()));
else
mLineEditList[j]->setText(mBlenderSettings[i].value);
if (i < LBL_RENDER_PERCENTAGE)
Expand Down Expand Up @@ -2192,7 +2207,6 @@ void BlenderPreferences::loadSettings()
};
}
mBlenderSettings[LBL_RENDER_PERCENTAGE].value = QString::number(gAddonPreferences->mRenderPercentage * 100);
mBlenderSettings[LBL_DEFAULT_COLOUR].value = QString::number(gDefaultColor);
}

// load default MM settings if settings not populated
Expand Down Expand Up @@ -2466,7 +2480,7 @@ void BlenderPreferences::showPathsGroup()

void BlenderPreferences::colorButtonClicked(bool)
{
int ColorIndex = mLineEditList[DEFAULT_COLOUR_EDIT]->property("ColourID").toInt();
int ColorIndex = mLineEditList[DEFAULT_COLOUR_EDIT]->property("ColorIndex").toInt();

QWidget *parent = mLineEditList[DEFAULT_COLOUR_EDIT];
lcQColorPickerPopup *popup = new lcQColorPickerPopup(parent, ColorIndex);
Expand All @@ -2491,25 +2505,26 @@ void BlenderPreferences::colorButtonClicked(bool)
popup->show();
}

void BlenderPreferences::setDefaultColor(int value)
void BlenderPreferences::setDefaultColor(int colorIndex)
{
QImage img(12, 12, QImage::Format_ARGB32);
img.fill(0);

lcColor* color = &gColorList[uint(value)];
lcColor* color = &gColorList[colorIndex];
QPainter painter(&img);
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.setPen(Qt::darkGray);
painter.setBrush(QColor::fromRgbF(qreal(color->Value[0]), qreal(color->Value[1]), qreal(color->Value[2])));
painter.drawRect(0, 0, img.width() - 1, img.height() - 1);
painter.end();

mLineEditList[DEFAULT_COLOUR_EDIT]->setText(QString("%1 (%2)").arg(color->Name).arg(value));
mLineEditList[DEFAULT_COLOUR_EDIT]->setProperty("ColourID", QVariant::fromValue(value));
int const colorCode = lcGetColorCode(colorIndex);
mLineEditList[DEFAULT_COLOUR_EDIT]->setText(QString("%1 (%2)").arg(color->Name).arg(colorCode));
mLineEditList[DEFAULT_COLOUR_EDIT]->setProperty("ColorIndex", QVariant::fromValue(colorIndex));
mDefaultColourEditAction->setIcon(QPixmap::fromImage(img));
mDefaultColourEditAction->setToolTip(tr("Select Colour"));

bool change = mBlenderSettings[LBL_DEFAULT_COLOUR].value != QString::number(value);
bool change = mBlenderSettings[LBL_DEFAULT_COLOUR].value != QString::number(colorCode);
change |= settingsModified(false/*update*/);
emit settingChangedSig(change);
}
Expand Down
2 changes: 1 addition & 1 deletion mainApp/blenderpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private slots:
void updateBlenderAddon();
void enableImportModule();
void sizeChanged(const QString &);
void setDefaultColor(int value);
void setDefaultColor(int);
void colorButtonClicked(bool);
void setModelSize(bool);
void validateColourScheme(int);
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.262.3373 (12 05 2023 06:02:11)
LPub3D 2.4.6.263.3374 (12 05 2023 06:02:39)

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.262.3373 (12 05 2023 06:02:11)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.6.263.3374 (12 05 2023 06:02:39)</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.262.3373
;; Last Update.: Fri, 12 May 2023 06:02:11 +0200
;; Version.....: 2.4.6.263.3374
;; Last Update.: Fri, 12 May 2023 06:02:39 +0200
;; License.....: GPLv3
;; Homepage....: https://trevorsandy.github.io/lpub3d
;; Copyright (C) 2021 - 2023 by Trevor SANDY
Expand Down

0 comments on commit 4e198d1

Please sign in to comment.