* \brief Parse `{"position": [x,y,z]}` from a PUT body. * * Shared between PUT /rendering/selected-position and PUT * /rendering/editors/mxn/windows/{id}/selected-position: same field * name, same shape, same validation rules. * * \returns nullopt on success; an error fragment otherwise. */
| 72 | * \returns nullopt on success; an error fragment otherwise. |
| 73 | */ |
| 74 | std::optional<std::string> ParsePositionFromBody(const nlohmann::json& body, mitk::Point3D& out) |
| 75 | { |
| 76 | if (!body.contains("position")) |
| 77 | return "'position' field is required."; |
| 78 | |
| 79 | const auto& posJson = body["position"]; |
| 80 | if (!posJson.is_array() || posJson.size() != 3) |
| 81 | return "'position' must be an array of exactly 3 numbers."; |
| 82 | |
| 83 | for (const auto& v : posJson) |
| 84 | if (!v.is_number()) |
| 85 | return "'position' must be an array of exactly 3 numbers."; |
| 86 | |
| 87 | out[0] = posJson[0].get<double>(); |
| 88 | out[1] = posJson[1].get<double>(); |
| 89 | out[2] = posJson[2].get<double>(); |
| 90 | return std::nullopt; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | RenderingController::RenderingController(DataStorageBridge& bridge) |
no test coverage detected