diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..efe9e38 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# qmake / build artifacts +source/Makefile* +source/.qmake.stash +source/*.o +source/moc_*.cpp +source/moc_*.o +source/moc_predefs.h +source/ui_*.h +source/object_script.* +*.app/ +3ddose_tools +3ddose_tools.exe +*.pro.user +.DS_Store diff --git a/README.md b/README.md index f423f9f..d5424b9 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,39 @@ -# Compiling information for those with Qt5 dev tools installed: +# 3ddose_tools -To compile, go to the source directory and invoke the following 2 commands: +3ddose file analysis tool (CLRP). Requires **Qt 6**. + +## Build + +With Qt 6 development tools installed: ``` -3ddose_tools/source> qmake -3ddose_tools/source> make +cd 3ddose_tools/source +qmake6 # or: qmake (if it points at Qt 6) +make ``` -and an executable should appear in the parent directory. - -# How to install from scratch +The executable appears in the parent directory as `3ddose_tools`. -If you don't have Qt5 installed, then you will need to do it manually, or through a package manager (like apt-get in Ubuntu). Here's an Ubuntu example: +### macOS (Homebrew) ``` -sudo apt-get install qtbase5-dev qt5-qmake qtbase5-dev-tools +brew install qt +cd 3ddose_tools/source +/opt/homebrew/opt/qt/bin/qmake +make ``` -Navigate to the directory you intend to install in, and invoke the following commands: +### Ubuntu / Debian ``` -> git clone https://github.com/MartinMartinov/3ddose_tools -> cd 3ddose_tools/source/ -3ddose_tools/source> qmake -3ddose_tools/source> make -3ddose_tools/source> cd .. -3ddose_tools> ./3ddose_tools +sudo apt-get install qt6-base-dev qt6-base-dev-tools +cd 3ddose_tools/source +qmake6 +make ``` -and you should launch 3ddose_tools. +## Clone + +``` +git clone https://github.com/clrp-code/3ddose_tools +``` diff --git a/source/interface.cpp b/source/interface.cpp index 53086c3..ad2e88c 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -182,7 +182,7 @@ Interface::~Interface() { *******************************************************************************/ void Interface::addDose() { QStringList paths = - QFileDialog::getOpenFileNames(0, tr("Load Files"), 0, + QFileDialog::getOpenFileNames(nullptr, tr("Load Files"), QString(), tr("3ddose (*.3ddose *.b3ddose)")); // Set up the progress bar @@ -289,7 +289,7 @@ void Interface::outputDose() { for (int i = 0; i < data->size(); i++) if (doseList->selectedItems().contains(doseList->item(i))) { path = - QFileDialog::getSaveFileName(0, tr("Save File ") + + QFileDialog::getSaveFileName(nullptr, tr("Save File ") + doseList->item(i)->text(), doseList->item(i)->text(), tr("3ddose (*.3ddose *.b3ddose)")); @@ -356,10 +356,10 @@ void Interface::doseAtPoints() { QFile *file; QTextStream *input; - QString path = QFileDialog::getOpenFileName(0, tr("Open File"), 0, + QString path = QFileDialog::getOpenFileName(nullptr, tr("Open File"), QString(), tr("Points File (*.txt)")); - if (path == 0) { + if (path.isEmpty()) { return; } @@ -483,9 +483,9 @@ void Interface::doseAtPoints() { } } - path = QFileDialog::getSaveFileName(0, tr("Save File"), 0, + path = QFileDialog::getSaveFileName(nullptr, tr("Save File"), QString(), tr("Dose at Points (*.txt)")); - if (path == 0) { + if (path.isEmpty()) { return; } @@ -509,7 +509,7 @@ void Interface::doseAtPoints() { s = s.left(30); } - *input << qSetFieldWidth(30) << center << s + *input << qSetFieldWidth(30) << Qt::center << s << qSetFieldWidth(0) << "|"; if (i != data->size()-1) { *input << "|"; @@ -574,10 +574,10 @@ void Interface::rebinBounds() { QFile *file; QTextStream *input; - QString path = QFileDialog::getOpenFileName(0, tr("Open File"), 0, + QString path = QFileDialog::getOpenFileName(nullptr, tr("Open File"), QString(), tr("Boundaries File (*.txt)")); - if (path == 0) { + if (path.isEmpty()) { return; } @@ -1226,7 +1226,7 @@ void Interface::plotAxis() { } } - QString path = QFileDialog::getSaveFileName(0, tr("Save File "), 0, + QString path = QFileDialog::getSaveFileName(nullptr, tr("Save File "), QString(), tr("Comma Separated Values ") + tr("(*.csv)")); if (path == "") { @@ -1246,12 +1246,10 @@ void Interface::plotAxis() { QString name = path.section("/",path.count("/"),path.count("/")); name = name.left(name.size() - (path.endsWith(tr(".csv"))?4:5)); *input << name << "\n"; - int n = 0; for (int i = 0; i < data->size(); i++) if (doseList->selectedItems().contains(doseList->item(i))) { *input << doseList->item(i)->text() << "\n"; *input << (*data)[i]->plot(axis, h, u, j, k); - n++; } *input << "\n"; @@ -1262,7 +1260,7 @@ void Interface::plotAxis() { void Interface::selectEGSFile() { QString path = - QFileDialog::getOpenFileName(0, tr("Open File"), 0, + QFileDialog::getOpenFileName(nullptr, tr("Open File"), QString(), tr("EGSphant File (*.egsphant *.begsphant)")); if (path == "") { return; @@ -1304,7 +1302,7 @@ void Interface::selectEGSFile() { void Interface::selectStatEGSFile() { QString path = - QFileDialog::getOpenFileName(0, tr("Open File"), 0, + QFileDialog::getOpenFileName(nullptr, tr("Open File"), QString(), tr("EGSphant File (*.egsphant *.begsphant)")); if (path == "") { return; @@ -1387,7 +1385,7 @@ void Interface::plotLine() { } } - QString path = QFileDialog::getSaveFileName(0, tr("Save File "), 0, + QString path = QFileDialog::getSaveFileName(nullptr, tr("Save File "), QString(), tr("Comma Separated Values ") + tr("(*.csv)")); if (path == "") { @@ -1414,7 +1412,6 @@ void Interface::plotLine() { name = name.left(name.size() - (path.endsWith(tr(".csv"))?4:5)); *input << name << "\n"; - int n = 0; double val = 0, err = 0; for (int i = 0; i < data->size(); i++) if (doseList->selectedItems().contains(doseList->item(i))) { @@ -1447,7 +1444,6 @@ void Interface::plotLine() { *input << QString::number(val*err, 'E', 6); *input << "\n"; } - n++; } *input << "\n"; @@ -1457,7 +1453,7 @@ void Interface::plotLine() { } void Interface::plotDVH() { - QString path = QFileDialog::getSaveFileName(0, tr("Save File "), 0, + QString path = QFileDialog::getSaveFileName(nullptr, tr("Save File "), QString(), tr("Comma Separated Values ") + tr("(*.csv)")); if (path == "") { @@ -1514,7 +1510,6 @@ void Interface::plotDVH() { name = name.left(name.size() - (path.endsWith(tr(".csv"))?4:5)); *input << name << "\n"; - int n = 0; for (int i = 0; i < data->size(); i++) if (doseList->selectedItems().contains(doseList->item(i))) { *input << doseList->item(i)->text() << "\n"; @@ -1560,7 +1555,6 @@ void Interface::plotDVH() { &eAvg, &err, &maxErr, &totVol, &nVox, &Dx, &Vx); - n++; } *input << "\n"; @@ -1569,9 +1563,9 @@ void Interface::plotDVH() { delete file; if (dvhExtra->isChecked()) { - QString path2 = QFileDialog::getSaveFileName(0, tr("Save File"), 0, + QString path2 = QFileDialog::getSaveFileName(nullptr, tr("Save File"), QString(), tr("Additional Statistics (*.txt)")); - if (path2 == 0) { + if (path2.isEmpty()) { return; } @@ -1629,7 +1623,7 @@ void Interface::plotDVHReg() { } } - QString path = QFileDialog::getSaveFileName(0, tr("Save File "), 0, + QString path = QFileDialog::getSaveFileName(nullptr, tr("Save File "), QString(), tr("Comma Separated Values ") + tr("(*.csv)")); if (path == "") { @@ -1684,7 +1678,6 @@ void Interface::plotDVHReg() { name = name.left(name.size() - (path.endsWith(tr(".csv"))?4:5)); *input << name << "\n"; - int n = 0; for (int i = 0; i < data->size(); i++) if (doseList->selectedItems().contains(doseList->item(i))) { xi = dvhxi->getText().toDouble(); @@ -1737,7 +1730,6 @@ void Interface::plotDVHReg() { &avg, &eAvg, &err, &maxErr, &totVol, &nVox, &Dx, &Vx); - n++; } *input << "\n"; @@ -1746,9 +1738,9 @@ void Interface::plotDVHReg() { delete file; if (dvhExtra->isChecked()) { - QString path2 = QFileDialog::getSaveFileName(0, tr("Save File"), 0, + QString path2 = QFileDialog::getSaveFileName(nullptr, tr("Save File"), QString(), tr("Additional Statistics (*.txt)")); - if (path2 == 0) { + if (path2.isEmpty()) { return; } @@ -1789,7 +1781,7 @@ void Interface::plotDVHMed() { } } - QString path = QFileDialog::getSaveFileName(0, tr("Save File "), 0, + QString path = QFileDialog::getSaveFileName(nullptr, tr("Save File "), QString(), tr("Comma Separated Values ") + tr("(*.csv)")); if (path == "") { @@ -1844,7 +1836,6 @@ void Interface::plotDVHMed() { name = name.left(name.size() - (path.endsWith(tr(".csv"))?4:5)); *input << name << "\n"; - int n = 0; for (int i = 0; i < data->size(); i++) if (doseList->selectedItems().contains(doseList->item(i))) { *input << doseList->item(i)->text() << "\n"; @@ -1876,7 +1867,6 @@ void Interface::plotDVHMed() { &avg, &eAvg, &err, &maxErr, &totVol, &nVox, &Dx, &Vx); - n++; } *input << "\n"; @@ -1885,9 +1875,9 @@ void Interface::plotDVHMed() { delete file; if (dvhExtra->isChecked()) { - QString path2 = QFileDialog::getSaveFileName(0, tr("Save File"), 0, + QString path2 = QFileDialog::getSaveFileName(nullptr, tr("Save File"), QString(), tr("Additional Statistics (*.txt)")); - if (path2 == 0) { + if (path2.isEmpty()) { return; } @@ -1949,7 +1939,7 @@ void Interface::plot() { // The 3 stat functions for different region cases need to be combined, // the current state is embarrassingly bad void Interface::statH(Dose *comp) { - QString path = QFileDialog::getSaveFileName(0, tr("Save File "), 0, + QString path = QFileDialog::getSaveFileName(nullptr, tr("Save File "), QString(), tr("Comma Separated Values ") + tr("(*.csv)")); if (path == "") { @@ -2101,7 +2091,6 @@ void Interface::statH(Dose *comp) { maxFinal = statMax->getText().toDouble(); } - int n = 0; for (int i = 0; i < data->size(); i++) if (doseList->selectedItems().contains(doseList->item(i))) { temp.copyDose((*data)[i]); @@ -2182,7 +2171,6 @@ void Interface::statH(Dose *comp) { + QString(" ") + " |"; } } - n++; } delete input; @@ -2190,9 +2178,9 @@ void Interface::statH(Dose *comp) { delete file; if (statExtra->isChecked()) { - QString path2 = QFileDialog::getSaveFileName(0, tr("Save File"), 0, + QString path2 = QFileDialog::getSaveFileName(nullptr, tr("Save File"), QString(), tr("Additional Statistics (*.txt)")); - if (path2 == 0) { + if (path2.isEmpty()) { return; } @@ -2226,7 +2214,7 @@ void Interface::statHReg(Dose *comp) { yf = statyf->getText().toDouble(); zf = statzf->getText().toDouble(); - QString path = QFileDialog::getSaveFileName(0, tr("Save File "), 0, + QString path = QFileDialog::getSaveFileName(nullptr, tr("Save File "), QString(), tr("Comma Separated Values ") + tr("(*.csv)")); if (path == "") { @@ -2375,7 +2363,6 @@ void Interface::statHReg(Dose *comp) { } } - int n = 0; for (int i = 0; i < data->size(); i++) if (doseList->selectedItems().contains(doseList->item(i))) { temp.copyDose((*data)[i]); @@ -2456,7 +2443,6 @@ void Interface::statHReg(Dose *comp) { + QString(" ") + " |"; } } - n++; } delete input; @@ -2464,9 +2450,9 @@ void Interface::statHReg(Dose *comp) { delete file; if (statExtra->isChecked()) { - QString path2 = QFileDialog::getSaveFileName(0, tr("Save File"), 0, + QString path2 = QFileDialog::getSaveFileName(nullptr, tr("Save File"), QString(), tr("Additional Statistics (*.txt)")); - if (path2 == 0) { + if (path2.isEmpty()) { return; } @@ -2508,7 +2494,7 @@ void Interface::statHMed(Dose *comp) { } } - QString path = QFileDialog::getSaveFileName(0, tr("Save File "), 0, + QString path = QFileDialog::getSaveFileName(nullptr, tr("Save File "), QString(), tr("Comma Separated values ") + tr("(*.csv)")); if (path == "") { @@ -2657,7 +2643,6 @@ void Interface::statHMed(Dose *comp) { } } - int n = 0; for (int i = 0; i < data->size(); i++) if (doseList->selectedItems().contains(doseList->item(i))) { temp.copyDose((*data)[i]); @@ -2739,7 +2724,6 @@ void Interface::statHMed(Dose *comp) { + QString(" ") + " |"; } } - n++; } delete input; @@ -2747,9 +2731,9 @@ void Interface::statHMed(Dose *comp) { delete file; if (statExtra->isChecked()) { - QString path2 = QFileDialog::getSaveFileName(0, tr("Save File"), 0, + QString path2 = QFileDialog::getSaveFileName(nullptr, tr("Save File"), QString(), tr("Additional Statistics (*.txt)")); - if (path2 == 0) { + if (path2.isEmpty()) { return; } diff --git a/source/interface.h b/source/interface.h index 76b5e01..f40a415 100644 --- a/source/interface.h +++ b/source/interface.h @@ -15,8 +15,6 @@ #ifndef INTERFACE_H #define INTERFACE_H -#define TRUE 1 -#define FALSE 0 #include "egsphant.h" #include "dose.h" #include "previewer.h" diff --git a/source/previewer.cpp b/source/previewer.cpp index 2ac2887..e2ef89f 100644 --- a/source/previewer.cpp +++ b/source/previewer.cpp @@ -4,18 +4,21 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Hover Label Class~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *******************************************************************************/ void HoverLabel::mouseMoveEvent(QMouseEvent *event) { - if (event->x() > 0 && event->x() < width() && event->y() > 0 && event->y() < height()) { - emit mouseMoved(event->x(),event->y()); + const QPointF pos = event->position(); + if (pos.x() > 0 && pos.x() < width() && pos.y() > 0 && pos.y() < height()) { + emit mouseMoved(int(pos.x()), int(pos.y())); } event->accept(); } void HoverLabel::wheelEvent(QWheelEvent *event) { - if (event->delta() > 0 && event->x() > 0 && event->x() < width() && event->y() > 0 && event->y() < height()) { - emit mouseWheelUp(); - } - else if (event->x() > 0 && event->x() < width() && event->y() > 0 && event->y() < height()) { - emit mouseWheelDown(); + const QPointF pos = event->position(); + if (pos.x() > 0 && pos.x() < width() && pos.y() > 0 && pos.y() < height()) { + if (event->angleDelta().y() > 0) { + emit mouseWheelUp(); + } else { + emit mouseWheelDown(); + } } event->accept(); } @@ -111,7 +114,7 @@ void Previewer::createLayout() { //style += "}"; errors = new QErrorMessage(); - errors->setHidden(TRUE); + errors->setHidden(true); errors->setWindowTitle(tr("Error")); window = new QWidget(); layout = new QGridLayout(); @@ -274,7 +277,7 @@ void Previewer::createLayout() { window->setStyleSheet(style); window->setLayout(layout); - window->setHidden(TRUE); + window->setHidden(true); window->setWindowTitle(tr("Previewer")); // Progress Bar @@ -407,7 +410,7 @@ void Previewer::connectLayout() { *******************************************************************************/ void Previewer::loadPhantom() { QString path = - QFileDialog::getOpenFileName(0, tr("Open File"), 0, + QFileDialog::getOpenFileName(nullptr, tr("Open File"), QString(), tr("EGSphant File (*.egsphant *begsphant)")); if (path == "") { return; @@ -440,60 +443,47 @@ void Previewer::loadPhantom() { } void Previewer::checkBounds() { - char flag = FALSE; if (phant.nx && phant.ny && phant.nz) { if (!dimBox->currentText().compare("x axis")) { if (dimai->getText().toDouble() < phant.y[0]) { dimai->setText(phant.y[0]); - flag++; } if (dimaf->getText().toDouble() > phant.y[phant.ny]) { dimaf->setText(phant.y[phant.ny]); - flag++; } if (dimbi->getText().toDouble() < phant.z[0]) { dimbi->setText(phant.z[0]); - flag++; } if (dimaf->getText().toDouble() > phant.z[phant.nz]) { dimbf->setText(phant.z[phant.nz]); - flag++; } } else if (!dimBox->currentText().compare("y axis")) { if (dimai->getText().toDouble() < phant.x[0]) { dimai->setText(phant.x[0]); - flag++; } if (dimaf->getText().toDouble() > phant.x[phant.nx]) { dimaf->setText(phant.x[phant.nx]); - flag++; } if (dimbi->getText().toDouble() < phant.z[0]) { dimbi->setText(phant.z[0]); - flag++; } if (dimaf->getText().toDouble() > phant.z[phant.nz]) { dimbf->setText(phant.z[phant.nz]); - flag++; } } else if (!dimBox->currentText().compare("z axis")) { if (dimai->getText().toDouble() < phant.x[0]) { dimai->setText(phant.x[0]); - flag++; } if (dimaf->getText().toDouble() > phant.x[phant.nx]) { dimaf->setText(phant.x[phant.nx]); - flag++; } if (dimbi->getText().toDouble() < phant.y[0]) { dimbi->setText(phant.y[0]); - flag++; } if (dimbf->getText().toDouble() > phant.y[phant.ny]) { dimbf->setText(phant.y[phant.ny]); - flag++; } } redraw(); @@ -876,7 +866,7 @@ void Previewer::updateImage() { pen.setColor(Qt::black); QFont font; - font.setWeight(75); + font.setWeight(QFont::Bold); font.setPointSize(16); painter.begin(picture); @@ -920,7 +910,7 @@ void Previewer::updateImage() { } void Previewer::saveImage() { - QString path = QFileDialog::getSaveFileName(0, tr("Save File"), "", + QString path = QFileDialog::getSaveFileName(nullptr, tr("Save File"), QString(), tr("PNG (*.png)")); if (path == "") { return; @@ -946,8 +936,8 @@ void Previewer::updateDoses() { } void Previewer::closePreview() { - this->setDisabled(TRUE); - mom->setEnabled(TRUE); + this->setDisabled(true); + mom->setEnabled(true); window->hide(); } diff --git a/source/previewer.h b/source/previewer.h index 2822a89..03cbaf2 100644 --- a/source/previewer.h +++ b/source/previewer.h @@ -1,8 +1,6 @@ #ifndef PREVIEWER_H #define PREVIEWER_H -#define TRUE 1 -#define FALSE 0 #include "dose.h" #include "egsphant.h" diff --git a/source/source.pro b/source/source.pro index b077fb5..0beb584 100644 --- a/source/source.pro +++ b/source/source.pro @@ -1,23 +1,19 @@ ###################################################################### -# Automatically generated by qmake (3.1) Thu Jun 25 15:03:50 2020 +# 3ddose_tools — Qt project file ###################################################################### QT += widgets +CONFIG += c++17 warn_on TEMPLATE = app TARGET = ../3ddose_tools INCLUDEPATH += . -# The following define makes your compiler warn you if you use any -# feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS +# Prefer a plain executable (matches historical Linux-oriented layout) +macx: CONFIG -= app_bundle -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 +# Warn on (and disallow) APIs deprecated in or before Qt 6.0 +DEFINES += QT_DEPRECATED_WARNINGS +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 -# Input HEADERS += dose.h egsphant.h interface.h previewer.h SOURCES += dose.cpp egsphant.cpp interface.cpp main.cpp previewer.cpp