MCPcopy Create free account
hub / github.com/MITK/MITK / FromJSON

Method FromJSON

Modules/Core/src/DataManagement/mitkTransferFunctionProperty.cpp:81–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 }
80
81 bool TransferFunctionProperty::FromJSON(const nlohmann::json& j)
82 {
83 auto tf = TransferFunction::New();
84 TransferFunction::ControlPoints::value_type point;
85
86 tf->ClearScalarOpacityPoints();
87
88 for (const auto& opacity : j["ScalarOpacity"])
89 {
90 opacity.get_to(point);
91 tf->AddScalarOpacityPoint(point.first, point.second);
92 }
93
94 tf->ClearGradientOpacityPoints();
95
96 for (const auto& opacity : j["GradientOpacity"])
97 {
98 opacity.get_to(point);
99 tf->AddGradientOpacityPoint(point.first, point.second);
100 }
101
102 auto* ctf = tf->GetColorTransferFunction();
103 ctf->RemoveAllPoints();
104
105 std::array<double, 6> value;
106
107 for (const auto& color : j["Color"])
108 {
109 color.get_to(value);
110 ctf->AddRGBPoint(value[0], value[1], value[2], value[3], value[4], value[5]);
111 }
112
113 this->SetValue(tf);
114
115 return true;
116 }
117
118} // namespace mitk

Callers

nothing calls this directly

Calls 8

AddScalarOpacityPointMethod · 0.80
RemoveAllPointsMethod · 0.80
AddRGBPointMethod · 0.80
NewFunction · 0.50
SetValueMethod · 0.45

Tested by

no test coverage detected