18#include <QApplication>
23#include <klocalizedstring.h>
57 const char * INTERNAL_RAW_PROFILE =
58 "ocio_profile_version: 1\n"
59 "strictparsing: false\n"
64 " - !<View> {name: Raw, colorspace: raw}\n"
72 " allocation: uniform\n"
73 " description: 'A raw color space. Conversions to and from this space are no-ops.'\n";
76 std::istringstream istream;
77 istream.str(INTERNAL_RAW_PROFILE);
78 return OCIO::Config::CreateFromStream(istream);
82 : QDockWidget(i18n(
"LUT Management"))
85 using namespace std::placeholders;
91 m_page =
new QWidget(
this);
96 m_chkUseOcio->setChecked(cfg.
useOcio());
100 m_bnSelectConfigurationFile->setToolTip(i18n(
"Select custom configuration file."));
105 m_txtLut->setText(ocioOptions.
lutPath);
107 m_bnSelectLut->setToolTip(i18n(
"Select LUT file"));
115 m_bnSelectLut->hide();
116 m_bnClearLut->hide();
120 m_exposureDoubleWidget->setToolTip(i18n(
"Select the exposure (stops) for HDR images."));
121 m_exposureDoubleWidget->setRange(-10.0, 10.0, 2);
122 m_exposureDoubleWidget->setValue(0.0);
123 m_exposureDoubleWidget->setSingleStep(0.25);
125 connect(m_exposureDoubleWidget, QOverload<double>::of(&KisDoubleSliderSpinBox::valueChanged),
130 m_gammaDoubleWidget->setToolTip(i18n(
"Select the amount of gamma modification for display. This does not affect the pixels of your image."));
131 m_gammaDoubleWidget->setRange(0.1, 5.0, 2);
132 m_gammaDoubleWidget->setValue(1.0);
133 m_gammaDoubleWidget->setSingleStep(0.1);
135 connect(m_gammaDoubleWidget, QOverload<double>::of(&KisDoubleSliderSpinBox::valueChanged),
168 setEnabled(_canvas != 0);
180 Q_ASSERT(displayFilter);
183 m_exposureDoubleWidget->setValue(displayFilter->
exposure);
185 m_gammaDoubleWidget->setValue(displayFilter->
gamma);
187 m_cmbComponents->setCurrentIndex((
int)displayFilter->
swizzle);
212 m_lblOcioVersion->setWordWrap(
true);
213 m_lblOcioVersion->setEnabled(
false);
223 if (!m_chkUseOcio->isChecked() || !
m_ocioConfig)
return false;
225 const bool externalColorManagementEnabled =
235 const bool exposureManagementEnabled =
236 externalColorManagementEnabled
242 return exposureManagementEnabled;
255 m_exposureDoubleWidget->setValue(
value);
257 m_canvas->viewManager()->showFloatingMessage(
258 i18nc(
"floating message about exposure",
"Exposure: %1",
274 m_gammaDoubleWidget->setValue(
value);
276 m_canvas->viewManager()->showFloatingMessage(
277 i18nc(
"floating message about gamma",
"Gamma: %1",
293 m_canvas->viewManager()->canvasResourceProvider()->setHDRExposure(exposure);
301 m_canvas->viewManager()->canvasResourceProvider()->setHDRGamma(gamma);
308 bool canDoExternalColorCorrection =
false;
312 canDoExternalColorCorrection =
316 if (!canDoExternalColorCorrection) {
318 Q_UNUSED(colorManagementBlocker);
322 const bool ocioEnabled = m_chkUseOcio->isChecked();
323 m_colorManagement->setEnabled(ocioEnabled && canDoExternalColorCorrection);
325 const bool externalColorManagementEnabled =
328 m_lblInputColorSpace->setEnabled(ocioEnabled && externalColorManagementEnabled);
329 m_cmbInputColorSpace->setEnabled(ocioEnabled && externalColorManagementEnabled);
330 m_lblDisplayDevice->setEnabled(ocioEnabled && externalColorManagementEnabled);
331 m_cmbDisplayDevice->setEnabled(ocioEnabled && externalColorManagementEnabled);
332 m_lblView->setEnabled(ocioEnabled && externalColorManagementEnabled);
333 m_cmbView->setEnabled(ocioEnabled && externalColorManagementEnabled);
334 m_lblLook->setEnabled(ocioEnabled && externalColorManagementEnabled);
335 m_cmbLook->setEnabled(ocioEnabled && externalColorManagementEnabled);
339 m_exposureDoubleWidget->setEnabled(exposureManagementEnabled);
340 m_gammaDoubleWidget->setEnabled(exposureManagementEnabled);
341 m_lblExposure->setEnabled(exposureManagementEnabled);
342 m_lblGamma->setEnabled(exposureManagementEnabled);
344 QString exposureToolTip;
346 if (!exposureManagementEnabled) {
347 exposureToolTip = i18nc(
"@info:tooltip",
"Exposure and Gamma corrections are disabled in Internal mode. Switch to OCIO mode to use them");
349 m_exposureDoubleWidget->setToolTip(exposureToolTip);
350 m_gammaDoubleWidget->setToolTip(exposureToolTip);
351 m_lblExposure->setToolTip(exposureToolTip);
352 m_lblGamma->setToolTip(exposureToolTip);
356 lblConfig->setEnabled(ocioEnabled && enableConfigPath);
357 m_txtConfigurationPath->setEnabled(ocioEnabled && enableConfigPath);
358 m_bnSelectConfigurationFile->setEnabled(ocioEnabled && enableConfigPath);
386 displayFilter->
look =
m_ocioConfig->getLookNameByIndex(m_cmbLook->currentIndex());
387 displayFilter->
gamma = m_gammaDoubleWidget->isEnabled() ? m_gammaDoubleWidget->value() : 1.0;
388 displayFilter->
exposure = m_exposureDoubleWidget->isEnabled() ? m_exposureDoubleWidget->value() : 0.0;
413 ocioOptions.
lutPath = m_txtLut->text();
414 ocioOptions.
inputColorSpace = m_cmbInputColorSpace->currentUnsqueezedText();
415 ocioOptions.
displayDevice = m_cmbDisplayDevice->currentUnsqueezedText();
416 ocioOptions.
displayView = m_cmbView->currentUnsqueezedText();
417 ocioOptions.
look = m_cmbLook->currentUnsqueezedText();
434 QString filename = m_txtConfigurationPath->text();
437 dialog.setCaption(i18n(
"Select OpenColorIO Configuration"));
438 dialog.setDefaultDir(QDir::cleanPath(filename.isEmpty() ? QDir::homePath() : filename));
439 dialog.setMimeTypeFilters(
QStringList() <<
"application/x-opencolorio-configuration");
440 filename = dialog.filename();
443 m_txtConfigurationPath->setText(filename);
464 if (QFile::exists(configFile)) {
465 m_ocioConfig = OCIO::Config::CreateFromFile(configFile.toUtf8());
473 }
catch (OCIO::Exception &exception) {
474 errKrita <<
"OpenColorIO Error:" << exception.what() <<
"Cannot create the LUT docker";
486 if (!
m_canvas->viewManager())
return;
487 if (!
m_canvas->viewManager()->canvasResourceProvider())
return;
488 if (!
m_canvas->viewManager()->image())
return;
497 m_colorManagement->setCurrentIndex((
int) ocioOptions.
mode);
502 m_exposureDoubleWidget->setValue(
m_canvas->viewManager()->canvasResourceProvider()->HDRExposure());
507 m_gammaDoubleWidget->setValue(
m_canvas->viewManager()->canvasResourceProvider()->HDRGamma());
514 itemsList << i18n(
"Luminance");
515 itemsList << i18n(
"All Channels");
517 itemsList << channel->
name();
520 if (m_cmbComponents->originalTexts() != itemsList) {
522 m_cmbComponents->resetOriginalTexts(itemsList);
523 m_cmbComponents->setCurrentIndex(1);
529 int numOcioColorSpaces =
m_ocioConfig->getNumColorSpaces();
530 for(
int i = 0; i < numOcioColorSpaces; ++i) {
531 const char *cs =
m_ocioConfig->getColorSpaceNameByIndex(i);
532 OCIO::ConstColorSpaceRcPtr colorSpace =
m_ocioConfig->getColorSpace(cs);
533 itemsList << QString::fromUtf8(colorSpace->getName());
538 if (itemsList != m_cmbInputColorSpace->originalTexts()) {
539 m_cmbInputColorSpace->resetOriginalTexts(itemsList);
548 for (
int i = 0; i < numDisplays; ++i) {
549 itemsList << QString::fromUtf8(
m_ocioConfig->getDisplay(i));
554 if (itemsList != m_cmbDisplayDevice->originalTexts()) {
555 m_cmbDisplayDevice->resetOriginalTexts(itemsList);
571 for (
int k = 0; k < numLooks; k++) {
572 itemsList << QString::fromUtf8(
m_ocioConfig->getLookNameByIndex(k));
574 itemsList << i18nc(
"Item to indicate no look transform being selected",
"None");
578 if (itemsList != m_cmbLook->originalTexts()) {
579 m_cmbLook->resetOriginalTexts(itemsList);
582 m_cmbLook->setCurrent(ocioOptions.
look);
594 const char *display =
m_ocioConfig->getDisplay(m_cmbDisplayDevice->currentIndex());
597 for (
int j = 0; j < numViews; ++j) {
598 m_cmbView->addSqueezedItem(QString::fromUtf8(
m_ocioConfig->getView(display, j)));
608 QString filename = m_txtLut->text();
611 dialog.setCaption(i18n(
"Select LUT file"));
612 dialog.setDefaultDir(QDir::cleanPath(filename));
613 dialog.setMimeTypeFilters(
QStringList() <<
"application/octet-stream",
"application/octet-stream");
614 filename = dialog.filename();
617 if (f.exists() && filename != m_txtLut->text()) {
618 m_txtLut->setText(filename);
float value(const T *src, size_t ch)
QList< QString > QStringList
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void showPopup(const QPoint &basePoint)
void setWhitePoint(qreal wp)
void setBlackPoint(qreal bp)
static KisConfigNotifier * instance()
bool useOcio(bool defaultValue=false) const
KisOcioConfiguration ocioConfiguration(bool defaultValue=false) const
void setOcioConfiguration(const KisOcioConfiguration &cfg)
void setUseOcio(bool useOCIO) const
void setOcioLockColorVisualRepresentation(bool value)
bool ocioLockColorVisualRepresentation(bool defaultValue=false) const
const KoColorSpace * colorSpace() const
QString configurationPath
static KisOpenGLModeProber * instance()
static QString currentDriver()
static KisSurfaceColorSpaceWrapper fromQtColorSpace(const QColorSpace &colorSpace)
static QList< KoChannelInfo * > displayOrderSorted(const QList< KoChannelInfo * > &channels)
QList< KoChannelInfo * > channels
virtual KoID colorModelId() const =0
void unsetCanvas() override
void setCurrentExposure(qreal value) override
OCIO::ConstConfigRcPtr m_ocioConfig
~LutDockerDock() override
void exposureValueChanged(double exposure)
void resetOcioConfiguration()
qreal currentExposure() const override
BlackWhitePointChooser * m_bwPointChooser
QPointer< KisCanvas2 > m_canvas
void setCurrentGamma(qreal value) override
QScopedPointer< KisSignalCompressorWithParam< qreal > > m_exposureCompressor
void updateDisplaySettings()
QScopedPointer< KisSignalCompressorWithParam< qreal > > m_gammaCompressor
void setCanvas(KoCanvasBase *canvas) override
reimplemented from KoCanvasObserverBase
QSharedPointer< KisDisplayFilter > m_displayFilter
void slotImageColorSpaceChanged()
qreal currentGamma() const override
void refillViewCombobox()
void selectOcioConfiguration()
bool canChangeExposureAndGamma() const override
void slotShowBWConfiguration()
void gammaValueChanged(double exposure)
void slotColorManagementModeChanged()
OCIO::ConstConfigRcPtr config
const char * displayDevice
const char * inputColorSpaceName
OCIO_CHANNEL_SWIZZLE swizzle
bool forceInternalColorManagement
void setLockCurrentColorVisualRepresentation(bool value)
#define KIS_ASSERT_RECOVER_RETURN(cond)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
OCIO::ConstConfigRcPtr defaultRawProfile()
#define OCIO_VERSION_FULL_STR
QIcon loadIcon(const QString &name)
QString KRITAIMAGE_EXPORT prettyFormatReal(qreal value)