Refactor Code ,change SeriesInstance to SeriesImageSet, add property to SeriesImageSet.
This commit is contained in:
@@ -13,7 +13,7 @@ public:
|
|||||||
static OrientationMapType orien_map;
|
static OrientationMapType orien_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SeriesInstance;
|
class SeriesImageSet;
|
||||||
|
|
||||||
|
|
||||||
class DICOMDirectoryHelper;
|
class DICOMDirectoryHelper;
|
||||||
@@ -41,9 +41,8 @@ public:
|
|||||||
UniqueIDInfo_t* createUniqueID(const std::string &dicomName, SeriesOpenMode openMode);
|
UniqueIDInfo_t* createUniqueID(const std::string &dicomName, SeriesOpenMode openMode);
|
||||||
bool IsDuplicate(UniqueIDInfo_t* unique);
|
bool IsDuplicate(UniqueIDInfo_t* unique);
|
||||||
|
|
||||||
//set imagedata from reader and set viewer
|
|
||||||
SeriesInstance* createSeries(UniqueIDInfo_t* uniqueID, DicomTagInfo_t* tag_info,
|
SeriesImageSet *createSeries(UniqueIDInfo_t *uniqueID);
|
||||||
vtkGenericOpenGLRenderWindow* gl_rewin, bool copy = false);
|
|
||||||
AddDicomType getAddDicomType()const
|
AddDicomType getAddDicomType()const
|
||||||
{
|
{
|
||||||
return m_addType;
|
return m_addType;
|
||||||
@@ -55,25 +54,16 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//if not duplicate
|
//if not duplicate
|
||||||
void InitFromRead(SeriesInstance* instance);// , DicomTagInfo_t* tag_info);
|
SeriesImageSet* InitFromRead(const UniqueIDInfo &uniqueID);// , DicomTagInfo_t* tag_info);
|
||||||
void InitFromCopy(SeriesInstance* instance);
|
|
||||||
|
|
||||||
|
|
||||||
bool deleteSeriesInstance(SeriesInstance* old);
|
|
||||||
|
|
||||||
// load series data to m_patient
|
|
||||||
SeriesInstance* addSeriesInstance(SeriesInstance* instance, bool copy =false);
|
|
||||||
|
|
||||||
SeriesInfo_t* getSerieInfo(const UniqueIDInfo &uniqueID);
|
SeriesInfo_t* getSerieInfo(const UniqueIDInfo &uniqueID);
|
||||||
SeriesInstance* getFirstInstance(const UniqueIDInfo &uniqueID);
|
SeriesImageSet* getFirstInstance(const UniqueIDInfo &uniqueID);
|
||||||
InstancesVecType* getInstancesVec(const UniqueIDInfo &uniqueID);
|
InstancesVecType* getInstancesVec(const UniqueIDInfo &uniqueID);
|
||||||
//for export use
|
//for export use
|
||||||
void getOpenedInstancesVec(InstancesVecType& retVec);
|
void getOpenedInstancesVec(InstancesVecType& retVec);
|
||||||
|
|
||||||
//void deleteSeriesInstance(SeriesInstance* instance,bool from_map = true);
|
//void deleteSeriesInstance(SeriesImageSet* instance,bool from_map = true);
|
||||||
void deleteInstanceFromMap(UniqueIDInfo uniqueID);
|
void deleteInstanceFromMap(UniqueIDInfo uniqueID);
|
||||||
void setDirObservers(void* client);
|
|
||||||
void setFileObservers(void* client);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DicomLoader();
|
explicit DicomLoader();
|
||||||
|
|||||||
@@ -6,56 +6,47 @@
|
|||||||
//#include "QVTKWidget.h"
|
//#include "QVTKWidget.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class myQVTKOpenGLNativeWidget;
|
|
||||||
class DicomLoader;
|
|
||||||
|
|
||||||
class SeriesInstance :public QObject
|
|
||||||
|
class ExtendMedicalImageProperties;
|
||||||
|
|
||||||
|
class SeriesImageSet : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class DicomLoader;
|
friend class DicomLoader;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SeriesInstance::SeriesInstance(UniqueIDInfo_t* uniqueID, DicomTagInfo_t* tag_info,
|
SeriesImageSet::SeriesImageSet(const UniqueIDInfo_t& uniqueID,ExtendMedicalImageProperties* property, vtkImageData* imagedata);
|
||||||
vtkGenericOpenGLRenderWindow* glrenWin);
|
~SeriesImageSet() override;
|
||||||
~SeriesInstance();
|
|
||||||
|
|
||||||
|
|
||||||
void setUpSeriesInstance();
|
void setUpSeriesInstance();
|
||||||
|
|
||||||
//UniqueID
|
//UniqueID
|
||||||
UniqueIDInfo_t* getUniqueID()const {
|
UniqueIDInfo_t* getUniqueID() {
|
||||||
return m_pUniqueID;
|
return &m_pUniqueID;
|
||||||
};
|
|
||||||
SeriesOpenMode getSerirsOpenMode() const
|
|
||||||
{
|
|
||||||
return m_pUniqueID->open_mode;
|
|
||||||
};
|
};
|
||||||
const char* getCurImageName()const;
|
const char* getCurImageName()const;
|
||||||
const char* getCurSeriesName() const;
|
const char* getCurSeriesName() const;
|
||||||
|
|
||||||
|
|
||||||
//SeriesTags
|
|
||||||
DicomTagInfo_t* getDicomTagInfo()const
|
|
||||||
{
|
|
||||||
return m_pSeriesTags;
|
|
||||||
}
|
|
||||||
int GetSeriesNumber()const
|
int GetSeriesNumber()const
|
||||||
{
|
{
|
||||||
return atoi(m_pSeriesTags->m_SeriesNumber.c_str());
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
infinitiViewer* getImageViewer2()
|
|
||||||
{
|
|
||||||
return m_imageViewer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//image data
|
//image data
|
||||||
QPixmap GetPixmap();
|
|
||||||
vtkImageData* GetData()
|
vtkImageData* GetData()
|
||||||
{
|
{
|
||||||
return m_image;
|
return m_image;
|
||||||
};
|
};
|
||||||
|
//image data
|
||||||
|
ExtendMedicalImageProperties* GetProperty()
|
||||||
|
{
|
||||||
|
return m_property;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//camera config
|
//camera config
|
||||||
@@ -81,21 +72,11 @@ private:
|
|||||||
QSize labelSizeHint() const {
|
QSize labelSizeHint() const {
|
||||||
return QSize(image_label_size, image_label_size);
|
return QSize(image_label_size, image_label_size);
|
||||||
}
|
}
|
||||||
QImage vtkImageDataToQImage(vtkImageData* imageData);
|
|
||||||
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkGenericOpenGLRenderWindow> m_glrenWin;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vtkSmartPointer <infinitiViewer> m_imageViewer;
|
|
||||||
vtkSmartPointer <vtkImageData> m_image;
|
vtkSmartPointer <vtkImageData> m_image;
|
||||||
//vtkSmartPointer <vtkImageData> m_overlap;
|
ExtendMedicalImageProperties* m_property = nullptr;
|
||||||
|
|
||||||
FileNamesContainerType m_fileNames;
|
UniqueIDInfo_t m_pUniqueID;
|
||||||
|
|
||||||
DicomTagInfo_t* m_pSeriesTags;
|
|
||||||
UniqueIDInfo_t* m_pUniqueID;
|
|
||||||
|
|
||||||
|
|
||||||
static qint32 image_label_size;
|
static qint32 image_label_size;
|
||||||
@@ -23,7 +23,6 @@ class ExportDialog : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit ExportDialog(QWidget *parent = nullptr);
|
explicit ExportDialog(QWidget *parent = nullptr);
|
||||||
~ExportDialog();
|
~ExportDialog();
|
||||||
//void setCurSeries(SeriesInstance *serie);
|
|
||||||
//void setViewContainer(ViewContainerWidget *widget)
|
//void setViewContainer(ViewContainerWidget *widget)
|
||||||
void setCurView(DicomImageView *view);
|
void setCurView(DicomImageView *view);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <qsize.h>
|
#include <qsize.h>
|
||||||
#include <qlist.h>
|
#include <qlist.h>
|
||||||
|
|
||||||
class SeriesInstance;
|
class SeriesImageSet;
|
||||||
|
|
||||||
class ExportOptions
|
class ExportOptions
|
||||||
{
|
{
|
||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
QSize customPictureSize;//apply when user choose customsize
|
QSize customPictureSize;//apply when user choose customsize
|
||||||
|
|
||||||
SeriesInstance *serie;
|
SeriesImageSet *serie;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXPORTOPTIONS_H
|
#endif // EXPORTOPTIONS_H
|
||||||
@@ -40,7 +40,7 @@ const double scalarSensitivity = 4.0;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SeriesInstance;
|
class SeriesImageSet;
|
||||||
class thumbnailImage;
|
class thumbnailImage;
|
||||||
|
|
||||||
enum DicomModality
|
enum DicomModality
|
||||||
@@ -382,7 +382,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector <SeriesInstance*> InstancesVecType;
|
typedef std::vector <SeriesImageSet*> InstancesVecType;
|
||||||
|
|
||||||
typedef struct SeriesInfo
|
typedef struct SeriesInfo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include "base/SeriesInstance.h"
|
#include "base/SeriesImageSet.h"
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
class infinitiViewer;
|
class infinitiViewer;
|
||||||
@@ -56,10 +56,10 @@ public:
|
|||||||
void Render();
|
void Render();
|
||||||
|
|
||||||
//Series
|
//Series
|
||||||
void setDicomImageView(SeriesInstance *series);
|
void setDicomImageView(SeriesImageSet *series);
|
||||||
bool HasSeries();
|
bool HasSeries();
|
||||||
int getSeriesNumber();
|
int getSeriesNumber();
|
||||||
SeriesInstance* getSeriesInstance()
|
SeriesImageSet* getSeriesInstance()
|
||||||
{
|
{
|
||||||
return _Series;
|
return _Series;
|
||||||
}
|
}
|
||||||
@@ -205,14 +205,13 @@ private:
|
|||||||
void orphanizeSeriesInstance();
|
void orphanizeSeriesInstance();
|
||||||
void ResetPanZoom();
|
void ResetPanZoom();
|
||||||
|
|
||||||
//bool deleteOlderSeries(SeriesInstance* old);
|
|
||||||
void initScrollbar();
|
void initScrollbar();
|
||||||
void CopyFromSeries(SeriesInstance *series);
|
void CopyFromSeries(SeriesImageSet *series);
|
||||||
|
|
||||||
vtkSmartPointer <vtkGenericOpenGLRenderWindow> m_glrenWin;
|
vtkSmartPointer <vtkGenericOpenGLRenderWindow> m_glrenWin;
|
||||||
|
|
||||||
infinitiViewer* _ImageViewer = nullptr;
|
infinitiViewer* _ImageViewer = nullptr;
|
||||||
SeriesInstance* _Series =nullptr;
|
SeriesImageSet* _Series = nullptr;
|
||||||
QScrollBar* _scrollBar =nullptr;
|
QScrollBar* _scrollBar =nullptr;
|
||||||
MyTitleBar *_titleBar =nullptr;
|
MyTitleBar *_titleBar =nullptr;
|
||||||
QVTKOpenGLNativeWidget* _glWidt = nullptr;
|
QVTKOpenGLNativeWidget* _glWidt = nullptr;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "QScrollArea.h"
|
#include "QScrollArea.h"
|
||||||
|
|
||||||
class ImageInstance;
|
class ImageInstance;
|
||||||
class SeriesInstance;
|
class SeriesImageSet;
|
||||||
class thumbnailImage;
|
class thumbnailImage;
|
||||||
class DicomImageView;
|
class DicomImageView;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include "global/QGlobals.h"
|
#include "global/QGlobals.h"
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
class QGridLayout;
|
class QGridLayout;
|
||||||
class DicomImageView;
|
class DicomImageView;
|
||||||
class SeriesInstance;
|
class SeriesImageSet;
|
||||||
|
|
||||||
class ViewContainerWidget : public QFrame {
|
class ViewContainerWidget : public QFrame {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
~ViewContainerWidget();
|
~ViewContainerWidget();
|
||||||
|
|
||||||
|
|
||||||
SeriesInstance* getCurrentSeries() const;
|
SeriesImageSet* getCurrentSeries() const;
|
||||||
DicomImageView* getCurrentView() const;
|
DicomImageView* getCurrentView() const;
|
||||||
DicomImageView* getNextView() const;
|
DicomImageView* getNextView() const;
|
||||||
QList<DicomImageView*> getViewList() const;
|
QList<DicomImageView*> getViewList() const;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "QDicomViewer.h"
|
#include "QDicomViewer.h"
|
||||||
#include "global/include_all.h"
|
#include "global/include_all.h"
|
||||||
#include "base/seriesinstance.h"
|
#include "base/SeriesImageSet.h"
|
||||||
#include "view/subview/gridpopwidget.h"
|
#include "view/subview/gridpopwidget.h"
|
||||||
#include "view/ViewContainerWidget.h"
|
#include "view/ViewContainerWidget.h"
|
||||||
#include "base/DicomLoader.h"
|
#include "base/DicomLoader.h"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include "base/seriesinstance.h"
|
#include "base/SeriesImageSet.h"
|
||||||
#include "DICOMDirectoryHelper.h"
|
#include "DICOMDirectoryHelper.h"
|
||||||
#include "ExtendMedicalImageProperties.h"
|
#include "ExtendMedicalImageProperties.h"
|
||||||
#include "vtkDICOMImageReader2.h"
|
#include "vtkDICOMImageReader2.h"
|
||||||
@@ -152,44 +152,18 @@ bool DicomLoader::IsDuplicate(UniqueIDInfo_t* unique)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//该函数所在的逻辑分支暂时不存在!!!
|
|
||||||
void DicomLoader::InitFromCopy(SeriesInstance* instance)
|
|
||||||
{
|
|
||||||
//copy data from existing instance!
|
|
||||||
UniqueIDInfo_t* unique = instance->getUniqueID();
|
|
||||||
//SeriesInfo_t* serie_info = getSerieInfo(*unique);
|
|
||||||
SeriesInstance *exists = getFirstInstance(*unique);
|
|
||||||
//DicomTagInfo_t *tag_info = serie_info->tag_info;
|
|
||||||
//instance->setDicomTagInfo(exists->getDicomTagInfo());
|
|
||||||
|
|
||||||
//copyDicomTagsInfo(exists, instance);
|
|
||||||
//smart pointer reference count++
|
|
||||||
instance->m_image = exists->m_image;
|
|
||||||
|
|
||||||
if (exists->getUniqueID()->open_mode == DIR_OPEN_MODE)
|
SeriesImageSet* DicomLoader::InitFromRead(const UniqueIDInfo &uniqueID)//, DicomTagInfo_t* tag_info)
|
||||||
{
|
|
||||||
//vector deep copy
|
|
||||||
//exists->m_fileNames = instance->m_fileNames;This is a bug<75><67>
|
|
||||||
instance->m_fileNames = exists->m_fileNames;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DicomLoader::InitFromRead(SeriesInstance* instance)//, DicomTagInfo_t* tag_info)
|
|
||||||
{
|
{
|
||||||
if (reader) reader->Delete();
|
if (reader) reader->Delete();
|
||||||
reader = vtkDICOMImageReader2::New();
|
reader = vtkDICOMImageReader2::New();
|
||||||
reader->SetFileNames(*(currentImageProperty->GetFileNames()));
|
reader->SetFileNames(*(currentImageProperty->GetFileNames()));
|
||||||
reader->Update();
|
reader->Update();
|
||||||
instance->m_image = reader->GetOutput();
|
SeriesImageSet* result = new SeriesImageSet(uniqueID,currentImageProperty,reader->GetOutput());
|
||||||
|
|
||||||
if (instance->getUniqueID()->open_mode == DIR_OPEN_MODE) {
|
|
||||||
auto files = reader->GetDICOMFileNames();
|
|
||||||
std::for_each(files->begin(), files->end(), [=](auto v) {
|
|
||||||
instance->m_fileNames.push_back(v);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
reader->Delete();
|
reader->Delete();
|
||||||
reader = nullptr;
|
reader = nullptr;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 无用函数
|
// 无用函数
|
||||||
@@ -203,7 +177,7 @@ void DicomLoader::deleteInstanceFromMap(UniqueIDInfo uniqueID)
|
|||||||
|
|
||||||
//in order
|
//in order
|
||||||
SeriesInfo_t* the_series = cur_study_iter->second->series->at(uniqueID.series_uid);
|
SeriesInfo_t* the_series = cur_study_iter->second->series->at(uniqueID.series_uid);
|
||||||
//SeriesInstance *cur_series = cur_study_iter->second->series->at(uniqueID.series_uid);
|
//SeriesImageSet *cur_series = cur_study_iter->second->series->at(uniqueID.series_uid);
|
||||||
|
|
||||||
|
|
||||||
//delete all the instances assotiated with this series UID
|
//delete all the instances assotiated with this series UID
|
||||||
@@ -274,7 +248,7 @@ void DicomLoader::getOpenedInstancesVec(InstancesVecType& retVec)
|
|||||||
cur_series->end(); cur_series_iter++)
|
cur_series->end(); cur_series_iter++)
|
||||||
{
|
{
|
||||||
//default export instance: the recently added one
|
//default export instance: the recently added one
|
||||||
SeriesInstance *last = cur_series_iter->second->instances->back();
|
SeriesImageSet *last = cur_series_iter->second->instances->back();
|
||||||
if(nullptr!=last)
|
if(nullptr!=last)
|
||||||
{
|
{
|
||||||
retVec.push_back(last);
|
retVec.push_back(last);
|
||||||
@@ -285,7 +259,7 @@ void DicomLoader::getOpenedInstancesVec(InstancesVecType& retVec)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SeriesInstance* DicomLoader::getFirstInstance(const UniqueIDInfo &uniqueID)
|
SeriesImageSet* DicomLoader::getFirstInstance(const UniqueIDInfo &uniqueID)
|
||||||
{
|
{
|
||||||
PatientsMapType::iterator cur_patient_iter = m_patients.find(uniqueID.patient_name);
|
PatientsMapType::iterator cur_patient_iter = m_patients.find(uniqueID.patient_name);
|
||||||
if (cur_patient_iter == m_patients.end())
|
if (cur_patient_iter == m_patients.end())
|
||||||
@@ -331,36 +305,6 @@ SeriesInfo_t* DicomLoader::getSerieInfo(const UniqueIDInfo &uniqueID)
|
|||||||
return the_series->second;
|
return the_series->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DicomLoader::deleteSeriesInstance(SeriesInstance* old)
|
|
||||||
{
|
|
||||||
//DicomLoader *helper = DicomLoader::GetInstance();
|
|
||||||
InstancesVecType* inst_vec = instance->getInstancesVec(*old->getUniqueID());
|
|
||||||
|
|
||||||
//if there is only one instance<63><65>do not delete
|
|
||||||
if (inst_vec->size() == SINGLE_INSTANCE)
|
|
||||||
{
|
|
||||||
//Comment1:You should set Series Instance to no DicomImageView
|
|
||||||
//Comment2:It is hard to tell wether it is in use,you'd better do nothing
|
|
||||||
//old->orphanizeSeriesInstance();
|
|
||||||
//You should set Series Instance to no DicomImageView
|
|
||||||
//old->orphanizeSeriesInstance();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (InstancesVecType::iterator iter = inst_vec->begin(); iter != inst_vec->end(); iter++)
|
|
||||||
{
|
|
||||||
if (old == *iter)
|
|
||||||
{
|
|
||||||
inst_vec->erase(iter);
|
|
||||||
delete old;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SeriesInstance* DicomLoader::addSeriesInstance(SeriesInstance* instance,bool copy)
|
|
||||||
{
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -412,81 +356,7 @@ UniqueIDInfo_t* DicomLoader::createUniqueID(const std::string &dicomName, Series
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DicomLoader::setDirObservers(void* client)
|
|
||||||
{
|
|
||||||
//Adding a reading progress observer to the reader so we can see how are we reading.
|
|
||||||
// itk::CStyleCommand::Pointer pcl = itk::CStyleCommand::New();
|
|
||||||
// pcl->SetCallback((itk::CStyleCommand::FunctionPointer)&itkReaderProCallbackFunction_DIR);
|
|
||||||
// pcl->SetClientData(client);
|
|
||||||
// //m_itkSeriesReader->AddObserver(itk::ProgressEvent(), pcl);
|
|
||||||
// m_itkSeriesReader->AddObserver(itk::ProgressEvent(), pcl);
|
|
||||||
//
|
|
||||||
// itk::CStyleCommand::Pointer pcl2 = itk::CStyleCommand::New();
|
|
||||||
// pcl2->SetClientData(client);
|
|
||||||
// pcl2->SetCallback((itk::CStyleCommand::FunctionPointer)&itkReaderEndCallbackFunction);
|
|
||||||
// //m_itkSeriesReader->AddObserver(itk::EndEvent(), pcl2);
|
|
||||||
// m_itkSeriesReader->AddObserver(itk::EndEvent(), pcl2);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
void DicomLoader::setFileObservers(void* client)
|
|
||||||
{
|
|
||||||
//Adding a reading progress observer to the reader so we can see how are we reading.
|
|
||||||
// itk::CStyleCommand::Pointer pcl = itk::CStyleCommand::New();
|
|
||||||
// pcl->SetCallback((itk::CStyleCommand::FunctionPointer)&itkReaderProCallbackFunction_FILE);
|
|
||||||
// pcl->SetClientData(client);
|
|
||||||
// //m_itkSeriesReader->AddObserver(itk::ProgressEvent(), pcl);
|
|
||||||
// m_itkSeriesReader->AddObserver(itk::ProgressEvent(), pcl);
|
|
||||||
//
|
|
||||||
// itk::CStyleCommand::Pointer pcl2 = itk::CStyleCommand::New();
|
|
||||||
// pcl2->SetClientData(client);
|
|
||||||
// pcl2->SetCallback((itk::CStyleCommand::FunctionPointer)&itkReaderEndCallbackFunction);
|
|
||||||
// //m_itkSeriesReader->AddObserver(itk::EndEvent(), pcl2);
|
|
||||||
// m_itkSeriesReader->AddObserver(itk::EndEvent(), pcl2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//void DicomLoader::itkReaderProCallbackFunction_FILE(itk::ProcessObject* obj, const itk::ProgressEvent&, void* data)
|
|
||||||
//{
|
|
||||||
// QMainWindow* qdv = reinterpret_cast<QMainWindow*>(data);
|
|
||||||
// QString status = QString("Reading Images...");
|
|
||||||
// qdv->statusBar()->showMessage(status);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void DicomLoader::itkReaderProCallbackFunction_DIR(itk::ProcessObject* obj, const itk::ProgressEvent&, void* data)
|
|
||||||
//{
|
|
||||||
// QMainWindow* qdv = reinterpret_cast<QMainWindow*>(data);
|
|
||||||
// QString status = QString("Scanning Folder...(%1%)").arg(100 * obj->GetProgress());
|
|
||||||
// qdv->statusBar()->showMessage(status);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void DicomLoader::itkReaderEndCallbackFunction(itk::ProcessObject* obj, const itk::ProgressEvent&, void* data)
|
|
||||||
//
|
|
||||||
//{
|
|
||||||
// QMainWindow* qdv = reinterpret_cast<QMainWindow*>(data);
|
|
||||||
// qdv->statusBar()->showMessage("Ready");
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void DicomLoader::copyDicomTagsInfo(SeriesInstance* origin, SeriesInstance* copy)
|
|
||||||
//{
|
|
||||||
// const DicomTagInfo_t *origin_info = origin->getConstDicomTagInfo();
|
|
||||||
// DicomTagInfo_t *copy_info = copy->getDicomTagInfo();
|
|
||||||
// copy_info->m_PatientName = origin_info->m_PatientName;
|
|
||||||
// copy_info->m_StudyDescription = origin_info->m_StudyDescription;
|
|
||||||
// copy_info->m_Institution = origin_info->m_Institution;
|
|
||||||
// copy_info->m_StudyDate = origin_info->m_StudyDate;
|
|
||||||
// copy_info->m_Modality = origin_info->m_Modality;
|
|
||||||
// copy_info->lbl_ser_num = origin_info->lbl_ser_num;
|
|
||||||
// copy_info->m_SeriesNumber = origin_info->m_SeriesNumber;
|
|
||||||
// copy_info->m_SeriesDescription = origin_info->m_SeriesDescription;
|
|
||||||
// copy_info->m_StudyTime = origin_info->m_StudyTime;
|
|
||||||
// copy_info->m_PatientBirth = origin_info->m_PatientBirth;
|
|
||||||
// copy_info->m_SliceNumber = origin_info->m_SliceNumber;
|
|
||||||
// copy_info->m_orientation = origin_info->m_orientation;
|
|
||||||
// copy_info->WL = origin_info->WL;
|
|
||||||
// copy_info->WW = origin_info->WW;
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
DicomTagInfo_t* DicomLoader::createDicomTagsInfo()
|
DicomTagInfo_t* DicomLoader::createDicomTagsInfo()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -528,21 +398,11 @@ DicomTagInfo_t* DicomLoader::createDicomTagsInfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SeriesInstance* DicomLoader::createSeries(UniqueIDInfo_t* uniqueID, DicomTagInfo_t* tag_info, vtkGenericOpenGLRenderWindow* gl_rewin, bool copy)
|
SeriesImageSet* DicomLoader::createSeries(UniqueIDInfo_t* uniqueID)
|
||||||
{
|
{
|
||||||
|
|
||||||
SeriesInstance* series = new SeriesInstance(uniqueID, tag_info, gl_rewin);
|
SeriesImageSet* series =instance->InitFromRead(*uniqueID);
|
||||||
/******in order*******/
|
|
||||||
//whether create or copy from existing one
|
|
||||||
//暂时不走该分支!!!
|
|
||||||
if (copy)
|
|
||||||
{
|
|
||||||
instance->InitFromCopy(series);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
instance->InitFromRead(series);
|
|
||||||
}
|
|
||||||
series->setUpSeriesInstance();
|
series->setUpSeriesInstance();
|
||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
|
|||||||
60
src/src/base/SeriesImageSet.cpp
Normal file
60
src/src/base/SeriesImageSet.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include "base/SeriesImageSet.h"
|
||||||
|
#include <vtkRendererCollection.h>
|
||||||
|
#include "view/DicomImageView.h"
|
||||||
|
#include "base/DicomLoader.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "ExtendMedicalImageProperties.h"
|
||||||
|
|
||||||
|
qint32 SeriesImageSet::image_label_size = 100;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
SeriesImageSet::SeriesImageSet(const UniqueIDInfo& uniqueID,ExtendMedicalImageProperties* property, vtkImageData* imagedata) :
|
||||||
|
m_pUniqueID(uniqueID)
|
||||||
|
{
|
||||||
|
m_image = imagedata;
|
||||||
|
m_property = property;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
SeriesImageSet::~SeriesImageSet() {
|
||||||
|
if (m_property) m_property->Delete();
|
||||||
|
m_property = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SeriesImageSet::setUpSeriesInstance()
|
||||||
|
{
|
||||||
|
|
||||||
|
// m_imageViewer->SetInputData(m_image);
|
||||||
|
// m_imageViewer->SetRenderWindow(m_glrenWin);
|
||||||
|
// m_imageViewer->SetupInteractor(m_glrenWin->GetInteractor());
|
||||||
|
//
|
||||||
|
// m_imageViewer->initCornerInfo(m_pSeriesTags);
|
||||||
|
// m_imageViewer->setUpImageViewer();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// vtkCamera* cam = m_imageViewer->GetRenderer()->GetActiveCamera();
|
||||||
|
// m_extent = m_image->GetDimensions()[0] * m_pSeriesTags->spacing[0] * 0.5;
|
||||||
|
// cam->SetParallelScale(m_extent);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// //remember
|
||||||
|
// m_imageViewer->GetRenderer()->GetActiveCamera()->GetViewUp(m_vup);
|
||||||
|
// m_imageViewer->GetRenderer()->GetActiveCamera()->GetPosition(m_cameraPosition);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* SeriesImageSet::getCurImageName() const
|
||||||
|
{
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* SeriesImageSet::getCurSeriesName() const
|
||||||
|
{
|
||||||
|
if (m_pUniqueID.dicom_name.empty())
|
||||||
|
return nullptr;
|
||||||
|
return m_pUniqueID.dicom_name.c_str();
|
||||||
|
}
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
#include "base/seriesinstance.h"
|
|
||||||
#include "qsurfaceformat.h"
|
|
||||||
#include <vtkRendererCollection.h>
|
|
||||||
#include "view/DicomImageView.h"
|
|
||||||
#include "base/DicomLoader.h"
|
|
||||||
#include "vtkImageMapToWindowLevelColors.h"
|
|
||||||
#include "vtkImageProperty.h"
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QDebug>
|
|
||||||
#include "vtkRenderer.h"
|
|
||||||
#include "vtkDiscretizableColorTransferFunction.h"
|
|
||||||
|
|
||||||
qint32 SeriesInstance::image_label_size = 100;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
|
||||||
SeriesInstance::SeriesInstance(UniqueIDInfo_t* uniqueID, DicomTagInfo_t* tag_info,
|
|
||||||
vtkGenericOpenGLRenderWindow* glrenWin) :
|
|
||||||
m_pUniqueID(uniqueID),
|
|
||||||
m_pSeriesTags(tag_info),
|
|
||||||
m_glrenWin(glrenWin)
|
|
||||||
{
|
|
||||||
m_imageViewer = vtkSmartPointer<infinitiViewer>::New();
|
|
||||||
m_image = vtkSmartPointer<vtkImageData>::New();
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
|
||||||
SeriesInstance::~SeriesInstance() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SeriesInstance::setUpSeriesInstance()
|
|
||||||
{
|
|
||||||
|
|
||||||
m_imageViewer->SetInputData(m_image);
|
|
||||||
m_imageViewer->SetRenderWindow(m_glrenWin);
|
|
||||||
m_imageViewer->SetupInteractor(m_glrenWin->GetInteractor());
|
|
||||||
|
|
||||||
m_imageViewer->initCornerInfo(m_pSeriesTags);
|
|
||||||
m_imageViewer->setUpImageViewer();
|
|
||||||
|
|
||||||
|
|
||||||
vtkCamera* cam = m_imageViewer->GetRenderer()->GetActiveCamera();
|
|
||||||
m_extent = m_image->GetDimensions()[0] * m_pSeriesTags->spacing[0] * 0.5;
|
|
||||||
cam->SetParallelScale(m_extent);
|
|
||||||
|
|
||||||
|
|
||||||
//remember
|
|
||||||
m_imageViewer->GetRenderer()->GetActiveCamera()->GetViewUp(m_vup);
|
|
||||||
m_imageViewer->GetRenderer()->GetActiveCamera()->GetPosition(m_cameraPosition);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* SeriesInstance::getCurImageName() const
|
|
||||||
{
|
|
||||||
if (m_pUniqueID->open_mode == FILE_OPEN_MODE)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (m_pUniqueID->dicom_name.empty())
|
|
||||||
return nullptr;
|
|
||||||
return m_pUniqueID->dicom_name.c_str();
|
|
||||||
}
|
|
||||||
if (m_pUniqueID->open_mode == DIR_OPEN_MODE)
|
|
||||||
{
|
|
||||||
int index = m_imageViewer->GetSlice();
|
|
||||||
return m_fileNames.at(index).c_str();
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* SeriesInstance::getCurSeriesName() const
|
|
||||||
{
|
|
||||||
if (m_pUniqueID->dicom_name.empty())
|
|
||||||
return nullptr;
|
|
||||||
return m_pUniqueID->dicom_name.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap SeriesInstance::GetPixmap()
|
|
||||||
{
|
|
||||||
QImage qimage = vtkImageDataToQImage(m_image);
|
|
||||||
return QPixmap::fromImage(qimage);
|
|
||||||
}
|
|
||||||
|
|
||||||
QImage SeriesInstance::vtkImageDataToQImage(vtkImageData* imageData)
|
|
||||||
{
|
|
||||||
if (!imageData) { return QImage(); }
|
|
||||||
|
|
||||||
int wl = m_pSeriesTags->WL;
|
|
||||||
int ww = m_pSeriesTags->WW;
|
|
||||||
/// \todo retrieve just the UpdateExtent
|
|
||||||
int width = imageData->GetDimensions()[0];
|
|
||||||
int height = imageData->GetDimensions()[1];
|
|
||||||
int slice_num = 0;
|
|
||||||
if (m_pUniqueID->open_mode == DIR_OPEN_MODE)
|
|
||||||
{
|
|
||||||
slice_num = std::atoi(m_pSeriesTags->m_SliceNumber.c_str()) / 2;
|
|
||||||
}
|
|
||||||
QImage image(width, height, QImage::Format_RGB32);
|
|
||||||
QRgb *rgbPtr = reinterpret_cast<QRgb *>(image.bits());// +width * (height - 1);
|
|
||||||
PixelType *colorsPtr = reinterpret_cast<PixelType*>(imageData->GetScalarPointer(0, 0, slice_num));
|
|
||||||
//unsigned char *colorsPtr = reinterpret_cast<unsigned char *>(imageData->GetScalarPointer());
|
|
||||||
// Loop over the vtkImageData contents.
|
|
||||||
for (int row = 0; row < height; row++)
|
|
||||||
{
|
|
||||||
for (int col = 0; col < width; col++)
|
|
||||||
{
|
|
||||||
// Swap the vtkImageData RGB values with an equivalent QColor
|
|
||||||
//qDebug() << colorsPtr[0];
|
|
||||||
PixelType adapt_color;
|
|
||||||
if ((colorsPtr[0] - wl) < -ww/2)
|
|
||||||
{
|
|
||||||
adapt_color = static_cast<PixelType>(0);
|
|
||||||
}
|
|
||||||
else if ((colorsPtr[0] - wl) > ww/2)
|
|
||||||
{
|
|
||||||
adapt_color = static_cast<PixelType>(255.0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
adapt_color = static_cast<PixelType>((1.0*(colorsPtr[0] - wl) / ww + 0.5) * 255.0);
|
|
||||||
}
|
|
||||||
*(rgbPtr++) = QColor(adapt_color, adapt_color, adapt_color).rgb();
|
|
||||||
|
|
||||||
colorsPtr += imageData->GetNumberOfScalarComponents();
|
|
||||||
}
|
|
||||||
|
|
||||||
//rgbPtr -= width * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
QImage resized = image.scaled(labelSizeHint(), Qt::KeepAspectRatio);
|
|
||||||
return resized;
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "export/dicomexporter.h"
|
#include "export/dicomexporter.h"
|
||||||
#include "include_vitk.h"
|
#include "include_vitk.h"
|
||||||
#include "vtkErrorCode.h"
|
#include "vtkErrorCode.h"
|
||||||
#include "seriesinstance.h"
|
#include "SeriesImageSet.h"
|
||||||
|
|
||||||
|
|
||||||
DicomExporter::DicomExporter(QObject *parent)
|
DicomExporter::DicomExporter(QObject *parent)
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ void ExportDialog::onBtnExportClicked()
|
|||||||
//export files
|
//export files
|
||||||
if (ui->rbCurrentImage->isChecked())//current image
|
if (ui->rbCurrentImage->isChecked())//current image
|
||||||
{
|
{
|
||||||
//SeriesInstance *instance = viewContainerWidget->getCurrentSeries();
|
|
||||||
if (cur_view->HasSeries())
|
if (cur_view->HasSeries())
|
||||||
{
|
{
|
||||||
QString imageName(cur_view->getSeriesInstance()->getCurImageName());
|
QString imageName(cur_view->getSeriesInstance()->getCurImageName());
|
||||||
@@ -72,7 +71,6 @@ void ExportDialog::onBtnExportClicked()
|
|||||||
}
|
}
|
||||||
else if (ui->rbCurrentSeries->isChecked())//current series
|
else if (ui->rbCurrentSeries->isChecked())//current series
|
||||||
{
|
{
|
||||||
//SeriesInstance *instance = viewContainerWidget->getCurrentSeries();
|
|
||||||
if (cur_view->HasSeries())
|
if (cur_view->HasSeries())
|
||||||
{
|
{
|
||||||
QString serieName(cur_view->getSeriesInstance()->getCurSeriesName());
|
QString serieName(cur_view->getSeriesInstance()->getCurSeriesName());
|
||||||
@@ -85,7 +83,7 @@ void ExportDialog::onBtnExportClicked()
|
|||||||
DicomLoader::GetInstance()->getOpenedInstancesVec(instanceVec);
|
DicomLoader::GetInstance()->getOpenedInstancesVec(instanceVec);
|
||||||
for (int i = 0; i < instanceVec.size(); i++)
|
for (int i = 0; i < instanceVec.size(); i++)
|
||||||
{
|
{
|
||||||
SeriesInstance *instance = instanceVec.at(i);
|
SeriesImageSet *instance = instanceVec.at(i);
|
||||||
if (instance != nullptr)
|
if (instance != nullptr)
|
||||||
{
|
{
|
||||||
options.inputData.push_back(instance->getCurSeriesName());
|
options.inputData.push_back(instance->getCurSeriesName());
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "view/thumbnailbarwidget.h"
|
#include "view/thumbnailbarwidget.h"
|
||||||
#include "view/thumbnailImage.h"
|
#include "view/thumbnailImage.h"
|
||||||
#include "base/DicomLoader.h"
|
#include "base/DicomLoader.h"
|
||||||
#include "base/seriesinstance.h"
|
#include "base/SeriesImageSet.h"
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -218,7 +218,7 @@ void ThumbnailBarWidget::Slot_setCurrentThumbnail(DicomImageView *view)
|
|||||||
if (view != nullptr)
|
if (view != nullptr)
|
||||||
{
|
{
|
||||||
if (view->HasSeries()) {
|
if (view->HasSeries()) {
|
||||||
SeriesInstance *series = view->getSeriesInstance();
|
SeriesImageSet *series = view->getSeriesInstance();
|
||||||
//set to another
|
//set to another
|
||||||
DicomLoader *helper = DicomLoader::GetInstance();
|
DicomLoader *helper = DicomLoader::GetInstance();
|
||||||
SeriesInfo_t* cur_serie = helper->getSerieInfo(*series->getUniqueID());
|
SeriesInfo_t* cur_serie = helper->getSerieInfo(*series->getUniqueID());
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "viewcontainerwidget.h"
|
#include "viewcontainerwidget.h"
|
||||||
#include "thumbnailImage.h"
|
#include "thumbnailImage.h"
|
||||||
#include "DicomLoader.h"
|
#include "DicomLoader.h"
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
@@ -59,7 +59,7 @@ DicomImageView* ViewContainerWidget::getNextView() const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
SeriesInstance* ViewContainerWidget::getCurrentSeries() const
|
SeriesImageSet* ViewContainerWidget::getCurrentSeries() const
|
||||||
{
|
{
|
||||||
if (current_view_ != nullptr)
|
if (current_view_ != nullptr)
|
||||||
{
|
{
|
||||||
@@ -390,7 +390,7 @@ void ViewContainerWidget::Slot_ViewEmpty(DicomImageView *view)
|
|||||||
void ViewContainerWidget::Slot_DragDropEvent(DicomImageView *view, thumbnailImage* tb)
|
void ViewContainerWidget::Slot_DragDropEvent(DicomImageView *view, thumbnailImage* tb)
|
||||||
{
|
{
|
||||||
SeriesInfo_t* serie_info = tb->getSeriesInfo();
|
SeriesInfo_t* serie_info = tb->getSeriesInfo();
|
||||||
SeriesInstance* old = nullptr;
|
SeriesImageSet* old = nullptr;
|
||||||
bool copy = true;
|
bool copy = true;
|
||||||
|
|
||||||
if (view->HasSeries())
|
if (view->HasSeries())
|
||||||
@@ -409,7 +409,7 @@ void ViewContainerWidget::Slot_ThumbnailClickEvent(thumbnailImage* tb)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SeriesInfo_t* serie_info = tb->getSeriesInfo();
|
SeriesInfo_t* serie_info = tb->getSeriesInfo();
|
||||||
SeriesInstance* old = nullptr;
|
SeriesImageSet* old = nullptr;
|
||||||
bool copy = true;
|
bool copy = true;
|
||||||
|
|
||||||
if (view->HasSeries())
|
if (view->HasSeries())
|
||||||
@@ -425,10 +425,7 @@ void ViewContainerWidget::replaceViewWithSerie(UniqueIDInfo_t* unique_info, Dico
|
|||||||
curV->removeViewWithFusion();
|
curV->removeViewWithFusion();
|
||||||
|
|
||||||
DicomLoader *helper = DicomLoader::GetInstance();
|
DicomLoader *helper = DicomLoader::GetInstance();
|
||||||
vtkGenericOpenGLRenderWindow* grw = curV->getRenWin();
|
curV->setDicomImageView(helper->createSeries(unique_info));
|
||||||
SeriesInstance* instance = helper->createSeries(unique_info, tag_info, grw, copy);
|
|
||||||
|
|
||||||
curV->setDicomImageView(instance);
|
|
||||||
curV->Render();
|
curV->Render();
|
||||||
//delete old after new instance render
|
//delete old after new instance render
|
||||||
if (old)
|
if (old)
|
||||||
|
|||||||
Reference in New Issue
Block a user