Skip to content

Commit

Permalink
Fade and highlight - remove custom attributes from native colors #710
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed May 8, 2023
1 parent 28d2810 commit 017d1f3
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 89 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.3336
pkgver=2.4.6.3337
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.3336
pkgver=2.4.6.3337
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.3336) debian; urgency=medium
lpub3d (2.4.6.3337) debian; urgency=medium

* LPub3D version 2.4.6.225.3336_20230508 for Linux
* LPub3D version 2.4.6.226.3337_20230508 for Linux

-- Trevor SANDY <[email protected]> Mon, 08 May 2023 15:12:48 +0200
-- Trevor SANDY <[email protected]> Mon, 08 May 2023 15:13:18 +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.3336
Version: 2.4.6.3337
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.3336
Version: 2.4.6.3337
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
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3336
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3337
- 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.3336) debian; urgency=medium
lpub3d (2.4.6.3337) debian; urgency=medium

* LPub3D version 2.4.6.225.3336_20230508 for Linux
* LPub3D version 2.4.6.226.3337_20230508 for Linux

-- Trevor SANDY <[email protected]> Mon, 08 May 2023 15:12:50 +0200
-- Trevor SANDY <[email protected]> Mon, 08 May 2023 15:13:20 +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.3336
Version: 2.4.6.3337
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.3336
Version: 2.4.6.3337
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
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3336
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3337
- 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 225 3336 603cfb074
2 4 6 226 3337 28d281072
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 = 225
GIT_REVISION = 226
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 = 3336
GIT_COMMIT = 3337
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}.225.3336.603cfb074
GIT_VERSION = $${VERSION}.226.3337.28d281072
message("~~~ GIT_DIR [$$GIT_DIR_ENV, USING VERSION] $$GIT_VERSION ~~~")
GIT_VERSION ~= s/\./" "
}
Expand Down
36 changes: 2 additions & 34 deletions lclib/common/lc_colors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ static std::vector<lcColor> lcParseColorFile(lcFile& File)
Color.Edge[1] = FLT_MAX;
Color.Edge[2] = FLT_MAX;
Color.Edge[3] = 1.0f;
/*** LPub3D Mod - use Visual Editor colors ***/
Color.CValue = ~0U;
Color.EValue = ~0U;
Color.Alpha = 255;
/*** LPub3D Mod end ***/

GetToken(Ptr, Token);
strncpy(Color.Name, Token, sizeof(Color.Name));
Expand Down Expand Up @@ -133,9 +128,7 @@ static std::vector<lcColor> lcParseColorFile(lcFile& File)
int Value;
if (sscanf(Token, "%x", &Value) != 1)
Value = 0;
/*** LPub3D Mod - use Visual Editor colors ***/
Color.CValue = Value;
/*** LPub3D Mod end ***/

Color.Value[2] = (float)(Value & 0xff) / 255.0f;
Value >>= 8;
Color.Value[1] = (float)(Value & 0xff) / 255.0f;
Expand All @@ -151,9 +144,6 @@ static std::vector<lcColor> lcParseColorFile(lcFile& File)
int Value;
if (sscanf(Token, "%x", &Value) != 1)
Value = 0;
/*** LPub3D Mod - use Visual Editor colors ***/
Color.EValue = Value;
/*** LPub3D Mod end ***/

Color.Edge[2] = (float)(Value & 0xff) / 255.0f;
Value >>= 8;
Expand All @@ -168,9 +158,7 @@ static std::vector<lcColor> lcParseColorFile(lcFile& File)
Color.Value[3] = (float)(Value & 0xff) / 255.0f;
if (Value != 255)
Color.Translucent = true;
/*** LPub3D Mod - use Visual Editor colors ***/
Color.Alpha = Value;
/*** LPub3D Mod end ***/

if (Value == 128)
Color.Group = LC_COLORGROUP_TRANSLUCENT;
else if (Value != 0)
Expand Down Expand Up @@ -290,11 +278,6 @@ bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle, bool Update, bool LPub
MainColor.Edge[1] = 0.2f;
MainColor.Edge[2] = 0.2f;
MainColor.Edge[3] = 1.0f;
/*** LPub3D Mod - use Visual Editor colors ***/
MainColor.CValue = lcColorFromVector3(lcVector3(MainColor.Value));
MainColor.EValue = lcColorFromVector3(lcVector3(MainColor.Edge));
MainColor.Alpha = 255;
/*** LPub3D Mod end ***/
strcpy(MainColor.Name, "Main Color");
strcpy(MainColor.SafeName, "Main_Color");

Expand All @@ -316,11 +299,6 @@ bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle, bool Update, bool LPub
EdgeColor.Edge[1] = 0.2f;
EdgeColor.Edge[2] = 0.2f;
EdgeColor.Edge[3] = 1.0f;
/*** LPub3D Mod - use Visual Editor colors ***/
EdgeColor.CValue = lcColorFromVector3(lcVector3(EdgeColor.Value));
EdgeColor.EValue = lcColorFromVector3(lcVector3(EdgeColor.Edge));
EdgeColor.Alpha = 255;
/*** LPub3D Mod end ***/
strcpy(EdgeColor.Name, "Edge Color");
strcpy(EdgeColor.SafeName, "Edge_Color");

Expand All @@ -337,11 +315,6 @@ bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle, bool Update, bool LPub
StudCylinderColor.Group = LC_NUM_COLORGROUPS;
StudCylinderColor.Value = lcVector4FromColor(Preferences.mStudCylinderColor);
StudCylinderColor.Edge = lcVector4FromColor(Preferences.mPartEdgeColor);
/*** LPub3D Mod - use Visual Editor colors ***/
StudCylinderColor.CValue = lcColorFromVector3(lcVector3(StudCylinderColor.Value));
StudCylinderColor.EValue = lcColorFromVector3(lcVector3(StudCylinderColor.Edge));
StudCylinderColor.Alpha = 255;
/*** LPub3D Mod end ***/
strcpy(StudCylinderColor.Name, "Stud Cylinder Color");
strcpy(StudCylinderColor.SafeName, "Stud_Cylinder_Color");

Expand All @@ -363,11 +336,6 @@ bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle, bool Update, bool LPub
NoColor.Edge[1] = 0.2f;
NoColor.Edge[2] = 0.2f;
NoColor.Edge[3] = 1.0f;
/*** LPub3D Mod - use Visual Editor colors ***/
NoColor.CValue = lcColorFromVector3(lcVector3(NoColor.Value));
NoColor.EValue = lcColorFromVector3(lcVector3(NoColor.Edge));
NoColor.Alpha = 255;
/*** LPub3D Mod end ***/
strcpy(NoColor.Name, "No Color");
strcpy(NoColor.SafeName, "No_Color");

Expand Down
5 changes: 0 additions & 5 deletions lclib/common/lc_colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ struct lcColor
lcVector4 Edge;
char Name[LC_MAX_COLOR_NAME];
char SafeName[LC_MAX_COLOR_NAME];
/*** LPub3D Mod - use Visual Editor colors ***/
quint32 CValue;
quint32 EValue;
int Alpha;
/*** LPub3D Mod end ***/
};

enum
Expand Down
7 changes: 7 additions & 0 deletions lclib/common/lc_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,13 @@ inline lcVector4 lcVector4FromColor(quint32 Color)
return v;
}

/*** LPub3D Mod - use Visual Editor colors ***/
inline QColor lcQColorFromVector4(const lcVector4& Color)
{
return QColor::fromRgb(roundf(Color[0] * 255), roundf(Color[1] * 255), roundf(Color[2] * 255), roundf(Color[3] * 255));
}
/*** LPub3D Mod end ***/

inline quint32 lcColorFromVector3(const lcVector3& Color)
{
return LC_RGB(roundf(Color[0] * 255), roundf(Color[1] * 255), roundf(Color[2] * 255));
Expand Down
47 changes: 22 additions & 25 deletions mainApp/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ void LDrawColor::LDrawColorInit()

for (lcColor& gColor : gColorList)
{
lcColor* nativeColor = &gColor;
if (nativeColor->Code == quint32(LC_COLOR_NOCOLOR))
continue;
QColor color(nativeColor->CValue);
color.setAlpha(nativeColor->Alpha);
QString const edge = QColor(nativeColor->EValue).name(QColor::HexRgb);
QString const name = nativeColor->SafeName;
QString const code = QString::number(nativeColor->Code);
if (gColor.Code == quint32(LC_COLOR_NOCOLOR))
continue;
QColor color = lcQColorFromVector4(gColor.Value);
QColor edgecolor = lcQColorFromVector4(gColor.Edge);
QString const edge = edgecolor.name(edgecolor.alpha() != 255 ? QColor::HexArgb : QColor::HexRgb);
QString const name = gColor.SafeName;
QString const code = QString::number(gColor.Code);

AddColor(color, name, code, edge);
}
}
Expand All @@ -66,28 +66,25 @@ void LDrawColor::LDrawColorInit()
*/
void LDrawColor::AddColor(const QColor& color, const QString& name, const QString& code, const QString& edge, bool native)
{
ldname2ldcolor.insert(name.toLower(),code); // color code from name (lower)
value2code. insert(color.name(QColor::HexRgb).toLower(),code.toInt());// color code from value (lower)
color2value.insert(code,color.name(QColor::HexRgb).toUpper()); // color value from code
color2edge. insert(code,edge.toUpper()); // color edge from code
color2alpha.insert(code,color.alpha()); // color alpha from code
color2name. insert(code,name); // color name from code (safe name e.g. Dark_Nougat)
color2name. insert(color.name(QColor::HexRgb).toLower(),name); // color name from value (lower)
name2QColor.insert(code,color); // QColor object from code
name2QColor.insert(name.toLower(),color); // QColor object from name (lower) - e.g. dark_nougat
QColor::NameFormat format = QColor::HexRgb;
ldname2ldcolor.insert(name.toLower(),code); // color code from name (lower)
value2code. insert(color.name(format).toLower(),code.toInt());// color code from value (lower)
color2value.insert(code,color.name(format).toUpper()); // color value from code
color2edge. insert(code,edge.toUpper()); // color edge from code
color2alpha.insert(code,color.alpha()); // color alpha from code
color2name. insert(code,name); // color name from code (safe name e.g. Dark_Nougat)
color2name. insert(color.name(format).toLower(),name); // color name from value (lower)
name2QColor.insert(code,color); // QColor object from code
name2QColor.insert(name.toLower(),color); // QColor object from name (lower) - e.g. dark_nougat

QString const message = QObject::tr("%1. ADD 0 !COLOUR %2 CODE %3 VALUE %4 EDGE %5 ALPHA %6 QCOLOR_NAME %7")
.arg(ldname2ldcolor.size(), 3, 10, QChar(' ')).arg(name).arg(code).arg(color.name().toUpper())
.arg(edge.toUpper()).arg(color.alpha()).arg(color.name());
.arg(ldname2ldcolor.size(), 3, 10, QChar(' ')).arg(name).arg(code).arg(color.name().toUpper())
.arg(edge.toUpper()).arg(color.alpha()).arg(color.name());
//qDebug() << qUtf8Printable(message);
if (!native) {
userdefinedcolors.append(name.toLower());
emit lpub->messageSig(LOG_INFO, message);
#ifdef QT_DEBUG_MODE
} else {
;
//qDebug() << qUtf8Printable(message);
#endif
}

}

/*
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.225.3336 (08 05 2023 15:12:50)
LPub3D 2.4.6.226.3337 (08 05 2023 15:13:20)

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.225.3336 (08 05 2023 15:12:50)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.6.226.3337 (08 05 2023 15:13:20)</h4>
<hr>
<p>
<span class="tg-1pky">LPub3D Official release.</span><br>
Expand Down
2 changes: 1 addition & 1 deletion mainApp/editwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ void EditWindow::editLineItem()
int colorCode = elements.first().toInt();
int newColorIndex = -1;
items = elements.at(1).split(" ", SkipEmptyParts);
QColor qcolor(gColorList[lcGetColorIndex(colorCode)].CValue);
QColor qcolor = lcQColorFromVector4(gColorList[lcGetColorIndex(colorCode)].Value);
QColor newColor = LDrawColorDialog::getLDrawColor(colorCode, newColorIndex, this);
if (newColor.isValid() && qcolor != newColor) {
if (elements.size() == 3) // selection is a substitute meta command
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.225.3336
;; Last Update.: Mon, 08 May 2023 15:12:50 +0200
;; Version.....: 2.4.6.226.3337
;; Last Update.: Mon, 08 May 2023 15:13:20 +0200
;; License.....: GPLv3
;; Homepage....: https://trevorsandy.github.io/lpub3d
;; Copyright (C) 2021 - 2023 by Trevor SANDY
Expand Down
4 changes: 2 additions & 2 deletions mainApp/substitutepartdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void SubstitutePartDialog::initialize()
ui->ldrawTitleLbl->setText(Pli::titleDescription(mLdrawType));
}

QColor partColor(gColorList[lcGetColorIndex(mAttributes.at(sColorCode).toInt())].CValue);
QColor partColor = lcQColorFromVector4(gColorList[lcGetColorIndex(mAttributes.at(sColorCode).toInt())].Value);
if(partColor.isValid() ) {
ui->colorLbl->setAutoFillBackground(true);
QString styleSheet =
Expand Down Expand Up @@ -631,7 +631,7 @@ void SubstitutePartDialog::browseType(bool clicked)
void SubstitutePartDialog::browseColor(bool clicked)
{
Q_UNUSED(clicked);
QString colorName = QColor(gColorList[lcGetColorIndex(mAttributes.at(sColorCode).toInt())].CValue).name();
QColor colorName = lcQColorFromVector4(gColorList[lcGetColorIndex(mAttributes.at(sColorCode).toInt())].Value).name();
int newColorIndex = ~0U;
QColor newColor = LDrawColorDialog::getLDrawColor(mAttributes.at(sColorCode).toInt(),newColorIndex,this);
QString newColorName = newColor.name();
Expand Down

0 comments on commit 017d1f3

Please sign in to comment.