feat: Add a data loading progress bar
This commit is contained in:
@@ -264,3 +264,19 @@ MPRResliceWindow#MPRWin{
|
|||||||
QSplitter::handle {
|
QSplitter::handle {
|
||||||
background: #5a5a5a;
|
background: #5a5a5a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QProgressBar{
|
||||||
|
min-height: 10px;
|
||||||
|
max-height: 10px;
|
||||||
|
border:1px solid #aaa;
|
||||||
|
/* border-radius: 4px; */
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 4px;
|
||||||
|
margin-left: 3px;
|
||||||
|
}
|
||||||
|
QProgressBar::chunk {
|
||||||
|
background: QLinearGradient( x1: 0, y1: 0,
|
||||||
|
x2: 1, y2: 0,
|
||||||
|
stop: 0 #ffffff,
|
||||||
|
stop: 1 #666666 );
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#define aLLEventMacro() \
|
#define aLLEventMacro() \
|
||||||
_add_Event(DefaultEvent)\
|
_add_Event(DefaultEvent)\
|
||||||
|
_add_Event(LoadProgressEvent)\
|
||||||
_add_Event(SyncStateChanged)\
|
_add_Event(SyncStateChanged)\
|
||||||
_add_Event(AnnotationStateChanged)\
|
_add_Event(AnnotationStateChanged)\
|
||||||
_add_Event(AnonymizeStateChanged)\
|
_add_Event(AnonymizeStateChanged)\
|
||||||
|
|||||||
@@ -4,16 +4,21 @@
|
|||||||
#include "dcmtk/dcmdata/dcdeftag.h"
|
#include "dcmtk/dcmdata/dcdeftag.h"
|
||||||
#include "dcmtk/dcmdata/dcdatset.h"
|
#include "dcmtk/dcmdata/dcdatset.h"
|
||||||
#include "dcmtk/dcmdata/dcspchrs.h"
|
#include "dcmtk/dcmdata/dcspchrs.h"
|
||||||
#include "ExtendMedicalImageProperties.h"
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <qDebug>
|
#include <qDebug>
|
||||||
#include <vtkNew.h>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <vtkMath.h>
|
|
||||||
#include <QtCore/qvarlengtharray.h>
|
#include <QtCore/qvarlengtharray.h>
|
||||||
|
|
||||||
|
#include <QDirIterator>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vtkNew.h>
|
||||||
|
#include <vtkMath.h>
|
||||||
|
|
||||||
|
#include "ExtendMedicalImageProperties.h"
|
||||||
|
|
||||||
|
|
||||||
void DICOMHeaderHelper::Update() {
|
void DICOMHeaderHelper::Update() {
|
||||||
|
CalculateResource();
|
||||||
ReadHeader();
|
ReadHeader();
|
||||||
ArrangeSeriesProperty();
|
ArrangeSeriesProperty();
|
||||||
SeriesCount = seriesProperties.size();
|
SeriesCount = seriesProperties.size();
|
||||||
@@ -33,6 +38,12 @@ ExtendMedicalImageProperties *DICOMHeaderHelper::GetSeriesBySeriesUID(const char
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DICOMHeaderHelper::SetProgressCallback(void (*aProgressCallback)(float))
|
||||||
|
{
|
||||||
|
if (!aProgressCallback) return;
|
||||||
|
mProgressCallback = aProgressCallback;
|
||||||
|
}
|
||||||
|
|
||||||
void DICOMHeaderHelper::Clear() {
|
void DICOMHeaderHelper::Clear() {
|
||||||
dirName.clear();
|
dirName.clear();
|
||||||
fileName.clear();
|
fileName.clear();
|
||||||
@@ -40,6 +51,18 @@ void DICOMHeaderHelper::Clear() {
|
|||||||
SeriesCount = 0;
|
SeriesCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DICOMHeaderHelper::CalculateResource()
|
||||||
|
{
|
||||||
|
mFilesCount = 0;
|
||||||
|
mProcessedCount = 0;
|
||||||
|
QDirIterator it(dirName.data(), QDir::Files, QDirIterator::Subdirectories);
|
||||||
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next(); // 移动到下一个文件
|
||||||
|
mFilesCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DICOMHeaderHelper::readHeaderFromDir(const char * rootPath){
|
void DICOMHeaderHelper::readHeaderFromDir(const char * rootPath){
|
||||||
QDir dir(QString::fromLocal8Bit(rootPath));
|
QDir dir(QString::fromLocal8Bit(rootPath));
|
||||||
dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
@@ -241,6 +264,10 @@ void DICOMHeaderHelper::readHeaderFromFile(const char * filePath){
|
|||||||
series[uniqueID].push_back(std::move(fileHeader));
|
series[uniqueID].push_back(std::move(fileHeader));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mProcessedCount++;
|
||||||
|
if (mProgressCallback){
|
||||||
|
mProgressCallback(((float)mProcessedCount/(float)(mFilesCount)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DICOMHeaderHelper::ReadHeader() {
|
void DICOMHeaderHelper::ReadHeader() {
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
void CalculateResource();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进行文件检索和数据读取,并按照读取所得的内容生成ExtendMedicalImageProperties
|
* 进行文件检索和数据读取,并按照读取所得的内容生成ExtendMedicalImageProperties
|
||||||
*/
|
*/
|
||||||
@@ -142,6 +144,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
ExtendMedicalImageProperties *GetSeriesBySeriesUID(const char *seriesUID);
|
ExtendMedicalImageProperties *GetSeriesBySeriesUID(const char *seriesUID);
|
||||||
|
|
||||||
|
void SetProgressCallback(void (*aProgressCallback)(float));
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ReadHeader();
|
void ReadHeader();
|
||||||
|
|
||||||
@@ -154,9 +158,13 @@ private:
|
|||||||
ExtendMedicalImageProperties *
|
ExtendMedicalImageProperties *
|
||||||
createProperty(const std::vector<DICOMFileHeader> &header, int splitIndex, int beginOffset);
|
createProperty(const std::vector<DICOMFileHeader> &header, int splitIndex, int beginOffset);
|
||||||
|
|
||||||
|
void (*mProgressCallback)(float aPercent) = nullptr;
|
||||||
|
|
||||||
std::string dirName;
|
std::string dirName;
|
||||||
std::string fileName;
|
std::string fileName;
|
||||||
int SeriesCount = 0;
|
int SeriesCount = 0;
|
||||||
|
int mFilesCount = 0;
|
||||||
|
int mProcessedCount = 0;
|
||||||
SeriesFileMap series;
|
SeriesFileMap series;
|
||||||
std::vector<ExtendMedicalImageProperties *> seriesProperties;
|
std::vector<ExtendMedicalImageProperties *> seriesProperties;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,12 +6,21 @@
|
|||||||
#include "DICOMHeaderHelper.h"
|
#include "DICOMHeaderHelper.h"
|
||||||
#include "DICOMPixelDataHelper.h"
|
#include "DICOMPixelDataHelper.h"
|
||||||
#include "vtkDCMTKImageReader.h"
|
#include "vtkDCMTKImageReader.h"
|
||||||
|
#include "Events/EventsCenter.h"
|
||||||
|
|
||||||
|
|
||||||
|
void raiseReadPropertyProgress(float aPercent)
|
||||||
|
{
|
||||||
|
EventObject eventObj;
|
||||||
|
eventObj.AddDetailValue("progress",aPercent);
|
||||||
|
EventsCenter::Default()->TriggerEvent(LoadProgressEvent, &eventObj);
|
||||||
|
}
|
||||||
|
|
||||||
void DicomLoader::readPropertiesFromDir(const std::string &dir,
|
void DicomLoader::readPropertiesFromDir(const std::string &dir,
|
||||||
std::vector<ExtendMedicalImageProperties*>& properties, int& count) {
|
std::vector<ExtendMedicalImageProperties*>& properties, int& count) {
|
||||||
DICOMHeaderHelper DICOMHelper;
|
DICOMHeaderHelper DICOMHelper;
|
||||||
DICOMHelper.SetDirName(dir.c_str());
|
DICOMHelper.SetDirName(dir.c_str());
|
||||||
|
DICOMHelper.SetProgressCallback(raiseReadPropertyProgress);
|
||||||
DICOMHelper.Update();
|
DICOMHelper.Update();
|
||||||
count = DICOMHelper.GetSeriesCount();
|
count = DICOMHelper.GetSeriesCount();
|
||||||
if ( DICOMHelper.GetSeriesCount()>0){
|
if ( DICOMHelper.GetSeriesCount()>0){
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QProgressBar>
|
||||||
|
|
||||||
|
|
||||||
#include "Common/Helper/OrientationHelper.h"
|
#include "Common/Helper/OrientationHelper.h"
|
||||||
#include "Common/ImageSetStore.h"
|
#include "Common/ImageSetStore.h"
|
||||||
@@ -47,6 +50,11 @@ QDicomViewer::QDicomViewer(QWidget *parent) : QMainWindow(parent),
|
|||||||
|
|
||||||
//TODO:目前为方向是写死的正交方向
|
//TODO:目前为方向是写死的正交方向
|
||||||
OrientationHelper::init();
|
OrientationHelper::init();
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout(ui->statusBar);
|
||||||
|
mProgress = new QProgressBar(ui->statusBar) ;
|
||||||
|
mProgress->setObjectName("progress");
|
||||||
|
layout->addWidget(mProgress);
|
||||||
|
mProgress->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDicomViewer::~QDicomViewer() {
|
QDicomViewer::~QDicomViewer() {
|
||||||
@@ -94,6 +102,8 @@ void QDicomViewer::SetupConnections() {
|
|||||||
|
|
||||||
connect(ui->toolBar, &QToolBar::visibilityChanged,
|
connect(ui->toolBar, &QToolBar::visibilityChanged,
|
||||||
this, &QDicomViewer::Slot_ToolbarVisibilityChanged);
|
this, &QDicomViewer::Slot_ToolbarVisibilityChanged);
|
||||||
|
|
||||||
|
connect(EventsCenter::Default(),&EventsCenter::LoadProgressEvent, this, &QDicomViewer::loadProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
//视窗操作,播放相关
|
//视窗操作,播放相关
|
||||||
@@ -331,10 +341,26 @@ void QDicomViewer::openDICOMFromPACS(int err, std::string dirName) {
|
|||||||
|
|
||||||
void QDicomViewer::changeColorTable(const QString& aTable)
|
void QDicomViewer::changeColorTable(const QString& aTable)
|
||||||
{
|
{
|
||||||
DicomImageView *curV = ui->viewContainer->getViewManager()->getCurrentView();
|
DicomImageView *curV = ui->viewContainer->getViewManager()->getCurrentView();
|
||||||
if (curV != nullptr && curV->hasSeries()) {
|
if (curV != nullptr && curV->hasSeries()) {
|
||||||
curV->setColorTable(aTable);
|
curV->setColorTable(aTable);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QDicomViewer::loadProgress(EventObject *aCalldata)
|
||||||
|
{
|
||||||
|
float value = aCalldata->Detail["progress"].toFloat();
|
||||||
|
if (value>=1){
|
||||||
|
mProgress->setValue(100);
|
||||||
|
this->update();
|
||||||
|
ui->statusBar->showMessage(tr("Ready"));
|
||||||
|
mProgress->setVisible(false);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ui->statusBar->showMessage("");
|
||||||
|
mProgress->setVisible(true);
|
||||||
|
mProgress->setValue(round(value*100));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: 覆盖逻辑和增加逻辑待补充
|
//TODO: 覆盖逻辑和增加逻辑待补充
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public slots:
|
|||||||
void Slot_ToolbarVisibilityChanged(bool);
|
void Slot_ToolbarVisibilityChanged(bool);
|
||||||
void openDICOMFromPACS(int,std::string);
|
void openDICOMFromPACS(int,std::string);
|
||||||
void changeColorTable(const QString& aTable);
|
void changeColorTable(const QString& aTable);
|
||||||
|
void loadProgress(EventObject* aCalldata);
|
||||||
private:
|
private:
|
||||||
Ui::QDicomViewerClass *ui;
|
Ui::QDicomViewerClass *ui;
|
||||||
|
|
||||||
@@ -86,6 +87,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
ExportDialog *exportDialog = nullptr;
|
ExportDialog *exportDialog = nullptr;
|
||||||
|
QProgressBar* mProgress = nullptr;
|
||||||
ImportWidget *m_import =nullptr;
|
ImportWidget *m_import =nullptr;
|
||||||
QSettings m_qs;
|
QSettings m_qs;
|
||||||
Customwindow *m_customwin =nullptr;
|
Customwindow *m_customwin =nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user