Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix HDR Metadata model to handle dependencies properly

Dmitry Kazakovf911474e5135
diff --git a/libs/image/kis_hdr_metadata.cpp b/libs/image/kis_hdr_metadata.cpp
index c1b68b01c7..cd8d43d239 100644
--- a/libs/image/kis_hdr_metadata.cpp
+++ b/libs/image/kis_hdr_metadata.cpp
@@ -22,3 +22,22 @@ bool KisColorVolumeInformation::operator==(const KisColorVolumeInformation &othe
&& white == other.white && red == other.red
&& green == other.green && blue == other.blue;
}
+
+const KisColorVolumeInformation KisColorVolumeInformation::BT2100PQ = {
+ {}, // for boost::equality_comparable :(
+ KoColorimetryUtils::Colorimetry::BT2020.white().toxy(),
+ KoColorimetryUtils::Colorimetry::BT2020.red().toxy(),
+ KoColorimetryUtils::Colorimetry::BT2020.green().toxy(),
+ KoColorimetryUtils::Colorimetry::BT2020.blue().toxy(),
+ 1000.0,
+ 0.005
+};
+const KisColorVolumeInformation KisColorVolumeInformation::DCIP3D65 = {
+ {}, // for boost::equality_comparable :(
+ KoColorimetryUtils::Colorimetry::DCIP3.white().toxy(),
+ KoColorimetryUtils::Colorimetry::DCIP3.red().toxy(),
+ KoColorimetryUtils::Colorimetry::DCIP3.green().toxy(),
+ KoColorimetryUtils::Colorimetry::DCIP3.blue().toxy(),
+ 1000.0,
+ 0.005
+};
\ No newline at end of file
diff --git a/libs/image/kis_hdr_metadata.h b/libs/image/kis_hdr_metadata.h
index af45987f2b..237998a189 100644
--- a/libs/image/kis_hdr_metadata.h
+++ b/libs/image/kis_hdr_metadata.h
@@ -55,6 +55,9 @@ struct KRITAIMAGE_EXPORT KisColorVolumeInformation: public boost::equality_compa
double minLuminance = 0.0; ///< Minimum screen brightness in cd/m²
bool operator==(const KisColorVolumeInformation & other) const;;
+
+ static const KisColorVolumeInformation BT2100PQ;
+ static const KisColorVolumeInformation DCIP3D65;
};
Q_DECLARE_METATYPE(KisRelativeContentLightLevelInformation::CalculationType);
diff --git a/libs/image/kis_hdr_metadata_models.cpp b/libs/image/kis_hdr_metadata_models.cpp
index 5b2a3bdd1f..b974ceeed2 100644
--- a/libs/image/kis_hdr_metadata_models.cpp
+++ b/libs/image/kis_hdr_metadata_models.cpp
@@ -6,20 +6,27 @@
#include "kis_hdr_metadata_models.h"
#include <KLocalizedString>
#include <lager/constant.hpp>
+#include <lager/setter.hpp>
#include <KisZug.h>
#include <KisLager.h>
namespace {
-QList<double> refWhiteList {
+static constexpr std::array<double, 2> refWhiteList {
80.0,
203.0
};
-auto referenceWhiteToInt = [](){
- return lager::lenses::getset(
+double calcEffectiveReferenceWhite(bool imageProfileIsRelative, double imageProfileReferenceWhite, double imageMetadataReferenceWhite)
+{
+ return imageProfileIsRelative ? imageMetadataReferenceWhite : imageProfileReferenceWhite;
+}
+
+auto referenceWhiteToInt =
+ lager::lenses::getset(
[] (const double &value) -> int {
int index = -1;
- for (int i = 0; i < refWhiteList.size(); i++) {
+
+ for (size_t i = 0; i < refWhiteList.size(); i++) {
if (qFuzzyCompare(value, refWhiteList.at(i))) {
index = i;
break;
@@ -28,18 +35,19 @@ auto referenceWhiteToInt = [](){
return index;
},
[] (double value, const int &newValue) {
- value = refWhiteList.value(newValue, 0.0);
+ if (newValue >= 0 && newValue < int(refWhiteList.size())) {
+ value = refWhiteList[newValue];
+ }
return value;
}
);
-};
-ComboBoxState whiteTypeToComboBoxState(int index, bool enabled)
+ComboBoxState calcWhiteTypeToComboBoxState(int index, bool enabled)
{
QStringList values;
QStringList toolTips;
- for (int i = 0; i < refWhiteList.size(); i++) {
+ for (size_t i = 0; i < refWhiteList.size(); i++) {
values << i18nc("Image reference white value", "%1 cd/m²", QString::number(refWhiteList.at(i)));
toolTips << "";
}
@@ -63,131 +71,141 @@ ComboBoxState calcTypeComboBoxState(KisRelativeContentLightLevelInformation::Cal
return {values, static_cast<int>(type), enabled, toolTips};
}
-auto multiplyByReferenceWhite = [](double referenceWhite){
- return lager::lenses::getset(
- [referenceWhite] (const double &value) -> double {
- return value * referenceWhite;
+auto noopSetter = [] (auto) {};
+
+auto calcRelativeToAbsoluteWhiteLevel = lager::lenses::getset(
+ // .first is relative white level
+ // .second is reference white level
+ [] (const std::tuple<double,double> &packed) -> double {
+ return std::get<0>(packed) * std::get<1>(packed);
},
- [referenceWhite] (double value, const double &newValue) {
- value = referenceWhite > 0? newValue/referenceWhite: 0.0;
- return value;
+ [] (std::tuple<double,double> packed, double absoluteValue) {
+ if (!qFuzzyIsNull(std::get<1>(packed))) {
+ std::get<0>(packed) = absoluteValue / std::get<1>(packed);
+ }
+ return packed;
}
- );
-};
+);
-auto colorimetryXcoord = []() {
- return lager::lenses::getset(
- [] (const KoColorimetryUtils::xy &value) -> double {
- return value.x;
+auto effectivePresetIndexForCvi =
+ lager::lenses::getset(
+ [] (const KisColorVolumeInformation &cvi) -> int {
+ if (cvi == KisColorVolumeInformation::BT2100PQ) {
+ return 0;
+ } else if (cvi == KisColorVolumeInformation::DCIP3D65) {
+ return 1;
+ } else {
+ return 2;
+ }
},
- [] (KoColorimetryUtils::xy value, const double &val) {
- value.x = val;
- return value;
+ [] (KisColorVolumeInformation cvi, const int &index) {
+ if (index == 0) {
+ cvi = KisColorVolumeInformation::BT2100PQ;
+ } else if (index == 1) {
+ cvi = KisColorVolumeInformation::DCIP3D65;
+ } else {
+ // noop, just keep `cvi` unchanged
+ }
+ return cvi;
}
);
-};
-auto colorimetryYcoord = []() {
- return lager::lenses::getset(
- [] (const KoColorimetryUtils::xy &value) -> double {
- return value.y;
- },
- [] (KoColorimetryUtils::xy value, const double &val) {
- value.y = val;
- return value;
- }
- );
-};
+ ComboBoxState calcCviEffectivePresetIndexState(int index, bool enabled) {
+ QStringList values;
+ QStringList toolTips;
+
+ values << i18n("Rec. 2100 PQ");
+ values << i18n("DCI-P3 D65");
+ values << i18n("Custom");
+
+ toolTips << i18nc("@info:tooltip", "Reset color volume to the values defined by Rec. 2100 PQ");
+ toolTips << i18nc("@info:tooltip", "Reset color volume to the values defined by DCI-P3 D65");
+ toolTips << i18nc("@info:tooltip", "Use custom values for color volume");
+
+ return {values, index, enabled, toolTips};
+}
}
-using KisWidgetConnectionUtils::ToSpinBoxState;
using KisWidgetConnectionUtils::ToControlState;
KisHDRMetadataModel::KisHDRMetadataModel(QObject *parent)
: QObject{parent}
, clliData(lager::make_state(KisRelativeContentLightLevelInformation(), lager::automatic_tag{}))
, cviData(lager::make_state(KisColorVolumeInformation(), lager::automatic_tag{}))
+ , imageProfileReferenceWhiteData(lager::make_state(203.0, lager::automatic_tag{}))
, referenceWhiteData(lager::make_state(203.0, lager::automatic_tag{}))
- , imageProfileRelativeData(lager::make_state(false, lager::automatic_tag{}))
- , referenceWhiteCheckedData(lager::make_state(false, lager::automatic_tag{}))
- , clliCheckedData(lager::make_state(false, lager::automatic_tag{}))
- , cviCheckedData(lager::make_state(false, lager::automatic_tag{}))
- , LAGER_QT(refWhiteChecked){lager::with(referenceWhiteCheckedData)}
- , LAGER_QT(refWhiteEnabled){lager::with(imageProfileRelativeData)}
- , LAGER_QT(refWhiteCheckedState){lager::with(LAGER_QT(refWhiteChecked), LAGER_QT(refWhiteEnabled)).map(ToControlState{})}
- , LAGER_QT(referenceWhite) {referenceWhiteData}
- , LAGER_QT(referenceWhiteIndex) {LAGER_QT(referenceWhite).zoom(referenceWhiteToInt())}
- , LAGER_QT(referenceWhiteState) {lager::with(LAGER_QT(referenceWhiteIndex), LAGER_QT(refWhiteChecked)).map(&whiteTypeToComboBoxState)}
- , LAGER_QT(clliChecked){lager::with(clliCheckedData)}
- , LAGER_QT(clliCheckedState){lager::with(LAGER_QT(clliChecked), lager::make_constant(true)).map(ToControlState{})}
- , LAGER_QT(maxContentLightLevel) {clliData[&KisRelativeContentLightLevelInformation::maxContentLightLevel].zoom(multiplyByReferenceWhite(LAGER_QT(referenceWhite).get()))}
- , LAGER_QT(maxContentLightLevelState) {lager::with(LAGER_QT(maxContentLightLevel),
- lager::make_constant(0.0),
- lager::make_constant(100000.0),
- LAGER_QT(clliChecked)).map(ToSpinBoxState{})}
- , LAGER_QT(maxFrameAverageLightLevel) {clliData[&KisRelativeContentLightLevelInformation::maxFrameAverageLightLevel].zoom(multiplyByReferenceWhite(LAGER_QT(referenceWhite).get()))}
- , LAGER_QT(maxFrameAverageLightLevelState) {lager::with(LAGER_QT(maxFrameAverageLightLevel),
- lager::make_constant(0.0),
- lager::make_constant(100000.0),
- LAGER_QT(clliChecked)).map(ToSpinBoxState{})}
- , LAGER_QT(clliCalculationType) {clliData[&KisRelativeContentLightLevelInformation::type]}
- , LAGER_QT(clliCalculationTypeState) {lager::with(LAGER_QT(clliCalculationType), LAGER_QT(clliChecked)).map(&calcTypeComboBoxState)}
- , LAGER_QT(cviChecked){lager::with(cviCheckedData)}
- , LAGER_QT(cviCheckedState){lager::with(LAGER_QT(cviChecked), lager::make_constant(true)).map(ToControlState{})}
- , LAGER_QT(cviWhiteX){cviData[&KisColorVolumeInformation::white].zoom(colorimetryXcoord())}
- , LAGER_QT(cviWhiteY){cviData[&KisColorVolumeInformation::white].zoom(colorimetryYcoord())}
- , LAGER_QT(cviWhiteXState){lager::with(LAGER_QT(cviWhiteX),
- lager::make_constant(0.0),
- lager::make_constant(1.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
- , LAGER_QT(cviWhiteYState){lager::with(LAGER_QT(cviWhiteY),
- lager::make_constant(0.0),
- lager::make_constant(1.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
- , LAGER_QT(cviRedX){cviData[&KisColorVolumeInformation::red].zoom(colorimetryXcoord())}
- , LAGER_QT(cviRedY){cviData[&KisColorVolumeInformation::red].zoom(colorimetryYcoord())}
- , LAGER_QT(cviRedXState){lager::with(LAGER_QT(cviRedX),
- lager::make_constant(0.0),
- lager::make_constant(1.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
- , LAGER_QT(cviRedYState){lager::with(LAGER_QT(cviRedY),
- lager::make_constant(0.0),
- lager::make_constant(1.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
- , LAGER_QT(cviGreenX){cviData[&KisColorVolumeInformation::green].zoom(colorimetryXcoord())}
- , LAGER_QT(cviGreenY){cviData[&KisColorVolumeInformation::green].zoom(colorimetryYcoord())}
- , LAGER_QT(cviGreenXState){lager::with(LAGER_QT(cviGreenX),
- lager::make_constant(0.0),
- lager::make_constant(1.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
- , LAGER_QT(cviGreenYState){lager::with(LAGER_QT(cviGreenY),
- lager::make_constant(0.0),
- lager::make_constant(1.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
- , LAGER_QT(cviBlueX){cviData[&KisColorVolumeInformation::blue].zoom(colorimetryXcoord())}
- , LAGER_QT(cviBlueY){cviData[&KisColorVolumeInformation::blue].zoom(colorimetryYcoord())}
- , LAGER_QT(cviBlueXState){lager::with(LAGER_QT(cviBlueX),
- lager::make_constant(0.0),
- lager::make_constant(1.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
- , LAGER_QT(cviBlueYState){lager::with(LAGER_QT(cviBlueY),
- lager::make_constant(0.0),
- lager::make_constant(1.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
+ , imageProfileIsRelativeData(lager::make_state(false, lager::automatic_tag{}))
+ , referenceWhitePresentData(lager::make_state(false, lager::automatic_tag{}))
+ , clliPresentData(lager::make_state(false, lager::automatic_tag{}))
+ , cviPresentData(lager::make_state(false, lager::automatic_tag{}))
+
+ , LAGER_QT(referenceWhitePresent) {referenceWhitePresentData}
+ , LAGER_QT(effectiveReferenceWhitePresent){
+ lager::with(referenceWhitePresentData,
+ imageProfileIsRelativeData.map(std::logical_not<>{})
+ ).map(std::logical_or<>{})}
+ , LAGER_QT(effectiveReferenceWhiteEnabled){imageProfileIsRelativeData}
+ , LAGER_QT(referenceWhitePresentState){lager::with(LAGER_QT(effectiveReferenceWhitePresent), LAGER_QT(effectiveReferenceWhiteEnabled)).map(ToControlState{})}
+
+ , LAGER_QT(referenceWhite){referenceWhiteData}
+ , LAGER_QT(referenceWhiteIndex){LAGER_QT(referenceWhite).zoom(referenceWhiteToInt)}
+ , LAGER_QT(effectiveReferenceWhite){
+ lager::with(
+ imageProfileIsRelativeData,
+ imageProfileReferenceWhiteData,
+ LAGER_QT(referenceWhite)
+ ).map(&calcEffectiveReferenceWhite)}
+ , LAGER_QT(effectiveReferenceWhiteIndex){LAGER_QT(effectiveReferenceWhite).zoom(referenceWhiteToInt)}
+ , LAGER_QT(referenceWhiteState){lager::with(LAGER_QT(effectiveReferenceWhiteIndex), LAGER_QT(effectiveReferenceWhitePresent))
+ .map(&calcWhiteTypeToComboBoxState)}
+
+ , LAGER_QT(clliPresent){clliPresentData}
+ , LAGER_QT(effectiveClliPresent){
+ lager::with(
+ clliPresentData,
+ LAGER_QT(effectiveReferenceWhitePresent)
+ ).map(std::logical_and<>{})}
+ , LAGER_QT(clliPresentState){lager::with(LAGER_QT(effectiveClliPresent), LAGER_QT(effectiveReferenceWhitePresent)).map(ToControlState{})}
+
+ , LAGER_QT(maxContentLightLevel){
+ lager::with(
+ clliData[&KisRelativeContentLightLevelInformation::maxContentLightLevel],
+ lager::with_setter(LAGER_QT(effectiveReferenceWhite), noopSetter)
+ ).zoom(calcRelativeToAbsoluteWhiteLevel)}
+ , LAGER_QT(maxFrameAverageLightLevel){
+ lager::with(
+ clliData[&KisRelativeContentLightLevelInformation::maxFrameAverageLightLevel],
+ lager::with_setter(LAGER_QT(effectiveReferenceWhite), noopSetter)
+ ).zoom(calcRelativeToAbsoluteWhiteLevel)}
+
+ , LAGER_QT(clliCalculationType){clliData[&KisRelativeContentLightLevelInformation::type]}
+ , LAGER_QT(clliCalculationTypeState){lager::with(LAGER_QT(clliCalculationType), LAGER_QT(effectiveClliPresent))
+ .map(&calcTypeComboBoxState)}
+
+ , LAGER_QT(cviPresent){cviPresentData}
+
+ , LAGER_QT(cviEffectivePresetIndex){cviData.zoom(effectivePresetIndexForCvi)}
+ , LAGER_QT(cviEffectivePresetIndexState){
+ lager::with(
+ LAGER_QT(cviEffectivePresetIndex),
+ /// we should explicitly pass the "enabled" value,
+ /// since modification of the "state" of the widget
+ /// overrides the value set by QGroupBox
+ LAGER_QT(cviPresent)
+ ).map(&calcCviEffectivePresetIndexState)}
+
+ , LAGER_QT(cviWhiteX){cviData[&KisColorVolumeInformation::white][&KoColorimetryUtils::xy::x]}
+ , LAGER_QT(cviWhiteY){cviData[&KisColorVolumeInformation::white][&KoColorimetryUtils::xy::y]}
+ , LAGER_QT(cviRedX){cviData[&KisColorVolumeInformation::red][&KoColorimetryUtils::xy::x]}
+ , LAGER_QT(cviRedY){cviData[&KisColorVolumeInformation::red][&KoColorimetryUtils::xy::y]}
+ , LAGER_QT(cviGreenX){cviData[&KisColorVolumeInformation::green][&KoColorimetryUtils::xy::x]}
+ , LAGER_QT(cviGreenY){cviData[&KisColorVolumeInformation::green][&KoColorimetryUtils::xy::y]}
+ , LAGER_QT(cviBlueX){cviData[&KisColorVolumeInformation::blue][&KoColorimetryUtils::xy::x]}
+ , LAGER_QT(cviBlueY){cviData[&KisColorVolumeInformation::blue][&KoColorimetryUtils::xy::y]}
, LAGER_QT(cviMaxLuminance){cviData[&KisColorVolumeInformation::maxLuminance]}
- , LAGER_QT(cviMaxLuminanceState){lager::with(LAGER_QT(cviMaxLuminance),
- lager::make_constant(0.0),
- lager::make_constant(10000.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
, LAGER_QT(cviMinLuminance){cviData[&KisColorVolumeInformation::minLuminance]}
- , LAGER_QT(cviMinLuminanceState){lager::with(LAGER_QT(cviMinLuminance),
- lager::make_constant(0.0),
- lager::make_constant(10000.0),
- LAGER_QT(cviChecked)).map(ToSpinBoxState{})}
-
{
-
}
KisHDRMetadataModel::~KisHDRMetadataModel() {
@@ -197,16 +215,16 @@ KisHDRMetadataModel::~KisHDRMetadataModel() {
void KisHDRMetadataModel::setClli(const std::optional<KisRelativeContentLightLevelInformation> &clli)
{
if (clli) {
- clliCheckedData.set(true);
+ clliPresentData.set(true);
clliData.set(*clli);
} else {
- clliCheckedData.set(false);
+ clliPresentData.set(false);
}
}
std::optional<KisRelativeContentLightLevelInformation> KisHDRMetadataModel::clli() const
{
- const bool enabled = clliCheckedData.get();
+ const bool enabled = clliPresentData.get();
if (enabled) {
return std::make_optional(clliData.get());
}
@@ -216,47 +234,49 @@ std::optional<KisRelativeContentLightLevelInformation> KisHDRMetadataModel::clli
void KisHDRMetadataModel::setCvi(const std::optional<KisColorVolumeInformation> &cvi)
{
if (cvi) {
- cviCheckedData.set(true);
+ cviPresentData.set(true);
cviData.set(*cvi);
} else {
- cviCheckedData.set(false);
+ cviPresentData.set(false);
+ cviData.set(KisColorVolumeInformation{});
}
}
std::optional<KisColorVolumeInformation> KisHDRMetadataModel::cvi() const
{
- const bool enabled = cviCheckedData.get();
+ const bool enabled = cviPresentData.get();
if (enabled) {
return std::make_optional(cviData.get());
}
return std::nullopt;
}
-void KisHDRMetadataModel::setRefWhite(const std::optional<double> &refWhite)
+void KisHDRMetadataModel::setImageHdrReferenceWhiteMetadata(const std::optional<double> &refWhite)
{
if (refWhite) {
- referenceWhiteCheckedData.set(true);
+ referenceWhitePresentData.set(true);
referenceWhiteData.set(*refWhite);
} else {
- referenceWhiteCheckedData.set(false);
+ referenceWhitePresentData.set(false);
+ referenceWhiteData.set(203.0);
}
}
-std::optional<double> KisHDRMetadataModel::refWhite() const
+std::optional<double> KisHDRMetadataModel::imageHdrReferenceWhiteMetadata() const
{
- const bool enabled = referenceWhiteCheckedData.get();
- if (enabled) {
- return std::make_optional(referenceWhiteData.get());
+ if (referenceWhitePresentData.get() && imageProfileIsRelativeData.get()) {
+ return referenceWhiteData.get();
}
return std::nullopt;
}
-void KisHDRMetadataModel::setImageProfileRelative(const std::optional<double> &refWhite)
+void KisHDRMetadataModel::setImageProfileHdrReferenceWhite(const std::optional<double> &refWhite)
{
if (refWhite) {
- imageProfileRelativeData.set(false);
- referenceWhiteData.set(*refWhite);
+ imageProfileIsRelativeData.set(false);
+ imageProfileReferenceWhiteData.set(*refWhite);
} else {
- imageProfileRelativeData.set(true);
+ imageProfileIsRelativeData.set(true);
+ imageProfileReferenceWhiteData.set(203.0);
}
}
diff --git a/libs/image/kis_hdr_metadata_models.h b/libs/image/kis_hdr_metadata_models.h
index 1ac13312bb..bee4c9d7e7 100644
--- a/libs/image/kis_hdr_metadata_models.h
+++ b/libs/image/kis_hdr_metadata_models.h
@@ -26,60 +26,57 @@ public:
lager::cursor<KisRelativeContentLightLevelInformation> clliData;
lager::cursor<KisColorVolumeInformation> cviData;
+ lager::cursor<double> imageProfileReferenceWhiteData;
lager::cursor<double> referenceWhiteData;
- lager::cursor<bool> imageProfileRelativeData;
- lager::cursor<bool> referenceWhiteCheckedData;
- lager::cursor<bool> clliCheckedData;
- lager::cursor<bool> cviCheckedData;
-
- LAGER_QT_CURSOR(bool, refWhiteChecked);
- LAGER_QT_READER(bool, refWhiteEnabled);
- LAGER_QT_READER(CheckBoxState, refWhiteCheckedState);
+ lager::cursor<bool> imageProfileIsRelativeData;
+ lager::cursor<bool> referenceWhitePresentData;
+ lager::cursor<bool> clliPresentData;
+ lager::cursor<bool> cviPresentData;
+
+ LAGER_QT_CURSOR(bool, referenceWhitePresent);
+ LAGER_QT_READER(bool, effectiveReferenceWhitePresent);
+ LAGER_QT_READER(bool, effectiveReferenceWhiteEnabled);
+ LAGER_QT_READER(CheckBoxState, referenceWhitePresentState);
+
LAGER_QT_CURSOR(double, referenceWhite);
LAGER_QT_CURSOR(int, referenceWhiteIndex);
+ LAGER_QT_READER(double, effectiveReferenceWhite);
+ LAGER_QT_READER(int, effectiveReferenceWhiteIndex);
LAGER_QT_READER(ComboBoxState, referenceWhiteState);
- LAGER_QT_CURSOR(bool, clliChecked);
- LAGER_QT_READER(CheckBoxState, clliCheckedState);
+ LAGER_QT_CURSOR(bool, clliPresent);
+ LAGER_QT_READER(bool, effectiveClliPresent);
+ LAGER_QT_READER(CheckBoxState, clliPresentState);
+
LAGER_QT_CURSOR(double, maxContentLightLevel);
- LAGER_QT_READER(DoubleSpinBoxState, maxContentLightLevelState);
LAGER_QT_CURSOR(double, maxFrameAverageLightLevel);
- LAGER_QT_READER(DoubleSpinBoxState, maxFrameAverageLightLevelState);
LAGER_QT_CURSOR(KisRelativeContentLightLevelInformation::CalculationType, clliCalculationType);
LAGER_QT_READER(ComboBoxState, clliCalculationTypeState);
- LAGER_QT_CURSOR(bool, cviChecked);
- LAGER_QT_READER(CheckBoxState, cviCheckedState);
+ LAGER_QT_CURSOR(bool, cviPresent);
+
+ LAGER_QT_CURSOR(int, cviEffectivePresetIndex);
+ LAGER_QT_READER(ComboBoxState, cviEffectivePresetIndexState);
+
LAGER_QT_CURSOR(double, cviWhiteX);
LAGER_QT_CURSOR(double, cviWhiteY);
- LAGER_QT_READER(DoubleSpinBoxState, cviWhiteXState);
- LAGER_QT_READER(DoubleSpinBoxState, cviWhiteYState);
LAGER_QT_CURSOR(double, cviRedX);
LAGER_QT_CURSOR(double, cviRedY);
- LAGER_QT_READER(DoubleSpinBoxState, cviRedXState);
- LAGER_QT_READER(DoubleSpinBoxState, cviRedYState);
LAGER_QT_CURSOR(double, cviGreenX);
LAGER_QT_CURSOR(double, cviGreenY);
- LAGER_QT_READER(DoubleSpinBoxState, cviGreenXState);
- LAGER_QT_READER(DoubleSpinBoxState, cviGreenYState);
LAGER_QT_CURSOR(double, cviBlueX);
LAGER_QT_CURSOR(double, cviBlueY);
- LAGER_QT_READER(DoubleSpinBoxState, cviBlueXState);
- LAGER_QT_READER(DoubleSpinBoxState, cviBlueYState);
LAGER_QT_CURSOR(double, cviMaxLuminance);
- LAGER_QT_READER(DoubleSpinBoxState, cviMaxLuminanceState);
LAGER_QT_CURSOR(double, cviMinLuminance);
- LAGER_QT_READER(DoubleSpinBoxState, cviMinLuminanceState);
-
void setClli(const std::optional<KisRelativeContentLightLevelInformation> &clli);
std::optional<KisRelativeContentLightLevelInformation> clli() const;
void setCvi(const std::optional<KisColorVolumeInformation> &cvi);
std::optional<KisColorVolumeInformation> cvi() const;
- void setRefWhite(const std::optional<double> &refWhite);
- std::optional<double> refWhite() const;
- void setImageProfileRelative(const std::optional<double> &refWhite);
+ void setImageHdrReferenceWhiteMetadata(const std::optional<double> &refWhite);
+ std::optional<double> imageHdrReferenceWhiteMetadata() const;
+ void setImageProfileHdrReferenceWhite(const std::optional<double> &refWhite);
};
diff --git a/libs/image/kis_image.cc b/libs/image/kis_image.cc
index 67f2937004..a169da7999 100644
--- a/libs/image/kis_image.cc
+++ b/libs/image/kis_image.cc
@@ -2137,6 +2137,16 @@ void KisImage::setDiffuseWhiteLightLevel(const std::optional<double> cdm2)
}
}
+std::optional<double> KisImage::hdrReferenceWhiteLightLevelMetadata() const
+{
+ return m_d->diffuseWhiteLightLevel;
+}
+
+void KisImage::setHdrReferenceWhiteLightLevelMetadata(const std::optional<double> value)
+{
+ m_d->diffuseWhiteLightLevel = value;
+}
+
void KisImage::stopIsolatedMode()
{
if (!m_d->isolationRootNode) return;
diff --git a/libs/image/kis_image.h b/libs/image/kis_image.h
index 165d7e4476..96770d0cd7 100644
--- a/libs/image/kis_image.h
+++ b/libs/image/kis_image.h
@@ -835,6 +835,9 @@ public:
/// Set the diffuse white light level, in cd/m²
void setDiffuseWhiteLightLevel(const std::optional<double> cdm2);
+ std::optional<double> hdrReferenceWhiteLightLevelMetadata() const;
+ void setHdrReferenceWhiteLightLevelMetadata(const std::optional<double> value);
+
public Q_SLOTS:
void stopIsolatedMode();
diff --git a/libs/ui/dialogs/kis_dlg_image_properties.cc b/libs/ui/dialogs/kis_dlg_image_properties.cc
index 02117a7554..39c20dd0dd 100644
--- a/libs/ui/dialogs/kis_dlg_image_properties.cc
+++ b/libs/ui/dialogs/kis_dlg_image_properties.cc
@@ -137,30 +137,29 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageWSP image, KisDisplayColorC
connect(d->image, &KisImage::sigDiffuseWhiteLightLevelChanged, this, &KisDlgImageProperties::updateHDRDiffuseWhite);
connect(d->image, &KisImage::sigColorVolumeInformationChanged, this, &KisDlgImageProperties::updateHDRColorVolume);
- m_page->cmbColorVolumePresets->addItem(i18n("Rec. 2100 PQ"), "p2100-pq");
- m_page->cmbColorVolumePresets->addItem(i18n("DCI-P3 D65"), "dci-p3-d65");
+ KisWidgetConnectionUtils::connectControlState( m_page->cmbDiffuseWhite, &d->hdrMetadataModel, "referenceWhiteState", "referenceWhiteIndex");
- KisWidgetConnectionUtils::connectControlState( m_page->cmbDiffuseWhite, &d->hdrMetadataModel, "referenceWhiteState", "referenceWhite");
+ KisWidgetConnectionUtils::connectControlState( m_page->gbxDiffuseWhite, &d->hdrMetadataModel, "referenceWhitePresentState", "referenceWhitePresent");
- KisWidgetConnectionUtils::connectControlState( m_page->gbxDiffuseWhite, &d->hdrMetadataModel, "refWhiteCheckedState", "refWhiteChecked");
-
- KisWidgetConnectionUtils::connectControlState( m_page->gbxContentLightLevel, &d->hdrMetadataModel, "clliCheckedState", "clliChecked");
- KisWidgetConnectionUtils::connectControlState( m_page->spnMaxCll, &d->hdrMetadataModel, "maxContentLightLevelState", "maxContentLightLevel");
- KisWidgetConnectionUtils::connectControlState( m_page->spnMaxFall, &d->hdrMetadataModel, "maxFrameAverageLightLevelState", "maxFrameAverageLightLevel");
+ KisWidgetConnectionUtils::connectControlState( m_page->gbxContentLightLevel, &d->hdrMetadataModel, "clliPresentState", "clliPresent");
+ KisWidgetConnectionUtils::connectControl( m_page->spnMaxCll, &d->hdrMetadataModel, "maxContentLightLevel");
+ KisWidgetConnectionUtils::connectControl( m_page->spnMaxFall, &d->hdrMetadataModel, "maxFrameAverageLightLevel");
KisWidgetConnectionUtils::connectControlState( m_page->cmbLumiCalcType, &d->hdrMetadataModel, "clliCalculationTypeState", "clliCalculationType");
- KisWidgetConnectionUtils::connectControlState( m_page->gbxColorVolume, &d->hdrMetadataModel, "cviCheckedState", "cviChecked");
- KisWidgetConnectionUtils::connectControlState( m_page->spnWhiteX, &d->hdrMetadataModel, "cviWhiteXState", "cviWhiteX");
- KisWidgetConnectionUtils::connectControlState( m_page->spnWhiteY, &d->hdrMetadataModel, "cviWhiteYState", "cviWhiteY");
- KisWidgetConnectionUtils::connectControlState( m_page->spnRedX, &d->hdrMetadataModel, "cviRedXState", "cviRedX");
- KisWidgetConnectionUtils::connectControlState( m_page->spnRedY, &d->hdrMetadataModel, "cviRedYState", "cviRedY");
- KisWidgetConnectionUtils::connectControlState( m_page->spnGreenX, &d->hdrMetadataModel, "cviGreenXState", "cviGreenX");
- KisWidgetConnectionUtils::connectControlState( m_page->spnGreenY, &d->hdrMetadataModel, "cviGreenYState", "cviGreenY");
- KisWidgetConnectionUtils::connectControlState( m_page->spnBlueX, &d->hdrMetadataModel, "cviBlueXState", "cviBlueX");
- KisWidgetConnectionUtils::connectControlState( m_page->spnBlueY, &d->hdrMetadataModel, "cviBlueYState", "cviBlueY");
- KisWidgetConnectionUtils::connectControlState( m_page->spnMinLuminance, &d->hdrMetadataModel, "cviMinLuminanceState", "cviMinLuminance");
- KisWidgetConnectionUtils::connectControlState( m_page->spnMaxLuminance, &d->hdrMetadataModel, "cviMaxLuminanceState", "cviMaxLuminance");
- connect(m_page->btnApplyColorVolumePreset, &QPushButton::clicked, this, &KisDlgImageProperties::changeColorVolumePreset);
+ KisWidgetConnectionUtils::connectControl( m_page->gbxColorVolume, &d->hdrMetadataModel, "cviPresent");
+
+ KisWidgetConnectionUtils::connectControl( m_page->spnWhiteX, &d->hdrMetadataModel, "cviWhiteX");
+ KisWidgetConnectionUtils::connectControl( m_page->spnWhiteY, &d->hdrMetadataModel, "cviWhiteY");
+ KisWidgetConnectionUtils::connectControl( m_page->spnRedX, &d->hdrMetadataModel, "cviRedX");
+ KisWidgetConnectionUtils::connectControl( m_page->spnRedY, &d->hdrMetadataModel, "cviRedY");
+ KisWidgetConnectionUtils::connectControl( m_page->spnGreenX, &d->hdrMetadataModel, "cviGreenX");
+ KisWidgetConnectionUtils::connectControl( m_page->spnGreenY, &d->hdrMetadataModel, "cviGreenY");
+ KisWidgetConnectionUtils::connectControl( m_page->spnBlueX, &d->hdrMetadataModel, "cviBlueX");
+ KisWidgetConnectionUtils::connectControl( m_page->spnBlueY, &d->hdrMetadataModel, "cviBlueY");
+ KisWidgetConnectionUtils::connectControl( m_page->spnMinLuminance, &d->hdrMetadataModel, "cviMinLuminance");
+ KisWidgetConnectionUtils::connectControl( m_page->spnMaxLuminance, &d->hdrMetadataModel, "cviMaxLuminance");
+
+ KisWidgetConnectionUtils::connectControlState( m_page->cmbColorVolumePresets, &d->hdrMetadataModel, "cviEffectivePresetIndexState", "cviEffectivePresetIndex");
const bool hdr = (d->image->colorSpace()->hasHighDynamicRange()
|| d->image->colorSpace()->profile()->getTransferCharacteristics() == TRC_ITU_R_BT_2100_0_PQ);
@@ -259,8 +258,8 @@ void KisDlgImageProperties::updateDisplayConfigInfo()
void KisDlgImageProperties::updateHDRDiffuseWhite()
{
- d->hdrMetadataModel.setImageProfileRelative(d->image->colorSpace()->profile()->hdrReferenceWhite());
- d->hdrMetadataModel.setRefWhite(d->image->diffuseWhiteLightLevel());
+ d->hdrMetadataModel.setImageProfileHdrReferenceWhite(d->image->colorSpace()->profile()->hdrReferenceWhite());
+ d->hdrMetadataModel.setImageHdrReferenceWhiteMetadata(d->image->hdrReferenceWhiteLightLevelMetadata());
}
void KisDlgImageProperties::updateHDRLightLevels()
@@ -285,8 +284,8 @@ void KisDlgImageProperties::setHDRLightLevelsOnImage()
void KisDlgImageProperties::setHDRDiffuseWhiteOnImage()
{
- std::optional<double> dw = d->hdrMetadataModel.refWhite();
- if (d->image->diffuseWhiteLightLevel() != dw) {
+ std::optional<double> dw = d->hdrMetadataModel.imageHdrReferenceWhiteMetadata();
+ if (d->image->hdrReferenceWhiteLightLevelMetadata() != dw) {
KUndo2Command *cmd = new KisChangeImageHdrDiffuseWhiteCommand(d->image, dw);
d->image->undoAdapter()->addCommand(cmd);
}
@@ -301,47 +300,6 @@ void KisDlgImageProperties::setHDRColorVolumeOnImage()
}
}
-void KisDlgImageProperties::changeColorVolumePreset()
-{
- const QString displayId = m_page->cmbColorVolumePresets->currentData().toString();
-
- if (displayId == "p2100-pq") {
- m_page->spnRedX->setValue(0.708);
- m_page->spnRedY->setValue(0.292);
-
- m_page->spnGreenX->setValue(0.170);
- m_page->spnGreenY->setValue(0.797);
-
- m_page->spnBlueX->setValue(0.131);
- m_page->spnBlueY->setValue(0.046);
-
- m_page->spnWhiteX->setValue(0.3127);
- m_page->spnWhiteY->setValue(0.3290);
-
- m_page->spnMinLuminance->setValue(0.005);
- m_page->spnMaxLuminance->setValue(1000);
-
- } else if (displayId == "dci-p3-d65") {
-
- m_page->spnRedX->setValue(0.680);
- m_page->spnRedY->setValue(0.320);
-
- m_page->spnGreenX->setValue(0.265);
- m_page->spnGreenY->setValue(0.690);
-
- m_page->spnBlueX->setValue(0.150);
- m_page->spnBlueY->setValue(0.060);
-
- m_page->spnWhiteX->setValue(0.3127);
- m_page->spnWhiteY->setValue(0.3290);
-
- m_page->spnMinLuminance->setValue(0.005);
- m_page->spnMaxLuminance->setValue(1000);
-
- }
-}
-
-
void KisDlgImageProperties::slotCalculateLightLevels()
{
KisRelativeContentLightLevelInformation::CalculationType type = d->hdrMetadataModel.clliCalculationType();
diff --git a/libs/ui/dialogs/kis_dlg_image_properties.h b/libs/ui/dialogs/kis_dlg_image_properties.h
index 73dc23d20c..9b5aad855b 100644
--- a/libs/ui/dialogs/kis_dlg_image_properties.h
+++ b/libs/ui/dialogs/kis_dlg_image_properties.h
@@ -53,7 +53,6 @@ private Q_SLOTS:
void setHDRLightLevelsOnImage();
void setHDRColorVolumeOnImage();
- void changeColorVolumePreset();
void slotCalculateLightLevels();
void slotColorSpaceChanged(const KoColorSpace*);
diff --git a/libs/ui/forms/wdgimageproperties.ui b/libs/ui/forms/wdgimageproperties.ui
index 9a2f8140f0..02fbc56605 100644
--- a/libs/ui/forms/wdgimageproperties.ui
+++ b/libs/ui/forms/wdgimageproperties.ui
@@ -11,7 +11,7 @@
<x>0</x>
<y>0</y>
<width>449</width>
- <height>522</height>
+ <height>583</height>
</rect>
</property>
<property name="windowTitle">
@@ -410,77 +410,6 @@
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_2">
- <item row="2" column="0">
- <widget class="QLabel" name="label_12">
- <property name="text">
- <string>Maximum Luminance:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_13">
- <property name="text">
- <string>Minimum Luminance:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QDoubleSpinBox" name="spnMaxLuminance">
- <property name="suffix">
- <string>cd/m²</string>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="maximum">
- <double>10000.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.001000000000000</double>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QDoubleSpinBox" name="spnMinLuminance">
- <property name="suffix">
- <string>cd/m²</string>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="singleStep">
- <double>0.001000000000000</double>
- </property>
- </widget>
- </item>
- <item row="5" column="0" colspan="2">
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Preset:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="cmbColorVolumePresets">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnApplyColorVolumePreset">
- <property name="text">
- <string>Apply Preset</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
<item row="0" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="2">
@@ -631,6 +560,70 @@
</item>
</layout>
</item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_12">
+ <property name="text">
+ <string>Maximum Luminance:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDoubleSpinBox" name="spnMaxLuminance">
+ <property name="suffix">
+ <string>cd/m²</string>
+ </property>
+ <property name="decimals">
+ <number>4</number>
+ </property>
+ <property name="maximum">
+ <double>10000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.001000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_13">
+ <property name="text">
+ <string>Minimum Luminance:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QDoubleSpinBox" name="spnMinLuminance">
+ <property name="suffix">
+ <string>cd/m²</string>
+ </property>
+ <property name="decimals">
+ <number>4</number>
+ </property>
+ <property name="singleStep">
+ <double>0.001000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Preset:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cmbColorVolumePresets">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
@@ -683,9 +676,9 @@
</widget>
<customwidgets>
<customwidget>
- <class>KisColorSpaceSelector</class>
- <extends>QWidget</extends>
- <header>kis_color_space_selector.h</header>
+ <class>KisDoubleSliderSpinBox</class>
+ <extends>QDoubleSpinBox</extends>
+ <header location="global">kis_slider_spin_box.h</header>
<container>1</container>
</customwidget>
<customwidget>
@@ -694,9 +687,9 @@
<header>kis_color_button.h</header>
</customwidget>
<customwidget>
- <class>KisDoubleSliderSpinBox</class>
- <extends>QDoubleSpinBox</extends>
- <header location="global">kis_slider_spin_box.h</header>
+ <class>KisColorSpaceSelector</class>
+ <extends>QWidget</extends>
+ <header>widgets/kis_color_space_selector.h</header>
<container>1</container>
</customwidget>
<customwidget>
diff --git a/libs/widgets/KisWidgetConnectionUtils.cpp b/libs/widgets/KisWidgetConnectionUtils.cpp
index 28d4c8036f..b70b753cc7 100644
--- a/libs/widgets/KisWidgetConnectionUtils.cpp
+++ b/libs/widgets/KisWidgetConnectionUtils.cpp
@@ -162,6 +162,11 @@ void connectControl(QCheckBox *button, QObject *source, const char *property)
connectButtonLikeControl(button, source, property);
}
+void connectControl(QGroupBox *button, QObject *source, const char *property)
+{
+ connectButtonLikeControl(button, source, property);
+}
+
void connectControl(QSpinBox *spinBox, QObject *source, const char *property)
{
const QMetaObject* meta = source->metaObject();
diff --git a/libs/widgets/KisWidgetConnectionUtils.h b/libs/widgets/KisWidgetConnectionUtils.h
index b2113a7571..77c80a06bc 100644
--- a/libs/widgets/KisWidgetConnectionUtils.h
+++ b/libs/widgets/KisWidgetConnectionUtils.h
@@ -139,6 +139,7 @@ using DoubleSpinBoxState = SpinBoxState<qreal>;
void KRITAWIDGETS_EXPORT connectControl(QAbstractButton *button, QObject *source, const char *property);
void KRITAWIDGETS_EXPORT connectControl(QAction *button, QObject *source, const char *property);
void KRITAWIDGETS_EXPORT connectControl(QCheckBox *button, QObject *source, const char *property);
+void KRITAWIDGETS_EXPORT connectControl(QGroupBox *button, QObject *source, const char *property);
void KRITAWIDGETS_EXPORT connectControl(QSpinBox *spinBox, QObject *source, const char *property);
void KRITAWIDGETS_EXPORT connectControl(QSlider *slider, QObject *source, const char *property);
void KRITAWIDGETS_EXPORT connectControl(QDoubleSpinBox *spinBox, QObject *source, const char *property);