#include "mainw.h" #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); #ifdef MULTIPLE_REF a_DCMref=new QRadioButton(frame_2); a_DCMref->setCheckable(true); a_DCMref->setText("DCM"); a_RTref=new QRadioButton(frame_2); a_RTref->setCheckable(true); a_RTref->setText("RT"); a_OTSref=new QRadioButton(frame_2); a_OTSref->setText("OTS"); a_OTSref->setCheckable(true); a_DCMref->setChecked(true); refGroup = new QButtonGroup(frame_2); refGroup->addButton (a_DCMref); refGroup->addButton(a_RTref); refGroup->addButton(a_OTSref); QHBoxLayout* reflay=new QHBoxLayout; reflay->addWidget(a_DCMref); reflay->addWidget(a_RTref); reflay->addWidget(a_OTSref); a_RTref->setDisabled(true); formLayout_2->setItem(6, QFormLayout::FieldRole, reflay); #endif 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 QVTKWidget(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(); 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); } // 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)); } void MainWindow::call_quit(){ loadPatient_thread->quit(); localize_thread->quit(); skull_thread->quit(); Sleep(100); cout<< "Bye bye" <l_isoV->clear(); (IsoV == true? Ui->l_isoV->setText("Yes") : Ui->l_isoV->setText("No") ); } 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); 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"); 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))); localize_thread = new QThread; localize_marker = new gLocalize; localize_marker->moveToThread(localize_thread); localize_thread->start(); connect(localize_marker,SIGNAL(localizationEnd(QList )),this,SLOT(onLocalizationEnd(QList ))); connect(localize_marker,SIGNAL(localizationProgress(int)), this->Ui->progBar ,SLOT(setValue(int))); 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: "< pippoReader= vtkSmartPointer::New(); //pippoReader->SetDirectoryName("D:\\testIn"); ////pippoReader->SetFileLowerLeft(1); //pippoReader->Update(); //pippoReader->Print(std::cout); //Visualizer->loadVolume(pippoReader->GetOutput()); //cout<< "height" <GetHeight()<GetWidth()<GetOutput()->GetBounds(); //cout<< "VolBounds: "<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); } 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); } 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(); } void MainWindow::setStatusMsg(QString msg, int timeout){ QMetaObject::invokeMethod(Ui->statusbar, "showMessage", Qt::QueuedConnection, Q_ARG(QString, msg ), Q_ARG(int, timeout)); } void MainWindow::retranslateUi(Ui_MainWindow* Ui, QMainWindow *MainWindow) { MainWindow->setWindowTitle(QApplication::translate("MainWindow", "gLocalize - Fondazione CNAO - Politecnico di Milano - 2014", 0, QApplication::UnicodeUTF8)); Ui->actionLoad->setText(QApplication::translate("MainWindow", "Load", 0, QApplication::UnicodeUTF8)); Ui->actionLoad->setIcon(QIcon(":/icons/pb_load.png")); #ifndef QT_NO_TOOLTIP Ui->actionLoad->setToolTip(QApplication::translate("MainWindow", "Load patient data", 0, QApplication::UnicodeUTF8)); #endif // QT_NO_TOOLTIP Ui->actionQuit->setText(QApplication::translate("MainWindow", "Quit", 0, QApplication::UnicodeUTF8)); Ui->actionQuit->setIcon(QIcon(":/icons/pb_quit.png")); #ifndef QT_NO_TOOLTIP Ui->actionQuit->setToolTip(QApplication::translate("MainWindow", "Quit application", 0, QApplication::UnicodeUTF8)); #endif // QT_NO_TOOLTIP Ui->actionVolRen->setText(QApplication::translate("MainWindow", "VolRen", 0, QApplication::UnicodeUTF8)); #ifndef QT_NO_TOOLTIP Ui->actionVolRen->setToolTip(QApplication::translate("MainWindow", "Volume rendering", 0, QApplication::UnicodeUTF8)); #endif // QT_NO_TOOLTIP Ui->actionVolRen->setIcon(QIcon(":/icons/volrenIco.png")); Ui->actionOrthoslice->setText(QApplication::translate("MainWindow", "Orthoslice", 0, QApplication::UnicodeUTF8)); Ui->actionOrthoslice->setIcon(QIcon(":/icons/ortoIco.png")); Ui->label_6->setText(QApplication::translate("MainWindow", "Patient ID:", 0, QApplication::UnicodeUTF8)); Ui->l_patientID->setText(QString()); Ui->label_8->setText(QApplication::translate("MainWindow", "Patient position:", 0, QApplication::UnicodeUTF8)); Ui->l_patientID_2->setText(QString()); Ui->label_12->setText(QApplication::translate("MainWindow", "RT Isocenter:", 0, QApplication::UnicodeUTF8)); Ui->l_patientID_6->setText(QString()); Ui->label_7->setText(QApplication::translate("MainWindow", "Automatic skull mask", 0, QApplication::UnicodeUTF8)); Ui->pushButton_5->setText(QApplication::translate("MainWindow", "Execute", 0, QApplication::UnicodeUTF8)); Ui->label->setText(QApplication::translate("MainWindow", "Marker intensity", 0, QApplication::UnicodeUTF8)); Ui->checkBox_2->setText(QString()); Ui->label_2->setText(QApplication::translate("MainWindow", "Box diagonal", 0, QApplication::UnicodeUTF8)); Ui->checkBox_3->setText(QString()); Ui->label_3->setText(QApplication::translate("MainWindow", "Hausdorff distance", 0, QApplication::UnicodeUTF8)); Ui->checkBox_5->setText(QString()); Ui->label_5->setText(QApplication::translate("MainWindow", "Box sides distance", 0, QApplication::UnicodeUTF8)); Ui->pushButton_3->setText(QApplication::translate("MainWindow", "Localize", 0, QApplication::UnicodeUTF8)); Ui->pushButton_4->setText(QApplication::translate("MainWindow", "Cancel", 0, QApplication::UnicodeUTF8)); /* QTreeWidgetItem *___qtreewidgetitem = Ui->treeWidget->headerItem(); ___qtreewidgetitem->setText(4, QApplication::translate("MainWindow", "Z", 0, QApplication::UnicodeUTF8)); ___qtreewidgetitem->setText(3, QApplication::translate("MainWindow", "Y", 0, QApplication::UnicodeUTF8)); ___qtreewidgetitem->setText(2, QApplication::translate("MainWindow", "X", 0, QApplication::UnicodeUTF8)); ___qtreewidgetitem->setText(0, QApplication::translate("MainWindow", "ID", 0, QApplication::UnicodeUTF8));*/ /* const bool __sortingEnabled = Ui->treeWidget->isSortingEnabled(); Ui->treeWidget->setSortingEnabled(false); QTreeWidgetItem *___qtreewidgetitem1 = Ui->treeWidget->topLevelItem(0); ___qtreewidgetitem1->setText(4, QApplication::translate("MainWindow", "0", 0, QApplication::UnicodeUTF8)); ___qtreewidgetitem1->setText(3, QApplication::translate("MainWindow", "0", 0, QApplication::UnicodeUTF8)); ___qtreewidgetitem1->setText(2, QApplication::translate("MainWindow", "0", 0, QApplication::UnicodeUTF8)); ___qtreewidgetitem1->setText(0, QApplication::translate("MainWindow", "1", 0, QApplication::UnicodeUTF8)); Ui->treeWidget->setSortingEnabled(__sortingEnabled); */ Ui->pushButton->setText(QApplication::translate("MainWindow", "Select all", 0, QApplication::UnicodeUTF8)); Ui->pushButton_2->setText(QApplication::translate("MainWindow", "Uncheck all", 0, QApplication::UnicodeUTF8)); Ui->toolBar->setWindowTitle(QApplication::translate("MainWindow", "toolBar", 0, QApplication::UnicodeUTF8)); } // 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); } 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)); } void MainWindow::call_localize_start(){ //bool selected[3]; QList selected; selected.clear(); selected.append(Ui->checkBox_2->isChecked()); selected.append(Ui->checkBox_3->isChecked()); selected.append(Ui->checkBox_5->isChecked()); QMetaObject::invokeMethod(localize_marker, "localize", Qt::QueuedConnection, Q_ARG(vtkImageData*, Visualizer->getVolume()), Q_ARG(int,Ui->spinBox->text().toInt()), Q_ARG(double,Ui->doubleSpinBox_2->text().toDouble()), Q_ARG(double,Ui->doubleSpinBox_2bis->text().toDouble()), Q_ARG(double,Ui->doubleSpinBox_3->text().toDouble()), Q_ARG(double,Ui->doubleSpinBox_5->text().toDouble()), Q_ARG(QList ,selected)); 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); } void MainWindow::call_localize_cancel(){ QMetaObject::invokeMethod(localize_marker, "callAbort", Qt::QueuedConnection); Ui->pushButton_4->setEnabled(false); } 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))); } 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); } void MainWindow::onLocalizationEnd(QList 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.size() == 0){ Ui->pb_save->setEnabled(false); QList marker_list; QMetaObject::invokeMethod(Visualizer, "renderMarkers", Qt::QueuedConnection, Q_ARG(QList,marker_list)); 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.at(i).centroid.x*1000))); columnList.append(new QStandardItem(QString("%0").arg(marker_list.at(i).centroid.y*1000))); columnList.append(new QStandardItem(QString("%0").arg(marker_list.at(i).centroid.z*1000))); item->appendRows(columnList); // cout<< "Scritto tree: " <appendRow(item); treeModel->setItem(i, 0, item); } Ui->treeView->setModel (treeModel); Visualizer->renderMarkers(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); } 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); 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(); } void MainWindow::call_visualize_all(){ // //VISUALIZATION and Countour shift for(int ii=0; ii< treeModel->rowCount() ; ii++) treeModel->item(ii,0)->setCheckState(Qt::Checked); } void MainWindow::call_hide_all(){ for(int ii=0; ii< treeModel->rowCount() ; ii++) treeModel->item(ii,0)->setCheckState(Qt::Unchecked); } 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); } } 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); } 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(); } 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])); } void MainWindow:: onCTVolumeAvailable(double* bounds, double* spacing, int* dim){ } 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)); //QMetaObject::invokeMethod(load2vtk, "loadInput", Qt::QueuedConnection, // Q_ARG(std::vector, infos->CTfiles), // Q_ARG(std::string,infos->rtIonPlanPath.toStdString()) // ); } void MainWindow::call_loadPatient(){ // Ui->gw_patientWidget->PatientAge->setText(infos->PatientAge); // QMetaObject::invokeMethod(load2vtk, "loadInput", Qt::QueuedConnection, // Q_ARG(std::vector, infos->CTfiles), // Q_ARG(std::string,infos->rtIonPlanPath.toStdString()) // ); // questo deve chiamare il loadVolume in Gren } #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)); } } #endif void MainWindow::onVisualizationTrigger(QAction* trigger_action){ if(trigger_action == Ui->actionOrthoslice ){ this->Visualizer->onRequestRenderChange(1); this->Ui->qvtk->GetInteractor()->Render(); } if(trigger_action == Ui->actionVolRen ){ this->Visualizer->onRequestRenderChange(0); this->Ui->qvtk->GetInteractor()->Render(); } } void MainWindow::onManualMaskTrigger(bool state){ if(state){ this->Visualizer->onRequestManualMask(0); }else{ this->Visualizer->onRequestManualMask(1); } }