| 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 |
nothing calls this directly
no test coverage detected