43 #include <QDomDocument>
44 #include <QStringList>
45 #include <vtkColorTransferFunction.h>
46 #include <vtkPiecewiseFunction.h>
47 #include <vtkLookupTable.h>
48 #include <vtkImageData.h>
74 QDomDocument doc = dataNode.ownerDocument();
76 QDomElement alphaNode = doc.createElement(
"alpha");
79 QStringList pointStringList;
82 pointStringList.append(QString(
"%1=%2").arg(opPoint->first). arg(opPoint->second));
83 alphaNode.appendChild(doc.createTextNode(pointStringList.join(
" ")));
85 pointStringList.clear();
86 QDomElement colorNode = doc.createElement(
"color");
88 for (ColorMap::iterator colorPoint =
mColorMap.begin(); colorPoint !=
mColorMap.end(); ++colorPoint)
89 pointStringList.append(QString(
"%1=%2/%3/%4").arg(colorPoint->first). arg(colorPoint->second.red()). arg(
90 colorPoint->second.green()). arg(colorPoint->second.blue()));
91 colorNode.appendChild(doc.createTextNode(pointStringList.join(
" ")));
93 dataNode.appendChild(alphaNode);
94 dataNode.appendChild(colorNode);
96 QDomElement elem = dataNode.toElement();
101 if (dataNode.isNull())
104 QDomNode alphaNode = dataNode.namedItem(
"alpha");
106 if (!alphaNode.isNull() && !alphaNode.toElement().text().isEmpty())
108 QString alphaString = alphaNode.toElement().text();
110 QStringList alphaStringList = alphaString.split(
" ", QString::SkipEmptyParts);
111 for (
int i = 0; i < alphaStringList.size(); i++)
113 QStringList pointStringList = alphaStringList[i].split(
"=");
114 if (pointStringList.size() < 2)
116 addAlphaPoint(pointStringList[0].toInt(), pointStringList[1].toInt());
121 std::cout <<
"Warning: ImageTF3D::parseXml() found no alpha transferfunction";
122 std::cout << std::endl;
125 QDomNode colorNode = dataNode.namedItem(
"color");
127 if (!colorNode.isNull() && !colorNode.toElement().text().isEmpty())
130 QStringList colorStringList = colorNode.toElement().text().split(
" ", QString::SkipEmptyParts);
131 for (
int i = 0; i < colorStringList.size(); i++)
133 QStringList pointStringList = colorStringList[i].split(
"=");
134 QStringList valueStringList = pointStringList[1].split(
"/");
135 addColorPoint(pointStringList[0].toInt(), QColor(valueStringList[0].toInt(), valueStringList[1].toInt(),
136 valueStringList[2].toInt()));
141 std::cout <<
"Warning: ImageTF3D::parseXml() found no color transferfunction";
142 std::cout << std::endl;
181 double newVal = (it->first-center)*scale+center + shift;
182 int roundedVal = floor(newVal + 0.5);
183 newColorMap[roundedVal] = it->second;
193 newOpacipyMap[it->first +
shift] = it->second;
203 double old = this->
getLLR();
237 it->second += val*255;
242 double scale = val/old;
257 amax = std::max<double>(it->second, amax);
268 val = std::max(1.0, val);
273 double scale = val/old;
295 double shift = val-old;
385 tf->SetColorSpaceToRGB();
386 tf->RemoveAllPoints();
387 for (ColorMap::const_iterator iter =
mColorMap.begin(); iter !=
mColorMap.end(); ++iter)
389 QColor c = iter->second;
390 tf->AddRGBPoint(iter->first, c.redF(), c.greenF(), c.blueF());
396 tf->RemoveAllPoints();
398 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