diff --git a/CMakeLists.txt b/CMakeLists.txt index 024f456..bc5d30a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ if(DCMTK_LIBRARIES) endif() add_subdirectory(thirdparty) +add_subdirectory(DIDKit) include_directories(${DCM_NETWORK_INCLUDE_DIRS}) @@ -72,4 +73,3 @@ add_dependencies(${PROJECT_NAME} dcm_network) set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") -#set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/level='requireAdministrator' /uiAccess='false'") diff --git a/DIDKit/CMakeLists.txt b/DIDKit/CMakeLists.txt new file mode 100644 index 0000000..dc528b0 --- /dev/null +++ b/DIDKit/CMakeLists.txt @@ -0,0 +1,27 @@ +project(DIDKit) + +file(GLOB_RECURSE DIDKit_headers ../src/src/IO/*.h) +file(GLOB_RECURSE DIDKit_cpps ../src/src/IO/*.cpp) +set(BUILD_SHARED_LIBS ON) +if (${BUILD_SHARED_LIBS}) + include_directories(Defines/) +endif() +include_directories(../src/src/) + +add_library(DIDKit SHARED ${DIDKit_headers} ${DIDKit_cpps}) + +find_package(DCMTK REQUIRED) +include_directories(${DCMTK_INCLUDE_DIRS}) +target_link_libraries(DIDKit ${DCMTK_LIBRARIES}) +include_directories(${DCM_NETWORK_INCLUDE_DIRS}) + +find_package(VTK REQUIRED) +include(${VTK_USE_FILE}) +target_link_libraries(DIDKit ${VTK_LIBRARIES}) + +#add_subdirectory(dcm_network) +#include_directories(dcm_network) + +include_directories(${DCM_NETWORK_INCLUDE_DIRS}) +target_link_libraries(DIDKit dcm_network) +add_dependencies(DIDKit dcm_network) \ No newline at end of file diff --git a/src/src/Common/Helper/OrientationHelper.cpp b/src/src/Common/Helper/OrientationHelper.cpp new file mode 100644 index 0000000..39c0312 --- /dev/null +++ b/src/src/Common/Helper/OrientationHelper.cpp @@ -0,0 +1,71 @@ +// +// Created by Krad on 2022/9/20. +// + +#include "OrientationHelper.h" + +#define ORIEN_NUM 4 +#define SINGLE_INSTANCE 1 +OrientationMapType OrientationHelper::orien_map; + +std::string OrientationHelper::StringFilter(char* str) +{ + const char s[] = "\\ "; + char *token; + char *buftmp; + token = strtok_s(str, s, &buftmp); + std::string trim =""; + while (token != NULL) { + //printf("%s\n", token); + trim += token; + token = strtok_s(NULL, s, &buftmp); + } + return trim; +} + +void OrientationHelper::init() +{ + const std::string index[] = { "LH","LF","RH","RF" }; + std::vector indexList(std::begin(index), std::end(index)); + + const std::string lh[] = { "S" ,"L" ,"R" ,"I" }; + const std::string lf[] = { "I" , "L" , "R" , "S" }; + const std::string rh[] = { "S" , "R" , "L" , "I" }; + const std::string rf[] = { "I" , "R" , "L" , "S" }; + + std::vector v_lh(std::begin(lh), std::end(lh)); + std::vector v_lf(std::begin(lf), std::end(lf)); + std::vector v_rh(std::begin(rh), std::end(rh)); + std::vector v_rf(std::begin(rf), std::end(rf)); + + std::vector> retList; + retList.push_back(v_lh); + retList.push_back(v_lf); + retList.push_back(v_rh); + retList.push_back(v_rh); + + for (int i = 0; i < ORIEN_NUM; i++) + { + OrientationHelper::orien_map.insert(std::pair>(indexList.at(i), retList.at(i))); + } +} + +std::vector* OrientationHelper::getOrientationStrList(const std::string &index) +{ + + const char* s = index.c_str(); + int len = strlen(s); + char *hint = new char[len + 1]; + strcpy_s(hint, len + 1, s); + + std::string trim = StringFilter(hint); + OrientationMapType::iterator it = OrientationHelper::orien_map.find(trim); + delete hint; + + if (it == orien_map.end()) + { + + return nullptr; + } + return &(it->second); +} diff --git a/src/src/Common/Helper/OrientationHelper.h b/src/src/Common/Helper/OrientationHelper.h new file mode 100644 index 0000000..02eff1b --- /dev/null +++ b/src/src/Common/Helper/OrientationHelper.h @@ -0,0 +1,19 @@ +// +// Created by Krad on 2022/9/20. +// + +#ifndef OMEGAV_ORIENTATIONHELPER_H +#define OMEGAV_ORIENTATIONHELPER_H +#include "Common/QGlobals.h" + +using namespace std; +typedef std::map> OrientationMapType; +class OrientationHelper +{ +public: + static std::string StringFilter(char* str); + static void init(); + static std::vector* getOrientationStrList(const std::string &index); + static OrientationMapType orien_map; +}; +#endif //OMEGAV_ORIENTATIONHELPER_H diff --git a/src/src/Common/ImageSetStore.cpp b/src/src/Common/ImageSetStore.cpp new file mode 100644 index 0000000..05b23b5 --- /dev/null +++ b/src/src/Common/ImageSetStore.cpp @@ -0,0 +1,90 @@ +// +// Created by Krad on 2022/9/20. +// + +#include "ImageSetStore.h" + +#include "SeriesImageSet.h" +#include "IO/DICOM/DicomLoader.h" +#include "IO/DICOM/ExtendMedicalImageProperties.h" + +SeriesImageSet *ImageSetStore::getSeriesImageSet(const string &uniqueID) { + //only user key to the series level + if (store.count(uniqueID)>0) + { + //use cache instead load + return store[uniqueID]; + } + + auto iter = std::find_if(imageProperties.begin(), imageProperties.end(),[&uniqueID](auto property){ + return property->GetUniqueID()==uniqueID; + }); + if (iter==imageProperties.end()) return nullptr; + vtkSmartPointer pixelData; + vtkSmartPointer overlayData; + DicomLoader::InitCodecs(); + DicomLoader::getImageData(*iter, pixelData, overlayData); + SeriesImageSet* set = new SeriesImageSet(*iter,pixelData); + if (overlayData.Get()){ + set->SetOverlayData(overlayData); + } + DicomLoader::FinalizeCodecs(); + store[uniqueID] = set; + return set; +} + +void ImageSetStore::reset() { + for(auto item: store){ + delete item.second; + } + store.clear(); + for(auto item: m_patients){ + delete item.second; + } + m_patients.clear(); + if (placeHolder)placeHolder->Delete(); + placeHolder = vtkObject::New(); + imageProperties.clear(); +} + +void ImageSetStore::addImageSet(ExtendMedicalImageProperties* property) { + std::string patient_name = property->GetPatientName(); + std::string study_uid = property->GetStudyUID(); + std::string series_uid = property->GetSeriesUID(); + //patient level + PatientInfo_t* patient = nullptr; + //get from store + if (m_patients.count(patient_name)>0){ + patient = m_patients[patient_name]; + } + else{ + //create new + patient = new PatientInfo_t(); + patient->patient_name = property->GetPatientName(); + patient->birth_date = property->GetPatientBirthDate(); + patient->studies = new StudiesMapType(); + m_patients[patient_name] = patient; + } + StudyInfo_t* study = nullptr; + //get from store + if (patient->studies->count(study_uid)>0){ + study = patient->studies->at(study_uid); + } + else{ + //create new + study = new StudyInfo_t(); + patient->studies->insert({study_uid, study}); + study->study_description = property->GetStudyDescription(); + study->study_date = property->GetStudyDate(); + study->study_time = property->GetStudyTime(); + study->series = new SeriesMapType(); + } + //TODO:need add Image set logic + if (study->series->count(series_uid)>0){ + + } + else { + study->series->insert({series_uid,property}); + imageProperties.push_back(property); + } +} diff --git a/src/src/Common/ImageSetStore.h b/src/src/Common/ImageSetStore.h new file mode 100644 index 0000000..3d9515a --- /dev/null +++ b/src/src/Common/ImageSetStore.h @@ -0,0 +1,41 @@ +// +// Created by Krad on 2022/9/20. +// + +#ifndef OMEGAV_IMAGESETSTORE_H +#define OMEGAV_IMAGESETSTORE_H + +#include "Common/QGlobals.h" +class SeriesImageSet; +class ExtendMedicalImageProperties; +typedef std::map StoreMap; +class ImageSetStore { +public: + static ImageSetStore *GetInstance(){ + static ImageSetStore store; + return &store; + } + + const PatientsMapType &getPatientsList() + { + return m_patients; + } + + void addImageSet(ExtendMedicalImageProperties* property); + + SeriesImageSet* getSeriesImageSet(const std::string& uniqueID); + std::vector& getProperties(){ + return imageProperties; + } + + void reset(); +private: + std::vector imageProperties; + StoreMap store; + PatientsMapType m_patients; + vtkObject* placeHolder; +}; + + + +#endif //OMEGAV_IMAGESETSTORE_H diff --git a/src/src/Common/SeriesImageSet.cpp b/src/src/Common/SeriesImageSet.cpp index c12b449..6d8147e 100644 --- a/src/src/Common/SeriesImageSet.cpp +++ b/src/src/Common/SeriesImageSet.cpp @@ -10,9 +10,9 @@ //---------------------------------------------------------------- -SeriesImageSet::SeriesImageSet(ExtendMedicalImageProperties* property, vtkImageData* imagedata) +SeriesImageSet::SeriesImageSet(ExtendMedicalImageProperties* property, vtkImageData* imagedata):QObject(nullptr) +,m_image(imagedata) { - m_image = imagedata; m_image->SetSpacing(property->GetSpacing()); m_property = property; m_pUniqueID.append(property->GetPatientName()); diff --git a/src/src/IO/DICOM/DICOMHeaderHelper.cpp b/src/src/IO/DICOM/DICOMHeaderHelper.cpp index ccc2582..b9c9e52 100644 --- a/src/src/IO/DICOM/DICOMHeaderHelper.cpp +++ b/src/src/IO/DICOM/DICOMHeaderHelper.cpp @@ -38,9 +38,6 @@ ExtendMedicalImageProperties *DICOMHeaderHelper::GetSeriesBySeriesUID(const char void DICOMHeaderHelper::Clear() { dirName.clear(); fileName.clear(); - for (auto property : seriesProperties) { - property->Delete(); - } seriesProperties.clear(); SeriesCount = 0; } diff --git a/src/src/IO/DICOM/DicomLoader.cpp b/src/src/IO/DICOM/DicomLoader.cpp index 28d9363..bae0371 100644 --- a/src/src/IO/DICOM/DicomLoader.cpp +++ b/src/src/IO/DICOM/DicomLoader.cpp @@ -1,241 +1,59 @@ #include "DicomLoader.h" -#include -#include -#include -#include -#include -#include +#include +#include -#include "Common/SeriesImageSet.h" #include "DICOMHeaderHelper.h" +#include "DICOMPixelDataHelper.h" #include "vtkDCMTKImageReader.h" -#define ORIEN_NUM 4 -#define SINGLE_INSTANCE 1 -OrientationMapType orientationHelper::orien_map; -/************************************************************************ -* [Q]Is there anything different between these two? -* instance->m_image = m_itkConnector->GetOutput(); -* instance->m_image->DeepCopy(m_itkConnector->GetOutput()); -* [Q]I have no idea why it works just fine not using deep copy, - while the vtkdata is replaced in the Qfusion Project using exatly the same workflow! -/************************************************************************/ -std::string orientationHelper::StringFilter(char* str) -{ - const char s[] = "\\ "; - char *token; - char *buftmp; - token = strtok_s(str, s, &buftmp); - std::string trim =""; - while (token != NULL) { - //printf("%s\n", token); - trim += token; - token = strtok_s(NULL, s, &buftmp); - } - return trim; -} - -void orientationHelper::init() -{ - const std::string index[] = { "LH","LF","RH","RF" }; - std::vector indexList(std::begin(index), std::end(index)); - - const std::string lh[] = { "S" ,"L" ,"R" ,"I" }; - const std::string lf[] = { "I" , "L" , "R" , "S" }; - const std::string rh[] = { "S" , "R" , "L" , "I" }; - const std::string rf[] = { "I" , "R" , "L" , "S" }; - - std::vector v_lh(std::begin(lh), std::end(lh)); - std::vector v_lf(std::begin(lf), std::end(lf)); - std::vector v_rh(std::begin(rh), std::end(rh)); - std::vector v_rf(std::begin(rf), std::end(rf)); - - std::vector> retList; - retList.push_back(v_lh); - retList.push_back(v_lf); - retList.push_back(v_rh); - retList.push_back(v_rh); - - for (int i = 0; i < ORIEN_NUM; i++) - { - orientationHelper::orien_map.insert(std::pair>(indexList.at(i), retList.at(i))); - } -} - -std::vector* orientationHelper::getOrientationStrList(const std::string &index) -{ - - const char* s = index.c_str(); - int len = strlen(s); - char *hint = new char[len + 1]; - strcpy_s(hint, len + 1, s); - - std::string trim = StringFilter(hint); - OrientationMapType::iterator it = orientationHelper::orien_map.find(trim); - delete hint; - - if (it == orien_map.end()) - { - - return nullptr; - } - return &(it->second); -} - -DicomLoader* DicomLoader::instance = new DicomLoader(); -DicomLoader* DicomLoader::GetInstance() { - //lazy man - //if (!instance) { - // instance = new DicomLoader(); - //} - //hungry man - return instance; -} - -DicomLoader::DicomLoader(){ - -// m_itkSeriesReader = SeriesReaderType::New(); -// m_itkConnector = ConnectorType::New(); -// m_gdcmIO = ImageIOType::New(); -// m_inputNames = InputNamesGeneratorType::New(); - - reader = nullptr; - //transfer to series after! - m_patients.clear(); - placeHolder = vtkObject::New(); - defaultUniqueID = ""; -} -DicomLoader::~DicomLoader() { - - placeHolder->Delete(); - imageProperties.clear(); -} - - -SeriesImageSet* DicomLoader::getSeriesImageSet(const std::string& uniqueID)//, DicomTagInfo_t* tag_info) -{ - //only user key to the series level - if (store.count(uniqueID)>0) - { - //use cache instead load - return store[uniqueID]; - } - if (reader) reader->Delete(); - reader = vtkDCMTKImageReader::New(); - auto iter = std::find_if(imageProperties.begin(), imageProperties.end(),[&uniqueID](auto property){ - return property->GetUniqueID()==uniqueID; - }); - if (iter==imageProperties.end()) return nullptr; - -// reader->SetFileNames((*iter)->GetFileNames()); - reader->SetImageProperties((*iter)); - reader->Update(); - auto imageData = reader->GetOutput(); - SeriesImageSet* result = new SeriesImageSet((*iter),imageData); - if (reader->GetHasOverlay()){ - result->SetOverlayData(reader->GetOutputOverLayData()); - } -// imageData->Register(placeHolder); - reader->Delete(); - reader = nullptr; - store[uniqueID] = result; - return result; -} - - -void DicomLoader::readTags(const std::string &dir, SeriesOpenMode openMode) -{ +void DicomLoader::readPropertiesFromDir(const std::string &dir, + std::vector& properties, int& count) { DICOMHeaderHelper DICOMHelper; - if (openMode == FILE_OPEN_MODE) - { - //m_itkSeriesReader->SetFileName(m_dicomName.toStdString()); - DICOMHelper.SetFileName(dir.c_str()); - } - if (openMode == DIR_OPEN_MODE) - { - DICOMHelper.SetDirName(dir.c_str()); - } - DICOMHelper.Update(); + DICOMHelper.SetDirName(dir.c_str()); + DICOMHelper.Update(); + count = DICOMHelper.GetSeriesCount(); if ( DICOMHelper.GetSeriesCount()>0){ for (auto item : DICOMHelper.GetSeriesProperties()) { - item->Register(placeHolder); - imageProperties.push_back(item); + properties.push_back(item); } } - if ( imageProperties.size() > 0 ) { - currentImageProperty = imageProperties[0]; - defaultUniqueID = currentImageProperty->GetUniqueID(); - readSeries(); - } } - -void DicomLoader::readSeries() { - - for (ExtendMedicalImageProperties* property: imageProperties){ - - std::string patient_name = property->GetPatientName(); - std::string study_uid = property->GetStudyUID(); - std::string series_uid = property->GetSeriesUID(); - //patient level - PatientInfo_t* patient = nullptr; - //get from store - if (m_patients.count(patient_name)>0){ - patient = m_patients[patient_name]; +void DicomLoader::readPropertiesFromFile(const std::string &file, + std::vector& properties, int& count) { + DICOMHeaderHelper DICOMHelper; + DICOMHelper.SetFileName(file.c_str()); + DICOMHelper.Update(); + count = DICOMHelper.GetSeriesCount(); + if ( DICOMHelper.GetSeriesCount()>0){ + for (auto item : DICOMHelper.GetSeriesProperties()) { + properties.push_back(item); } - else{ - //create new - patient = new PatientInfo_t(); - patient->patient_name = property->GetPatientName(); - patient->birth_date = property->GetPatientBirthDate(); - patient->studies = new StudiesMapType(); - m_patients[patient_name] = patient; - } - StudyInfo_t* study = nullptr; - //get from store - if (patient->studies->count(study_uid)>0){ - study = patient->studies->at(study_uid); - } - else{ - //create new - study = new StudyInfo_t(); - patient->studies->insert({study_uid, study}); - study->study_description = property->GetStudyDescription(); - study->study_date = property->GetStudyDate(); - study->study_time = property->GetStudyTime(); - study->series = new SeriesMapType(); - } - if (study->series->count(series_uid)>0){ -// series = study->series->at(series_uid); - //TODO:need to add override logic!! - } - else { - study->series->insert({series_uid,property}); - -// double *wlww = property->GetNthWindowLevelPreset(0); -// int ww = wlww ? ((int) wlww[0]) : (512); -// int wl = wlww ? ((int) wlww[1]) : (256); - } - } } -void DicomLoader::reset() { - - currentImageProperty = nullptr; - reader = nullptr; - for(auto item: store){ - delete item.second; - } - store.clear(); - for(auto item: m_patients){ - delete item.second; - } - m_patients.clear(); - placeHolder->Delete(); - placeHolder = vtkObject::New(); - imageProperties.clear(); +void DicomLoader::getImageData(ExtendMedicalImageProperties *property, + vtkSmartPointer& pixelData, vtkSmartPointer& overlayData) { + vtkNew reader; + reader->SetImageProperties(property); + reader->Update(); + pixelData = reader->GetOutput(); + overlayData = reader->GetOutputOverLayData(); +} + +void DicomLoader::InitCodecs() { + DICOMPixelDataHelper::InitCodecs(); +} + +void DicomLoader::FinalizeCodecs() { + DICOMPixelDataHelper::FinalizeCodecs(); +} + +void DicomLoader::getThumbnailData(ExtendMedicalImageProperties* property,void*& data, int& sample) { + unsigned long l ; + DICOMPixelDataHelper::GetThumbnailData(property, data,l,sample); + } diff --git a/src/src/IO/DICOM/DicomLoader.h b/src/src/IO/DICOM/DicomLoader.h index 3021e6b..ae46e9a 100644 --- a/src/src/IO/DICOM/DicomLoader.h +++ b/src/src/IO/DICOM/DicomLoader.h @@ -1,77 +1,32 @@ #ifndef OMEGAV_DICOMLOADER_H #define OMEGAV_DICOMLOADER_H -#pragma once +#include +#include +#include -#include "Common/QGlobals.h" - -using namespace std; -typedef std::map> OrientationMapType; -class orientationHelper -{ -public: - static std::string StringFilter(char* str); - static void init(); - static std::vector* getOrientationStrList(const std::string &index); - static OrientationMapType orien_map; -}; - -class SeriesImageSet; - - -class DICOMHeaderHelper; class ExtendMedicalImageProperties; -class vtkDCMTKImageReader; -typedef std::map ImageSetStore; +class vtkImageData; class DicomLoader { public: + static void InitCodecs(); - static DicomLoader *GetInstance(); + static void FinalizeCodecs(); - /** - * 读取数据Tag - * @param dir - * @param openMode - */ - void readTags(const std::string &dir, SeriesOpenMode openMode); + static void readPropertiesFromDir(const std::string &dir, + std::vector& properties, int& count); - const std::string& getDefaultUniqueID(){ - return defaultUniqueID; - } + static void readPropertiesFromFile(const std::string &file, + std::vector& properties, int& count); - const PatientsMapType &getPatientsList() - { - return m_patients; - } - - SeriesImageSet* getSeriesImageSet(const std::string& uniqueID); - - void reset(); + static void getImageData(ExtendMedicalImageProperties* property, + vtkSmartPointer& pixelData, vtkSmartPointer& overlayData); + static void getThumbnailData(ExtendMedicalImageProperties* property,void*& data, int& sample); private: - explicit DicomLoader(); - ~DicomLoader(); - - /** - * 本函数根据DICOM文件TagValue来构建一个树状的PSSI结构 - * 即:Patient-Study-Series-Image - * 主要用途是为左侧的thumbnail bar 做数据支撑 - * TODO:目前Image层暂缺 - */ - void readSeries(); - - static DicomLoader *instance; - - //once - - ExtendMedicalImageProperties * currentImageProperty = nullptr; - std::vector imageProperties; - vtkDCMTKImageReader * reader = nullptr; - ImageSetStore store; - std::string defaultUniqueID; - PatientsMapType m_patients; - vtkObject* placeHolder; + DicomLoader() = delete; + ~DicomLoader() = delete; }; #endif OMEGAV_DICOMLOADER_H diff --git a/src/src/IO/Defines/DIDKitExport.h b/src/src/IO/Defines/DIDKitExport.h new file mode 100644 index 0000000..e42b34e --- /dev/null +++ b/src/src/IO/Defines/DIDKitExport.h @@ -0,0 +1,19 @@ +// +// Created by Krad on 2022/9/19. +// + +#ifndef OMEGAV_DIDKITEXPORT_H +#define OMEGAV_DIDKITEXPORT_H + +#ifdef _WIN32 +#ifdef DIDKIT_SHARED +/* Defines needed for building DLLs on windows */ +#define DIDKIT_EXPORT __declspec(dllexport) +#elif USE_DIDKIT +/* Defines needed for use DLLs on windows */ +#define DIDKIT_EXPORT __declspec(dllimport) +#else +#define DIDKIT_EXPORT +#endif +#endif +#endif //OMEGAV_DIDKITEXPORT_H diff --git a/src/src/UI/Manager/ImageViewManager.cpp b/src/src/UI/Manager/ImageViewManager.cpp index e8eec2a..f86031a 100644 --- a/src/src/UI/Manager/ImageViewManager.cpp +++ b/src/src/UI/Manager/ImageViewManager.cpp @@ -9,7 +9,7 @@ #include #include -#include "IO/DICOM/DicomLoader.h" +#include "Common/ImageSetStore.h" #include "Interaction/ActorDraggableInteractorStyle.h" #include "Rendering/Measure/MeasureFactory.h" #include "UI/Widget/ImageView/ViewContainerWidget.h" @@ -359,7 +359,7 @@ void ImageViewManager::viewEndWindowLevel(DicomImageView *src, double level, dou void ImageViewManager::viewReload(const std::string &unique_info) { if (!currentView) return; currentView->unloadFusion(); - DicomLoader *helper = DicomLoader::GetInstance(); + ImageSetStore *helper = ImageSetStore::GetInstance(); currentView->loadSeries(helper->getSeriesImageSet(unique_info)); currentView->render(); reloadCurrentView(currentView); diff --git a/src/src/UI/Widget/Thumbnail/thumbnailImage.cpp b/src/src/UI/Widget/Thumbnail/thumbnailImage.cpp index 575b647..c9090d9 100644 --- a/src/src/UI/Widget/Thumbnail/thumbnailImage.cpp +++ b/src/src/UI/Widget/Thumbnail/thumbnailImage.cpp @@ -3,7 +3,7 @@ #include #include "qstyleoption.h" #include "qpainter.h" -#include "IO/DICOM/DICOMPixelDataHelper.h" +#include "IO/DICOM/DicomLoader.h" static QString unpick_style = "*{background-color:#7f7f7f;}" "QLabel#m_descri{color:white}"; @@ -134,9 +134,8 @@ thumbnailImage::~thumbnailImage() void thumbnailImage::drawThumbnail() { if (m_Data) free(m_Data); m_Data = nullptr; - unsigned long length = 0; int sample = 0; - DICOMPixelDataHelper::GetThumbnailData(seriesProperty, m_Data, length, sample); + DicomLoader::getThumbnailData(seriesProperty, m_Data, sample); QImage image( (uchar*)m_Data, seriesProperty->GetColumns(), seriesProperty->GetRows(), sample == 1 ? QImage::Format_Grayscale8 : QImage::Format_RGB888);//使用8位深度的灰度图做输出 image = image.scaledToHeight(100); diff --git a/src/src/UI/Widget/Thumbnail/thumbnailbarwidget.cpp b/src/src/UI/Widget/Thumbnail/thumbnailbarwidget.cpp index d037c4a..a588e9b 100644 --- a/src/src/UI/Widget/Thumbnail/thumbnailbarwidget.cpp +++ b/src/src/UI/Widget/Thumbnail/thumbnailbarwidget.cpp @@ -5,8 +5,8 @@ #include #include +#include "Common/ImageSetStore.h" #include "IO/DICOM/DicomLoader.h" -#include "IO/DICOM/DICOMPixelDataHelper.h" #include "Common/SeriesImageSet.h" #include "UI/Widget/ImageView/dicomimageview.h" @@ -84,7 +84,7 @@ void ThumbnailBarWidget::updateThumbnailBar() } clear(); bool firstThumbnail = true; - DicomLoader *helper = DicomLoader::GetInstance(); + ImageSetStore *helper = ImageSetStore::GetInstance(); //获取Patient const PatientsMapType & all_patients = helper->getPatientsList(); for (PatientsMapType::const_iterator it_pa = all_patients.cbegin(); it_pa != all_patients.cend(); it_pa++) { @@ -116,7 +116,7 @@ void ThumbnailBarWidget::updateThumbnailBar() SeriesMapType *series = it_st->second->series; - DICOMPixelDataHelper::InitCodecs(); + DicomLoader::InitCodecs(); for (SeriesMapType::const_iterator it_se = series->cbegin(); it_se != series->cend(); it_se++) { thumbnailImage *thumbnail = createThumbnailImage(seriesPanel, it_se->second); @@ -128,7 +128,7 @@ void ThumbnailBarWidget::updateThumbnailBar() //save all thumbnail in one list LabelList << thumbnail; } - DICOMPixelDataHelper::FinalizeCodecs(); + DicomLoader::FinalizeCodecs(); } } } diff --git a/src/src/UI/Window/QDicomViewer.cpp b/src/src/UI/Window/QDicomViewer.cpp index 54d2af6..06b5a7b 100644 --- a/src/src/UI/Window/QDicomViewer.cpp +++ b/src/src/UI/Window/QDicomViewer.cpp @@ -7,6 +7,9 @@ #include +#include "Common/Helper/OrientationHelper.h" +#include "Common/ImageSetStore.h" +#include "IO/DICOM/DicomLoader.h" #include "Interaction/ActorDraggableInteractorStyle.h" #include "UI/Manager/ImageViewManager.h" #include "UI/Widget/Component/gridpopwidget.h" @@ -39,7 +42,7 @@ QDicomViewer::QDicomViewer(QWidget *parent) : QMainWindow(parent), displayThumbnailBar(false); //TODO:目前为方向是写死的正交方向 - orientationHelper::init(); + OrientationHelper::init(); } QDicomViewer::~QDicomViewer() { @@ -272,14 +275,24 @@ void QDicomViewer::openDICOM(const std::string &dicomName, SeriesOpenMode openMo //必须首先重置成1个窗口的布局 ui->viewContainer->resetLayoutToSingle(); - //数据读取 - DicomLoader *helper = DicomLoader::GetInstance(); - helper->reset(); - //load image and tag - helper->readTags(dicomName, openMode); - auto unique = helper->getDefaultUniqueID(); - ui->viewContainer->getViewManager()->viewReload(unique); + //reset store + ImageSetStore *helper = ImageSetStore::GetInstance(); + helper->reset(); + + int count = 0; + std::vector vector; + if (openMode == SeriesOpenMode::DIR_OPEN_MODE){ + DicomLoader::readPropertiesFromDir(dicomName, vector,count); + }else{ + DicomLoader::readPropertiesFromFile(dicomName, vector, count); + } + for (int i = 0; i < count; ++i) { + helper->addImageSet(vector[i]); + } + if (count > 0){ + ui->viewContainer->getViewManager()->viewReload(vector[0]->GetUniqueID()); + } ui->thumbnailBar->updateThumbnailBar(); }