diff --git a/DicomScanService.cpp b/DicomScanService.cpp index 3cd7f03..2969f50 100644 --- a/DicomScanService.cpp +++ b/DicomScanService.cpp @@ -377,12 +377,13 @@ void DicomScanService::parse(QString p_loadDir){ s.SetComputeZSpacing( true ); s.SetZSpacingTolerance( 1e-2 ); - if(result==NOERRORS) - if(!s.Sort( patientInfos->filenames ) ) { - result=PARSER_CT_FAILED_SORTING; + if (result == NOERRORS) { + if (!s.Sort(patientInfos->filenames)) { + result = PARSER_CT_FAILED_SORTING; } else { - s.GetFilenames().size() == 0 ? result = PARSER_CT_FILES_MISSING : result=NOERRORS; + s.GetFilenames().size() == 0 ? result = PARSER_CT_FILES_MISSING : result = NOERRORS; } + } if(result == NOERRORS){ patientInfos->CTfiles=s.GetFilenames (); diff --git a/LocalizationService.cpp b/LocalizationService.cpp index ed60d67..689cd38 100644 --- a/LocalizationService.cpp +++ b/LocalizationService.cpp @@ -216,14 +216,14 @@ MarkerList LocalizationService::localize( bool ok = true; // 0: bounding-box diagonal length - if (params.selectedFilters.size() > 0 && params.selectedFilters[0]) + if (params.selectedFilters[0]) { if (len < params.thrDown_D || len > params.thrUp_D) ok = false; } // 1: Hausdorff - if (ok && params.selectedFilters.size() > 1 && params.selectedFilters[1]) + if (ok && params.selectedFilters[1]) { double center[3]; out->GetCenter(center); @@ -233,7 +233,7 @@ MarkerList LocalizationService::localize( } // 2: side-difference - if (ok && params.selectedFilters.size() > 2 && params.selectedFilters[2]) + if (ok && params.selectedFilters[2]) { const double metric = sideDifferenceMetric(b); if (metric > params.thr_S) diff --git a/main.cpp b/main.cpp index 2a6a347..c19c148 100644 --- a/main.cpp +++ b/main.cpp @@ -38,7 +38,7 @@ int main(int argc, char **argv) { msgBox.setInformativeText("Please add config.ini file in the gLocalize path."); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); - int ret = msgBox.exec(); + (void)msgBox.exec(); cout<<"prequit" <addItem(horizonatlSpacer, layout->rowCount(), 0 ,1 ,layout->columnCount()); - int ret = msgBox.exec(); + (void)msgBox.exec(); cout<<"prequit" <show(); - int res= app.exec(); + return app.exec(); - return 0; + // unreachable } diff --git a/mainw.cpp b/mainw.cpp index aa07259..932dc66 100644 --- a/mainw.cpp +++ b/mainw.cpp @@ -15,7 +15,8 @@ void MainWindow::onSkullMaskingUpdt(QString msg, double val){ - Ui->progBar->setValue(val*100); + // SkullRemovalWorker already emits progress in percent [0..100] + Ui->progBar->setValue(static_cast(val)); QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, Q_ARG(QString, msg ), Q_ARG(int, 0)); @@ -124,7 +125,7 @@ MainWindow::MainWindow(QString p_loadPath){ skull_thread= new QThread; skullRemoval->moveToThread(skull_thread); skull_thread->start(); - connect(skullRemoval, SIGNAL(skull_mask_end(vtkImageData *)),Visualizer,SLOT(onAutoSkullMaskEnd(vtkImageData* ))); + // Handle result in MainWindow and forward to the renderer from the GUI thread. connect(skullRemoval, SIGNAL(skull_mask_end(vtkImageData *)),this,SLOT(onAutoSkullMaskEnd(vtkImageData* ))); connect(skullRemoval, SIGNAL(errMsg(QString)),this,SLOT(onAutoMaskError(QString ))); @@ -221,6 +222,11 @@ MainWindow::~MainWindow(){ } void MainWindow::onAutoSkullMaskEnd(vtkImageData* img){ + // Apply the masked volume to the renderer. gRen deep-copies the input, + // so we can safely free the temporary VTK image afterwards. + if (img && Visualizer) + Visualizer->onAutoSkullMaskEnd(img); + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, Q_ARG(QString, QString("Masking Done") ), Q_ARG(int, 3000)); @@ -233,6 +239,9 @@ void MainWindow::onAutoSkullMaskEnd(vtkImageData* img){ Ui->frame_3->setEnabled(true); Ui->frame_4->setEnabled(true); + if (img) + img->Delete(); + return; } diff --git a/types.h b/types.h index 2c29505..a8f5343 100644 --- a/types.h +++ b/types.h @@ -1,5 +1,6 @@ #pragma once +#include #include // Shared data model used across logic, Qt UI, and VTK rendering. @@ -33,5 +34,5 @@ struct LocalizationParams // 0: bounding-box diagonal length filter // 1: Hausdorff distance filter // 2: side-difference filter - std::vector selectedFilters{true, true, true}; + std::array selectedFilters{true, true, true}; }; diff --git a/ui_mainw.cpp b/ui_mainw.cpp index 2d14383..d15251c 100644 --- a/ui_mainw.cpp +++ b/ui_mainw.cpp @@ -61,10 +61,14 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) frame_2->setObjectName(QString::fromUtf8("frame_2")); frame_2->setFrameShape(QFrame::StyledPanel); frame_2->setFrameShadow(QFrame::Raised); + // Top-level layout for frame_2 (the only layout installed on the widget) auto verticalLayout_2 = new QVBoxLayout(frame_2); verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2")); - auto formLayout_2 = new QFormLayout(frame_2); + // Sub-layouts must NOT be constructed with a QWidget parent, otherwise Qt tries to + // install them as the widget's layout and warns if the widget already has one. + auto formLayout_2 = new QFormLayout(); formLayout_2->setObjectName(QString::fromUtf8("formLayout_2")); + verticalLayout_2->addLayout(formLayout_2); label_6 = new QLabel(frame_2); label_6->setObjectName(QString::fromUtf8("label_6")); @@ -111,9 +115,6 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) l_isoV->setMinimumSize(QSize(91, 0)); formLayout_2->setWidget(6, QFormLayout::FieldRole, l_isoV); - verticalLayout_2->addLayout(formLayout_2); - - verticalLayout_5->addWidget(frame_2); auto frame_5 = new QFrame(widget); @@ -122,7 +123,7 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) frame_5->setFrameShadow(QFrame::Raised); auto verticalLayout_4 = new QVBoxLayout(frame_5); verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4")); - auto horizontalLayout_7 = new QHBoxLayout(frame_5); + auto horizontalLayout_7 = new QHBoxLayout(); horizontalLayout_7->setObjectName(QString::fromUtf8("horizontalLayout_7")); label_7 = new QLabel(frame_5); label_7->setObjectName(QString::fromUtf8("label_7")); @@ -139,7 +140,7 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) verticalLayout_4->addLayout(horizontalLayout_7); - auto manualMask_lay = new QHBoxLayout(frame_5); + auto manualMask_lay = new QHBoxLayout(); manualMask_lay->setObjectName(QString::fromUtf8("manualMask_lay")); QLabel* l_manualMask = new QLabel(frame_5); l_manualMask->setObjectName(QString::fromUtf8("l_manualMask")); @@ -166,7 +167,7 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) frame_3->setFrameShadow(QFrame::Raised); auto verticalLayout = new QVBoxLayout(frame_3); verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); - auto horizontalLayout = new QHBoxLayout(frame_3); + auto horizontalLayout = new QHBoxLayout(); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); label = new QLabel(frame_3); label->setObjectName(QString::fromUtf8("label")); @@ -190,7 +191,7 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) verticalLayout->addLayout(horizontalLayout); - auto horizontalLayout_2 = new QHBoxLayout(frame_3); + auto horizontalLayout_2 = new QHBoxLayout(); horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); checkBox_2 = new QCheckBox(frame_3); checkBox_2->setObjectName(QString::fromUtf8("checkBox_2")); @@ -225,7 +226,7 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) verticalLayout->addLayout(horizontalLayout_2); - auto horizontalLayout_3 = new QHBoxLayout(frame_3); + auto horizontalLayout_3 = new QHBoxLayout(); horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3")); checkBox_3 = new QCheckBox(frame_3); checkBox_3->setObjectName(QString::fromUtf8("checkBox_3")); @@ -254,7 +255,7 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) verticalLayout->addLayout(horizontalLayout_3); - auto horizontalLayout_5 = new QHBoxLayout(frame_3); + auto horizontalLayout_5 = new QHBoxLayout(); horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5")); checkBox_5 = new QCheckBox(frame_3); checkBox_5->setObjectName(QString::fromUtf8("checkBox_5")); @@ -281,7 +282,7 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) verticalLayout->addLayout(horizontalLayout_5); - auto horizontalLayout_6 = new QHBoxLayout(frame_3); + auto horizontalLayout_6 = new QHBoxLayout(); horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6")); pushButton_3 = new QPushButton(frame_3); pushButton_3->setObjectName(QString::fromUtf8("pushButton_3")); @@ -327,7 +328,7 @@ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) verticalLayout_3->addWidget(treeView); - auto formLayout = new QHBoxLayout(frame_4); + auto formLayout = new QHBoxLayout(); formLayout->setObjectName(QString::fromUtf8("formLayout")); pushButton = new QPushButton(frame_4); pushButton->setObjectName(QString::fromUtf8("pushButton"));