32 vtkLookupTable *lut = mitkLut->GetVtkLookupTable();
36 auto element =
new TiXmlElement(
"LookupTable");
41 element->SetAttribute(
"NumberOfColors", lut->GetNumberOfTableValues());
42 element->SetAttribute(
"Scale", lut->GetScale());
43 element->SetAttribute(
"Ramp", lut->GetRamp());
45 range = lut->GetHueRange();
46 auto child =
new TiXmlElement(
"HueRange");
47 element->LinkEndChild(child);
48 child->SetAttribute(
"min", boost::lexical_cast<std::string>(range[0]));
49 child->SetAttribute(
"max", boost::lexical_cast<std::string>(range[1]));
51 range = lut->GetValueRange();
52 child =
new TiXmlElement(
"ValueRange");
53 element->LinkEndChild(child);
54 child->SetAttribute(
"min", boost::lexical_cast<std::string>(range[0]));
55 child->SetAttribute(
"max", boost::lexical_cast<std::string>(range[1]));
57 range = lut->GetSaturationRange();
58 child =
new TiXmlElement(
"SaturationRange");
59 element->LinkEndChild(child);
60 child->SetAttribute(
"min", boost::lexical_cast<std::string>(range[0]));
61 child->SetAttribute(
"max", boost::lexical_cast<std::string>(range[1]));
63 range = lut->GetAlphaRange();
64 child =
new TiXmlElement(
"AlphaRange");
65 element->LinkEndChild(child);
66 child->SetAttribute(
"min", boost::lexical_cast<std::string>(range[0]));
67 child->SetAttribute(
"max", boost::lexical_cast<std::string>(range[1]));
69 range = lut->GetTableRange();
70 child =
new TiXmlElement(
"TableRange");
71 element->LinkEndChild(child);
72 child->SetAttribute(
"min", boost::lexical_cast<std::string>(range[0]));
73 child->SetAttribute(
"max", boost::lexical_cast<std::string>(range[1]));
75 child =
new TiXmlElement(
"Table");
76 element->LinkEndChild(child);
77 for (
int index = 0; index < lut->GetNumberOfTableValues(); ++index)
79 auto grandChild =
new TiXmlElement(
"RgbaColor");
80 rgba = lut->GetTableValue(index);
81 grandChild->SetAttribute(
"R", boost::lexical_cast<std::string>(rgba[0]));
82 grandChild->SetAttribute(
"G", boost::lexical_cast<std::string>(rgba[1]));
83 grandChild->SetAttribute(
"B", boost::lexical_cast<std::string>(rgba[2]));
84 grandChild->SetAttribute(
"A", boost::lexical_cast<std::string>(rgba[3]));
85 child->LinkEndChild(grandChild);
103 std::string double_strings[4];
110 if (element->QueryIntAttribute(
"NumberOfColors", &numberOfColors) == TIXML_SUCCESS)
112 lut->SetNumberOfTableValues(numberOfColors);
116 if (element->QueryIntAttribute(
"Scale", &scale) == TIXML_SUCCESS)
118 lut->SetScale(scale);
122 if (element->QueryIntAttribute(
"Ramp", &ramp) == TIXML_SUCCESS)
131 TiXmlElement *child = element->FirstChildElement(
"HueRange");
134 if (child->QueryStringAttribute(
"min", &double_strings[0]) != TIXML_SUCCESS)
136 if (child->QueryStringAttribute(
"max", &double_strings[1]) != TIXML_SUCCESS)
138 StringsToNumbers<double>(2, double_strings, range);
139 lut->SetHueRange(range);
142 child = element->FirstChildElement(
"ValueRange");
145 if (child->QueryStringAttribute(
"min", &double_strings[0]) != TIXML_SUCCESS)
147 if (child->QueryStringAttribute(
"max", &double_strings[1]) != TIXML_SUCCESS)
149 StringsToNumbers<double>(2, double_strings, range);
150 lut->SetValueRange(range);
153 child = element->FirstChildElement(
"SaturationRange");
156 if (child->QueryStringAttribute(
"min", &double_strings[0]) != TIXML_SUCCESS)
158 if (child->QueryStringAttribute(
"max", &double_strings[1]) != TIXML_SUCCESS)
160 StringsToNumbers<double>(2, double_strings, range);
161 lut->SetSaturationRange(range);
164 child = element->FirstChildElement(
"AlphaRange");
167 if (child->QueryStringAttribute(
"min", &double_strings[0]) != TIXML_SUCCESS)
169 if (child->QueryStringAttribute(
"max", &double_strings[1]) != TIXML_SUCCESS)
171 StringsToNumbers<double>(2, double_strings, range);
172 lut->SetAlphaRange(range);
175 child = element->FirstChildElement(
"TableRange");
178 if (child->QueryStringAttribute(
"min", &double_strings[0]) != TIXML_SUCCESS)
180 if (child->QueryStringAttribute(
"max", &double_strings[1]) != TIXML_SUCCESS)
182 StringsToNumbers<double>(2, double_strings, range);
183 lut->SetTableRange(range);
186 child = element->FirstChildElement(
"Table");
189 unsigned int index(0);
190 for (TiXmlElement *grandChild = child->FirstChildElement(
"RgbaColor"); grandChild;
191 grandChild = grandChild->NextSiblingElement(
"RgbaColor"))
193 if (grandChild->QueryStringAttribute(
"R", &double_strings[0]) != TIXML_SUCCESS)
195 if (grandChild->QueryStringAttribute(
"G", &double_strings[1]) != TIXML_SUCCESS)
197 if (grandChild->QueryStringAttribute(
"B", &double_strings[2]) != TIXML_SUCCESS)
199 if (grandChild->QueryStringAttribute(
"A", &double_strings[3]) != TIXML_SUCCESS)
201 StringsToNumbers<double>(4, double_strings, rgba);
202 lut->SetTableValue(index, rgba);
207 catch (boost::bad_lexical_cast &e)
209 MITK_ERROR <<
"Could not parse string as number: " << e.what();
214 mitkLut->SetVtkLookupTable(lut);
virtual BaseProperty::Pointer Deserialize(TiXmlElement *element) override
Deserializes given TiXmlElement.
The LookupTableProperty class Property to associate mitk::LookupTable to an mitk::DataNode.
Convenience class to temporarily change the current locale.
BaseProperty::ConstPointer m_Property
virtual TiXmlElement * Serialize() override
Serializes given BaseData object.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.