43 #include <QDomDocument>
44 #include <QStringList>
45 #include <vtkColorTransferFunction.h>
46 #include <vtkPiecewiseFunction.h>
47 #include <vtkLookupTable.h>
48 #include <vtkImageData.h>
75 QDomDocument doc = dataNode.ownerDocument();
77 QDomElement alphaNode = doc.createElement(
"alpha");
80 QStringList pointStringList;
83 pointStringList.append(QString(
"%1=%2").arg(opPoint->first). arg(opPoint->second));
84 alphaNode.appendChild(doc.createTextNode(pointStringList.join(
" ")));
86 pointStringList.clear();
87 QDomElement colorNode = doc.createElement(
"color");
89 for (ColorMap::iterator colorPoint =
mColorMap.begin(); colorPoint !=
mColorMap.end(); ++colorPoint)
90 pointStringList.append(QString(
"%1=%2/%3/%4").arg(colorPoint->first). arg(colorPoint->second.red()). arg(
91 colorPoint->second.green()). arg(colorPoint->second.blue()));
92 colorNode.appendChild(doc.createTextNode(pointStringList.join(
" ")));
94 dataNode.appendChild(alphaNode);
95 dataNode.appendChild(colorNode);
97 QDomElement elem = dataNode.toElement();
102 if (dataNode.isNull())
108 QDomNode alphaNode = dataNode.namedItem(
"alpha");
110 if (!alphaNode.isNull() && !alphaNode.toElement().text().isEmpty())
112 QString alphaString = alphaNode.toElement().text();
114 QStringList alphaStringList = alphaString.split(
" ", QString::SkipEmptyParts);
115 for (
int i = 0; i < alphaStringList.size(); i++)
117 QStringList pointStringList = alphaStringList[i].split(
"=");
118 if (pointStringList.size() < 2)
120 addAlphaPoint(pointStringList[0].toInt(), pointStringList[1].toInt());
125 CX_LOG_WARNING() <<
"ImageTF3D::parseXml() found no alpha transferfunction";
128 QDomNode colorNode = dataNode.namedItem(
"color");
130 if (!colorNode.isNull() && !colorNode.toElement().text().isEmpty())
133 QStringList colorStringList = colorNode.toElement().text().split(
" ", QString::SkipEmptyParts);
134 for (
int i = 0; i < colorStringList.size(); i++)
136 QStringList pointStringList = colorStringList[i].split(
"=");
137 QStringList valueStringList = pointStringList[1].split(
"/");
138 addColorPoint(pointStringList[0].toInt(), QColor(valueStringList[0].toInt(), valueStringList[1].toInt(),
139 valueStringList[2].toInt()));
144 CX_LOG_WARNING() <<
"ImageTF3D::parseXml() found no color transferfunction";
183 double newVal = (it->first-center)*scale+center + shift;
184 int roundedVal = floor(newVal + 0.5);
185 newColorMap[roundedVal] = it->second;
195 newOpacipyMap[it->first +
shift] = it->second;
205 double old = this->
getLLR();
239 it->second += val*255;
244 double scale = val/old;
259 amax = std::max<double>(it->second, amax);
270 val = std::max(1.0, val);
275 double scale = val/old;
297 double shift = val-old;
387 tf->SetColorSpaceToRGB();
388 tf->RemoveAllPoints();
389 for (ColorMap::const_iterator iter =
mColorMap.begin(); iter !=
mColorMap.end(); ++iter)
391 QColor c = iter->second;
392 tf->AddRGBPoint(iter->first, c.redF(), c.greenF(), c.blueF());
398 tf->RemoveAllPoints();
400 tf->AddPoint(iter->first, iter->second / 255.0);
void setLLR(double val)
range [scalarMin..scalarMax]
void unsignedCT(bool onLoad)
void shiftColor(int shift, double center, double scale)
virtual void addXml(QDomNode dataNode)
adds xml information about the transferfunction and its variabels
void fillOpacityTFFromMap(vtkPiecewiseFunctionPtr tf) const
virtual void parseXml(QDomNode dataNode)
Use a XML node to load data.
vtkColorTransferFunctionPtr generateColorTF() const
void shift(int val)
shift the transfter function index values by the input amount. Used for signed/unsigned conversion...
vtkSmartPointer< class vtkPiecewiseFunction > vtkPiecewiseFunctionPtr
void resetColor(ColorMap val)
void setAlpha(double val)
range [0..1]
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
vtkSmartPointer< class vtkColorTransferFunction > vtkColorTransferFunctionPtr
void removeAlphaPoint(int alphaPosition)
Remove point from the opacity transfer function.
std::map< int, QColor > ColorMap
void setWindow(double val)
range [1..scalarMax-scalarMin]
void moveColorPoint(int oldpos, int newpos, QColor colorValue)
void removeColorPoint(int colorPosition)
Remove point from the color transfer function.
vtkPiecewiseFunctionPtr generateOpacityTF() const
virtual void internalsHaveChanged()
void resetAlpha(IntIntMap val)
std::map< int, int > IntIntMap
IntIntMap getOpacityMap()
Data class for Transfer Function info, either 2D or 3D.
void setLevel(double val)
range [scalarMin..scalarMax]
void addAlphaPoint(int alphaPosition, int alphaValue)
Add point to the opacity transfer function.
void moveAlphaPoint(int oldpos, int newpos, int alphaValue)
void shiftOpacity(int shift)
void addColorPoint(int colorPosition, QColor colorValue)
Add point to the color transfer function.
void deepCopy(ImageTFData *source)
void fillColorTFFromMap(vtkColorTransferFunctionPtr tf) const