diff --git a/LocalizationService.cpp b/LocalizationService.cpp index 5e06418..da70a00 100644 --- a/LocalizationService.cpp +++ b/LocalizationService.cpp @@ -154,6 +154,18 @@ MarkerList LocalizationService::localize( if (!labeled) return result; + // VTK has changed over time whether "RegionId" is stored on cells or points. + // For stable per-region extraction we want it on *cells*. + vtkPolyData* labeledForThreshold = labeled; + vtkNew p2c; + if (!labeled->GetCellData()->GetArray("RegionId") && labeled->GetPointData()->GetArray("RegionId")) + { + p2c->SetInputData(labeled); + p2c->PassPointDataOn(); + p2c->Update(); + labeledForThreshold = vtkPolyData::SafeDownCast(p2c->GetOutput()); + } + const int nRegions = connectivity->GetNumberOfExtractedRegions(); if (nRegions <= 0) return result; @@ -168,7 +180,7 @@ MarkerList LocalizationService::localize( onProgress(100.0 * static_cast(regionId + 1) / static_cast(nRegions)); vtkNew th; - th->SetInputData(labeled); + th->SetInputData(labeledForThreshold); th->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "RegionId"); th->SetLowerThreshold(regionId); th->SetUpperThreshold(regionId); diff --git a/LocalizationWorker.cpp b/LocalizationWorker.cpp index 59dece9..ce3910e 100644 --- a/LocalizationWorker.cpp +++ b/LocalizationWorker.cpp @@ -3,6 +3,8 @@ #include +#include + LocalizationWorker::LocalizationWorker(QObject* parent) : QObject(parent) { @@ -32,9 +34,8 @@ void LocalizationWorker::run(vtkImageData* volume, LocalizationParams params) emit finished(std::move(markers)); } catch (const std::exception& e) { - // Keep behavior consistent with legacy code: treat as aborted. - // (UI can be extended to show the exception message.) - (void)e; - emit aborted(); + emit failed(QString::fromUtf8(e.what())); + } catch (...) { + emit failed(QStringLiteral("Unknown error in localization")); } } diff --git a/LocalizationWorker.h b/LocalizationWorker.h index 830f215..9b9918e 100644 --- a/LocalizationWorker.h +++ b/LocalizationWorker.h @@ -23,6 +23,7 @@ signals: void progress(double percent); void finished(MarkerList markers); void aborted(); + void failed(QString message); private: std::atomic_bool m_abort{false}; diff --git a/legacy/gLocalize_legacy.cpp b/legacy/gLocalize_legacy.cpp new file mode 100644 index 0000000..ab7b978 --- /dev/null +++ b/legacy/gLocalize_legacy.cpp @@ -0,0 +1,416 @@ +#include "gLocalize.h" + +#include +#include +#include +#include + + +gLocalize::gLocalize(){ + + abortSignal=false; +} + +void gLocalize::localize(vtkImageData* vol, + int march_tresh, + double thrDown_D, + double thrUp_D, + double thr_HAUSD, + double thr_S, + QList selectedFilters) +{ + std::cout << "march_tresh: " << march_tresh << std::endl; + std::cout << "thrDown_D: " << thrDown_D << std::endl; + std::cout << "thrUp_D: " << thrUp_D << std::endl; + std::cout << "thr_HAUSD: " << thr_HAUSD << std::endl; + std::cout << "thr_S: " << thr_S << std::endl; + + abortSignal = false; + int progress = 0; + + vtkSmartPointer marchingcubes = vtkSmartPointer::New(); + vtkSmartPointer smoother = vtkSmartPointer::New(); + vtkSmartPointer normals = vtkSmartPointer::New(); + + // Connectivity filter used ONLY to label regions (AllRegions + RegionId). + vtkSmartPointer regionLabeler = + vtkSmartPointer::New(); + + marchingcubes->SetInputData(vol); + marchingcubes->SetValue(0, march_tresh); + marchingcubes->SetComputeNormals(0); + + if (marchingcubes->GetNumberOfInputConnections(0) == 0) + return; + + marchingcubes->Update(); + std::cout << "inizio run" << std::endl; + + // Smoothing + smoother->SetInputConnection(marchingcubes->GetOutputPort()); + smoother->SetNumberOfIterations(20); + smoother->NormalizeCoordinatesOn(); + smoother->SetPassBand(0.01); + smoother->BoundarySmoothingOn(); + smoother->Update(); + + // Normals + normals->SetInputConnection(smoother->GetOutputPort()); + normals->Update(); + + // Label regions (this produces RegionId in *PointData* in your build) + regionLabeler->SetInputConnection(normals->GetOutputPort()); + regionLabeler->SetExtractionModeToAllRegions(); + regionLabeler->ColorRegionsOn(); // IMPORTANT + regionLabeler->Update(); + + vtkPolyData* labeledPoly = regionLabeler->GetOutput(); + if (!labeledPoly) + throw("CRITICAL: connectivity produced no output"); + + // Debug prints (optional) + // labeledPoly->GetCellData()->Print(std::cout); + // labeledPoly->GetPointData()->Print(std::cout); + + // RegionId is in PointData: + vtkDataArray* ridArr = labeledPoly->GetPointData()->GetArray("RegionId"); + if (!ridArr) + throw("CRITICAL: RegionId array not found in PointData (ColorRegionsOn did not produce it)"); + + // Determine region id range robustly + double rRange[2]; + ridArr->GetRange(rRange); + int minRid = static_cast(rRange[0]); + int maxRid = static_cast(rRange[1]); + int nRegions = regionLabeler->GetNumberOfExtractedRegions(); + + std::cout << "nRegions=" << nRegions + << " RegionId range=" << minRid << ".." << maxRid << "\n"; + + if (nRegions == 0) + throw("CRITICAL: No surfaces in ConnectivityFilter output"); + if (nRegions > 3000) + std::cout << "ho trovato troppe superfici: " << nRegions << std::endl; + + QList surflist; + surflist.clear(); + surf tempsurf; + + int OKd = 0, OKh = 0, OKs = 0; + + // We iterate over RegionId range (more reliable than assuming 0..nRegions-1) + for (int idouble = minRid; idouble <= maxRid; ++idouble) + { + QApplication::processEvents(); + progress++; + + // progress relative to range: + const double denom = (maxRid - minRid + 1); + emit localizationProgress((double)progress / denom * 100.0); + + if (abortSignal) + { + abortSignal = false; + emit localizationAborted(); + return; + } + + int ok = 1; + + // --- Extract ONE region by thresholding RegionId on POINTS --- + vtkNew th; + th->SetInputData(labeledPoly); + + th->SetInputArrayToProcess( + 0, 0, 0, + vtkDataObject::FIELD_ASSOCIATION_POINTS, // IMPORTANT: RegionId is point data + "RegionId" + ); + th->SetLowerThreshold(idouble); + th->SetUpperThreshold(idouble); + + vtkNew geom; + geom->SetInputConnection(th->GetOutputPort()); + geom->Update(); + + vtkPolyData* out0 = geom->GetOutput(); + if (!out0 || out0->GetNumberOfCells() == 0) + continue; + + // Keep only one connected surface (thresholding on points can leave fragments) + vtkNew keepLargest; + keepLargest->SetInputData(out0); + keepLargest->SetExtractionModeToLargestRegion(); + keepLargest->Update(); + + vtkPolyData* out = keepLargest->GetOutput(); + if (!out || out->GetNumberOfCells() == 0) + continue; + + out->ComputeBounds(); + double b[6]; out->GetBounds(b); + double len = out->GetLength(); + + std::cout << "id " << idouble + << " cells " << out->GetNumberOfCells() + << " len " << len + << " bounds " + << b[0] << " " << b[1] << " " + << b[2] << " " << b[3] << " " + << b[4] << " " << b[5] << "\n"; + + // --- Your filters --- + if (selectedFilters.at(0) && ok == 1) + { + tempsurf.lenght = len; + if (tempsurf.lenght < thrDown_D || tempsurf.lenght > thrUp_D) + ok = 0; + } + + if (selectedFilters.at(1) && ok == 1) + { + OKd++; + out->GetCenter(tempsurf.center); + + tempsurf.hausdorff = hausdorff(out, tempsurf); + + if (tempsurf.hausdorff > thr_HAUSD) + ok = 0; + } + + if (selectedFilters.at(2) && ok == 1) + { + OKh++; + out->GetBounds(tempsurf.bounds); + tempsurf.confronto_lati = lati(tempsurf.bounds); + if (tempsurf.confronto_lati > thr_S) + ok = 0; + } + + if (ok == 1) + { + OKs++; + tempsurf.sorting = idouble; // store RegionId + surflist.append(tempsurf); + } + } + + std::cout << "Nsurfaces " << nRegions << std::endl; + std::cout << "OKD " << OKd << " OKH " << OKh << " OKS " << OKs << std::endl; + + // --- marker center calculation --- + QList final_list; + surf tmp_p; + + if (surflist.count() != 0) + { + for (int ii = 0; ii < surflist.count(); ++ii) + { + tmp_p = surflist.at(ii); + + // Re-extract the chosen region using the SAME pipeline as above: + vtkNew th; + th->SetInputData(labeledPoly); + th->SetInputArrayToProcess( + 0, 0, 0, + vtkDataObject::FIELD_ASSOCIATION_POINTS, + "RegionId" + ); + th->SetLowerThreshold(tmp_p.sorting); + th->SetUpperThreshold(tmp_p.sorting); + + vtkNew geom; + geom->SetInputConnection(th->GetOutputPort()); + geom->Update(); + + vtkPolyData* out0 = geom->GetOutput(); + if (!out0 || out0->GetNumberOfCells() == 0) + continue; + + vtkNew keepLargest; + keepLargest->SetInputData(out0); + keepLargest->SetExtractionModeToLargestRegion(); + keepLargest->Update(); + + vtkPolyData* out = keepLargest->GetOutput(); + if (!out || out->GetNumberOfCells() == 0) + continue; + + // centroid calculation needs mesh vertex/edges + vtkSmartPointer edge_extractor = vtkSmartPointer::New(); + edge_extractor->SetInputData(out); + edge_extractor->Update(); + + vtkPolyData* tmp = edge_extractor->GetOutput(); + tmp->BuildCells(); + tmp->BuildLinks(); + + QList punti; + punti.reserve((int)tmp->GetNumberOfPoints()); + + point ptemp; + for (int id = 0; id < (int)tmp->GetNumberOfPoints(); ++id) + { + double* P = tmp->GetPoint(id); + ptemp.x = P[0]; + ptemp.y = P[1]; + ptemp.z = P[2]; + punti.append(ptemp); + } + + tmp_p.centroid = centroid(punti); + punti.clear(); + + final_list.append(tmp_p); + } + } + + for (int ii = 0; ii < final_list.size(); ++ii) + { + std::cout << 1000 * final_list.at(ii).centroid.x << " " + << 1000 * final_list.at(ii).centroid.y << " " + << 1000 * final_list.at(ii).centroid.z << std::endl; + } + + emit localizationEnd(final_list); +} + +// +// +///** +// * Centroid calculation of a given points cloud +// */ +point gLocalize::centroid(QList< point > punti) +{ + int i; + point centroide; + centroide.x=0,centroide.y=0,centroide.z=0; + for ( i=0;id2 && d1>d3) return d1; + if(d2>d1 && d2>d3) return d2; + if(d3>d2 && d3>d1) return d3; + return 9999; +} + + +int gLocalize::get_byteorder() +{ + union { + long l; + char c[4]; + } test; + test.l = 1; + if( test.c[3] && !test.c[2] && !test.c[1] && !test.c[0] ) + return ORDER_BIGENDIAN; + + if( !test.c[3] && !test.c[2] && !test.c[1] && test.c[0] ) + return ORDER_LITTLEENDIAN; + + return ORDER_UNKNOWN; +} + +/** + * Implementation of the Hausdorff distance from a reference 1 cm diameter sphere + * Uses the current extracted surface polydata (one region). + */ +double gLocalize::hausdorff(vtkPolyData* surface, surf tempsurf) +{ + if (!surface || surface->GetNumberOfPoints() == 0) + return 1e9; // or 0, but "far" is safer for filtering + + vtkSmartPointer source_sphere = vtkSmartPointer::New(); + source_sphere->SetCenter(tempsurf.center[0], tempsurf.center[1], tempsurf.center[2]); + source_sphere->SetRadius(5.0); + source_sphere->Update(); + + vtkPolyData* sphere = source_sphere->GetOutput(); + sphere->BuildCells(); + + // Extract edges from the *surface polydata*, not from a filter output port + vtkSmartPointer edge_extractor = vtkSmartPointer::New(); + edge_extractor->SetInputData(surface); + edge_extractor->Update(); + + vtkPolyData* tmp = edge_extractor->GetOutput(); + tmp->BuildCells(); + tmp->BuildLinks(); + + QList punti_sup; + punti_sup.reserve((int)tmp->GetNumberOfPoints()); + + point ptemp; + for (int id = 0; id < (int)tmp->GetNumberOfPoints(); id++) { + double* p = tmp->GetPoint(id); + ptemp.x = p[0]; + ptemp.y = p[1]; + ptemp.z = p[2]; + punti_sup.append(ptemp); + } + + QList punti_sphere; + punti_sphere.reserve((int)sphere->GetNumberOfPoints()); + + for (int id = 0; id < (int)sphere->GetNumberOfPoints(); id++) { + double* p = sphere->GetPoint(id); + ptemp.x = p[0]; + ptemp.y = p[1]; + ptemp.z = p[2]; + punti_sphere.append(ptemp); + } + + int nr_source_points = punti_sup.count(); + int nr_target_points = punti_sphere.count(); + + double maxmin = -1e9; + + for (int i = 0; i < nr_source_points; i++) { + double smallest = 1e9; + + double x1 = punti_sup.at(i).x; + double y1 = punti_sup.at(i).y; + double z1 = punti_sup.at(i).z; + + for (int j = 0; j < nr_target_points; j++) { + double x2 = punti_sphere.at(j).x; + double y2 = punti_sphere.at(j).y; + double z2 = punti_sphere.at(j).z; + + double dx = x1 - x2; + double dy = y1 - y2; + double dz = z1 - z2; + + double dist = dx*dx + dy*dy + dz*dz; // squared distance + + if (dist < smallest) smallest = dist; + } + + if (smallest > maxmin) maxmin = smallest; // max of mins + } + + punti_sphere.clear(); + punti_sup.clear(); + + return maxmin; // squared Hausdorff +} diff --git a/legacy/gLocalize_legacy.h b/legacy/gLocalize_legacy.h new file mode 100644 index 0000000..55e8fe6 --- /dev/null +++ b/legacy/gLocalize_legacy.h @@ -0,0 +1,213 @@ +#ifndef _GLOCALIZE_H_ +#define _GLOCALIZE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "gSkullRemoval.h" + +#include +#include +#include +#include +#include +#include +//#include "gTRiPtools_b.h" +#include +//#include "resampler.h" +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +//#include +#include +#include +#include +#include +// #include +#include +#include +//#include +#include +#include +#include +#include +#include + + + + +#define ORDER_BIGENDIAN 0 +#define ORDER_LITTLEENDIAN 1 +#define ORDER_UNKNOWN 2 + +// Some Macros to make the code more readable +// + +//#ifndef SWAP_TMP_INT +// #define SWAP_TMP_INT +// #define EVAL_INDEX(X,Y,L) (reference[ (Y)*(L) +(X)]) +// int swap_tmp_int; +// #define INT_SWAP(X,Y) swap_tmp_int=X; X=Y; Y=swap_tmp_int; +//#endif +// +// + +#define N_ITERAZ_ICP 100 + + +typedef struct point { + +public: +double x; +double y; +double z; +}point; + + +typedef struct surf { + +public: +int sorting; +int surfn; +double lenght; +int ntriangle; +int npoint; +double bounds[6]; +double center[3]; +double volume; +int ismarker; +point centroid; +double centroid_median [3]; +point fitting ; +double confronto_lati; +double hausdorff; +}surf; + + + + + +class gLocalize : public QObject{ + +Q_OBJECT + +public: + gLocalize(); + +public slots: + void localize(vtkImageData* vol, + int march_tresh, + double thrDown_D, + double thrUp_D, + double thr_HAUSD, + double thr_S, + QList selectedFilters); + void callAbort(){ + cout<< "Aborted" <); + void localizationProgress(int); + void localizationAborted(); + +private: + //double hausdorff(vtkPolyDataConnectivityFilter* filter, surf tempsurf); + double hausdorff(vtkPolyData* surface, surf tempsurf); + int get_byteorder(); + double lati(double p[6]); + point centroid(QList< point > punti); + volatile bool abortSignal; + + + /** + * Functions for Qlist sorting + */ + bool lenghtLessThan(const surf &d1, const surf &d2){ return d1.lenght > d2.lenght; }; + bool tringleLessThan(const surf &d1, const surf &d2){ return d1.ntriangle > d2.ntriangle; }; + bool zLessThan(const surf &d1, const surf &d2){ return d1.center[2] < d2.center[2]; }; + bool confronto_latiLessThan(const surf &d1, const surf &d2){return d1.confronto_lati - +#include "mainw.h" +#include + #include -#include -#include - -#include - -void Ui_MainWindow::setupUi(QMainWindow *MainWindow) -{ - if (MainWindow->objectName().isEmpty()) - MainWindow->setObjectName(QString::fromUtf8("MainWindow")); - MainWindow->resize(872, 737); - actionLoad = new QAction(MainWindow); - actionLoad->setObjectName(QString::fromUtf8("actionLoad")); - actionQuit = new QAction(MainWindow); - actionQuit->setObjectName(QString::fromUtf8("actionQuit")); - actionVolRen = new QAction(MainWindow); - actionVolRen->setObjectName(QString::fromUtf8("actionVolRen")); - actionVolRen->setCheckable(true); - actionOrthoslice = new QAction(MainWindow); - actionOrthoslice->setObjectName(QString::fromUtf8("actionOrthoslice")); - actionOrthoslice->setCheckable(true); - viewGroup = new QActionGroup(MainWindow); - viewGroup->addAction(actionVolRen); - viewGroup->addAction(actionOrthoslice); - actionOrthoslice->setChecked(true); - centralwidget = new QWidget(MainWindow); - centralwidget->setObjectName(QString::fromUtf8("centralwidget")); - horizontalLayout_8 = new QHBoxLayout(centralwidget); - horizontalLayout_8->setObjectName(QString::fromUtf8("horizontalLayout_8")); - widget = new QWidget(centralwidget); - widget->setObjectName(QString::fromUtf8("widget")); - widget->setMaximumSize(QSize(300, 16777215)); - widget->setMinimumSize(QSize(300, 0)); - verticalLayout_5 = new QVBoxLayout(widget); - verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5")); - frame_2 = new QFrame(widget); - frame_2->setObjectName(QString::fromUtf8("frame_2")); - frame_2->setFrameShape(QFrame::StyledPanel); - frame_2->setFrameShadow(QFrame::Raised); - verticalLayout_2 = new QVBoxLayout(frame_2); - verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2")); - formLayout_2 = new QFormLayout(); - formLayout_2->setObjectName(QString::fromUtf8("formLayout_2")); - label_6 = new QLabel(frame_2); - label_6->setObjectName(QString::fromUtf8("label_6")); - - formLayout_2->setWidget(0, QFormLayout::LabelRole, label_6); - - l_patientID = new QLabel(frame_2); - l_patientID->setObjectName(QString::fromUtf8("l_patientID")); - l_patientID->setMinimumSize(QSize(91, 0)); - - formLayout_2->setWidget(0, QFormLayout::FieldRole, l_patientID); - - label_8 = new QLabel(frame_2); - label_8->setObjectName(QString::fromUtf8("label_8")); - - formLayout_2->setWidget(1, QFormLayout::LabelRole, label_8); - - l_patientID_2 = new QLabel(frame_2); - l_patientID_2->setObjectName(QString::fromUtf8("l_patientID_2")); - l_patientID_2->setMinimumSize(QSize(91, 0)); - - formLayout_2->setWidget(1, QFormLayout::FieldRole, l_patientID_2); - - - label_12 = new QLabel(frame_2); - label_12->setObjectName(QString::fromUtf8("label_12")); - - formLayout_2->setWidget(5, QFormLayout::LabelRole, label_12); - - l_patientID_6 = new QLabel(frame_2); - l_patientID_6->setObjectName(QString::fromUtf8("l_patientID_6")); - l_patientID_6->setMinimumSize(QSize(91, 0)); - - formLayout_2->setWidget(5, QFormLayout::FieldRole, l_patientID_6); - - label_isoV = new QLabel(frame_2); - label_isoV->setObjectName(QString::fromUtf8("label_isoV")); - label_isoV->setText("Virtual Iso:"); - label_isoV->setMinimumSize(QSize(91, 0)); - formLayout_2->setWidget(6, QFormLayout::LabelRole, label_isoV); - - l_isoV = new QLabel(frame_2); - l_isoV->setObjectName(QString::fromUtf8("l_isoV")); - l_isoV->setText("N.a."); - l_isoV->setMinimumSize(QSize(91, 0)); - formLayout_2->setWidget(6, QFormLayout::FieldRole, l_isoV); - - verticalLayout_2->addLayout(formLayout_2); - - - verticalLayout_5->addWidget(frame_2); - - frame_5 = new QFrame(widget); - frame_5->setObjectName(QString::fromUtf8("frame_5")); - frame_5->setFrameShape(QFrame::StyledPanel); - frame_5->setFrameShadow(QFrame::Raised); - verticalLayout_4 = new QVBoxLayout(frame_5); - verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4")); - horizontalLayout_7 = new QHBoxLayout(); - horizontalLayout_7->setObjectName(QString::fromUtf8("horizontalLayout_7")); - label_7 = new QLabel(frame_5); - label_7->setObjectName(QString::fromUtf8("label_7")); - - horizontalLayout_7->addWidget(label_7); - - pushButton_5 = new QPushButton(frame_5); - pushButton_5->setObjectName(QString::fromUtf8("pushButton_5")); - pushButton_5->setEnabled(true); - - horizontalLayout_7->addWidget(pushButton_5); - - - verticalLayout_4->addLayout(horizontalLayout_7); - - - QHBoxLayout* 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")); - l_manualMask->setText("Manual volume clip"); - - manualMask_lay->addWidget(l_manualMask); - - pb_manualMask = new QPushButton(frame_5); - pb_manualMask->setObjectName(QString::fromUtf8("pb_manualMask")); - pb_manualMask->setEnabled(true); - pb_manualMask->setText("View"); - pb_manualMask->setCheckable(true); - - manualMask_lay->addWidget(pb_manualMask); - verticalLayout_4->addLayout(manualMask_lay); - - - verticalLayout_5->addWidget(frame_5); - - frame_3 = new QFrame(widget); - frame_3->setObjectName(QString::fromUtf8("frame_3")); - frame_3->setEnabled(true); - frame_3->setFrameShape(QFrame::StyledPanel); - frame_3->setFrameShadow(QFrame::Raised); - verticalLayout = new QVBoxLayout(frame_3); - verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); - horizontalLayout = new QHBoxLayout(); - horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); - label = new QLabel(frame_3); - label->setObjectName(QString::fromUtf8("label")); - - horizontalLayout->addWidget(label); - - horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - horizontalLayout->addItem(horizontalSpacer); - - spinBox = new QSpinBox(frame_3); - spinBox->setObjectName(QString::fromUtf8("spinBox")); - spinBox->setMinimumSize(QSize(71, 0)); - spinBox->setMaximumSize(QSize(71, 16777215)); - spinBox->setMinimum(-1024); - spinBox->setMaximum(3000); - spinBox->setValue(1800); - - horizontalLayout->addWidget(spinBox); - - - verticalLayout->addLayout(horizontalLayout); - - horizontalLayout_2 = new QHBoxLayout(); - horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); - checkBox_2 = new QCheckBox(frame_3); - checkBox_2->setObjectName(QString::fromUtf8("checkBox_2")); - checkBox_2->setChecked(true); - - horizontalLayout_2->addWidget(checkBox_2); - - label_2 = new QLabel(frame_3); - label_2->setObjectName(QString::fromUtf8("label_2")); - - horizontalLayout_2->addWidget(label_2); - - horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - horizontalLayout_2->addItem(horizontalSpacer_2); - - doubleSpinBox_2 = new QDoubleSpinBox(frame_3); - doubleSpinBox_2->setObjectName(QString::fromUtf8("doubleSpinBox_2")); - doubleSpinBox_2->setMinimumSize(QSize(71, 0)); - doubleSpinBox_2->setMaximumSize(QSize(71, 16777215)); - - horizontalLayout_2->addWidget(doubleSpinBox_2); - - doubleSpinBox_2bis = new QDoubleSpinBox(frame_3); - doubleSpinBox_2bis->setObjectName(QString::fromUtf8("doubleSpinBox_2bis")); - doubleSpinBox_2bis->setMinimumSize(QSize(71, 0)); - doubleSpinBox_2bis->setMaximumSize(QSize(71, 16777215)); - - horizontalLayout_2->addWidget(doubleSpinBox_2bis); - - - - verticalLayout->addLayout(horizontalLayout_2); - - horizontalLayout_3 = new QHBoxLayout(); - horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3")); - checkBox_3 = new QCheckBox(frame_3); - checkBox_3->setObjectName(QString::fromUtf8("checkBox_3")); - checkBox_3->setChecked(true); - - horizontalLayout_3->addWidget(checkBox_3); - - label_3 = new QLabel(frame_3); - label_3->setObjectName(QString::fromUtf8("label_3")); - - horizontalLayout_3->addWidget(label_3); - - horizontalSpacer_3 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - horizontalLayout_3->addItem(horizontalSpacer_3); - - doubleSpinBox_3 = new QDoubleSpinBox(frame_3); - doubleSpinBox_3->setObjectName(QString::fromUtf8("doubleSpinBox_3")); - doubleSpinBox_3->setMinimumSize(QSize(71, 0)); - doubleSpinBox_3->setMaximumSize(QSize(71, 16777215)); - doubleSpinBox_3->setMaximum(999999); - doubleSpinBox_3->setValue(22); - - horizontalLayout_3->addWidget(doubleSpinBox_3); - - - verticalLayout->addLayout(horizontalLayout_3); - - horizontalLayout_5 = new QHBoxLayout(); - horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5")); - checkBox_5 = new QCheckBox(frame_3); - checkBox_5->setObjectName(QString::fromUtf8("checkBox_5")); - checkBox_5->setChecked(true); - - horizontalLayout_5->addWidget(checkBox_5); - - label_5 = new QLabel(frame_3); - label_5->setObjectName(QString::fromUtf8("label_5")); - - horizontalLayout_5->addWidget(label_5); - - horizontalSpacer_5 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - horizontalLayout_5->addItem(horizontalSpacer_5); - - doubleSpinBox_5 = new QDoubleSpinBox(frame_3); - doubleSpinBox_5->setObjectName(QString::fromUtf8("doubleSpinBox_5")); - doubleSpinBox_5->setMinimumSize(QSize(71, 0)); - doubleSpinBox_5->setMaximumSize(QSize(71, 16777215)); - - horizontalLayout_5->addWidget(doubleSpinBox_5); - - - verticalLayout->addLayout(horizontalLayout_5); - - horizontalLayout_6 = new QHBoxLayout(); - horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6")); - pushButton_3 = new QPushButton(frame_3); - pushButton_3->setObjectName(QString::fromUtf8("pushButton_3")); - pushButton_3->setEnabled(true); - - horizontalLayout_6->addWidget(pushButton_3); - - pushButton_4 = new QPushButton(frame_3); - pushButton_4->setObjectName(QString::fromUtf8("pushButton_4")); - pushButton_4->setEnabled(false); - - horizontalLayout_6->addWidget(pushButton_4); - - - verticalLayout->addLayout(horizontalLayout_6); - - - verticalLayout_5->addWidget(frame_3); - - frame_4 = new QFrame(widget); - frame_4->setObjectName(QString::fromUtf8("frame_4")); - frame_4->setEnabled(true); - frame_4->setMaximumSize(QSize(16777215, 171)); - frame_4->setFrameShape(QFrame::StyledPanel); - frame_4->setFrameShadow(QFrame::Raised); - verticalLayout_3 = new QVBoxLayout(frame_4); - verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3")); - treeView = new QTreeView(frame_4); - //new QTreeWidgetItem(treeWidget); - treeView->setObjectName(QString::fromUtf8("treeView")); - treeView->setEnabled(true); - treeView->setFrameShape(QFrame::StyledPanel); - // treeView->setAlternatingRowColors(true); - treeView->setUniformRowHeights(true); - treeView->setSortingEnabled(false); - treeView->setAnimated(true); - treeView->setAllColumnsShowFocus(false); - //treeView->setColumnCount(5); - treeView->header()->setVisible(true); - treeView->header()->setCascadingSectionResizes(false); - treeView->header()->setHighlightSections(true); - treeView->header()->setStretchLastSection(true); - - verticalLayout_3->addWidget(treeView); - - formLayout = new QHBoxLayout(); - formLayout->setObjectName(QString::fromUtf8("formLayout")); - pushButton = new QPushButton(frame_4); - pushButton->setObjectName(QString::fromUtf8("pushButton")); - pushButton->setEnabled(false); - - formLayout->addWidget(pushButton); - - pushButton_2 = new QPushButton(frame_4); - pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); - pushButton_2->setEnabled(false); - - formLayout->addWidget(pushButton_2); - - pb_save= new QPushButton(frame_4); - pb_save->setObjectName(QString::fromUtf8("pb_save")); - pb_save->setText("Save .tac"); - formLayout->addWidget(pb_save); - pb_save->setEnabled(false); - - verticalLayout_3->addLayout(formLayout); - - verticalLayout_5->addWidget(frame_4); - - - horizontalLayout_8->addWidget(widget); - - frame = new QFrame(centralwidget); - frame->setObjectName(QString::fromUtf8("frame")); - frame->setMinimumSize(QSize(561, 0)); - frame->setFrameShape(QFrame::StyledPanel); - frame->setFrameShadow(QFrame::Raised); - - QHBoxLayout* renLay= new QHBoxLayout(frame); - qvtk= new QVTKOpenGLNativeWidget(frame); - renLay->addWidget(qvtk); - horizontalLayout_8->addWidget(frame); - - MainWindow->setCentralWidget(centralwidget); - statusbar = new QStatusBar(MainWindow); - statusbar->setObjectName(QString::fromUtf8("statusbar")); - MainWindow->setStatusBar(statusbar); - toolBar = new QToolBar(MainWindow); - toolBar->setObjectName(QString::fromUtf8("toolBar")); - MainWindow->addToolBar(Qt::TopToolBarArea, toolBar); - - toolBar->addAction(actionLoad); - toolBar->addSeparator(); - toolBar->addAction(actionVolRen); - toolBar->addAction(actionOrthoslice); - toolBar->addSeparator(); - - -#ifdef MULTIPLE_REF - - QWidget* qw_refs = new QWidget(toolBar); - a_DCMref=new QRadioButton(qw_refs); - a_DCMref->setCheckable(true); - a_DCMref->setText("DCM"); - a_RTref=new QRadioButton(qw_refs); - a_RTref->setCheckable(true); - a_RTref->setText("RT"); - a_OTSref=new QRadioButton(qw_refs); - a_OTSref->setText("OTS"); - a_OTSref->setCheckable(true); - a_DCMref->setChecked(true); - - refGroup = new QButtonGroup(qw_refs); - refGroup->addButton (a_DCMref); - refGroup->addButton(a_RTref); - refGroup->addButton(a_OTSref); - - QHBoxLayout* reflay=new QHBoxLayout(qw_refs); - reflay->addWidget(a_DCMref); - reflay->addWidget(a_RTref); - reflay->addWidget(a_OTSref); - - a_RTref->setDisabled(true); - - toolBar->addWidget(qw_refs); -#endif - - QWidget *widget = new QWidget; - QHBoxLayout *spacerLayout = new QHBoxLayout; - QSpacerItem *spacer = - new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Minimum); - spacerLayout->addSpacerItem(spacer); - widget->setLayout(spacerLayout); - toolBar->addWidget(widget); - toolBar->addAction(actionQuit); - - progBar = new QProgressBar(MainWindow); - progBar->setMinimum(0); - progBar->setMaximum(100); - progBar->setMaximumHeight(15); - statusbar->addPermanentWidget(progBar); - - return; -} // setupUi - - - -void MainWindow::onSkullMaskingUpdt(QString msg, double val){ - Ui->progBar->setValue(val*100); - QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, msg ), - Q_ARG(int, 0)); - return; -} - - -void MainWindow::call_quit(){ - - loadPatient_thread->quit(); - localize_thread->quit(); - skull_thread->quit(); - sleep(1); - //Sleep(100); - cout<< "Bye bye" <l_isoV->clear(); - (IsoV == true? Ui->l_isoV->setText("Yes") : Ui->l_isoV->setText("No") ); - return; -} - -void MainWindow::showEvent(QShowEvent* e) -{ - QMainWindow::showEvent(e); - static bool done = false; - if (done) return; - done = true; - Visualizer->init(); -} - -#include -#include - -MainWindow::MainWindow(QString p_loadPath){ - - Ui = new Ui_MainWindow; - Ui->setupUi(this); - this->retranslateUi(Ui,this); - this->connectUi(Ui); - Ui->actionVolRen->setEnabled(false); - Ui->actionOrthoslice->setEnabled(false); - Ui->pushButton_3->setEnabled(false); - Ui->pb_manualMask->setEnabled(false); - Ui->pushButton_5->setEnabled(false); - - auto rw = vtkSmartPointer::New(); - Ui->qvtk->setRenderWindow(rw); - Visualizer= new gRen(Ui->qvtk); - - loadPatient= new gLoadPatient; - loadPatient_thread = new QThread; - loadPatient->moveToThread(loadPatient_thread); - loadPatient_thread->start(); - - qRegisterMetaType< gPatientRTGeneralInfos* >("gPatientRTGeneralInfos *"); - qRegisterMetaType< std::vector >("std::vector"); - qRegisterMetaType< std::string >("std::string"); - qRegisterMetaType< vtkImageData* >("vtkImageData*"); - qRegisterMetaType < QList > ("QList"); - - connect(loadPatient, SIGNAL(loadEnd(vtkImageData*)), Visualizer,SLOT(loadVolume (vtkImageData* ))); - connect(loadPatient, SIGNAL(folderIsEmpty()),this,SLOT(onParsedEmptyFolder())); - connect(loadPatient, SIGNAL(parse_result(int , gPatientRTGeneralInfos* )),this,SLOT(onParsedOK(int , gPatientRTGeneralInfos* ))); - connect(loadPatient, SIGNAL(loadedRTIso(double*)),this,SLOT(onRTIsoAvailable(double*))); - connect(loadPatient, SIGNAL(loadedVolBBox(double*, double*, int*)),this,SLOT(onCTVolumeAvailable(double*,double*,int*))); - connect(loadPatient, SIGNAL(virtualIsoTested(bool)),this,SLOT(onVirtualIsoTested(bool))); - - +#include +#include + +#include + +void Ui_MainWindow::setupUi(QMainWindow *MainWindow) +{ + if (MainWindow->objectName().isEmpty()) + MainWindow->setObjectName(QString::fromUtf8("MainWindow")); + MainWindow->resize(872, 737); + actionLoad = new QAction(MainWindow); + actionLoad->setObjectName(QString::fromUtf8("actionLoad")); + actionQuit = new QAction(MainWindow); + actionQuit->setObjectName(QString::fromUtf8("actionQuit")); + actionVolRen = new QAction(MainWindow); + actionVolRen->setObjectName(QString::fromUtf8("actionVolRen")); + actionVolRen->setCheckable(true); + actionOrthoslice = new QAction(MainWindow); + actionOrthoslice->setObjectName(QString::fromUtf8("actionOrthoslice")); + actionOrthoslice->setCheckable(true); + viewGroup = new QActionGroup(MainWindow); + viewGroup->addAction(actionVolRen); + viewGroup->addAction(actionOrthoslice); + actionOrthoslice->setChecked(true); + centralwidget = new QWidget(MainWindow); + centralwidget->setObjectName(QString::fromUtf8("centralwidget")); + horizontalLayout_8 = new QHBoxLayout(centralwidget); + horizontalLayout_8->setObjectName(QString::fromUtf8("horizontalLayout_8")); + widget = new QWidget(centralwidget); + widget->setObjectName(QString::fromUtf8("widget")); + widget->setMaximumSize(QSize(300, 16777215)); + widget->setMinimumSize(QSize(300, 0)); + verticalLayout_5 = new QVBoxLayout(widget); + verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5")); + frame_2 = new QFrame(widget); + frame_2->setObjectName(QString::fromUtf8("frame_2")); + frame_2->setFrameShape(QFrame::StyledPanel); + frame_2->setFrameShadow(QFrame::Raised); + verticalLayout_2 = new QVBoxLayout(frame_2); + verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2")); + formLayout_2 = new QFormLayout(); + formLayout_2->setObjectName(QString::fromUtf8("formLayout_2")); + label_6 = new QLabel(frame_2); + label_6->setObjectName(QString::fromUtf8("label_6")); + + formLayout_2->setWidget(0, QFormLayout::LabelRole, label_6); + + l_patientID = new QLabel(frame_2); + l_patientID->setObjectName(QString::fromUtf8("l_patientID")); + l_patientID->setMinimumSize(QSize(91, 0)); + + formLayout_2->setWidget(0, QFormLayout::FieldRole, l_patientID); + + label_8 = new QLabel(frame_2); + label_8->setObjectName(QString::fromUtf8("label_8")); + + formLayout_2->setWidget(1, QFormLayout::LabelRole, label_8); + + l_patientID_2 = new QLabel(frame_2); + l_patientID_2->setObjectName(QString::fromUtf8("l_patientID_2")); + l_patientID_2->setMinimumSize(QSize(91, 0)); + + formLayout_2->setWidget(1, QFormLayout::FieldRole, l_patientID_2); + + + label_12 = new QLabel(frame_2); + label_12->setObjectName(QString::fromUtf8("label_12")); + + formLayout_2->setWidget(5, QFormLayout::LabelRole, label_12); + + l_patientID_6 = new QLabel(frame_2); + l_patientID_6->setObjectName(QString::fromUtf8("l_patientID_6")); + l_patientID_6->setMinimumSize(QSize(91, 0)); + + formLayout_2->setWidget(5, QFormLayout::FieldRole, l_patientID_6); + + label_isoV = new QLabel(frame_2); + label_isoV->setObjectName(QString::fromUtf8("label_isoV")); + label_isoV->setText("Virtual Iso:"); + label_isoV->setMinimumSize(QSize(91, 0)); + formLayout_2->setWidget(6, QFormLayout::LabelRole, label_isoV); + + l_isoV = new QLabel(frame_2); + l_isoV->setObjectName(QString::fromUtf8("l_isoV")); + l_isoV->setText("N.a."); + l_isoV->setMinimumSize(QSize(91, 0)); + formLayout_2->setWidget(6, QFormLayout::FieldRole, l_isoV); + + verticalLayout_2->addLayout(formLayout_2); + + + verticalLayout_5->addWidget(frame_2); + + frame_5 = new QFrame(widget); + frame_5->setObjectName(QString::fromUtf8("frame_5")); + frame_5->setFrameShape(QFrame::StyledPanel); + frame_5->setFrameShadow(QFrame::Raised); + verticalLayout_4 = new QVBoxLayout(frame_5); + verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4")); + horizontalLayout_7 = new QHBoxLayout(); + horizontalLayout_7->setObjectName(QString::fromUtf8("horizontalLayout_7")); + label_7 = new QLabel(frame_5); + label_7->setObjectName(QString::fromUtf8("label_7")); + + horizontalLayout_7->addWidget(label_7); + + pushButton_5 = new QPushButton(frame_5); + pushButton_5->setObjectName(QString::fromUtf8("pushButton_5")); + pushButton_5->setEnabled(true); + + horizontalLayout_7->addWidget(pushButton_5); + + + verticalLayout_4->addLayout(horizontalLayout_7); + + + QHBoxLayout* 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")); + l_manualMask->setText("Manual volume clip"); + + manualMask_lay->addWidget(l_manualMask); + + pb_manualMask = new QPushButton(frame_5); + pb_manualMask->setObjectName(QString::fromUtf8("pb_manualMask")); + pb_manualMask->setEnabled(true); + pb_manualMask->setText("View"); + pb_manualMask->setCheckable(true); + + manualMask_lay->addWidget(pb_manualMask); + verticalLayout_4->addLayout(manualMask_lay); + + + verticalLayout_5->addWidget(frame_5); + + frame_3 = new QFrame(widget); + frame_3->setObjectName(QString::fromUtf8("frame_3")); + frame_3->setEnabled(true); + frame_3->setFrameShape(QFrame::StyledPanel); + frame_3->setFrameShadow(QFrame::Raised); + verticalLayout = new QVBoxLayout(frame_3); + verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); + horizontalLayout = new QHBoxLayout(); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + label = new QLabel(frame_3); + label->setObjectName(QString::fromUtf8("label")); + + horizontalLayout->addWidget(label); + + horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + horizontalLayout->addItem(horizontalSpacer); + + spinBox = new QSpinBox(frame_3); + spinBox->setObjectName(QString::fromUtf8("spinBox")); + spinBox->setMinimumSize(QSize(71, 0)); + spinBox->setMaximumSize(QSize(71, 16777215)); + spinBox->setMinimum(-1024); + spinBox->setMaximum(3000); + spinBox->setValue(1800); + + horizontalLayout->addWidget(spinBox); + + + verticalLayout->addLayout(horizontalLayout); + + horizontalLayout_2 = new QHBoxLayout(); + horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); + checkBox_2 = new QCheckBox(frame_3); + checkBox_2->setObjectName(QString::fromUtf8("checkBox_2")); + checkBox_2->setChecked(true); + + horizontalLayout_2->addWidget(checkBox_2); + + label_2 = new QLabel(frame_3); + label_2->setObjectName(QString::fromUtf8("label_2")); + + horizontalLayout_2->addWidget(label_2); + + horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + horizontalLayout_2->addItem(horizontalSpacer_2); + + doubleSpinBox_2 = new QDoubleSpinBox(frame_3); + doubleSpinBox_2->setObjectName(QString::fromUtf8("doubleSpinBox_2")); + doubleSpinBox_2->setMinimumSize(QSize(71, 0)); + doubleSpinBox_2->setMaximumSize(QSize(71, 16777215)); + + horizontalLayout_2->addWidget(doubleSpinBox_2); + + doubleSpinBox_2bis = new QDoubleSpinBox(frame_3); + doubleSpinBox_2bis->setObjectName(QString::fromUtf8("doubleSpinBox_2bis")); + doubleSpinBox_2bis->setMinimumSize(QSize(71, 0)); + doubleSpinBox_2bis->setMaximumSize(QSize(71, 16777215)); + + horizontalLayout_2->addWidget(doubleSpinBox_2bis); + + + + verticalLayout->addLayout(horizontalLayout_2); + + horizontalLayout_3 = new QHBoxLayout(); + horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3")); + checkBox_3 = new QCheckBox(frame_3); + checkBox_3->setObjectName(QString::fromUtf8("checkBox_3")); + checkBox_3->setChecked(true); + + horizontalLayout_3->addWidget(checkBox_3); + + label_3 = new QLabel(frame_3); + label_3->setObjectName(QString::fromUtf8("label_3")); + + horizontalLayout_3->addWidget(label_3); + + horizontalSpacer_3 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + horizontalLayout_3->addItem(horizontalSpacer_3); + + doubleSpinBox_3 = new QDoubleSpinBox(frame_3); + doubleSpinBox_3->setObjectName(QString::fromUtf8("doubleSpinBox_3")); + doubleSpinBox_3->setMinimumSize(QSize(71, 0)); + doubleSpinBox_3->setMaximumSize(QSize(71, 16777215)); + doubleSpinBox_3->setMaximum(999999); + doubleSpinBox_3->setValue(22); + + horizontalLayout_3->addWidget(doubleSpinBox_3); + + + verticalLayout->addLayout(horizontalLayout_3); + + horizontalLayout_5 = new QHBoxLayout(); + horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5")); + checkBox_5 = new QCheckBox(frame_3); + checkBox_5->setObjectName(QString::fromUtf8("checkBox_5")); + checkBox_5->setChecked(true); + + horizontalLayout_5->addWidget(checkBox_5); + + label_5 = new QLabel(frame_3); + label_5->setObjectName(QString::fromUtf8("label_5")); + + horizontalLayout_5->addWidget(label_5); + + horizontalSpacer_5 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + horizontalLayout_5->addItem(horizontalSpacer_5); + + doubleSpinBox_5 = new QDoubleSpinBox(frame_3); + doubleSpinBox_5->setObjectName(QString::fromUtf8("doubleSpinBox_5")); + doubleSpinBox_5->setMinimumSize(QSize(71, 0)); + doubleSpinBox_5->setMaximumSize(QSize(71, 16777215)); + + horizontalLayout_5->addWidget(doubleSpinBox_5); + + + verticalLayout->addLayout(horizontalLayout_5); + + horizontalLayout_6 = new QHBoxLayout(); + horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6")); + pushButton_3 = new QPushButton(frame_3); + pushButton_3->setObjectName(QString::fromUtf8("pushButton_3")); + pushButton_3->setEnabled(true); + + horizontalLayout_6->addWidget(pushButton_3); + + pushButton_4 = new QPushButton(frame_3); + pushButton_4->setObjectName(QString::fromUtf8("pushButton_4")); + pushButton_4->setEnabled(false); + + horizontalLayout_6->addWidget(pushButton_4); + + + verticalLayout->addLayout(horizontalLayout_6); + + + verticalLayout_5->addWidget(frame_3); + + frame_4 = new QFrame(widget); + frame_4->setObjectName(QString::fromUtf8("frame_4")); + frame_4->setEnabled(true); + frame_4->setMaximumSize(QSize(16777215, 171)); + frame_4->setFrameShape(QFrame::StyledPanel); + frame_4->setFrameShadow(QFrame::Raised); + verticalLayout_3 = new QVBoxLayout(frame_4); + verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3")); + treeView = new QTreeView(frame_4); + //new QTreeWidgetItem(treeWidget); + treeView->setObjectName(QString::fromUtf8("treeView")); + treeView->setEnabled(true); + treeView->setFrameShape(QFrame::StyledPanel); + // treeView->setAlternatingRowColors(true); + treeView->setUniformRowHeights(true); + treeView->setSortingEnabled(false); + treeView->setAnimated(true); + treeView->setAllColumnsShowFocus(false); + //treeView->setColumnCount(5); + treeView->header()->setVisible(true); + treeView->header()->setCascadingSectionResizes(false); + treeView->header()->setHighlightSections(true); + treeView->header()->setStretchLastSection(true); + + verticalLayout_3->addWidget(treeView); + + formLayout = new QHBoxLayout(); + formLayout->setObjectName(QString::fromUtf8("formLayout")); + pushButton = new QPushButton(frame_4); + pushButton->setObjectName(QString::fromUtf8("pushButton")); + pushButton->setEnabled(false); + + formLayout->addWidget(pushButton); + + pushButton_2 = new QPushButton(frame_4); + pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); + pushButton_2->setEnabled(false); + + formLayout->addWidget(pushButton_2); + + pb_save= new QPushButton(frame_4); + pb_save->setObjectName(QString::fromUtf8("pb_save")); + pb_save->setText("Save .tac"); + formLayout->addWidget(pb_save); + pb_save->setEnabled(false); + + verticalLayout_3->addLayout(formLayout); + + verticalLayout_5->addWidget(frame_4); + + + horizontalLayout_8->addWidget(widget); + + frame = new QFrame(centralwidget); + frame->setObjectName(QString::fromUtf8("frame")); + frame->setMinimumSize(QSize(561, 0)); + frame->setFrameShape(QFrame::StyledPanel); + frame->setFrameShadow(QFrame::Raised); + + QHBoxLayout* renLay= new QHBoxLayout(frame); + qvtk= new QVTKOpenGLNativeWidget(frame); + renLay->addWidget(qvtk); + horizontalLayout_8->addWidget(frame); + + MainWindow->setCentralWidget(centralwidget); + statusbar = new QStatusBar(MainWindow); + statusbar->setObjectName(QString::fromUtf8("statusbar")); + MainWindow->setStatusBar(statusbar); + toolBar = new QToolBar(MainWindow); + toolBar->setObjectName(QString::fromUtf8("toolBar")); + MainWindow->addToolBar(Qt::TopToolBarArea, toolBar); + + toolBar->addAction(actionLoad); + toolBar->addSeparator(); + toolBar->addAction(actionVolRen); + toolBar->addAction(actionOrthoslice); + toolBar->addSeparator(); + + +#ifdef MULTIPLE_REF + + QWidget* qw_refs = new QWidget(toolBar); + a_DCMref=new QRadioButton(qw_refs); + a_DCMref->setCheckable(true); + a_DCMref->setText("DCM"); + a_RTref=new QRadioButton(qw_refs); + a_RTref->setCheckable(true); + a_RTref->setText("RT"); + a_OTSref=new QRadioButton(qw_refs); + a_OTSref->setText("OTS"); + a_OTSref->setCheckable(true); + a_DCMref->setChecked(true); + + refGroup = new QButtonGroup(qw_refs); + refGroup->addButton (a_DCMref); + refGroup->addButton(a_RTref); + refGroup->addButton(a_OTSref); + + QHBoxLayout* reflay=new QHBoxLayout(qw_refs); + reflay->addWidget(a_DCMref); + reflay->addWidget(a_RTref); + reflay->addWidget(a_OTSref); + + a_RTref->setDisabled(true); + + toolBar->addWidget(qw_refs); +#endif + + QWidget *widget = new QWidget; + QHBoxLayout *spacerLayout = new QHBoxLayout; + QSpacerItem *spacer = + new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Minimum); + spacerLayout->addSpacerItem(spacer); + widget->setLayout(spacerLayout); + toolBar->addWidget(widget); + toolBar->addAction(actionQuit); + + progBar = new QProgressBar(MainWindow); + progBar->setMinimum(0); + progBar->setMaximum(100); + progBar->setMaximumHeight(15); + statusbar->addPermanentWidget(progBar); + + return; +} // setupUi + + + +void MainWindow::onSkullMaskingUpdt(QString msg, double val){ + Ui->progBar->setValue(val*100); + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, msg ), + Q_ARG(int, 0)); + return; +} + + +void MainWindow::call_quit(){ + + loadPatient_thread->quit(); + localize_thread->quit(); + skull_thread->quit(); + sleep(1); + //Sleep(100); + cout<< "Bye bye" <l_isoV->clear(); + (IsoV == true? Ui->l_isoV->setText("Yes") : Ui->l_isoV->setText("No") ); + return; +} + +void MainWindow::showEvent(QShowEvent* e) +{ + QMainWindow::showEvent(e); + static bool done = false; + if (done) return; + done = true; + Visualizer->init(); +} + +#include +#include + +MainWindow::MainWindow(QString p_loadPath){ + + Ui = new Ui_MainWindow; + Ui->setupUi(this); + this->retranslateUi(Ui,this); + this->connectUi(Ui); + Ui->actionVolRen->setEnabled(false); + Ui->actionOrthoslice->setEnabled(false); + Ui->pushButton_3->setEnabled(false); + Ui->pb_manualMask->setEnabled(false); + Ui->pushButton_5->setEnabled(false); + + auto rw = vtkSmartPointer::New(); + Ui->qvtk->setRenderWindow(rw); + Visualizer= new gRen(Ui->qvtk); + + loadPatient= new gLoadPatient; + loadPatient_thread = new QThread; + loadPatient->moveToThread(loadPatient_thread); + loadPatient_thread->start(); + + qRegisterMetaType< gPatientRTGeneralInfos* >("gPatientRTGeneralInfos *"); + qRegisterMetaType< std::vector >("std::vector"); + qRegisterMetaType< std::string >("std::string"); + qRegisterMetaType< vtkImageData* >("vtkImageData*"); + qRegisterMetaType < QList > ("QList"); + // For queued cross-thread signal/slot connections + qRegisterMetaType("Marker"); + qRegisterMetaType("MarkerList"); + qRegisterMetaType("LocalizationParams"); + + connect(loadPatient, SIGNAL(loadEnd(vtkImageData*)), Visualizer,SLOT(loadVolume (vtkImageData* ))); + connect(loadPatient, SIGNAL(folderIsEmpty()),this,SLOT(onParsedEmptyFolder())); + connect(loadPatient, SIGNAL(parse_result(int , gPatientRTGeneralInfos* )),this,SLOT(onParsedOK(int , gPatientRTGeneralInfos* ))); + connect(loadPatient, SIGNAL(loadedRTIso(double*)),this,SLOT(onRTIsoAvailable(double*))); + connect(loadPatient, SIGNAL(loadedVolBBox(double*, double*, int*)),this,SLOT(onCTVolumeAvailable(double*,double*,int*))); + connect(loadPatient, SIGNAL(virtualIsoTested(bool)),this,SLOT(onVirtualIsoTested(bool))); + + localize_thread = new QThread; localize_marker = new LocalizationWorker; localize_marker->moveToThread(localize_thread); @@ -499,209 +503,233 @@ MainWindow::MainWindow(QString p_loadPath){ connect(localize_marker, SIGNAL(finished(MarkerList)), this, SLOT(onLocalizationEnd(MarkerList))); connect(localize_marker, SIGNAL(progress(double)), this, SLOT(onLocalizationProgress(double))); - connect(localize_marker, SIGNAL(aborted()), this, SLOT(slot_localize_aborted())); - connect(localize_marker, SIGNAL(failed(QString)), this, SLOT(onLocalizationError(QString))); - - skullRemoval= new gSkullRemoval; - skull_thread= new QThread; - skullRemoval->moveToThread(skull_thread); - skull_thread->start(); - connect(skullRemoval, SIGNAL(skull_mask_end(vtkImageData *)),Visualizer,SLOT(onAutoSkullMaskEnd(vtkImageData* ))); - connect(skullRemoval, SIGNAL(skull_mask_end(vtkImageData *)),this,SLOT(onAutoSkullMaskEnd(vtkImageData* ))); - - connect(skullRemoval, SIGNAL(errMsg(QString)),this,SLOT(onAutoMaskError(QString ))); - connect(skullRemoval, SIGNAL(skull_mask_upd(QString , double )), this, SLOT(onSkullMaskingUpdt(QString,double))); - - - treeModel = new QStandardItemModel; - connect(treeModel,SIGNAL(itemChanged(QStandardItem*)),this,SLOT(onItemChanged(QStandardItem*))); - connect(Ui->viewGroup, SIGNAL(triggered(QAction*)), this, SLOT(onVisualizationTrigger(QAction* ))); - connect(Ui->pb_manualMask, SIGNAL(toggled ( bool )), this, SLOT(onManualMaskTrigger(bool))); -#ifdef MULTIPLE_REF - connect(Ui->refGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onRefTrigger(QAbstractButton*))); -#endif - loadDialog = new gLoadPatDialog; - connect(Visualizer, SIGNAL(PatientLoaded()),this,SLOT(onPatientlLoaded())); - - - QSettings *config = new QSettings ("config.ini",QSettings::IniFormat); - pathIn = config->value("Path/inDir").toString(); - pathOut = config->value("Path/outDir").toString(); - - - /*default values*/ - Ui->spinBox->setValue(config->value("fiducialsLocalize/markerIntensity").toInt()); - Ui->doubleSpinBox_2->setValue(config->value("fiducialsLocalize/boxDiag_down").toDouble()); - Ui->doubleSpinBox_2bis->setValue(config->value("fiducialsLocalize/boxDiag_up").toDouble()); - Ui->doubleSpinBox_3->setValue(config->value("fiducialsLocalize/hausdDist").toDouble()); - Ui->doubleSpinBox_5->setValue(config->value("fiducialsLocalize/boxSidesDiff").toDouble()); - regGrownParameters[0]=config->value("skullMask/regGrow_up").toDouble(); - regGrownParameters[1]=config->value("skullMask/regGrow_down").toDouble(); - - - - delete config; - - - connect(localize_marker, SIGNAL(localizationAborted()), - this,SLOT(onLocalizationAborted())); - connect(loadPatient,SIGNAL(referenceChange(double, double, double )), - Visualizer,SLOT(onReferenceChange(double, double , double))); - connect(loadPatient,SIGNAL(referenceChange(double, double, double )), - this,SLOT(updateMarkerPos(double, double , double))); - - /*load passed workdir if any*/ - loadPath.clear(); - /*first check for argv [1]*/ - if(p_loadPath.isEmpty()) { - /*then check for ini inDir*/ - if(!pathIn.isEmpty()) - loadPath=pathIn; - } else - loadPath=p_loadPath; - - if(loadPath.isEmpty()){ - cout<< "loadpath is emty" <show(); - cout<< "loadPath: "<statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, QString("Masking Done") ), - Q_ARG(int, 3000)); - - Ui->progBar->reset(); - QApplication::restoreOverrideCursor(); - - Ui->pb_manualMask->setEnabled(true); - Ui->pushButton_5->setEnabled(true); - Ui->frame_3->setEnabled(true); - Ui->frame_4->setEnabled(true); - - return; -} - -void MainWindow::onPatientlLoaded(){ - QApplication::restoreOverrideCursor(); - - Ui->pushButton_5->setEnabled(true); - Ui->pb_manualMask->setEnabled(true); - Ui->actionVolRen->setEnabled(true); - Ui->actionOrthoslice->setEnabled(true); - Ui->pushButton_3->setEnabled(true); - - loadDialog->close(); - Ui->actionLoad->setEnabled(false); - - Ui->pb_manualMask->setEnabled(true); - Ui->pushButton_5->setEnabled(true); - Ui->pushButton_4->setEnabled(false); - Ui->pushButton_3->setEnabled(true); - return; -} - -void MainWindow::onParsedEmptyFolder(){ - QApplication::restoreOverrideCursor(); - loadDialog->close(); - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Icon::Critical); - msgBox.setText("Load failed..."); - msgBox.setInformativeText("Parsed directory is empty or does not contain CT."); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret = msgBox.exec(); - return; -} - -void MainWindow::setStatusMsg(QString msg, int timeout){ - QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, msg ), - Q_ARG(int, timeout)); - return; -} - -void MainWindow::retranslateUi(Ui_MainWindow* Ui, QMainWindow *MainWindow) { - MainWindow->setWindowTitle(QApplication::translate("MainWindow", "gLocalize - Fondazione CNAO - Politecnico di Milano - 2014", 0)); - Ui->actionLoad->setText(QApplication::translate("MainWindow", "Load", 0)); - Ui->actionLoad->setIcon(QIcon(":/icons/pb_load.png")); -#ifndef QT_NO_TOOLTIP - Ui->actionLoad->setToolTip(QApplication::translate("MainWindow", "Load patient data", 0)); -#endif // QT_NO_TOOLTIP - Ui->actionQuit->setText(QApplication::translate("MainWindow", "Quit", 0)); - Ui->actionQuit->setIcon(QIcon(":/icons/pb_quit.png")); -#ifndef QT_NO_TOOLTIP - Ui->actionQuit->setToolTip(QApplication::translate("MainWindow", "Quit application", 0)); -#endif // QT_NO_TOOLTIP - Ui->actionVolRen->setText(QApplication::translate("MainWindow", "VolRen", 0)); -#ifndef QT_NO_TOOLTIP - Ui->actionVolRen->setToolTip(QApplication::translate("MainWindow", "Volume rendering", 0)); -#endif // QT_NO_TOOLTIP - Ui->actionVolRen->setIcon(QIcon(":/icons/volrenIco.png")); - Ui->actionOrthoslice->setText(QApplication::translate("MainWindow", "Orthoslice", 0)); - Ui->actionOrthoslice->setIcon(QIcon(":/icons/ortoIco.png")); - Ui->label_6->setText(QApplication::translate("MainWindow", "Patient ID:", 0)); - Ui->l_patientID->setText(QString()); - Ui->label_8->setText(QApplication::translate("MainWindow", "Patient position:", 0)); - Ui->l_patientID_2->setText(QString()); - Ui->label_12->setText(QApplication::translate("MainWindow", "RT Isocenter:", 0)); - Ui->l_patientID_6->setText(QString()); - Ui->label_7->setText(QApplication::translate("MainWindow", "Automatic skull mask", 0)); - Ui->pushButton_5->setText(QApplication::translate("MainWindow", "Execute", 0)); - Ui->label->setText(QApplication::translate("MainWindow", "Marker intensity", 0)); - Ui->checkBox_2->setText(QString()); - Ui->label_2->setText(QApplication::translate("MainWindow", "Box diagonal", 0)); - Ui->checkBox_3->setText(QString()); - Ui->label_3->setText(QApplication::translate("MainWindow", "Hausdorff distance", 0)); - Ui->checkBox_5->setText(QString()); - Ui->label_5->setText(QApplication::translate("MainWindow", "Box sides distance", 0)); - Ui->pushButton_3->setText(QApplication::translate("MainWindow", "Localize", 0)); - Ui->pushButton_4->setText(QApplication::translate("MainWindow", "Cancel", 0)); - Ui->pushButton->setText(QApplication::translate("MainWindow", "Select all", 0)); - Ui->pushButton_2->setText(QApplication::translate("MainWindow", "Uncheck all", 0)); - Ui->toolBar->setWindowTitle(QApplication::translate("MainWindow", "toolBar", 0)); - - return; -} // retranslateUi - -void MainWindow::connectUi(Ui_MainWindow* Ui){ - QObject::connect(Ui->pushButton_3, SIGNAL(released()), this, SLOT(call_localize_start())); - QObject::connect(Ui->pushButton_4, SIGNAL(released()), this, SLOT(call_localize_cancel())); - QObject::connect(Ui->pushButton, SIGNAL(released()), this, SLOT(call_visualize_all())); - QObject::connect(Ui->pushButton_2, SIGNAL(released()), this, SLOT(call_hide_all())); - QObject::connect(Ui->toolBar, SIGNAL(actionTriggered(QAction*)), this, SLOT(call_ToolbarAction(QAction*))); - QObject::connect(Ui->pushButton_5, SIGNAL(released()), this, SLOT(call_skullMask())); - QObject::connect(Ui->pb_save, SIGNAL(released()), this, SLOT(call_saveDotCtFile())); - - - QMetaObject::connectSlotsByName(this); - return; -} - - - -void MainWindow::onLocalizationAborted(){ - Ui->pushButton_4->setEnabled(false); - Ui->pushButton_3->setEnabled(true); - Ui->progBar->reset(); - QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, "Localization aborted..." ), - Q_ARG(int, 3000)); - return; -} - + connect(localize_marker, SIGNAL(aborted()), this, SLOT(onLocalizationAborted())); + connect(localize_marker, SIGNAL(failed(QString)), this, SLOT(onLocalizationError(QString))); + + skullRemoval= new gSkullRemoval; + skull_thread= new QThread; + skullRemoval->moveToThread(skull_thread); + skull_thread->start(); + connect(skullRemoval, SIGNAL(skull_mask_end(vtkImageData *)),Visualizer,SLOT(onAutoSkullMaskEnd(vtkImageData* ))); + connect(skullRemoval, SIGNAL(skull_mask_end(vtkImageData *)),this,SLOT(onAutoSkullMaskEnd(vtkImageData* ))); + + connect(skullRemoval, SIGNAL(errMsg(QString)),this,SLOT(onAutoMaskError(QString ))); + connect(skullRemoval, SIGNAL(skull_mask_upd(QString , double )), this, SLOT(onSkullMaskingUpdt(QString,double))); + + + treeModel = new QStandardItemModel; + connect(treeModel,SIGNAL(itemChanged(QStandardItem*)),this,SLOT(onItemChanged(QStandardItem*))); + connect(Ui->viewGroup, SIGNAL(triggered(QAction*)), this, SLOT(onVisualizationTrigger(QAction* ))); + connect(Ui->pb_manualMask, SIGNAL(toggled ( bool )), this, SLOT(onManualMaskTrigger(bool))); +#ifdef MULTIPLE_REF + connect(Ui->refGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onRefTrigger(QAbstractButton*))); +#endif + loadDialog = new gLoadPatDialog; + connect(Visualizer, SIGNAL(PatientLoaded()),this,SLOT(onPatientlLoaded())); + + + QSettings *config = new QSettings ("config.ini",QSettings::IniFormat); + pathIn = config->value("Path/inDir").toString(); + pathOut = config->value("Path/outDir").toString(); + + + /*default values*/ + Ui->spinBox->setValue(config->value("fiducialsLocalize/markerIntensity").toInt()); + Ui->doubleSpinBox_2->setValue(config->value("fiducialsLocalize/boxDiag_down").toDouble()); + Ui->doubleSpinBox_2bis->setValue(config->value("fiducialsLocalize/boxDiag_up").toDouble()); + Ui->doubleSpinBox_3->setValue(config->value("fiducialsLocalize/hausdDist").toDouble()); + Ui->doubleSpinBox_5->setValue(config->value("fiducialsLocalize/boxSidesDiff").toDouble()); + regGrownParameters[0]=config->value("skullMask/regGrow_up").toDouble(); + regGrownParameters[1]=config->value("skullMask/regGrow_down").toDouble(); + + + + delete config; + + + // (Legacy signal kept in old versions; replaced by LocalizationWorker::aborted()) + connect(loadPatient,SIGNAL(referenceChange(double, double, double )), + Visualizer,SLOT(onReferenceChange(double, double , double))); + connect(loadPatient,SIGNAL(referenceChange(double, double, double )), + this,SLOT(updateMarkerPos(double, double , double))); + + /*load passed workdir if any*/ + loadPath.clear(); + /*first check for argv [1]*/ + if(p_loadPath.isEmpty()) { + /*then check for ini inDir*/ + if(!pathIn.isEmpty()) + loadPath=pathIn; + } else + loadPath=p_loadPath; + + if(loadPath.isEmpty()){ + cout<< "loadpath is emty" <show(); + cout<< "loadPath: "<quit(); + localize_thread->wait(); + } + if (skull_thread) { + skull_thread->quit(); + skull_thread->wait(); + } + if (loadPatient_thread) { + loadPatient_thread->quit(); + loadPatient_thread->wait(); + } + + if (localize_marker) localize_marker->deleteLater(); + if (skullRemoval) skullRemoval->deleteLater(); + if (loadPatient) loadPatient->deleteLater(); + if (localize_thread) localize_thread->deleteLater(); + if (skull_thread) skull_thread->deleteLater(); + if (loadPatient_thread) loadPatient_thread->deleteLater(); + + delete Ui; +} + +void MainWindow::onAutoSkullMaskEnd(vtkImageData* img){ + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, QString("Masking Done") ), + Q_ARG(int, 3000)); + + Ui->progBar->reset(); + QApplication::restoreOverrideCursor(); + + Ui->pb_manualMask->setEnabled(true); + Ui->pushButton_5->setEnabled(true); + Ui->frame_3->setEnabled(true); + Ui->frame_4->setEnabled(true); + + return; +} + +void MainWindow::onPatientlLoaded(){ + QApplication::restoreOverrideCursor(); + + Ui->pushButton_5->setEnabled(true); + Ui->pb_manualMask->setEnabled(true); + Ui->actionVolRen->setEnabled(true); + Ui->actionOrthoslice->setEnabled(true); + Ui->pushButton_3->setEnabled(true); + + loadDialog->close(); + Ui->actionLoad->setEnabled(false); + + Ui->pb_manualMask->setEnabled(true); + Ui->pushButton_5->setEnabled(true); + Ui->pushButton_4->setEnabled(false); + Ui->pushButton_3->setEnabled(true); + return; +} + +void MainWindow::onParsedEmptyFolder(){ + QApplication::restoreOverrideCursor(); + loadDialog->close(); + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Icon::Critical); + msgBox.setText("Load failed..."); + msgBox.setInformativeText("Parsed directory is empty or does not contain CT."); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + return; +} + +void MainWindow::setStatusMsg(QString msg, int timeout){ + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, msg ), + Q_ARG(int, timeout)); + return; +} + +void MainWindow::retranslateUi(Ui_MainWindow* Ui, QMainWindow *MainWindow) { + MainWindow->setWindowTitle(QApplication::translate("MainWindow", "gLocalize - Fondazione CNAO - Politecnico di Milano - 2014", 0)); + Ui->actionLoad->setText(QApplication::translate("MainWindow", "Load", 0)); + Ui->actionLoad->setIcon(QIcon(":/icons/pb_load.png")); +#ifndef QT_NO_TOOLTIP + Ui->actionLoad->setToolTip(QApplication::translate("MainWindow", "Load patient data", 0)); +#endif // QT_NO_TOOLTIP + Ui->actionQuit->setText(QApplication::translate("MainWindow", "Quit", 0)); + Ui->actionQuit->setIcon(QIcon(":/icons/pb_quit.png")); +#ifndef QT_NO_TOOLTIP + Ui->actionQuit->setToolTip(QApplication::translate("MainWindow", "Quit application", 0)); +#endif // QT_NO_TOOLTIP + Ui->actionVolRen->setText(QApplication::translate("MainWindow", "VolRen", 0)); +#ifndef QT_NO_TOOLTIP + Ui->actionVolRen->setToolTip(QApplication::translate("MainWindow", "Volume rendering", 0)); +#endif // QT_NO_TOOLTIP + Ui->actionVolRen->setIcon(QIcon(":/icons/volrenIco.png")); + Ui->actionOrthoslice->setText(QApplication::translate("MainWindow", "Orthoslice", 0)); + Ui->actionOrthoslice->setIcon(QIcon(":/icons/ortoIco.png")); + Ui->label_6->setText(QApplication::translate("MainWindow", "Patient ID:", 0)); + Ui->l_patientID->setText(QString()); + Ui->label_8->setText(QApplication::translate("MainWindow", "Patient position:", 0)); + Ui->l_patientID_2->setText(QString()); + Ui->label_12->setText(QApplication::translate("MainWindow", "RT Isocenter:", 0)); + Ui->l_patientID_6->setText(QString()); + Ui->label_7->setText(QApplication::translate("MainWindow", "Automatic skull mask", 0)); + Ui->pushButton_5->setText(QApplication::translate("MainWindow", "Execute", 0)); + Ui->label->setText(QApplication::translate("MainWindow", "Marker intensity", 0)); + Ui->checkBox_2->setText(QString()); + Ui->label_2->setText(QApplication::translate("MainWindow", "Box diagonal", 0)); + Ui->checkBox_3->setText(QString()); + Ui->label_3->setText(QApplication::translate("MainWindow", "Hausdorff distance", 0)); + Ui->checkBox_5->setText(QString()); + Ui->label_5->setText(QApplication::translate("MainWindow", "Box sides distance", 0)); + Ui->pushButton_3->setText(QApplication::translate("MainWindow", "Localize", 0)); + Ui->pushButton_4->setText(QApplication::translate("MainWindow", "Cancel", 0)); + Ui->pushButton->setText(QApplication::translate("MainWindow", "Select all", 0)); + Ui->pushButton_2->setText(QApplication::translate("MainWindow", "Uncheck all", 0)); + Ui->toolBar->setWindowTitle(QApplication::translate("MainWindow", "toolBar", 0)); + + return; +} // retranslateUi + +void MainWindow::connectUi(Ui_MainWindow* Ui){ + QObject::connect(Ui->pushButton_3, SIGNAL(released()), this, SLOT(call_localize_start())); + QObject::connect(Ui->pushButton_4, SIGNAL(released()), this, SLOT(call_localize_cancel())); + QObject::connect(Ui->pushButton, SIGNAL(released()), this, SLOT(call_visualize_all())); + QObject::connect(Ui->pushButton_2, SIGNAL(released()), this, SLOT(call_hide_all())); + QObject::connect(Ui->toolBar, SIGNAL(actionTriggered(QAction*)), this, SLOT(call_ToolbarAction(QAction*))); + QObject::connect(Ui->pushButton_5, SIGNAL(released()), this, SLOT(call_skullMask())); + QObject::connect(Ui->pb_save, SIGNAL(released()), this, SLOT(call_saveDotCtFile())); + + + QMetaObject::connectSlotsByName(this); + return; +} + + + +void MainWindow::onLocalizationAborted(){ + Ui->pushButton_4->setEnabled(false); + Ui->pushButton_3->setEnabled(true); + Ui->progBar->reset(); + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, "Localization aborted..." ), + Q_ARG(int, 3000)); + return; +} + void MainWindow::call_localize_start(){ LocalizationParams params; @@ -718,340 +746,340 @@ void MainWindow::call_localize_start(){ QMetaObject::invokeMethod(localize_marker, "run", Qt::QueuedConnection, Q_ARG(vtkImageData*, Visualizer->getVolume()), - Q_ARG(LocalizationParams, params)); - - - QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, "Localizing..." ), - Q_ARG(int, 0)); - Ui->pushButton_4->setEnabled(true); - Ui->pushButton_3->setEnabled(false); - return; -} - -void MainWindow::call_localize_cancel(){ - - QMetaObject::invokeMethod(localize_marker, "abort", Qt::QueuedConnection); - Ui->pushButton_4->setEnabled(false); - return;} - - -void MainWindow::onItemChanged(QStandardItem* item){ - - - QMetaObject::invokeMethod(Visualizer, "onSingleMarkerChange", Qt::QueuedConnection, - Q_ARG(int, item->text().toInt() ), - Q_ARG(bool, (item->checkState() == Qt::Checked ? true : false))); - - return; -} - -void MainWindow::updateMarkerPos(double dx, double dy, double dz){ - treeModel->blockSignals(true); - for(int ii=0; ii< treeModel->rowCount() ; ii++){ - treeModel->item(ii,0)->child(0,0)->setText(QString::number( - treeModel->item(ii,0)->child(0,0)->text().toDouble()-dx)); - treeModel->item(ii,0)->child(1,0)->setText(QString::number( - treeModel->item(ii,0)->child(1,0)->text().toDouble()-dy)); - treeModel->item(ii,0)->child(2,0)->setText(QString::number( - treeModel->item(ii,0)->child(2,0)->text().toDouble()-dz)); - } - treeModel->blockSignals(false); - - return; -} - -void MainWindow::onLocalizationEnd(MarkerList marker_list){ - - Ui->treeView->reset(); - treeModel->clear(); - Ui->pb_save->setEnabled(true); - Ui->pushButton_4->setEnabled(false); - Ui->pushButton_3->setEnabled(true); - + Q_ARG(LocalizationParams, params)); + + + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, "Localizing..." ), + Q_ARG(int, 0)); + Ui->pushButton_4->setEnabled(true); + Ui->pushButton_3->setEnabled(false); + return; +} + +void MainWindow::call_localize_cancel(){ + + QMetaObject::invokeMethod(localize_marker, "abort", Qt::QueuedConnection); + Ui->pushButton_4->setEnabled(false); + return;} + + +void MainWindow::onItemChanged(QStandardItem* item){ + + + QMetaObject::invokeMethod(Visualizer, "onSingleMarkerChange", Qt::QueuedConnection, + Q_ARG(int, item->text().toInt() ), + Q_ARG(bool, (item->checkState() == Qt::Checked ? true : false))); + + return; +} + +void MainWindow::updateMarkerPos(double dx, double dy, double dz){ + treeModel->blockSignals(true); + for(int ii=0; ii< treeModel->rowCount() ; ii++){ + treeModel->item(ii,0)->child(0,0)->setText(QString::number( + treeModel->item(ii,0)->child(0,0)->text().toDouble()-dx)); + treeModel->item(ii,0)->child(1,0)->setText(QString::number( + treeModel->item(ii,0)->child(1,0)->text().toDouble()-dy)); + treeModel->item(ii,0)->child(2,0)->setText(QString::number( + treeModel->item(ii,0)->child(2,0)->text().toDouble()-dz)); + } + treeModel->blockSignals(false); + + return; +} + +void MainWindow::onLocalizationEnd(MarkerList marker_list){ + + Ui->treeView->reset(); + treeModel->clear(); + Ui->pb_save->setEnabled(true); + Ui->pushButton_4->setEnabled(false); + Ui->pushButton_3->setEnabled(true); + if(marker_list.empty()){ Ui->pb_save->setEnabled(false); - Visualizer->setMarkers(MarkerList{}); - - QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, "Localization done. No markers found." ), - Q_ARG(int, 3000)); - - this->Ui->progBar->reset(); - this->Ui->pushButton->setEnabled(false); - this->Ui->pushButton_2->setEnabled(false); - - return; - } - - QStandardItem *parentItem = treeModel->invisibleRootItem(); - - for (int i = 0; i < marker_list.size() ; i++) { - QStandardItem *item = new QStandardItem(QString("%0").arg(i)); - item->setCheckable(true); - item->setCheckState(Qt::Checked); - item->setEditable(false); - - QList columnList; - columnList.clear(); - columnList.append(new QStandardItem(QString("%0").arg(marker_list[i].centroid.x*1000))); - columnList.append(new QStandardItem(QString("%0").arg(marker_list[i].centroid.y*1000))); - columnList.append(new QStandardItem(QString("%0").arg(marker_list[i].centroid.z*1000))); - item->appendRows(columnList); - - // cout<< "Scritto tree: " <appendRow(item); - treeModel->setItem(i, 0, item); - } - - Ui->treeView->setModel (treeModel); - Visualizer->setMarkers(marker_list); - Ui->statusbar->showMessage("Localization done.",3); - - QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, "Localization done." ), - Q_ARG(int, 3000)); - - this->Ui->progBar->reset(); - this->Ui->pushButton->setEnabled(true); - this->Ui->pushButton_2->setEnabled(true); - - return; -} - -void MainWindow::call_saveDotCtFile(){ - - /*QString filename = QFileDialog::getSaveFileName ( - this, - tr("Save .tac file"), - ".", - tr("Reference marker file (*.tac)") );*/ - - QString filename; - filename = pathOut - + "\\" - + Ui->l_patientID->text().split(" ").first() + - + ".tac"; - - QFile file(filename); - //file.open(QIODevice::WriteOnly | QIODevice::Text); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QMessageBox::warning(this, "Save failed", - "Cannot open file for writing:\n" + file.fileName() + "\n" + file.errorString()); - return; - } - QTextStream out(&file); -#ifdef MULTIPLE_REF - if(Ui->a_OTSref->isChecked() ){ -#endif - /*divide by volumeSpacing*/ - for(int ii=0; ii< treeModel->rowCount() ; ii++) - if( treeModel->item(ii,0)->checkState() == Qt::Checked) - out << treeModel->item(ii,0)->child(0,0)->text().toDouble()/Visualizer->getSpacing()[0]<<" " - << treeModel->item(ii,0)->child(1,0)->text().toDouble()/Visualizer->getSpacing()[1]<<" " - << treeModel->item(ii,0)->child(2,0)->text().toDouble()/Visualizer->getSpacing()[2]<rowCount() ; ii++) - if( treeModel->item(ii,0)->checkState() == Qt::Checked) - out << treeModel->item(ii,0)->child(0,0)->text()<<" " - << treeModel->item(ii,0)->child(1,0)->text()<<" " - << treeModel->item(ii,0)->child(2,0)->text()<l_isoV->text() == QString("Yes")) - out<< 1; - else if (Ui->l_isoV->text() == QString("No")) - out<< 0; - - // optional, as QFile destructor will already do it: - file.close(); - - - QMessageBox msgBox; - msgBox.setText("File saved"); - msgBox.setIcon(QMessageBox::Icon::Information); - msgBox.setInformativeText(filename); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setFixedSize(400,150); - int ret = msgBox.exec(); - - return; -} - - -void MainWindow::call_visualize_all(){ - // //VISUALIZATION and Countour shift - for(int ii=0; ii< treeModel->rowCount() ; ii++) - treeModel->item(ii,0)->setCheckState(Qt::Checked); - return; -} - - -void MainWindow::call_hide_all(){ - for(int ii=0; ii< treeModel->rowCount() ; ii++) - treeModel->item(ii,0)->setCheckState(Qt::Unchecked); - return; -} - -void MainWindow::call_ToolbarAction(QAction* action){ - - if(action == Ui->actionQuit) - this->call_quit(); - // QApplication::quit(); - - if(action == Ui->actionLoad){ - QString dirName = QFileDialog::getExistingDirectory(this,tr("Chose DICOM Directory"), "wrkDir",QFileDialog::ShowDirsOnly); - if(!dirName.isEmpty()) { - QMetaObject::invokeMethod(loadPatient, "load", Qt::QueuedConnection, - Q_ARG(QString, dirName)); - loadDialog->show(); - - QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, "Loading patient..." ), - Q_ARG(int, 3000)); - - } - //patientLoader->parse(dirName); - } - - return; -} - -void MainWindow::call_skullMask(){ - - QApplication::setOverrideCursor(Qt::WaitCursor); - - QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, "Skull masking..." ), - Q_ARG(int, 3000)); - - QMetaObject::invokeMethod(skullRemoval, "runFilter", Qt::QueuedConnection, - Q_ARG(vtkImageData*, Visualizer->getVolume()), - Q_ARG(double, regGrownParameters[1]), - Q_ARG(double,regGrownParameters[0])); - - Ui->pb_manualMask->setEnabled(false); - Ui->pushButton_5->setEnabled(false); - Ui->frame_3->setEnabled(false); - Ui->frame_4->setEnabled(false); - - return; -} - - -void MainWindow::onAutoMaskError(QString msg){ - QApplication::restoreOverrideCursor(); - QMessageBox msgBox; - msgBox.setText("The automatic masking failed..."); - msgBox.setInformativeText("Manual volume clipping is the way to handle this error."); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret = msgBox.exec(); - return; -} - -void MainWindow:: onRTIsoAvailable(double* iso){ - -#ifdef MULTIPLE_REF - Ui->a_RTref->setEnabled(true); -#endif - Ui->l_patientID_6->setText(QString("%0 %1 %2") - .arg(iso[0]) - .arg(iso[1]) - .arg(iso[2])); - return; -} - -void MainWindow:: onCTVolumeAvailable(double* bounds, double* spacing, int* dim){ - - return; -} - -void MainWindow:: onParsedOK(int result, gPatientRTGeneralInfos* infos){ - - - if(result != NOERRORS) - return; - - if( QString(infos->PatientID).isEmpty() ) - Ui->l_patientID->setText(QString("RTPlan not available")); - else - Ui->l_patientID->setText(QString(infos->PatientID)); - - if( QString(infos->PatientOrientation).isEmpty() ) - Ui->l_patientID_2->setText(QString("RTPlan not available")); - else - Ui->l_patientID_2->setText(QString(infos->PatientOrientation)); - - - - QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, - Q_ARG(QString, "Dir parser: Ok." ), - Q_ARG(int, 3000)); - return; - -} - -void MainWindow::call_loadPatient(){ - - - return; -} - - -#ifdef MULTIPLE_REF - -void MainWindow::onRefTrigger(QAbstractButton* trigger_button){ - - QRadioButton* clickedButton= reinterpret_cast (trigger_button); - - if(clickedButton == Ui->a_DCMref){ - QMetaObject::invokeMethod(loadPatient, "changeRef", Qt::QueuedConnection, - Q_ARG(int,0)); - } - - if(clickedButton == Ui->a_RTref){ - QMetaObject::invokeMethod(loadPatient, "changeRef", Qt::QueuedConnection, - Q_ARG(int,1)); - } - - if(clickedButton == Ui->a_OTSref){ - QMetaObject::invokeMethod(loadPatient, "changeRef", Qt::QueuedConnection, - Q_ARG(int,2)); - } - return; -} -#endif - -void MainWindow::onVisualizationTrigger(QAction* trigger_action){ - - if(trigger_action == Ui->actionOrthoslice ){ - this->Visualizer->onRequestRenderChange(1); - this->Ui->qvtk->renderWindow()->GetInteractor()->Render(); - } - - if(trigger_action == Ui->actionVolRen ){ - this->Visualizer->onRequestRenderChange(0); - this->Ui->qvtk->renderWindow()->GetInteractor()->Render(); - } - return; -} - - -void MainWindow::onManualMaskTrigger(bool state){ - - if(state){ - this->Visualizer->onRequestManualMask(0); - }else{ - this->Visualizer->onRequestManualMask(1); - } - return; -} - - + Visualizer->setMarkers(MarkerList{}); + + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, "Localization done. No markers found." ), + Q_ARG(int, 3000)); + + this->Ui->progBar->reset(); + this->Ui->pushButton->setEnabled(false); + this->Ui->pushButton_2->setEnabled(false); + + return; + } + + QStandardItem *parentItem = treeModel->invisibleRootItem(); + + for (int i = 0; i < marker_list.size() ; i++) { + QStandardItem *item = new QStandardItem(QString("%0").arg(i)); + item->setCheckable(true); + item->setCheckState(Qt::Checked); + item->setEditable(false); + + QList columnList; + columnList.clear(); + columnList.append(new QStandardItem(QString("%0").arg(marker_list[i].centroid.x*1000))); + columnList.append(new QStandardItem(QString("%0").arg(marker_list[i].centroid.y*1000))); + columnList.append(new QStandardItem(QString("%0").arg(marker_list[i].centroid.z*1000))); + item->appendRows(columnList); + + // cout<< "Scritto tree: " <appendRow(item); + treeModel->setItem(i, 0, item); + } + + Ui->treeView->setModel (treeModel); + Visualizer->setMarkers(marker_list); + Ui->statusbar->showMessage("Localization done.",3); + + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, "Localization done." ), + Q_ARG(int, 3000)); + + this->Ui->progBar->reset(); + this->Ui->pushButton->setEnabled(true); + this->Ui->pushButton_2->setEnabled(true); + + return; +} + +void MainWindow::call_saveDotCtFile(){ + + /*QString filename = QFileDialog::getSaveFileName ( + this, + tr("Save .tac file"), + ".", + tr("Reference marker file (*.tac)") );*/ + + QString filename; + filename = pathOut + + "\\" + + Ui->l_patientID->text().split(" ").first() + + + ".tac"; + + QFile file(filename); + //file.open(QIODevice::WriteOnly | QIODevice::Text); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QMessageBox::warning(this, "Save failed", + "Cannot open file for writing:\n" + file.fileName() + "\n" + file.errorString()); + return; + } + QTextStream out(&file); +#ifdef MULTIPLE_REF + if(Ui->a_OTSref->isChecked() ){ +#endif + /*divide by volumeSpacing*/ + for(int ii=0; ii< treeModel->rowCount() ; ii++) + if( treeModel->item(ii,0)->checkState() == Qt::Checked) + out << treeModel->item(ii,0)->child(0,0)->text().toDouble()/Visualizer->getSpacing()[0]<<" " + << treeModel->item(ii,0)->child(1,0)->text().toDouble()/Visualizer->getSpacing()[1]<<" " + << treeModel->item(ii,0)->child(2,0)->text().toDouble()/Visualizer->getSpacing()[2]<rowCount() ; ii++) + if( treeModel->item(ii,0)->checkState() == Qt::Checked) + out << treeModel->item(ii,0)->child(0,0)->text()<<" " + << treeModel->item(ii,0)->child(1,0)->text()<<" " + << treeModel->item(ii,0)->child(2,0)->text()<l_isoV->text() == QString("Yes")) + out<< 1; + else if (Ui->l_isoV->text() == QString("No")) + out<< 0; + + // optional, as QFile destructor will already do it: + file.close(); + + + QMessageBox msgBox; + msgBox.setText("File saved"); + msgBox.setIcon(QMessageBox::Icon::Information); + msgBox.setInformativeText(filename); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.setFixedSize(400,150); + int ret = msgBox.exec(); + + return; +} + + +void MainWindow::call_visualize_all(){ + // //VISUALIZATION and Countour shift + for(int ii=0; ii< treeModel->rowCount() ; ii++) + treeModel->item(ii,0)->setCheckState(Qt::Checked); + return; +} + + +void MainWindow::call_hide_all(){ + for(int ii=0; ii< treeModel->rowCount() ; ii++) + treeModel->item(ii,0)->setCheckState(Qt::Unchecked); + return; +} + +void MainWindow::call_ToolbarAction(QAction* action){ + + if(action == Ui->actionQuit) + this->call_quit(); + // QApplication::quit(); + + if(action == Ui->actionLoad){ + QString dirName = QFileDialog::getExistingDirectory(this,tr("Chose DICOM Directory"), "wrkDir",QFileDialog::ShowDirsOnly); + if(!dirName.isEmpty()) { + QMetaObject::invokeMethod(loadPatient, "load", Qt::QueuedConnection, + Q_ARG(QString, dirName)); + loadDialog->show(); + + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, "Loading patient..." ), + Q_ARG(int, 3000)); + + } + //patientLoader->parse(dirName); + } + + return; +} + +void MainWindow::call_skullMask(){ + + QApplication::setOverrideCursor(Qt::WaitCursor); + + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, "Skull masking..." ), + Q_ARG(int, 3000)); + + QMetaObject::invokeMethod(skullRemoval, "runFilter", Qt::QueuedConnection, + Q_ARG(vtkImageData*, Visualizer->getVolume()), + Q_ARG(double, regGrownParameters[1]), + Q_ARG(double,regGrownParameters[0])); + + Ui->pb_manualMask->setEnabled(false); + Ui->pushButton_5->setEnabled(false); + Ui->frame_3->setEnabled(false); + Ui->frame_4->setEnabled(false); + + return; +} + + +void MainWindow::onAutoMaskError(QString msg){ + QApplication::restoreOverrideCursor(); + QMessageBox msgBox; + msgBox.setText("The automatic masking failed..."); + msgBox.setInformativeText("Manual volume clipping is the way to handle this error."); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + return; +} + +void MainWindow:: onRTIsoAvailable(double* iso){ + +#ifdef MULTIPLE_REF + Ui->a_RTref->setEnabled(true); +#endif + Ui->l_patientID_6->setText(QString("%0 %1 %2") + .arg(iso[0]) + .arg(iso[1]) + .arg(iso[2])); + return; +} + +void MainWindow:: onCTVolumeAvailable(double* bounds, double* spacing, int* dim){ + + return; +} + +void MainWindow:: onParsedOK(int result, gPatientRTGeneralInfos* infos){ + + + if(result != NOERRORS) + return; + + if( QString(infos->PatientID).isEmpty() ) + Ui->l_patientID->setText(QString("RTPlan not available")); + else + Ui->l_patientID->setText(QString(infos->PatientID)); + + if( QString(infos->PatientOrientation).isEmpty() ) + Ui->l_patientID_2->setText(QString("RTPlan not available")); + else + Ui->l_patientID_2->setText(QString(infos->PatientOrientation)); + + + + QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, + Q_ARG(QString, "Dir parser: Ok." ), + Q_ARG(int, 3000)); + return; + +} + +void MainWindow::call_loadPatient(){ + + + return; +} + + +#ifdef MULTIPLE_REF + +void MainWindow::onRefTrigger(QAbstractButton* trigger_button){ + + QRadioButton* clickedButton= reinterpret_cast (trigger_button); + + if(clickedButton == Ui->a_DCMref){ + QMetaObject::invokeMethod(loadPatient, "changeRef", Qt::QueuedConnection, + Q_ARG(int,0)); + } + + if(clickedButton == Ui->a_RTref){ + QMetaObject::invokeMethod(loadPatient, "changeRef", Qt::QueuedConnection, + Q_ARG(int,1)); + } + + if(clickedButton == Ui->a_OTSref){ + QMetaObject::invokeMethod(loadPatient, "changeRef", Qt::QueuedConnection, + Q_ARG(int,2)); + } + return; +} +#endif + +void MainWindow::onVisualizationTrigger(QAction* trigger_action){ + + if(trigger_action == Ui->actionOrthoslice ){ + this->Visualizer->onRequestRenderChange(1); + this->Ui->qvtk->renderWindow()->GetInteractor()->Render(); + } + + if(trigger_action == Ui->actionVolRen ){ + this->Visualizer->onRequestRenderChange(0); + this->Ui->qvtk->renderWindow()->GetInteractor()->Render(); + } + return; +} + + +void MainWindow::onManualMaskTrigger(bool state){ + + if(state){ + this->Visualizer->onRequestManualMask(0); + }else{ + this->Visualizer->onRequestManualMask(1); + } + return; +} + + void MainWindow::onLocalizationProgress(double percent) {