183 lines
4.4 KiB
C++
183 lines
4.4 KiB
C++
#include "exportdialog.h"
|
|
#include "ui_exportdialog.h"
|
|
|
|
ExportDialog::ExportDialog(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::ExportDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
ui->progressBar->setVisible(false);
|
|
init();
|
|
|
|
}
|
|
|
|
ExportDialog::~ExportDialog()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void ExportDialog::init()
|
|
{
|
|
connect(ui->btnExport, SIGNAL(clicked()), this, SLOT(onBtnExportClicked()));
|
|
connect(ui->btnCancel, SIGNAL(clicked()), this, SLOT(onBtnCancelClicked()));
|
|
connect(ui->btnSelectFolder, SIGNAL(clicked()), this, SLOT(onBtnSelectFolderClicked()));
|
|
}
|
|
|
|
void ExportDialog::initUI()
|
|
{
|
|
ui->progressBar->setVisible(false);
|
|
}
|
|
|
|
void ExportDialog::onBtnSelectFolderClicked()
|
|
{
|
|
QDir dir;
|
|
QString dirpath = QFileDialog::getExistingDirectory(this, tr("select a directory"), "./", QFileDialog::ShowDirsOnly);
|
|
if (!dir.exists(dirpath))
|
|
{
|
|
return;
|
|
}
|
|
|
|
ui->edtExportFolder->setText(dirpath);
|
|
}
|
|
|
|
void ExportDialog::onBtnExportClicked()
|
|
{
|
|
QDir dir;
|
|
if (!dir.exists(ui->edtExportFolder->text()))
|
|
{
|
|
QString dirpath = QFileDialog::getExistingDirectory(this, tr("select a directory"), "./", QFileDialog::ShowDirsOnly);
|
|
if (!dir.exists(dirpath))
|
|
{
|
|
return;
|
|
}
|
|
|
|
ui->edtExportFolder->setText(dirpath);
|
|
}
|
|
|
|
ui->btnExport->setEnabled(false);
|
|
ui->progressBar->setVisible(true);
|
|
ui->progressBar->setValue(0);
|
|
|
|
ExportOptions options;
|
|
|
|
//export files
|
|
if (ui->rbCurrentImage->isChecked())//current image
|
|
{
|
|
if (cur_view->hasSeries())
|
|
{
|
|
QString imageName(cur_view->getSeriesInstance()->getCurImageName());
|
|
options.inputData.push_back(imageName);
|
|
}
|
|
}
|
|
else if (ui->rbCurrentSeries->isChecked())//current series
|
|
{
|
|
if (cur_view->hasSeries())
|
|
{
|
|
QString serieName(cur_view->getSeriesInstance()->getSeriesName());
|
|
options.inputData.push_back(serieName);
|
|
}
|
|
}
|
|
else if (ui->rbAllOpendSeries->isChecked())// all opened series
|
|
{
|
|
//disable this function
|
|
// InstancesVecType instanceVec;
|
|
// DicomLoader::GetInstance()->getOpenedInstancesVec(instanceVec);
|
|
// for (int i = 0; i < instanceVec.size(); i++)
|
|
// {
|
|
// SeriesImageSet *instance = instanceVec.at(i);
|
|
// if (instance != nullptr)
|
|
// {
|
|
// options.inputData.push_back(instance->getSeriesName());
|
|
// }
|
|
// }
|
|
}
|
|
|
|
if (ui->rbJPEG->isChecked())
|
|
{
|
|
options.exportFileFormat = ExportOptions::FileFormat::Jpeg;
|
|
}
|
|
else if (ui->rbBMP->isChecked())
|
|
{
|
|
options.exportFileFormat = ExportOptions::FileFormat::Bmp;
|
|
}
|
|
else if (ui->rbPNG->isChecked())
|
|
{
|
|
options.exportFileFormat = ExportOptions::FileFormat::Png;
|
|
}
|
|
else if (ui->rbTIFF->isChecked())
|
|
{
|
|
options.exportFileFormat = ExportOptions::FileFormat::Tiff;
|
|
}
|
|
else if (ui->rbDICOM->isChecked())
|
|
{
|
|
options.exportFileFormat = ExportOptions::FileFormat::Dicom;
|
|
}
|
|
|
|
options.exportDirectory = ui->edtExportFolder->text();
|
|
|
|
if (ui->rbFull->isChecked())
|
|
{
|
|
options.cornerAnnotation = ExportOptions::CornerAnnotation::Full;
|
|
}
|
|
else if (ui->rbBasic->isChecked())
|
|
{
|
|
options.cornerAnnotation = ExportOptions::CornerAnnotation::Basic;
|
|
}
|
|
else if (ui->rbDisabled->isChecked())
|
|
{
|
|
options.cornerAnnotation = ExportOptions::CornerAnnotation::Disabled;
|
|
}
|
|
|
|
options.fileNamePrefix = ui->edtFileNamePrefix->text();
|
|
|
|
if (!ui->rbFull->isChecked())
|
|
{
|
|
options.isAnonymization = true;
|
|
}
|
|
else
|
|
{
|
|
options.isAnonymization = false;
|
|
}
|
|
|
|
options.windowLevel = cur_view->getImageViewer()->GetColorLevel();
|
|
options.windowWidth = cur_view->getImageViewer()->GetColorWindow();
|
|
options.serie = cur_view->getSeriesInstance();
|
|
DicomExporterThread *worker = new DicomExporterThread(options);
|
|
//disconnect(worker, SIGNAL(exportProgress(int, int)), this, SLOT(onExportProgress(int, int)));
|
|
connect(worker, SIGNAL(exportProgress(int, int)), this, SLOT(onExportProgress(int, int)));
|
|
|
|
//disconnect(worker, SIGNAL(exportFinished()), this, SLOT(onExportFinished()));
|
|
connect(worker, SIGNAL(exportFinished()), this, SLOT(onExportFinished()));
|
|
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
|
|
|
|
worker->start();
|
|
}
|
|
|
|
void ExportDialog::onBtnCancelClicked()
|
|
{
|
|
reject();
|
|
}
|
|
|
|
void ExportDialog::onExportProgress(int totalCount, int progress)
|
|
{
|
|
ui->progressBar->setMinimum(0);
|
|
ui->progressBar->setMaximum(totalCount);
|
|
ui->progressBar->setValue(progress);
|
|
}
|
|
|
|
void ExportDialog::onExportFinished()
|
|
{
|
|
ui->progressBar->setVisible(false);
|
|
ui->btnExport->setEnabled(true);
|
|
}
|
|
|
|
void ExportDialog::setCurView(DicomImageView *view)
|
|
{
|
|
cur_view = view;
|
|
}
|
|
|
|
//void ExportDialog::setViewContainer(ViewContainerWidget *widget)
|
|
//{
|
|
// viewContainerWidget = widget;
|
|
//}
|