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);
140 image->resetTransferFunctions(
true,
false);
145 LUT2D->parseXml(node.
getElement().namedItem(
"lookuptable2D"));
148 if ((0 <= image->getMin()) && (
"CT" == image->getModality()) && (name !=
"Transfer function preset...") )
150 LUT2D->unsignedCT(
true);
157 image->resetTransferFunctions(
false,
true);
159 ImageTF3DPtr transferFunctions = image->getTransferFunctions3D();
162 transferFunctions->parseXml(node.
getElement().namedItem(
"transferfunctions"));
166 image->setShading(shading);
169 if ((0 <= image->getMin()) && (
"CT" == image->getModality()) && (name !=
"Transfer function preset...") )
171 transferFunctions->unsignedCT(
true);
177 QStringList presetList;
180 for (
int i = 0; i < presetNodeList.count(); ++i)
182 QString presetName = presetNodeList.item(i).toElement().attribute(
"name");
183 if (presetName ==
"Default")
187 QString sourceModality = presetNodeList.item(i).toElement().attribute(
"modality");
188 if ( (modality == sourceModality) || (
"UNKNOWN" == modality) || modality.isEmpty() )
189 presetList << presetName;
194 presetNodeList = customFile.
getElement().elementsByTagName(
"Preset");
195 for (
int i = 0; i < presetNodeList.count(); ++i)
197 QString presetName = presetNodeList.item(i).toElement().attribute(
"name");
198 QString presetModality = presetNodeList.item(i).toElement().attribute(
"modality");
199 if ( (presetModality == modality) || (
"UNKNOWN" == modality) || modality.isEmpty() )
200 presetList << presetName;
209 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
Namespace for all CustusX production code.