Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/lut/lutdocker_dock.cpp
Context not available. | |||||
17 | */ | 17 | */ | ||
---|---|---|---|---|---|
18 | 18 | | |||
19 | #include "lutdocker_dock.h" | 19 | #include "lutdocker_dock.h" | ||
20 | #include <config-hdr.h> | ||||
20 | 21 | | |||
21 | #include <sstream> | 22 | #include <sstream> | ||
22 | 23 | | |||
Context not available. | |||||
56 | 57 | | |||
57 | #include "ocio_display_filter.h" | 58 | #include "ocio_display_filter.h" | ||
58 | #include "black_white_point_chooser.h" | 59 | #include "black_white_point_chooser.h" | ||
60 | #include "KisOcioConfiguration.h" | ||||
61 | #include <opengl/KisOpenGLModeProber.h> | ||||
59 | 62 | | |||
60 | 63 | | |||
61 | OCIO::ConstConfigRcPtr defaultRawProfile() | 64 | OCIO::ConstConfigRcPtr defaultRawProfile() | ||
Context not available. | |||||
107 | connect(m_chkUseOcio, SIGNAL(toggled(bool)), SLOT(updateDisplaySettings())); | 110 | connect(m_chkUseOcio, SIGNAL(toggled(bool)), SLOT(updateDisplaySettings())); | ||
108 | connect(m_colorManagement, SIGNAL(currentIndexChanged(int)), SLOT(slotColorManagementModeChanged())); | 111 | connect(m_colorManagement, SIGNAL(currentIndexChanged(int)), SLOT(slotColorManagementModeChanged())); | ||
109 | 112 | | |||
110 | m_txtConfigurationPath->setText(cfg.ocioConfigurationPath()); | | |||
111 | | ||||
112 | m_bnSelectConfigurationFile->setToolTip(i18n("Select custom configuration file.")); | 113 | m_bnSelectConfigurationFile->setToolTip(i18n("Select custom configuration file.")); | ||
113 | connect(m_bnSelectConfigurationFile,SIGNAL(clicked()), SLOT(selectOcioConfiguration())); | 114 | connect(m_bnSelectConfigurationFile,SIGNAL(clicked()), SLOT(selectOcioConfiguration())); | ||
114 | 115 | | |||
115 | m_txtLut->setText(cfg.ocioLutPath()); | 116 | KisOcioConfiguration ocioOptions = cfg.ocioConfiguration(); | ||
117 | m_txtConfigurationPath->setText(ocioOptions.configurationPath); | ||||
118 | m_txtLut->setText(ocioOptions.lutPath); | ||||
116 | 119 | | |||
117 | m_bnSelectLut->setToolTip(i18n("Select LUT file")); | 120 | m_bnSelectLut->setToolTip(i18n("Select LUT file")); | ||
118 | connect(m_bnSelectLut, SIGNAL(clicked()), SLOT(selectLut())); | 121 | connect(m_bnSelectLut, SIGNAL(clicked()), SLOT(selectLut())); | ||
Context not available. | |||||
235 | 238 | | |||
236 | bool LutDockerDock::canChangeExposureAndGamma() const | 239 | bool LutDockerDock::canChangeExposureAndGamma() const | ||
237 | { | 240 | { | ||
238 | return m_chkUseOcio->isChecked() && m_ocioConfig; | 241 | if (!m_chkUseOcio->isChecked() || !m_ocioConfig) return false; | ||
242 | | ||||
243 | const bool externalColorManagementEnabled = | ||||
244 | m_colorManagement->currentIndex() != (int)KisOcioConfiguration::INTERNAL; | ||||
245 | | ||||
246 | const bool exposureManagementEnabled = | ||||
247 | externalColorManagementEnabled | ||||
248 | #ifdef HAVE_HDR | ||||
249 | || KisOpenGLModeProber::instance()->surfaceformatInUse().colorSpace() == QSurfaceFormat::scRGBColorSpace | ||||
250 | #endif | ||||
251 | ; | ||||
252 | | ||||
253 | return exposureManagementEnabled; | ||||
239 | } | 254 | } | ||
240 | 255 | | |||
241 | qreal LutDockerDock::currentExposure() const | 256 | qreal LutDockerDock::currentExposure() const | ||
Context not available. | |||||
345 | if (!canDoExternalColorCorrection) { | 360 | if (!canDoExternalColorCorrection) { | ||
346 | KisSignalsBlocker colorManagementBlocker(m_colorManagement); | 361 | KisSignalsBlocker colorManagementBlocker(m_colorManagement); | ||
347 | Q_UNUSED(colorManagementBlocker); | 362 | Q_UNUSED(colorManagementBlocker); | ||
348 | m_colorManagement->setCurrentIndex((int) KisConfig::INTERNAL); | 363 | m_colorManagement->setCurrentIndex((int) KisOcioConfiguration::INTERNAL); | ||
349 | } | 364 | } | ||
350 | 365 | | |||
351 | bool ocioEnabled = m_chkUseOcio->isChecked(); | 366 | const bool ocioEnabled = m_chkUseOcio->isChecked(); | ||
352 | m_colorManagement->setEnabled(ocioEnabled && canDoExternalColorCorrection); | 367 | m_colorManagement->setEnabled(ocioEnabled && canDoExternalColorCorrection); | ||
353 | 368 | | |||
354 | bool externalColorManagementEnabled = | 369 | const bool externalColorManagementEnabled = | ||
355 | m_colorManagement->currentIndex() != (int)KisConfig::INTERNAL; | 370 | m_colorManagement->currentIndex() != (int)KisOcioConfiguration::INTERNAL; | ||
356 | 371 | | |||
357 | m_lblInputColorSpace->setEnabled(ocioEnabled && externalColorManagementEnabled); | 372 | m_lblInputColorSpace->setEnabled(ocioEnabled && externalColorManagementEnabled); | ||
358 | m_cmbInputColorSpace->setEnabled(ocioEnabled && externalColorManagementEnabled); | 373 | m_cmbInputColorSpace->setEnabled(ocioEnabled && externalColorManagementEnabled); | ||
Context not available. | |||||
363 | m_lblLook->setEnabled(ocioEnabled && externalColorManagementEnabled); | 378 | m_lblLook->setEnabled(ocioEnabled && externalColorManagementEnabled); | ||
364 | m_cmbLook->setEnabled(ocioEnabled && externalColorManagementEnabled); | 379 | m_cmbLook->setEnabled(ocioEnabled && externalColorManagementEnabled); | ||
365 | 380 | | |||
366 | bool enableConfigPath = m_colorManagement->currentIndex() == (int) KisConfig::OCIO_CONFIG; | 381 | const bool exposureManagementEnabled = canChangeExposureAndGamma(); | ||
382 | | ||||
383 | m_exposureDoubleWidget->setEnabled(exposureManagementEnabled); | ||||
384 | m_gammaDoubleWidget->setEnabled(exposureManagementEnabled); | ||||
385 | m_lblExposure->setEnabled(exposureManagementEnabled); | ||||
386 | m_lblGamma->setEnabled(exposureManagementEnabled); | ||||
387 | | ||||
388 | QString exposureToolTip; | ||||
389 | | ||||
390 | if (!exposureManagementEnabled) { | ||||
391 | exposureToolTip = i18nc("@info:tooltip", "Exposure and Gamma corrections are disabled in Internal mode. Switch to OCIO mode to use them"); | ||||
392 | } | ||||
393 | m_exposureDoubleWidget->setToolTip(exposureToolTip); | ||||
394 | m_gammaDoubleWidget->setToolTip(exposureToolTip); | ||||
395 | m_lblExposure->setToolTip(exposureToolTip); | ||||
396 | m_lblGamma->setToolTip(exposureToolTip); | ||||
397 | | ||||
398 | bool enableConfigPath = m_colorManagement->currentIndex() == (int) KisOcioConfiguration::OCIO_CONFIG; | ||||
367 | 399 | | |||
368 | lblConfig->setEnabled(ocioEnabled && enableConfigPath); | 400 | lblConfig->setEnabled(ocioEnabled && enableConfigPath); | ||
369 | m_txtConfigurationPath->setEnabled(ocioEnabled && enableConfigPath); | 401 | m_txtConfigurationPath->setEnabled(ocioEnabled && enableConfigPath); | ||
Context not available. | |||||
396 | displayFilter->displayDevice = m_ocioConfig->getDisplay(m_cmbDisplayDevice->currentIndex()); | 428 | displayFilter->displayDevice = m_ocioConfig->getDisplay(m_cmbDisplayDevice->currentIndex()); | ||
397 | displayFilter->view = m_ocioConfig->getView(displayFilter->displayDevice, m_cmbView->currentIndex()); | 429 | displayFilter->view = m_ocioConfig->getView(displayFilter->displayDevice, m_cmbView->currentIndex()); | ||
398 | displayFilter->look = m_ocioConfig->getLookNameByIndex(m_cmbLook->currentIndex()); | 430 | displayFilter->look = m_ocioConfig->getLookNameByIndex(m_cmbLook->currentIndex()); | ||
399 | displayFilter->gamma = m_gammaDoubleWidget->value(); | 431 | displayFilter->gamma = m_gammaDoubleWidget->isEnabled() ? m_gammaDoubleWidget->value() : 1.0; | ||
400 | displayFilter->exposure = m_exposureDoubleWidget->value(); | 432 | displayFilter->exposure = m_exposureDoubleWidget->isEnabled() ? m_exposureDoubleWidget->value() : 0.0; | ||
401 | displayFilter->swizzle = (OCIO_CHANNEL_SWIZZLE)m_cmbComponents->currentIndex(); | 433 | displayFilter->swizzle = (OCIO_CHANNEL_SWIZZLE)m_cmbComponents->currentIndex(); | ||
402 | 434 | | |||
403 | displayFilter->blackPoint = m_bwPointChooser->blackPoint(); | 435 | displayFilter->blackPoint = m_bwPointChooser->blackPoint(); | ||
404 | displayFilter->whitePoint = m_bwPointChooser->whitePoint(); | 436 | displayFilter->whitePoint = m_bwPointChooser->whitePoint(); | ||
405 | 437 | | |||
406 | displayFilter->forceInternalColorManagement = | 438 | displayFilter->forceInternalColorManagement = | ||
407 | m_colorManagement->currentIndex() == (int)KisConfig::INTERNAL; | 439 | m_colorManagement->currentIndex() == (int)KisOcioConfiguration::INTERNAL; | ||
408 | 440 | | |||
409 | displayFilter->setLockCurrentColorVisualRepresentation(m_btnConvertCurrentColor->isChecked()); | 441 | displayFilter->setLockCurrentColorVisualRepresentation(m_btnConvertCurrentColor->isChecked()); | ||
410 | 442 | | |||
Context not available. | |||||
419 | 451 | | |||
420 | void LutDockerDock::writeControls() | 452 | void LutDockerDock::writeControls() | ||
421 | { | 453 | { | ||
422 | KisConfig cfg(true); | 454 | KisOcioConfiguration ocioOptions; | ||
423 | 455 | ocioOptions.mode = (KisOcioConfiguration::Mode)m_colorManagement->currentIndex(); | |||
456 | ocioOptions.configurationPath = m_txtConfigurationPath->text(); | ||||
457 | ocioOptions.lutPath = m_txtLut->text(); | ||||
458 | ocioOptions.inputColorSpace = m_cmbInputColorSpace->itemHighlighted(); | ||||
459 | ocioOptions.displayDevice = m_cmbDisplayDevice->itemHighlighted(); | ||||
460 | ocioOptions.displayView = m_cmbView->itemHighlighted(); | ||||
461 | ocioOptions.look = m_cmbLook->itemHighlighted(); | ||||
462 | | ||||
463 | KisConfig cfg(false); | ||||
424 | cfg.setUseOcio(m_chkUseOcio->isChecked()); | 464 | cfg.setUseOcio(m_chkUseOcio->isChecked()); | ||
425 | cfg.setOcioColorManagementMode((KisConfig::OcioColorManagementMode) m_colorManagement->currentIndex()); | 465 | cfg.setOcioConfiguration(ocioOptions); | ||
426 | cfg.setOcioLockColorVisualRepresentation(m_btnConvertCurrentColor->isChecked()); | 466 | cfg.setOcioLockColorVisualRepresentation(m_btnConvertCurrentColor->isChecked()); | ||
427 | } | 467 | } | ||
428 | 468 | | |||
Context not available. | |||||
445 | QFile f(filename); | 485 | QFile f(filename); | ||
446 | if (f.exists()) { | 486 | if (f.exists()) { | ||
447 | m_txtConfigurationPath->setText(filename); | 487 | m_txtConfigurationPath->setText(filename); | ||
448 | KisConfig cfg(false); | | |||
449 | cfg.setOcioConfigurationPath(filename); | | |||
450 | writeControls(); | 488 | writeControls(); | ||
451 | resetOcioConfiguration(); | 489 | resetOcioConfiguration(); | ||
452 | } | 490 | } | ||
Context not available. | |||||
455 | void LutDockerDock::resetOcioConfiguration() | 493 | void LutDockerDock::resetOcioConfiguration() | ||
456 | { | 494 | { | ||
457 | KisConfig cfg(true); | 495 | KisConfig cfg(true); | ||
496 | KisOcioConfiguration ocioOptions = cfg.ocioConfiguration(); | ||||
458 | m_ocioConfig.reset(); | 497 | m_ocioConfig.reset(); | ||
459 | 498 | | |||
460 | try { | 499 | try { | ||
461 | if (cfg.ocioColorManagementMode() == KisConfig::INTERNAL) { | 500 | if (ocioOptions.mode == KisOcioConfiguration::INTERNAL) { | ||
462 | m_ocioConfig = defaultRawProfile(); | 501 | m_ocioConfig = defaultRawProfile(); | ||
463 | } else if (cfg.ocioColorManagementMode() == KisConfig::OCIO_ENVIRONMENT) { | 502 | } else if (ocioOptions.mode == KisOcioConfiguration::OCIO_ENVIRONMENT) { | ||
464 | m_ocioConfig = OCIO::Config::CreateFromEnv(); | 503 | m_ocioConfig = OCIO::Config::CreateFromEnv(); | ||
465 | } | 504 | } | ||
466 | else if (cfg.ocioColorManagementMode() == KisConfig::OCIO_CONFIG) { | 505 | else if (ocioOptions.mode == KisOcioConfiguration::OCIO_CONFIG) { | ||
467 | QString configFile = cfg.ocioConfigurationPath(); | 506 | QString configFile = ocioOptions.configurationPath; | ||
468 | 507 | | |||
469 | if (QFile::exists(configFile)) { | 508 | if (QFile::exists(configFile)) { | ||
470 | m_ocioConfig = OCIO::Config::CreateFromFile(configFile.toUtf8()); | 509 | m_ocioConfig = OCIO::Config::CreateFromFile(configFile.toUtf8()); | ||
Context not available. | |||||
495 | 534 | | |||
496 | KIS_ASSERT_RECOVER_RETURN(m_ocioConfig); | 535 | KIS_ASSERT_RECOVER_RETURN(m_ocioConfig); | ||
497 | 536 | | |||
537 | KisConfig cfg(true); | ||||
538 | KisOcioConfiguration ocioOptions = cfg.ocioConfiguration(); | ||||
539 | | ||||
498 | { // Color Management Mode | 540 | { // Color Management Mode | ||
499 | KisConfig cfg(true); | | |||
500 | KisSignalsBlocker modeBlocker(m_colorManagement); | 541 | KisSignalsBlocker modeBlocker(m_colorManagement); | ||
501 | m_colorManagement->setCurrentIndex((int) cfg.ocioColorManagementMode()); | 542 | m_colorManagement->setCurrentIndex((int) ocioOptions.mode); | ||
502 | } | 543 | } | ||
503 | 544 | | |||
504 | { // Exposure | 545 | { // Exposure | ||
Context not available. | |||||
537 | itemsList << QString::fromUtf8(colorSpace->getName()); | 578 | itemsList << QString::fromUtf8(colorSpace->getName()); | ||
538 | } | 579 | } | ||
539 | 580 | | |||
581 | KisSignalsBlocker inputCSBlocker(m_cmbInputColorSpace); | ||||
582 | | ||||
540 | if (itemsList != m_cmbInputColorSpace->originalTexts()) { | 583 | if (itemsList != m_cmbInputColorSpace->originalTexts()) { | ||
541 | KisSignalsBlocker inputCSBlocker(m_cmbInputColorSpace); | | |||
542 | m_cmbInputColorSpace->resetOriginalTexts(itemsList); | 584 | m_cmbInputColorSpace->resetOriginalTexts(itemsList); | ||
543 | } | 585 | } | ||
586 | | ||||
587 | m_cmbInputColorSpace->setCurrent(ocioOptions.inputColorSpace); | ||||
544 | } | 588 | } | ||
545 | 589 | | |||
546 | { // Display Device | 590 | { // Display Device | ||
Context not available. | |||||
550 | itemsList << QString::fromUtf8(m_ocioConfig->getDisplay(i)); | 594 | itemsList << QString::fromUtf8(m_ocioConfig->getDisplay(i)); | ||
551 | } | 595 | } | ||
552 | 596 | | |||
597 | KisSignalsBlocker displayDeviceLocker(m_cmbDisplayDevice); | ||||
598 | | ||||
553 | if (itemsList != m_cmbDisplayDevice->originalTexts()) { | 599 | if (itemsList != m_cmbDisplayDevice->originalTexts()) { | ||
554 | KisSignalsBlocker displayDeviceLocker(m_cmbDisplayDevice); | | |||
555 | m_cmbDisplayDevice->resetOriginalTexts(itemsList); | 600 | m_cmbDisplayDevice->resetOriginalTexts(itemsList); | ||
556 | } | 601 | } | ||
602 | | ||||
603 | m_cmbDisplayDevice->setCurrent(ocioOptions.displayDevice); | ||||
557 | } | 604 | } | ||
558 | 605 | | |||
559 | { // Lock Current Color | 606 | { // Lock Current Color | ||
560 | KisSignalsBlocker locker(m_btnConvertCurrentColor); | 607 | KisSignalsBlocker locker(m_btnConvertCurrentColor); | ||
561 | KisConfig cfg(true); | | |||
562 | m_btnConvertCurrentColor->setChecked(cfg.ocioLockColorVisualRepresentation()); | 608 | m_btnConvertCurrentColor->setChecked(cfg.ocioLockColorVisualRepresentation()); | ||
563 | } | 609 | } | ||
564 | 610 | | |||
Context not available. | |||||
572 | } | 618 | } | ||
573 | itemsList << i18nc("Item to indicate no look transform being selected","None"); | 619 | itemsList << i18nc("Item to indicate no look transform being selected","None"); | ||
574 | 620 | | |||
621 | KisSignalsBlocker LookComboLocker(m_cmbLook); | ||||
622 | | ||||
575 | if (itemsList != m_cmbLook->originalTexts()) { | 623 | if (itemsList != m_cmbLook->originalTexts()) { | ||
576 | KisSignalsBlocker LookComboLocker(m_cmbLook); | | |||
577 | m_cmbLook->resetOriginalTexts(itemsList); | 624 | m_cmbLook->resetOriginalTexts(itemsList); | ||
578 | } | 625 | } | ||
626 | | ||||
627 | m_cmbLook->setCurrent(ocioOptions.look); | ||||
579 | } | 628 | } | ||
580 | updateDisplaySettings(); | 629 | updateDisplaySettings(); | ||
581 | } | 630 | } | ||
Context not available. | |||||
593 | for (int j = 0; j < numViews; ++j) { | 642 | for (int j = 0; j < numViews; ++j) { | ||
594 | m_cmbView->addSqueezedItem(QString::fromUtf8(m_ocioConfig->getView(display, j))); | 643 | m_cmbView->addSqueezedItem(QString::fromUtf8(m_ocioConfig->getView(display, j))); | ||
595 | } | 644 | } | ||
645 | | ||||
646 | KisConfig cfg(true); | ||||
647 | KisOcioConfiguration ocioOptions = cfg.ocioConfiguration(); | ||||
648 | m_cmbView->setCurrent(ocioOptions.displayView); | ||||
596 | } | 649 | } | ||
597 | 650 | | |||
598 | void LutDockerDock::selectLut() | 651 | void LutDockerDock::selectLut() | ||
Context not available. | |||||
608 | QFile f(filename); | 661 | QFile f(filename); | ||
609 | if (f.exists() && filename != m_txtLut->text()) { | 662 | if (f.exists() && filename != m_txtLut->text()) { | ||
610 | m_txtLut->setText(filename); | 663 | m_txtLut->setText(filename); | ||
611 | KisConfig cfg(false); | 664 | writeControls(); | ||
612 | cfg.setOcioLutPath(filename); | | |||
613 | updateDisplaySettings(); | 665 | updateDisplaySettings(); | ||
614 | } | 666 | } | ||
615 | } | 667 | } | ||
Context not available. |