37 #include <vtkColorTransferFunction.h>
38 #include <QStringList>
39 #include <QDomElement>
40 #include <QDomDocument>
67 file = file.
descend(
"Preset",
"name", name);
69 QDomNode tf2DNode = file.
getElement(
"lookuptable2D");
70 while (tf2DNode.hasChildNodes())
71 tf2DNode.removeChild(tf2DNode.firstChild());
76 if ((0 <= image->getMin()) && (
"CT" == image->getModality()))
78 LUT2D->unsignedCT(
false);
81 LUT2D->addXml(file.
getElement(
"lookuptable2D"));
84 if ((0 <= image->getMin()) && (
"CT" == image->getModality()))
86 LUT2D->unsignedCT(
true);
89 file.
getElement().setAttribute(
"modality", image->getModality());
99 file = file.
descend(
"Preset",
"name", name);
101 QDomNode tf3DNode = file.
getElement(
"transferfunctions");
102 while (tf3DNode.hasChildNodes())
103 tf3DNode.removeChild(tf3DNode.firstChild());
105 ImageTF3DPtr transferFunctions = image->getTransferFunctions3D();
108 if ((0 <= image->getMin()) && (
"CT" == image->getModality()))
110 transferFunctions->unsignedCT(
false);
113 transferFunctions->addXml(file.
getElement(
"transferfunctions"));
114 image->getShading().addXml(file.
getElement(
"shading"));
117 if ((0 <= image->getMin()) && (
"CT" == image->getModality()))
119 transferFunctions->unsignedCT(
true);
122 file.
getElement().setAttribute(
"modality", image->getModality());
129 this->
load2D(name, image);
131 this->
load3D(name, image);
137 image->resetTransferFunctions(
true,
false);
142 LUT2D->parseXml(node.
getElement().namedItem(
"lookuptable2D"));
145 if ((0 <= image->getMin()) && (
"CT" == image->getModality()) && (name !=
"Transfer function preset...") )
147 LUT2D->unsignedCT(
true);
154 image->resetTransferFunctions(
false,
true);
156 ImageTF3DPtr transferFunctions = image->getTransferFunctions3D();
159 transferFunctions->parseXml(node.
getElement().namedItem(
"transferfunctions"));
163 image->setShading(shading);
166 if ((0 <= image->getMin()) && (
"CT" == image->getModality()) && (name !=
"Transfer function preset...") )
168 transferFunctions->unsignedCT(
true);
174 QStringList presetList;
177 for (
int i = 0; i < presetNodeList.count(); ++i)
179 QString presetName = presetNodeList.item(i).toElement().attribute(
"name");
180 if (presetName ==
"Default")
184 QString sourceModality = presetNodeList.item(i).toElement().attribute(
"modality");
185 if ( (modality == sourceModality) || (
"UNKNOWN" == modality) || modality.isEmpty() )
186 presetList << presetName;
191 presetNodeList = customFile.
getElement().elementsByTagName(
"Preset");
192 for (
int i = 0; i < presetNodeList.count(); ++i)
194 QString presetName = presetNodeList.item(i).toElement().attribute(
"name");
195 QString presetModality = presetNodeList.item(i).toElement().attribute(
"modality");
196 if ( (presetModality == modality) || (
"UNKNOWN" == modality) || modality.isEmpty() )
197 presetList << presetName;
206 std::cout <<
"TODO rewrite TransferFunctions3DPresets::deletePresetData(QString name, bool _2D, bool _3D)" << std::endl;
void load2D(QString name, ImagePtr image)
void load(QString name, ImagePtr image, bool _2D=true, bool _3D=true)
void parseXml(QDomNode dataNode)
Base class for a group of presets in the system.
boost::shared_ptr< class Image > ImagePtr
void load3D(QString name, ImagePtr image)
virtual void save()
saves the presets to file
QStringList generatePresetList(QString modality)
internally generate the preset list
QDomElement getElement()
return the current element
void save3D(QString name, ImagePtr image)
XmlOptionFile mPresetFile
< the name of the last custom preset removed
void deletePresetData(QString name, bool _2D=true, bool _3D=true)
Delete the preset data node.
XmlOptionFile getCustomFile()
TransferFunctions3DPresets(XmlOptionFile presetFile, XmlOptionFile customFile)
boost::shared_ptr< class ImageLUT2D > ImageLUT2DPtr
void save2D(QString name, ImagePtr image)
void deleteNode()
Delete the current node.
void save()
save entire document.
XmlOptionFile getPresetNode(const QString &presetName)
Look for a preset with the given name. Create one if not found.
boost::shared_ptr< class ImageTF3D > ImageTF3DPtr
Helper class for xml files used to store ssc/cx data.
XmlOptionFile descend(QString element) const
step one level down in the xml tree