16 #include <vtkColorTransferFunction.h> 17 #include <QStringList> 18 #include <QDomElement> 19 #include <QDomDocument> 47 file = file.
descend(
"Preset",
"name", name);
49 QDomNode tf2DNode = file.
getElement(
"lookuptable2D");
50 while (tf2DNode.hasChildNodes())
51 tf2DNode.removeChild(tf2DNode.firstChild());
56 if ((0 <= image->getMin()) && (
imCT == image->getModality()))
58 LUT2D->unsignedCT(
false);
61 LUT2D->addXml(file.
getElement(
"lookuptable2D"));
64 if ((0 <= image->getMin()) && (
imCT == image->getModality()))
66 LUT2D->unsignedCT(
true);
79 file = file.
descend(
"Preset",
"name", name);
81 QDomNode tf3DNode = file.
getElement(
"transferfunctions");
82 while (tf3DNode.hasChildNodes())
83 tf3DNode.removeChild(tf3DNode.firstChild());
85 ImageTF3DPtr transferFunctions = image->getTransferFunctions3D();
88 if ((0 <= image->getMin()) && (
imCT == image->getModality()))
90 transferFunctions->unsignedCT(
false);
93 transferFunctions->addXml(file.
getElement(
"transferfunctions"));
94 image->getShading().addXml(file.
getElement(
"shading"));
97 if ((0 <= image->getMin()) && (
imCT == image->getModality()))
99 transferFunctions->unsignedCT(
true);
109 this->
load2D(name, image);
111 this->
load3D(name, image);
120 image->resetTransferFunctions(
true,
false);
125 LUT2D->parseXml(node.
getElement().namedItem(
"lookuptable2D"));
128 if ((0 <= image->getMin()) && (
imCT == image->getModality()) && (name !=
"Transfer function preset...") )
130 LUT2D->unsignedCT(
true);
137 image->resetTransferFunctions(
false,
true);
139 ImageTF3DPtr transferFunctions = image->getTransferFunctions3D();
142 transferFunctions->parseXml(node.
getElement().namedItem(
"transferfunctions"));
146 image->setShading(shading);
149 if ((0 <= image->getMin()) && (
imCT == image->getModality()) && (name !=
"Transfer function preset...") )
151 transferFunctions->unsignedCT(
true);
157 QStringList presetList;
160 for (
int i = 0; i < presetNodeList.count(); ++i)
162 QString presetName = presetNodeList.item(i).toElement().attribute(
"name");
163 if (presetName ==
"Default")
167 QString sourceModality = presetNodeList.item(i).toElement().attribute(
"modality");
168 if ( (modality == string2enum<IMAGE_MODALITY>(sourceModality)) || (
imUNKNOWN == modality) || imCOUNT == modality )
169 presetList << presetName;
174 presetNodeList = customFile.
getElement().elementsByTagName(
"Preset");
175 for (
int i = 0; i < presetNodeList.count(); ++i)
177 QString presetName = presetNodeList.item(i).toElement().attribute(
"name");
178 QString presetModality = presetNodeList.item(i).toElement().attribute(
"modality");
179 if ( (string2enum<IMAGE_MODALITY>(presetModality) == modality) || (
imUNKNOWN == modality) || imCOUNT == modality )
180 presetList << presetName;
189 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
QDomElement getElement()
return the current element
virtual QStringList generatePresetList(IMAGE_MODALITY modality)
internally generate the preset list
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.
QString enum2string(const ENUM &val)
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.