Mercurial > hg > orthanc-stone
comparison Applications/Samples/SimpleViewerApplication.h @ 300:b4abaeb783b1 am-callable-and-promise
messaging refactoring almost complete: works fine in native
author | am@osimis.io |
---|---|
date | Tue, 18 Sep 2018 15:23:21 +0200 |
parents | 3897f9f28cfa |
children | be2660b6e40a |
comparison
equal
deleted
inserted
replaced
299:3897f9f28cfa | 300:b4abaeb783b1 |
---|---|
266 orthancApiClient_.reset(new OrthancApiClient(broker_, context_->GetWebService())); | 266 orthancApiClient_.reset(new OrthancApiClient(broker_, context_->GetWebService())); |
267 | 267 |
268 if (parameters.count("studyId") < 1) | 268 if (parameters.count("studyId") < 1) |
269 { | 269 { |
270 LOG(WARNING) << "The study ID is missing, will take the first studyId found in Orthanc"; | 270 LOG(WARNING) << "The study ID is missing, will take the first studyId found in Orthanc"; |
271 orthancApiClient_->GetJsonAsync("/studies", new Callable<SimpleViewerApplication, OrthancApiClient::NewGetJsonResponseReadyMessage>(*this, &SimpleViewerApplication::OnStudyListReceived)); | 271 orthancApiClient_->GetJsonAsync("/studies", new Callable<SimpleViewerApplication, OrthancApiClient::JsonResponseReadyMessage>(*this, &SimpleViewerApplication::OnStudyListReceived)); |
272 } | 272 } |
273 else | 273 else |
274 { | 274 { |
275 SelectStudy(parameters["studyId"].as<std::string>()); | 275 SelectStudy(parameters["studyId"].as<std::string>()); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 void OnStudyListReceived(const OrthancApiClient::NewGetJsonResponseReadyMessage& message) | 279 void OnStudyListReceived(const OrthancApiClient::JsonResponseReadyMessage& message) |
280 { | 280 { |
281 const Json::Value& response = message.response_; | 281 const Json::Value& response = message.Response; |
282 | 282 |
283 if (response.isArray() && response.size() > 1) | 283 if (response.isArray() && response.size() > 1) |
284 { | 284 { |
285 SelectStudy(response[0].asString()); | 285 SelectStudy(response[0].asString()); |
286 } | 286 } |
287 } | 287 } |
288 void OnStudyReceived(const OrthancApiClient::NewGetJsonResponseReadyMessage& message) | 288 void OnStudyReceived(const OrthancApiClient::JsonResponseReadyMessage& message) |
289 { | 289 { |
290 const Json::Value& response = message.response_; | 290 const Json::Value& response = message.Response; |
291 | 291 |
292 if (response.isObject() && response["Series"].isArray()) | 292 if (response.isObject() && response["Series"].isArray()) |
293 { | 293 { |
294 for (size_t i=0; i < response["Series"].size(); i++) | 294 for (size_t i=0; i < response["Series"].size(); i++) |
295 { | 295 { |
296 orthancApiClient_->GetJsonAsync("/series/" + response["Series"][(int)i].asString(), new Callable<SimpleViewerApplication, OrthancApiClient::NewGetJsonResponseReadyMessage>(*this, &SimpleViewerApplication::OnSeriesReceived)); | 296 orthancApiClient_->GetJsonAsync("/series/" + response["Series"][(int)i].asString(), new Callable<SimpleViewerApplication, OrthancApiClient::JsonResponseReadyMessage>(*this, &SimpleViewerApplication::OnSeriesReceived)); |
297 } | 297 } |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
301 void OnSeriesReceived(const OrthancApiClient::NewGetJsonResponseReadyMessage& message) | 301 void OnSeriesReceived(const OrthancApiClient::JsonResponseReadyMessage& message) |
302 { | 302 { |
303 const Json::Value& response = message.response_; | 303 const Json::Value& response = message.Response; |
304 | 304 |
305 if (response.isObject() && response["Instances"].isArray() && response["Instances"].size() > 0) | 305 if (response.isObject() && response["Instances"].isArray() && response["Instances"].size() > 0) |
306 { | 306 { |
307 // keep track of all instances IDs | 307 // keep track of all instances IDs |
308 const std::string& seriesId = response["ID"].asString(); | 308 const std::string& seriesId = response["ID"].asString(); |
336 thumbnailWidget->SetInteractor(*thumbnailInteractor_); | 336 thumbnailWidget->SetInteractor(*thumbnailInteractor_); |
337 } | 337 } |
338 | 338 |
339 void SelectStudy(const std::string& studyId) | 339 void SelectStudy(const std::string& studyId) |
340 { | 340 { |
341 orthancApiClient_->GetJsonAsync("/studies/" + studyId, new Callable<SimpleViewerApplication, OrthancApiClient::NewGetJsonResponseReadyMessage>(*this, &SimpleViewerApplication::OnStudyReceived)); | 341 orthancApiClient_->GetJsonAsync("/studies/" + studyId, new Callable<SimpleViewerApplication, OrthancApiClient::JsonResponseReadyMessage>(*this, &SimpleViewerApplication::OnStudyReceived)); |
342 } | 342 } |
343 | 343 |
344 void OnWidgetGeometryChanged(const LayerWidget::GeometryChangedMessage& message) | 344 void OnWidgetGeometryChanged(const LayerWidget::GeometryChangedMessage& message) |
345 { | 345 { |
346 message.origin_.SetDefaultView(); | 346 message.origin_.SetDefaultView(); |