16 #include <vtkColorTransferFunction.h> 17 #include <QStringList> 18 #include <QDomElement> 19 #include <QDomDocument> 46 file = file.
descend(
"Preset",
"name", name);
48 QDomNode tf2DNode = file.
getElement(
"lookuptable2D");
49 while (tf2DNode.hasChildNodes())
50 tf2DNode.removeChild(tf2DNode.firstChild());
55 if ((0 <= image->getMin()) && (
"CT" == image->getModality()))
57 LUT2D->unsignedCT(
false);
60 LUT2D->addXml(file.
getElement(
"lookuptable2D"));
63 if ((0 <= image->getMin()) && (
"CT" == image->getModality()))
65 LUT2D->unsignedCT(
true);
68 file.
getElement().setAttribute(
"modality", image->getModality());
78 file = file.
descend(
"Preset",
"name", name);
80 QDomNode tf3DNode = file.
getElement(
"transferfunctions");
81 while (tf3DNode.hasChildNodes())
82 tf3DNode.removeChild(tf3DNode.firstChild());
84 ImageTF3DPtr transferFunctions = image->getTransferFunctions3D();
87 if ((0 <= image->getMin()) && (
"CT" == image->getModality()))
89 transferFunctions->unsignedCT(
false);
92 transferFunctions->addXml(file.
getElement(
"transferfunctions"));
93 image->getShading().addXml(file.
getElement(
"shading"));
96 if ((0 <= image->getMin()) && (
"CT" == image->getModality()))
98 transferFunctions->unsignedCT(
true);
101 file.
getElement().setAttribute(
"modality", image->getModality());
108 this->
load2D(name, image);
110 this->
load3D(name, image);
119 image->resetTransferFunctions(
true,
false);
124 LUT2D->parseXml(node.
getElement().namedItem(
"lookuptable2D"));
127 if ((0 <= image->getMin()) && (
"CT" == image->getModality()) && (name !=
"Transfer function preset...") )
129 LUT2D->unsignedCT(
true);
136 image->resetTransferFunctions(
false,
true);
138 ImageTF3DPtr transferFunctions = image->getTransferFunctions3D();
141 transferFunctions->parseXml(node.
getElement().namedItem(
"transferfunctions"));
145 image->setShading(shading);
148 if ((0 <= image->getMin()) && (
"CT" == image->getModality()) && (name !=
"Transfer function preset...") )
150 transferFunctions->unsignedCT(
true);
156 QStringList presetList;
159 for (
int i = 0; i < presetNodeList.count(); ++i)
161 QString presetName = presetNodeList.item(i).toElement().attribute(
"name");
162 if (presetName ==
"Default")
166 QString sourceModality = presetNodeList.item(i).toElement().attribute(
"modality");
167 if ( (modality == sourceModality) || (
"UNKNOWN" == modality) || modality.isEmpty() )
168 presetList << presetName;
173 presetNodeList = customFile.
getElement().elementsByTagName(
"Preset");
174 for (
int i = 0; i < presetNodeList.count(); ++i)
176 QString presetName = presetNodeList.item(i).toElement().attribute(
"name");
177 QString presetModality = presetNodeList.item(i).toElement().attribute(
"modality");
178 if ( (presetModality == modality) || (
"UNKNOWN" == modality) || modality.isEmpty() )
179 presetList << presetName;
188 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.