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

Method HandlePUT_stdmultiCamera

Modules/RESTAPI/src/mitkRenderingController.cpp:1198–1259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1196}
1197
1198void RenderingController::HandlePUT_stdmultiCamera(const httplib::Request& req, httplib::Response& res) const
1199{
1200 const auto id = ReadRequiredPathParam(req, "id");
1201
1202 if (!IsValidStdMultiWindowId(id))
1203 {
1204 const auto error = ErrorResponse::RenderWindowNotFound(id, req.path);
1205 this->SendErrorResponse(res, 404, error);
1206 return;
1207 }
1208
1209 if (req.body.empty())
1210 {
1211 const auto error = ErrorResponse::InvalidRequest("Request body is required.", req.path);
1212 this->SendErrorResponse(res, 400, error);
1213 return;
1214 }
1215
1216 nlohmann::json body;
1217 try
1218 {
1219 body = nlohmann::json::parse(req.body);
1220 }
1221 catch (const nlohmann::json::exception&)
1222 {
1223 const auto error = ErrorResponse::InvalidRequest("Invalid JSON body.", req.path);
1224 this->SendErrorResponse(res, 400, error);
1225 return;
1226 }
1227
1228 CameraPatch patch;
1229 if (const auto err = ParseCameraPatch(body, IsStdMulti3dWindow(id), patch))
1230 {
1231 const auto error = ErrorResponse::InvalidRequest(*err, req.path);
1232 this->SendErrorResponse(res, 400, error);
1233 return;
1234 }
1235
1236 if (m_RenderWindowBridge == nullptr || !m_RenderWindowBridge->HasStdMultiCameraSetter())
1237 {
1238 const auto error = ErrorResponse::RenderWindowNotAvailable(req.path);
1239 this->SendErrorResponse(res, 503, error);
1240 return;
1241 }
1242
1243 try
1244 {
1245 m_RenderWindowBridge->SetStdMultiCamera(id, patch);
1246 res.status = 204;
1247 }
1248 catch (const mitk::Exception& e)
1249 {
1250 const auto error = ErrorResponse::RenderingError(
1251 std::string("Camera update failed: ") + e.what(), req.path);
1252 this->SendErrorResponse(res, 422, error);
1253 }
1254 catch (const std::exception& e)
1255 {

Calls 6

SendErrorResponseMethod · 0.95
ParseCameraPatchFunction · 0.85
SetStdMultiCameraMethod · 0.80
whatMethod · 0.80
emptyMethod · 0.45