void colorTransformDataTranslator::writeColorSpaceForNodes(fstream& f) { MItDependencyNodes nodeIter; f << "====================== Nodes with color space attribute =======================\n"; for (; !nodeIter.isDone(); nodeIter.next()) { MObject node = nodeIter.item(); if(!node.isNull() && ( (node.apiType()==MFn::kFileTexture) || (node.apiType()==MFn::kImagePlane) ) ) { MString inputColorSpace = getInputColorSpace(node); MString transformId; f << "Found node with colorspace " << inputColorSpace.asUTF8(); if(MColorManagementUtilities::getColorTransformCacheIdForInputSpace( inputColorSpace, transformId)) { f << ", its corresponding transform id: " << transformId.asUTF8() << std::endl; } else { f << ", no corresponding transform id found.\n"; } } } }
void colorTransformDataTranslator::writeOutputTransformId(fstream& f) { f << "============================ Output Transform Id =============================\n"; MString transformId; if(MColorManagementUtilities::getColorTransformCacheIdForOutputTransform(transformId)) { f << "Output transform id: " << transformId.asUTF8() << std::endl; } else { f << "No output transform id found.\n"; } }
MStatus PRTAttrs::updateRuleFiles(MFnDependencyNode & node, MString & rulePkg) { PRTNode* prtNode = (PRTNode*)node.userNode(); MStatus stat; std::string utf8Path(rulePkg.asUTF8()); std::vector<char> percentEncodedPath(2*utf8Path.size()+1); size_t len = percentEncodedPath.size(); prt::StringUtils::percentEncode(utf8Path.c_str(), &percentEncodedPath[0], &len); if(len > percentEncodedPath.size()+1){ percentEncodedPath.resize(len); prt::StringUtils::percentEncode(utf8Path.c_str(), &percentEncodedPath[0], &len); } std::string uri(FILE_PREFIX); uri.append(&percentEncodedPath[0]); prtNode->mLRulePkg = uri; if(prtNode->mCreatedInteractively) { int count = (int)node.attributeCount(&stat); MCHECK(stat); MObjectArray attrs; for(int i = 0; i < count; i++) { MObject attr = node.attribute(i, &stat); if(stat != MS::kSuccess) continue; attrs.append(attr); } for(unsigned int i = 0; i < attrs.length(); i++) { MPlug plug(node.object(), attrs[i]); MString name = plug.partialName(); if(prtNode->mBriefName2prtAttr.count(name.asWChar())) node.removeAttribute(attrs[i]); } prtNode->destroyEnums(); } else { node.removeAttribute(node.attribute(NAME_GENERATE, &stat)); MCHECK(stat); } prtNode->mRuleFile.clear(); prtNode->mStartRule.clear(); MString unpackDir = MGlobal::executeCommandStringResult("workspace -q -fullName"); unpackDir += "/assets"; prt::Status resolveMapStatus = prt::STATUS_UNSPECIFIED_ERROR; std::wstring utf16URI; utf16URI.resize(uri.size()+1); len = utf16URI.size(); if(prt::StringUtils::toUTF16FromUTF8(uri.c_str(), &utf16URI[0], &len)) { utf16URI.resize(len); prt::StringUtils::toUTF16FromUTF8(uri.c_str(), &utf16URI[0], &len); } prtNode->mResolveMap = prt::createResolveMap(utf16URI.c_str(), unpackDir.asWChar(), &resolveMapStatus); if(resolveMapStatus == prt::STATUS_OK) { size_t nKeys; const wchar_t * const* keys = prtNode->mResolveMap->getKeys(&nKeys); std::wstring sCGB(L".cgb"); for(size_t k = 0; k < nKeys; k++) { std::wstring key = std::wstring(keys[k]); if(std::equal(sCGB.rbegin(), sCGB.rend(), key.rbegin())) { prtNode->mRuleFile = key; break; } } } else { prtNode->mResolveMap = 0; } if(prtNode->mRuleFile.length() > 0) updateStartRules(node); return MS::kSuccess; }
UnicodeString MStringToString(const MString& string) { return fromUTF8(string.asUTF8()); }