/** * OpenColorIO Workingspace base Iop. */ #include "OCIOWorkingSpaceBase.h" #include #include #include #include #include using namespace DD::Image; OCIOWorkingSpaceBase::OCIOWorkingSpaceBase(Node *n) : DD::Image::OCIOPluginBase(n) { m_workingSpaceIndex = 0; } OCIOWorkingSpaceBase::~OCIOWorkingSpaceBase() { } void OCIOWorkingSpaceBase::knobs(DD::Image::Knob_Callback f) { updateConfigBeforeCreatingKnobs(f); DD::Image::Colorspace_knob(f, &m_workingSpaceIndex, OCIO::ROLE_SCENE_LINEAR, "working_space", "working space"); DD::Image::Tooltip(f, "Working color space that the file is applied in. The input is transformed from scene linear to the working space, the file color transform is applied and then the result is transformed back to scene linear."); } void OCIOWorkingSpaceBase::append(DD::Image::Hash& nodehash) { try { // append the config cache id -> makes sure the color space drop down // will get reloaded during validate OCIO::ConstConfigRcPtr config = getConfigForProject(); std::string configCacheID = config->getCacheID(config->getCurrentContext()); nodehash.append(configCacheID); } catch(OCIO::Exception &e) { error(e.what()); return; } } void OCIOWorkingSpaceBase::_validate(bool for_real) { const std::string workingName = knob("working_space")->enumerationKnob()->getSelectedItemString(); // Error on invalid color space settings. This may happen with deprecated colour spaces. // Note that it is possible to send invalid colour spaces to OCIO but the error messages returned // are not user friendly. See TP 387269 for details. if (knob("working_space")->enumerationKnob()->getError()) { std::stringstream errorMsg; errorMsg << "Invalid input LUT selected: " << workingName << std::endl; error(errorMsg.str().c_str()); return; } // Call through to the base implementation DD::Image::OCIOPluginBase::_validate(for_real); }