22 #include <QDomDocument>
23 #include <QStringList>
24 #include <vtkColorTransferFunction.h>
25 #include <vtkPiecewiseFunction.h>
26 #include <vtkLookupTable.h>
27 #include <vtkImageData.h>
54 QDomDocument doc = dataNode.ownerDocument();
56 QDomElement alphaNode = doc.createElement(
"alpha");
59 QStringList pointStringList;
62 pointStringList.append(QString(
"%1=%2").arg(opPoint->first). arg(opPoint->second));
63 alphaNode.appendChild(doc.createTextNode(pointStringList.join(
" ")));
65 pointStringList.clear();
66 QDomElement colorNode = doc.createElement(
"color");
68 for (ColorMap::iterator colorPoint =
mColorMap.begin(); colorPoint !=
mColorMap.end(); ++colorPoint)
69 pointStringList.append(QString(
"%1=%2/%3/%4").arg(colorPoint->first). arg(colorPoint->second.red()). arg(
70 colorPoint->second.green()). arg(colorPoint->second.blue()));
71 colorNode.appendChild(doc.createTextNode(pointStringList.join(
" ")));
73 dataNode.appendChild(alphaNode);
74 dataNode.appendChild(colorNode);
76 QDomElement elem = dataNode.toElement();
81 if (dataNode.isNull())
87 QDomNode alphaNode = dataNode.namedItem(
"alpha");
89 if (!alphaNode.isNull() && !alphaNode.toElement().text().isEmpty())
91 QString alphaString = alphaNode.toElement().text();
93 QStringList alphaStringList = alphaString.split(
" ", QString::SkipEmptyParts);
94 for (
int i = 0; i < alphaStringList.size(); i++)
96 QStringList pointStringList = alphaStringList[i].split(
"=");
97 if (pointStringList.size() < 2)
99 addAlphaPoint(pointStringList[0].toInt(), pointStringList[1].toInt());
104 CX_LOG_WARNING() <<
"ImageTF3D::parseXml() found no alpha transferfunction";
107 QDomNode colorNode = dataNode.namedItem(
"color");
109 if (!colorNode.isNull() && !colorNode.toElement().text().isEmpty())
112 QStringList colorStringList = colorNode.toElement().text().split(
" ", QString::SkipEmptyParts);
113 for (
int i = 0; i < colorStringList.size(); i++)
115 QStringList pointStringList = colorStringList[i].split(
"=");
116 QStringList valueStringList = pointStringList[1].split(
"/");
117 addColorPoint(pointStringList[0].toInt(), QColor(valueStringList[0].toInt(), valueStringList[1].toInt(),
118 valueStringList[2].toInt()));
123 CX_LOG_WARNING() <<
"ImageTF3D::parseXml() found no color transferfunction";
162 double newVal = (it->first-center)*scale+center +
shift;
163 int roundedVal = floor(newVal + 0.5);
164 newColorMap[roundedVal] = it->second;
174 newOpacipyMap[it->first +
shift] = it->second;
184 double old = this->
getLLR();
218 it->second += val*255;
223 double scale = val/old;
238 amax = std::max<double>(it->second, amax);
249 val = std::max(1.0, val);
254 double scale = val/old;
276 double shift = val-old;
366 tf->SetColorSpaceToRGB();
367 tf->RemoveAllPoints();
368 for (ColorMap::const_iterator iter =
mColorMap.begin(); iter !=
mColorMap.end(); ++iter)
370 QColor c = iter->second;
371 tf->AddRGBPoint(iter->first, c.redF(), c.greenF(), c.blueF());
377 tf->RemoveAllPoints();
379 tf->AddPoint(iter->first, iter->second / 255.0);