QColor ScColorEngine::getDisplayColor(const ScColor& color, const ScribusDoc* doc, double level) { QColor tmp; if (color.getColorModel() == colorModelRGB) { RGBColorF rgb; rgb.r = color.m_values[0]; rgb.g = color.m_values[1]; rgb.b = color.m_values[2]; getShadeColorRGB(color, doc, rgb, level); tmp = getDisplayColor(rgb, doc, color.isSpotColor()); } else if (color.getColorModel() == colorModelCMYK) { CMYKColorF cmyk; cmyk.c = color.m_values[0]; cmyk.m = color.m_values[1]; cmyk.y = color.m_values[2]; cmyk.k = color.m_values[3]; getShadeColorCMYK(color, doc, cmyk, level); tmp = getDisplayColor(cmyk, doc, color.isSpotColor()); } else if (color.getColorModel() == colorModelLab) { ScColorTransform trans = doc ? doc->stdLabToScreenTrans : ScCore->defaultLabToRGBTrans; double inC[3]; inC[0] = 100 - (100 - color.m_L_val) * (level / 100.0); inC[1] = color.m_a_val * (level / 100.0); inC[2] = color.m_b_val * (level / 100.0); quint16 outC[3]; trans.apply(inC, outC, 1); tmp = QColor(outC[0] / 257, outC[1] / 257, outC[2] / 257); } return tmp; }
QColor ScColorEngine::getDisplayColor(const ScColor& color, const ScribusDoc* doc) { QColor tmp; if (color.getColorModel() == colorModelRGB) { RGBColor rgb; rgb.r = color.CR; rgb.g = color.MG; rgb.b = color.YB; tmp = getDisplayColor(rgb, doc, color.isSpotColor()); } else if (color.getColorModel() == colorModelCMYK) { CMYKColor cmyk; cmyk.c = color.CR; cmyk.m = color.MG; cmyk.y = color.YB; cmyk.k = color.K; tmp = getDisplayColor(cmyk, doc, color.isSpotColor()); } else if (color.getColorModel() == colorModelLab) { ScColorTransform trans = doc ? doc->stdLabToRGBTrans : ScCore->defaultLabToRGBTrans; double inC[3]; inC[0] = color.L_val; inC[1] = color.a_val; inC[2] = color.b_val; quint16 outC[3]; trans.apply(inC, outC, 1); tmp = QColor(outC[0] / 257, outC[1] / 257, outC[2] / 257); } return tmp; }
QColor ScColorEngine::getDisplayColorGC(const ScColor& color, const ScribusDoc* doc) { QColor tmp; bool doSoftProofing = doc ? doc->SoftProofing : false; bool doGamutCheck = doc ? doc->Gamut : false; if ( doSoftProofing && doGamutCheck ) { bool outOfGamutFlag = isOutOfGamut(color, doc); tmp = outOfGamutFlag ? QColor(0, 255, 0) : getDisplayColor(color, doc); } else tmp = getDisplayColor(color, doc); return tmp; }
QColor ScColorEngine::getDisplayColor(const ScColor& color, const ScribusDoc* doc) { QColor tmp; if (color.getColorModel() == colorModelRGB) { RGBColor rgb; rgb.r = color.CR; rgb.g = color.MG; rgb.b = color.YB; tmp = getDisplayColor(rgb, doc, color.isSpotColor()); } else { CMYKColor cmyk; cmyk.c = color.CR; cmyk.m = color.MG; cmyk.y = color.YB; cmyk.k = color.K; tmp = getDisplayColor(cmyk, doc, color.isSpotColor()); } return tmp; }
QColor ScColorEngine::getDisplayColor(const ScColor& color, const ScribusDoc* doc) { QColor tmp; if (color.getColorModel() == colorModelRGB) { RGBColorF rgb; rgb.r = color.m_values[0]; rgb.g = color.m_values[1]; rgb.b = color.m_values[2]; tmp = getDisplayColor(rgb, doc, color.isSpotColor()); } else if (color.getColorModel() == colorModelCMYK) { CMYKColorF cmyk; cmyk.c = color.m_values[0]; cmyk.m = color.m_values[1]; cmyk.y = color.m_values[2]; cmyk.k = color.m_values[3]; tmp = getDisplayColor(cmyk, doc, color.isSpotColor()); } else if (color.getColorModel() == colorModelLab) { bool cmsUse = doc ? doc->HasCMS : false; ScColorTransform trans = doc ? doc->stdLabToScreenTrans : ScCore->defaultLabToRGBTrans; if (cmsUse && trans) { double inC[3]; inC[0] = color.m_L_val; inC[1] = color.m_a_val; inC[2] = color.m_b_val; quint16 outC[3]; trans.apply(inC, outC, 1); tmp = QColor(outC[0] / 257, outC[1] / 257, outC[2] / 257); } else { // First step: Lab -> XYZ double var_Y = (color.m_L_val + 16) / 116.0; double var_X = color.m_a_val / 500.0 + var_Y; double var_Z = var_Y - color.m_b_val / 200.0; if (pow(var_Y, 3) > 0.008856) var_Y = pow(var_Y, 3); else var_Y = (var_Y - 16.0 / 116.0) / 7.787; if (pow(var_X, 3) > 0.008856) var_X = pow(var_X, 3); else var_X = (var_X - 16.0 / 116.0) / 7.787; if (pow(var_Z, 3) > 0.008856) var_Z = pow(var_Z, 3); else var_Z = (var_Z - 16.0 / 116.0) / 7.787; // Second step: XYZ -> RGB // Whitepoint D50 var_X = 0.990720 * var_X; var_Y = 1.00000 * var_Y; var_Z = 0.825210 * var_Z; double var_R = var_X * 3.2406 + var_Y * -1.5372 + var_Z * -0.4986; double var_G = var_X * -0.9689 + var_Y * 1.8758 + var_Z * 0.0415; double var_B = var_X * 0.0557 + var_Y * -0.2040 + var_Z * 1.0570; if (var_R > 0.0031308) var_R = 1.055 * (pow(var_R, (1.0 / 2.4))) - 0.055; else var_R = 12.92 * var_R; if (var_G > 0.0031308) var_G = 1.055 * (pow(var_G, (1.0 / 2.4))) - 0.055; else var_G = 12.92 * var_G; if (var_B > 0.0031308) var_B = 1.055 * (pow(var_B, (1.0 / 2.4))) - 0.055; else var_B = 12.92 * var_B; tmp = QColor(0, 0, 0, 0); var_R = qMax(qMin(var_R, 1.0), 0.0); var_G = qMax(qMin(var_G, 1.0), 0.0); var_B = qMax(qMin(var_B, 1.0), 0.0); tmp.setRgbF(var_R, var_G, var_B); } } return tmp; }
QPair<QVariant, RPropertyAttributes> REntity::getProperty( RPropertyTypeId& propertyTypeId, bool humanReadable, bool noAttributes) { if (propertyTypeId == PropertyType) { return qMakePair(QVariant(getType()), RPropertyAttributes()); } else if (propertyTypeId == PropertyBlock) { return qMakePair(QVariant(getData().getBlockId()), RPropertyAttributes()); } else if (propertyTypeId == PropertyLayer) { if (humanReadable) { RDocument* document = getData().getDocument(); if (document != NULL) { RPropertyAttributes attr; if (!noAttributes) { // TODO: filter out locked layers: attr.setChoices(document->getLayerNames()); } return qMakePair(QVariant(document->getLayerName( getData().getLayerId())), attr); } } else { return qMakePair(QVariant(getData().getLayerId()), RPropertyAttributes()); } } else if (propertyTypeId == PropertyLinetype) { if (humanReadable) { RDocument* document = getData().getDocument(); if (document != NULL) { RPropertyAttributes attr; // if (!noAttributes) { // attr.setChoices(document->getLinetypeNames()); // } QString desc = document->getLinetypeLabel(getData().getLinetypeId()); return qMakePair(QVariant(desc), attr); } } else { return qMakePair(QVariant(getData().getLinetypeId()), RPropertyAttributes()); } } else if (propertyTypeId == PropertyLinetypeScale) { return qMakePair(QVariant(getData().getLinetypeScale()), RPropertyAttributes()); } else if (propertyTypeId == PropertyLineweight) { QVariant v; v.setValue<RLineweight::Lineweight>(getData().getLineweight()); return qMakePair(v, RPropertyAttributes()); } else if (propertyTypeId == PropertyColor) { QVariant var; var.setValue<RColor> (getData().getColor()); return qMakePair(var, RPropertyAttributes()); } else if (propertyTypeId == PropertyDisplayedColor) { QVariant var; var.setValue<RColor> (getDisplayColor()); return qMakePair(var, RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertyDrawOrder) { return qMakePair(QVariant(getData().getDrawOrder()), RPropertyAttributes()); } else if (propertyTypeId == PropertyMinX) { return qMakePair(QVariant(getBoundingBox().getMinimum().x), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertyMinY) { return qMakePair(QVariant(getBoundingBox().getMinimum().y), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertyMaxX) { return qMakePair(QVariant(getBoundingBox().getMaximum().x), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertyMaxY) { return qMakePair(QVariant(getBoundingBox().getMaximum().y), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertySizeX) { return qMakePair(QVariant(getBoundingBox().getWidth()), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertySizeY) { return qMakePair(QVariant(getBoundingBox().getHeight()), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } return RObject::getProperty(propertyTypeId, humanReadable, noAttributes); }