26 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
28 ERR(
"XmlLutReader::readFromFile(): Can't open xml-file {:s}.",
29 fileName.toStdString());
33 QDomDocument doc(
"ColorMap");
34 doc.setContent(&file);
35 QDomElement docElement = doc.documentElement();
36 if (docElement.nodeName().compare(
"ColorMap"))
38 ERR(
"XmlLutReader::readFromFile(): Unexpected XML root.");
43 if (docElement.hasAttribute(
"interpolation"))
45 if (docElement.attribute(
"interpolation").compare(
"Linear") == 0)
47 else if (docElement.attribute(
"interpolation").compare(
"Exponential") == 0)
55 QDomElement point = docElement.firstChildElement();
56 double range[2] = { point.attribute(
"x").toDouble(), point.attribute(
"x").toDouble() };
58 while (!point.isNull())
60 if ((point.nodeName().compare(
"Point") == 0 )
61 && point.hasAttribute(
"x")
62 && point.hasAttribute(
"r")
63 && point.hasAttribute(
"g")
64 && point.hasAttribute(
"b"))
66 double value = point.attribute(
"x").toDouble();
67 unsigned char r =
static_cast<int>(255 * point.attribute(
"r").toDouble());
68 unsigned char g =
static_cast<int>(255 * point.attribute(
"g").toDouble());
69 unsigned char b =
static_cast<int>(255 * point.attribute(
"b").toDouble());
70 unsigned char o =
static_cast<int>(255 * (point.hasAttribute(
"o") ? point.attribute(
"o").toDouble() : 1));
80 point = point.nextSiblingElement();