37 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
39 ERR(
"XmlLutReader::readFromFile(): Can't open xml-file {:s}.",
40 fileName.toStdString());
44 QDomDocument doc(
"ColorMap");
45 doc.setContent(&file);
46 QDomElement docElement = doc.documentElement();
47 if (docElement.nodeName().compare(
"ColorMap"))
49 ERR(
"XmlLutReader::readFromFile(): Unexpected XML root.");
54 if (docElement.hasAttribute(
"interpolation"))
56 if (docElement.attribute(
"interpolation").compare(
"Linear") == 0)
58 else if (docElement.attribute(
"interpolation").compare(
"Exponential") == 0)
66 QDomElement point = docElement.firstChildElement();
67 double range[2] = { point.attribute(
"x").toDouble(), point.attribute(
"x").toDouble() };
69 while (!point.isNull())
71 if ((point.nodeName().compare(
"Point") == 0 )
72 && point.hasAttribute(
"x")
73 && point.hasAttribute(
"r")
74 && point.hasAttribute(
"g")
75 && point.hasAttribute(
"b"))
77 double value = point.attribute(
"x").toDouble();
78 unsigned char r =
static_cast<int>(255 * point.attribute(
"r").toDouble());
79 unsigned char g =
static_cast<int>(255 * point.attribute(
"g").toDouble());
80 unsigned char b =
static_cast<int>(255 * point.attribute(
"b").toDouble());
81 unsigned char o =
static_cast<int>(255 * (point.hasAttribute(
"o") ? point.attribute(
"o").toDouble() : 1));
91 point = point.nextSiblingElement();