diff --git a/Modules/REST/src/mitkRESTClient.cpp b/Modules/REST/src/mitkRESTClient.cpp index a5f2aabaf6..849fd58438 100644 --- a/Modules/REST/src/mitkRESTClient.cpp +++ b/Modules/REST/src/mitkRESTClient.cpp @@ -1,211 +1,217 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include #include #include #include #include using http_client = web::http::client::http_client; using http_request = web::http::http_request; using http_response = web::http::http_response; using methods = web::http::methods; using status_codes = web::http::status_codes; using file_buffer = concurrency::streams::file_buffer; using streambuf = concurrency::streams::streambuf; mitk::RESTClient::RESTClient() { m_ClientConfig.set_validate_certificates(false); } mitk::RESTClient::~RESTClient() {} bool mitk::RESTClient::CheckResponseContentType(web::http::http_response &response) { auto status = response.status_code(); if (status_codes::OK != status) { MITK_WARN << "Status: " << status; MITK_WARN << "Response: " << mitk::RESTUtil::convertToUtf8(response.to_string()); mitkThrow() << mitk::RESTUtil::convertToUtf8(response.to_string()); } auto requestContentType = response.headers().content_type(); MITK_DEBUG << "Content Type: " << mitk::RESTUtil::convertToUtf8(requestContentType); MITK_DEBUG << "Body: " << mitk::RESTUtil::convertToUtf8(response.to_string()); if (requestContentType.find(U("json")) != std::wstring::npos) { MITK_DEBUG << "Caution! The given response content type was '" << mitk::RESTUtil::convertToUtf8(requestContentType) << "' but contains 'json'. So we awesome the answer actually contains a JSON message."; response.headers().set_content_type(U("application/json")); return true; } return false; } pplx::task mitk::RESTClient::Get(const web::uri &uri, const std::map headers) { auto client = new http_client(uri, m_ClientConfig); http_request request; for (auto param : headers) { request.headers().add(param.first, param.second); } return client->request(request).then([=](pplx::task responseTask) { try { auto response = responseTask.get(); bool isjson = CheckResponseContentType(response); - if (isjson) - return response.extract_json().get(); - web::http::http_response dummy; - return dummy.extract_json().get(); + if (!isjson) + { + web::json::value dummy; + return dummy; + } + return response.extract_json().get(); } catch (const std::exception &e) { MITK_INFO << e.what(); mitkThrow() << "Getting response went wrong: " << e.what(); } }); } pplx::task mitk::RESTClient::Get(const web::uri &uri, const utility::string_t &filePath, const std::map headers) { auto client = new http_client(uri, m_ClientConfig); auto fileBuffer = std::make_shared>(); http_request request; for (auto param : headers) { request.headers().add(param.first, param.second); } // Open file stream for the specified file path return file_buffer::open(filePath, std::ios::out) .then([=](streambuf outFile) -> pplx::task { *fileBuffer = outFile; return client->request(methods::GET); }) // Write the response body into the file buffer .then([=](http_response response) -> pplx::task { auto status = response.status_code(); if (status_codes::OK != status) { MITK_INFO << status; MITK_INFO << mitk::RESTUtil::convertToUtf8(response.to_string()); mitkThrow() << mitk::RESTUtil::convertToUtf8(response.to_string()); } return response.body().read_to_end(*fileBuffer); }) // Close the file buffer .then([=](size_t) { return fileBuffer->close(); }) // Return empty JSON object .then([=]() { return web::json::value(); }); } pplx::task mitk::RESTClient::Put(const web::uri &uri, const web::json::value *content) { auto client = new http_client(uri, m_ClientConfig); http_request request(methods::PUT); if (nullptr != content) request.set_body(*content); return client->request(request).then([=](pplx::task responseTask) { try { auto response = responseTask.get(); bool isjson = CheckResponseContentType(response); - if (isjson) - return response.extract_json().get(); - web::http::http_response dummy; - return dummy.extract_json().get(); + if (!isjson) + { + web::json::value dummy; + return dummy; + } + return response.extract_json().get(); } catch (std::exception &e) { MITK_INFO << e.what(); mitkThrow() << "Getting response went wrong"; } }); } pplx::task mitk::RESTClient::Post(const web::uri &uri, const std::vector *content, const std::map headers) { auto request = InitRequest(headers); request.set_method(methods::POST); if (nullptr != content) request.set_body(*content); return ExecutePost(uri, request); } pplx::task mitk::RESTClient::Post(const web::uri &uri, const web::json::value *content, const std::map headers) { auto request = InitRequest(headers); request.set_method(methods::POST); if (nullptr != content) request.set_body(*content); return ExecutePost(uri, request); } http_request mitk::RESTClient::InitRequest(const std::map headers) { http_request request; for (auto param : headers) { request.headers().add(param.first, param.second); } return request; } pplx::task mitk::RESTClient::ExecutePost(const web::uri &uri, http_request request) { auto client = new http_client(uri, m_ClientConfig); return client->request(request).then([=](pplx::task responseTask) { try { auto response = responseTask.get(); bool isjson = CheckResponseContentType(response); - if (isjson) - return response.extract_json().get(); - web::http::http_response dummy; - return dummy.extract_json().get(); + if (!isjson) + { + web::json::value dummy; + return dummy; + } + return response.extract_json().get(); } catch (std::exception &e) { MITK_INFO << e.what(); mitkThrow() << "Getting response went wrong"; } }); } diff --git a/Plugins/org.mitk.gui.qt.dicomweb/src/internal/DicomWebView.cpp b/Plugins/org.mitk.gui.qt.dicomweb/src/internal/DicomWebView.cpp index c68212a82c..cab8e48743 100644 --- a/Plugins/org.mitk.gui.qt.dicomweb/src/internal/DicomWebView.cpp +++ b/Plugins/org.mitk.gui.qt.dicomweb/src/internal/DicomWebView.cpp @@ -1,452 +1,465 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include #include // Qmitk #include #include // Qt #include #include // mitk #include "DicomWebView.h" #include "mitkLabelSetImage.h" #include #include "mitkIOUtil.h" #include "mitkNodePredicateProperty.h" #include "mitkImage.h" #include "mitkNodePredicateDataType.h" #include #include const std::string DicomWebView::VIEW_ID = "org.mitk.views.dicomwebview"; void DicomWebView::SetFocus() {} void DicomWebView::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); m_Parent = parent; SetPredicates(); qRegisterMetaType>("std::vector"); qRegisterMetaType>("std::vector"); qRegisterMetaType("DicomDTO"); m_Controls.cleanDicomBtn->setVisible(true); connect(m_Controls.buttonUpload, &QPushButton::clicked, this, &DicomWebView::UploadNewSegmentation); connect(m_Controls.cleanDicomBtn, &QPushButton::clicked, this, &DicomWebView::CleanDicomFolder); connect(m_Controls.restartConnection, &QPushButton::clicked, this, &DicomWebView::OnRestartConnection); connect(m_Controls.patImageSelector, SIGNAL(CurrentSelectionChanged(QList)), this, SLOT(OnPatientSelectionChanged(QList))); connect(m_Controls.segImageSelector, SIGNAL(CurrentSelectionChanged(QList)), this, SLOT(OnSegmentationSelectionChanged(QList))); m_DownloadBaseDir = mitk::IOUtil::GetTempPath() + "segrework"; MITK_INFO << "using download base dir: " << m_DownloadBaseDir; m_UploadBaseDir = mitk::IOUtil::GetTempPath() + "uploadSeg"; if (!itksys::SystemTools::FileIsDirectory(m_DownloadBaseDir)) { itk::FileTools::CreateDirectory(m_DownloadBaseDir); } if (!itksys::SystemTools::FileIsDirectory(m_UploadBaseDir)) { itk::FileTools::CreateDirectory(m_UploadBaseDir); } m_HostURL = U("http://localhost"); auto host = m_HostURL; auto envHostURL = std::getenv("HOST_URL"); if (envHostURL) { MITK_INFO << "host url " << std::string(envHostURL); m_HostURL = mitk::RESTUtil::convertToTString(std::string(envHostURL)); host = m_HostURL; } else { host = host.append(U(":8000")); } m_restURL = host.append(U("/rest-srs")); MITK_INFO << "rest url: " << mitk::RESTUtil::convertToUtf8(m_restURL); utility::string_t pacsURL = U("");// e.g. http://10.128.129.166:8080 auto envPacsURL = std::getenv("PACS_URL"); if (envPacsURL) { pacsURL = mitk::RESTUtil::convertToTString(std::string(envPacsURL)); } m_RequestHandler = new DicomWebRequestHandler(m_DownloadBaseDir, pacsURL); connect(this, &DicomWebView::InvokeProgress, this, &DicomWebView::AddProgress); connect(m_RequestHandler, &DicomWebRequestHandler::InvokeProgress, this, &DicomWebView::AddProgress); connect( m_RequestHandler, &DicomWebRequestHandler::InvokeUpdateDcmMeta, this, &DicomWebView::InitializeDcmMeta); connect(m_RequestHandler, &DicomWebRequestHandler::InvokeLoadData, this, &DicomWebView::LoadData); // Get the micro service us::ModuleContext *context = us::ModuleRegistry::GetModule(1)->GetModuleContext(); auto managerRef = context->GetServiceReference(); if (managerRef) { auto managerService = context->GetService(managerRef); if (managerService) { m_ManagerService = managerService; } } // Should be done last, if everything else is configured because it triggers the autoselection of data. m_Controls.patImageSelector->SetAutoSelectNewNodes(true); m_Controls.segImageSelector->SetAutoSelectNewNodes(true); //RestartConnection(pacsURL); } void DicomWebView::SetPredicates() { mitk::TNodePredicateDataType::Pointer isImage = mitk::TNodePredicateDataType::New(); mitk::NodePredicateDataType::Pointer isDwi = mitk::NodePredicateDataType::New("DiffusionImage"); mitk::NodePredicateDataType::Pointer isDti = mitk::NodePredicateDataType::New("TensorImage"); mitk::NodePredicateDataType::Pointer isOdf = mitk::NodePredicateDataType::New("OdfImage"); auto isSegment = mitk::NodePredicateDataType::New("Segment"); mitk::NodePredicateOr::Pointer validImages = mitk::NodePredicateOr::New(); validImages->AddPredicate(mitk::NodePredicateAnd::New(isImage, mitk::NodePredicateNot::New(isSegment))); validImages->AddPredicate(isDwi); validImages->AddPredicate(isDti); validImages->AddPredicate(isOdf); m_IsNotAHelperObject = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true))); m_IsOfTypeImagePredicate = mitk::NodePredicateAnd::New(validImages, m_IsNotAHelperObject); mitk::NodePredicateProperty::Pointer isBinaryPredicate = mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true)); mitk::NodePredicateNot::Pointer isNotBinaryPredicate = mitk::NodePredicateNot::New(isBinaryPredicate); mitk::NodePredicateAnd::Pointer isABinaryImagePredicate = mitk::NodePredicateAnd::New(m_IsOfTypeImagePredicate, isBinaryPredicate); mitk::NodePredicateAnd::Pointer isNotABinaryImagePredicate = mitk::NodePredicateAnd::New(m_IsOfTypeImagePredicate, isNotBinaryPredicate); m_IsASegmentationImagePredicate = mitk::NodePredicateOr::New(isABinaryImagePredicate, mitk::TNodePredicateDataType::New()); m_IsAPatientImagePredicate = mitk::NodePredicateAnd::New( isNotABinaryImagePredicate, mitk::NodePredicateNot::New(mitk::TNodePredicateDataType::New())); m_Controls.patImageSelector->SetDataStorage(GetDataStorage()); m_Controls.patImageSelector->SetNodePredicate(m_IsAPatientImagePredicate); m_Controls.patImageSelector->SetSelectionIsOptional(false); m_Controls.patImageSelector->SetInvalidInfo("Select an image."); m_Controls.patImageSelector->SetPopUpTitel("Select an image."); m_Controls.patImageSelector->SetPopUpHint( "Select an image that should be used and could be uploaded."); // TODO: set Image to uplaod m_Controls.segImageSelector->SetDataStorage(GetDataStorage()); m_Controls.segImageSelector->SetNodePredicate(m_IsASegmentationImagePredicate); m_Controls.segImageSelector->SetSelectionIsOptional(false); m_Controls.segImageSelector->SetInvalidInfo("Select a segmentation."); m_Controls.segImageSelector->SetPopUpTitel("Select a segmentation."); m_Controls.segImageSelector->SetPopUpHint("Select a segmentation that should be uploaded."); } void DicomWebView::AddProgress(int progress, QString status) { auto futureValue = m_Controls.progressBar->value() + progress; if (futureValue >= 100) { m_Controls.progressBar->setValue(0); m_Controls.progressBar->setFormat(""); } else { m_Controls.progressBar->setFormat(status.append(" %p%")); m_Controls.progressBar->setValue(futureValue); } } void DicomWebView::InitializeDcmMeta(DicomWebRequestHandler::DicomDTO dto) { m_CurrentStudyUID = mitk::RESTUtil::convertToUtf8(dto.studyUID); m_SRUID = mitk::RESTUtil::convertToUtf8(dto.srSeriesUID); m_GroundTruth = mitk::RESTUtil::convertToUtf8(dto.groundTruth); } void DicomWebView::Activated() { StartServer(); MITK_INFO << "activated"; } void DicomWebView::Deactivated() { MITK_INFO << "deactivated"; m_ManagerService->HandleDeleteObserver(m_RequestHandler); } void DicomWebView::Visible() { MITK_INFO << "visible"; } void DicomWebView::Hidden() { MITK_INFO << "hidden"; } pplx::task DicomWebView::TestConnection() { mitk::RESTUtil::ParamMap seriesInstancesParams; seriesInstancesParams.insert(mitk::RESTUtil::ParamMap::value_type(U("limit"), U("1"))); m_Controls.connectionStatus->setText(QString("Testing connection ...")); return m_RequestHandler->DicomWebGet().SendQIDO(seriesInstancesParams).then([=](pplx::task resultTask) { try { auto result = resultTask.get(); if (!result.is_null()) { m_Controls.connectionStatus->setText(QString("Connection works!")); return true; } else { m_Controls.connectionStatus->setText(QString("Trouble with connection. Not valid!")); return false; } } catch (mitk::Exception &e) { MITK_WARN << e.what(); m_Controls.connectionStatus->setText(QString("No connection possible.")); return false; } }); } void DicomWebView::OnRestartConnection() { RestartConnection(mitk::RESTUtil::convertToTString(m_Controls.dcm4cheeHostValue->text().toStdString())); } void DicomWebView::RestartConnection(utility::string_t newHost) { utility::string_t host; if (newHost.empty()) { MITK_INFO << "Host was empty"; m_Controls.connectionStatus->setText(QString("Host must not be empty!")); return; } utility::string_t url = newHost + U("/dcm4chee-arc/aets/DCM4CHEE/"); MITK_INFO << "Restarting connection to " << mitk::RESTUtil::convertToUtf8(url) << " ..."; m_Controls.connectionStatus->setText(QString("Restarting connection...")); m_Controls.dcm4cheeURL->setText({(utility::conversions::to_utf8string(url).c_str())}); m_RequestHandler->UpdateDicomWebUrl(url); if (!TestConnection().get()) { MITK_INFO << "Restart did not work.."; m_Controls.connectionStatus->setText(QString("No PACS server available under given host!")); } else { MITK_INFO << "requests to pacs are sent to: " << mitk::RESTUtil::convertToUtf8(url); } } mitk::DataStorage::SetOfObjects::Pointer DicomWebView::LoadData(std::vector filePathList) { MITK_INFO << "Pushing data to data storage ..."; auto ds = GetDataStorage(); auto dataNodes = mitk::IOUtil::Load(filePathList, *ds); // reinit view mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(ds); return dataNodes; } void DicomWebView::StartServer() { utility::string_t path = U("/inject"); auto pathEnv = std::getenv("SERVER_PATH"); if (pathEnv) { path = mitk::RESTUtil::convertToTString(std::string(pathEnv)); } utility::string_t port = U(":4040"); utility::string_t address = U("http://+"); if (m_HostURL == U("http://localhost")) address = m_HostURL; address.append(port); address.append(path); // Setup listening server m_ManagerService->ReceiveRequest(address, m_RequestHandler); MITK_INFO << "Listening for requests at: " << utility::conversions::to_utf8string(address); } void DicomWebView::UploadNewSegmentation() { + auto segNote = m_Controls.segImageSelector->GetSelectedNode(); + if (!segNote) + return; AddProgress(10, {"save SEG to temp folder"}); std::string folderPathSeg = mitk::IOUtil::CreateTemporaryDirectory("XXXXXX", m_UploadBaseDir) + "/"; - const std::string savePath = folderPathSeg + m_SegC->GetName() + ".dcm"; + const std::string savePath = folderPathSeg + segNote->GetName() + ".dcm"; const std::string mimeType = mitk::MitkDICOMSEGIOMimeTypes::DICOMSEG_MIMETYPE_NAME(); - mitk::IOUtil::Save(m_SegC->GetData(), mimeType, savePath); + mitk::IOUtil::Save(segNote->GetData(), mimeType, savePath); // get Series Instance UID from new SEG auto scanner = mitk::DICOMDCMTKTagScanner::New(); mitk::DICOMTagPath seriesUID(0x0020, 0x000E); mitk::StringList files; files.push_back(savePath); scanner->SetInputFiles(files); scanner->AddTagPath(seriesUID); scanner->Scan(); mitk::DICOMDatasetAccessingImageFrameList frames = scanner->GetFrameInfoList(); auto findings = frames.front()->GetTagValueAsString(seriesUID); auto segSeriesUID = findings.front().value; AddProgress(20, {"push SEG to PACS"}); auto filePath = utility::conversions::to_string_t(savePath); try { m_RequestHandler->DicomWebGet().SendSTOW(filePath, mitk::RESTUtil::convertToTString(m_CurrentStudyUID)).then([=] { emit InvokeProgress(50, {"persist reworked SEG to evaluation database"}); - mitk::DICOMweb::MitkUriBuilder queryBuilder(m_restURL + U("/tasks/evaluations/")); - queryBuilder.append_query(U("srUID"), utility::conversions::to_string_t(m_SRUID)); - - m_ManagerService->SendRequest(queryBuilder.to_uri(), mitk::IRESTManager::RequestType::Get) - .then([=](web::json::value result) { - MITK_INFO << "after GET"; - MITK_INFO << utility::conversions::to_utf8string(result.serialize()); - auto updatedContent = result.as_array()[0]; - updatedContent[U("reworkedSegmentationUID")] = - web::json::value::string(utility::conversions::to_string_t(segSeriesUID)); - - auto id = updatedContent.at(U("id")).as_integer(); - MITK_INFO << id; - auto idParam = std::to_string(id).append("/"); - - mitk::DICOMweb::MitkUriBuilder queryBuilder(m_restURL + U("/tasks/evaluations")); - queryBuilder.append_path(utility::conversions::to_string_t(idParam)); - - m_ManagerService->SendJSONRequest(queryBuilder.to_uri(), mitk::IRESTManager::RequestType::Put, &updatedContent) - .then([=](web::json::value result) { - MITK_INFO << utility::conversions::to_utf8string(result.serialize()); - if (result[U("reworkedSegmentationUID")].as_string() == utility::conversions::to_string_t(segSeriesUID)) - { - MITK_INFO << "successfully stored"; - emit InvokeProgress(30, {"successfully stored"}); - } - }); - }); + MITK_INFO << "successfully stored"; + emit InvokeProgress(30, {"successfully stored"}); + + // TODO update content on server?? needed? + // mitk::DICOMweb::MitkUriBuilder queryBuilder(m_restURL + U("/tasks/evaluations/")); + //TODO update content on server?? needed? + //queryBuilder.append_query(U("srUID"), utility::conversions::to_string_t(m_SRUID)); + + + //m_ManagerService->SendRequest(queryBuilder.to_uri(), mitk::IRESTManager::RequestType::Get) + // .then([=](web::json::value result) { + // MITK_INFO << "after GET"; + // MITK_INFO << utility::conversions::to_utf8string(result.serialize()); + // auto updatedContent = result.as_array()[0]; + // updatedContent[U("reworkedSegmentationUID")] = + // web::json::value::string(utility::conversions::to_string_t(segSeriesUID)); + + // auto id = updatedContent.at(U("id")).as_integer(); + // MITK_INFO << id; + // auto idParam = std::to_string(id).append("/"); + + // mitk::DICOMweb::MitkUriBuilder queryBuilder(m_restURL + U("/tasks/evaluations")); + // queryBuilder.append_path(utility::conversions::to_string_t(idParam)); + + // m_ManagerService->SendJSONRequest(queryBuilder.to_uri(), mitk::IRESTManager::RequestType::Put, &updatedContent) + // .then([=](web::json::value result) { + // MITK_INFO << utility::conversions::to_utf8string(result.serialize()); + // if (result[U("reworkedSegmentationUID")].as_string() == utility::conversions::to_string_t(segSeriesUID)) + // { + // MITK_INFO << "successfully stored"; + // emit InvokeProgress(30, {"successfully stored"}); + // } + // }); + // }); }); } catch (const std::exception &exception) { std::cout << exception.what() << std::endl; } } -//std::vector DicomWebView::CreateSegmentation(mitk::Image::Pointer baseSegmentation, -// double threshold) -//{ -// MITK_INFO << "handle individual segmentation creation"; -// std::map::iterator it; -// -// std::vector sliceIndices; -// -// unsigned int count = 0; -// for (it = m_ScoreMap.begin(); it != m_ScoreMap.end(); it++) -// { -// if (it->second < threshold) -// { -// auto index = it->first; -// try -// { -// mitk::ImagePixelWriteAccessor imageAccessor(baseSegmentation); -// for (unsigned int x = 0; x < baseSegmentation->GetDimension(0); x++) -// { -// for (unsigned int y = 0; y < baseSegmentation->GetDimension(1); y++) -// { -// imageAccessor.SetPixelByIndex({{x, y, int(index)}}, 0); -// } -// } -// } -// catch (mitk::Exception &e) -// { -// MITK_ERROR << e.what(); -// } -// -// count++; -// sliceIndices.push_back(index); -// MITK_INFO << "slice " << it->first << " removed "; -// } -// } -// MITK_INFO << "slices deleted " << count; -// return sliceIndices; -//} - -void DicomWebView::CleanDicomFolder() +void DicomWebView::OnPatientSelectionChanged(QList nodes) { - if (m_SegA || m_SegB || m_SegC) + if (!nodes.empty()) { - QMessageBox::warning(nullptr, - tr("Clean dicom folder"), - tr("Please remove the data in data storage before cleaning the download folder")); + auto node = nodes.first(); + m_Controls.segImageSelector->SetNodePredicate(m_IsASegmentationImagePredicate); + + mitk::DataNode *segNode = m_Controls.segImageSelector->GetSelectedNode(); + if (segNode) + { + // Doing this we can assure that the segmenation is always visible if the segmentation and the patient image are + // loaded separately + int layer(10); + node->GetIntProperty("layer", layer); + layer++; + segNode->SetProperty("layer", mitk::IntProperty::New(layer)); + m_Controls.buttonUpload->setEnabled(true); + } + } + else + { + m_Controls.segImageSelector->SetNodePredicate(m_IsASegmentationImagePredicate); + m_Controls.buttonUpload->setEnabled(false); + } +} + +void DicomWebView::OnSegmentationSelectionChanged(QList nodes) +{ + m_Controls.buttonUpload->setEnabled(false); + if (nodes.empty()) + return; + + + auto refNode = m_Controls.patImageSelector->GetSelectedNode(); + auto segNode = nodes.front(); + + if (!refNode) return; + + if (segNode) + { + // Doing this we can assure that the segmenation is always visible if the segmentation and the patient image are + // loaded separately + int layer(10); + refNode->GetIntProperty("layer", layer); + layer++; + segNode->SetProperty("layer", mitk::IntProperty::New(layer)); + m_Controls.buttonUpload->setEnabled(true); } +} +void DicomWebView::CleanDicomFolder() +{ auto downloadDir = Poco::File(m_DownloadBaseDir); downloadDir.remove(true); } diff --git a/Plugins/org.mitk.gui.qt.dicomweb/src/internal/DicomWebView.h b/Plugins/org.mitk.gui.qt.dicomweb/src/internal/DicomWebView.h index 1aaee5aa08..ce6f0142cd 100644 --- a/Plugins/org.mitk.gui.qt.dicomweb/src/internal/DicomWebView.h +++ b/Plugins/org.mitk.gui.qt.dicomweb/src/internal/DicomWebView.h @@ -1,135 +1,141 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef DicomWebView_h #define DicomWebView_h #include #include #include #include #include "DicomWebRequestHandler.h" #include #include #include "ui_DicomWebViewControls.h" #include "mitkNodePredicateNot.h" #include "mitkNodePredicateAnd.h" #include "mitkNodePredicateOr.h" /** @brief DicomWebView This class represents the view to make connections to a PACS server and show some information to do a manual DicomWeb upon two existing segmentation volumes. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class DicomWebView : public QmitkAbstractView, public mitk::ILifecycleAwarePart //, public mitk::IRenderWindowPartListener { Q_OBJECT public: static const std::string VIEW_ID; /** * @brief Loads the files given by a list of file paths. * * @param filePathList a list of absolute file paths * @return set of objects containing the newly loaded data nodes */ mitk::DataStorage::SetOfObjects::Pointer LoadData(std::vector filePathList); /** * @brief Progress is added to the progressbar in a percent value and the given status is displayed. The progress will * not exceed 100 points. * * @param progress the progress in percent points to be added to the bar * @param status the status to be displayed after achieving the progress */ void AddProgress(int progress, QString status); /** * @brief Initializes the DICOM meta data used by this view. * * @param dto the data transfer object for received DICOM meta data. */ void InitializeDcmMeta(DicomWebRequestHandler::DicomDTO dto); virtual void Activated() override; virtual void Deactivated() override; virtual void Visible() override; virtual void Hidden() override; signals: void InvokeProgress(int, QString status); +protected slots: + void OnPatientSelectionChanged(QList nodes); + void OnSegmentationSelectionChanged(QList nodes); + + protected: virtual void CreateQtPartControl(QWidget *parent) override; void SetPredicates(); virtual void SetFocus() override; void CleanDicomFolder(); void UploadNewSegmentation(); void RestartConnection(utility::string_t newHost); void OnRestartConnection(); pplx::task TestConnection(); Ui::DicomWebViewControls m_Controls; mitk::NodePredicateNot::Pointer m_IsNotAHelperObject; mitk::NodePredicateAnd::Pointer m_IsOfTypeImagePredicate; mitk::NodePredicateOr::Pointer m_IsASegmentationImagePredicate; mitk::NodePredicateAnd::Pointer m_IsAPatientImagePredicate; + private: // std::vector CreateSegmentation(mitk::Image::Pointer baseSegmentation, double threshold); //std::string GetAlgorithmOfSegByPath(std::string path); void SetSimilarityGraph(std::vector simScoreArray, int sliceMinStart); void StartServer(); mitk::IRESTManager *m_ManagerService; DicomWebRequestHandler *m_RequestHandler; std::string m_CurrentStudyUID; std::string m_SRUID; std::string m_DownloadBaseDir; std::string m_UploadBaseDir; mitk::DataNode::Pointer m_Image; mitk::DataNode::Pointer m_SegA; mitk::DataNode::Pointer m_SegB; mitk::DataNode::Pointer m_SegC; std::map m_ScoreMap; std::string m_GroundTruth; std::string m_thresholdLabel; QWidget *m_Parent; utility::string_t m_restURL; utility::string_t m_HostURL; }; #endif // DicomWebView_h