From 2bc4b2ca6fbc02cd5fd40ed3adda923f4b1db059 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Fri, 8 Feb 2019 17:31:08 +0100 Subject: [PATCH 01/26] remove unused Q3Support headers -> Q3ListWidget -> Q3Mimexxx --- iSeg/AtlasWidget.cpp | 1 + iSeg/FastmarchingFuzzyWidget.h | 1 - iSeg/FeatureWidget.cpp | 1 - iSeg/FeatureWidget.h | 2 -- iSeg/HystereticGrowingWidget.cpp | 1 - iSeg/HystereticGrowingWidget.h | 2 -- iSeg/ImageForestingTransformRegionGrowingWidget.h | 1 - iSeg/InterpolationWidget.h | 2 -- iSeg/LivewireWidget.cpp | 1 - iSeg/LivewireWidget.h | 2 -- iSeg/MeasurementWidget.h | 1 - iSeg/PickerWidget.h | 1 - iSeg/Precompiled.h | 1 - iSeg/SaveOutlinesWidget.h | 3 ++- iSeg/SliceViewerWidget.cpp | 2 -- iSeg/SliceViewerWidget.h | 1 - iSeg/SmoothingWidget.h | 1 - iSeg/ThresholdWidget.cpp | 1 - iSeg/ThresholdWidget.h | 2 -- iSeg/TransformWidget.h | 1 - iSeg/VesselWidget.h | 1 - iSeg/WatershedWidget.h | 1 - 22 files changed, 3 insertions(+), 27 deletions(-) diff --git a/iSeg/AtlasWidget.cpp b/iSeg/AtlasWidget.cpp index e652706d..9df7c76a 100755 --- a/iSeg/AtlasWidget.cpp +++ b/iSeg/AtlasWidget.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/iSeg/FastmarchingFuzzyWidget.h b/iSeg/FastmarchingFuzzyWidget.h index 19c0689d..50829666 100755 --- a/iSeg/FastmarchingFuzzyWidget.h +++ b/iSeg/FastmarchingFuzzyWidget.h @@ -12,7 +12,6 @@ #include "Interface/WidgetInterface.h" #include -#include #include #include #include diff --git a/iSeg/FeatureWidget.cpp b/iSeg/FeatureWidget.cpp index edda3d01..cec4bb38 100755 --- a/iSeg/FeatureWidget.cpp +++ b/iSeg/FeatureWidget.cpp @@ -20,7 +20,6 @@ #include "Core/ImageForestingTransform.h" #include "Core/Pair.h" -#include #include #include #include diff --git a/iSeg/FeatureWidget.h b/iSeg/FeatureWidget.h index 770563cf..13b9642c 100755 --- a/iSeg/FeatureWidget.h +++ b/iSeg/FeatureWidget.h @@ -16,7 +16,6 @@ #include "Core/ImageForestingTransform.h" -#include #include #include #include @@ -33,7 +32,6 @@ #include #include //Added by qt3to4: -#include #include namespace iseg { diff --git a/iSeg/HystereticGrowingWidget.cpp b/iSeg/HystereticGrowingWidget.cpp index c4b08d47..a3ec3604 100755 --- a/iSeg/HystereticGrowingWidget.cpp +++ b/iSeg/HystereticGrowingWidget.cpp @@ -18,7 +18,6 @@ #include "Core/Pair.h" #include -#include #include #include #include diff --git a/iSeg/HystereticGrowingWidget.h b/iSeg/HystereticGrowingWidget.h index 08cb7e9f..00e82a66 100755 --- a/iSeg/HystereticGrowingWidget.h +++ b/iSeg/HystereticGrowingWidget.h @@ -14,8 +14,6 @@ #include "Interface/WidgetInterface.h" -#include -#include #include #include #include diff --git a/iSeg/ImageForestingTransformRegionGrowingWidget.h b/iSeg/ImageForestingTransformRegionGrowingWidget.h index f6b29a1c..b544c6d3 100755 --- a/iSeg/ImageForestingTransformRegionGrowingWidget.h +++ b/iSeg/ImageForestingTransformRegionGrowingWidget.h @@ -15,7 +15,6 @@ #include "Interface/WidgetInterface.h" #include -#include #include #include #include diff --git a/iSeg/InterpolationWidget.h b/iSeg/InterpolationWidget.h index f0404bb7..98e32b1e 100755 --- a/iSeg/InterpolationWidget.h +++ b/iSeg/InterpolationWidget.h @@ -14,8 +14,6 @@ #include "Interface/WidgetInterface.h" -#include -#include #include #include #include diff --git a/iSeg/LivewireWidget.cpp b/iSeg/LivewireWidget.cpp index 18b77fad..1b36020e 100755 --- a/iSeg/LivewireWidget.cpp +++ b/iSeg/LivewireWidget.cpp @@ -18,7 +18,6 @@ #include "Core/ImageForestingTransform.h" #include "Core/Pair.h" -#include #include #include #include diff --git a/iSeg/LivewireWidget.h b/iSeg/LivewireWidget.h index 9de230d9..ab5d8794 100755 --- a/iSeg/LivewireWidget.h +++ b/iSeg/LivewireWidget.h @@ -17,8 +17,6 @@ #include "Core/ImageForestingTransform.h" -#include -#include #include #include #include diff --git a/iSeg/MeasurementWidget.h b/iSeg/MeasurementWidget.h index 621389fa..89f2a1c3 100755 --- a/iSeg/MeasurementWidget.h +++ b/iSeg/MeasurementWidget.h @@ -15,7 +15,6 @@ #include "Interface/WidgetInterface.h" -#include #include #include #include diff --git a/iSeg/PickerWidget.h b/iSeg/PickerWidget.h index 40885838..9e1c338d 100755 --- a/iSeg/PickerWidget.h +++ b/iSeg/PickerWidget.h @@ -15,7 +15,6 @@ #include "Interface/WidgetInterface.h" -#include #include #include #include diff --git a/iSeg/Precompiled.h b/iSeg/Precompiled.h index fb2502b8..721b70aa 100755 --- a/iSeg/Precompiled.h +++ b/iSeg/Precompiled.h @@ -15,7 +15,6 @@ #include #include -#include #include #include #include diff --git a/iSeg/SaveOutlinesWidget.h b/iSeg/SaveOutlinesWidget.h index dd14c456..907d3b96 100755 --- a/iSeg/SaveOutlinesWidget.h +++ b/iSeg/SaveOutlinesWidget.h @@ -14,7 +14,6 @@ #include "bmp_read_1.h" #include -#include #include #include #include @@ -30,6 +29,8 @@ #include #include +class Q3ListBox; + namespace iseg { class SaveOutlinesWidget : public QDialog diff --git a/iSeg/SliceViewerWidget.cpp b/iSeg/SliceViewerWidget.cpp index 620658fd..abf1373d 100755 --- a/iSeg/SliceViewerWidget.cpp +++ b/iSeg/SliceViewerWidget.cpp @@ -17,8 +17,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/iSeg/SliceViewerWidget.h b/iSeg/SliceViewerWidget.h index b6fbe138..d0a1c42f 100755 --- a/iSeg/SliceViewerWidget.h +++ b/iSeg/SliceViewerWidget.h @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/iSeg/SmoothingWidget.h b/iSeg/SmoothingWidget.h index a0407a9d..33a70af5 100755 --- a/iSeg/SmoothingWidget.h +++ b/iSeg/SmoothingWidget.h @@ -15,7 +15,6 @@ #include "Interface/WidgetInterface.h" -#include #include #include #include diff --git a/iSeg/ThresholdWidget.cpp b/iSeg/ThresholdWidget.cpp index 02d908cb..4feb114a 100755 --- a/iSeg/ThresholdWidget.cpp +++ b/iSeg/ThresholdWidget.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/iSeg/ThresholdWidget.h b/iSeg/ThresholdWidget.h index 9e5fbe14..96d36995 100755 --- a/iSeg/ThresholdWidget.h +++ b/iSeg/ThresholdWidget.h @@ -14,8 +14,6 @@ #include "Interface/WidgetInterface.h" -#include -#include #include #include #include diff --git a/iSeg/TransformWidget.h b/iSeg/TransformWidget.h index ccf6c359..15b76e4b 100755 --- a/iSeg/TransformWidget.h +++ b/iSeg/TransformWidget.h @@ -13,7 +13,6 @@ #include "Interface/WidgetInterface.h" -#include #include #include #include diff --git a/iSeg/VesselWidget.h b/iSeg/VesselWidget.h index bb31e31b..6513dbff 100755 --- a/iSeg/VesselWidget.h +++ b/iSeg/VesselWidget.h @@ -14,7 +14,6 @@ #include "Interface/WidgetInterface.h" -#include #include #include #include diff --git a/iSeg/WatershedWidget.h b/iSeg/WatershedWidget.h index 97f3eed4..1bcafd8b 100755 --- a/iSeg/WatershedWidget.h +++ b/iSeg/WatershedWidget.h @@ -11,7 +11,6 @@ #include "Interface/WidgetInterface.h" -#include #include #include #include From ae957057062277aba96657eadd7cf3b3412ccb0e Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Fri, 8 Feb 2019 22:53:12 +0100 Subject: [PATCH 02/26] get rid of Q3Action --- iSeg/AtlasViewer.h | 1 - iSeg/AtlasWidget.h | 1 - iSeg/ImageViewerWidget.cpp | 30 ++++++------- iSeg/ImageViewerWidget.h | 28 ++++++------ iSeg/MainWindow.cpp | 89 +++++++++++++++++--------------------- iSeg/MainWindow.h | 33 +++++--------- 6 files changed, 79 insertions(+), 103 deletions(-) diff --git a/iSeg/AtlasViewer.h b/iSeg/AtlasViewer.h index 36ec69c7..91a852cf 100755 --- a/iSeg/AtlasViewer.h +++ b/iSeg/AtlasViewer.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/iSeg/AtlasWidget.h b/iSeg/AtlasWidget.h index e6367148..859c8c65 100755 --- a/iSeg/AtlasWidget.h +++ b/iSeg/AtlasWidget.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/iSeg/ImageViewerWidget.cpp b/iSeg/ImageViewerWidget.cpp index 4d71592a..596d47e6 100644 --- a/iSeg/ImageViewerWidget.cpp +++ b/iSeg/ImageViewerWidget.cpp @@ -19,13 +19,12 @@ #include "Core/ColorLookupTable.h" -#include +#include #include #include #include #include #include -#include #include #include #include @@ -37,6 +36,7 @@ #include #include +#include #include #include #include @@ -63,19 +63,19 @@ ImageViewerWidget::ImageViewerWidget(QWidget* parent, const char* name, Qt::Wind overlayalpha = 0.0f; // vp=new vector; // vp_old=new vector; - selecttissue = new Q3Action("Select Tissue", 0, this); - addtoselection = new Q3Action("Select Tissue", 0, this); - viewtissue = new Q3Action("View Tissue Surface", 0, this); - nexttargetslice = new Q3Action("Next Target Slice", 0, this); - addmark = new Q3Action("&Add Mark", 0, this); - addlabel = new Q3Action("Add &Label", 0, this); - removemark = new Q3Action("&Remove Mark", 0, this); - clearmarks = new Q3Action("&Clear Marks", 0, this); - addtissue = new Q3Action("Add &Tissue", 0, this); - addtissueconnected = new Q3Action("Add Tissue &Conn", 0, this); - addtissue3D = new Q3Action("Add Tissue 3&D", 0, this); - subtissue = new Q3Action("&Subtract Tissue", 0, this); - addtissuelarger = new Q3Action("Add Tissue &Larger", 0, this); + selecttissue = new QAction("Select Tissue", this); + addtoselection = new QAction("Select Tissue", this); + viewtissue = new QAction("View Tissue Surface", this); + nexttargetslice = new QAction("Next Target Slice", this); + addmark = new QAction("&Add Mark", this); + addlabel = new QAction("Add &Label", this); + removemark = new QAction("&Remove Mark", this); + clearmarks = new QAction("&Clear Marks", this); + addtissue = new QAction("Add &Tissue", this); + addtissueconnected = new QAction("Add Tissue &Conn", this); + addtissue3D = new QAction("Add Tissue 3&D", this); + subtissue = new QAction("&Subtract Tissue", this); + addtissuelarger = new QAction("Add Tissue &Larger", this); connect(addmark, SIGNAL(activated()), this, SLOT(add_mark())); connect(addlabel, SIGNAL(activated()), this, SLOT(add_label())); connect(clearmarks, SIGNAL(activated()), this, SLOT(clear_marks())); diff --git a/iSeg/ImageViewerWidget.h b/iSeg/ImageViewerWidget.h index 50e065c0..9268ab1f 100644 --- a/iSeg/ImageViewerWidget.h +++ b/iSeg/ImageViewerWidget.h @@ -18,7 +18,7 @@ #include -class Q3Action; +class QAction; namespace iseg { @@ -131,19 +131,19 @@ class ImageViewerWidget : public QWidget QPoint mousePosZoom; std::vector* marks; int eventx, eventy; - Q3Action* addmark; - Q3Action* addlabel; - Q3Action* clearmarks; - Q3Action* removemark; - Q3Action* addtissue; - Q3Action* addtissueconnected; - Q3Action* subtissue; - Q3Action* addtissue3D; - Q3Action* addtissuelarger; - Q3Action* selecttissue; - Q3Action* addtoselection; - Q3Action* viewtissue; - Q3Action* nexttargetslice; + QAction* addmark; + QAction* addlabel; + QAction* clearmarks; + QAction* removemark; + QAction* addtissue; + QAction* addtissueconnected; + QAction* subtissue; + QAction* addtissue3D; + QAction* addtissuelarger; + QAction* selecttissue; + QAction* addtoselection; + QAction* viewtissue; + QAction* nexttargetslice; std::vector vp; std::vector vp_old; std::vector vp1; diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index 89cb8633..82a7b089 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include #include @@ -1231,10 +1231,10 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, editmenu = menuBar()->addMenu(tr("E&dit")); undonr = editmenu->insertItem( - QIcon(m_picpath.absFilePath(QString("undo.png")).ascii()), "&Undo", this, + QIcon(m_picpath.absFilePath(QString("undo.png"))), "&Undo", this, SLOT(execute_undo())); redonr = editmenu->insertItem( - QIcon(m_picpath.absFilePath(QString("redo.png")).ascii()), "Redo", this, + QIcon(m_picpath.absFilePath(QString("redo.png"))), "Redo", this, SLOT(execute_redo())); editmenu->insertSeparator(); editmenu->insertItem("&Configure Undo...", this, SLOT(execute_undoconf())); @@ -1258,39 +1258,35 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, hidemenu->addAction(overlaydock->toggleViewAction()); hidemenu->addAction(multiDatasetDock->toggleViewAction()); - hidecontrastbright = new Q3Action("Contr./Bright.", 0, this); + hidecontrastbright = new QAction("Contr./Bright.", this); hidecontrastbright->setToggleAction(true); hidecontrastbright->setOn(true); - connect(hidecontrastbright, SIGNAL(toggled(bool)), this, - SLOT(execute_hidecontrastbright(bool))); + connect(hidecontrastbright, SIGNAL(toggled(bool)), this, SLOT(execute_hidecontrastbright(bool))); hidecontrastbright->addTo(hidemenu); - hidesource = new Q3Action("Source", 0, this); + hidesource = new QAction("Source", this); hidesource->setToggleAction(true); hidesource->setOn(true); - connect(hidesource, SIGNAL(toggled(bool)), this, - SLOT(execute_hidesource(bool))); + connect(hidesource, SIGNAL(toggled(bool)), this, SLOT(execute_hidesource(bool))); hidesource->addTo(hidemenu); - hidetarget = new Q3Action("Target", 0, this); + hidetarget = new QAction("Target", this); hidetarget->setToggleAction(true); hidetarget->setOn(true); - connect(hidetarget, SIGNAL(toggled(bool)), this, - SLOT(execute_hidetarget(bool))); + connect(hidetarget, SIGNAL(toggled(bool)), this, SLOT(execute_hidetarget(bool))); hidetarget->addTo(hidemenu); - hidecopyswap = new Q3Action("Copy/Swap", 0, this); + hidecopyswap = new QAction("Copy/Swap", this); hidecopyswap->setToggleAction(true); hidecopyswap->setOn(true); - connect(hidecopyswap, SIGNAL(toggled(bool)), this, - SLOT(execute_hidecopyswap(bool))); + connect(hidecopyswap, SIGNAL(toggled(bool)), this, SLOT(execute_hidecopyswap(bool))); hidecopyswap->addTo(hidemenu); for (unsigned short i = 0; i < nrtabbuttons; i++) { - showtab_action[i] = new Q3Action(tabwidgets[i]->GetName().c_str(), 0, this); + showtab_action[i] = new QAction(tabwidgets[i]->GetName().c_str(), this); showtab_action[i]->setToggleAction(true); showtab_action[i]->setOn(showpb_tab[i]); connect(showtab_action[i], SIGNAL(toggled(bool)), this, SLOT(execute_showtabtoggled(bool))); showtab_action[i]->addTo(hidesubmenu); } - hideparameters = new Q3Action("Simplified", 0, this); + hideparameters = new QAction("Simplified", this); hideparameters->setToggleAction(true); hideparameters->setOn(WidgetInterface::get_hideparams()); connect(hideparameters, SIGNAL(toggled(bool)), this, SLOT(execute_hideparameters(bool))); @@ -1659,39 +1655,32 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, // QObject::connect(pb_work2tissue,SIGNAL(clicked()),this,SLOT(do_work2tissue())); - m_acc_sliceup = new Q3Accel(this); - m_acc_sliceup->connectItem(m_acc_sliceup->insertItem(QKeySequence(Qt::CTRL + Qt::Key_Right)), this, - SLOT(slicenr_up())); - m_acc_slicedown = new Q3Accel(this); - m_acc_slicedown->connectItem(m_acc_slicedown->insertItem(QKeySequence(Qt::CTRL + Qt::Key_Left)), this, - SLOT(slicenr_down())); - m_acc_sliceup1 = new Q3Accel(this); - m_acc_sliceup->connectItem(m_acc_sliceup->insertItem(QKeySequence(Qt::Key_Next)), this, - SLOT(slicenr_up())); - m_acc_slicedown1 = new Q3Accel(this); - m_acc_slicedown->connectItem(m_acc_slicedown->insertItem(QKeySequence(Qt::Key_Prior)), this, - SLOT(slicenr_down())); - m_acc_zoomin = new Q3Accel(this); - m_acc_zoomin->connectItem(m_acc_zoomin->insertItem(QKeySequence(Qt::CTRL + Qt::Key_Up)), this, - SLOT(zoom_in())); - m_acc_zoomout = new Q3Accel(this); - m_acc_zoomout->connectItem(m_acc_zoomout->insertItem(QKeySequence(Qt::CTRL + Qt::Key_Down)), this, - SLOT(zoom_out())); - m_acc_add = new Q3Accel(this); - m_acc_add->connectItem(m_acc_add->insertItem(QKeySequence(Qt::CTRL + Qt::Key_Plus)), this, - SLOT(add_tissue_shortkey())); - m_acc_sub = new Q3Accel(this); - m_acc_sub->connectItem(m_acc_sub->insertItem(QKeySequence(Qt::CTRL + Qt::Key_Minus)), this, - SLOT(subtract_tissue_shortkey())); - m_acc_undo = new Q3Accel(this); - m_acc_undo->connectItem(m_acc_undo->insertItem(QKeySequence(Qt::Key_Escape)), - this, SLOT(execute_undo())); - m_acc_undo2 = new Q3Accel(this); - m_acc_undo2->connectItem(m_acc_undo2->insertItem(QKeySequence("Ctrl+Z")), - this, SLOT(execute_undo())); - m_acc_redo = new Q3Accel(this); - m_acc_redo->connectItem(m_acc_redo->insertItem(QKeySequence("Ctrl+Y")), this, - SLOT(execute_redo())); + // shortcuts -> TODO: replace those which have a button/menu action so user can learn about shortcut + auto shortcut_sliceup = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right), this); + connect(shortcut_sliceup, SIGNAL(activated()), this, SLOT(slicenr_up())); + auto shortcut_slicedown = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left), this); + connect(shortcut_slicedown, SIGNAL(activated()), this, SLOT(slicenr_down())); + auto shortcut_sliceup1 = new QShortcut(QKeySequence(Qt::Key_Next), this); + connect(shortcut_sliceup, SIGNAL(activated()), this, SLOT(slicenr_up())); + auto shortcut_slicedown1 = new QShortcut(QKeySequence(Qt::Key_Prior), this); + connect(shortcut_slicedown, SIGNAL(activated()), this, SLOT(slicenr_down())); + + auto shortcut_zoomin = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up), this); + connect(shortcut_zoomin, SIGNAL(activated()), this, SLOT(zoom_in())); + auto shortcut_zoomout = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down), this); + connect(shortcut_zoomout, SIGNAL(activated()), this, SLOT(zoom_out())); + + auto shortcut_add = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus), this); + connect(shortcut_add, SIGNAL(activated()), this, SLOT(add_tissue_shortkey())); + auto shortcut_sub = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus), this); + connect(shortcut_sub, SIGNAL(activated()), this, SLOT(subtract_tissue_shortkey())); + + auto shortcut_undo = new QShortcut(QKeySequence(Qt::Key_Escape), this); + connect(shortcut_undo, SIGNAL(activated()), this, SLOT(execute_undo())); + auto shortcut_undo2 = new QShortcut(QKeySequence("Ctrl+Z"), this); + connect(shortcut_undo2, SIGNAL(activated()), this, SLOT(execute_undo())); + auto shortcut_redo = new QShortcut(QKeySequence("Ctrl+Y"), this); + connect(shortcut_redo, SIGNAL(activated()), this, SLOT(execute_redo())); update_brightnesscontrast(true); update_brightnesscontrast(false); diff --git a/iSeg/MainWindow.h b/iSeg/MainWindow.h index 2dc226b9..37e12850 100755 --- a/iSeg/MainWindow.h +++ b/iSeg/MainWindow.h @@ -39,8 +39,7 @@ class QStackedWidget; class QScrollBar; class Q3ScrollView; class Q3PopupMenu; -class Q3Action; -class Q3Accel; +class QAction; namespace iseg { @@ -211,15 +210,15 @@ class MainWindow : public QMainWindow QPushButton* clearTissue; QPushButton* clearTissues; QWidget* menubarspacer; - Q3Action* hideparameters; - Q3Action* hidezoom; - Q3Action* hidecontrastbright; - Q3Action* hidecopyswap; - Q3Action* hidestack; - Q3Action* hidenotes; - Q3Action* hidesource; - Q3Action* hidetarget; - std::vector showtab_action; + QAction* hideparameters; + QAction* hidezoom; + QAction* hidecontrastbright; + QAction* hidecopyswap; + QAction* hidestack; + QAction* hidenotes; + QAction* hidesource; + QAction* hidetarget; + std::vector showtab_action; QCheckBox* tissue3Dopt; QStackedWidget* methodTab; ThresholdWidget* threshold_widget; @@ -298,17 +297,7 @@ class MainWindow : public QMainWindow QSlider* sl_contrastwork; QSlider* sl_brightnessbmp; QSlider* sl_brightnesswork; - Q3Accel* m_acc_undo; - Q3Accel* m_acc_undo2; - Q3Accel* m_acc_redo; - Q3Accel* m_acc_sub; - Q3Accel* m_acc_add; - Q3Accel* m_acc_zoomout; - Q3Accel* m_acc_zoomin; - Q3Accel* m_acc_slicedown1; - Q3Accel* m_acc_sliceup1; - Q3Accel* m_acc_slicedown; - Q3Accel* m_acc_sliceup; + QTextEdit* m_notes; std::vector pb_tab; QSignalMapper* m_widget_signal_mapper; From 03a40fbcbb6bc278b16e13296a84c22c19845c41 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Thu, 7 Feb 2019 18:24:36 +0100 Subject: [PATCH 03/26] fix: prevent crash during SaveSettings for certain configurations (MacOS, ...?) --- iSeg/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index 82a7b089..ea72ec59 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -3192,7 +3192,7 @@ void MainWindow::SaveSettings() fwrite(&flag, 1, sizeof(bool), fp); for (unsigned short i = 0; i < 16; i++) { - flag = showtab_action[i]->isOn(); + flag = (i < showtab_action.size()) ? showtab_action[i]->isOn() : true; fwrite(&flag, 1, sizeof(bool), fp); } fp = TissueInfos::SaveTissues(fp, saveProjVersion); From a5782c3b5ef1e5c1310eeeb36ce3996d2aaac035 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Fri, 8 Feb 2019 23:18:11 +0100 Subject: [PATCH 04/26] get rid of Q3ListWidget --- iSeg/SaveOutlinesWidget.cpp | 21 ++++++++------------- iSeg/SaveOutlinesWidget.h | 4 ++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/iSeg/SaveOutlinesWidget.cpp b/iSeg/SaveOutlinesWidget.cpp index 1e161640..8b1323b0 100755 --- a/iSeg/SaveOutlinesWidget.cpp +++ b/iSeg/SaveOutlinesWidget.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include @@ -37,12 +37,12 @@ SaveOutlinesWidget::SaveOutlinesWidget(SlicesHandler* hand3D, QWidget* parent, : QDialog(parent, name, TRUE, wFlags), handler3D(hand3D) { vbox1 = new Q3VBox(this); - lbo_tissues = new Q3ListBox(vbox1); + lbo_tissues = new QListWidget(vbox1); for (tissues_size_t i = 1; i <= TissueInfos::GetTissueCount(); ++i) { - lbo_tissues->insertItem(ToQ(TissueInfos::GetTissueName(i))); + lbo_tissues->addItem(ToQ(TissueInfos::GetTissueName(i))); } - lbo_tissues->setMultiSelection(true); + lbo_tissues->setSelectionMode(QAbstractItemView::ExtendedSelection); hbox2 = new Q3HBox(vbox1); hbox1 = new Q3HBox(vbox1); hbox3 = new Q3HBox(vbox1); @@ -128,16 +128,11 @@ SaveOutlinesWidget::SaveOutlinesWidget(SlicesHandler* hand3D, QWidget* parent, QObject::connect(pb_file, SIGNAL(clicked()), this, SLOT(file_pushed())); QObject::connect(pb_exec, SIGNAL(clicked()), this, SLOT(save_pushed())); QObject::connect(pb_close, SIGNAL(clicked()), this, SLOT(close())); - QObject::connect(filetype, SIGNAL(buttonClicked(int)), this, - SLOT(mode_changed())); - QObject::connect(cb_extrusion, SIGNAL(clicked()), this, - SLOT(mode_changed())); - QObject::connect(simplif, SIGNAL(buttonClicked(int)), this, - SLOT(simplif_changed())); + QObject::connect(filetype, SIGNAL(buttonClicked(int)), this, SLOT(mode_changed())); + QObject::connect(cb_extrusion, SIGNAL(clicked()), this, SLOT(mode_changed())); + QObject::connect(simplif, SIGNAL(buttonClicked(int)), this, SLOT(simplif_changed())); mode_changed(); - - return; } SaveOutlinesWidget::~SaveOutlinesWidget() @@ -238,7 +233,7 @@ void SaveOutlinesWidget::save_pushed() vector vtissues; for (tissues_size_t i = 0; i < TissueInfos::GetTissueCount(); i++) { - if (lbo_tissues->isSelected((int)i)) + if (lbo_tissues->item((int)i)->isSelected()) { vtissues.push_back((tissues_size_t)i + 1); } diff --git a/iSeg/SaveOutlinesWidget.h b/iSeg/SaveOutlinesWidget.h index 907d3b96..09a86362 100755 --- a/iSeg/SaveOutlinesWidget.h +++ b/iSeg/SaveOutlinesWidget.h @@ -29,7 +29,7 @@ #include #include -class Q3ListBox; +class QListWidget; namespace iseg { @@ -55,7 +55,7 @@ class SaveOutlinesWidget : public QDialog Q3HBox* hbox9; Q3HBox* hboxslicesbetween; Q3VBox* vbox1; - Q3ListBox* lbo_tissues; + QListWidget* lbo_tissues; QPushButton* pb_file; QPushButton* pb_exec; QPushButton* pb_close; From d14b1d58c5182f6880ef7cd8236d67b5b003ac9e Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Fri, 8 Feb 2019 23:18:44 +0100 Subject: [PATCH 05/26] get rid of Q3PopupMenu --- iSeg/AtlasViewer.cpp | 1 - iSeg/AtlasWidget.cpp | 1 - iSeg/ImageViewerWidget.cpp | 30 +++++++++++++++--------------- iSeg/MainWindow.cpp | 13 ++++++------- iSeg/MainWindow.h | 17 ++++++++--------- 5 files changed, 29 insertions(+), 33 deletions(-) diff --git a/iSeg/AtlasViewer.cpp b/iSeg/AtlasViewer.cpp index cf67086f..b194c0d9 100755 --- a/iSeg/AtlasViewer.cpp +++ b/iSeg/AtlasViewer.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/iSeg/AtlasWidget.cpp b/iSeg/AtlasWidget.cpp index 9df7c76a..902d80b0 100755 --- a/iSeg/AtlasWidget.cpp +++ b/iSeg/AtlasWidget.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/iSeg/ImageViewerWidget.cpp b/iSeg/ImageViewerWidget.cpp index 596d47e6..5c10c2e2 100644 --- a/iSeg/ImageViewerWidget.cpp +++ b/iSeg/ImageViewerWidget.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -718,32 +718,32 @@ void ImageViewerWidget::contextMenuEvent(QContextMenuEvent* event) eventx = (int)max(min(width - 1.0, (event->x() / (zoom * pixelsize.high))), 0.0); eventy = (int)max(min(height - 1.0, height - 1 - (event->y() / (zoom * pixelsize.low))), 0.0); - Q3PopupMenu contextMenu(this); + QMenu contextMenu(this); if (!bmporwork) { - nexttargetslice->addTo(&contextMenu); + contextMenu.addAction(nexttargetslice); } - addmark->addTo(&contextMenu); - addlabel->addTo(&contextMenu); - removemark->addTo(&contextMenu); - clearmarks->addTo(&contextMenu); + contextMenu.addAction(addmark); + contextMenu.addAction(addlabel); + contextMenu.addAction(removemark); + contextMenu.addAction(clearmarks); if (event->modifiers() == Qt::ControlModifier) { - addtoselection->addTo(&contextMenu); + contextMenu.addAction(addtoselection); } else { - selecttissue->addTo(&contextMenu); + contextMenu.addAction(selecttissue); } - viewtissue->addTo(&contextMenu); + contextMenu.addAction(viewtissue); if (!bmporwork) { contextMenu.insertSeparator(); - addtissue->addTo(&contextMenu); - subtissue->addTo(&contextMenu); - addtissue3D->addTo(&contextMenu); - addtissueconnected->addTo(&contextMenu); - addtissuelarger->addTo(&contextMenu); + contextMenu.addAction(addtissue); + contextMenu.addAction(subtissue); + contextMenu.addAction(addtissue3D); + contextMenu.addAction(addtissueconnected); + contextMenu.addAction(addtissuelarger); } contextMenu.exec(event->globalPos()); } diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index ea72ec59..330065aa 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -64,7 +64,6 @@ #include #include #include -#include #include #include #include @@ -1090,7 +1089,7 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, file->insertItem( QIcon(m_picpath.absFilePath(QString("filenew.png")).ascii()), "&New...", this, SLOT(execute_new())); - loadmenu = new Q3PopupMenu(this, "loadmenu"); + loadmenu = new QMenu("loadmenu", this); loadmenu->insertItem("Open .dcm...", this, SLOT(execute_loaddicom())); loadmenu->insertItem("Open .bmp...", this, SLOT(execute_loadbmp())); loadmenu->insertItem("Open .png...", this, SLOT(execute_loadpng())); @@ -1103,7 +1102,7 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, loadmenu->insertItem("Open RTdose...", this, SLOT(execute_loadrtdose())); file->insertItem("&Open", loadmenu); } - reloadmenu = new Q3PopupMenu(this, "reloadmenu"); + reloadmenu = new QMenu("reloadmenu", this); reloadmenu->insertItem("Reopen .dc&m...", this, SLOT(execute_reloaddicom())); reloadmenu->insertItem("Reopen .&bmp...", this, SLOT(execute_reloadbmp())); reloadmenu->insertItem("Reopen .raw...", this, SLOT(execute_reloadraw())); @@ -1141,7 +1140,7 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, file->insertItem("&Export Image(s)...", this, SLOT(execute_saveimg())); file->insertItem("Export &Contour...", this, SLOT(execute_saveContours())); - exportmenu = new Q3PopupMenu(this, "exportmenu"); + exportmenu = new QMenu("exportmenu", this); exportmenu->insertItem("Export &Labelfield...(am)", this, SLOT(execute_exportlabelfield())); exportmenu->insertItem("Export vtk-ascii...(vti/vtk)", this, SLOT(execute_exportvtkascii())); exportmenu->insertItem("Export vtk-binary...(vti/vtk)", this, SLOT(execute_exportvtkbinary())); @@ -1245,8 +1244,8 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, editmenu->insertItem("&Settings...", this, SLOT(execute_settings())); viewmenu = menuBar()->addMenu(tr("&View")); - hidemenu = new Q3PopupMenu(this, "hidemenu"); - hidesubmenu = new Q3PopupMenu(this, "hidesubmenu"); + hidemenu = new QMenu("hidemenu", this); + hidesubmenu = new QMenu("hidesubmenu", this); hidemenu->addAction(tabswdock->toggleViewAction()); hidemenu->addAction(methodTabdock->toggleViewAction()); hidemenu->addAction(notesdock->toggleViewAction()); @@ -6490,7 +6489,7 @@ void MainWindow::tree_widget_contextmenu(const QPoint& pos) { QList list = tissueTreeWidget->selectedItems(); - Q3PopupMenu contextMenu(tissueTreeWidget, "tissuetreemenu"); + QMenu contextMenu("tissuetreemenu", tissueTreeWidget); if (list.size() <= 1) // single selection { if (tissueTreeWidget->get_current_is_folder()) diff --git a/iSeg/MainWindow.h b/iSeg/MainWindow.h index 37e12850..e613f7b8 100755 --- a/iSeg/MainWindow.h +++ b/iSeg/MainWindow.h @@ -38,7 +38,6 @@ class QDockWidget; class QStackedWidget; class QScrollBar; class Q3ScrollView; -class Q3PopupMenu; class QAction; namespace iseg { @@ -186,14 +185,14 @@ class MainWindow : public QMainWindow QMenu* atlasmenu; QMenu* helpmenu; QMenu* editmenu; - Q3PopupMenu* loadmenu; - Q3PopupMenu* reloadmenu; - Q3PopupMenu* exportmenu; - Q3PopupMenu* saveprojasmenu; - Q3PopupMenu* saveprojmenu; - Q3PopupMenu* saveactiveslicesmenu; - Q3PopupMenu* hidemenu; - Q3PopupMenu* hidesubmenu; + QMenu* loadmenu; + QMenu* reloadmenu; + QMenu* exportmenu; + QMenu* saveprojasmenu; + QMenu* saveprojmenu; + QMenu* saveactiveslicesmenu; + QMenu* hidemenu; + QMenu* hidesubmenu; QDockWidget* tissuesDock; TissueTreeWidget* tissueTreeWidget; // Widget visualizing the tissue hierarchy QLineEdit* tissueFilter; From a254873f7518e0bbe0c738a007adf0c1df8db344 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Fri, 8 Feb 2019 23:38:10 +0100 Subject: [PATCH 06/26] replace isOn by isChecked (buttons, like QRadioButton) --- iSeg/AtlasWidget.cpp | 6 +- iSeg/EdgeWidget.cpp | 52 +++---- iSeg/FastmarchingFuzzyWidget.cpp | 24 ++-- iSeg/HystereticGrowingWidget.cpp | 14 +- ...eForestingTransformRegionGrowingWidget.cpp | 8 +- iSeg/InterpolationWidget.cpp | 72 +++++----- iSeg/LivewireWidget.cpp | 34 ++--- iSeg/LoaderWidgets.cpp | 84 +++++------ iSeg/MainWindow.cpp | 132 +++++++++--------- iSeg/MeasurementWidget.cpp | 76 +++++----- iSeg/MorphologyWidget.cpp | 26 ++-- iSeg/OutlineCorrectionParameterViews.cpp | 22 +-- iSeg/OutlineCorrectionParameterViews.h | 20 +-- iSeg/PickerWidget.cpp | 26 ++-- iSeg/SaveOutlinesWidget.cpp | 20 +-- iSeg/SliceViewerWidget.cpp | 6 +- iSeg/SmoothingWidget.cpp | 50 +++---- iSeg/ThresholdWidget.cpp | 56 ++++---- iSeg/TransformWidget.cpp | 8 +- iSeg/VolumeViewerWidget.cpp | 24 ++-- iSeg/WidgetCollection.cpp | 28 ++-- 21 files changed, 394 insertions(+), 394 deletions(-) diff --git a/iSeg/AtlasWidget.cpp b/iSeg/AtlasWidget.cpp index 902d80b0..ef010aba 100755 --- a/iSeg/AtlasWidget.cpp +++ b/iSeg/AtlasWidget.cpp @@ -291,17 +291,17 @@ void AtlasWidget::sl_transp_changed() void AtlasWidget::xyz_changed() { scb_slicenr->setValue(0); - if (rb_x->isOn()) + if (rb_x->isChecked()) { scb_slicenr->setMaxValue(dimx - 1); atlasViewer->orient_changed(0); } - else if (rb_y->isOn()) + else if (rb_y->isChecked()) { scb_slicenr->setMaxValue(dimy - 1); atlasViewer->orient_changed(1); } - else if (rb_z->isOn()) + else if (rb_z->isChecked()) { scb_slicenr->setMaxValue(dimz - 1); atlasViewer->orient_changed(2); diff --git a/iSeg/EdgeWidget.cpp b/iSeg/EdgeWidget.cpp index cf9c2662..7b00a64b 100755 --- a/iSeg/EdgeWidget.cpp +++ b/iSeg/EdgeWidget.cpp @@ -200,33 +200,33 @@ void EdgeWidget::execute() dataSelection.work = true; emit begin_datachange(dataSelection, this); - if (rb_sobel->isOn()) + if (rb_sobel->isChecked()) { bmphand->sobel(); } - else if (rb_laplacian->isOn()) + else if (rb_laplacian->isChecked()) { bmphand->laplacian1(); } - else if (rb_interquartile->isOn()) + else if (rb_interquartile->isChecked()) { bmphand->median_interquartile(false); } - else if (rb_momentline->isOn()) + else if (rb_momentline->isChecked()) { bmphand->moment_line(); } - else if (rb_gaussline->isOn()) + else if (rb_gaussline->isChecked()) { bmphand->gauss_line(sl_sigma->value() * 0.05f); } - else if (rb_canny->isOn()) + else if (rb_canny->isChecked()) { bmphand->canny_line(sl_sigma->value() * 0.05f, sl_thresh1->value() * 1.5f, sl_thresh2->value() * 1.5f); } - else if (rb_centerlines->isOn()) + else if (rb_centerlines->isChecked()) { try { @@ -290,23 +290,23 @@ void EdgeWidget::method_changed(int) { if (hideparams) { - if (!rb_laplacian->isOn()) + if (!rb_laplacian->isChecked()) { rb_laplacian->hide(); } - if (!rb_interquartile->isOn()) + if (!rb_interquartile->isChecked()) { rb_interquartile->hide(); } - if (!rb_momentline->isOn()) + if (!rb_momentline->isChecked()) { rb_momentline->hide(); } - if (!rb_gaussline->isOn()) + if (!rb_gaussline->isChecked()) { rb_gaussline->hide(); } - if (!rb_gaussline->isOn()) + if (!rb_gaussline->isChecked()) { rb_laplacianzero->hide(); } @@ -320,7 +320,7 @@ void EdgeWidget::method_changed(int) rb_laplacianzero->show(); } - if (rb_sobel->isOn()) + if (rb_sobel->isChecked()) { hbox1->hide(); hbox2->hide(); @@ -328,7 +328,7 @@ void EdgeWidget::method_changed(int) hbox4->hide(); btn_exec->show(); } - else if (rb_laplacian->isOn()) + else if (rb_laplacian->isChecked()) { hbox1->hide(); hbox2->hide(); @@ -336,7 +336,7 @@ void EdgeWidget::method_changed(int) hbox4->hide(); btn_exec->show(); } - else if (rb_interquartile->isOn()) + else if (rb_interquartile->isChecked()) { hbox1->hide(); hbox2->hide(); @@ -344,7 +344,7 @@ void EdgeWidget::method_changed(int) hbox4->hide(); btn_exec->show(); } - else if (rb_momentline->isOn()) + else if (rb_momentline->isChecked()) { hbox1->hide(); hbox2->hide(); @@ -352,7 +352,7 @@ void EdgeWidget::method_changed(int) hbox4->hide(); btn_exec->show(); } - else if (rb_gaussline->isOn()) + else if (rb_gaussline->isChecked()) { if (hideparams) hbox1->hide(); @@ -363,7 +363,7 @@ void EdgeWidget::method_changed(int) hbox4->hide(); btn_exec->show(); } - else if (rb_canny->isOn()) + else if (rb_canny->isChecked()) { txt_thresh11->setText("Thresh low: 0 "); txt_thresh12->setText(" 150"); @@ -382,7 +382,7 @@ void EdgeWidget::method_changed(int) hbox4->hide(); btn_exec->show(); } - else if (rb_centerlines->isOn()) + else if (rb_centerlines->isChecked()) { hbox1->hide(); hbox2->hide(); @@ -438,19 +438,19 @@ FILE* EdgeWidget::SaveParams(FILE* fp, int version) fwrite(&(dummy), 1, sizeof(int), fp); dummy = sl_thresh2->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_sobel->isOn()); + dummy = (int)(rb_sobel->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_laplacian->isOn()); + dummy = (int)(rb_laplacian->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_interquartile->isOn()); + dummy = (int)(rb_interquartile->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_momentline->isOn()); + dummy = (int)(rb_momentline->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_gaussline->isOn()); + dummy = (int)(rb_gaussline->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_canny->isOn()); + dummy = (int)(rb_canny->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_laplacianzero->isOn()); + dummy = (int)(rb_laplacianzero->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); } diff --git a/iSeg/FastmarchingFuzzyWidget.cpp b/iSeg/FastmarchingFuzzyWidget.cpp index 12f0288d..4f30e24d 100755 --- a/iSeg/FastmarchingFuzzyWidget.cpp +++ b/iSeg/FastmarchingFuzzyWidget.cpp @@ -295,7 +295,7 @@ void FastmarchingFuzzyWidget::getrange() void FastmarchingFuzzyWidget::on_mouse_clicked(Point p) { - if (rb_fastmarch->isOn()) + if (rb_fastmarch->isChecked()) { if (IFTmarch != nullptr) delete IFTmarch; @@ -324,7 +324,7 @@ void FastmarchingFuzzyWidget::on_mouse_clicked(Point p) map = IFTfuzzy->return_pf(); } - if (rb_slider->isOn()) + if (rb_slider->isChecked()) { getrange(); if (extend > extendmax) @@ -346,7 +346,7 @@ void FastmarchingFuzzyWidget::on_mouse_clicked(Point p) void FastmarchingFuzzyWidget::on_mouse_released(Point p) { - if (rb_drag->isOn()) + if (rb_drag->isChecked()) { vpdyn_arg.clear(); emit vpdyn_changed(&vpdyn_arg); @@ -368,7 +368,7 @@ void FastmarchingFuzzyWidget::on_mouse_released(Point p) void FastmarchingFuzzyWidget::on_mouse_moved(Point p) { - if (rb_drag->isOn()) + if (rb_drag->isChecked()) { vpdyn_arg.clear(); unsigned short width = bmphand->return_width(); @@ -497,7 +497,7 @@ void FastmarchingFuzzyWidget::execute() void FastmarchingFuzzyWidget::slextend_changed(int val) { extend = val * 0.005f * extendmax; - if (rb_slider->isOn()) + if (rb_slider->isChecked()) execute(); return; @@ -512,7 +512,7 @@ void FastmarchingFuzzyWidget::bmp_changed() void FastmarchingFuzzyWidget::method_changed() { - if (rb_fastmarch->isOn()) + if (rb_fastmarch->isChecked()) { if (hideparams) { @@ -539,7 +539,7 @@ void FastmarchingFuzzyWidget::method_changed() void FastmarchingFuzzyWidget::interact_changed() { - if (rb_drag->isOn()) + if (rb_drag->isChecked()) { if (hideparams) hbox7->hide(); @@ -616,7 +616,7 @@ void FastmarchingFuzzyWidget::slider_changed() s1 = sl_s1->value() * 0.01f * sb_s1->value(); s2 = sl_s2->value() * 0.01f * sb_s2->value(); - if (rb_fastmarch->isOn() && IFTmarch != nullptr) + if (rb_fastmarch->isChecked() && IFTmarch != nullptr) { delete IFTmarch; IFTmarch = nullptr; @@ -662,13 +662,13 @@ FILE* FastmarchingFuzzyWidget::SaveParams(FILE* fp, int version) fwrite(&(dummy), 1, sizeof(int), fp); dummy = sb_s2->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_fastmarch->isOn()); + dummy = (int)(rb_fastmarch->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_fuzzy->isOn()); + dummy = (int)(rb_fuzzy->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_drag->isOn()); + dummy = (int)(rb_drag->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_slider->isOn()); + dummy = (int)(rb_slider->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); fwrite(&sigma, 1, sizeof(float), fp); diff --git a/iSeg/HystereticGrowingWidget.cpp b/iSeg/HystereticGrowingWidget.cpp index a3ec3604..275c1f8e 100755 --- a/iSeg/HystereticGrowingWidget.cpp +++ b/iSeg/HystereticGrowingWidget.cpp @@ -62,7 +62,7 @@ HystereticGrowingWidget::HystereticGrowingWidget(SlicesHandler* hand3D, QWidget* vbox2 = new Q3VBox(hbox1); vbox3 = new Q3VBox(hbox1); autoseed = new QCheckBox("AutoSeed: ", hbox2); - if (autoseed->isOn()) + if (autoseed->isChecked()) autoseed->toggle(); vbox4 = new Q3VBox(hbox2); vbox5 = new Q3VBox(hbox2); @@ -187,7 +187,7 @@ void HystereticGrowingWidget::on_mouse_clicked(Point p) } else { - if (!autoseed->isOn()) + if (!autoseed->isChecked()) { p1 = p; execute(); @@ -197,7 +197,7 @@ void HystereticGrowingWidget::on_mouse_clicked(Point p) void HystereticGrowingWidget::update_visible() { - if (autoseed->isOn()) + if (autoseed->isChecked()) { vbox4->show(); vbox5->show(); @@ -221,7 +221,7 @@ void HystereticGrowingWidget::auto_toggled() { update_visible(); - if (autoseed->isOn()) + if (autoseed->isChecked()) { execute(); } @@ -244,7 +244,7 @@ void HystereticGrowingWidget::execute() void HystereticGrowingWidget::execute1() { - if (autoseed->isOn()) + if (autoseed->isChecked()) { float ll = lower_limit + (upper_limit - lower_limit) * 0.005f * sl_lower->value(); @@ -765,9 +765,9 @@ FILE* HystereticGrowingWidget::SaveParams(FILE* fp, int version) fwrite(&(dummy), 1, sizeof(int), fp); dummy = sl_upperhyster->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(autoseed->isOn()); + dummy = (int)(autoseed->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(allslices->isOn()); + dummy = (int)(allslices->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); fwrite(&upper_limit, 1, sizeof(float), fp); diff --git a/iSeg/ImageForestingTransformRegionGrowingWidget.cpp b/iSeg/ImageForestingTransformRegionGrowingWidget.cpp index 0522e010..df768edf 100755 --- a/iSeg/ImageForestingTransformRegionGrowingWidget.cpp +++ b/iSeg/ImageForestingTransformRegionGrowingWidget.cpp @@ -189,7 +189,7 @@ void ImageForestingTransformRegionGrowingWidget::on_tissuenr_changed(int i) void ImageForestingTransformRegionGrowingWidget::on_mouse_clicked(Point p) { last_pt = p; - if (pushremove->isOn()) + if (pushremove->isChecked()) { removemarks(p); } @@ -197,7 +197,7 @@ void ImageForestingTransformRegionGrowingWidget::on_mouse_clicked(Point p) void ImageForestingTransformRegionGrowingWidget::on_mouse_moved(Point p) { - if (!pushremove->isOn()) + if (!pushremove->isChecked()) { addLine(&vmdyn, last_pt, p); last_pt = p; @@ -207,7 +207,7 @@ void ImageForestingTransformRegionGrowingWidget::on_mouse_moved(Point p) void ImageForestingTransformRegionGrowingWidget::on_mouse_released(Point p) { - if (!pushremove->isOn()) + if (!pushremove->isChecked()) { addLine(&vmdyn, last_pt, p); Mark m; @@ -241,7 +241,7 @@ void ImageForestingTransformRegionGrowingWidget::on_mouse_released(Point p) } else { - pushremove->setOn(false); + pushremove->setChecked(false); } } diff --git a/iSeg/InterpolationWidget.cpp b/iSeg/InterpolationWidget.cpp index 2ce53481..6b3f7fad 100755 --- a/iSeg/InterpolationWidget.cpp +++ b/iSeg/InterpolationWidget.cpp @@ -236,7 +236,7 @@ void InterpolationWidget::startslice_pressed() void InterpolationWidget::on_mouse_clicked(Point p) { - if (rb_work->isOn() || rb_tissue->isOn()) + if (rb_work->isChecked() || rb_tissue->isChecked()) { brush->set_tissue_value(tissuenr); brush->on_mouse_clicked(p); @@ -249,7 +249,7 @@ void InterpolationWidget::on_mouse_clicked(Point p) void InterpolationWidget::on_mouse_released(Point p) { - if (rb_work->isOn() || rb_tissue->isOn()) + if (rb_work->isChecked() || rb_tissue->isChecked()) { brush->on_mouse_released(p); } @@ -261,7 +261,7 @@ void InterpolationWidget::on_mouse_released(Point p) void InterpolationWidget::on_mouse_moved(Point p) { - if (rb_work->isOn() || rb_tissue->isOn()) + if (rb_work->isChecked() || rb_tissue->isChecked()) { brush->on_mouse_moved(p); } @@ -280,12 +280,12 @@ void InterpolationWidget::execute() if (current != startnr) { iseg::DataSelection dataSelection; - if (rb_extra->isOn()) + if (rb_extra->isChecked()) { dataSelection.sliceNr = (unsigned short)sb_slicenr->value() - 1; dataSelection.work = true; emit begin_datachange(dataSelection, this); - if (rb_work->isOn()) + if (rb_work->isChecked()) { handler3D->extrapolatework(startnr, current, (unsigned short)sb_slicenr->value() - 1); } @@ -295,43 +295,43 @@ void InterpolationWidget::execute() } emit end_datachange(this); } - else if (rb_inter->isOn()) + else if (rb_inter->isChecked()) { dataSelection.allSlices = true; - if (rb_work->isOn()) + if (rb_work->isChecked()) { dataSelection.work = true; emit begin_datachange(dataSelection, this); if (cb_medianset->isChecked()) { - handler3D->interpolateworkgrey_medianset(startnr, current, rb_8connectivity->isOn()); + handler3D->interpolateworkgrey_medianset(startnr, current, rb_8connectivity->isChecked()); } else { handler3D->interpolateworkgrey(startnr, current, connected); } } - else if (rb_tissue->isOn()) + else if (rb_tissue->isChecked()) { dataSelection.work = true; emit begin_datachange(dataSelection, this); if (cb_medianset->isChecked()) { - handler3D->interpolatetissue_medianset(startnr, current, tissuenr, rb_8connectivity->isOn()); + handler3D->interpolatetissue_medianset(startnr, current, tissuenr, rb_8connectivity->isChecked()); } else { handler3D->interpolatetissue(startnr, current, tissuenr, connected); } } - else if (rb_tissueall->isOn()) + else if (rb_tissueall->isChecked()) { dataSelection.tissues = true; emit begin_datachange(dataSelection, this); if (cb_medianset->isChecked()) { - handler3D->interpolatetissuegrey_medianset(startnr, current, rb_8connectivity->isOn()); + handler3D->interpolatetissuegrey_medianset(startnr, current, rb_8connectivity->isChecked()); } else { @@ -340,11 +340,11 @@ void InterpolationWidget::execute() } emit end_datachange(this); } - else if (rb_batchinter->isOn()) + else if (rb_batchinter->isChecked()) { dataSelection.allSlices = true; - if (rb_work->isOn()) + if (rb_work->isChecked()) { dataSelection.work = true; emit begin_datachange(dataSelection, this); @@ -356,12 +356,12 @@ void InterpolationWidget::execute() batchstart <= current - batchstride; batchstart += batchstride) { - handler3D->interpolateworkgrey_medianset(batchstart, batchstart + batchstride, rb_8connectivity->isOn()); + handler3D->interpolateworkgrey_medianset(batchstart, batchstart + batchstride, rb_8connectivity->isChecked()); } // Last batch with smaller stride if (batchstart > current && current - (batchstart - batchstride) >= 2) { - handler3D->interpolateworkgrey_medianset(batchstart - batchstride, current, rb_8connectivity->isOn()); + handler3D->interpolateworkgrey_medianset(batchstart - batchstride, current, rb_8connectivity->isChecked()); } } else @@ -380,7 +380,7 @@ void InterpolationWidget::execute() } } } - else if (rb_tissue->isOn()) + else if (rb_tissue->isChecked()) { dataSelection.work = true; emit begin_datachange(dataSelection, this); @@ -392,12 +392,12 @@ void InterpolationWidget::execute() batchstart <= current - batchstride; batchstart += batchstride) { - handler3D->interpolatetissue_medianset(batchstart, batchstart + batchstride, tissuenr, rb_8connectivity->isOn()); + handler3D->interpolatetissue_medianset(batchstart, batchstart + batchstride, tissuenr, rb_8connectivity->isChecked()); } // Last batch with smaller stride if (batchstart > current && current - (batchstart - batchstride) >= 2) { - handler3D->interpolatetissue_medianset(batchstart - batchstride, current, tissuenr, rb_8connectivity->isOn()); + handler3D->interpolatetissue_medianset(batchstart - batchstride, current, tissuenr, rb_8connectivity->isChecked()); } } else @@ -416,7 +416,7 @@ void InterpolationWidget::execute() } } } - else if (rb_tissueall->isOn()) + else if (rb_tissueall->isChecked()) { dataSelection.tissues = true; emit begin_datachange(dataSelection, this); @@ -429,13 +429,13 @@ void InterpolationWidget::execute() batchstart += batchstride) { handler3D->interpolatetissuegrey_medianset(batchstart, batchstart + batchstride, - rb_8connectivity->isOn()); + rb_8connectivity->isChecked()); } // Last batch with smaller stride if (batchstart > current && current - (batchstart - batchstride) >= 2) { - handler3D->interpolatetissuegrey_medianset(batchstart - batchstride, current, rb_8connectivity->isOn()); + handler3D->interpolatetissuegrey_medianset(batchstart - batchstride, current, rb_8connectivity->isChecked()); } } else @@ -465,14 +465,14 @@ void InterpolationWidget::brush_changed() { if (brush) { - brush->set_brush_target(rb_work->isOn()); + brush->set_brush_target(rb_work->isChecked()); brush->set_radius(brush_radius->text().toDouble()); } } void InterpolationWidget::method_changed() { - if (rb_extra->isOn()) + if (rb_extra->isChecked()) { hboxextra->show(); hboxbatch->hide(); @@ -486,7 +486,7 @@ void InterpolationWidget::method_changed() } rb_tissueall->setEnabled(false); } - else if (rb_inter->isOn()) + else if (rb_inter->isChecked()) { hboxextra->hide(); hboxbatch->hide(); @@ -500,12 +500,12 @@ void InterpolationWidget::method_changed() } else { - cb_connectedshapebased->setVisible(!rb_tissueall->isOn()); + cb_connectedshapebased->setVisible(!rb_tissueall->isChecked()); rb_4connectivity->hide(); rb_8connectivity->hide(); } } - else if (rb_batchinter->isOn()) + else if (rb_batchinter->isChecked()) { hboxextra->hide(); hboxbatch->show(); @@ -530,7 +530,7 @@ void InterpolationWidget::source_changed() if (brush) { - brush->set_brush_target(rb_work->isOn()); + brush->set_brush_target(rb_work->isChecked()); } } @@ -541,27 +541,27 @@ FILE* InterpolationWidget::SaveParams(FILE* fp, int version) int dummy; dummy = sb_slicenr->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_tissue->isOn()); + dummy = (int)(rb_tissue->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_work->isOn()); + dummy = (int)(rb_work->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_inter->isOn()); + dummy = (int)(rb_inter->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_extra->isOn()); + dummy = (int)(rb_extra->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); if (version >= 11) { - dummy = (int)(rb_tissueall->isOn()); + dummy = (int)(rb_tissueall->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_batchinter->isOn()); + dummy = (int)(rb_batchinter->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); if (version >= 12) { dummy = (int)(cb_medianset->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_4connectivity->isOn()); + dummy = (int)(rb_4connectivity->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_8connectivity->isOn()); + dummy = (int)(rb_8connectivity->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); } } diff --git a/iSeg/LivewireWidget.cpp b/iSeg/LivewireWidget.cpp index 1b36020e..c91f82a7 100755 --- a/iSeg/LivewireWidget.cpp +++ b/iSeg/LivewireWidget.cpp @@ -141,7 +141,7 @@ void LivewireWidget::on_mouse_clicked(Point p) { if (!drawing) { - if (autotrace->isOn()) + if (autotrace->isChecked()) { if (lw == nullptr) { @@ -170,7 +170,7 @@ void LivewireWidget::on_mouse_clicked(Point p) } else { - if (straight->isOn()) + if (straight->isChecked()) { addLine(&established, p1, p); dynamic.clear(); @@ -203,15 +203,15 @@ void LivewireWidget::on_mouse_clicked(Point p) void LivewireWidget::pt_doubleclicked(Point p) { - if (drawing && !freedraw->isOn()) + if (drawing && !freedraw->isChecked()) { clicks.push_back(p); - if (straight->isOn()) + if (straight->isChecked()) { addLine(&established, p1, p); addLine(&established, p2, p); } - else if (autotrace->isOn()) + else if (autotrace->isChecked()) { lw->return_path(p, &dynamic); established.insert(established.end(), dynamic.begin(), @@ -257,7 +257,7 @@ void LivewireWidget::pt_midclicked(Point p) } else { - if (straight->isOn()) + if (straight->isChecked()) { established.clear(); dynamic.clear(); @@ -278,7 +278,7 @@ void LivewireWidget::pt_midclicked(Point p) addLine(&dynamic, p2, p); emit vp1dyn_changed(&established, &dynamic); } - else if (autotrace->isOn()) + else if (autotrace->isChecked()) { dynamic.clear(); clicks.pop_back(); @@ -335,7 +335,7 @@ void LivewireWidget::pt_doubleclickedmid(Point p) void LivewireWidget::on_mouse_released(Point p) { - if (freedraw->isOn() && drawing) + if (freedraw->isChecked() && drawing) { clicks.push_back(p); addLine(&dynamic, p1, p); @@ -366,7 +366,7 @@ void LivewireWidget::on_mouse_moved(Point p) { if (drawing) { - if (freedraw->isOn()) + if (freedraw->isChecked()) { dynamic1.clear(); addLine(&dynamic, p1, p); @@ -376,7 +376,7 @@ void LivewireWidget::on_mouse_moved(Point p) p1 = p; clicks.push_back(p); } - else if (straight->isOn()) + else if (straight->isChecked()) { dynamic.clear(); addLine(&dynamic, p1, p); @@ -612,7 +612,7 @@ void LivewireWidget::bmphand_changed(bmphandler* bmph) void LivewireWidget::mode_changed() { - if (autotrace->isOn()) + if (autotrace->isChecked()) { hbox2->show(); } @@ -621,7 +621,7 @@ void LivewireWidget::mode_changed() hbox2->hide(); } - if (freedraw->isOn()) + if (freedraw->isChecked()) { hbox3->hide(); } @@ -662,15 +662,15 @@ FILE* LivewireWidget::SaveParams(FILE* fp, int version) int dummy; dummy = sb_freezing->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)autotrace->isOn(); + dummy = (int)autotrace->isChecked(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)straight->isOn(); + dummy = (int)straight->isChecked(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)freedraw->isOn(); + dummy = (int)freedraw->isChecked(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(cb_freezing->isOn()); + dummy = (int)(cb_freezing->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(cb_closing->isOn()); + dummy = (int)(cb_closing->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); } diff --git a/iSeg/LoaderWidgets.cpp b/iSeg/LoaderWidgets.cpp index 11a41e9c..b12aa668 100755 --- a/iSeg/LoaderWidgets.cpp +++ b/iSeg/LoaderWidgets.cpp @@ -178,7 +178,7 @@ LoaderDicom::~LoaderDicom() void LoaderDicom::subsect_toggled() { - if (cb_subsect->isOn()) + if (cb_subsect->isChecked()) { hbox2->show(); } @@ -192,7 +192,7 @@ void LoaderDicom::subsect_toggled() void LoaderDicom::ct_toggled() { - if (cb_ct->isOn()) + if (cb_ct->isChecked()) { vbox6->show(); } @@ -226,7 +226,7 @@ void LoaderDicom::load_pushed() vnames.push_back((*it).ascii()); } - if (cb_subsect->isOn()) + if (cb_subsect->isChecked()) { Point p; p.px = xoffset->value(); @@ -245,23 +245,23 @@ void LoaderDicom::load_pushed() handler3D->LoadDICOM(vnames); } - if (cb_ct->isOn()) + if (cb_ct->isChecked()) { Pair p; - if (rb_muscle->isOn()) + if (rb_muscle->isChecked()) { // handler3D->get_range(&p); p.high = 1190; p.low = 890; } - else if (rb_bone->isOn()) + else if (rb_bone->isChecked()) { handler3D->get_range(&p); // p.high=; // p.low=; } handler3D->scale_colors(p); - if (cb_crop->isOn()) + if (cb_crop->isChecked()) { handler3D->crop_colors(); } @@ -397,7 +397,7 @@ QString LoaderRaw::GetFileName() { return nameEdit->text(); } void LoaderRaw::subsect_toggled() { - bool isset = subsect->isOn(); + bool isset = subsect->isChecked(); ; if (isset) { @@ -418,14 +418,14 @@ void LoaderRaw::subsect_toggled() void LoaderRaw::load_pushed() { unsigned bitdepth; - if (bit8->isOn()) + if (bit8->isChecked()) bitdepth = 8; else bitdepth = 16; if (!(nameEdit->text()).isEmpty()) { - if (subsect->isOn()) + if (subsect->isChecked()) { Point p; p.px = xoffset->value(); @@ -561,8 +561,8 @@ SaverImg::~SaverImg() void SaverImg::type_changed(int) { - if (typevti->isOn() || typevtk->isOn() || typemat->isOn() || - typenii->isOn()) + if (typevti->isChecked() || typevtk->isChecked() || typemat->isChecked() || + typenii->isChecked()) { all1->setChecked(TRUE); vbox5->setEnabled(false); @@ -580,11 +580,11 @@ void SaverImg::save_pushed() { boost::filesystem::path file_path(nameEdit->text().ascii()); - if (typebmp->isOn()) + if (typebmp->isChecked()) { - if (pictbmp->isOn()) + if (pictbmp->isChecked()) { - if (all1->isOn()) + if (all1->isChecked()) { res = handler3D->SaveBmpBitmap(nameEdit->text().ascii()); } @@ -597,9 +597,9 @@ void SaverImg::save_pushed() s.ascii()) == 0); } } - else if (pictwork->isOn()) + else if (pictwork->isChecked()) { - if (all1->isOn()) + if (all1->isChecked()) { res = handler3D->SaveWorkBitmap(nameEdit->text().ascii()); } @@ -613,9 +613,9 @@ void SaverImg::save_pushed() s.ascii()) == 0); } } - else if (picttissue->isOn()) + else if (picttissue->isChecked()) { - if (all1->isOn()) + if (all1->isChecked()) { res = handler3D->SaveTissueBitmap(nameEdit->text().ascii()); } @@ -631,48 +631,48 @@ void SaverImg::save_pushed() } } } - else if (typevtk->isOn() || typevti->isOn() || typenii->isOn()) + else if (typevtk->isChecked() || typevti->isChecked() || typenii->isChecked()) { if (!file_path.has_extension()) { - file_path.append(typevtk->isOn() + file_path.append(typevtk->isChecked() ? ".vtk" - : (typevti->isOn() ? ".vti" : ".nii")); + : (typevti->isChecked() ? ".vti" : ".nii")); } bool binary = true; - if (pictbmp->isOn()) + if (pictbmp->isChecked()) { res = handler3D->export_bmp(file_path.string().c_str(), binary); } - else if (picttissue->isOn()) + else if (picttissue->isChecked()) { res = handler3D->export_tissue(file_path.string().c_str(), binary); } - else if (pictwork->isOn()) + else if (pictwork->isChecked()) { res = handler3D->export_work(file_path.string().c_str(), binary); } } - else if (typemat->isOn()) + else if (typemat->isChecked()) { - if (pictbmp->isOn()) + if (pictbmp->isChecked()) { QString s = nameEdit->text(); if (s.length() > 4 && !s.endsWith(QString(".mat"))) s.append(".mat"); res = handler3D->print_bmpmat(s.ascii()); } - else if (pictwork->isOn()) + else if (pictwork->isChecked()) { QString s = nameEdit->text(); if (s.length() > 4 && !s.endsWith(QString(".mat"))) s.append(".mat"); res = handler3D->print_workmat(s.ascii()); } - else if (picttissue->isOn()) + else if (picttissue->isChecked()) { QString s = nameEdit->text(); if (s.length() > 4 && !s.endsWith(QString(".mat"))) @@ -680,11 +680,11 @@ void SaverImg::save_pushed() res = handler3D->print_tissuemat(s.ascii()); } } - else if (typeraw->isOn()) + else if (typeraw->isChecked()) { - if (pictbmp->isOn()) + if (pictbmp->isChecked()) { - if (all1->isOn()) + if (all1->isChecked()) { res = (handler3D->SaveBmpRaw(nameEdit->text().ascii()) == 0); @@ -695,9 +695,9 @@ void SaverImg::save_pushed() nameEdit->text().ascii()) == 0); } } - else if (pictwork->isOn()) + else if (pictwork->isChecked()) { - if (all1->isOn()) + if (all1->isChecked()) { res = (handler3D->SaveWorkRaw(nameEdit->text().ascii()) == 0); @@ -708,9 +708,9 @@ void SaverImg::save_pushed() nameEdit->text().ascii()) == 0); } } - else if (picttissue->isOn()) + else if (picttissue->isChecked()) { - if (all1->isOn()) + if (all1->isChecked()) { res = (handler3D->SaveTissueRaw(nameEdit->text().ascii()) == 0); @@ -852,7 +852,7 @@ ReloaderRaw::~ReloaderRaw() void ReloaderRaw::subsect_toggled() { - bool isset = subsect->isOn(); + bool isset = subsect->isChecked(); ; if (isset) { @@ -873,14 +873,14 @@ void ReloaderRaw::subsect_toggled() void ReloaderRaw::load_pushed() { unsigned bitdepth; - if (bit8->isOn()) + if (bit8->isChecked()) bitdepth = 8; else bitdepth = 16; if (!(nameEdit->text()).isEmpty()) { - if (subsect->isOn()) + if (subsect->isChecked()) { Point p; p.px = xoffset->value(); @@ -1161,7 +1161,7 @@ void LoaderColorImages::load_mixer() handler3D->set_rgb_factors(33, 33, 33); } - if (subsect->isOn()) + if (subsect->isChecked()) { Point p; p.px = xoffset->value(); @@ -1780,7 +1780,7 @@ ReloaderBmp2::~ReloaderBmp2() { delete vbox1; } void ReloaderBmp2::subsect_toggled() { - bool isset = subsect->isOn(); + bool isset = subsect->isChecked(); ; if (isset) { @@ -1802,7 +1802,7 @@ void ReloaderBmp2::subsect_toggled() void ReloaderBmp2::load_pushed() { - if (subsect->isOn()) + if (subsect->isChecked()) { Point p; p.px = xoffset->value(); diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index 330065aa..1e538a7b 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -1259,35 +1259,35 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, hidecontrastbright = new QAction("Contr./Bright.", this); hidecontrastbright->setToggleAction(true); - hidecontrastbright->setOn(true); + hidecontrastbright->setChecked(true); connect(hidecontrastbright, SIGNAL(toggled(bool)), this, SLOT(execute_hidecontrastbright(bool))); hidecontrastbright->addTo(hidemenu); hidesource = new QAction("Source", this); hidesource->setToggleAction(true); - hidesource->setOn(true); + hidesource->setChecked(true); connect(hidesource, SIGNAL(toggled(bool)), this, SLOT(execute_hidesource(bool))); hidesource->addTo(hidemenu); hidetarget = new QAction("Target", this); hidetarget->setToggleAction(true); - hidetarget->setOn(true); + hidetarget->setChecked(true); connect(hidetarget, SIGNAL(toggled(bool)), this, SLOT(execute_hidetarget(bool))); hidetarget->addTo(hidemenu); hidecopyswap = new QAction("Copy/Swap", this); hidecopyswap->setToggleAction(true); - hidecopyswap->setOn(true); + hidecopyswap->setChecked(true); connect(hidecopyswap, SIGNAL(toggled(bool)), this, SLOT(execute_hidecopyswap(bool))); hidecopyswap->addTo(hidemenu); for (unsigned short i = 0; i < nrtabbuttons; i++) { showtab_action[i] = new QAction(tabwidgets[i]->GetName().c_str(), this); showtab_action[i]->setToggleAction(true); - showtab_action[i]->setOn(showpb_tab[i]); + showtab_action[i]->setChecked(showpb_tab[i]); connect(showtab_action[i], SIGNAL(toggled(bool)), this, SLOT(execute_showtabtoggled(bool))); showtab_action[i]->addTo(hidesubmenu); } hideparameters = new QAction("Simplified", this); hideparameters->setToggleAction(true); - hideparameters->setOn(WidgetInterface::get_hideparams()); + hideparameters->setChecked(WidgetInterface::get_hideparams()); connect(hideparameters, SIGNAL(toggled(bool)), this, SLOT(execute_hideparameters(bool))); hidesubmenu->insertSeparator(); hideparameters->addTo(hidesubmenu); @@ -3176,22 +3176,22 @@ void MainWindow::SaveSettings() bool flag; flag = WidgetInterface::get_hideparams(); fwrite(&flag, 1, sizeof(bool), fp); - // flag=!hidestack->isOn(); + // flag=!hidestack->isChecked(); flag = false; fwrite(&flag, 1, sizeof(bool), fp); - // flag=!hidenotes->isOn(); + // flag=!hidenotes->isChecked(); flag = false; fwrite(&flag, 1, sizeof(bool), fp); - // flag=!hidezoom->isOn(); + // flag=!hidezoom->isChecked(); flag = false; fwrite(&flag, 1, sizeof(bool), fp); - flag = !hidecontrastbright->isOn(); + flag = !hidecontrastbright->isChecked(); fwrite(&flag, 1, sizeof(bool), fp); - flag = !hidecopyswap->isOn(); + flag = !hidecopyswap->isChecked(); fwrite(&flag, 1, sizeof(bool), fp); for (unsigned short i = 0; i < 16; i++) { - flag = (i < showtab_action.size()) ? showtab_action[i]->isOn() : true; + flag = (i < showtab_action.size()) ? showtab_action[i]->isChecked() : true; fwrite(&flag, 1, sizeof(bool), fp); } fp = TissueInfos::SaveTissues(fp, saveProjVersion); @@ -3258,7 +3258,7 @@ void MainWindow::LoadSettings(const char* loadfilename) bool flag; fread(&flag, sizeof(bool), 1, fp); execute_hideparameters(flag); - hideparameters->setOn(flag); + hideparameters->setChecked(flag); fread(&flag, sizeof(bool), 1, fp); if (loadProjVersion >= 7) @@ -3272,18 +3272,18 @@ void MainWindow::LoadSettings(const char* loadfilename) fread(&flag, sizeof(bool), 1, fp); fread(&flag, sizeof(bool), 1, fp); - hidecontrastbright->setOn(!flag); + hidecontrastbright->setChecked(!flag); execute_hidecontrastbright(!flag); fread(&flag, sizeof(bool), 1, fp); - hidecopyswap->setOn(!flag); + hidecopyswap->setChecked(!flag); execute_hidecopyswap(!flag); // turn visibility on for all auto nrtabbuttons = (unsigned short)tabwidgets.size(); for (int i = 0; i < nrtabbuttons; i++) { - showtab_action[i]->setOn(true); + showtab_action[i]->setChecked(true); } // load visibility settings from file @@ -3291,19 +3291,19 @@ void MainWindow::LoadSettings(const char* loadfilename) { fread(&flag, sizeof(bool), 1, fp); if (i < nrtabbuttons) - showtab_action.at(i)->setOn(flag); + showtab_action.at(i)->setChecked(flag); } if (loadProjVersion >= 6) { fread(&flag, sizeof(bool), 1, fp); if (14 < nrtabbuttons) - showtab_action.at(14)->setOn(flag); + showtab_action.at(14)->setChecked(flag); } if (loadProjVersion >= 9) { fread(&flag, sizeof(bool), 1, fp); if (15 < nrtabbuttons) - showtab_action.at(15)->setOn(flag); + showtab_action.at(15)->setChecked(flag); } execute_showtabtoggled(flag); @@ -4927,7 +4927,7 @@ void MainWindow::execute_showtabtoggled(bool) auto nrtabbuttons = (unsigned short)tabwidgets.size(); for (unsigned short i = 0; i < nrtabbuttons; i++) { - showpb_tab[i] = showtab_action[i]->isOn(); + showpb_tab[i] = showtab_action[i]->isChecked(); } WidgetInterface* currentwidget = static_cast(methodTab->currentWidget()); @@ -4973,8 +4973,8 @@ void MainWindow::execute_xslice() xsliceshower->xyexists_changed(true); ysliceshower->xyexists_changed(true); } - bmp_show->set_crosshairyvisible(cb_bmpcrosshairvisible->isOn()); - work_show->set_crosshairyvisible(cb_workcrosshairvisible->isOn()); + bmp_show->set_crosshairyvisible(cb_bmpcrosshairvisible->isChecked()); + work_show->set_crosshairyvisible(cb_workcrosshairvisible->isChecked()); xshower_slicechanged(); float offset1, factor1; bmp_show->get_scaleoffsetfactor(offset1, factor1); @@ -5021,8 +5021,8 @@ void MainWindow::execute_yslice() ysliceshower->xyexists_changed(true); xsliceshower->xyexists_changed(true); } - bmp_show->set_crosshairxvisible(cb_bmpcrosshairvisible->isOn()); - work_show->set_crosshairxvisible(cb_workcrosshairvisible->isOn()); + bmp_show->set_crosshairxvisible(cb_bmpcrosshairvisible->isChecked()); + work_show->set_crosshairxvisible(cb_workcrosshairvisible->isChecked()); yshower_slicechanged(); float offset1, factor1; bmp_show->get_scaleoffsetfactor(offset1, factor1); @@ -5300,7 +5300,7 @@ void MainWindow::add_tissue_clicked(Point p) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(add_tissue_clicked(Point))); - pb_add->setOn(false); + pb_add->setChecked(false); QObject::connect(work_show, SIGNAL(mousereleased_sign(Point)), this, SLOT(reconnectmouse_afterrelease(Point))); addhold_tissue_clicked(p); @@ -5342,7 +5342,7 @@ void MainWindow::subtract_tissue_clicked(Point p) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtract_tissue_clicked(Point))); - pb_sub->setOn(false); + pb_sub->setChecked(false); QObject::connect(work_show, SIGNAL(mousereleased_sign(Point)), this, SLOT(reconnectmouse_afterrelease(Point))); subtracthold_tissue_clicked(p); @@ -5377,26 +5377,26 @@ void MainWindow::subtracthold_tissue_clicked(Point p) void MainWindow::add_tissue_pushed() { - if (pb_sub->isOn()) + if (pb_sub->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtract_tissue_clicked(Point))); - pb_sub->setOn(false); + pb_sub->setChecked(false); } - if (pb_subhold->isOn()) + if (pb_subhold->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtracthold_tissue_clicked(Point))); - pb_subhold->setOn(false); + pb_subhold->setChecked(false); } - if (pb_addhold->isOn()) + if (pb_addhold->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(addhold_tissue_clicked(Point))); - pb_addhold->setOn(false); + pb_addhold->setChecked(false); } - if (pb_add->isOn()) + if (pb_add->isChecked()) { QObject::connect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(add_tissue_clicked(Point))); @@ -5428,26 +5428,26 @@ void MainWindow::addhold_tissue_pushed() QObject::disconnect(work_show,SIGNAL(mousepressed_sign(Point)),this,SLOT(add_tissue_connected_clicked(Point))); pb_addconn->setDown(false); }*/ - if (pb_sub->isOn()) + if (pb_sub->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtract_tissue_clicked(Point))); - pb_sub->setOn(false); + pb_sub->setChecked(false); } - if (pb_subhold->isOn()) + if (pb_subhold->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtracthold_tissue_clicked(Point))); - pb_subhold->setOn(false); + pb_subhold->setChecked(false); } - if (pb_add->isOn()) + if (pb_add->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(add_tissue_clicked(Point))); - pb_add->setOn(false); + pb_add->setChecked(false); } - if (pb_addhold->isOn()) + if (pb_addhold->isChecked()) { QObject::connect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(addhold_tissue_clicked(Point))); @@ -5488,13 +5488,13 @@ void MainWindow::addhold_tissue_pushed() void MainWindow::subtract_tissue_pushed() { - if (pb_add->isOn()) + if (pb_add->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(add_tissue_clicked(Point))); - pb_add->setOn(false); + pb_add->setChecked(false); } - if (pb_sub->isOn()) + if (pb_sub->isChecked()) { QObject::connect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtract_tissue_clicked(Point))); @@ -5506,19 +5506,19 @@ void MainWindow::subtract_tissue_pushed() SLOT(subtract_tissue_clicked(Point))); connect_mouseclick(); } - if (pb_subhold->isOn()) + if (pb_subhold->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtracthold_tissue_clicked(Point))); // pb_subhold->setDown(false); - pb_subhold->setOn(false); + pb_subhold->setChecked(false); } - if (pb_addhold->isOn()) + if (pb_addhold->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(addhold_tissue_clicked(Point))); - // pb_addhold->setOn(false); - pb_addhold->setOn(false); + // pb_addhold->setChecked(false); + pb_addhold->setChecked(false); } // pb_sub->setDown(!pb_sub->isDown()); /* if(pb_addconn->isDown()){ @@ -5533,13 +5533,13 @@ void MainWindow::subtract_tissue_pushed() void MainWindow::subtracthold_tissue_pushed() { - if (pb_add->isOn()) + if (pb_add->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(add_tissue_clicked(Point))); - pb_add->setOn(false); + pb_add->setChecked(false); } - if (pb_subhold->isOn()) + if (pb_subhold->isChecked()) { QObject::connect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtracthold_tissue_clicked(Point))); @@ -5551,17 +5551,17 @@ void MainWindow::subtracthold_tissue_pushed() SLOT(subtracthold_tissue_clicked(Point))); connect_mouseclick(); } - if (pb_sub->isOn()) + if (pb_sub->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtract_tissue_clicked(Point))); - pb_sub->setOn(false); + pb_sub->setChecked(false); } - if (pb_addhold->isOn()) + if (pb_addhold->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(addhold_tissue_clicked(Point))); - pb_addhold->setOn(false); + pb_addhold->setChecked(false); } // pb_subhold->setDown(!pb_subhold->isDown()); /* if(pb_addconn->isDown()){ @@ -5582,11 +5582,11 @@ void MainWindow::stophold_tissue_pushed() SLOT(add_tissue_clicked(Point))); pb_add->setDown(false); } - if (pb_subhold->isOn()) + if (pb_subhold->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(subtracthold_tissue_clicked(Point))); - pb_subhold->setOn(false); + pb_subhold->setChecked(false); } if (pb_sub->isDown()) { @@ -5594,11 +5594,11 @@ void MainWindow::stophold_tissue_pushed() SLOT(subtract_tissue_clicked(Point))); pb_sub->setDown(false); } - if (pb_addhold->isOn()) + if (pb_addhold->isChecked()) { QObject::disconnect(work_show, SIGNAL(mousepressed_sign(Point)), this, SLOT(addhold_tissue_clicked(Point))); - pb_addhold->setOn(false); + pb_addhold->setChecked(false); } } @@ -5772,7 +5772,7 @@ void MainWindow::newFolderPressed() void MainWindow::lockAllTissues() { - bool lockstate = lockTissues->isOn(); + bool lockstate = lockTissues->isChecked(); cb_tissuelock->setChecked(lockstate); TissueInfos::SetTissuesLocked(lockstate); tissueTreeWidget->update_folder_icons(); @@ -6570,7 +6570,7 @@ void MainWindow::tissuelock_toggled() tissueTreeWidget->update_folder_icons(); if (!cb_tissuelock->isChecked()) - lockTissues->setOn(false); + lockTissues->setChecked(false); } void MainWindow::execute_undo() @@ -7035,18 +7035,18 @@ void MainWindow::updateMethodButtonsPressed(WidgetInterface* qw) for (unsigned short i = 0; i < (counter + 1) / 2; i++, counter1++) { if (counter1 == pos) - pb_tab[i]->setOn(true); + pb_tab[i]->setChecked(true); else - pb_tab[i]->setOn(false); + pb_tab[i]->setChecked(false); } for (unsigned short i = (nrtabbuttons + 1) / 2; counter1 < counter; i++, counter1++) { if (counter1 == pos) - pb_tab[i]->setOn(true); + pb_tab[i]->setChecked(true); else - pb_tab[i]->setOn(false); + pb_tab[i]->setChecked(false); } } @@ -7226,7 +7226,7 @@ void MainWindow::pb_tab_pressed(int nr) unsigned short tabnr = nr + 1; for (unsigned short tabnr1 = 0; tabnr1 < pb_tab.size(); tabnr1++) { - pb_tab[tabnr1]->setOn(tabnr == tabnr1 + 1); + pb_tab[tabnr1]->setChecked(tabnr == tabnr1 + 1); } unsigned short pos1 = 0; for (unsigned short i = 0; i < nrtabbuttons; i++) diff --git a/iSeg/MeasurementWidget.cpp b/iSeg/MeasurementWidget.cpp index 47a7cece..5a693cff 100755 --- a/iSeg/MeasurementWidget.cpp +++ b/iSeg/MeasurementWidget.cpp @@ -155,19 +155,19 @@ FILE* MeasurementWidget::SaveParams(FILE* fp, int version) if (version >= 4) { int dummy; - dummy = (int)(rb_vector->isOn()); + dummy = (int)(rb_vector->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_dist->isOn()); + dummy = (int)(rb_dist->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_angle->isOn()); + dummy = (int)(rb_angle->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_4ptangle->isOn()); + dummy = (int)(rb_4ptangle->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_vol->isOn()); + dummy = (int)(rb_vol->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_pts->isOn()); + dummy = (int)(rb_pts->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_lbls->isOn()); + dummy = (int)(rb_lbls->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); } @@ -215,9 +215,9 @@ FILE* MeasurementWidget::LoadParams(FILE* fp, int version) void MeasurementWidget::on_mouse_clicked(Point p) { - if (rb_pts->isOn()) + if (rb_pts->isChecked()) { - if (rb_vector->isOn()) + if (rb_vector->isChecked()) { if (state == 0) { @@ -245,7 +245,7 @@ void MeasurementWidget::on_mouse_clicked(Point p) QString(") mm (Mark new start point.)")); } } - else if (rb_dist->isOn()) + else if (rb_dist->isChecked()) { if (state == 0) { @@ -270,7 +270,7 @@ void MeasurementWidget::on_mouse_clicked(Point p) QString(" mm (Mark new start point.)")); } } - else if (rb_thick->isOn()) + else if (rb_thick->isChecked()) { if (state == 0) { @@ -295,7 +295,7 @@ void MeasurementWidget::on_mouse_clicked(Point p) QString(" mm Mark new start point.)")); } } - else if (rb_angle->isOn()) + else if (rb_angle->isChecked()) { if (state == 0) { @@ -330,7 +330,7 @@ void MeasurementWidget::on_mouse_clicked(Point p) QString(" deg (Mark new first point.)")); } } - else if (rb_4ptangle->isOn()) + else if (rb_4ptangle->isChecked()) { if (state == 0) { @@ -377,7 +377,7 @@ void MeasurementWidget::on_mouse_clicked(Point p) QString(" deg (Mark new first point.)")); } } - else if (rb_vol->isOn()) + else if (rb_vol->isChecked()) { state = 0; established.clear(); @@ -407,9 +407,9 @@ void MeasurementWidget::on_mouse_clicked(Point p) QString(" mm^3") + note + QString("\n(Select new object.)")); } } - else if (rb_lbls->isOn()) + else if (rb_lbls->isChecked()) { - if (rb_vol->isOn()) + if (rb_vol->isChecked()) { state = 0; established.clear(); @@ -461,13 +461,13 @@ void MeasurementWidget::set_coord(unsigned short posit, Point p, void MeasurementWidget::cbb_changed(int) { - if (rb_lbls->isOn() && !rb_vol->isOn()) + if (rb_lbls->isChecked() && !rb_vol->isChecked()) { state = 0; drawing = false; dynamic.clear(); established.clear(); - if (rb_dist->isOn()) + if (rb_dist->isChecked()) { Point pc; pc.px = (short)handler3D->width() / 2; @@ -485,7 +485,7 @@ void MeasurementWidget::cbb_changed(int) txt_displayer->setText(QString::number(calculate(), 'g', 3) + QString(" mm")); } - else if (rb_thick->isOn()) + else if (rb_thick->isChecked()) { Point pc; pc.px = (short)handler3D->width() / 2; @@ -503,7 +503,7 @@ void MeasurementWidget::cbb_changed(int) txt_displayer->setText(QString::number(calculate(), 'g', 3) + QString(" mm")); } - else if (rb_vector->isOn()) + else if (rb_vector->isChecked()) { Point pc; pc.px = (short)handler3D->width() / 2; @@ -524,7 +524,7 @@ void MeasurementWidget::cbb_changed(int) QString(",") + QString::number(calculatevec(2), 'g', 3) + QString(") mm (Mark new start point.)")); } - else if (rb_angle->isOn()) + else if (rb_angle->isChecked()) { Point pc; pc.px = (short)handler3D->width() / 2; @@ -547,7 +547,7 @@ void MeasurementWidget::cbb_changed(int) txt_displayer->setText(QString::number(calculate(), 'g', 3) + QString(" deg")); } - else if (rb_4ptangle->isOn()) + else if (rb_4ptangle->isChecked()) { Point pc; pc.px = (short)handler3D->width() / 2; @@ -600,7 +600,7 @@ void MeasurementWidget::update_visualization() hbox2->show(); } - if (rb_pts->isOn()) + if (rb_pts->isChecked()) { state = 0; drawing = false; @@ -610,33 +610,33 @@ void MeasurementWidget::update_visualization() emit vp1dyn_changed(&established, &dynamic); hbox3->hide(); hbox4->hide(); - if (rb_dist->isOn() || rb_thick->isOn() || rb_vector->isOn()) + if (rb_dist->isChecked() || rb_thick->isChecked() || rb_vector->isChecked()) { txt_displayer->setText("Mark start point."); } - else if (rb_angle->isOn()) + else if (rb_angle->isChecked()) { txt_displayer->setText("Mark first point."); } - else if (rb_4ptangle->isOn()) + else if (rb_4ptangle->isChecked()) { txt_displayer->setText("Mark first point."); } - else if (rb_vol->isOn()) + else if (rb_vol->isChecked()) { hbox2->hide(); txt_displayer->setText("Select object."); } } - else if (rb_lbls->isOn()) + else if (rb_lbls->isChecked()) { - if (rb_dist->isOn() || rb_thick->isOn() || rb_vector->isOn()) + if (rb_dist->isChecked() || rb_thick->isChecked() || rb_vector->isChecked()) { hbox3->show(); hbox4->hide(); // txt_displayer->setText(QString::number(calculate(),'g',3)+QString(" mm")); } - else if (rb_angle->isOn()) + else if (rb_angle->isChecked()) { hbox3->show(); hbox4->show(); @@ -645,7 +645,7 @@ void MeasurementWidget::update_visualization() txt_ccb4->hide(); // txt_displayer->setText(QString::number(calculate(),'g',3)+QString(" deg")); } - else if (rb_4ptangle->isOn()) + else if (rb_4ptangle->isChecked()) { hbox3->show(); hbox4->show(); @@ -654,7 +654,7 @@ void MeasurementWidget::update_visualization() txt_ccb4->show(); // txt_displayer->setText(QString::number(calculate(),'g',3)+QString(" deg")); } - else if (rb_vol->isOn()) + else if (rb_vol->isChecked()) { hbox2->hide(); hbox3->hide(); @@ -715,7 +715,7 @@ float MeasurementWidget::calculate() Pair p1 = handler3D->get_pixelsize(); float value = 0; - if (rb_lbls->isOn()) + if (rb_lbls->isChecked()) { //float thick=handler3D->get_slicethickness(); //Pair p1=handler3D->get_pixelsize(); @@ -769,14 +769,14 @@ float MeasurementWidget::calculate() } } - if (rb_dist->isOn()) + if (rb_dist->isChecked()) { value = sqrt( (pt[0][0] - pt[1][0]) * (pt[0][0] - pt[1][0]) * p1.high * p1.high + (pt[0][1] - pt[1][1]) * (pt[0][1] - pt[1][1]) * p1.low * p1.low + (pt[0][2] - pt[1][2]) * (pt[0][2] - pt[1][2]) * thick * thick); } - else if (rb_thick->isOn()) + else if (rb_thick->isChecked()) { int xDist = abs(pt[0][0] - pt[1][0]); if (xDist != 0) @@ -793,7 +793,7 @@ float MeasurementWidget::calculate() (yDist) * (yDist)*p1.low * p1.low + (zDist) * (zDist)*thick * thick); } - else if (rb_angle->isOn()) + else if (rb_angle->isChecked()) { float l1square = (pt[0][0] - pt[1][0]) * (pt[0][0] - pt[1][0]) * p1.high * p1.high + @@ -813,7 +813,7 @@ float MeasurementWidget::calculate() sqrt(l1square * l2square)) * 180 / 3.141592f; } - else if (rb_4ptangle->isOn()) + else if (rb_4ptangle->isChecked()) { float d1[3]; float d2[3]; @@ -850,7 +850,7 @@ float MeasurementWidget::calculatevec(unsigned short orient) Pair p1 = handler3D->get_pixelsize(); float value = 0; - if (rb_lbls->isOn()) + if (rb_lbls->isChecked()) { //float thick=handler3D->get_slicethickness(); //Pair p1=handler3D->get_pixelsize(); diff --git a/iSeg/MorphologyWidget.cpp b/iSeg/MorphologyWidget.cpp index b8608d37..430b4db9 100755 --- a/iSeg/MorphologyWidget.cpp +++ b/iSeg/MorphologyWidget.cpp @@ -114,15 +114,15 @@ void MorphologyWidget::execute() dataSelection.allSlices = true; emit begin_datachange(dataSelection, this); - if (rb_open->isOn()) + if (rb_open->isChecked()) { handler3D->open(radius, connect8); } - else if (rb_close->isOn()) + else if (rb_close->isChecked()) { handler3D->closure(radius, connect8); } - else if (rb_erode->isOn()) + else if (rb_erode->isChecked()) { handler3D->erosion(radius, connect8); } @@ -138,15 +138,15 @@ void MorphologyWidget::execute() dataSelection.sliceNr = handler3D->active_slice(); emit begin_datachange(dataSelection, this); - if (rb_open->isOn()) + if (rb_open->isChecked()) { bmphand->open(radius, connect8); } - else if (rb_close->isOn()) + else if (rb_close->isChecked()) { bmphand->closure(radius, connect8); } - else if (rb_erode->isOn()) + else if (rb_erode->isChecked()) { bmphand->erosion(radius, connect8); } @@ -195,19 +195,19 @@ FILE* MorphologyWidget::SaveParams(FILE* fp, int version) int dummy; dummy = static_cast(radius); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(connect8); // rb_8connect->isOn()); + dummy = (int)(connect8); // rb_8connect->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(!connect8); // rb_4connect->isOn()); + dummy = (int)(!connect8); // rb_4connect->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_open->isOn()); + dummy = (int)(rb_open->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_close->isOn()); + dummy = (int)(rb_close->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_erode->isOn()); + dummy = (int)(rb_erode->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_dilate->isOn()); + dummy = (int)(rb_dilate->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(all_slices->isOn()); + dummy = (int)(all_slices->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); } diff --git a/iSeg/OutlineCorrectionParameterViews.cpp b/iSeg/OutlineCorrectionParameterViews.cpp index d966abc5..0a52d1c3 100755 --- a/iSeg/OutlineCorrectionParameterViews.cpp +++ b/iSeg/OutlineCorrectionParameterViews.cpp @@ -48,7 +48,7 @@ OLCorrParamView::OLCorrParamView(QWidget* parent /*= 0*/) : ParamViewBase(parent { _target = new QRadioButton(QString("Target")); _tissues = new QRadioButton(QString("Tissues")); - _target->setOn(true); + _target->setChecked(true); auto input_group = make_button_group(this, {_target, _tissues}); _select_object = new QPushButton(tr("Select")); @@ -77,7 +77,7 @@ BrushParamView::BrushParamView(QWidget* parent /*= 0*/) : ParamViewBase(parent) _target = new QRadioButton(QString("Target")); _tissues = new QRadioButton(QString("Tissues")); auto input_group = make_button_group(this, {_target, _tissues}); - _target->setOn(true); + _target->setChecked(true); _select_object = new QPushButton(tr("Select")); _select_object->setCheckable(true); @@ -88,13 +88,13 @@ BrushParamView::BrushParamView(QWidget* parent /*= 0*/) : ParamViewBase(parent) _draw = new QRadioButton(QString("Draw")); _erase = new QRadioButton(QString("Erase")); auto mode_group = make_button_group(this, {_modify, _draw, _erase}); - _modify->setOn(true); + _modify->setChecked(true); _radius = new QLineEdit(QString::number(1)); _unit_pixel = new QRadioButton(tr("Pixel")); _unit_mm = new QRadioButton(tr("Use spacing")); auto unit_group = make_button_group(this, {_unit_pixel, _unit_mm}); - _unit_pixel->setOn(true); + _unit_pixel->setChecked(true); _show_guide = new QCheckBox; _show_guide->setChecked(false); @@ -202,7 +202,7 @@ FillHolesParamView::FillHolesParamView(QWidget* parent /*= 0*/) : ParamViewBase( _target = new QRadioButton(QString("Target")); _tissues = new QRadioButton(QString("Tissues")); auto input_group = make_button_group(this, {_target, _tissues}); - _target->setOn(true); + _target->setChecked(true); _select_object = new QPushButton(tr("Select")); _select_object->setCheckable(true); @@ -240,19 +240,19 @@ AddSkinParamView::AddSkinParamView(QWidget* parent /*= 0*/) : ParamViewBase(pare _target = new QRadioButton(QString("Target")); _tissues = new QRadioButton(QString("Tissues")); auto input_group = make_button_group(this, {_target, _tissues}); - _target->setOn(true); + _target->setChecked(true); _thickness = new QLineEdit(QString::number(1)); _thickness->setValidator(new QIntValidator); _unit_pixel = new QRadioButton(tr("Pixel")); _unit_mm = new QRadioButton(tr("Use spacing")); auto unit_group = make_button_group(this, {_unit_pixel, _unit_mm}); - _unit_pixel->setOn(true); + _unit_pixel->setChecked(true); _inside = new QRadioButton(tr("Inside")); _outside = new QRadioButton(tr("Outside")); auto mode_group = make_button_group(this, {_inside, _outside}); - _inside->setOn(true); + _inside->setChecked(true); _execute = new QPushButton(tr("Execute")); @@ -294,7 +294,7 @@ FillSkinParamView::FillSkinParamView(SliceHandlerInterface* h, QWidget* parent / _unit_pixel = new QRadioButton(tr("Pixel")); _unit_mm = new QRadioButton(tr("Use spacing")); auto unit_group = make_button_group(this, {_unit_pixel, _unit_mm}); - _unit_pixel->setOn(true); + _unit_pixel->setChecked(true); _select_background = new QPushButton(tr("Get Selected")); _background_value = new QLineEdit; @@ -394,7 +394,7 @@ FillAllParamView::FillAllParamView(QWidget* parent /*= 0*/) : ParamViewBase(pare _target = new QRadioButton(QString("Target")); _tissues = new QRadioButton(QString("Tissues")); auto input_group = make_button_group(this, {_target, _tissues}); - _target->setOn(true); + _target->setChecked(true); _execute = new QPushButton(tr("Execute")); @@ -418,7 +418,7 @@ SmoothTissuesParamView::SmoothTissuesParamView(QWidget* parent /*= 0*/) : ParamV _all_slices = new QRadioButton(tr("All slices (2D)")); _3D = new QRadioButton(tr("Fully 3D")); auto where_group = make_button_group(this, {_active_slice, _all_slices, _3D}); - _active_slice->setOn(true); + _active_slice->setChecked(true); _sigma = new QLineEdit(QString::number(0.3)); _sigma->setValidator(new QDoubleValidator); diff --git a/iSeg/OutlineCorrectionParameterViews.h b/iSeg/OutlineCorrectionParameterViews.h index dfcb7c77..4e21f9ef 100755 --- a/iSeg/OutlineCorrectionParameterViews.h +++ b/iSeg/OutlineCorrectionParameterViews.h @@ -48,8 +48,8 @@ class OLCorrParamView : public ParamViewBase public: OLCorrParamView(QWidget* parent = 0); - bool work() const override { return _target->isOn(); } - void set_work(bool v) override { _target->setOn(v); } + bool work() const override { return _target->isChecked(); } + void set_work(bool v) override { _target->setChecked(v); } float object_value() const override { return _object_value->text().toFloat(); } void set_object_value(float v) override; @@ -67,8 +67,8 @@ class BrushParamView : public ParamViewBase public: BrushParamView(QWidget* parent = 0); - bool work() const override { return _target->isOn(); } - void set_work(bool v) override { _target->setOn(v); } + bool work() const override { return _target->isChecked(); } + void set_work(bool v) override { _target->setChecked(v); } float object_value() const override { return _object_value->text().toFloat(); } void set_object_value(float v) override; @@ -105,8 +105,8 @@ class FillHolesParamView : public ParamViewBase public: FillHolesParamView(QWidget* parent = 0); - bool work() const override { return _target->isOn(); } - void set_work(bool v) override { _target->setOn(v); } + bool work() const override { return _target->isChecked(); } + void set_work(bool v) override { _target->setChecked(v); } float object_value() const override { return _object_value->text().toFloat(); } void set_object_value(float v) override; @@ -132,8 +132,8 @@ class AddSkinParamView : public ParamViewBase public: AddSkinParamView(QWidget* parent = 0); - bool work() const override { return _target->isOn(); } - void set_work(bool v) override { _target->setOn(v); } + bool work() const override { return _target->isChecked(); } + void set_work(bool v) override { _target->setChecked(v); } // params QCheckBox* _all_slices; @@ -201,8 +201,8 @@ class FillAllParamView : public ParamViewBase public: FillAllParamView(QWidget* parent = 0); - bool work() const override { return _target->isOn(); } - void set_work(bool v) override { _target->setOn(v); } + bool work() const override { return _target->isChecked(); } + void set_work(bool v) override { _target->setChecked(v); } // params QCheckBox* _all_slices; diff --git a/iSeg/PickerWidget.cpp b/iSeg/PickerWidget.cpp index 15c3b5dd..5de4ad7e 100755 --- a/iSeg/PickerWidget.cpp +++ b/iSeg/PickerWidget.cpp @@ -153,13 +153,13 @@ FILE* PickerWidget::SaveParams(FILE* fp, int version) if (version >= 6) { int dummy; - dummy = (int)(rb_work->isOn()); + dummy = (int)(rb_work->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_tissue->isOn()); + dummy = (int)(rb_tissue->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_erase->isOn()); + dummy = (int)(rb_erase->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_fill->isOn()); + dummy = (int)(rb_fill->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); } @@ -202,7 +202,7 @@ void PickerWidget::on_mouse_clicked(Point p) } } bool addorsub = !(currentselection[p.px + (unsigned long)(p.py) * width]); - if (rb_work->isOn()) + if (rb_work->isChecked()) bmphand->change2mask_connectedwork(currentselection, p, addorsub); else bmphand->change2mask_connectedtissue( @@ -292,7 +292,7 @@ void PickerWidget::cleanup() void PickerWidget::update_active() { - if (hasclipboard && (rb_work->isOn() == clipboardworkortissue)) + if (hasclipboard && (rb_work->isChecked() == clipboardworkortissue)) { pb_paste->show(); } @@ -309,7 +309,7 @@ void PickerWidget::copy_pressed() { mask[i] = currentselection[i]; } - clipboardworkortissue = rb_work->isOn(); + clipboardworkortissue = rb_work->isChecked(); if (clipboardworkortissue) { bmphand->copy_work(valuedistrib); @@ -336,7 +336,7 @@ void PickerWidget::cut_pressed() void PickerWidget::paste_pressed() { - if (clipboardworkortissue != rb_work->isOn()) + if (clipboardworkortissue != rb_work->isChecked()) return; unsigned int area = bmphand->return_area(); @@ -369,20 +369,20 @@ void PickerWidget::delete_pressed() { iseg::DataSelection dataSelection; dataSelection.sliceNr = handler3D->active_slice(); - dataSelection.work = rb_work->isOn(); - dataSelection.tissues = !rb_work->isOn(); + dataSelection.work = rb_work->isChecked(); + dataSelection.tissues = !rb_work->isChecked(); emit begin_datachange(dataSelection, this); - if (rb_work->isOn()) + if (rb_work->isChecked()) { - if (rb_erase->isOn()) + if (rb_erase->isChecked()) bmphand->erasework(currentselection); else bmphand->floodwork(currentselection); } else { - if (rb_erase->isOn()) + if (rb_erase->isChecked()) bmphand->erasetissue(handler3D->active_tissuelayer(), currentselection); else diff --git a/iSeg/SaveOutlinesWidget.cpp b/iSeg/SaveOutlinesWidget.cpp index 8b1323b0..567a4f59 100755 --- a/iSeg/SaveOutlinesWidget.cpp +++ b/iSeg/SaveOutlinesWidget.cpp @@ -144,7 +144,7 @@ SaveOutlinesWidget::~SaveOutlinesWidget() void SaveOutlinesWidget::mode_changed() { - if (rb_line->isOn()) + if (rb_line->isChecked()) { rb_dougpeuck->setText("Doug-Peucker"); lb_f1->setText("Max. Dist.: 0 "); @@ -197,17 +197,17 @@ void SaveOutlinesWidget::mode_changed() void SaveOutlinesWidget::simplif_changed() { - if (rb_none->isOn()) + if (rb_none->isChecked()) { hbox4->hide(); hbox7->hide(); } - else if (rb_dougpeuck->isOn()) + else if (rb_dougpeuck->isChecked()) { hbox4->hide(); hbox7->show(); } - else if (rb_dist->isOn()) + else if (rb_dist->isChecked()) { hbox4->show(); hbox7->hide(); @@ -217,7 +217,7 @@ void SaveOutlinesWidget::simplif_changed() void SaveOutlinesWidget::file_pushed() { QString loadfilename; - if (rb_triang->isOn()) + if (rb_triang->isChecked()) loadfilename = QFileDialog::getSaveFileName( QString::null, "Surface grids (*.vtp *.dat *.stl)", this); else @@ -250,7 +250,7 @@ void SaveOutlinesWidget::save_pushed() if (!(le_file->text()).isEmpty()) { QString loadfilename = le_file->text(); - if (rb_triang->isOn()) + if (rb_triang->isChecked()) { ISEG_INFO_MSG("triangulating..."); // If no extension given, add a default one @@ -304,18 +304,18 @@ void SaveOutlinesWidget::save_pushed() Pair pair1 = handler3D->get_pixelsize(); handler3D->set_pixelsize(pair1.high / 2, pair1.low / 2); // handler3D->extract_contours2(sb_minsize->value(), vtissues); - if (rb_dougpeuck->isOn()) + if (rb_dougpeuck->isChecked()) { handler3D->extract_contours2_xmirrored( sb_minsize->value(), vtissues, sl_f->value() * 0.05f); // handler3D->dougpeuck_line(sl_f->value()*0.05f*2); } - else if (rb_dist->isOn()) + else if (rb_dist->isChecked()) { handler3D->extract_contours2_xmirrored(sb_minsize->value(), vtissues); } - else if (rb_none->isOn()) + else if (rb_none->isChecked()) { handler3D->extract_contours2_xmirrored(sb_minsize->value(), vtissues); @@ -365,7 +365,7 @@ void SaveOutlinesWidget::save_pushed() { handler3D->extractinterpolatesave_contours2_xmirrored( sb_minsize->value(), vtissues, sb_between->value(), - rb_dougpeuck->isOn(), sl_f->value() * 0.05f, + rb_dougpeuck->isChecked(), sl_f->value() * 0.05f, loadfilename.ascii()); } } diff --git a/iSeg/SliceViewerWidget.cpp b/iSeg/SliceViewerWidget.cpp index abf1373d..971df185 100755 --- a/iSeg/SliceViewerWidget.cpp +++ b/iSeg/SliceViewerWidget.cpp @@ -558,7 +558,7 @@ int SliceViewerWidget::get_slicenr() { return qsb_slicenr->value() - 1; } void SliceViewerWidget::bmp_changed() { - if (rb_bmp->isOn()) + if (rb_bmp->isChecked()) { unsigned short nrslicesnew; if (directionx) @@ -583,7 +583,7 @@ void SliceViewerWidget::bmp_changed() void SliceViewerWidget::work_changed() { - if (rb_work->isOn()) + if (rb_work->isChecked()) { unsigned short nrslicesnew; if (directionx) @@ -615,7 +615,7 @@ void SliceViewerWidget::tissuevisible_changed() void SliceViewerWidget::workorbmp_changed() { - if (rb_bmp->isOn()) + if (rb_bmp->isChecked()) { shower->set_bmporwork(true); } diff --git a/iSeg/SmoothingWidget.cpp b/iSeg/SmoothingWidget.cpp index 17b0cb3c..12e2b705 100755 --- a/iSeg/SmoothingWidget.cpp +++ b/iSeg/SmoothingWidget.cpp @@ -182,19 +182,19 @@ void SmoothingWidget::execute() if (allslices->isChecked()) { - if (rb_gaussian->isOn()) + if (rb_gaussian->isChecked()) { handler3D->gaussian(sl_sigma->value() * 0.05f); } - else if (rb_average->isOn()) + else if (rb_average->isChecked()) { handler3D->average((short unsigned)sb_n->value()); } - else if (rb_median->isOn()) + else if (rb_median->isChecked()) { handler3D->median_interquartile(true); } - else if (rb_sigmafilter->isOn()) + else if (rb_sigmafilter->isChecked()) { handler3D->sigmafilter( (sl_k->value() + 1) * 0.01f * sb_kmax->value(), @@ -209,19 +209,19 @@ void SmoothingWidget::execute() } else { - if (rb_gaussian->isOn()) + if (rb_gaussian->isChecked()) { bmphand->gaussian(sl_sigma->value() * 0.05f); } - else if (rb_average->isOn()) + else if (rb_average->isChecked()) { bmphand->average((short unsigned)sb_n->value()); } - else if (rb_median->isOn()) + else if (rb_median->isChecked()) { bmphand->median_interquartile(true); } - else if (rb_sigmafilter->isOn()) + else if (rb_sigmafilter->isChecked()) { bmphand->sigmafilter((sl_k->value() + 1) * 0.01f * sb_kmax->value(), (short unsigned)sb_n->value(), @@ -239,7 +239,7 @@ void SmoothingWidget::execute() void SmoothingWidget::method_changed(int) { - if (rb_gaussian->isOn()) + if (rb_gaussian->isChecked()) { if (hideparams) hbox2->hide(); @@ -250,7 +250,7 @@ void SmoothingWidget::method_changed(int) vbox2->hide(); contdiff->hide(); } - else if (rb_average->isOn()) + else if (rb_average->isChecked()) { if (hideparams) hbox1->hide(); @@ -261,7 +261,7 @@ void SmoothingWidget::method_changed(int) vbox2->hide(); contdiff->hide(); } - else if (rb_median->isOn()) + else if (rb_median->isChecked()) { hbox1->hide(); hbox2->hide(); @@ -269,7 +269,7 @@ void SmoothingWidget::method_changed(int) vbox2->hide(); contdiff->hide(); } - else if (rb_sigmafilter->isOn()) + else if (rb_sigmafilter->isChecked()) { if (hideparams) hbox1->hide(); @@ -307,7 +307,7 @@ void SmoothingWidget::method_changed(int) void SmoothingWidget::continue_diff() { - if (!rb_anisodiff->isOn()) + if (!rb_anisodiff->isChecked()) { return; } @@ -337,7 +337,7 @@ void SmoothingWidget::continue_diff() void SmoothingWidget::sigmaslider_changed(int newval) { UNREFERENCED_PARAMETER(newval); - if (rb_gaussian->isOn()) + if (rb_gaussian->isChecked()) { if (allslices->isChecked()) handler3D->gaussian(sl_sigma->value() * 0.05f); @@ -352,7 +352,7 @@ void SmoothingWidget::sigmaslider_changed(int newval) void SmoothingWidget::kslider_changed(int newval) { UNREFERENCED_PARAMETER(newval); - if (rb_sigmafilter->isOn()) + if (rb_sigmafilter->isChecked()) { if (allslices->isChecked()) handler3D->sigmafilter( @@ -378,7 +378,7 @@ void SmoothingWidget::n_changed(int newval) dataSelection.work = true; emit begin_datachange(dataSelection, this); - if (rb_sigmafilter->isOn()) + if (rb_sigmafilter->isChecked()) { if (allslices->isChecked()) { @@ -417,7 +417,7 @@ void SmoothingWidget::kmax_changed(int newval) dataSelection.work = true; emit begin_datachange(dataSelection, this); - if (rb_sigmafilter->isOn()) + if (rb_sigmafilter->isChecked()) { if (allslices->isChecked()) { @@ -462,7 +462,7 @@ void SmoothingWidget::newloaded() void SmoothingWidget::slider_pressed() { - if ((rb_gaussian->isOn() || rb_sigmafilter->isOn())) + if ((rb_gaussian->isChecked() || rb_sigmafilter->isChecked())) { iseg::DataSelection dataSelection; dataSelection.allSlices = allslices->isChecked(); @@ -474,7 +474,7 @@ void SmoothingWidget::slider_pressed() void SmoothingWidget::slider_released() { - if (rb_gaussian->isOn() || rb_sigmafilter->isOn()) + if (rb_gaussian->isChecked() || rb_sigmafilter->isChecked()) { emit end_datachange(this); } @@ -497,17 +497,17 @@ FILE* SmoothingWidget::SaveParams(FILE* fp, int version) fwrite(&(dummy), 1, sizeof(int), fp); dummy = sb_kmax->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_gaussian->isOn()); + dummy = (int)(rb_gaussian->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_average->isOn()); + dummy = (int)(rb_average->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_median->isOn()); + dummy = (int)(rb_median->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_sigmafilter->isOn()); + dummy = (int)(rb_sigmafilter->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_anisodiff->isOn()); + dummy = (int)(rb_anisodiff->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(allslices->isOn()); + dummy = (int)(allslices->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); } diff --git a/iSeg/ThresholdWidget.cpp b/iSeg/ThresholdWidget.cpp index 4feb114a..6107da7a 100755 --- a/iSeg/ThresholdWidget.cpp +++ b/iSeg/ThresholdWidget.cpp @@ -259,18 +259,18 @@ void ThresholdWidget::execute() dataSelection.work = true; emit begin_datachange(dataSelection, this); - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { if (allslices->isChecked()) handler3D->threshold(threshs); else bmphand->threshold(threshs); } - else if (rb_histo->isOn()) + else if (rb_histo->isChecked()) { bmphand->swap_bmpwork(); - if (subsect->isOn()) + if (subsect->isChecked()) { Point p; p.px = (unsigned short)sb_px->value(); @@ -291,7 +291,7 @@ void ThresholdWidget::execute() bmphand->threshold(thresh1); free(thresh1); } - else if (rb_kmeans->isOn()) + else if (rb_kmeans->isChecked()) { FILE* fp = fopen("C:\\gamma.txt", "r"); if (fp != nullptr) @@ -434,9 +434,9 @@ void ThresholdWidget::method_changed(int) { if (hideparams) { - if (!rb_histo->isOn()) + if (!rb_histo->isChecked()) rb_histo->hide(); - if (!rb_EM->isOn()) + if (!rb_EM->isChecked()) rb_EM->hide(); } else @@ -444,7 +444,7 @@ void ThresholdWidget::method_changed(int) rb_histo->show(); rb_EM->show(); } - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { pb_saveborders->show(); pb_loadborders->show(); @@ -470,7 +470,7 @@ void ThresholdWidget::method_changed(int) // pushrange->show(); // execute(); } - else if (rb_histo->isOn()) + else if (rb_histo->isChecked()) { pb_saveborders->hide(); pb_loadborders->hide(); @@ -490,7 +490,7 @@ void ThresholdWidget::method_changed(int) hbox5->hide(); le_borderval->hide(); } - else if (rb_kmeans->isOn()) + else if (rb_kmeans->isChecked()) { pb_saveborders->hide(); pb_loadborders->hide(); @@ -564,7 +564,7 @@ void ThresholdWidget::getrange() threshs[i + 1] = lower; } - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { int i = int((threshs[sb_tissuenr->value()] - lower) * 200 / (upper - lower)); @@ -578,18 +578,18 @@ void ThresholdWidget::getrange() void ThresholdWidget::on_tissuenr_changed(int newval) { - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { slider->setValue( int(200 * (threshs[newval] - lower) / (upper - lower))); le_borderval->setText(QString::number(threshs[newval], 'g', 3)); } - else if (rb_kmeans->isOn() || rb_EM->isOn()) + else if (rb_kmeans->isChecked() || rb_EM->isChecked()) { slider->setValue(int(200 * weights[newval - 1])); } - if (newval > 1 && (rb_kmeans->isOn() || rb_EM->isOn())) + if (newval > 1 && (rb_kmeans->isChecked() || rb_EM->isChecked())) { hboxfilenames->show(); le_filename->setText(filenames[newval - 2]); @@ -602,7 +602,7 @@ void ThresholdWidget::on_tissuenr_changed(int newval) void ThresholdWidget::nrtissues_changed(int newval) { - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { threshs[0] = float(newval - 1); sb_tissuenr->setMaxValue(newval - 1); @@ -627,7 +627,7 @@ void ThresholdWidget::nrtissues_changed(int newval) void ThresholdWidget::dim_changed(int newval) { - if (rb_kmeans->isOn() || rb_EM->isOn()) + if (rb_kmeans->isChecked() || rb_EM->isChecked()) { size_t cursize = filenames.size(); if (newval > cursize + 1) @@ -669,7 +669,7 @@ void ThresholdWidget::dim_changed(int newval) void ThresholdWidget::subsect_toggled() { - if (subsect->isOn()) + if (subsect->isChecked()) { hbox8->show(); } @@ -683,7 +683,7 @@ void ThresholdWidget::subsect_toggled() void ThresholdWidget::slider_changed(int newval) { - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { threshs[sb_tissuenr->value()] = newval * 0.005f * (upper - lower) + lower; @@ -697,7 +697,7 @@ void ThresholdWidget::slider_changed(int newval) emit end_datachange(this, iseg::NoUndo); } - else if (rb_kmeans->isOn() || rb_EM->isOn()) + else if (rb_kmeans->isChecked() || rb_EM->isChecked()) { weights[sb_tissuenr->value() - 1] = newval * 0.005f; } @@ -707,7 +707,7 @@ void ThresholdWidget::slider_changed(int newval) void ThresholdWidget::slider_pressed() { - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { iseg::DataSelection dataSelection; dataSelection.allSlices = allslices->isChecked(); @@ -719,7 +719,7 @@ void ThresholdWidget::slider_pressed() void ThresholdWidget::slider_released() { - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { emit end_datachange(this); } @@ -776,7 +776,7 @@ void ThresholdWidget::le_borderval_returnpressed() float val = le_borderval->text().toFloat(&b1); if (b1) { - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { if (val > upper) threshs[sb_tissuenr->value()] = upper; @@ -832,7 +832,7 @@ void ThresholdWidget::saveborders_execute() void ThresholdWidget::loadborders_execute() { - if (rb_manual->isOn()) + if (rb_manual->isChecked()) { QString loadfilename = QFileDialog::getOpenFileName(QString::null, @@ -907,17 +907,17 @@ FILE* ThresholdWidget::SaveParams(FILE* fp, int version) fwrite(&(dummy), 1, sizeof(int), fp); dummy = sb_minpix->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(subsect->isOn()); + dummy = (int)(subsect->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_manual->isOn()); + dummy = (int)(rb_manual->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_histo->isOn()); + dummy = (int)(rb_histo->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_kmeans->isOn()); + dummy = (int)(rb_kmeans->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_EM->isOn()); + dummy = (int)(rb_EM->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(allslices->isOn()); + dummy = (int)(allslices->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); fwrite(&upper, 1, sizeof(float), fp); diff --git a/iSeg/TransformWidget.cpp b/iSeg/TransformWidget.cpp index e8ad41b7..0ffb2f7c 100755 --- a/iSeg/TransformWidget.cpp +++ b/iSeg/TransformWidget.cpp @@ -322,7 +322,7 @@ void TransformWidget::UpdatePreview() dataSelection.tissues = transformTissuesCheckBox->isChecked(); emit begin_datachange(dataSelection, this, false); - if (translateRadioButton->isOn()) + if (translateRadioButton->isChecked()) { // Translate sliceTransform->Translate( @@ -331,7 +331,7 @@ void TransformWidget::UpdatePreview() transformParameters.translationOffset[0] = updateParameter1; transformParameters.translationOffset[1] = updateParameter2; } - else if (rotateRadioButton->isOn()) + else if (rotateRadioButton->isChecked()) { // Rotate sliceTransform->Rotate(updateParameter1 - @@ -340,7 +340,7 @@ void TransformWidget::UpdatePreview() transformParameters.transformCenter[1]); transformParameters.rotationAngle = updateParameter1; } - else if (scaleRadioButton->isOn()) + else if (scaleRadioButton->isChecked()) { // Scale sliceTransform->Scale( @@ -351,7 +351,7 @@ void TransformWidget::UpdatePreview() transformParameters.scalingFactor[0] = updateParameter1; transformParameters.scalingFactor[1] = updateParameter2; } - else if (shearRadioButton->isOn()) + else if (shearRadioButton->isChecked()) { // Shear if (xAxisRadioButton->isChecked()) diff --git a/iSeg/VolumeViewerWidget.cpp b/iSeg/VolumeViewerWidget.cpp index 39eb2448..dea159a3 100644 --- a/iSeg/VolumeViewerWidget.cpp +++ b/iSeg/VolumeViewerWidget.cpp @@ -403,7 +403,7 @@ VolumeViewerWidget::VolumeViewerWidget(SlicesHandler* hand3D1, bool bmportissue1 planeWidgetY->SetPlaceFactor(1.0); planeWidgetY->PlaceWidget(); planeWidgetY->SetOrigin(center); - planeWidgetY->SetEnabled(cb_showslice1->isOn()); + planeWidgetY->SetEnabled(cb_showslice1->isChecked()); planeWidgetY->PlaceWidget(bounds); my_sliceDataZ = vtkSmartPointer::New(); @@ -417,7 +417,7 @@ VolumeViewerWidget::VolumeViewerWidget(SlicesHandler* hand3D1, bool bmportissue1 planeWidgetZ->SetPlaceFactor(1.0); planeWidgetZ->PlaceWidget(); planeWidgetZ->SetOrigin(center); - planeWidgetZ->SetEnabled(cb_showslice2->isOn()); + planeWidgetZ->SetEnabled(cb_showslice2->isChecked()); planeWidgetZ->PlaceWidget(bounds); // @@ -451,7 +451,7 @@ VolumeViewerWidget::~VolumeViewerWidget() { delete vbox1; } void VolumeViewerWidget::shade_changed() { - if (cb_shade->isOn()) + if (cb_shade->isChecked()) { volumeProperty->ShadeOn(); } @@ -465,7 +465,7 @@ void VolumeViewerWidget::shade_changed() void VolumeViewerWidget::raytraceortexturemap_changed() { - if (cb_raytraceortexturemap->isOn()) + if (cb_raytraceortexturemap->isChecked()) { volumeMapper->SetRequestedRenderModeToDefault(); } @@ -481,20 +481,20 @@ void VolumeViewerWidget::raytraceortexturemap_changed() void VolumeViewerWidget::showslices_changed() { bool changed = false; - if ((cb_showslices->isOn() ? 1 : 0) != sliceActorY->GetVisibility()) + if ((cb_showslices->isChecked() ? 1 : 0) != sliceActorY->GetVisibility()) { - sliceActorY->SetVisibility(cb_showslices->isOn()); - sliceActorZ->SetVisibility(cb_showslices->isOn()); + sliceActorY->SetVisibility(cb_showslices->isChecked()); + sliceActorZ->SetVisibility(cb_showslices->isChecked()); changed = true; } - if ((cb_showslice1->isOn() ? 1 : 0) != planeWidgetY->GetEnabled()) + if ((cb_showslice1->isChecked() ? 1 : 0) != planeWidgetY->GetEnabled()) { - planeWidgetY->SetEnabled(cb_showslice1->isOn()); + planeWidgetY->SetEnabled(cb_showslice1->isChecked()); changed = true; } - if ((cb_showslice2->isOn() ? 1 : 0) != planeWidgetZ->GetEnabled()) + if ((cb_showslice2->isChecked() ? 1 : 0) != planeWidgetZ->GetEnabled()) { - planeWidgetZ->SetEnabled(cb_showslice2->isOn()); + planeWidgetZ->SetEnabled(cb_showslice2->isChecked()); changed = true; } @@ -506,7 +506,7 @@ void VolumeViewerWidget::showslices_changed() void VolumeViewerWidget::showvolume_changed() { - if (cb_showvolume->isOn()) + if (cb_showvolume->isChecked()) { volume->SetVisibility(true); cb_shade->show(); diff --git a/iSeg/WidgetCollection.cpp b/iSeg/WidgetCollection.cpp index d05f64ed..54c8d8ca 100755 --- a/iSeg/WidgetCollection.cpp +++ b/iSeg/WidgetCollection.cpp @@ -436,7 +436,7 @@ ShowHisto::~ShowHisto() void ShowHisto::subsect_toggled() { - bool isset = subsect->isOn(); + bool isset = subsect->isChecked(); if (isset) { vbox2->show(); @@ -466,10 +466,10 @@ void ShowHisto::subsect_update() void ShowHisto::draw_histo() { //Point p; - if (bmppict->isOn()) + if (bmppict->isChecked()) { bmphand->swap_bmpwork(); - if (subsect->isOn()) + if (subsect->isChecked()) { Point p; p.px = xoffset->value(); @@ -490,7 +490,7 @@ void ShowHisto::draw_histo() } else { - if (subsect->isOn()) + if (subsect->isChecked()) { Point p; p.px = xoffset->value(); @@ -1821,7 +1821,7 @@ void extoverlay_widget::remove_dataset(unsigned short idx) void extoverlay_widget::reload_overlay() { bool ok = true; - if (selectedDataset == 0 && (srcCheckBox->isOn() || tgtCheckBox->isOn())) + if (selectedDataset == 0 && (srcCheckBox->isChecked() || tgtCheckBox->isChecked())) { handler3D->clear_overlay(); } @@ -1929,13 +1929,13 @@ void extoverlay_widget::slider_changed(int newval) void extoverlay_widget::source_toggled() { - bool isset = srcCheckBox->isOn(); + bool isset = srcCheckBox->isChecked(); emit bmpoverlayvisible_changed(isset); } void extoverlay_widget::target_toggled() { - bool isset = tgtCheckBox->isOn(); + bool isset = tgtCheckBox->isChecked(); emit workoverlayvisible_changed(isset); } @@ -2772,7 +2772,7 @@ ImageMath::~ImageMath() { delete vbox1; } void ImageMath::imgorval_changed(int) { - if (rb_val->isOn()) + if (rb_val->isChecked()) { hbox2->show(); } @@ -2795,7 +2795,7 @@ void ImageMath::add_pushed() if (allslices->isChecked()) { - if (rb_val->isOn()) + if (rb_val->isChecked()) { handler3D->bmp_add(val); } @@ -2806,7 +2806,7 @@ void ImageMath::add_pushed() } else { - if (rb_val->isOn()) + if (rb_val->isChecked()) { bmphand->bmp_add(val); } @@ -2832,7 +2832,7 @@ void ImageMath::sub_pushed() if (allslices->isChecked()) { - if (rb_val->isOn()) + if (rb_val->isChecked()) { handler3D->bmp_add(-val); } @@ -2843,7 +2843,7 @@ void ImageMath::sub_pushed() } else { - if (rb_val->isOn()) + if (rb_val->isChecked()) { bmphand->bmp_add(-val); } @@ -2869,7 +2869,7 @@ void ImageMath::mult_pushed() if (allslices->isChecked()) { - if (rb_val->isOn()) + if (rb_val->isChecked()) { handler3D->bmp_mult(val); } @@ -2880,7 +2880,7 @@ void ImageMath::mult_pushed() } else { - if (rb_val->isOn()) + if (rb_val->isChecked()) { bmphand->bmp_mult(val); } From 2f1ece296d9ff5ef9abe88ca1b0d4372087819f1 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Mon, 11 Feb 2019 21:11:35 +0100 Subject: [PATCH 07/26] refactor undo dialog: use QFormLayout --- iSeg/UndoConfigurationDialog.cpp | 39 ++++++++++++++------------------ iSeg/UndoConfigurationDialog.h | 17 ++------------ 2 files changed, 19 insertions(+), 37 deletions(-) diff --git a/iSeg/UndoConfigurationDialog.cpp b/iSeg/UndoConfigurationDialog.cpp index 83ad2ee4..522ecc77 100755 --- a/iSeg/UndoConfigurationDialog.cpp +++ b/iSeg/UndoConfigurationDialog.cpp @@ -11,7 +11,7 @@ #include "UndoConfigurationDialog.h" -#include +#include #include #include #include @@ -23,39 +23,34 @@ UndoConfigurationDialog::UndoConfigurationDialog(SlicesHandler* hand3D, QWidget* Qt::WindowFlags wFlags) : QDialog(parent, name, TRUE, wFlags), handler3D(hand3D) { - vbox1 = new Q3VBox(this); + auto layout = new QFormLayout; - cb_undo3D = new QCheckBox(QString("Enable 3D undo"), vbox1); + cb_undo3D = new QCheckBox; cb_undo3D->setChecked(handler3D->return_undo3D()); - hbox1 = new Q3HBox(vbox1); - // hbox2= new QHBox(vbox1); - vbox2 = new Q3VBox(hbox1); - vbox3 = new Q3VBox(hbox1); - - lb_nrundo = new QLabel("Maximal nr of undo steps: ", vbox2); - sb_nrundo = new QSpinBox(1, 100, 1, vbox3); + sb_nrundo = new QSpinBox(1, 100, 1, nullptr); sb_nrundo->setValue(handler3D->GetNumberOfUndoSteps()); - lb_nrundoarrays = new QLabel("Maximal nr of stored images: ", vbox2); - sb_nrundoarrays = new QSpinBox(6, 10000, 1, vbox3); + sb_nrundoarrays = new QSpinBox(6, 10000, 1, nullptr); sb_nrundoarrays->setValue(handler3D->GetNumberOfUndoArrays()); - pb_close = new QPushButton("Accept", vbox1); + pb_close = new QPushButton("Accept"); - vbox1->show(); - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + // layout + layout->addRow(tr("Enable 3D Undo"), cb_undo3D); + layout->addRow(tr("Maximal nr of undo steps"), sb_nrundo); + layout->addRow(tr("Maximal nr of stored images"), sb_nrundoarrays); + layout->addRow(pb_close); - vbox2->setFixedSize(vbox2->sizeHint()); - vbox3->setFixedSize(vbox3->sizeHint()); - hbox1->setFixedSize(hbox1->sizeHint()); - vbox1->setFixedSize(vbox1->sizeHint()); + setLayout(layout); + // connections QObject::connect(pb_close, SIGNAL(clicked()), this, SLOT(ok_pressed())); - - return; } -UndoConfigurationDialog::~UndoConfigurationDialog() { delete vbox1; } +UndoConfigurationDialog::~UndoConfigurationDialog() +{ + +} void UndoConfigurationDialog::ok_pressed() { diff --git a/iSeg/UndoConfigurationDialog.h b/iSeg/UndoConfigurationDialog.h index 00193ffa..4c2fab95 100755 --- a/iSeg/UndoConfigurationDialog.h +++ b/iSeg/UndoConfigurationDialog.h @@ -7,19 +7,14 @@ * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ -#ifndef UNDOCONFIG_23NOV05 -#define UNDOCONFIG_23NOV05 +#pragma once #include "SlicesHandler.h" -#include -#include -#include #include -#include +#include #include #include -#include namespace iseg { @@ -34,13 +29,6 @@ class UndoConfigurationDialog : public QDialog private: SlicesHandler* handler3D; QCheckBox* cb_undo3D; - Q3VBox* vbox1; - Q3VBox* vbox2; - Q3VBox* vbox3; - Q3HBox* hbox1; - // QHBox *hbox2; - QLabel* lb_nrundo; - QLabel* lb_nrundoarrays; QSpinBox* sb_nrundo; QSpinBox* sb_nrundoarrays; QPushButton* pb_close; @@ -51,4 +39,3 @@ private slots: } // namespace iseg -#endif From 21e81fd4a6bcde11e4676be69b35abc0f4084f41 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Mon, 11 Feb 2019 21:26:59 +0100 Subject: [PATCH 08/26] refactor watershed widget: use QFormLayout, remove Qt3 stuff --- iSeg/WatershedWidget.cpp | 116 ++++++++++++--------------------------- iSeg/WatershedWidget.h | 18 +----- 2 files changed, 37 insertions(+), 97 deletions(-) diff --git a/iSeg/WatershedWidget.cpp b/iSeg/WatershedWidget.cpp index fc9938a4..009d921a 100755 --- a/iSeg/WatershedWidget.cpp +++ b/iSeg/WatershedWidget.cpp @@ -13,20 +13,8 @@ #include "WatershedWidget.h" #include "bmp_read_1.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include using namespace iseg; @@ -34,49 +22,48 @@ WatershedWidget::WatershedWidget(SlicesHandler* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), handler3D(hand3D) { - setToolTip( - Format("Segment a tissue (2D) by selecting points in the current slice " - "based on the Watershed method." - "
" - "The method: the gradient of the slightly smoothed image is " - "calculated. High values are interpreted as mountains and " - "low values as valleys. Subsequently, a flooding with water is " - "simulated resulting in thousands of basins. " - "Higher water causes adjacent basins to merge. ")); + setToolTip(Format( + "Segment a tissue (2D) by selecting points in the current slice " + "based on the Watershed method." + "
" + "The method: the gradient of the slightly smoothed image is " + "calculated. High values are interpreted as mountains and " + "low values as valleys. Subsequently, a flooding with water is " + "simulated resulting in thousands of basins. " + "Higher water causes adjacent basins to merge. ")); activeslice = handler3D->active_slice(); bmphand = handler3D->get_activebmphandler(); usp = nullptr; - vbox1 = new Q3VBox(this); - vbox1->setMargin(8); - hbox1 = new Q3HBox(vbox1); - btn_exec = new QPushButton("Execute", vbox1); - hbox2 = new Q3HBox(vbox1); - hbox3 = new Q3HBox(vbox1); - txt_h = new QLabel("Flooding height (h): ", hbox1); - sl_h = new QSlider(Qt::Horizontal, hbox1); + sl_h = new QSlider(Qt::Horizontal, nullptr); sl_h->setRange(0, 200); sl_h->setValue(160); - sb_h = new QSpinBox(10, 100, 10, hbox1); + + sb_h = new QSpinBox(10, 100, 10, nullptr); sb_h->setValue(40); + sbh_old = sb_h->value(); - sl_h->setFixedWidth(300); - hbox1->setFixedSize(hbox1->sizeHint()); - vbox1->setFixedSize(vbox1->sizeHint()); + btn_exec = new QPushButton("Execute"); - sbh_old = sb_h->value(); + // layout + auto height_hbox = new QHBoxLayout; + height_hbox->addWidget(sl_h); + height_hbox->addWidget(sb_h); + + auto layout = new QFormLayout; + layout->addRow(tr("Flooding height (h)"), height_hbox); + layout->addRow(btn_exec); + + setLayout(layout); - QObject::connect(sl_h, SIGNAL(valueChanged(int)), this, - SLOT(hsl_changed())); - QObject::connect(sl_h, SIGNAL(sliderPressed()), this, - SLOT(slider_pressed())); - QObject::connect(sl_h, SIGNAL(sliderReleased()), this, - SLOT(slider_released())); - QObject::connect(sb_h, SIGNAL(valueChanged(int)), this, - SLOT(hsb_changed(int))); - QObject::connect(btn_exec, SIGNAL(clicked()), this, SLOT(execute())); + // connections + connect(sl_h, SIGNAL(valueChanged(int)), this, SLOT(hsl_changed())); + connect(sl_h, SIGNAL(sliderPressed()), this, SLOT(slider_pressed())); + connect(sl_h, SIGNAL(sliderReleased()), this, SLOT(slider_released())); + connect(sb_h, SIGNAL(valueChanged(int)), this, SLOT(hsb_changed(int))); + connect(btn_exec, SIGNAL(clicked()), this, SLOT(execute())); } void WatershedWidget::hsl_changed() @@ -98,8 +85,6 @@ void WatershedWidget::hsb_changed(int value) recalc(); } sbh_old = sbh_new; - - return; } void WatershedWidget::execute() @@ -128,14 +113,10 @@ void WatershedWidget::recalc() emit end_datachange(this); } - - return; } void WatershedWidget::marks_changed() { - // recalc(); - if (usp != nullptr) { iseg::DataSelection dataSelection; @@ -147,8 +128,6 @@ void WatershedWidget::marks_changed() emit end_datachange(this, iseg::MergeUndo); } - - return; } void WatershedWidget::recalc1() @@ -158,16 +137,10 @@ void WatershedWidget::recalc1() bmphand->construct_regions( (unsigned int)(sb_h->value() * sl_h->value() * 0.005f), usp); } - - return; } -QSize WatershedWidget::sizeHint() const { return vbox1->sizeHint(); } - WatershedWidget::~WatershedWidget() { - delete vbox1; - free(usp); } @@ -186,7 +159,6 @@ void WatershedWidget::bmphand_changed(bmphandler* bmph) } bmphand = bmph; - return; } void WatershedWidget::init() @@ -237,10 +209,8 @@ FILE* WatershedWidget::LoadParams(FILE* fp, int version) { if (version >= 2) { - QObject::disconnect(sl_h, SIGNAL(valueChanged(int)), this, - SLOT(hsl_changed())); - QObject::disconnect(sb_h, SIGNAL(valueChanged(int)), this, - SLOT(hsb_changed(int))); + disconnect(sl_h, SIGNAL(valueChanged(int)), this, SLOT(hsl_changed())); + disconnect(sb_h, SIGNAL(valueChanged(int)), this, SLOT(hsb_changed(int))); int dummy; fread(&dummy, sizeof(int), 1, fp); @@ -250,22 +220,8 @@ FILE* WatershedWidget::LoadParams(FILE* fp, int version) fread(&sbh_old, sizeof(float), 1, fp); - QObject::connect(sl_h, SIGNAL(valueChanged(int)), this, - SLOT(hsl_changed())); - QObject::connect(sb_h, SIGNAL(valueChanged(int)), this, - SLOT(hsb_changed(int))); + connect(sl_h, SIGNAL(valueChanged(int)), this, SLOT(hsl_changed())); + connect(sb_h, SIGNAL(valueChanged(int)), this, SLOT(hsb_changed(int))); } return fp; } - -void WatershedWidget::hideparams_changed() -{ - if (hideparams) - { - hbox1->hide(); - } - else - { - hbox1->show(); - } -} diff --git a/iSeg/WatershedWidget.h b/iSeg/WatershedWidget.h index 1bcafd8b..3ac6dbe2 100755 --- a/iSeg/WatershedWidget.h +++ b/iSeg/WatershedWidget.h @@ -11,19 +11,9 @@ #include "Interface/WidgetInterface.h" -#include -#include -#include -#include -#include #include -#include -#include #include #include -#include - -#include namespace iseg { @@ -37,12 +27,10 @@ class WatershedWidget : public WidgetInterface WatershedWidget(SlicesHandler* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); ~WatershedWidget(); - QSize sizeHint() const override; void init() override; void newloaded() override; FILE* SaveParams(FILE* fp, int version) override; FILE* LoadParams(FILE* fp, int version) override; - void hideparams_changed() override; std::string GetName() override { return std::string("Watershed"); } QIcon GetIcon(QDir picdir) override { return QIcon(picdir.absFilePath(QString("watershed.png"))); } @@ -56,11 +44,7 @@ class WatershedWidget : public WidgetInterface bmphandler* bmphand; SlicesHandler* handler3D; unsigned short activeslice; - Q3HBox* hbox1; - Q3HBox* hbox2; - Q3HBox* hbox3; - Q3VBox* vbox1; - QLabel* txt_h; + QSpinBox* sb_h; QSlider* sl_h; QPushButton* btn_exec; From 66958772ae66512c7d30ca2e86c82c503827ec60 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Mon, 11 Feb 2019 21:28:48 +0100 Subject: [PATCH 09/26] remove unused header includes --- iSeg/AtlasViewer.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/iSeg/AtlasViewer.h b/iSeg/AtlasViewer.h index 91a852cf..bbb7c66f 100755 --- a/iSeg/AtlasViewer.h +++ b/iSeg/AtlasViewer.h @@ -15,20 +15,7 @@ #include "Core/Pair.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include #include #include From 2300195461a54cc1d164ed001e282af0ded33dba Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 12 Feb 2019 19:10:59 +0100 Subject: [PATCH 10/26] refactor fuzzy widget: use QFormLayout, remove Qt3 stuff --- iSeg/FastmarchingFuzzyWidget.cpp | 318 +++++++++++++------------------ iSeg/FastmarchingFuzzyWidget.h | 42 +--- 2 files changed, 143 insertions(+), 217 deletions(-) diff --git a/iSeg/FastmarchingFuzzyWidget.cpp b/iSeg/FastmarchingFuzzyWidget.cpp index 4f30e24d..a944c763 100755 --- a/iSeg/FastmarchingFuzzyWidget.cpp +++ b/iSeg/FastmarchingFuzzyWidget.cpp @@ -15,83 +15,80 @@ #include "Core/ImageForestingTransform.h" -#include -#include #include -#include -#include -#include +#include +#include +#include #include #include #include #include -#include #include +#include using namespace iseg; +namespace { +QHBoxLayout* make_hbox(std::initializer_list list) +{ + auto hbox = new QHBoxLayout; + for (auto w : list) + { + hbox->addWidget(w); + } + return hbox; +} +QWidget* add_to_widget(QLayout* layout) +{ + auto widget = new QWidget; + widget->setLayout(layout); + return widget; +} + +} + FastmarchingFuzzyWidget::FastmarchingFuzzyWidget(SlicesHandler* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), handler3D(hand3D) { - setToolTip( - Format("The Fuzzy tab actually provides access to two different " - "segmentation techniques that have a very different " - "background but a similar user and interaction interface : " - "1) Fuzzy connectedness and 2) a Fast Marching " - "implementation of a levelset technique. Both methods " - "require a seed point to be specified.")); + setToolTip(Format( + "The Fuzzy tab actually provides access to two different " + "segmentation techniques that have a very different " + "background but a similar user and interaction interface : " + "1) Fuzzy connectedness and 2) a Fast Marching " + "implementation of a levelset technique. Both methods " + "require a seed point to be specified.")); activeslice = handler3D->active_slice(); bmphand = handler3D->get_activebmphandler(); area = 0; - hboxoverall = new Q3HBox(this); - hboxoverall->setMargin(8); - vboxmethods = new Q3VBox(hboxoverall); - vbox1 = new Q3VBox(hboxoverall); - vboxfast = new Q3VBox(vbox1); - vboxfuzzy = new Q3VBox(vbox1); - - hbox1 = new Q3HBox(vboxfast); - hbox2 = new Q3HBox(vboxfast); - hbox3 = new Q3HBox(vboxfuzzy); - hbox4 = new Q3HBox(vboxfuzzy); - hbox5 = new Q3HBox(vboxfuzzy); - hbox7 = new Q3HBox(vbox1); - - txt_sigma = new QLabel(QString("Sigma: "), hbox1); - txt_thresh = new QLabel(QString("Thresh: 0"), hbox2); - txt_m1 = new QLabel(QString("m1: 0"), hbox3); - txt_s1 = new QLabel(QString("s1: 0"), hbox4); - txt_s2 = new QLabel(QString("s2: 0"), hbox5); - - sl_sigma = new QSlider(Qt::Horizontal, hbox1); + sl_sigma = new QSlider(Qt::Horizontal, nullptr); sl_sigma->setRange(0, 100); sl_sigma->setValue(int(sigma / sigmamax * 100)); - sl_thresh = new QSlider(Qt::Horizontal, hbox2); + sl_thresh = new QSlider(Qt::Horizontal, nullptr); sl_thresh->setRange(0, 100); - sl_m1 = new QSlider(Qt::Horizontal, hbox3); + sl_m1 = new QSlider(Qt::Horizontal, nullptr); sl_m1->setRange(0, 100); - sl_m1->setToolTip( - Format("The average gray value of the region to be segmented.")); + sl_m1->setToolTip(Format("The average gray value of the region to be segmented.")); - sl_s1 = new QSlider(Qt::Horizontal, hbox4); + sl_s1 = new QSlider(Qt::Horizontal, nullptr); sl_s1->setRange(0, 100); - sl_s1->setToolTip( - Format("A measure of how much the gray values are expected " - "to deviate from m1 (standard deviation).")); + sl_s1->setToolTip(Format( + "A measure of how much the gray values are expected " + "to deviate from m1 (standard deviation).")); - sl_s2 = new QSlider(Qt::Horizontal, hbox5); + sl_s2 = new QSlider(Qt::Horizontal, nullptr); sl_s2->setRange(0, 100); - sl_s2->setToolTip(Format("Sudden changes larger than s2 are considered to " - "indicate boundaries.")); + sl_s2->setToolTip(Format( + "Sudden changes larger than s2 are considered to " + "indicate boundaries.")); - rb_fastmarch = new QRadioButton(QString("Fast Marching"), vboxmethods); + rb_fastmarch = new QRadioButton(tr("Fast Marching")); rb_fastmarch->setToolTip(Format( "Fuzzy connectedness computes for each image " "point the likelihood of its belonging to the same region as the " @@ -101,103 +98,103 @@ FastmarchingFuzzyWidget::FastmarchingFuzzyWidget(SlicesHandler* hand3D, "identical to the probability of this path lying entirely in the same " "tissue " "as the start point.")); - rb_fuzzy = new QRadioButton(QString("Fuzzy Connect."), vboxmethods); - rb_fuzzy->setToolTip( - Format("This tool simulates the evolution of a line (boundary) on a 2D " - "image in time. " - "The boundary is continuously expanding. The Sigma parameter " - "(Gaussian smoothing) controls the impact of noise.")); - - bg_method = new QButtonGroup(this); + rb_fuzzy = new QRadioButton(tr("Fuzzy Connect.")); + rb_fuzzy->setToolTip(Format( + "This tool simulates the evolution of a line (boundary) on a 2D " + "image in time. " + "The boundary is continuously expanding. The Sigma parameter " + "(Gaussian smoothing) controls the impact of noise.")); + + auto bg_method = new QButtonGroup(this); bg_method->insert(rb_fastmarch); bg_method->insert(rb_fuzzy); - rb_fuzzy->show(); - rb_fastmarch->setChecked(TRUE); - rb_fastmarch->show(); - - rb_drag = new QRadioButton(QString("Drag"), hbox7); - rb_drag->setToolTip( - Format("Drag allows the user to drag the mouse (after clicking on " - "the start point and keeping the mouse button pressed down) " - "specifying the " - "extent of the region on the image.")); - rb_drag->setChecked(TRUE); + rb_fastmarch->setChecked(true); + + rb_drag = new QRadioButton(tr("Drag")); + rb_drag->setToolTip(Format( + "Drag allows the user to drag the mouse (after clicking on " + "the start point and keeping the mouse button pressed down) " + "specifying the " + "extent of the region on the image.")); + rb_drag->setChecked(true); rb_drag->show(); - rb_slider = new QRadioButton(QString("Slider"), hbox7); + rb_slider = new QRadioButton(tr("Slider")); rb_slider->setToolTip(Format("Increase or decrease the region size.")); - rb_slider->show(); - bg_interact = new QButtonGroup(this); + auto bg_interact = new QButtonGroup(this); bg_interact->insert(rb_drag); bg_interact->insert(rb_slider); - sl_extend = new QSlider(Qt::Horizontal, vbox1); + sl_extend = new QSlider(Qt::Horizontal, nullptr); sl_extend->setRange(0, 200); sl_extend->setValue(0); - sl_extend->setEnabled(false); - sb_thresh = new QSpinBox(10, 100, 10, hbox2); + sb_thresh = new QSpinBox(10, 100, 10, nullptr); sb_thresh->setValue(30); - sb_m1 = new QSpinBox(50, 1000, 50, hbox3); + sb_m1 = new QSpinBox(50, 1000, 50, nullptr); sb_m1->setValue(200); - sb_s1 = new QSpinBox(50, 500, 50, hbox4); + sb_s1 = new QSpinBox(50, 500, 50, nullptr); sb_s1->setValue(100); - sb_s2 = new QSpinBox(10, 200, 10, hbox5); + sb_s2 = new QSpinBox(10, 200, 10, nullptr); sb_s2->setValue(100); - sl_s1->setFixedWidth(300); - sl_s2->setFixedWidth(300); - sl_m1->setFixedWidth(300); - sl_extend->setFixedWidth(400); - sl_thresh->setFixedWidth(300); - sl_sigma->setFixedWidth(300); - - vboxmethods->setMargin(5); - vbox1->setMargin(5); - vboxmethods->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - vboxmethods->setLineWidth(1); - - hbox1->setFixedSize(hbox1->sizeHint()); - hbox2->setFixedSize(hbox2->sizeHint()); - hbox3->setFixedSize(hbox3->sizeHint()); - hbox4->setFixedSize(hbox4->sizeHint()); - hbox5->setFixedSize(hbox5->sizeHint()); - vbox1->setFixedSize(vbox1->sizeHint()); + // layout + auto method_layout = new QVBoxLayout; + method_layout->addWidget(rb_fastmarch); + method_layout->addWidget(rb_fuzzy); + + auto method_area = new QFrame; + method_area->setLayout(method_layout); + method_area->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + method_area->setLineWidth(1); + + auto fm_params = new QFormLayout; + fm_params->addRow(tr("Sigma"), sl_sigma); + fm_params->addRow(tr("Thresh"), make_hbox({sl_thresh, sb_thresh})); + + auto fuzzy_params = new QFormLayout; + fuzzy_params->addRow(tr("m1"), make_hbox({sl_m1, sb_m1})); + fuzzy_params->addRow(tr("s1"), make_hbox({sl_s1, sb_s1})); + fuzzy_params->addRow(tr("s2"), make_hbox({sl_s2, sb_s2})); + + params_stack_layout = new QStackedLayout; + params_stack_layout->addWidget(add_to_widget(fm_params)); + params_stack_layout->addWidget(add_to_widget(fuzzy_params)); + + auto interact_layout = new QVBoxLayout; + interact_layout->addWidget(rb_drag); + interact_layout->addLayout(make_hbox({rb_slider, sl_extend})); + + auto params_layout = new QVBoxLayout; + params_layout->addLayout(params_stack_layout); + params_layout->addLayout(interact_layout); + + auto top_layout = new QHBoxLayout; + top_layout->addWidget(method_area); + top_layout->addLayout(params_layout); + + setLayout(top_layout); + + // connections + connect(sl_extend, SIGNAL(valueChanged(int)), this, SLOT(slextend_changed(int))); + connect(sl_extend, SIGNAL(sliderPressed()), this, SLOT(slextend_pressed())); + connect(sl_extend, SIGNAL(sliderReleased()), this, SLOT(slextend_released())); + connect(sl_sigma, SIGNAL(sliderMoved(int)), this, SLOT(slider_changed())); + connect(sl_thresh, SIGNAL(sliderMoved(int)), this, SLOT(slider_changed())); + connect(sl_m1, SIGNAL(sliderMoved(int)), this, SLOT(slider_changed())); + connect(sl_s1, SIGNAL(sliderMoved(int)), this, SLOT(slider_changed())); + connect(sl_s2, SIGNAL(sliderMoved(int)), this, SLOT(slider_changed())); + + connect(bg_method, SIGNAL(buttonClicked(int)), this, SLOT(method_changed())); + connect(bg_interact, SIGNAL(buttonClicked(int)), this, SLOT(interact_changed())); + + connect(sb_thresh, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); + connect(sb_m1, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); + connect(sb_s1, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); + connect(sb_s2, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); IFTmarch = nullptr; IFTfuzzy = nullptr; - - QObject::connect(sl_extend, SIGNAL(valueChanged(int)), this, - SLOT(slextend_changed(int))); - QObject::connect(sl_extend, SIGNAL(sliderPressed()), this, - SLOT(slextend_pressed())); - QObject::connect(sl_extend, SIGNAL(sliderReleased()), this, - SLOT(slextend_released())); - QObject::connect(sl_sigma, SIGNAL(sliderMoved(int)), this, - SLOT(slider_changed())); - QObject::connect(sl_thresh, SIGNAL(sliderMoved(int)), this, - SLOT(slider_changed())); - QObject::connect(sl_m1, SIGNAL(sliderMoved(int)), this, - SLOT(slider_changed())); - QObject::connect(sl_s1, SIGNAL(sliderMoved(int)), this, - SLOT(slider_changed())); - QObject::connect(sl_s2, SIGNAL(sliderMoved(int)), this, - SLOT(slider_changed())); - - QObject::connect(bg_method, SIGNAL(buttonClicked(int)), this, - SLOT(method_changed())); - QObject::connect(bg_interact, SIGNAL(buttonClicked(int)), this, - SLOT(interact_changed())); - - QObject::connect(sb_thresh, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - QObject::connect(sb_m1, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - QObject::connect(sb_s1, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - QObject::connect(sb_s2, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - sigma = 1.0f; sigmamax = 5.0f; thresh = 100.0f; @@ -213,10 +210,6 @@ FastmarchingFuzzyWidget::FastmarchingFuzzyWidget(SlicesHandler* hand3D, FastmarchingFuzzyWidget::~FastmarchingFuzzyWidget() { - delete vbox1; - delete bg_method; - delete bg_interact; - if (IFTmarch != nullptr) delete IFTmarch; if (IFTfuzzy != nullptr) @@ -282,15 +275,12 @@ void FastmarchingFuzzyWidget::cleanup() sl_extend->setEnabled(false); } -QSize FastmarchingFuzzyWidget::sizeHint() const { return vbox1->sizeHint(); } - void FastmarchingFuzzyWidget::getrange() { extendmax = 0; for (unsigned i = 0; i < area; i++) if (extendmax < map[i]) extendmax = map[i]; - return; } void FastmarchingFuzzyWidget::on_mouse_clicked(Point p) @@ -514,26 +504,11 @@ void FastmarchingFuzzyWidget::method_changed() { if (rb_fastmarch->isChecked()) { - if (hideparams) - { - vboxmethods->hide(); - vboxfast->hide(); - } - else - { - vboxmethods->show(); - vboxfast->show(); - } - vboxfuzzy->hide(); + params_stack_layout->setCurrentIndex(0); } else { - vboxmethods->show(); - if (hideparams) - vboxfuzzy->hide(); - else - vboxfuzzy->show(); - vboxfast->hide(); + params_stack_layout->setCurrentIndex(1); } } @@ -541,16 +516,11 @@ void FastmarchingFuzzyWidget::interact_changed() { if (rb_drag->isChecked()) { - if (hideparams) - hbox7->hide(); - else - hbox7->show(); - sl_extend->hide(); + sl_extend->setVisible(false); } else { - hbox7->show(); - sl_extend->show(); + sl_extend->setVisible(true); } } @@ -688,20 +658,11 @@ FILE* FastmarchingFuzzyWidget::LoadParams(FILE* fp, int version) { if (version >= 2) { - QObject::disconnect(sl_extend, SIGNAL(valueChanged(int)), this, - SLOT(slextend_changed(int))); - QObject::disconnect(bg_method, SIGNAL(buttonClicked(int)), this, - SLOT(method_changed())); - QObject::disconnect(bg_interact, SIGNAL(buttonClicked(int)), this, - SLOT(interact_changed())); - QObject::disconnect(sb_thresh, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - QObject::disconnect(sb_m1, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - QObject::disconnect(sb_s1, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - QObject::disconnect(sb_s2, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); + disconnect(sl_extend, SIGNAL(valueChanged(int)), this, SLOT(slextend_changed(int))); + disconnect(sb_thresh, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); + disconnect(sb_m1, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); + disconnect(sb_s1, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); + disconnect(sb_s2, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); int dummy; fread(&dummy, sizeof(int), 1, fp); @@ -745,20 +706,11 @@ FILE* FastmarchingFuzzyWidget::LoadParams(FILE* fp, int version) method_changed(); interact_changed(); - QObject::connect(sl_extend, SIGNAL(valueChanged(int)), this, - SLOT(slextend_changed(int))); - QObject::connect(bg_method, SIGNAL(buttonClicked(int)), this, - SLOT(method_changed())); - QObject::connect(bg_interact, SIGNAL(buttonClicked(int)), this, - SLOT(interact_changed())); - QObject::connect(sb_thresh, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - QObject::connect(sb_m1, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - QObject::connect(sb_s1, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); - QObject::connect(sb_s2, SIGNAL(valueChanged(int)), this, - SLOT(spinbox_changed())); + connect(sl_extend, SIGNAL(valueChanged(int)), this, SLOT(slextend_changed(int))); + connect(sb_thresh, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); + connect(sb_m1, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); + connect(sb_s1, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); + connect(sb_s2, SIGNAL(valueChanged(int)), this, SLOT(spinbox_changed())); } return fp; } diff --git a/iSeg/FastmarchingFuzzyWidget.h b/iSeg/FastmarchingFuzzyWidget.h index 50829666..c039ef9a 100755 --- a/iSeg/FastmarchingFuzzyWidget.h +++ b/iSeg/FastmarchingFuzzyWidget.h @@ -11,20 +11,12 @@ #include "Interface/WidgetInterface.h" -#include -#include -#include -#include -#include -#include -#include #include #include #include #include -#include -#include +class QStackedLayout; namespace iseg { @@ -43,7 +35,6 @@ class FastmarchingFuzzyWidget : public WidgetInterface void init() override; void newloaded() override; void cleanup() override; - QSize sizeHint() const override; FILE* SaveParams(FILE* fp, int version) override; FILE* LoadParams(FILE* fp, int version) override; void hideparams_changed() override; @@ -63,40 +54,23 @@ class FastmarchingFuzzyWidget : public WidgetInterface bmphandler* bmphand; SlicesHandler* handler3D; unsigned short activeslice; - Q3HBox* hboxoverall; - Q3VBox* vboxmethods; - Q3HBox* hbox1; - Q3HBox* hbox2; - Q3HBox* hbox3; - Q3HBox* hbox4; - Q3HBox* hbox5; - Q3HBox* hbox7; - Q3VBox* vbox1; - Q3VBox* vboxfast; - Q3VBox* vboxfuzzy; - QLabel* txt_sigma; - QLabel* txt_thresh; - QLabel* txt_m1; - QLabel* txt_s1; - QLabel* txt_s2; - QLabel* txt_extend; + + QStackedLayout* params_stack_layout; QSlider* sl_sigma; QSlider* sl_thresh; - QSlider* sl_m1; - QSlider* sl_s1; - QSlider* sl_s2; - QSlider* sl_extend; QSpinBox* sb_thresh; + QSlider* sl_m1; QSpinBox* sb_m1; + QSlider* sl_s1; QSpinBox* sb_s1; + QSlider* sl_s2; QSpinBox* sb_s2; - // QPushButton *pushexec; + QSlider* sl_extend; QRadioButton* rb_fastmarch; QRadioButton* rb_fuzzy; QRadioButton* rb_drag; QRadioButton* rb_slider; - QButtonGroup* bg_method; - QButtonGroup* bg_interact; + void getrange(); float sigma, thresh, m1, s1, s2; float sigmamax; From e61dbc0484db6673c4d31b6814b954e8703c0205 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 12 Feb 2019 20:26:49 +0100 Subject: [PATCH 11/26] refactor active slices dialog: use QFormLayout, remove Qt3 stuff rename SliceHandlerInterface to SlicesHandlerInterface rename ActiveSlicesConfigWidget to ActiveSlicesConfigDialog --- Core/ImageWriter.cpp | 6 +- Core/ImageWriter.h | 8 +- Core/SmoothTissues.cpp | 8 +- Core/SmoothTissues.h | 4 +- Core/VotingReplaceLabel.cpp | 10 +- Core/VotingReplaceLabel.h | 4 +- Core/testsuite/test_ImageIO.cpp | 2 +- Data/BrushInteraction.cpp | 2 +- Data/BrushInteraction.h | 6 +- Data/CMakeLists.txt | 2 +- ...pper.cpp => SlicesHandlerITKInterface.cpp} | 26 ++--- ...kWrapper.h => SlicesHandlerITKInterface.h} | 14 +-- Data/SlicesHandlerInterface.h | 2 +- Interface/Plugin.cpp | 2 +- Interface/Plugin.h | 8 +- Plugins/BiasCorrection/BiasCorrection.cpp | 10 +- Plugins/BiasCorrection/BiasCorrection.h | 4 +- .../ConfidenceConnected/ConfidenceWidget.cpp | 6 +- .../ConfidenceConnected/ConfidenceWidget.h | 4 +- Plugins/GraphCut/BoneSegmentationWidget.cpp | 10 +- Plugins/GraphCut/BoneSegmentationWidget.h | 4 +- Plugins/GraphCut/TissueSeparatorWidget.cpp | 10 +- Plugins/GraphCut/TissueSeparatorWidget.h | 4 +- Plugins/KalmanFilterTracing/AutoTubePanel.cpp | 18 ++-- Plugins/KalmanFilterTracing/AutoTubePanel.h | 4 +- Plugins/Levelset/LevelsetWidget.cpp | 8 +- Plugins/Levelset/LevelsetWidget.h | 4 +- .../AutoTubeWidget.cpp | 6 +- .../TracingTubularStructures/AutoTubeWidget.h | 4 +- .../TraceTubesWidget.cpp | 16 +-- .../TraceTubesWidget.h | 4 +- iSeg/ActiveSlicesConfigDialog.cpp | 82 ++++++++++++++++ ...figWidget.h => ActiveSlicesConfigDialog.h} | 20 +--- iSeg/ActiveslicesConfigWidget.cpp | 98 ------------------- iSeg/CMakeLists.txt | 4 +- iSeg/EdgeWidget.cpp | 8 +- iSeg/MainWindow.cpp | 4 +- iSeg/OutlineCorrectionParameterViews.cpp | 2 +- iSeg/OutlineCorrectionParameterViews.h | 4 +- iSeg/SlicesHandler.cpp | 22 ++--- iSeg/SlicesHandler.h | 2 +- 41 files changed, 220 insertions(+), 246 deletions(-) rename Data/{SliceHandlerItkWrapper.cpp => SlicesHandlerITKInterface.cpp} (73%) rename Data/{SliceHandlerItkWrapper.h => SlicesHandlerITKInterface.h} (87%) create mode 100755 iSeg/ActiveSlicesConfigDialog.cpp rename iSeg/{ActiveslicesConfigWidget.h => ActiveSlicesConfigDialog.h} (68%) delete mode 100755 iSeg/ActiveslicesConfigWidget.cpp diff --git a/Core/ImageWriter.cpp b/Core/ImageWriter.cpp index cda79af9..def2c02a 100755 --- a/Core/ImageWriter.cpp +++ b/Core/ImageWriter.cpp @@ -13,7 +13,7 @@ #include "VtkGlue/itkImageToVTKImageFilter.h" #include "Data/Logger.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include "Data/Transform.h" #include @@ -30,9 +30,9 @@ using namespace iseg; template -bool ImageWriter::writeVolume(const std::string& filename, const std::vector& all_slices, bool active_slices, const SliceHandlerInterface* handler) +bool ImageWriter::writeVolume(const std::string& filename, const std::vector& all_slices, bool active_slices, const SlicesHandlerInterface* handler) { - auto image = SliceHandlerItkWrapper::GetITKView(all_slices, handler->start_slice(), handler->end_slice(), handler); + auto image = SlicesHandlerITKInterface::GetITKView(all_slices, handler->start_slice(), handler->end_slice(), handler); if (image) { boost::filesystem::path path(filename); diff --git a/Core/ImageWriter.h b/Core/ImageWriter.h index eeabeb7d..21438e2d 100755 --- a/Core/ImageWriter.h +++ b/Core/ImageWriter.h @@ -19,7 +19,7 @@ namespace iseg { -class SliceHandlerInterface; +class SlicesHandlerInterface; /** \brief Image writer based on ITK image writer factory */ @@ -29,16 +29,16 @@ class ImageWriter ImageWriter(bool binary = true) : m_Binary(binary) {} template - bool writeVolume(const std::string& filename, const std::vector& all_slices, bool active_slices, const SliceHandlerInterface* handler); + bool writeVolume(const std::string& filename, const std::vector& all_slices, bool active_slices, const SlicesHandlerInterface* handler); private: bool m_Binary; }; iSegCore_TEMPLATE template ISEG_CORE_API bool ImageWriter::writeVolume( - const std::string& filename, const std::vector& all_slices, bool active_slices, const SliceHandlerInterface* handler); + const std::string& filename, const std::vector& all_slices, bool active_slices, const SlicesHandlerInterface* handler); iSegCore_TEMPLATE template ISEG_CORE_API bool ImageWriter::writeVolume( - const std::string& filename, const std::vector& all_slices, bool active_slices, const SliceHandlerInterface* handler); + const std::string& filename, const std::vector& all_slices, bool active_slices, const SlicesHandlerInterface* handler); } // namespace iseg diff --git a/Core/SmoothTissues.cpp b/Core/SmoothTissues.cpp index 20d36b20..71ca2c78 100644 --- a/Core/SmoothTissues.cpp +++ b/Core/SmoothTissues.cpp @@ -12,7 +12,7 @@ #include "SmoothTissues.h" #include "../Data/ItkUtils.h" -#include "../Data/SliceHandlerItkWrapper.h" +#include "../Data/SlicesHandlerITKInterface.h" #include #include @@ -105,14 +105,14 @@ bool _SmoothTissues(TInput* tissues, const std::vector& locks, double sigm return ok; } -bool SmoothTissues(SliceHandlerInterface* handler, size_t start_slice, size_t end_slice, double sigma, bool smooth3d) +bool SmoothTissues(SlicesHandlerInterface* handler, size_t start_slice, size_t end_slice, double sigma, bool smooth3d) { - SliceHandlerItkWrapper itkhandler(handler); + SlicesHandlerITKInterface itkhandler(handler); auto locks = handler->tissue_locks(); if (smooth3d) { - using label_image_type = SliceHandlerItkWrapper::tissues_ref_type; + using label_image_type = SlicesHandlerITKInterface::tissues_ref_type; auto tissues = itkhandler.GetTissues(start_slice, end_slice); diff --git a/Core/SmoothTissues.h b/Core/SmoothTissues.h index 1fa737be..43cdeb41 100644 --- a/Core/SmoothTissues.h +++ b/Core/SmoothTissues.h @@ -17,8 +17,8 @@ namespace iseg { -class SliceHandlerInterface; +class SlicesHandlerInterface; -ISEG_CORE_API bool SmoothTissues(SliceHandlerInterface* handler, size_t start_slice, size_t end_slice, double sigma, bool smooth3d); +ISEG_CORE_API bool SmoothTissues(SlicesHandlerInterface* handler, size_t start_slice, size_t end_slice, double sigma, bool smooth3d); } // namespace iseg diff --git a/Core/VotingReplaceLabel.cpp b/Core/VotingReplaceLabel.cpp index 402f9d9d..e51b0b69 100755 --- a/Core/VotingReplaceLabel.cpp +++ b/Core/VotingReplaceLabel.cpp @@ -14,13 +14,13 @@ #include "itkLabelVotingBinaryImageFilter.h" #include "../Data/ItkUtils.h" -#include "../Data/SliceHandlerItkWrapper.h" +#include "../Data/SlicesHandlerITKInterface.h" #include namespace iseg { -size_t VotingReplaceLabel(SliceHandlerInterface* handler, +size_t VotingReplaceLabel(SlicesHandlerInterface* handler, tissues_size_t foreground, tissues_size_t background, std::array iradius, @@ -30,10 +30,10 @@ size_t VotingReplaceLabel(SliceHandlerInterface* handler, using image_type = itk::Image; using voting_filter_type = itk::LabelVotingBinaryImageFilter; - SliceHandlerItkWrapper itkhandler(handler); + SlicesHandlerITKInterface itkhandler(handler); auto tissues = itkhandler.GetTissues(true); - auto cast = itk::CastImageFilter::New(); + auto cast = itk::CastImageFilter::New(); cast->SetInput(tissues); cast->Update(); auto input = cast->GetOutput(); @@ -83,7 +83,7 @@ size_t VotingReplaceLabel(SliceHandlerInterface* handler, } // paste into output - iseg::Paste(output, tissues); + iseg::Paste(output, tissues); return number_remaining; } diff --git a/Core/VotingReplaceLabel.h b/Core/VotingReplaceLabel.h index 9e43f6c6..d9443a1e 100755 --- a/Core/VotingReplaceLabel.h +++ b/Core/VotingReplaceLabel.h @@ -17,9 +17,9 @@ namespace iseg { -class SliceHandlerInterface; +class SlicesHandlerInterface; -ISEG_CORE_API size_t VotingReplaceLabel(SliceHandlerInterface* handler, tissues_size_t foreground, tissues_size_t background, +ISEG_CORE_API size_t VotingReplaceLabel(SlicesHandlerInterface* handler, tissues_size_t foreground, tissues_size_t background, std::array iradius, unsigned int majority_threshold, unsigned int max_iterations); } // namespace iseg diff --git a/Core/testsuite/test_ImageIO.cpp b/Core/testsuite/test_ImageIO.cpp index 0708d789..0d15c177 100755 --- a/Core/testsuite/test_ImageIO.cpp +++ b/Core/testsuite/test_ImageIO.cpp @@ -28,7 +28,7 @@ namespace iseg { namespace { -class TestHandler : public SliceHandlerInterface +class TestHandler : public SlicesHandlerInterface { unsigned short _dims[3]; unsigned short _start; diff --git a/Data/BrushInteraction.cpp b/Data/BrushInteraction.cpp index 797d5645..f6c11a81 100644 --- a/Data/BrushInteraction.cpp +++ b/Data/BrushInteraction.cpp @@ -5,7 +5,7 @@ namespace iseg { -void BrushInteraction::init(iseg::SliceHandlerInterface* handler) +void BrushInteraction::init(iseg::SlicesHandlerInterface* handler) { if (handler == nullptr) throw std::runtime_error("null slice handler"); diff --git a/Data/BrushInteraction.h b/Data/BrushInteraction.h index 5fb13f39..cd58c823 100644 --- a/Data/BrushInteraction.h +++ b/Data/BrushInteraction.h @@ -22,7 +22,7 @@ namespace iseg { class ISEG_DATA_API BrushInteraction { public: - BrushInteraction(SliceHandlerInterface* handler, + BrushInteraction(SlicesHandlerInterface* handler, const boost::function& begin, const boost::function& end, const boost::function*)>& vpdynchanged) @@ -34,7 +34,7 @@ namespace iseg { } /// throws std::runtime_error if handler is invalid - void init(SliceHandlerInterface* handler); + void init(SlicesHandlerInterface* handler); void set_radius(float radius) { _radius = radius; } void set_brush_target(bool on) { _brush_target = on; } @@ -54,7 +54,7 @@ namespace iseg { boost::function end_datachange; boost::function*)> vpdyn_changed; - SliceHandlerInterface* _slice_handler; + SlicesHandlerInterface* _slice_handler; std::vector _cached_tissue_locks; unsigned _width; unsigned _height; diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index 7dabf6c9..83a9e818 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -19,7 +19,7 @@ SET(SOURCES Color.cpp ItkProgressObserver.cpp LogApi.cpp - SliceHandlerItkWrapper.cpp + SlicesHandlerITKInterface.cpp Transform.cpp ) diff --git a/Data/SliceHandlerItkWrapper.cpp b/Data/SlicesHandlerITKInterface.cpp similarity index 73% rename from Data/SliceHandlerItkWrapper.cpp rename to Data/SlicesHandlerITKInterface.cpp index c7975222..8c5294af 100644 --- a/Data/SliceHandlerItkWrapper.cpp +++ b/Data/SlicesHandlerITKInterface.cpp @@ -1,10 +1,10 @@ -#include "SliceHandlerItkWrapper.h" +#include "SlicesHandlerITKInterface.h" #include namespace iseg { -itk::SliceContiguousImage::Pointer SliceHandlerItkWrapper::GetSource(bool active_slices) +itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetSource(bool active_slices) { if (active_slices) return GetSource(_handler->start_slice(), _handler->end_slice()); @@ -12,12 +12,12 @@ itk::SliceContiguousImage::Pointer SliceHandlerItkWrapper::GetSource(bool return GetSource(0, _handler->num_slices()); } -itk::SliceContiguousImage::Pointer SliceHandlerItkWrapper::GetSource(size_t start_slice, size_t end_slice) +itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetSource(size_t start_slice, size_t end_slice) { return GetITKView(_handler->source_slices(), start_slice, end_slice, _handler); } -itk::SliceContiguousImage::Pointer SliceHandlerItkWrapper::GetTarget(bool active_slices) +itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetTarget(bool active_slices) { if (active_slices) return GetTarget(_handler->start_slice(), _handler->end_slice()); @@ -25,12 +25,12 @@ itk::SliceContiguousImage::Pointer SliceHandlerItkWrapper::GetTarget(bool return GetTarget(0, _handler->num_slices()); } -itk::SliceContiguousImage::Pointer SliceHandlerItkWrapper::GetTarget(size_t start_slice, size_t end_slice) +itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetTarget(size_t start_slice, size_t end_slice) { return GetITKView(_handler->target_slices(), start_slice, end_slice, _handler); } -itk::SliceContiguousImage::Pointer SliceHandlerItkWrapper::GetTissues(bool active_slices) +itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetTissues(bool active_slices) { if (active_slices) return GetTissues(_handler->start_slice(), _handler->end_slice()); @@ -38,7 +38,7 @@ itk::SliceContiguousImage::Pointer SliceHandlerItkWrapper::GetTi return GetTissues(0, _handler->num_slices()); } -itk::SliceContiguousImage::Pointer SliceHandlerItkWrapper::GetTissues(size_t start_slice, size_t end_slice) +itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetTissues(size_t start_slice, size_t end_slice) { auto all_slices = _handler->tissue_slices(_handler->active_tissuelayer()); return GetITKView(all_slices, start_slice, end_slice, _handler); @@ -68,7 +68,7 @@ typename itk::Image::Pointer _GetITKView2D(T* slice, size_t dims[2], double s return image; } -itk::Image::Pointer SliceHandlerItkWrapper::GetSourceSlice(int slice) +itk::Image::Pointer SlicesHandlerITKInterface::GetSourceSlice(int slice) { size_t dims[2] = { _handler->width(), @@ -81,7 +81,7 @@ itk::Image::Pointer SliceHandlerItkWrapper::GetSourceSlice(int slice) return _GetITKView2D(all_slices.at(slice), dims, spacing); } -itk::Image::Pointer SliceHandlerItkWrapper::GetTargetSlice(int slice) +itk::Image::Pointer SlicesHandlerITKInterface::GetTargetSlice(int slice) { size_t dims[2] = { _handler->width(), @@ -94,7 +94,7 @@ itk::Image::Pointer SliceHandlerItkWrapper::GetTargetSlice(int slice) return _GetITKView2D(all_slices.at(slice), dims, spacing); } -itk::Image::Pointer SliceHandlerItkWrapper::GetTissuesSlice(int slice) +itk::Image::Pointer SlicesHandlerITKInterface::GetTissuesSlice(int slice) { size_t dims[2] = { _handler->width(), @@ -107,14 +107,14 @@ itk::Image::Pointer SliceHandlerItkWrapper::GetTissuesSlice(i return _GetITKView2D(all_slices.at(slice), dims, spacing); } -itk::ImageRegion<3> SliceHandlerItkWrapper::GetActiveRegion() const +itk::ImageRegion<3> SlicesHandlerITKInterface::GetActiveRegion() const { itk::Index<3> start = {0, 0, _handler->start_slice()}; itk::Size<3> size = {_handler->width(), _handler->height(), static_cast(_handler->end_slice() - _handler->start_slice())}; return itk::ImageRegion<3>(start, size); } -itk::Image::Pointer SliceHandlerItkWrapper::GetImageDeprecated(eImageType type, bool active_slices) +itk::Image::Pointer SlicesHandlerITKInterface::GetImageDeprecated(eImageType type, bool active_slices) { using input_image = itk::SliceContiguousImage; using output_image = itk::Image; @@ -125,7 +125,7 @@ itk::Image::Pointer SliceHandlerItkWrapper::GetImageDeprecated(eImageT return cast->GetOutput(); } -itk::Image::Pointer SliceHandlerItkWrapper::GetTissuesDeprecated(bool active_slices) +itk::Image::Pointer SlicesHandlerITKInterface::GetTissuesDeprecated(bool active_slices) { using input_image = itk::SliceContiguousImage; using output_image = itk::Image; diff --git a/Data/SliceHandlerItkWrapper.h b/Data/SlicesHandlerITKInterface.h similarity index 87% rename from Data/SliceHandlerItkWrapper.h rename to Data/SlicesHandlerITKInterface.h index 291c7931..42343c86 100644 --- a/Data/SliceHandlerItkWrapper.h +++ b/Data/SlicesHandlerITKInterface.h @@ -19,19 +19,19 @@ namespace iseg { -class ISEG_DATA_API SliceHandlerItkWrapper +class ISEG_DATA_API SlicesHandlerITKInterface { public: - using pixel_type = SliceHandlerInterface::pixel_type; - using tissue_type = SliceHandlerInterface::tissue_type; + using pixel_type = SlicesHandlerInterface::pixel_type; + using tissue_type = SlicesHandlerInterface::tissue_type; using image_ref_type = itk::SliceContiguousImage; using tissues_ref_type = itk::SliceContiguousImage; - SliceHandlerItkWrapper(SliceHandlerInterface* sh) : _handler(sh) {} + SlicesHandlerITKInterface(SlicesHandlerInterface* sh) : _handler(sh) {} template - static typename itk::SliceContiguousImage::Pointer GetITKView(const std::vector& all_slices, size_t start_slice, size_t end_slice, const SliceHandlerInterface* handler); + static typename itk::SliceContiguousImage::Pointer GetITKView(const std::vector& all_slices, size_t start_slice, size_t end_slice, const SlicesHandlerInterface* handler); itk::SliceContiguousImage::Pointer GetSource(bool active_slices); itk::SliceContiguousImage::Pointer GetSource(size_t start_slice, size_t end_slice); @@ -57,12 +57,12 @@ class ISEG_DATA_API SliceHandlerItkWrapper itk::Image::Pointer GetTissuesDeprecated(bool active_slices); private: - SliceHandlerInterface* _handler; + SlicesHandlerInterface* _handler; }; template typename itk::SliceContiguousImage::Pointer - SliceHandlerItkWrapper::GetITKView(const std::vector& all_slices, size_t start_slice, size_t end_slice, const SliceHandlerInterface* handler) + SlicesHandlerITKInterface::GetITKView(const std::vector& all_slices, size_t start_slice, size_t end_slice, const SlicesHandlerInterface* handler) { using SliceContiguousImageType = itk::SliceContiguousImage; diff --git a/Data/SlicesHandlerInterface.h b/Data/SlicesHandlerInterface.h index 7a3c94b1..8a27d1aa 100644 --- a/Data/SlicesHandlerInterface.h +++ b/Data/SlicesHandlerInterface.h @@ -17,7 +17,7 @@ namespace iseg { -class SliceHandlerInterface +class SlicesHandlerInterface { public: typedef tissues_size_t tissue_type; diff --git a/Interface/Plugin.cpp b/Interface/Plugin.cpp index 791b7e9b..9a72585a 100755 --- a/Interface/Plugin.cpp +++ b/Interface/Plugin.cpp @@ -22,7 +22,7 @@ Plugin::Plugin() { _addons.push_back(this); } Plugin::~Plugin() {} -void Plugin::install_slice_handler(SliceHandlerInterface* slice_handler) +void Plugin::install_slice_handler(SlicesHandlerInterface* slice_handler) { _slice_handler = slice_handler; } diff --git a/Interface/Plugin.h b/Interface/Plugin.h index 26359cd8..ee9b59d5 100755 --- a/Interface/Plugin.h +++ b/Interface/Plugin.h @@ -19,7 +19,7 @@ #include namespace iseg { -class SliceHandlerInterface; +class SlicesHandlerInterface; } namespace iseg { namespace plugin { @@ -30,8 +30,8 @@ class ISEG_INTERFACE_API Plugin Plugin(); ~Plugin(); - void install_slice_handler(SliceHandlerInterface* slice_handler); - SliceHandlerInterface* slice_handler() const { return _slice_handler; } + void install_slice_handler(SlicesHandlerInterface* slice_handler); + SlicesHandlerInterface* slice_handler() const { return _slice_handler; } virtual std::string name() const = 0; @@ -41,7 +41,7 @@ class ISEG_INTERFACE_API Plugin const char* name, Qt::WindowFlags wFlags) const = 0; private: - SliceHandlerInterface* _slice_handler; + SlicesHandlerInterface* _slice_handler; }; class ISEG_INTERFACE_API PluginRegistry diff --git a/Plugins/BiasCorrection/BiasCorrection.cpp b/Plugins/BiasCorrection/BiasCorrection.cpp index 9e4edf34..0140aaba 100755 --- a/Plugins/BiasCorrection/BiasCorrection.cpp +++ b/Plugins/BiasCorrection/BiasCorrection.cpp @@ -9,7 +9,7 @@ */ #include "BiasCorrection.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include "Data/ItkUtils.h" #include @@ -105,7 +105,7 @@ typename ImageType::Pointer AllocImage( } // namespace -BiasCorrectionWidget::BiasCorrectionWidget(iseg::SliceHandlerInterface* hand3D, +BiasCorrectionWidget::BiasCorrectionWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), handler3D(hand3D), @@ -149,8 +149,8 @@ void BiasCorrectionWidget::do_work() { typedef itk::Image InputImageType; - iseg::SliceHandlerItkWrapper wrapper(handler3D); - InputImageType::Pointer input = wrapper.GetImageDeprecated(iseg::SliceHandlerItkWrapper::kSource, true); + iseg::SlicesHandlerITKInterface wrapper(handler3D); + InputImageType::Pointer input = wrapper.GetImageDeprecated(iseg::SlicesHandlerITKInterface::kSource, true); //Ensure that it is a 3D image for the 3D image filter ! Else it does nothing if (input->GetLargestPossibleRegion().GetSize(2) > 1) @@ -176,7 +176,7 @@ void BiasCorrectionWidget::do_work() dataSelection.bmp = true; emit begin_datachange(dataSelection, this); - iseg::Paste(output, source); + iseg::Paste(output, source); emit end_datachange(this); } diff --git a/Plugins/BiasCorrection/BiasCorrection.h b/Plugins/BiasCorrection/BiasCorrection.h index 0d0e516b..d7719ad7 100755 --- a/Plugins/BiasCorrection/BiasCorrection.h +++ b/Plugins/BiasCorrection/BiasCorrection.h @@ -29,7 +29,7 @@ class BiasCorrectionWidget : public iseg::WidgetInterface { Q_OBJECT public: - BiasCorrectionWidget(iseg::SliceHandlerInterface* hand3D, QWidget* parent = 0, + BiasCorrectionWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); ~BiasCorrectionWidget(); @@ -47,7 +47,7 @@ class BiasCorrectionWidget : public iseg::WidgetInterface const std::vector& numIters, int shrinkFactor, double convergenceThreshold); - iseg::SliceHandlerInterface* handler3D; + iseg::SlicesHandlerInterface* handler3D; unsigned short activeslice; Q3VBox* vbox1; QLabel* bias_header; diff --git a/Plugins/ConfidenceConnected/ConfidenceWidget.cpp b/Plugins/ConfidenceConnected/ConfidenceWidget.cpp index e1023502..3eaf82c4 100644 --- a/Plugins/ConfidenceConnected/ConfidenceWidget.cpp +++ b/Plugins/ConfidenceConnected/ConfidenceWidget.cpp @@ -10,7 +10,7 @@ #include "ConfidenceWidget.h" #include "Data/ItkUtils.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include #include @@ -21,7 +21,7 @@ #include #include -ConfidenceWidget::ConfidenceWidget(iseg::SliceHandlerInterface* hand3D, QWidget* parent, +ConfidenceWidget::ConfidenceWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), handler3D(hand3D) { @@ -133,7 +133,7 @@ void ConfidenceWidget::get_seeds(std::vector>& seeds) void ConfidenceWidget::do_work() { - iseg::SliceHandlerItkWrapper itk_handler(handler3D); + iseg::SlicesHandlerITKInterface itk_handler(handler3D); if (all_slices->isChecked()) { using input_type = itk::SliceContiguousImage; diff --git a/Plugins/ConfidenceConnected/ConfidenceWidget.h b/Plugins/ConfidenceConnected/ConfidenceWidget.h index 4b2f2e0b..251cc1b7 100644 --- a/Plugins/ConfidenceConnected/ConfidenceWidget.h +++ b/Plugins/ConfidenceConnected/ConfidenceWidget.h @@ -26,7 +26,7 @@ class ConfidenceWidget : public iseg::WidgetInterface { Q_OBJECT public: - ConfidenceWidget(iseg::SliceHandlerInterface* hand3D, QWidget* parent = 0, + ConfidenceWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); ~ConfidenceWidget() {} void init() override; @@ -46,7 +46,7 @@ class ConfidenceWidget : public iseg::WidgetInterface void get_seeds(std::vector>&); private: - iseg::SliceHandlerInterface* handler3D; + iseg::SlicesHandlerInterface* handler3D; unsigned short activeslice; QCheckBox* all_slices; diff --git a/Plugins/GraphCut/BoneSegmentationWidget.cpp b/Plugins/GraphCut/BoneSegmentationWidget.cpp index 62717cf3..c5a66276 100755 --- a/Plugins/GraphCut/BoneSegmentationWidget.cpp +++ b/Plugins/GraphCut/BoneSegmentationWidget.cpp @@ -12,7 +12,7 @@ #include "ImageGraphCut3DFilter.h" #include "Data/ItkUtils.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include #include @@ -68,7 +68,7 @@ class CommandProgressUpdate : public itk::Command } // namespace BoneSegmentationWidget::BoneSegmentationWidget( - iseg::SliceHandlerInterface* hand3D, QWidget* parent, const char* name, + iseg::SlicesHandlerInterface* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), m_Handler3D(hand3D), m_CurrentFilter(nullptr) @@ -155,8 +155,8 @@ void BoneSegmentationWidget::do_work() typedef itk::ImageGraphCutFilter GraphCutFilterType; // get input image - iseg::SliceHandlerItkWrapper itk_wrapper(m_Handler3D); - auto input = itk_wrapper.GetImageDeprecated(iseg::SliceHandlerItkWrapper::kSource, m_UseSliceRange->isChecked()); + iseg::SlicesHandlerITKInterface itk_wrapper(m_Handler3D); + auto input = itk_wrapper.GetImageDeprecated(iseg::SlicesHandlerITKInterface::kSource, m_UseSliceRange->isChecked()); assert(m_MaxFlowAlgorithm->currentItem() > 0); @@ -196,7 +196,7 @@ void BoneSegmentationWidget::do_work() dataSelection.work = true; emit begin_datachange(dataSelection, this); - iseg::Paste(output, target); + iseg::Paste(output, target); emit end_datachange(this); } diff --git a/Plugins/GraphCut/BoneSegmentationWidget.h b/Plugins/GraphCut/BoneSegmentationWidget.h index 5cf88bbc..f0fa9d88 100755 --- a/Plugins/GraphCut/BoneSegmentationWidget.h +++ b/Plugins/GraphCut/BoneSegmentationWidget.h @@ -27,7 +27,7 @@ class BoneSegmentationWidget : public iseg::WidgetInterface { Q_OBJECT public: - BoneSegmentationWidget(iseg::SliceHandlerInterface* hand3D, + BoneSegmentationWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); ~BoneSegmentationWidget(); QSize sizeHint() const override; @@ -39,7 +39,7 @@ class BoneSegmentationWidget : public iseg::WidgetInterface private: void on_slicenr_changed() override; - iseg::SliceHandlerInterface* m_Handler3D; + iseg::SlicesHandlerInterface* m_Handler3D; unsigned short m_CurrentSlice; Q3VBox* m_VGrid; Q3HBox* m_HGrid1; diff --git a/Plugins/GraphCut/TissueSeparatorWidget.cpp b/Plugins/GraphCut/TissueSeparatorWidget.cpp index 9cc016f1..89847bc3 100755 --- a/Plugins/GraphCut/TissueSeparatorWidget.cpp +++ b/Plugins/GraphCut/TissueSeparatorWidget.cpp @@ -14,7 +14,7 @@ #include "Data/LogApi.h" #include "Data/ItkUtils.h" #include "Data/addLine.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include @@ -29,7 +29,7 @@ using namespace iseg; TissueSeparatorWidget::TissueSeparatorWidget( - iseg::SliceHandlerInterface* hand3D, QWidget* parent, const char* name, + iseg::SlicesHandlerInterface* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), slice_handler(hand3D) { @@ -182,7 +182,7 @@ void TissueSeparatorWidget::do_work_all_slices() using source_type = itk::SliceContiguousImage; using mask_type = itk::Image; - SliceHandlerItkWrapper wrapper(slice_handler); + SlicesHandlerITKInterface wrapper(slice_handler); auto source = wrapper.GetSource(false); auto target = wrapper.GetTarget(false); @@ -217,7 +217,7 @@ void TissueSeparatorWidget::do_work_current_slice() { using source_type = itk::Image; - SliceHandlerItkWrapper wrapper(slice_handler); + SlicesHandlerITKInterface wrapper(slice_handler); auto source = wrapper.GetSourceSlice(); auto target = wrapper.GetTargetSlice(); @@ -238,7 +238,7 @@ template typename itk::Image::Pointer TissueSeparatorWidget::do_work(TInput* source, TInput* target, const typename itk::Image::RegionType& requested_region) { - using tissue_value_type = SliceHandlerInterface::tissue_type; + using tissue_value_type = SlicesHandlerInterface::tissue_type; tissue_value_type const OBJECT_1 = 127; tissue_value_type const OBJECT_2 = 255; bool has_sigma; diff --git a/Plugins/GraphCut/TissueSeparatorWidget.h b/Plugins/GraphCut/TissueSeparatorWidget.h index b0d4268e..87368f75 100755 --- a/Plugins/GraphCut/TissueSeparatorWidget.h +++ b/Plugins/GraphCut/TissueSeparatorWidget.h @@ -25,7 +25,7 @@ class TissueSeparatorWidget : public iseg::WidgetInterface { Q_OBJECT public: - TissueSeparatorWidget(iseg::SliceHandlerInterface* hand3D, + TissueSeparatorWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); ~TissueSeparatorWidget() {} @@ -55,7 +55,7 @@ private slots: typename itk::Image::Pointer do_work(TInput* source, TInput* target, const typename itk::Image::RegionType& requested_region); - iseg::SliceHandlerInterface* slice_handler; + iseg::SlicesHandlerInterface* slice_handler; unsigned current_slice; unsigned tissuenr; iseg::Point last_pt; diff --git a/Plugins/KalmanFilterTracing/AutoTubePanel.cpp b/Plugins/KalmanFilterTracing/AutoTubePanel.cpp index 9b97f302..79b89f29 100644 --- a/Plugins/KalmanFilterTracing/AutoTubePanel.cpp +++ b/Plugins/KalmanFilterTracing/AutoTubePanel.cpp @@ -9,7 +9,7 @@ #include "Data/ItkUtils.h" #include "Data/Logger.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include "Core/Morpho.h" @@ -70,7 +70,7 @@ typedef unsigned long LabelType; typedef itk::ShapeLabelObject LabelObjectType; typedef itk::LabelMap LabelMapType; -AutoTubePanel::AutoTubePanel(iseg::SliceHandlerInterface* hand3D, QWidget* parent, +AutoTubePanel::AutoTubePanel(iseg::SlicesHandlerInterface* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), _handler3D(hand3D) { @@ -432,14 +432,14 @@ void AutoTubePanel::add_to_tissues() for (auto filter : k_filters) labels.push_back(filter.get_label()); - iseg::SliceHandlerItkWrapper itk_handler(_handler3D); + iseg::SlicesHandlerITKInterface itk_handler(_handler3D); auto tissue_names = _handler3D->tissue_names(); // shallow copy - used to transform index to world coordinates auto image_3d = itk_handler.GetSource(false); typedef float PixelType; - using tissue_type = SliceHandlerInterface::tissue_type; + using tissue_type = SlicesHandlerInterface::tissue_type; using ImageType = itk::Image; using ConstIteratorType = itk::ImageRegionConstIterator; using IteratorType = itk::ImageRegionIterator>; @@ -1849,7 +1849,7 @@ void AutoTubePanel::extrapolate_results() max_active_slice_reached = _handler3D->active_slice(); // preparing data for do_work_nd -> function of Execute button which will save a new label map in label_maps[_handler3D->active_slice()] - iseg::SliceHandlerItkWrapper itk_handler(_handler3D); + iseg::SlicesHandlerITKInterface itk_handler(_handler3D); using input_type = itk::Image; using tissues_type = itk::Image; @@ -2340,7 +2340,7 @@ void AutoTubePanel::do_work() { // function for Execute Button - iseg::SliceHandlerItkWrapper itk_handler(_handler3D); + iseg::SlicesHandlerITKInterface itk_handler(_handler3D); using input_type = itk::Image; using tissues_type = itk::Image; auto source = itk_handler.GetSourceSlice(); @@ -2386,7 +2386,7 @@ void AutoTubePanel::visualize_label_map(LabelMapType::Pointer labelMap, std::vec typedef float PixelType; using ImageType = itk::Image; - iseg::SliceHandlerItkWrapper itk_handler(_handler3D); + iseg::SlicesHandlerITKInterface itk_handler(_handler3D); auto target = itk_handler.GetTargetSlice(); typedef itk::LabelMapToLabelImageFilter Label2ImageType; @@ -2394,7 +2394,7 @@ void AutoTubePanel::visualize_label_map(LabelMapType::Pointer labelMap, std::vec label2image->SetInput(labelMap); SAFE_UPDATE(label2image, return ); - using tissue_type = SliceHandlerInterface::tissue_type; + using tissue_type = SlicesHandlerInterface::tissue_type; iseg::DataSelection dataSelection; dataSelection.allSlices = false; // all_slices->isChecked(); dataSelection.sliceNr = _handler3D->active_slice(); @@ -2571,7 +2571,7 @@ void AutoTubePanel::do_work_nd(TInput* source, TTissue* tissues, TTarget* target binaryImageToLabelMapFilter->SetFullyConnected(false); SAFE_UPDATE(binaryImageToLabelMapFilter, return ); - iseg::SliceHandlerItkWrapper itk_handler(_handler3D); + iseg::SlicesHandlerITKInterface itk_handler(_handler3D); std::vector label_object_list; auto labelMap = binaryImageToLabelMapFilter->GetOutput(); diff --git a/Plugins/KalmanFilterTracing/AutoTubePanel.h b/Plugins/KalmanFilterTracing/AutoTubePanel.h index 681f5365..c7c13678 100644 --- a/Plugins/KalmanFilterTracing/AutoTubePanel.h +++ b/Plugins/KalmanFilterTracing/AutoTubePanel.h @@ -67,7 +67,7 @@ class AutoTubePanel : public iseg::WidgetInterface Q_OBJECT public: - AutoTubePanel(iseg::SliceHandlerInterface* hand3D, QWidget* parent = 0, + AutoTubePanel(iseg::SlicesHandlerInterface* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); ~AutoTubePanel() {} @@ -119,7 +119,7 @@ class AutoTubePanel : public iseg::WidgetInterface void on_slicenr_changed() override; void on_mouse_clicked(iseg::Point p) override; - iseg::SliceHandlerInterface* _handler3D; + iseg::SlicesHandlerInterface* _handler3D; QListWidget* object_list; QListWidget* object_probability_list; diff --git a/Plugins/Levelset/LevelsetWidget.cpp b/Plugins/Levelset/LevelsetWidget.cpp index 5ea07428..4e1d71e5 100644 --- a/Plugins/Levelset/LevelsetWidget.cpp +++ b/Plugins/Levelset/LevelsetWidget.cpp @@ -11,7 +11,7 @@ #include "Data/Logger.h" #include "Data/ItkUtils.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include #include @@ -35,7 +35,7 @@ namespace acc = boost::accumulators; -LevelsetWidget::LevelsetWidget(iseg::SliceHandlerInterface* hand3D, QWidget* parent, +LevelsetWidget::LevelsetWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), handler3D(hand3D) { @@ -159,7 +159,7 @@ void LevelsetWidget::get_seeds(std::vector>& seeds) void LevelsetWidget::guess_thresholds() { - iseg::SliceHandlerItkWrapper itk_handler(handler3D); + iseg::SlicesHandlerITKInterface itk_handler(handler3D); if (all_slices->isChecked()) { using input_type = itk::SliceContiguousImage; @@ -219,7 +219,7 @@ void LevelsetWidget::guess_thresholds_nd(TInput* source) void LevelsetWidget::do_work() { - iseg::SliceHandlerItkWrapper itk_handler(handler3D); + iseg::SlicesHandlerITKInterface itk_handler(handler3D); if (all_slices->isChecked()) { using input_type = itk::SliceContiguousImage; diff --git a/Plugins/Levelset/LevelsetWidget.h b/Plugins/Levelset/LevelsetWidget.h index 565f9870..9705d15e 100644 --- a/Plugins/Levelset/LevelsetWidget.h +++ b/Plugins/Levelset/LevelsetWidget.h @@ -25,7 +25,7 @@ class LevelsetWidget : public iseg::WidgetInterface { Q_OBJECT public: - LevelsetWidget(iseg::SliceHandlerInterface* hand3D, QWidget* parent = 0, + LevelsetWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); ~LevelsetWidget() {} void init() override; @@ -47,7 +47,7 @@ class LevelsetWidget : public iseg::WidgetInterface template void guess_thresholds_nd(TInput* source); - iseg::SliceHandlerInterface* handler3D; + iseg::SlicesHandlerInterface* handler3D; unsigned short activeslice; QCheckBox* all_slices; diff --git a/Plugins/TracingTubularStructures/AutoTubeWidget.cpp b/Plugins/TracingTubularStructures/AutoTubeWidget.cpp index ed9ae09b..0429b70a 100644 --- a/Plugins/TracingTubularStructures/AutoTubeWidget.cpp +++ b/Plugins/TracingTubularStructures/AutoTubeWidget.cpp @@ -11,7 +11,7 @@ #include "Data/ItkUtils.h" #include "Data/Logger.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include "itkBinaryThinningImageFilter3D.h" #include "itkNonMaxSuppressionImageFilter.h" @@ -66,7 +66,7 @@ class BinaryThinningImageFilter : public itk::Bina { }; -AutoTubeWidget::AutoTubeWidget(iseg::SliceHandlerInterface* hand3D, QWidget* parent, +AutoTubeWidget::AutoTubeWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), _handler3D(hand3D) { @@ -170,7 +170,7 @@ void AutoTubeWidget::select_objects() void AutoTubeWidget::do_work() { - iseg::SliceHandlerItkWrapper itk_handler(_handler3D); + iseg::SlicesHandlerITKInterface itk_handler(_handler3D); try { if (true) //(all_slices->isChecked()) diff --git a/Plugins/TracingTubularStructures/AutoTubeWidget.h b/Plugins/TracingTubularStructures/AutoTubeWidget.h index 5d4e5064..6ffd1c53 100644 --- a/Plugins/TracingTubularStructures/AutoTubeWidget.h +++ b/Plugins/TracingTubularStructures/AutoTubeWidget.h @@ -25,7 +25,7 @@ class AutoTubeWidget : public iseg::WidgetInterface { Q_OBJECT public: - AutoTubeWidget(iseg::SliceHandlerInterface* hand3D, QWidget* parent = 0, + AutoTubeWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); ~AutoTubeWidget() {} void init() override; @@ -47,7 +47,7 @@ class AutoTubeWidget : public iseg::WidgetInterface template typename TImage::Pointer compute_feature_image_2d(TInput* source) const; - iseg::SliceHandlerInterface* _handler3D; + iseg::SlicesHandlerInterface* _handler3D; QLineEdit* _sigma_low; QLineEdit* _sigma_hi; diff --git a/Plugins/TracingTubularStructures/TraceTubesWidget.cpp b/Plugins/TracingTubularStructures/TraceTubesWidget.cpp index d1fefd4a..2572d40b 100644 --- a/Plugins/TracingTubularStructures/TraceTubesWidget.cpp +++ b/Plugins/TracingTubularStructures/TraceTubesWidget.cpp @@ -14,7 +14,7 @@ #include "Data/BrushInteraction.h" #include "Data/ItkUtils.h" #include "Data/LogApi.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include #include @@ -76,7 +76,7 @@ void add_completer(QLineEdit* file_path, QWidget* parent) } } // namespace -TraceTubesWidget::TraceTubesWidget(iseg::SliceHandlerInterface* hand3D, +TraceTubesWidget::TraceTubesWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), _handler(hand3D) @@ -313,7 +313,7 @@ itk::Image::Pointer TraceTubesWidget::compute_vesselness(const itk::Im double beta = _beta->text().toDouble(); double gamma = _gamma->text().toDouble(); - iseg::SliceHandlerItkWrapper itk_handler(_handler); + iseg::SlicesHandlerITKInterface itk_handler(_handler); auto source = itk_handler.GetSource(true); auto hessian_filter = hessian_filter_type::New(); @@ -352,7 +352,7 @@ itk::Image::Pointer TraceTubesWidget::compute_blobiness(const itk::Ima double beta = _beta->text().toDouble(); double gamma = _gamma->text().toDouble(); - iseg::SliceHandlerItkWrapper itk_handler(_handler); + iseg::SlicesHandlerITKInterface itk_handler(_handler); auto source = itk_handler.GetSource(true); auto hessian_filter = hessian_filter_type::New(); @@ -379,7 +379,7 @@ itk::Image::Pointer TraceTubesWidget::compute_blobiness(const itk::Ima itk::Image::Pointer TraceTubesWidget::compute_object_sdf(const itk::ImageBase<3>::RegionType& requested_region) const { - iseg::SliceHandlerItkWrapper itk_handler(_handler); + iseg::SlicesHandlerITKInterface itk_handler(_handler); auto target = itk_handler.GetTarget(true); using input_type = itk::SliceContiguousImage; @@ -428,7 +428,7 @@ void TraceTubesWidget::estimate_intensity() { using image_type = itk::Image; - iseg::SliceHandlerItkWrapper itk_handler(_handler); + iseg::SlicesHandlerITKInterface itk_handler(_handler); auto source = itk_handler.GetSource(true); double intensity = 0.0; @@ -482,7 +482,7 @@ void TraceTubesWidget::do_work() int pad = get_padding(); auto export_file_path = _debug_metric_file_path->text().toStdString(); - iseg::SliceHandlerItkWrapper itk_handler(_handler); + iseg::SlicesHandlerITKInterface itk_handler(_handler); auto source = itk_handler.GetSource(true); input_type::IndexType idx_lo = {_points.front().px, _points.front().py, _points.front().pz}; @@ -544,7 +544,7 @@ void TraceTubesWidget::do_work_template(TSpeedImage* speed_image, const itk::Ima using path_filter_type = itk::WeightedDijkstraImageFilter; using metric_type = itk::MyMetric; - iseg::SliceHandlerItkWrapper itk_handler(_handler); + iseg::SlicesHandlerITKInterface itk_handler(_handler); auto target = itk_handler.GetTarget(true); int pad = get_padding(); diff --git a/Plugins/TracingTubularStructures/TraceTubesWidget.h b/Plugins/TracingTubularStructures/TraceTubesWidget.h index 464b643b..6bfe0d57 100644 --- a/Plugins/TracingTubularStructures/TraceTubesWidget.h +++ b/Plugins/TracingTubularStructures/TraceTubesWidget.h @@ -45,7 +45,7 @@ class TraceTubesWidget : public iseg::WidgetInterface { Q_OBJECT public: - TraceTubesWidget(iseg::SliceHandlerInterface* hand3D, QWidget* parent = 0, + TraceTubesWidget(iseg::SlicesHandlerInterface* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); ~TraceTubesWidget() {} @@ -78,7 +78,7 @@ class TraceTubesWidget : public iseg::WidgetInterface template void do_work_template(TSpeedImage* speed_image, const itk::ImageBase<3>::RegionType& requested_region); - iseg::SliceHandlerInterface* _handler; + iseg::SlicesHandlerInterface* _handler; std::vector _points; QWidget* _main_options; diff --git a/iSeg/ActiveSlicesConfigDialog.cpp b/iSeg/ActiveSlicesConfigDialog.cpp new file mode 100755 index 00000000..d8fe0020 --- /dev/null +++ b/iSeg/ActiveSlicesConfigDialog.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018 The Foundation for Research on Information Technologies in Society (IT'IS). + * + * This file is part of iSEG + * (see https://github.com/ITISFoundation/osparc-iseg). + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ +#include "Precompiled.h" + +#include "ActiveSlicesConfigDialog.h" + +#include "SlicesHandler.h" + +#include + +using namespace iseg; + +ActiveSlicesConfigDialog::ActiveSlicesConfigDialog(SlicesHandler* hand3D, QWidget* parent, + const char* name, Qt::WindowFlags wFlags) + : QDialog(parent, name, TRUE, wFlags), handler3D(hand3D) +{ + sb_start = new QSpinBox(1, (int)handler3D->num_slices(), 1, nullptr); + sb_start->setValue((int)handler3D->start_slice() + 1); + + sb_end = new QSpinBox(1, (int)handler3D->num_slices(), 1, nullptr); + sb_end->setValue((int)handler3D->end_slice()); + + pb_ok = new QPushButton("OK"); + pb_close = new QPushButton("Cancel"); + + // layout + auto layout = new QFormLayout; + layout->addRow(tr("Start slice"), sb_start); + layout->addRow(tr("End slice"), sb_end); + layout->addRow(pb_ok, pb_close); + + setLayout(layout); + + // connections + connect(pb_close, SIGNAL(clicked()), this, SLOT(close())); + connect(pb_ok, SIGNAL(clicked()), this, SLOT(ok_pressed())); + connect(sb_start, SIGNAL(valueChanged(int)), this, SLOT(startslice_changed(int))); + connect(sb_end, SIGNAL(valueChanged(int)), this, SLOT(endslice_changed(int))); +} + +void ActiveSlicesConfigDialog::ok_pressed() +{ + if (sb_start->value() > sb_end->value()) + return; + + handler3D->set_startslice(sb_start->value() - 1); + handler3D->set_endslice(sb_end->value()); + + close(); +} + +void ActiveSlicesConfigDialog::startslice_changed(int startslice1) +{ + if (startslice1 > sb_end->value()) + { + //sb_end->setValue(startslice1); + pb_ok->setEnabled(false); + } + else + { + pb_ok->setEnabled(true); + } +} + +void ActiveSlicesConfigDialog::endslice_changed(int endslice1) +{ + if (endslice1 < sb_start->value()) + { + pb_ok->setEnabled(false); + } + else + { + pb_ok->setEnabled(true); + } +} diff --git a/iSeg/ActiveslicesConfigWidget.h b/iSeg/ActiveSlicesConfigDialog.h similarity index 68% rename from iSeg/ActiveslicesConfigWidget.h rename to iSeg/ActiveSlicesConfigDialog.h index e39c70eb..eb1f6efd 100755 --- a/iSeg/ActiveslicesConfigWidget.h +++ b/iSeg/ActiveSlicesConfigDialog.h @@ -9,34 +9,24 @@ */ #pragma once -#include "SlicesHandler.h" - -#include -#include #include -#include #include #include -#include namespace iseg { -class ActiveSlicesConfigWidget : public QDialog +class SlicesHandler; + +class ActiveSlicesConfigDialog : public QDialog { Q_OBJECT public: - ActiveSlicesConfigWidget(SlicesHandler* hand3D, QWidget* parent = 0, + ActiveSlicesConfigDialog(SlicesHandler* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); private: SlicesHandler* handler3D; - Q3VBox* vbox1; - Q3VBox* vbox2; - Q3VBox* vbox3; - Q3HBox* hbox1; - Q3HBox* hbox2; - QLabel* lb_start; - QLabel* lb_end; + QSpinBox* sb_start; QSpinBox* sb_end; QPushButton* pb_close; diff --git a/iSeg/ActiveslicesConfigWidget.cpp b/iSeg/ActiveslicesConfigWidget.cpp deleted file mode 100755 index cfef45c3..00000000 --- a/iSeg/ActiveslicesConfigWidget.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2018 The Foundation for Research on Information Technologies in Society (IT'IS). - * - * This file is part of iSEG - * (see https://github.com/ITISFoundation/osparc-iseg). - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ -#include "Precompiled.h" - -#include "ActiveslicesConfigWidget.h" - -#include -#include -#include -#include -#include - -using namespace iseg; - -ActiveSlicesConfigWidget::ActiveSlicesConfigWidget(SlicesHandler* hand3D, QWidget* parent, - const char* name, Qt::WindowFlags wFlags) - : QDialog(parent, name, TRUE, wFlags), handler3D(hand3D) -{ - vbox1 = new Q3VBox(this); - hbox1 = new Q3HBox(vbox1); - vbox2 = new Q3VBox(hbox1); - vbox3 = new Q3VBox(hbox1); - hbox2 = new Q3HBox(vbox1); - - lb_start = new QLabel("Start Slice: ", vbox2); - lb_end = new QLabel("End Slice: ", vbox2); - - sb_start = new QSpinBox(1, (int)handler3D->num_slices(), 1, vbox3); - sb_start->setValue((int)handler3D->start_slice() + 1); - - sb_end = new QSpinBox(1, (int)handler3D->num_slices(), 1, vbox3); - sb_end->setValue((int)handler3D->end_slice()); - - pb_ok = new QPushButton("OK", hbox2); - pb_close = new QPushButton("Cancel", hbox2); - - vbox1->show(); - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - - hbox2->setFixedSize(hbox2->sizeHint()); - vbox2->setFixedSize(vbox2->sizeHint()); - vbox3->setFixedSize(vbox3->sizeHint()); - hbox1->setFixedSize(hbox1->sizeHint()); - vbox1->setFixedSize(vbox1->sizeHint()); - - QObject::connect(pb_close, SIGNAL(clicked()), this, SLOT(close())); - QObject::connect(pb_ok, SIGNAL(clicked()), this, SLOT(ok_pressed())); - QObject::connect(sb_start, SIGNAL(valueChanged(int)), this, - SLOT(startslice_changed(int))); - QObject::connect(sb_end, SIGNAL(valueChanged(int)), this, - SLOT(endslice_changed(int))); - - return; -} - -void ActiveSlicesConfigWidget::ok_pressed() -{ - if (sb_start->value() > sb_end->value()) - return; - - handler3D->set_startslice(sb_start->value() - 1); - handler3D->set_endslice(sb_end->value()); - - close(); -} - -void ActiveSlicesConfigWidget::startslice_changed(int startslice1) -{ - if (startslice1 > sb_end->value()) - { - //sb_end->setValue(startslice1); - pb_ok->setEnabled(false); - } - else - { - pb_ok->setEnabled(true); - } -} - -void ActiveSlicesConfigWidget::endslice_changed(int endslice1) -{ - if (endslice1 < sb_start->value()) - { - //sb_start->setValue(endslice1); - pb_ok->setEnabled(false); - } - else - { - pb_ok->setEnabled(true); - } -} diff --git a/iSeg/CMakeLists.txt b/iSeg/CMakeLists.txt index b9a40f22..6beb37e7 100755 --- a/iSeg/CMakeLists.txt +++ b/iSeg/CMakeLists.txt @@ -31,7 +31,7 @@ INCLUDE_DIRECTORIES( FILE(GLOB ViewerHeaders *.h) SET(ViewerSrcs - ActiveslicesConfigWidget.cpp + ActiveSlicesConfigDialog.cpp Atlas.cpp AtlasViewer.cpp AtlasWidget.cpp @@ -90,7 +90,7 @@ SET(ViewerSrcs ) SET(MyMocHeaders - ActiveslicesConfigWidget.h + ActiveSlicesConfigDialog.h AtlasViewer.h AtlasWidget.h EdgeWidget.h diff --git a/iSeg/EdgeWidget.cpp b/iSeg/EdgeWidget.cpp index 7b00a64b..05146ea3 100755 --- a/iSeg/EdgeWidget.cpp +++ b/iSeg/EdgeWidget.cpp @@ -15,7 +15,7 @@ #include "Data/ItkUtils.h" #include "Data/Point.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include "Data/ScopedTimer.h" #include "Core/BinaryThinningImageFilter.h" @@ -153,7 +153,7 @@ void EdgeWidget::export_centerlines() QString savefilename = QFileDialog::getSaveFileName(QString::null, "VTK legacy file (*.vtk)\n", this); if (!savefilename.isEmpty()) { - SliceHandlerItkWrapper wrapper(handler3D); + SlicesHandlerITKInterface wrapper(handler3D); auto target = wrapper.GetTarget(true); using input_type = itk::SliceContiguousImage; @@ -236,7 +236,7 @@ void EdgeWidget::execute() using input_type = itk::SliceContiguousImage; using output_type = itk::Image; - SliceHandlerItkWrapper wrapper(handler3D); + SlicesHandlerITKInterface wrapper(handler3D); auto target = wrapper.GetTarget(true); auto skeleton = BinaryThinning(target, 0.001f); @@ -254,7 +254,7 @@ void EdgeWidget::execute() using input_type = itk::Image; using output_type = itk::Image; - SliceHandlerItkWrapper wrapper(handler3D); + SlicesHandlerITKInterface wrapper(handler3D); auto target = wrapper.GetTargetSlice(); auto skeleton = BinaryThinning(target, 0.001f); diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index 1e538a7b..a3b84b29 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -11,7 +11,7 @@ #include "../config.h" -#include "ActiveslicesConfigWidget.h" +#include "ActiveSlicesConfigDialog.h" #include "AtlasWidget.h" #include "EdgeWidget.h" #include "FastmarchingFuzzyWidget.h" @@ -4755,7 +4755,7 @@ void MainWindow::execute_undoconf() void MainWindow::execute_activeslicesconf() { - ActiveSlicesConfigWidget AC(handler3D, this); + ActiveSlicesConfigDialog AC(handler3D, this); AC.move(QCursor::pos()); AC.exec(); diff --git a/iSeg/OutlineCorrectionParameterViews.cpp b/iSeg/OutlineCorrectionParameterViews.cpp index 0a52d1c3..8decbbe9 100755 --- a/iSeg/OutlineCorrectionParameterViews.cpp +++ b/iSeg/OutlineCorrectionParameterViews.cpp @@ -284,7 +284,7 @@ void AddSkinParamView::unit_changed() } } -FillSkinParamView::FillSkinParamView(SliceHandlerInterface* h, QWidget* parent /*= 0*/) : ParamViewBase(parent), _handler(h) +FillSkinParamView::FillSkinParamView(SlicesHandlerInterface* h, QWidget* parent /*= 0*/) : ParamViewBase(parent), _handler(h) { // parameter fields _all_slices = new QCheckBox; diff --git a/iSeg/OutlineCorrectionParameterViews.h b/iSeg/OutlineCorrectionParameterViews.h index 4e21f9ef..aeca77a1 100755 --- a/iSeg/OutlineCorrectionParameterViews.h +++ b/iSeg/OutlineCorrectionParameterViews.h @@ -158,7 +158,7 @@ class FillSkinParamView : public ParamViewBase { Q_OBJECT public: - FillSkinParamView(SliceHandlerInterface* h, QWidget* parent = 0); + FillSkinParamView(SlicesHandlerInterface* h, QWidget* parent = 0); void init() override; @@ -188,7 +188,7 @@ private slots: private: // data - SliceHandlerInterface* _handler; + SlicesHandlerInterface* _handler; tissues_size_t selectedBackgroundID; tissues_size_t selectedSkinID; bool backgroundSelected = false; diff --git a/iSeg/SlicesHandler.cpp b/iSeg/SlicesHandler.cpp index 4b505096..dd220977 100755 --- a/iSeg/SlicesHandler.cpp +++ b/iSeg/SlicesHandler.cpp @@ -28,7 +28,7 @@ #include "vtkImageExtractCompatibleMesher.h" #include "Data/ItkProgressObserver.h" -#include "Data/SliceHandlerItkWrapper.h" +#include "Data/SlicesHandlerITKInterface.h" #include "Data/Transform.h" #include "Core/ColorLookupTable.h" @@ -5202,7 +5202,7 @@ class MyVisitor : public boost::static_visitor> void SlicesHandler::erosion(boost::variant radius, bool connectivity) { - SliceHandlerItkWrapper wrapper(this); + SlicesHandlerITKInterface wrapper(this); auto all_slices = wrapper.GetTarget(false); auto ball = boost::apply_visitor(MyVisitor(all_slices->GetSpacing()), radius); @@ -5215,7 +5215,7 @@ void SlicesHandler::erosion(boost::variant radius, bool connectivity void SlicesHandler::dilation(boost::variant radius, bool connectivity) { - SliceHandlerItkWrapper wrapper(this); + SlicesHandlerITKInterface wrapper(this); auto all_slices = wrapper.GetTarget(false); auto ball = boost::apply_visitor(MyVisitor(all_slices->GetSpacing()), radius); @@ -5228,7 +5228,7 @@ void SlicesHandler::dilation(boost::variant radius, bool connectivit void SlicesHandler::closure(boost::variant radius, bool connectivity) { - SliceHandlerItkWrapper wrapper(this); + SlicesHandlerITKInterface wrapper(this); auto all_slices = wrapper.GetTarget(false); auto ball = boost::apply_visitor(MyVisitor(all_slices->GetSpacing()), radius); @@ -5241,7 +5241,7 @@ void SlicesHandler::closure(boost::variant radius, bool connectivity void SlicesHandler::open(boost::variant radius, bool connectivity) { - SliceHandlerItkWrapper wrapper(this); + SlicesHandlerITKInterface wrapper(this); auto all_slices = wrapper.GetTarget(false); auto ball = boost::apply_visitor(MyVisitor(all_slices->GetSpacing()), radius); @@ -5319,7 +5319,7 @@ void SlicesHandler::interpolateworkgrey(unsigned short slice1, unsigned short sl } else { - SliceHandlerItkWrapper itk_handler(this); + SlicesHandlerITKInterface itk_handler(this); auto img1 = itk_handler.GetTargetSlice(slice1); auto img2 = itk_handler.GetTargetSlice(slice2); @@ -6034,7 +6034,7 @@ void SlicesHandler::interpolatetissue(unsigned short slice1, unsigned short slic } else { - SliceHandlerItkWrapper itk_handler(this); + SlicesHandlerITKInterface itk_handler(this); auto tissues1 = itk_handler.GetTissuesSlice(slice1); auto tissues2 = itk_handler.GetTissuesSlice(slice2); @@ -11436,10 +11436,10 @@ void SlicesHandler::get_color(size_t idx, unsigned char& r, unsigned char& g, un bool SlicesHandler::compute_target_connectivity(ProgressInfo* progress) { - using input_type = SliceHandlerItkWrapper::image_ref_type; + using input_type = SlicesHandlerITKInterface::image_ref_type; using image_type = itk::Image; - SliceHandlerItkWrapper wrapper(this); + SlicesHandlerITKInterface wrapper(this); auto all_slices = wrapper.GetTarget(true); auto observer = ItkProgressObserver::New(); @@ -11476,11 +11476,11 @@ bool SlicesHandler::compute_target_connectivity(ProgressInfo* progress) bool SlicesHandler::compute_split_tissues(tissues_size_t tissue, ProgressInfo* progress) { - using input_type = SliceHandlerItkWrapper::tissues_ref_type; + using input_type = SlicesHandlerITKInterface::tissues_ref_type; using internal_type = itk::Image; using image_type = itk::Image; - SliceHandlerItkWrapper wrapper(this); + SlicesHandlerITKInterface wrapper(this); auto all_slices = wrapper.GetTissues(true); auto observer = ItkProgressObserver::New(); diff --git a/iSeg/SlicesHandler.h b/iSeg/SlicesHandler.h index c5c0d0a6..1f0bc160 100755 --- a/iSeg/SlicesHandler.h +++ b/iSeg/SlicesHandler.h @@ -40,7 +40,7 @@ class ColorLookupTable; class bmphandler; class ProgressInfo; -class SlicesHandler : public SliceHandlerInterface +class SlicesHandler : public SlicesHandlerInterface { public: SlicesHandler(); From 6ef90bb155fa31f8c39ab0cdebcc577c18cf169b Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 12 Feb 2019 20:40:55 +0100 Subject: [PATCH 12/26] refactor IFT widget: use QFormLayout, remove Qt3 stuff --- ...eForestingTransformRegionGrowingWidget.cpp | 85 ++++++------------- ...ageForestingTransformRegionGrowingWidget.h | 15 +--- 2 files changed, 30 insertions(+), 70 deletions(-) diff --git a/iSeg/ImageForestingTransformRegionGrowingWidget.cpp b/iSeg/ImageForestingTransformRegionGrowingWidget.cpp index df768edf..86174805 100755 --- a/iSeg/ImageForestingTransformRegionGrowingWidget.cpp +++ b/iSeg/ImageForestingTransformRegionGrowingWidget.cpp @@ -10,24 +10,13 @@ #include "Precompiled.h" #include "ImageForestingTransformRegionGrowingWidget.h" -#include "SlicesHandler.h" -#include "bmp_read_1.h" #include "Data/addLine.h" #include "Core/ImageForestingTransform.h" -#include -#include -#include -#include -#include -#include -#include +#include -#include - -using namespace std; using namespace iseg; ImageForestingTransformRegionGrowingWidget::ImageForestingTransformRegionGrowingWidget(SlicesHandler* hand3D, QWidget* parent, @@ -54,12 +43,12 @@ ImageForestingTransformRegionGrowingWidget::ImageForestingTransformRegionGrowing bmphand = handler3D->get_activebmphandler(); area = 0; + IFTrg = nullptr; + lbmap = nullptr; + thresh = 0; - vbox1 = new Q3VBox(this); - vbox1->setMargin(8); - - pushclear = new QPushButton("Clear Lines", vbox1); - pushremove = new QPushButton("Remove Line", vbox1); + pushclear = new QPushButton("Clear Lines"); + pushremove = new QPushButton("Remove Line"); pushremove->setToggleButton(true); pushremove->setToolTip(Format( "Remove Line followed by a click on a line deletes " @@ -68,39 +57,32 @@ ImageForestingTransformRegionGrowingWidget::ImageForestingTransformRegionGrowing "been pressed accidentally, a second press will deactivate the " "function again.")); - hbox1 = new Q3HBox(vbox1); - - sl_thresh = new QSlider(Qt::Horizontal, vbox1); + sl_thresh = new QSlider(Qt::Horizontal, nullptr); sl_thresh->setRange(0, 100); sl_thresh->setValue(60); sl_thresh->setEnabled(false); sl_thresh->setFixedWidth(400); - hbox1->setFixedSize(hbox1->sizeHint()); - vbox1->setFixedSize(vbox1->sizeHint()); + // layout + auto layout = new QFormLayout; + layout->addRow(pushremove, pushclear); + layout->addRow(sl_thresh); - IFTrg = nullptr; - lbmap = nullptr; - thresh = 0; + setLayout(layout); - QObject::connect(pushclear, SIGNAL(clicked()), this, SLOT(clearmarks())); - QObject::connect(sl_thresh, SIGNAL(sliderMoved(int)), this, - SLOT(slider_changed(int))); - QObject::connect(sl_thresh, SIGNAL(sliderPressed()), this, - SLOT(slider_pressed())); - QObject::connect(sl_thresh, SIGNAL(sliderReleased()), this, - SLOT(slider_released())); + // connections + connect(pushclear, SIGNAL(clicked()), this, SLOT(clearmarks())); + connect(sl_thresh, SIGNAL(sliderMoved(int)), this, SLOT(slider_changed(int))); + connect(sl_thresh, SIGNAL(sliderPressed()), this, SLOT(slider_pressed())); + connect(sl_thresh, SIGNAL(sliderReleased()), this, SLOT(slider_released())); } ImageForestingTransformRegionGrowingWidget::~ImageForestingTransformRegionGrowingWidget() { - delete vbox1; - if (IFTrg != nullptr) delete IFTrg; if (lbmap != nullptr) delete lbmap; - return; } void ImageForestingTransformRegionGrowingWidget::init() @@ -131,10 +113,9 @@ void ImageForestingTransformRegionGrowingWidget::newloaded() void ImageForestingTransformRegionGrowingWidget::init1() { - vector>* vvm = bmphand->return_vvm(); + std::vector>* vvm = bmphand->return_vvm(); vm.clear(); - for (vector>::iterator it = vvm->begin(); it != vvm->end(); - it++) + for (auto it = vvm->begin(); it != vvm->end(); it++) { vm.insert(vm.end(), it->begin(), it->end()); } @@ -146,11 +127,11 @@ void ImageForestingTransformRegionGrowingWidget::init1() for (unsigned i = 0; i < area; i++) lbmap[i] = 0; unsigned width = (unsigned)bmphand->return_width(); - for (vector::iterator it = vm.begin(); it != vm.end(); it++) + for (auto it = vm.begin(); it != vm.end(); it++) { lbmap[width * it->p.py + it->p.px] = (float)it->mark; } - for (vector::iterator it = vmdyn.begin(); it != vmdyn.end(); it++) + for (auto it = vmdyn.begin(); it != vmdyn.end(); it++) { lbmap[width * it->py + it->px] = (float)tissuenr; } @@ -181,8 +162,6 @@ void ImageForestingTransformRegionGrowingWidget::cleanup() void ImageForestingTransformRegionGrowingWidget::on_tissuenr_changed(int i) { - // \todo B - std::cerr << "ImageForestingTransformRegionGrowingWidget: tissuenr = " << i << std::endl; tissuenr = (unsigned)i + 1; } @@ -213,9 +192,9 @@ void ImageForestingTransformRegionGrowingWidget::on_mouse_released(Point p) Mark m; m.mark = tissuenr; unsigned width = (unsigned)bmphand->return_width(); - vector vmdummy; + std::vector vmdummy; vmdummy.clear(); - for (vector::iterator it = vmdyn.begin(); it != vmdyn.end(); + for (auto it = vmdyn.begin(); it != vmdyn.end(); it++) { m.p = *it; @@ -321,7 +300,7 @@ void ImageForestingTransformRegionGrowingWidget::bmphand_changed(bmphandler* bmp unsigned width = (unsigned)bmphand->return_width(); - vector>* vvm = bmphand->return_vvm(); + std::vector>* vvm = bmphand->return_vvm(); vm.clear(); for (auto& line : *vvm) { @@ -347,8 +326,6 @@ void ImageForestingTransformRegionGrowingWidget::bmphand_changed(bmphandler* bmp } emit vm_changed(&vm); - - return; } void ImageForestingTransformRegionGrowingWidget::getrange() @@ -366,13 +343,9 @@ void ImageForestingTransformRegionGrowingWidget::getrange() thresh = maxthresh; if (maxthresh == 0) maxthresh = thresh = 1; - sl_thresh->setValue(min(int(thresh * 100 / maxthresh), 100)); - - return; + sl_thresh->setValue(std::min(int(thresh * 100 / maxthresh), 100)); } -QSize ImageForestingTransformRegionGrowingWidget::sizeHint() const { return vbox1->sizeHint(); } - void ImageForestingTransformRegionGrowingWidget::removemarks(Point p) { if (bmphand->del_vm(p, 3)) @@ -383,19 +356,17 @@ void ImageForestingTransformRegionGrowingWidget::removemarks(Point p) dataSelection.vvm = true; emit begin_datachange(dataSelection, this); - vector>* vvm = bmphand->return_vvm(); + std::vector>* vvm = bmphand->return_vvm(); vm.clear(); - for (vector>::iterator it = vvm->begin(); it != vvm->end(); - it++) + for (auto it = vvm->begin(); it != vvm->end(); it++) { vm.insert(vm.end(), it->begin(), it->end()); - ; } unsigned width = (unsigned)bmphand->return_width(); for (unsigned i = 0; i < area; i++) lbmap[i] = 0; - for (vector::iterator it = vm.begin(); it != vm.end(); it++) + for (auto it = vm.begin(); it != vm.end(); it++) { lbmap[width * it->p.py + it->p.px] = (float)it->mark; } diff --git a/iSeg/ImageForestingTransformRegionGrowingWidget.h b/iSeg/ImageForestingTransformRegionGrowingWidget.h index b544c6d3..50db4494 100755 --- a/iSeg/ImageForestingTransformRegionGrowingWidget.h +++ b/iSeg/ImageForestingTransformRegionGrowingWidget.h @@ -14,17 +14,9 @@ #include "Interface/WidgetInterface.h" -#include -#include -#include #include -#include -#include #include #include -#include - -#include namespace iseg { @@ -38,7 +30,6 @@ class ImageForestingTransformRegionGrowingWidget : public WidgetInterface void init() override; void newloaded() override; void cleanup() override; - QSize sizeHint() const override; FILE* SaveParams(FILE* fp, int version) override; FILE* LoadParams(FILE* fp, int version) override; void hideparams_changed() override; @@ -64,14 +55,12 @@ class ImageForestingTransformRegionGrowingWidget : public WidgetInterface bmphandler* bmphand; SlicesHandler* handler3D; unsigned short activeslice; - Q3HBox* hbox1; - Q3VBox* vbox1; - QLabel* txt_lower; - QLabel* txt_upper; + QSlider* sl_thresh; QPushButton* pushexec; QPushButton* pushclear; QPushButton* pushremove; + unsigned tissuenr; float thresh; float maxthresh; From 06f9736576883cc7e7cc0223c681ab18874b0852 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 12 Feb 2019 20:44:20 +0100 Subject: [PATCH 13/26] remove q3 headers from Precompiled.h --- iSeg/Precompiled.h | 2 -- iSeg/SurfaceViewerWidget.cpp | 1 + iSeg/VolumeViewerWidget.cpp | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iSeg/Precompiled.h b/iSeg/Precompiled.h index 721b70aa..d827acda 100755 --- a/iSeg/Precompiled.h +++ b/iSeg/Precompiled.h @@ -14,8 +14,6 @@ #include #include -#include -#include #include #include #include diff --git a/iSeg/SurfaceViewerWidget.cpp b/iSeg/SurfaceViewerWidget.cpp index 9533f9d9..28642ded 100644 --- a/iSeg/SurfaceViewerWidget.cpp +++ b/iSeg/SurfaceViewerWidget.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include diff --git a/iSeg/VolumeViewerWidget.cpp b/iSeg/VolumeViewerWidget.cpp index dea159a3..ad959537 100644 --- a/iSeg/VolumeViewerWidget.cpp +++ b/iSeg/VolumeViewerWidget.cpp @@ -16,6 +16,7 @@ #include "QVTKWidget.h" #include +#include #include #include From 779aa849804423f7b5642e298080f44bb09de3d7 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 12 Feb 2019 20:56:25 +0100 Subject: [PATCH 14/26] refactor BiasCorrection widget: use QFormLayout, remove Qt3 stuff --- Plugins/BiasCorrection/BiasCorrection.cpp | 51 +++++++++++++---------- Plugins/BiasCorrection/BiasCorrection.h | 27 ++++-------- 2 files changed, 36 insertions(+), 42 deletions(-) diff --git a/Plugins/BiasCorrection/BiasCorrection.cpp b/Plugins/BiasCorrection/BiasCorrection.cpp index 0140aaba..62f60194 100755 --- a/Plugins/BiasCorrection/BiasCorrection.cpp +++ b/Plugins/BiasCorrection/BiasCorrection.cpp @@ -22,7 +22,9 @@ #include #include +#include #include +#include #include #include @@ -120,29 +122,31 @@ BiasCorrectionWidget::BiasCorrectionWidget(iseg::SlicesHandlerInterface* hand3D, activeslice = handler3D->active_slice(); - vbox1 = new Q3VBox(this); - bias_header = new QLabel("N4 Bias Correction: ", vbox1); - hbox2 = new Q3HBox(vbox1); - hbox3 = new Q3HBox(vbox1); - hbox4 = new Q3HBox(vbox1); + auto bias_header = new QLabel("N4 Bias Correction"); - txt_h2 = new QLabel("Fitting Levels: ", hbox2); - edit_num_levels = new QSpinBox(0, 50, 1, hbox2); - edit_num_levels->setValue(4); + number_levels = new QSpinBox(0, 50, 1, nullptr); + number_levels->setValue(4); - txt_h3 = new QLabel("Shrink Factor", hbox3); - edit_shrink_factor = new QSpinBox(1, 16, 1, hbox3); - edit_shrink_factor->setValue(4); + shrink_factor = new QSpinBox(1, 16, 1, nullptr); + shrink_factor->setValue(4); - txt_h4 = new QLabel("Iterations: ", hbox4); - edit_num_iterations = new QSpinBox(1, 200, 5, hbox4); - edit_num_iterations->setValue(50); + number_iterations = new QSpinBox(1, 200, 5, nullptr); + number_iterations->setValue(50); - bias_exec = new QPushButton("Execute", vbox1); + execute = new QPushButton("Execute"); - vbox1->setMinimumWidth(std::max(300, vbox1->sizeHint().width())); + // layout + auto layout = new QFormLayout; + layout->addRow(bias_header); + layout->addRow("Fitting Levels", number_levels); + layout->addRow("Shrink Factor", shrink_factor); + layout->addRow("Iterations", number_iterations); + layout->addRow(execute); - QObject::connect(bias_exec, SIGNAL(clicked()), this, SLOT(do_work())); + setLayout(layout); + + // connections + connect(execute, SIGNAL(clicked()), this, SLOT(do_work())); } void BiasCorrectionWidget::do_work() @@ -155,16 +159,16 @@ void BiasCorrectionWidget::do_work() //Ensure that it is a 3D image for the 3D image filter ! Else it does nothing if (input->GetLargestPossibleRegion().GetSize(2) > 1) { - int num_levels = edit_num_levels->value(); - int num_iterations = edit_num_iterations->value(); - int shrink_factor = edit_shrink_factor->value(); + int num_levels = number_levels->value(); + int num_iterations = number_iterations->value(); + int factor = shrink_factor->value(); double conv_threshold = 0.0; try { auto output = DoBiasCorrection( input, ITK_NULLPTR, - std::vector(num_levels, num_iterations), shrink_factor, + std::vector(num_levels, num_iterations), factor, conv_threshold); if (output) @@ -200,9 +204,10 @@ void BiasCorrectionWidget::cancel() } } -QSize BiasCorrectionWidget::sizeHint() const { return vbox1->sizeHint(); } +BiasCorrectionWidget::~BiasCorrectionWidget() +{ -BiasCorrectionWidget::~BiasCorrectionWidget() { delete vbox1; } +} void BiasCorrectionWidget::on_slicenr_changed() { diff --git a/Plugins/BiasCorrection/BiasCorrection.h b/Plugins/BiasCorrection/BiasCorrection.h index d7719ad7..83a978fb 100755 --- a/Plugins/BiasCorrection/BiasCorrection.h +++ b/Plugins/BiasCorrection/BiasCorrection.h @@ -9,18 +9,15 @@ */ #pragma once -#include - #include "Data/SlicesHandlerInterface.h" + #include "Interface/WidgetInterface.h" -#include -#include -#include -#include #include #include +#include + namespace itk { class ProcessObject; } @@ -33,7 +30,6 @@ class BiasCorrectionWidget : public iseg::WidgetInterface const char* name = 0, Qt::WindowFlags wFlags = 0); ~BiasCorrectionWidget(); - QSize sizeHint() const override; void init() override; void newloaded() override; std::string GetName() override; @@ -49,18 +45,11 @@ class BiasCorrectionWidget : public iseg::WidgetInterface iseg::SlicesHandlerInterface* handler3D; unsigned short activeslice; - Q3VBox* vbox1; - QLabel* bias_header; - QPushButton* bias_exec; - Q3HBox* hbox2; - Q3HBox* hbox3; - Q3HBox* hbox4; - QLabel* txt_h2; - QLabel* txt_h3; - QLabel* txt_h4; - QSpinBox* edit_num_levels; - QSpinBox* edit_shrink_factor; - QSpinBox* edit_num_iterations; + + QSpinBox* number_levels; + QSpinBox* shrink_factor; + QSpinBox* number_iterations; + QPushButton* execute; itk::ProcessObject* m_CurrentFilter; From 9c173aeaff0a699a9284dd66a66a9f5433af1bab Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 12 Feb 2019 21:24:41 +0100 Subject: [PATCH 15/26] refactor Feature widget: use QFormLayout, remove Qt3 stuff --- iSeg/FeatureWidget.cpp | 88 +++++++++++++++--------------------------- iSeg/FeatureWidget.h | 23 +---------- 2 files changed, 33 insertions(+), 78 deletions(-) diff --git a/iSeg/FeatureWidget.cpp b/iSeg/FeatureWidget.cpp index cec4bb38..802c6b76 100755 --- a/iSeg/FeatureWidget.cpp +++ b/iSeg/FeatureWidget.cpp @@ -20,22 +20,8 @@ #include "Core/ImageForestingTransform.h" #include "Core/Pair.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include using namespace iseg; @@ -51,52 +37,40 @@ FeatureWidget::FeatureWidget(SlicesHandler* hand3D, QWidget* parent, activeslice = handler3D->active_slice(); bmphand = handler3D->get_activebmphandler(); - hbox1 = new Q3HBox(this); - hbox1->setMargin(8); - vbox1 = new Q3VBox(hbox1); - vbox2 = new Q3VBox(hbox1); - vbox3 = new Q3VBox(hbox1); selecting = false; - lb_map = new QLabel("", vbox1); - lb_av = new QLabel("Average: ", vbox1); - lb_stddev = new QLabel("Std Dev.: ", vbox1); - lb_min = new QLabel("Minimum: ", vbox1); - lb_max = new QLabel("Maximum: ", vbox1); - lb_grey = new QLabel("Grey val.:", vbox1); - lb_pt = new QLabel("Coord.: ", vbox1); - lb_tissue = new QLabel("Tissue: ", vbox1); - lb_map_value = new QLabel("abcdefghijk", vbox2); - lb_av_value = new QLabel("", vbox2); - lb_stddev_value = new QLabel("", vbox2); - lb_min_value = new QLabel("", vbox2); - lb_max_value = new QLabel("", vbox2); - lb_grey_value = new QLabel("", vbox2); - lb_pt_value = new QLabel("", vbox2); - lb_dummy = new QLabel("", vbox2); - lb_work_map_value = new QLabel("xxxxxxxxxxxxxxxxxxxxxxx", vbox3); - lb_work_av_value = new QLabel("", vbox3); - lb_work_stddev_value = new QLabel("", vbox3); - lb_work_min_value = new QLabel("", vbox3); - lb_work_max_value = new QLabel("", vbox3); - lb_work_grey_value = new QLabel("", vbox3); - lb_work_pt_value = new QLabel("", vbox3); - lb_tissuename = new QLabel("", vbox3); - - vbox1->setFixedSize(vbox1->sizeHint()); - vbox2->setFixedSize(vbox2->sizeHint()); - // BL: hack to make layout wide enought to show very long tissue names - vbox3->setFixedSize(3 * vbox3->sizeHint().width(), - vbox3->sizeHint().height()); - hbox1->setFixedSize(hbox1->sizeHint()); - - lb_map_value->setText("Source:"); - lb_work_map_value->setText("Target:"); + auto layout = new QGridLayout; + layout->addWidget(lb_map = new QLabel(""), 0, 0); + layout->addWidget(lb_av = new QLabel("Average: "), 1, 0); + layout->addWidget(lb_stddev = new QLabel("Std Dev.: "), 2, 0); + layout->addWidget(lb_min = new QLabel("Minimum: "), 3, 0); + layout->addWidget(lb_max = new QLabel("Maximum: "), 4, 0); + layout->addWidget(lb_grey = new QLabel("Grey val.:"), 5, 0); + layout->addWidget(lb_pt = new QLabel("Coord.: "), 6, 0); + layout->addWidget(lb_tissue = new QLabel("Tissue: "), 7, 0); + + layout->addWidget(lb_map_value = new QLabel("Source"), 0, 1); + layout->addWidget(lb_av_value = new QLabel(""), 1, 1); + layout->addWidget(lb_stddev_value = new QLabel(""), 2, 1); + layout->addWidget(lb_min_value = new QLabel(""), 3, 1); + layout->addWidget(lb_max_value = new QLabel(""), 4, 1); + layout->addWidget(lb_grey_value = new QLabel(""), 5, 1); + layout->addWidget(lb_pt_value = new QLabel(""), 6, 1); + layout->addWidget(lb_dummy = new QLabel(""), 7, 1); + + layout->addWidget(lb_work_map_value = new QLabel("Target"), 0, 2); + layout->addWidget(lb_work_av_value = new QLabel(""), 1, 2); + layout->addWidget(lb_work_stddev_value = new QLabel(""), 2, 2); + layout->addWidget(lb_work_min_value = new QLabel(""), 3, 2); + layout->addWidget(lb_work_max_value = new QLabel(""), 4, 2); + layout->addWidget(lb_work_grey_value = new QLabel(""), 5, 2); + layout->addWidget(lb_work_pt_value = new QLabel(""), 6, 2); + layout->addWidget(lb_tissuename = new QLabel(""), 7, 2); + + setLayout(layout); } -QSize FeatureWidget::sizeHint() const { return hbox1->sizeHint(); } - void FeatureWidget::on_mouse_clicked(Point p) { selecting = true; diff --git a/iSeg/FeatureWidget.h b/iSeg/FeatureWidget.h index 13b9642c..234f279d 100755 --- a/iSeg/FeatureWidget.h +++ b/iSeg/FeatureWidget.h @@ -16,23 +16,7 @@ #include "Core/ImageForestingTransform.h" -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -//Added by qt3to4: -#include namespace iseg { @@ -44,7 +28,6 @@ class FeatureWidget : public WidgetInterface const char* name = 0, Qt::WindowFlags wFlags = 0); void init() override; void newloaded() override; - QSize sizeHint() const override; std::string GetName() override { return std::string("Feature"); } QIcon GetIcon(QDir picdir) override { return QIcon(picdir.absFilePath(QString("feature.png")).ascii()); } @@ -59,10 +42,7 @@ class FeatureWidget : public WidgetInterface bmphandler* bmphand; SlicesHandler* handler3D; unsigned short activeslice; - Q3VBox* vbox1; - Q3VBox* vbox2; - Q3VBox* vbox3; - Q3HBox* hbox1; + QLabel* lb_map; QLabel* lb_av; QLabel* lb_stddev; @@ -87,6 +67,7 @@ class FeatureWidget : public WidgetInterface QLabel* lb_work_grey_value; QLabel* lb_tissuename; QLabel* lb_dummy; + Point pstart; }; From fc5b6fc31ada26446347dc4fb5abbede0de52e3d Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 12 Feb 2019 21:38:45 +0100 Subject: [PATCH 16/26] refactor Picker widget: use QFormLayout, remove Qt3 stuff --- iSeg/PickerWidget.cpp | 114 +++++++++++++++++++++--------------------- iSeg/PickerWidget.h | 23 ++------- 2 files changed, 59 insertions(+), 78 deletions(-) diff --git a/iSeg/PickerWidget.cpp b/iSeg/PickerWidget.cpp index 5de4ad7e..51cff1bb 100755 --- a/iSeg/PickerWidget.cpp +++ b/iSeg/PickerWidget.cpp @@ -10,24 +10,39 @@ #include "Precompiled.h" #include "PickerWidget.h" -#include "SlicesHandler.h" -#include "bmp_read_1.h" #include "Data/addLine.h" #include "Core/Pair.h" +#include +#include + #include +#include using namespace iseg; +namespace { +QHBoxLayout* make_hbox(std::initializer_list list) +{ + auto hbox = new QHBoxLayout; + for (auto w : list) + { + hbox->addWidget(w); + } + return hbox; +} +} + PickerWidget::PickerWidget(SlicesHandler* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), handler3D(hand3D) { - setToolTip(Format("Copy and erase regions. Copying can be used to transfer " - "segmented regions from one slice to another. All the " - "functions are based on the current region selection.")); + setToolTip(Format( + "Copy and erase regions. Copying can be used to transfer " + "segmented regions from one slice to another. All the " + "functions are based on the current region selection.")); bmphand = handler3D->get_activebmphandler(); @@ -38,75 +53,64 @@ PickerWidget::PickerWidget(SlicesHandler* hand3D, QWidget* parent, hasclipboard = false; shiftpressed = false; - vbox1 = new Q3VBox(this); - vbox1->setMargin(8); - hbox1 = new Q3HBox(vbox1); - hbox2 = new Q3HBox(vbox1); - hbox3 = new Q3HBox(vbox1); - - rb_work = new QRadioButton(QString("Target"), hbox1); - rb_tissue = new QRadioButton(QString("Tissue"), hbox1); - worktissuegroup = new QButtonGroup(this); + rb_work = new QRadioButton(tr("Target")); + rb_tissue = new QRadioButton(tr("Tissue")); + auto worktissuegroup = new QButtonGroup(this); worktissuegroup->insert(rb_work); worktissuegroup->insert(rb_tissue); - rb_tissue->setChecked(TRUE); + rb_tissue->setChecked(true); - rb_erase = new QRadioButton(QString("Erase"), hbox2); + rb_erase = new QRadioButton(tr("Erase")); rb_erase->setToolTip(Format("The deleted regions will be left empty.")); - rb_fill = new QRadioButton(QString("Fill"), hbox2); - rb_fill->setToolTip( - Format("Fill the resulting hole based on the neighboring regions.")); - erasefillgroup = new QButtonGroup(this); + rb_fill = new QRadioButton(tr("Fill")); + rb_fill->setToolTip(Format("Fill the resulting hole based on the neighboring regions.")); + + auto erasefillgroup = new QButtonGroup(this); erasefillgroup->insert(rb_erase); erasefillgroup->insert(rb_fill); - rb_erase->setChecked(TRUE); + rb_erase->setChecked(true); - pb_copy = new QPushButton("Copy", hbox3); + pb_copy = new QPushButton("Copy"); pb_copy->setToolTip(Format("Copies an image on the clip-board.")); - pb_paste = new QPushButton("Paste", hbox3); + pb_paste = new QPushButton("Paste"); pb_paste->setToolTip(Format("Clip-board is pasted into the current slice")); - pb_cut = new QPushButton("Cut", hbox3); - pb_cut->setToolTip( - Format("Tissues or target image pixels inside the region " - "selection are erased but a copy " - "is placed on the clipboard.")); - pb_delete = new QPushButton("Delete", hbox3); - pb_delete->setToolTip( - Format("Tissues (resp. target image pixels) inside the " - "region selection are erased.")); - - hbox1->setFixedSize(hbox1->sizeHint()); - hbox2->setFixedSize(hbox2->sizeHint()); - hbox3->setFixedSize(hbox3->sizeHint()); - vbox1->setFixedSize(vbox1->sizeHint()); - + pb_cut = new QPushButton("Cut"); + pb_cut->setToolTip(Format( + "Tissues or target image pixels inside the region " + "selection are erased but a copy " + "is placed on the clipboard.")); + pb_delete = new QPushButton("Delete"); + pb_delete->setToolTip(Format( + "Tissues (resp. target image pixels) inside the " + "region selection are erased.")); + + // layout + auto layout = new QFormLayout; + layout->addRow(rb_work, rb_tissue); + layout->addRow(rb_erase, rb_fill); + layout->addRow(make_hbox({pb_copy, pb_paste, pb_cut, pb_delete})); + setLayout(layout); + + // initialize selection.clear(); - update_active(); showborder(); - QObject::connect(worktissuegroup, SIGNAL(buttonClicked(int)), this, - SLOT(worktissue_changed(int))); - QObject::connect(pb_copy, SIGNAL(clicked()), this, SLOT(copy_pressed())); - QObject::connect(pb_paste, SIGNAL(clicked()), this, SLOT(paste_pressed())); - QObject::connect(pb_cut, SIGNAL(clicked()), this, SLOT(cut_pressed())); - QObject::connect(pb_delete, SIGNAL(clicked()), this, - SLOT(delete_pressed())); + // connections + connect(worktissuegroup, SIGNAL(buttonClicked(int)), this, SLOT(worktissue_changed(int))); + connect(pb_copy, SIGNAL(clicked()), this, SLOT(copy_pressed())); + connect(pb_paste, SIGNAL(clicked()), this, SLOT(paste_pressed())); + connect(pb_cut, SIGNAL(clicked()), this, SLOT(cut_pressed())); + connect(pb_delete, SIGNAL(clicked()), this, SLOT(delete_pressed())); } PickerWidget::~PickerWidget() { - delete vbox1; - delete worktissuegroup; - delete erasefillgroup; - delete[] mask; delete[] currentselection; delete[] valuedistrib; } -QSize PickerWidget::sizeHint() const { return vbox1->sizeHint(); } - void PickerWidget::bmphand_changed(bmphandler* bmph) { bmphand = bmph; @@ -170,9 +174,6 @@ FILE* PickerWidget::LoadParams(FILE* fp, int version) { if (version >= 6) { - QObject::disconnect(worktissuegroup, SIGNAL(buttonClicked(int)), this, - SLOT(worktissue_changed(int))); - int dummy; fread(&dummy, sizeof(int), 1, fp); rb_work->setChecked(dummy > 0); @@ -184,9 +185,6 @@ FILE* PickerWidget::LoadParams(FILE* fp, int version) rb_fill->setChecked(dummy > 0); worktissue_changed(0); - - QObject::connect(worktissuegroup, SIGNAL(buttonClicked(int)), this, - SLOT(worktissue_changed(int))); } return fp; } diff --git a/iSeg/PickerWidget.h b/iSeg/PickerWidget.h index 9e1c338d..962343d2 100755 --- a/iSeg/PickerWidget.h +++ b/iSeg/PickerWidget.h @@ -7,26 +7,15 @@ * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ -#ifndef PICKERWIDGET_15DEZ08 -#define PICKERWIDGET_15DEZ08 +#pragma once #include "SlicesHandler.h" #include "bmp_read_1.h" #include "Interface/WidgetInterface.h" -#include -#include -#include -#include -#include -#include -#include #include #include -#include - -#include namespace iseg { @@ -39,7 +28,6 @@ class PickerWidget : public WidgetInterface ~PickerWidget(); FILE* SaveParams(FILE* fp, int version) override; FILE* LoadParams(FILE* fp, int version) override; - QSize sizeHint() const override; void init() override; void cleanup() override; void newloaded() override; @@ -65,20 +53,16 @@ class PickerWidget : public WidgetInterface bool* currentselection; float* valuedistrib; unsigned char mode; - Q3HBox* hbox1; - Q3HBox* hbox2; - Q3HBox* hbox3; - Q3VBox* vbox1; + QPushButton* pb_copy; QPushButton* pb_paste; QPushButton* pb_cut; QPushButton* pb_delete; QRadioButton* rb_work; QRadioButton* rb_tissue; - QButtonGroup* worktissuegroup; QRadioButton* rb_erase; QRadioButton* rb_fill; - QButtonGroup* erasefillgroup; + std::vector selection; signals: @@ -100,4 +84,3 @@ private slots: } // namespace iseg -#endif From 7b4c603a8504c4838f078e76c32ded5aed764790 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Mon, 18 Feb 2019 22:17:39 +0100 Subject: [PATCH 17/26] refactor Measurement widget: use Qt4 layouting, remove Qt3 stuff add style for QComboBox:disabled --- iSeg/MeasurementWidget.cpp | 292 +++++++++++------------ iSeg/MeasurementWidget.h | 36 ++- iSeg/OutlineCorrectionParameterViews.cpp | 1 - iSeg/OutlineCorrectionWidget.cpp | 30 +-- iSeg/OutlineCorrectionWidget.h | 4 +- iSeg/main.cpp | 4 +- 6 files changed, 177 insertions(+), 190 deletions(-) diff --git a/iSeg/MeasurementWidget.cpp b/iSeg/MeasurementWidget.cpp index 5a693cff..b4b23c2b 100755 --- a/iSeg/MeasurementWidget.cpp +++ b/iSeg/MeasurementWidget.cpp @@ -21,11 +21,36 @@ #include "Core/Pair.h" #include +#include +#include +#include #include +#include using namespace iseg; +namespace { +QHBoxLayout* make_hbox(std::initializer_list list) +{ + auto box = new QHBoxLayout; + for (auto w : list) + { + box->addWidget(w); + } + return box; +} +QVBoxLayout* make_vbox(std::initializer_list list) +{ + auto box = new QVBoxLayout; + for (auto w : list) + { + box->addWidget(w); + } + return box; +} +} + MeasurementWidget::MeasurementWidget(SlicesHandler* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), handler3D(hand3D) @@ -35,62 +60,76 @@ MeasurementWidget::MeasurementWidget(SlicesHandler* hand3D, QWidget* parent, activeslice = handler3D->active_slice(); bmphand = handler3D->get_activebmphandler(); - - hboxoverall = new Q3HBox(this); - hboxoverall->setMargin(8); - vboxmethods = new Q3VBox(hboxoverall); - vbox1 = new Q3VBox(hboxoverall); - hbox2 = new Q3HBox(vbox1); - hbox3 = new Q3HBox(vbox1); - hbox4 = new Q3HBox(vbox1); - txt_displayer = new QLabel(" ", vbox1); - state = 0; - rb_vector = new QRadioButton(QString("Vect."), vboxmethods); - rb_dist = new QRadioButton(QString("Dist."), vboxmethods); - rb_thick = new QRadioButton(QString("Thick."), vboxmethods); - rb_angle = new QRadioButton(QString("Angle"), vboxmethods); - rb_4ptangle = new QRadioButton(QString("4pt-Angle"), vboxmethods); - rb_vol = new QRadioButton(QString("Volume"), vboxmethods); - modegroup = new QButtonGroup(this); - // modegroup->hide(); + // properties + txt_displayer = new QLabel(" "); + //txt_displayer->setWordWrap(true); + + rb_vector = new QRadioButton("Vector"); + rb_dist = new QRadioButton("Distance"); + rb_thick = new QRadioButton("Thickness"); + rb_angle = new QRadioButton("Angle"); + rb_4ptangle = new QRadioButton("4pt-Angle"); + rb_vol = new QRadioButton("Volume"); + auto modegroup = new QButtonGroup(this); modegroup->insert(rb_vector); modegroup->insert(rb_dist); modegroup->insert(rb_thick); modegroup->insert(rb_angle); modegroup->insert(rb_4ptangle); modegroup->insert(rb_vol); - rb_dist->setChecked(TRUE); + rb_dist->setChecked(true); - rb_pts = new QRadioButton(QString("Clicks"), hbox2); - rb_lbls = new QRadioButton(QString("Labels"), hbox2); - inputgroup = new QButtonGroup(this); - // inputgroup->hide(); + rb_pts = new QRadioButton("Clicks"); + rb_lbls = new QRadioButton("Labels"); + auto inputgroup = new QButtonGroup(this); inputgroup->insert(rb_pts); inputgroup->insert(rb_lbls); - rb_pts->setChecked(TRUE); - - txt_ccb1 = new QLabel("Pt. 1:", hbox3); - cbb_lb1 = new QComboBox(hbox3); - txt_ccb2 = new QLabel(" Pt. 2:", hbox3); - cbb_lb2 = new QComboBox(hbox3); - txt_ccb3 = new QLabel("Pt. 3:", hbox4); - cbb_lb3 = new QComboBox(hbox4); - txt_ccb4 = new QLabel(" Pt. 4:", hbox4); - cbb_lb4 = new QComboBox(hbox4); - - vboxmethods->setMargin(5); - vbox1->setMargin(5); - vboxmethods->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - vboxmethods->setLineWidth(1); - - hbox2->setFixedSize(hbox2->sizeHint()); - hbox3->setFixedSize(hbox3->sizeHint()); - // vboxmethods->setFixedSize(vboxmethods->sizeHint()); - // hboxoverall->setFixedSize(hboxoverall->sizeHint());// - vbox1->setFixedSize(vbox1->sizeHint()); - + rb_pts->setChecked(true); + + cbb_lb1 = new QComboBox; + cbb_lb2 = new QComboBox; + cbb_lb3 = new QComboBox; + cbb_lb4 = new QComboBox; + + // layout + auto method_layout = make_vbox({rb_vector, rb_dist, rb_thick, rb_angle, rb_4ptangle, rb_vol}); + auto method_area = new QFrame; + method_area->setLayout(method_layout); + method_area->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + method_area->setLineWidth(1); + + input_area = new QWidget; + input_area->setLayout(make_hbox({rb_pts, rb_lbls})); + input_area->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); + + auto labels_layout = new QFormLayout; + labels_layout->addRow("Point 1", cbb_lb1); + labels_layout->addRow("Point 2", cbb_lb2); + labels_layout->addRow("Point 3", cbb_lb3); + labels_layout->addRow("Point 4", cbb_lb4); + + labels_area = new QWidget; + labels_area->setLayout(labels_layout); + + auto params_layout = new QVBoxLayout; + params_layout->addWidget(input_area); + params_layout->addWidget(txt_displayer); + params_layout->setAlignment(txt_displayer, Qt::AlignHCenter | Qt::AlignCenter); + + stacked_widget = new QStackedWidget; + stacked_widget->addWidget(new QLabel(" ")); + stacked_widget->addWidget(labels_area); + + auto top_layout = new QHBoxLayout; + top_layout->addWidget(method_area); + top_layout->addLayout(params_layout); + top_layout->addWidget(stacked_widget); + + setLayout(top_layout); + + // initialize marks_changed(); method_changed(0); inputtype_changed(0); @@ -101,36 +140,20 @@ MeasurementWidget::MeasurementWidget(SlicesHandler* hand3D, QWidget* parent, emit vp1dyn_changed(&established, &dynamic); - QObject::connect(modegroup, SIGNAL(buttonClicked(int)), this, - SLOT(method_changed(int))); - QObject::connect(inputgroup, SIGNAL(buttonClicked(int)), this, - SLOT(inputtype_changed(int))); - QObject::connect(cbb_lb1, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); - QObject::connect(cbb_lb2, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); - QObject::connect(cbb_lb3, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); - QObject::connect(cbb_lb4, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); -} - -MeasurementWidget::~MeasurementWidget() -{ - delete vbox1; - delete modegroup; - delete inputgroup; + // connections + connect(modegroup, SIGNAL(buttonClicked(int)), this, SLOT(method_changed(int))); + connect(inputgroup, SIGNAL(buttonClicked(int)), this, SLOT(inputtype_changed(int))); + connect(cbb_lb1, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); + connect(cbb_lb2, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); + connect(cbb_lb3, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); + connect(cbb_lb4, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); } -QSize MeasurementWidget::sizeHint() const { return vbox1->sizeHint(); } - void MeasurementWidget::bmphand_changed(bmphandler* bmph) { bmphand = bmph; getlabels(); - - return; } void MeasurementWidget::init() @@ -141,7 +164,29 @@ void MeasurementWidget::init() bmphand_changed(handler3D->get_activebmphandler()); } else + { getlabels(); + } +} + +void MeasurementWidget::setActiveLabels(eActiveLabels act) +{ + bool b1=false, b2=false, b3=false, b4=false; + switch(act) + { + case kP4: + b4 = true; + case kP3: + b3 = true; + case kP2: + b2 = true; + case kP1: + b1 = true; + } + cbb_lb1->setEnabled(b1); + cbb_lb2->setEnabled(b2); + cbb_lb3->setEnabled(b3); + cbb_lb4->setEnabled(b4); } void MeasurementWidget::newloaded() @@ -178,11 +223,6 @@ FILE* MeasurementWidget::LoadParams(FILE* fp, int version) { if (version >= 3) { - QObject::disconnect(modegroup, SIGNAL(buttonClicked(int)), this, - SLOT(method_changed(int))); - QObject::disconnect(inputgroup, SIGNAL(buttonClicked(int)), this, - SLOT(inputtype_changed(int))); - int dummy; if (version >= 4) { @@ -204,11 +244,6 @@ FILE* MeasurementWidget::LoadParams(FILE* fp, int version) method_changed(0); inputtype_changed(0); - - QObject::connect(modegroup, SIGNAL(buttonClicked(int)), this, - SLOT(method_changed(int))); - QObject::connect(inputgroup, SIGNAL(buttonClicked(int)), this, - SLOT(inputtype_changed(int))); } return fp; } @@ -422,20 +457,15 @@ void MeasurementWidget::on_mouse_clicked(Point p) else tissuename1 = ToQ(TissueInfos::GetTissueName(tnr)); QString note = QString(""); - if (!(handler3D->start_slice() == 0 && - handler3D->end_slice() == handler3D->num_slices())) + if (!(handler3D->start_slice() == 0 && handler3D->end_slice() == handler3D->num_slices())) { note = QString("\nCalculated for active slices only."); } txt_displayer->setText( QString("Tissue '") + tissuename1 + QString("': ") + - QString::number(handler3D->calculate_tissuevolume( - p, handler3D->active_slice()), - 'g', 3) + + QString::number(handler3D->calculate_tissuevolume(p, handler3D->active_slice()), 'g', 3) + QString(" mm^3\n") + QString("'Target': ") + - QString::number(handler3D->calculate_volume( - p, handler3D->active_slice()), - 'g', 3) + + QString::number(handler3D->calculate_volume(p, handler3D->active_slice()), 'g', 3) + QString(" mm^3") + note + QString("\n(Select new object.)")); } } @@ -451,8 +481,7 @@ void MeasurementWidget::on_mouse_moved(Point p) } } -void MeasurementWidget::set_coord(unsigned short posit, Point p, - unsigned short slicenr) +void MeasurementWidget::set_coord(unsigned short posit, Point p, unsigned short slicenr) { pt[posit][0] = (int)p.px; pt[posit][1] = (int)p.py; @@ -482,8 +511,7 @@ void MeasurementWidget::cbb_changed(int) else p2 = labels[cbb_lb2->currentItem() - 1].p; addLine(&established, p1, p2); - txt_displayer->setText(QString::number(calculate(), 'g', 3) + - QString(" mm")); + txt_displayer->setText(QString::number(calculate(), 'g', 3) + QString(" mm")); } else if (rb_thick->isChecked()) { @@ -500,8 +528,7 @@ void MeasurementWidget::cbb_changed(int) else p2 = labels[cbb_lb2->currentItem() - 1].p; addLine(&established, p1, p2); - txt_displayer->setText(QString::number(calculate(), 'g', 3) + - QString(" mm")); + txt_displayer->setText(QString::number(calculate(), 'g', 3) + QString(" mm")); } else if (rb_vector->isChecked()) { @@ -544,8 +571,7 @@ void MeasurementWidget::cbb_changed(int) p3 = labels[cbb_lb3->currentItem() - 1].p; addLine(&established, p1, p2); addLine(&established, p2, p3); - txt_displayer->setText(QString::number(calculate(), 'g', 3) + - QString(" deg")); + txt_displayer->setText(QString::number(calculate(), 'g', 3) + QString(" deg")); } else if (rb_4ptangle->isChecked()) { @@ -572,8 +598,7 @@ void MeasurementWidget::cbb_changed(int) addLine(&established, p1, p2); addLine(&established, p2, p3); addLine(&established, p3, p4); - txt_displayer->setText(QString::number(calculate(), 'g', 3) + - QString(" deg")); + txt_displayer->setText(QString::number(calculate(), 'g', 3) + QString(" deg")); } emit vp1dyn_changed(&established, &dynamic); } @@ -581,26 +606,27 @@ void MeasurementWidget::cbb_changed(int) void MeasurementWidget::method_changed(int) { update_visualization(); } -void MeasurementWidget::inputtype_changed(int) { update_visualization(); } +void MeasurementWidget::inputtype_changed(int) +{ + update_visualization(); +} void MeasurementWidget::update_visualization() { if (labels.empty()) { - QObject::disconnect(inputgroup, SIGNAL(buttonClicked(int)), this, - SLOT(inputtype_changed(int))); - hbox2->hide(); + //BLdisconnect(inputgroup, SIGNAL(buttonClicked(int)), this, SLOT(inputtype_changed(int))); + input_area->hide(); rb_pts->setChecked(true); rb_lbls->setChecked(false); - QObject::connect(inputgroup, SIGNAL(buttonClicked(int)), this, - SLOT(inputtype_changed(int))); + //BLconnect(inputgroup, SIGNAL(buttonClicked(int)), this, SLOT(inputtype_changed(int))); } else { - hbox2->show(); + input_area->show(); } - if (rb_pts->isChecked()) + if (rb_pts->isChecked() || rb_vol->isChecked()) { state = 0; drawing = false; @@ -608,8 +634,7 @@ void MeasurementWidget::update_visualization() established.clear(); dynamic.clear(); emit vp1dyn_changed(&established, &dynamic); - hbox3->hide(); - hbox4->hide(); + stacked_widget->setCurrentIndex(0); if (rb_dist->isChecked() || rb_thick->isChecked() || rb_vector->isChecked()) { txt_displayer->setText("Mark start point."); @@ -624,42 +649,23 @@ void MeasurementWidget::update_visualization() } else if (rb_vol->isChecked()) { - hbox2->hide(); txt_displayer->setText("Select object."); } } else if (rb_lbls->isChecked()) { + stacked_widget->setCurrentIndex(1); if (rb_dist->isChecked() || rb_thick->isChecked() || rb_vector->isChecked()) { - hbox3->show(); - hbox4->hide(); - // txt_displayer->setText(QString::number(calculate(),'g',3)+QString(" mm")); + setActiveLabels(kP2); } else if (rb_angle->isChecked()) { - hbox3->show(); - hbox4->show(); - cbb_lb3->show(); - cbb_lb4->hide(); - txt_ccb4->hide(); - // txt_displayer->setText(QString::number(calculate(),'g',3)+QString(" deg")); + setActiveLabels(kP3); } else if (rb_4ptangle->isChecked()) { - hbox3->show(); - hbox4->show(); - cbb_lb3->show(); - cbb_lb4->show(); - txt_ccb4->show(); - // txt_displayer->setText(QString::number(calculate(),'g',3)+QString(" deg")); - } - else if (rb_vol->isChecked()) - { - hbox2->hide(); - hbox3->hide(); - hbox4->hide(); - txt_displayer->setText("Select object."); + setActiveLabels(kP4); } cbb_changed(0); } @@ -673,14 +679,10 @@ void MeasurementWidget::getlabels() cbb_lb3->clear(); cbb_lb4->clear(); - QObject::disconnect(cbb_lb1, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); - QObject::disconnect(cbb_lb2, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); - QObject::disconnect(cbb_lb3, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); - QObject::disconnect(cbb_lb4, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); + disconnect(cbb_lb1, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); + disconnect(cbb_lb2, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); + disconnect(cbb_lb3, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); + disconnect(cbb_lb4, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); cbb_lb1->insertItem(QString("Center")); cbb_lb2->insertItem(QString("Center")); @@ -695,14 +697,10 @@ void MeasurementWidget::getlabels() cbb_lb4->insertItem(QString(labels[i].name.c_str())); } - QObject::connect(cbb_lb1, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); - QObject::connect(cbb_lb2, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); - QObject::connect(cbb_lb3, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); - QObject::connect(cbb_lb4, SIGNAL(activated(int)), this, - SLOT(cbb_changed(int))); + connect(cbb_lb1, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); + connect(cbb_lb2, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); + connect(cbb_lb3, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); + connect(cbb_lb4, SIGNAL(activated(int)), this, SLOT(cbb_changed(int))); update_visualization(); } @@ -717,8 +715,6 @@ float MeasurementWidget::calculate() float value = 0; if (rb_lbls->isChecked()) { - //float thick=handler3D->get_slicethickness(); - //Pair p1=handler3D->get_pixelsize(); if (cbb_lb1->currentItem() == 0) { pt[0][0] = (int)handler3D->width() / 2; @@ -852,8 +848,6 @@ float MeasurementWidget::calculatevec(unsigned short orient) float value = 0; if (rb_lbls->isChecked()) { - //float thick=handler3D->get_slicethickness(); - //Pair p1=handler3D->get_pixelsize(); if (cbb_lb1->currentItem() == 0) { pt[0][0] = (int)handler3D->width() / 2; diff --git a/iSeg/MeasurementWidget.h b/iSeg/MeasurementWidget.h index 89f2a1c3..7cc4f3c9 100755 --- a/iSeg/MeasurementWidget.h +++ b/iSeg/MeasurementWidget.h @@ -15,15 +15,11 @@ #include "Interface/WidgetInterface.h" -#include -#include #include -#include -#include -#include -#include #include -#include + +class QStackedWidget; +class QLabel; namespace iseg { @@ -33,10 +29,9 @@ class MeasurementWidget : public WidgetInterface public: MeasurementWidget(SlicesHandler* hand3D, QWidget* parent = 0, const char* name = 0, Qt::WindowFlags wFlags = 0); - ~MeasurementWidget(); + ~MeasurementWidget() {} FILE* SaveParams(FILE* fp, int version) override; FILE* LoadParams(FILE* fp, int version) override; - QSize sizeHint() const override; void init() override; void cleanup() override; void newloaded() override; @@ -52,35 +47,32 @@ class MeasurementWidget : public WidgetInterface float calculate(); void set_coord(unsigned short posit, Point p, unsigned short slicenr); + enum eActiveLabels { kP1, kP2, kP3, kP4 }; + void setActiveLabels(eActiveLabels labels); + bmphandler* bmphand; SlicesHandler* handler3D; std::vector labels; unsigned short activeslice; - Q3HBox* hboxoverall; - Q3VBox* vboxmethods; - Q3HBox* hbox2; - Q3HBox* hbox3; - Q3HBox* hbox4; - Q3VBox* vbox1; - QLabel* txt_displayer; - QLabel* txt_ccb1; - QLabel* txt_ccb2; - QLabel* txt_ccb3; - QLabel* txt_ccb4; + QRadioButton* rb_vector; QRadioButton* rb_dist; QRadioButton* rb_thick; QRadioButton* rb_angle; QRadioButton* rb_4ptangle; QRadioButton* rb_vol; - QButtonGroup* modegroup; + QWidget* input_area; QRadioButton* rb_pts; QRadioButton* rb_lbls; - QButtonGroup* inputgroup; + + QStackedWidget* stacked_widget; + QLabel* txt_displayer; + QWidget* labels_area; QComboBox* cbb_lb1; QComboBox* cbb_lb2; QComboBox* cbb_lb3; QComboBox* cbb_lb4; + int state; int pt[4][3]; bool drawing; diff --git a/iSeg/OutlineCorrectionParameterViews.cpp b/iSeg/OutlineCorrectionParameterViews.cpp index 8decbbe9..bf3e03a6 100755 --- a/iSeg/OutlineCorrectionParameterViews.cpp +++ b/iSeg/OutlineCorrectionParameterViews.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include diff --git a/iSeg/OutlineCorrectionWidget.cpp b/iSeg/OutlineCorrectionWidget.cpp index 2b197aee..c827326a 100755 --- a/iSeg/OutlineCorrectionWidget.cpp +++ b/iSeg/OutlineCorrectionWidget.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace iseg { @@ -120,20 +120,20 @@ OutlineCorrectionWidget::OutlineCorrectionWidget(SlicesHandler* hand3D, QWidget* smooth_tissues_params = new SmoothTissuesParamView; // layouts - stacked_param_layout = new QStackedLayout; - stacked_param_layout->addWidget(brush_params); - stacked_param_layout->addWidget(olc_params); - stacked_param_layout->addWidget(fill_holes_params); - stacked_param_layout->addWidget(remove_islands_params); - stacked_param_layout->addWidget(fill_gaps_params); - stacked_param_layout->addWidget(add_skin_params); - stacked_param_layout->addWidget(fill_skin_params); - stacked_param_layout->addWidget(fill_all_params); - stacked_param_layout->addWidget(smooth_tissues_params); + stacked_params = new QStackedWidget; + stacked_params->addWidget(brush_params); + stacked_params->addWidget(olc_params); + stacked_params->addWidget(fill_holes_params); + stacked_params->addWidget(remove_islands_params); + stacked_params->addWidget(fill_gaps_params); + stacked_params->addWidget(add_skin_params); + stacked_params->addWidget(fill_skin_params); + stacked_params->addWidget(fill_all_params); + stacked_params->addWidget(smooth_tissues_params); auto top_layout = new QHBoxLayout; top_layout->addWidget(method_area); - top_layout->addLayout(stacked_param_layout); + top_layout->addWidget(stacked_params); setLayout(top_layout); // remember QStackedLayout page where parameters of method are added @@ -144,7 +144,7 @@ OutlineCorrectionWidget::OutlineCorrectionWidget(SlicesHandler* hand3D, QWidget* // start with brush tool brush->setChecked(true); - stacked_param_layout->setCurrentWidget(brush_params); + stacked_params->setCurrentWidget(brush_params); // create connections connect(methods, SIGNAL(buttonClicked(int)), this, SLOT(method_changed())); @@ -499,11 +499,11 @@ void OutlineCorrectionWidget::method_changed() { if (_widget_page.count(methods->checkedButton())) { - stacked_param_layout->setCurrentIndex(_widget_page[methods->checkedButton()]); + stacked_params->setCurrentIndex(_widget_page[methods->checkedButton()]); } // keep selected object definition across tools - auto new_widget = dynamic_cast(stacked_param_layout->currentWidget()); + auto new_widget = dynamic_cast(stacked_params->currentWidget()); if (current_params) { new_widget->set_work(current_params->work()); diff --git a/iSeg/OutlineCorrectionWidget.h b/iSeg/OutlineCorrectionWidget.h index 72cf6724..9f4c249f 100755 --- a/iSeg/OutlineCorrectionWidget.h +++ b/iSeg/OutlineCorrectionWidget.h @@ -15,7 +15,7 @@ class QButtonGroup; class QRadioButton; -class QStackedLayout; +class QStackedWidget; namespace iseg { @@ -76,7 +76,7 @@ class OutlineCorrectionWidget : public WidgetInterface QRadioButton* smooth_tissues; ParamViewBase* current_params = nullptr; - QStackedLayout* stacked_param_layout; + QStackedWidget* stacked_params; OLCorrParamView* olc_params; BrushParamView* brush_params; FillHolesParamView* fill_holes_params; diff --git a/iSeg/main.cpp b/iSeg/main.cpp index b61ad519..9b63f64b 100755 --- a/iSeg/main.cpp +++ b/iSeg/main.cpp @@ -226,7 +226,9 @@ int main(int argc, char** argv) mainWindow->setStyleSheet( "QWidget { color: white; }" "QPushButton:checked { background-color: rgb(150,150,150); font: bold }" - "QPushButton:disabled { background-color: rgb(40,40,40); color: rgb(128,128,128) }"); + "QPushButton:disabled { background-color: rgb(40,40,40); color: rgb(128,128,128) }" + "QComboBox:disabled { background-color: rgb(40,40,40); color: rgb(128,128,128) }"); + mainWindow->LoadLoadProj(latestprojpath); mainWindow->LoadAtlas(atlasdir); From 3a2c4f34e28ec91fa1065f9971a6427f53a7a8f7 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 19 Feb 2019 08:00:01 +0100 Subject: [PATCH 18/26] refactor Livewire widget: use Qt4 layouting, remove Qt3 stuff move helper functions to shared header: LayoutTools.h --- Interface/LayoutTools.h | 50 +++++++ iSeg/FastmarchingFuzzyWidget.cpp | 21 +-- iSeg/LivewireWidget.cpp | 175 ++++++++--------------- iSeg/LivewireWidget.h | 34 ++--- iSeg/MeasurementWidget.cpp | 23 +-- iSeg/OutlineCorrectionParameterViews.cpp | 23 +-- iSeg/PickerWidget.cpp | 15 +- iSeg/SmoothingWidget.h | 7 +- 8 files changed, 132 insertions(+), 216 deletions(-) create mode 100644 Interface/LayoutTools.h diff --git a/Interface/LayoutTools.h b/Interface/LayoutTools.h new file mode 100644 index 00000000..2698a793 --- /dev/null +++ b/Interface/LayoutTools.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018 The Foundation for Research on Information Technologies in Society (IT'IS). + * + * This file is part of iSEG + * (see https://github.com/ITISFoundation/osparc-iseg). + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ +#pragma once + +#include +#include +#include + +#include + +namespace iseg { + +inline QHBoxLayout* make_hbox(std::initializer_list list) +{ + auto box = new QHBoxLayout; + for (auto w : list) + { + box->addWidget(w); + } + return box; +} + +inline QVBoxLayout* make_vbox(std::initializer_list list) +{ + auto box = new QVBoxLayout; + for (auto w : list) + { + box->addWidget(w); + } + return box; +} + +inline QButtonGroup* make_button_group(QWidget* parent, std::initializer_list list) +{ + auto group = new QButtonGroup(parent); + for (auto w : list) + { + group->addButton(w); + } + return group; +} + +} \ No newline at end of file diff --git a/iSeg/FastmarchingFuzzyWidget.cpp b/iSeg/FastmarchingFuzzyWidget.cpp index a944c763..c423d2d3 100755 --- a/iSeg/FastmarchingFuzzyWidget.cpp +++ b/iSeg/FastmarchingFuzzyWidget.cpp @@ -15,8 +15,8 @@ #include "Core/ImageForestingTransform.h" -#include -#include +#include "Interface/LayoutTools.h" + #include #include #include @@ -24,28 +24,15 @@ #include #include -#include -#include - using namespace iseg; namespace { -QHBoxLayout* make_hbox(std::initializer_list list) -{ - auto hbox = new QHBoxLayout; - for (auto w : list) - { - hbox->addWidget(w); - } - return hbox; -} QWidget* add_to_widget(QLayout* layout) { auto widget = new QWidget; widget->setLayout(layout); return widget; } - } FastmarchingFuzzyWidget::FastmarchingFuzzyWidget(SlicesHandler* hand3D, @@ -105,9 +92,7 @@ FastmarchingFuzzyWidget::FastmarchingFuzzyWidget(SlicesHandler* hand3D, "The boundary is continuously expanding. The Sigma parameter " "(Gaussian smoothing) controls the impact of noise.")); - auto bg_method = new QButtonGroup(this); - bg_method->insert(rb_fastmarch); - bg_method->insert(rb_fuzzy); + auto bg_method = make_button_group(this, {rb_fastmarch, rb_fuzzy}); rb_fastmarch->setChecked(true); rb_drag = new QRadioButton(tr("Drag")); diff --git a/iSeg/LivewireWidget.cpp b/iSeg/LivewireWidget.cpp index c91f82a7..e8343e84 100755 --- a/iSeg/LivewireWidget.cpp +++ b/iSeg/LivewireWidget.cpp @@ -15,28 +15,14 @@ #include "Data/addLine.h" +#include "Interface/LayoutTools.h" + #include "Core/ImageForestingTransform.h" #include "Core/Pair.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define UNREFERENCED_PARAMETER(P) (P) - -using namespace std; +#include +#include + using namespace iseg; LivewireWidget::LivewireWidget(SlicesHandler* hand3D, QWidget* parent, @@ -49,18 +35,12 @@ LivewireWidget::LivewireWidget(SlicesHandler* hand3D, QWidget* parent, activeslice = handler3D->active_slice(); bmphand = handler3D->get_activebmphandler(); - hboxoverall = new Q3HBox(this); - hboxoverall->setMargin(8); - vboxmethods = new Q3VBox(hboxoverall); - vbox1 = new Q3VBox(hboxoverall); - drawing = false; lw = lwfirst = nullptr; - drawmode = new QButtonGroup(this); - - straight = new QRadioButton(QString("Straight"), vboxmethods); - autotrace = new QRadioButton(QString("Auto Trace"), vboxmethods); + // parameters + straight = new QRadioButton(QString("Straight")); + autotrace = new QRadioButton(QString("Auto Trace")); autotrace->setToolTip(Format( "The Livewire (intelligent scissors) algorithm " "to automatically identify the ideal contour path.This algorithm uses " @@ -80,63 +60,61 @@ LivewireWidget::LivewireWidget(SlicesHandler* hand3D, QWidget* parent, "mouse button. A double left click closes the contour while a double " "middle " "click aborts the line drawing process.")); - freedraw = new QRadioButton(QString("Free"), vboxmethods); - drawmode->insert(straight); - drawmode->insert(autotrace); - drawmode->insert(freedraw); - autotrace->setChecked(TRUE); - - hbox2 = new Q3HBox(vbox1); - cb_freezing = new QCheckBox("Freezing", hbox2); - cb_freezing->setToolTip( - Format("Specify the number of seconds after which a line segment is " - "frozen even without mouse click if it has not changed.")); - lb_freezing1 = new QLabel("Delay: ", hbox2); - sb_freezing = new QSpinBox(1, 10, 1, hbox2); + freedraw = new QRadioButton(QString("Free")); + auto drawmode = make_button_group(this, {straight, autotrace, freedraw}); + autotrace->setChecked(true); + + cb_freezing = new QCheckBox; + cb_freezing->setToolTip(Format( + "Specify the number of seconds after which a line segment is " + "frozen even without mouse click if it has not changed.")); + sb_freezing = new QSpinBox(1, 10, 1, nullptr); sb_freezing->setValue(3); - lb_freezing2 = new QLabel("seconds", hbox2); - hbox3 = new Q3HBox(vbox1); - cb_closing = new QCheckBox("Close Contour", hbox3); + cb_closing = new QCheckBox; cb_closing->setChecked(true); - vboxmethods->setMargin(5); - vbox1->setMargin(5); - vboxmethods->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + // layout + auto method_layout = make_vbox({straight, autotrace, freedraw}); + auto method_area = new QFrame; + method_area->setLayout(method_layout); + method_area->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + method_area->setLineWidth(1); + method_area->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + + params_layout = new QFormLayout; + params_layout->addRow("Close contour", cb_closing); + params_layout->addRow("Freezing", cb_freezing); + params_layout->addRow("Freezing delay (s)", sb_freezing); + + auto top_layout = new QHBoxLayout; + top_layout->addWidget(method_area); + top_layout->addLayout(params_layout); + + setLayout(top_layout); + // initialize cooling = false; cb_freezing->setChecked(cooling); - hbox2->setFixedSize(hbox2->sizeHint() + QSize(100, 0)); - hbox3->setFixedSize(hbox3->sizeHint() + QSize(100, 0)); - vbox1->setFixedSize(vbox1->sizeHint() + QSize(50, 0)); - sbfreezing_changed(sb_freezing->value()); freezing_changed(); mode_changed(); - QObject::connect(drawmode, SIGNAL(buttonClicked(int)), this, - SLOT(mode_changed())); - QObject::connect(cb_freezing, SIGNAL(clicked()), this, - SLOT(freezing_changed())); - QObject::connect(sb_freezing, SIGNAL(valueChanged(int)), this, - SLOT(sbfreezing_changed(int))); - - return; + // connections + connect(drawmode, SIGNAL(buttonClicked(int)), this, SLOT(mode_changed())); + connect(cb_freezing, SIGNAL(clicked()), this, SLOT(freezing_changed())); + connect(sb_freezing, SIGNAL(valueChanged(int)), this, SLOT(sbfreezing_changed(int))); } LivewireWidget::~LivewireWidget() { - delete vbox1; - delete drawmode; if (lw != nullptr) delete lw; if (lwfirst != nullptr) delete lwfirst; } -QSize LivewireWidget::sizeHint() const { return hboxoverall->sizeHint(); } - void LivewireWidget::on_mouse_clicked(Point p) { if (!drawing) @@ -265,7 +243,7 @@ void LivewireWidget::pt_midclicked(Point p) establishedlengths.pop_back(); p1 = clicks.back(); addLine(&dynamic, p1, p); - vector::iterator it = clicks.begin(); + auto it = clicks.begin(); Point pp = p2; it++; while (it != clicks.end()) @@ -283,7 +261,7 @@ void LivewireWidget::pt_midclicked(Point p) dynamic.clear(); clicks.pop_back(); establishedlengths.pop_back(); - vector::iterator it1 = established.begin(); + auto it1 = established.begin(); for (int i = 0; i < establishedlengths.back(); i++) it1++; established.erase(it1, established.end()); @@ -294,7 +272,7 @@ void LivewireWidget::pt_midclicked(Point p) { times.resize(dynamic.size()); QTime now = QTime::currentTime(); - vector::iterator tit = times.begin(); + auto tit = times.begin(); while (tit != times.end()) { *tit = now; @@ -313,7 +291,6 @@ void LivewireWidget::pt_midclicked(Point p) void LivewireWidget::pt_doubleclickedmid(Point p) { - UNREFERENCED_PARAMETER(p); if (drawing) { dynamic.clear(); @@ -392,11 +369,11 @@ void LivewireWidget::on_mouse_moved(Point p) if (cooling) { - vector::reverse_iterator rit, ritold; + std::vector::reverse_iterator rit, ritold; rit = dynamic.rbegin(); ritold = dynamicold.rbegin(); times.resize(dynamic.size()); - vector::iterator tit = times.begin(); + auto tit = times.begin(); while (rit != dynamic.rend() && ritold != dynamicold.rend() && (*rit).px == (*ritold).px && (*rit).py == (*ritold).py) { @@ -612,41 +589,19 @@ void LivewireWidget::bmphand_changed(bmphandler* bmph) void LivewireWidget::mode_changed() { - if (autotrace->isChecked()) - { - hbox2->show(); - } - else - { - hbox2->hide(); - } + cb_freezing->setEnabled(autotrace->isChecked()); + params_layout->labelForField(cb_freezing)->setEnabled(autotrace->isChecked()); + freezing_changed(); - if (freedraw->isChecked()) - { - hbox3->hide(); - } - else - { - hbox3->show(); - } + cb_closing->setEnabled(!freedraw->isChecked()); + params_layout->labelForField(cb_closing)->setEnabled(cb_closing->isEnabled()); } void LivewireWidget::freezing_changed() { - if (cb_freezing->isChecked()) - { - cooling = true; - sb_freezing->show(); - lb_freezing1->show(); - lb_freezing2->show(); - } - else - { - cooling = false; - sb_freezing->hide(); - lb_freezing1->hide(); - lb_freezing2->hide(); - } + cooling = cb_freezing->isChecked(); + sb_freezing->setEnabled(cooling && autotrace->isChecked()); + params_layout->labelForField(sb_freezing)->setEnabled(sb_freezing->isEnabled()); } void LivewireWidget::sbfreezing_changed(int i) @@ -681,12 +636,9 @@ FILE* LivewireWidget::LoadParams(FILE* fp, int version) { if (version >= 2) { - QObject::disconnect(drawmode, SIGNAL(buttonClicked(int)), this, - SLOT(mode_changed())); - QObject::disconnect(cb_freezing, SIGNAL(clicked()), this, - SLOT(freezing_changed())); - QObject::disconnect(sb_freezing, SIGNAL(valueChanged(int)), this, - SLOT(sbfreezing_changed(int))); + //disconnect(drawmode, SIGNAL(buttonClicked(int)), this, SLOT(mode_changed())); + disconnect(cb_freezing, SIGNAL(clicked()), this, SLOT(freezing_changed())); + disconnect(sb_freezing, SIGNAL(valueChanged(int)), this, SLOT(sbfreezing_changed(int))); int dummy; fread(&dummy, sizeof(int), 1, fp); @@ -706,12 +658,9 @@ FILE* LivewireWidget::LoadParams(FILE* fp, int version) freezing_changed(); mode_changed(); - QObject::connect(drawmode, SIGNAL(buttonClicked(int)), this, - SLOT(mode_changed())); - QObject::connect(cb_freezing, SIGNAL(clicked()), this, - SLOT(freezing_changed())); - QObject::connect(sb_freezing, SIGNAL(valueChanged(int)), this, - SLOT(sbfreezing_changed(int))); + //connect(drawmode, SIGNAL(buttonClicked(int)), this, SLOT(mode_changed())); + connect(cb_freezing, SIGNAL(clicked()), this, SLOT(freezing_changed())); + connect(sb_freezing, SIGNAL(valueChanged(int)), this, SLOT(sbfreezing_changed(int))); } return fp; } @@ -719,6 +668,6 @@ FILE* LivewireWidget::LoadParams(FILE* fp, int version) void LivewireWidget::hideparams_changed() { mode_changed(); - if (hideparams && !cb_freezing->isChecked()) - hbox2->hide(); + //if (hideparams && !cb_freezing->isChecked()) + // hbox2->hide(); } diff --git a/iSeg/LivewireWidget.h b/iSeg/LivewireWidget.h index ab5d8794..244dcb09 100755 --- a/iSeg/LivewireWidget.h +++ b/iSeg/LivewireWidget.h @@ -17,25 +17,12 @@ #include "Core/ImageForestingTransform.h" -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include #include -#include -#include +class QFormLayout; namespace iseg { @@ -52,7 +39,6 @@ class LivewireWidget : public WidgetInterface FILE* SaveParams(FILE* fp, int version) override; FILE* LoadParams(FILE* fp, int version) override; void hideparams_changed() override; - QSize sizeHint() const override; std::string GetName() override { return std::string("Contour"); } QIcon GetIcon(QDir picdir) override { return QIcon(picdir.absFilePath(QString("contour.png"))); } @@ -82,22 +68,18 @@ class LivewireWidget : public WidgetInterface bmphandler* bmphand; SlicesHandler* handler3D; unsigned short activeslice; - Q3HBox* hboxoverall; - Q3VBox* vboxmethods; - Q3VBox* vbox1; - Q3HBox* hbox2; - Q3HBox* hbox3; + + QRadioButton* autotrace; + QRadioButton* straight; + QRadioButton* freedraw; + + QFormLayout* params_layout; QCheckBox* cb_freezing; QCheckBox* cb_closing; QSpinBox* sb_freezing; - QLabel* lb_freezing1; - QLabel* lb_freezing2; QPushButton* pushexec; + bool straightmode; - QRadioButton* autotrace; - QRadioButton* straight; - QRadioButton* freedraw; - QButtonGroup* drawmode; Point p1, p2; std::vector establishedlengths; diff --git a/iSeg/MeasurementWidget.cpp b/iSeg/MeasurementWidget.cpp index b4b23c2b..48afa0e8 100755 --- a/iSeg/MeasurementWidget.cpp +++ b/iSeg/MeasurementWidget.cpp @@ -18,6 +18,8 @@ #include "Data/Point.h" #include "Data/addLine.h" +#include "Interface/LayoutTools.h" + #include "Core/Pair.h" #include @@ -30,27 +32,6 @@ using namespace iseg; -namespace { -QHBoxLayout* make_hbox(std::initializer_list list) -{ - auto box = new QHBoxLayout; - for (auto w : list) - { - box->addWidget(w); - } - return box; -} -QVBoxLayout* make_vbox(std::initializer_list list) -{ - auto box = new QVBoxLayout; - for (auto w : list) - { - box->addWidget(w); - } - return box; -} -} - MeasurementWidget::MeasurementWidget(SlicesHandler* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), handler3D(hand3D) diff --git a/iSeg/OutlineCorrectionParameterViews.cpp b/iSeg/OutlineCorrectionParameterViews.cpp index bf3e03a6..425921af 100755 --- a/iSeg/OutlineCorrectionParameterViews.cpp +++ b/iSeg/OutlineCorrectionParameterViews.cpp @@ -12,6 +12,7 @@ #include "OutlineCorrectionParameterViews.h" #include "Interface/FormatTooltip.h" +#include "Interface/LayoutTools.h" #include #include @@ -19,30 +20,8 @@ #include #include -#include - namespace iseg { -QHBoxLayout* make_hbox(std::initializer_list list) -{ - auto hbox = new QHBoxLayout; - for (auto w : list) - { - hbox->addWidget(w); - } - return hbox; -} - -QButtonGroup* make_button_group(QWidget* parent, std::initializer_list list) -{ - auto group = new QButtonGroup(parent); - for (auto w : list) - { - group->addButton(w); - } - return group; -} - OLCorrParamView::OLCorrParamView(QWidget* parent /*= 0*/) : ParamViewBase(parent) { _target = new QRadioButton(QString("Target")); diff --git a/iSeg/PickerWidget.cpp b/iSeg/PickerWidget.cpp index 51cff1bb..d58a3ff2 100755 --- a/iSeg/PickerWidget.cpp +++ b/iSeg/PickerWidget.cpp @@ -13,28 +13,17 @@ #include "Data/addLine.h" +#include "Interface/LayoutTools.h" + #include "Core/Pair.h" #include #include #include -#include using namespace iseg; -namespace { -QHBoxLayout* make_hbox(std::initializer_list list) -{ - auto hbox = new QHBoxLayout; - for (auto w : list) - { - hbox->addWidget(w); - } - return hbox; -} -} - PickerWidget::PickerWidget(SlicesHandler* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) : WidgetInterface(parent, name, wFlags), handler3D(hand3D) diff --git a/iSeg/SmoothingWidget.h b/iSeg/SmoothingWidget.h index 33a70af5..9fb34016 100755 --- a/iSeg/SmoothingWidget.h +++ b/iSeg/SmoothingWidget.h @@ -79,15 +79,16 @@ class SmoothingWidget : public WidgetInterface QSpinBox* sb_iter; QSpinBox* sb_kmax; // QSpinBox *sb_restrainmax; - QPushButton* pushexec; - QPushButton* contdiff; + QCheckBox* allslices; QRadioButton* rb_gaussian; QRadioButton* rb_average; QRadioButton* rb_median; QRadioButton* rb_sigmafilter; QRadioButton* rb_anisodiff; QButtonGroup* modegroup; - QCheckBox* allslices; + QPushButton* pushexec; + QPushButton* contdiff; + bool dontundo; private slots: From 81170e695a8274515623045d27b31abcb9c07bcb Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Wed, 20 Feb 2019 23:25:11 +0100 Subject: [PATCH 19/26] feature: add voxeling of lines (currently via .vtk file format) --- Core/ImageWriter.cpp | 4 +- Core/VoxelSurface.cpp | 150 ++++++++++++++++++------ Core/VoxelSurface.h | 35 +++--- Data/ImageToITK.h | 178 ++++++++++++++++++----------- Data/SlicesHandlerITKInterface.cpp | 9 +- Data/SlicesHandlerITKInterface.h | 64 +---------- iSeg/MainWindow.cpp | 15 +-- iSeg/SlicesHandler.cpp | 32 ++++-- iSeg/SlicesHandler.h | 2 +- 9 files changed, 290 insertions(+), 199 deletions(-) diff --git a/Core/ImageWriter.cpp b/Core/ImageWriter.cpp index def2c02a..66483d0f 100755 --- a/Core/ImageWriter.cpp +++ b/Core/ImageWriter.cpp @@ -32,7 +32,9 @@ using namespace iseg; template bool ImageWriter::writeVolume(const std::string& filename, const std::vector& all_slices, bool active_slices, const SlicesHandlerInterface* handler) { - auto image = SlicesHandlerITKInterface::GetITKView(all_slices, handler->start_slice(), handler->end_slice(), handler); + unsigned dims[3] = {handler->width(), handler->height(), handler->num_slices()}; + auto image = wrapToITK(all_slices, dims, handler->start_slice(), handler->end_slice(), handler->spacing(), handler->transform()); + if (image) { boost::filesystem::path path(filename); diff --git a/Core/VoxelSurface.cpp b/Core/VoxelSurface.cpp index 3a8cc285..6f030f94 100755 --- a/Core/VoxelSurface.cpp +++ b/Core/VoxelSurface.cpp @@ -12,6 +12,7 @@ #include "VoxelSurface.h" #include "Data/Transform.h" +#include "Data/ImageToITK.h" #include #include @@ -30,6 +31,10 @@ #include #include +#include +#include +#include + using namespace iseg; namespace { @@ -56,30 +61,81 @@ float round_me_dn(float n, const float to_what) return n; } -} // namespace - -VoxelSurface::eSurfaceImageOverlap - VoxelSurface::Run(const char* filename, const unsigned dims[3], - const float spacing[3], const Transform& transform, - float** slices, unsigned startslice, - unsigned endslice) const +template +VoxelSurface::eSurfaceImageOverlap voxelPolyline(const std::vector>& polyline, + TImage* label_field, float label, int startslice, int endslice) { - vtkNew reader; - reader->SetFileName(filename); - reader->Update(); - if (reader->GetOutput()) + using label_field_type = TImage; + using path_type = itk::PolyLineParametricPath<3>; + + VoxelSurface::eSurfaceImageOverlap ret = VoxelSurface::kNone; + for (size_t i = 1; i < polyline.size(); ++i) { - return Run(reader->GetOutput(), dims, spacing, transform, slices, - startslice, endslice); + auto p0 = polyline[i - 1]; + auto p1 = polyline[i]; + + itk::Index<3> idx0, idx1; + auto p0in = label_field->TransformPhysicalPointToIndex(p0, idx0); + auto p1in = label_field->TransformPhysicalPointToIndex(p1, idx1); + + auto path = path_type::New(); + path->Initialize(); + if (p0in && p1in) + { + if (ret == VoxelSurface::kNone) + ret = VoxelSurface::kContained; + + path->AddVertex(idx0); + path->AddVertex(idx1); + } + else if (p0in || p1in) + { + ret = VoxelSurface::kPartial; + + if (p1in) // reduce to one case + { + std::swap(p0, p1); + std::swap(idx0, idx1); + } + + path->AddVertex(idx0); + + // do iterative bisection to find point close (and inside) to boundary + itk::Point pnew; + for (int iter=0; iter<10; iter++) + { + if (p0 != p1) + { + pnew.SetToMidPoint(p0, p1); + auto pnewin = label_field->TransformPhysicalPointToIndex(pnew, idx1); + if (pnewin) + p0 = pnew; + else + p1 = pnew; + } + } + label_field->TransformPhysicalPointToIndex(p0, idx1); + path->AddVertex(idx1); + } + + if (path->GetVertexList()->Size()) + { + itk::PathIterator it(label_field, path); + for (it.GoToBegin(); !it.IsAtEnd(); ++it) + { + if (it.GetIndex()[2] >= startslice && it.GetIndex()[2] < endslice) + { + it.Set(label); + } + } + } } - return eSurfaceImageOverlap::kNone; + return ret; } -VoxelSurface::eSurfaceImageOverlap - VoxelSurface::Run(vtkPolyData* surface, const unsigned dims[3], - const float spacing[3], const Transform& transform, - float** slices, unsigned startslice, - unsigned endslice) const +VoxelSurface::eSurfaceImageOverlap voxelSurface(vtkPolyData* surface, float** slices, const unsigned dims[3], + const float spacing[3], const Transform& transform, + float label, unsigned startslice, unsigned endslice) { // instead of applying the transform to the image, we inverse transform the surface auto m = to_double(transform); @@ -97,18 +153,18 @@ VoxelSurface::eSurfaceImageOverlap (dims[1] - 1) * spacing[1], 0, (dims[2] - 1) * spacing[2]); - eSurfaceImageOverlap result = kNone; + VoxelSurface::eSurfaceImageOverlap result = VoxelSurface::kNone; if (image_bb.Contains(surface_bb)) { - result = eSurfaceImageOverlap::kContained; + result = VoxelSurface::eSurfaceImageOverlap::kContained; } else if (image_bb.Intersects(surface_bb)) { - result = eSurfaceImageOverlap::kPartial; + result = VoxelSurface::eSurfaceImageOverlap::kPartial; } else { - return eSurfaceImageOverlap::kNone; + return VoxelSurface::eSurfaceImageOverlap::kNone; } vtkNew surface_inverse_transformed; @@ -232,7 +288,7 @@ VoxelSurface::eSurfaceImageOverlap int ds_y = offset_y + ct_y; int index = ds_x + ds_y * (dims[0]); - workBits[index] = m_ForeGroundValue; + workBits[index] = label; } } } @@ -243,13 +299,43 @@ VoxelSurface::eSurfaceImageOverlap return result; } -VoxelSurface::eSurfaceImageOverlap VoxelSurface::Intersect(const char* filename, const unsigned dims[3], const float spacing[3], const Transform& transform, float** slices, unsigned startslice, unsigned endslice, double rel_tolerance) +} // namespace + +VoxelSurface::eSurfaceImageOverlap VoxelSurface::Voxelize(vtkPolyData* polydata, + std::vector& all_slices, const unsigned dims[3], + const Vec3& spacing, const Transform& transform, + unsigned startslice, unsigned endslice) const { - vtkNew reader; - reader->SetFileName(filename); - reader->Update(); - auto surface = reader->GetOutput(); + eSurfaceImageOverlap res = kNone; + if (polydata->GetNumberOfPolys() != 0) + { + return voxelSurface(polydata, all_slices.data(), dims, spacing.v, transform, m_ForeGroundValue, startslice, endslice); + } + else if (polydata->GetNumberOfLines() != 0) + { + using image_type = itk::SliceContiguousImage; + auto image = wrapToITK(all_slices, dims, 0, dims[2], spacing, transform); + + vtkIdType npts, *pts; + vtkCellArray* lines = polydata->GetLines(); + for (lines->InitTraversal(); lines->GetNextCell(npts, pts); ) + { + std::vector> line(npts); + for (vtkIdType i=0; iGetPoint(pts[i], line[i].GetDataPointer()); + } + res = std::max(res, voxelPolyline(line, image, m_ForeGroundValue, startslice, endslice)); + } + } + return res; +} +VoxelSurface::eSurfaceImageOverlap VoxelSurface::Intersect(vtkPolyData* surface, + std::vector& all_slices, const unsigned dims[3], + const Vec3& spacing, const Transform& transform, + unsigned startslice, unsigned endslice, double rel_tolerance) +{ // instead of applying the transform to the image, we inverse transform the surface auto m = to_double(transform); vtkNew inverse_transform; @@ -284,7 +370,7 @@ VoxelSurface::eSurfaceImageOverlap VoxelSurface::Intersect(const char* filename, surface->BuildCells(); auto num_cells = surface->GetNumberOfCells(); - double tol = (*std::min_element(spacing, spacing + 3)) * rel_tolerance; + double tol = (*std::min_element(spacing.v, spacing.v + 3)) * rel_tolerance; vtkIdType *pts, npts; double bb[6]; int bbi[6]; @@ -332,7 +418,7 @@ VoxelSurface::eSurfaceImageOverlap VoxelSurface::Intersect(const char* filename, ijk[1] < dims[1] && ijk[2] < dims[2]) { - float* slice = slices[ijk[2]]; + float* slice = all_slices[ijk[2]]; slice[ijk[0] + dims[0] * ijk[1]] = m_ForeGroundValue; } @@ -344,7 +430,7 @@ VoxelSurface::eSurfaceImageOverlap VoxelSurface::Intersect(const char* filename, ijk[1] < dims[1] && ijk[2] < dims[2]) { - float* slice = slices[ijk[2]]; + float* slice = all_slices[ijk[2]]; slice[ijk[0] + dims[0] * ijk[1]] = m_ForeGroundValue; } } diff --git a/Core/VoxelSurface.h b/Core/VoxelSurface.h index a55a377e..c828a729 100755 --- a/Core/VoxelSurface.h +++ b/Core/VoxelSurface.h @@ -11,6 +11,10 @@ #include "iSegCore.h" +#include "Data/Transform.h" + +#include + class vtkPolyData; namespace iseg { @@ -22,22 +26,21 @@ class ISEG_CORE_API VoxelSurface public: VoxelSurface(float fg = 255.f) : m_ForeGroundValue(fg) {} - enum eSurfaceImageOverlap { kNone, - kPartial, - kContained }; - - eSurfaceImageOverlap Run(const char* filename, const unsigned dims[3], - const float spacing[3], const Transform& transform, - float** slices, unsigned startslice, - unsigned endslice) const; - eSurfaceImageOverlap Run(vtkPolyData* surface, const unsigned dims[3], - const float spacing[3], const Transform& transform, - float** slices, unsigned startslice, - unsigned endslice) const; - - eSurfaceImageOverlap Intersect(const char* filename, const unsigned dims[3], - const float spacing[3], const Transform& transform, - float** slices, unsigned startslice, unsigned endslice, + enum eSurfaceImageOverlap { + kNone = 0, + kContained = 1, + kPartial = 2 + }; + + eSurfaceImageOverlap Voxelize(vtkPolyData* polydata, + std::vector& all_slices, const unsigned dims[3], + const Vec3& spacing, const Transform& transform, + unsigned startslice, unsigned endslice) const; + + eSurfaceImageOverlap Intersect(vtkPolyData* surface, + std::vector& all_slices, const unsigned dims[3], + const Vec3& spacing, const Transform& transform, + unsigned startslice, unsigned endslice, double relative_tolerance = 0.1); private: diff --git a/Data/ImageToITK.h b/Data/ImageToITK.h index 84b2642a..7f9af7f2 100644 --- a/Data/ImageToITK.h +++ b/Data/ImageToITK.h @@ -13,88 +13,130 @@ #include "Transform.h" #include +#include + +#include namespace iseg { -class ImageToITK +inline void copyToITK(const Transform& transform, + typename itk::Point& origin, + typename itk::Matrix& direction) { -public: - static void copy(const Transform& transform, - typename itk::Point& origin, - typename itk::Matrix& direction) - { - transform.getRotation(direction); - transform.getOffset(origin); - } + transform.getRotation(direction); + transform.getOffset(origin); +} - template - static void setup(unsigned width, unsigned height, unsigned startslice, - unsigned nrslices, const float spacing[3], - const Transform& transform, itk::Image* image) - { - typedef itk::Image ImageType; - - typename ImageType::IndexType start; - start[0] = 0; // first index on X - start[1] = 0; // first index on Y - start[2] = startslice; // first index on Z - typename ImageType::SizeType size; - size[0] = width; // size along X - size[1] = height; // size along Y - size[2] = nrslices; // size along Z - typename ImageType::RegionType region; - region.SetSize(size); - region.SetIndex(start); - - typename ImageType::PointType origin; - typename ImageType::DirectionType direction; - ImageToITK::copy(transform, origin, direction); - - image->SetRegions(region); - image->SetSpacing(spacing); - image->SetOrigin(origin); - image->SetDirection(direction); - image->Allocate(); - } +template +typename itk::Image::Pointer allocateImage(const unsigned dimensions[3], + unsigned start_slice, unsigned end_slice, + const Vec3& spacing, const Transform& transform) +{ + typedef itk::Image ImageType; - template - static void copy(const T** data, unsigned width, unsigned height, - unsigned startslice, unsigned nrslices, - const float spacing[3], const Transform& transform, - itk::Image* image) - { - setup(width, height, startslice, nrslices, spacing, transform, image); + typename ImageType::IndexType start; + start[0] = 0; // first index on X + start[1] = 0; // first index on Y + start[2] = start_slice; // first index on Z + typename ImageType::SizeType size; + size[0] = dimensions[0]; // size along X + size[1] = dimensions[1]; // size along Y + size[2] = dimensions[2]; // size along Z + typename ImageType::RegionType region; + region.SetSize(size); + region.SetIndex(start); + + typename ImageType::PointType origin; + typename ImageType::DirectionType direction; + toITK(transform, origin, direction); + + auto image = itk::Image::New(); + image->SetRegions(region); + image->SetSpacing(spacing); + image->SetOrigin(origin); + image->SetDirection(direction); + image->Allocate(); + return image; +} - typename itk::Image::IndexType pi; - auto size = image->GetLargestPossibleRegion().GetSize(); +template +typename itk::Image::Pointer copyToITK(const std::vector& all_slices, const unsigned dimensions[3], + unsigned start_slice, unsigned end_slice, + const Vec3& spacing, const Transform& transform) +{ + auto image = allocateImage(dimensions, start_slice, end_slice, spacing, transform); + + typename itk::Image::IndexType pi; + auto size = image->GetLargestPossibleRegion().GetSize(); - for (unsigned z = 0; z < size[2]; z++) + // \todo copy using std::copy per slice + for (unsigned z = 0; z < size[2]; z++) + { + const T* slice = all_slices[start_slice + z]; + pi.SetElement(2, z); + size_t idx = 0; + for (unsigned y = 0; y < size[1]; y++) { - const T* slice = data[startslice + z]; - pi.SetElement(2, z); - size_t idx = 0; - for (unsigned y = 0; y < size[1]; y++) + pi.SetElement(1, y); + for (unsigned x = 0; x < size[0]; x++, idx++) { - pi.SetElement(1, y); - for (unsigned x = 0; x < size[0]; x++, idx++) - { - pi.SetElement(0, x); - image->SetPixel(pi, slice[idx]); - } + pi.SetElement(0, x); + image->SetPixel(pi, slice[idx]); } } } + return image; +} - template - static typename itk::Image::Pointer - copy(const T** data, unsigned width, unsigned height, - unsigned startslice, unsigned nrslices, const float spacing[3], - const Transform& transform) +template +typename itk::SliceContiguousImage::Pointer wrapToITK(const std::vector& all_slices, const unsigned dims[3], + unsigned start_slice, unsigned end_slice, + const Vec3& spacing, const Transform& transform) +{ + using SliceContiguousImageType = itk::SliceContiguousImage; + + typename SliceContiguousImageType::IndexType start; + start.Fill(0); + + typename SliceContiguousImageType::SizeType size; + size[0] = dims[0]; + size[1] = dims[1]; + size[2] = dims[2]; + + typename SliceContiguousImageType::RegionType region(start, size); + + assert(end_slice > start_slice); + if (end_slice > start_slice) { - auto image = itk::Image::New(); - copy(data, width, height, startslice, nrslices, spacing, transform, - image.GetPointer()); - return image; + // \note deactivated, because instead I set the extent above to start-end + // // correct transform if we are exporting active slices + // int cropping[] = { 0,0,handler->start_slice() }; + // transform.paddingUpdateTransform(cropping, spacing.v); + + start[2] = start_slice; + size[2] = end_slice - start_slice; } -}; + + itk::Point origin; + transform.getOffset(origin); + + itk::Matrix direction; + transform.getRotation(direction); + + auto image = SliceContiguousImageType::New(); + image->SetSpacing(spacing.v); + image->SetOrigin(origin); + image->SetDirection(direction); + image->SetRegions(region); + image->Allocate(); + + // Set slice pointers + std::vector slices = all_slices; + auto container = SliceContiguousImageType::PixelContainer::New(); + container->SetImportPointersForSlices(slices, size[0] * size[1], false); + image->SetPixelContainer(container); + + return image; +} + } // namespace iseg diff --git a/Data/SlicesHandlerITKInterface.cpp b/Data/SlicesHandlerITKInterface.cpp index 8c5294af..4fd82751 100644 --- a/Data/SlicesHandlerITKInterface.cpp +++ b/Data/SlicesHandlerITKInterface.cpp @@ -14,7 +14,8 @@ itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetSource(b itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetSource(size_t start_slice, size_t end_slice) { - return GetITKView(_handler->source_slices(), start_slice, end_slice, _handler); + unsigned dims[3] = {_handler->width(), _handler->height(), _handler->num_slices()}; + return wrapToITK(_handler->source_slices(), dims, start_slice, end_slice, _handler->spacing(), _handler->transform()); } itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetTarget(bool active_slices) @@ -27,7 +28,8 @@ itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetTarget(b itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetTarget(size_t start_slice, size_t end_slice) { - return GetITKView(_handler->target_slices(), start_slice, end_slice, _handler); + unsigned dims[3] = {_handler->width(), _handler->height(), _handler->num_slices()}; + return wrapToITK(_handler->target_slices(), dims, start_slice, end_slice, _handler->spacing(), _handler->transform()); } itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetTissues(bool active_slices) @@ -40,8 +42,9 @@ itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::Ge itk::SliceContiguousImage::Pointer SlicesHandlerITKInterface::GetTissues(size_t start_slice, size_t end_slice) { + unsigned dims[3] = {_handler->width(), _handler->height(), _handler->num_slices()}; auto all_slices = _handler->tissue_slices(_handler->active_tissuelayer()); - return GetITKView(all_slices, start_slice, end_slice, _handler); + return wrapToITK(all_slices, dims, start_slice, end_slice, _handler->spacing(), _handler->transform()); } template diff --git a/Data/SlicesHandlerITKInterface.h b/Data/SlicesHandlerITKInterface.h index 42343c86..5eb6f3ae 100644 --- a/Data/SlicesHandlerITKInterface.h +++ b/Data/SlicesHandlerITKInterface.h @@ -9,13 +9,9 @@ */ #pragma once -#include "SlicesHandlerInterface.h" -#include "Transform.h" -#include "Vec3.h" #include "iSegData.h" - -#include -#include +#include "SlicesHandlerInterface.h" +#include "ImageToITK.h" namespace iseg { @@ -30,9 +26,6 @@ class ISEG_DATA_API SlicesHandlerITKInterface SlicesHandlerITKInterface(SlicesHandlerInterface* sh) : _handler(sh) {} - template - static typename itk::SliceContiguousImage::Pointer GetITKView(const std::vector& all_slices, size_t start_slice, size_t end_slice, const SlicesHandlerInterface* handler); - itk::SliceContiguousImage::Pointer GetSource(bool active_slices); itk::SliceContiguousImage::Pointer GetSource(size_t start_slice, size_t end_slice); itk::SliceContiguousImage::Pointer GetTarget(bool active_slices); @@ -60,57 +53,4 @@ class ISEG_DATA_API SlicesHandlerITKInterface SlicesHandlerInterface* _handler; }; -template -typename itk::SliceContiguousImage::Pointer - SlicesHandlerITKInterface::GetITKView(const std::vector& all_slices, size_t start_slice, size_t end_slice, const SlicesHandlerInterface* handler) -{ - using SliceContiguousImageType = itk::SliceContiguousImage; - - typename SliceContiguousImageType::IndexType start; - start.Fill(0); - - typename SliceContiguousImageType::SizeType size; - size[0] = handler->width(); - size[1] = handler->height(); - size[2] = handler->num_slices(); - - typename SliceContiguousImageType::RegionType region(start, size); - - auto spacing = handler->spacing(); - auto transform = handler->transform(); - - assert(end_slice > start_slice); - if (end_slice > start_slice) - { - // \note deactivated, because instead I set the extent above to start-end - // // correct transform if we are exporting active slices - // int cropping[] = { 0,0,handler->start_slice() }; - // transform.paddingUpdateTransform(cropping, spacing.v); - - start[2] = start_slice; - size[2] = end_slice - start_slice; - } - - itk::Point origin; - transform.getOffset(origin); - - itk::Matrix direction; - transform.getRotation(direction); - - auto image = SliceContiguousImageType::New(); - image->SetSpacing(spacing.v); - image->SetOrigin(origin); - image->SetDirection(direction); - image->SetRegions(region); - image->Allocate(); - - // Set slice pointers - std::vector slices = all_slices; - auto container = SliceContiguousImageType::PixelContainer::New(); - container->SetImportPointersForSlices(slices, size[0] * size[1], false); - image->SetPixelContainer(container); - - return image; -} - } // namespace iseg diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index 3e684754..d9878737 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -1117,26 +1117,23 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, if (!m_editingmode) { openS4LLinkPos = file->actions().size(); - QAction* importS4LLink = file->addAction("Import S4L link (h5)..."); + QAction* importS4LLink = file->addAction("Import S4L-link (h5)..."); connect(importS4LLink, SIGNAL(triggered()), this, SLOT(execute_loads4llivelink())); - importS4LLink->setToolTip("Loads a Sim4Life live link file (the h5 file, " - "which is part of an iSEG project)."); + importS4LLink->setToolTip("Loads a Sim4Life live link file (iSEG project .h5 file)."); importS4LLink->setEnabled(true); } importSurfacePos = file->actions().size(); - QAction* importSurface = file->addAction("Import Surface..."); + QAction* importSurface = file->addAction("Import Surface/Lines..."); connect(importSurface, SIGNAL(triggered()), this, SLOT(execute_loadsurface())); - importSurface->setToolTip("Some data must be opened first to load the " - "surface on top of the existing project."); + importSurface->setToolTip("Voxelize a surface or polyline mesh in the Target image."); importSurface->setEnabled(true); importRTstructPos = file->actions().size(); QAction* importRTAction = file->addAction("Import RTstruct..."); connect(importRTAction, SIGNAL(triggered()), this, SLOT(execute_loadrtstruct())); importRTAction->setToolTip("Some data must be opened first to import its RTStruct file"); - importRTAction->setEnabled(false); file->insertItem("&Export Image(s)...", this, SLOT(execute_saveimg())); file->insertItem("Export &Contour...", this, SLOT(execute_saveContours())); @@ -2785,7 +2782,7 @@ void MainWindow::execute_loadsurface() bool ok = true; QString loadfilename = QFileDialog::getOpenFileName(QString::null, - "STL (*.stl)\n" + "Surfaces & Polylines (*.stl *.vtk)\n" "All (*.*)", this); if (!loadfilename.isEmpty()) @@ -2808,7 +2805,7 @@ void MainWindow::execute_loadsurface() if (overwrite == 2) return; - ok = handler3D->LoadSurface(loadfilename.ascii(), overwrite == 0, intersect); + ok = handler3D->LoadSurface(loadfilename.toStdString(), overwrite == 0, intersect); } if (ok) diff --git a/iSeg/SlicesHandler.cpp b/iSeg/SlicesHandler.cpp index 1a8fd3d9..1dbef1c7 100755 --- a/iSeg/SlicesHandler.cpp +++ b/iSeg/SlicesHandler.cpp @@ -63,6 +63,8 @@ #include #include #include +#include +#include #include #include #include @@ -823,10 +825,8 @@ int SlicesHandler::ReadRTdose(const char* filename) return res; } -bool SlicesHandler::LoadSurface(const char* filename, - bool overwrite_working, bool intersect) +bool SlicesHandler::LoadSurface(const std::string& filename_in, bool overwrite_working, bool intersect) { - float spacing[3] = {_dx, _dy, _thickness}; unsigned dims[3] = {_width, _height, _nrslices}; auto slices = target_slices(); @@ -835,17 +835,35 @@ bool SlicesHandler::LoadSurface(const char* filename, clear_work(); } + std::string filename = filename_in; + std::transform(filename_in.begin(), filename_in.end(), filename.begin(), ::tolower); + + vtkSmartPointer reader; + if (filename.substr(filename.find_last_of(".") + 1) == "stl") + { + auto stl_reader = vtkSmartPointer::New(); + stl_reader->SetFileName(filename.c_str()); + reader = stl_reader; + } + else if (filename.substr(filename.find_last_of(".") + 1) == "vtk") + { + auto vtk_reader = vtkSmartPointer::New(); + vtk_reader->SetFileName(filename.c_str()); + reader = vtk_reader; + } + + reader->Update(); + auto surface = vtkPolyData::SafeDownCast(reader->GetOutputDataObject(0)); + VoxelSurface voxeler; VoxelSurface::eSurfaceImageOverlap ret; if (intersect) { - ret = voxeler.Intersect(filename, dims, spacing, _transform, slices.data(), - _startslice, _endslice); + ret = voxeler.Intersect(surface, slices, dims, spacing(), _transform, _startslice, _endslice); } else { - ret = voxeler.Run(filename, dims, spacing, _transform, slices.data(), - _startslice, _endslice); + ret = voxeler.Voxelize(surface, slices, dims, spacing(), _transform, _startslice, _endslice); } return (ret != VoxelSurface::kNone); } diff --git a/iSeg/SlicesHandler.h b/iSeg/SlicesHandler.h index 1f0bc160..bee71aa3 100755 --- a/iSeg/SlicesHandler.h +++ b/iSeg/SlicesHandler.h @@ -79,7 +79,7 @@ class SlicesHandler : public SlicesHandlerInterface int ReadOverlay(const char* filename, unsigned short slicenr); int ReadAvw(const char* filename); int ReadRTdose(const char* filename); - bool LoadSurface(const char* filename, bool overwrite_working, bool intersect); + bool LoadSurface(const std::string& filename, bool overwrite_working, bool intersect); int LoadAllXdmf(const char* filename); int LoadAllHDF(const char* filename); From 5c86ca01906531cef43ac1354e2266692e420fe6 Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Fri, 22 Feb 2019 17:56:14 +0100 Subject: [PATCH 20/26] ThresholdWidget --- .vscode/.cmaketools.json | 5 + .vscode/c_cpp_properties.json | 16 + iSeg/CMakeLists.txt | 3 + iSeg/MainWindow.cpp | 3 + iSeg/MainWindow.h | 2 + iSeg/ThresholdWidgetQt4.cpp | 756 ++++++++++++++++++++++++++++++++++ iSeg/ThresholdWidgetQt4.h | 100 +++++ iSeg/ThresholdWidgetQt4.ui | 702 +++++++++++++++++++++++++++++++ 8 files changed, 1587 insertions(+) create mode 100644 .vscode/.cmaketools.json create mode 100644 .vscode/c_cpp_properties.json create mode 100644 iSeg/ThresholdWidgetQt4.cpp create mode 100644 iSeg/ThresholdWidgetQt4.h create mode 100644 iSeg/ThresholdWidgetQt4.ui diff --git a/.vscode/.cmaketools.json b/.vscode/.cmaketools.json new file mode 100644 index 00000000..e8a5846b --- /dev/null +++ b/.vscode/.cmaketools.json @@ -0,0 +1,5 @@ +{ + "variant": null, + "activeEnvironments": [], + "codeModel": null +} \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..82e6a24d --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "null", + "includePath": [], + "defines": [], + "browse": { + "path": [], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + }, + "intelliSenseMode": "msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/iSeg/CMakeLists.txt b/iSeg/CMakeLists.txt index b9a40f22..70352d37 100755 --- a/iSeg/CMakeLists.txt +++ b/iSeg/CMakeLists.txt @@ -68,6 +68,7 @@ SET(ViewerSrcs SmoothingWidget.cpp SurfaceViewerWidget.cpp ThresholdWidget.cpp + ThresholdWidgetQt4.cpp TissueCleaner.cpp TissueHierarchy.cpp TissueInfos.cpp @@ -117,6 +118,7 @@ SET(MyMocHeaders SurfaceViewerWidget.h TissueTreeWidget.h ThresholdWidget.h + ThresholdWidgetQt4.h TransformWidget.h UndoConfigurationDialog.h VesselWidget.h @@ -133,6 +135,7 @@ ENDIF() SET(UIS Settings.ui + ThresholdWidgetQt4.ui ) SET(RCCS images.qrc) diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index 89cb8633..e93fe106 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -35,6 +35,7 @@ #include "StdStringToQString.h" #include "SurfaceViewerWidget.h" #include "ThresholdWidget.h" +#include "ThresholdWidgetQt4.h" #include "TissueCleaner.h" #include "TissueInfos.h" #include "TissueTreeWidget.h" @@ -614,6 +615,8 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, threshold_widget = new ThresholdWidget(handler3D, nullptr, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase); tabwidgets.push_back(threshold_widget); + threshold_widget_qt4 = new ThresholdWidgetQt4(handler3D, nullptr, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase); + tabwidgets.push_back(threshold_widget_qt4); hyst_widget = new HystereticGrowingWidget(handler3D, nullptr, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase); tabwidgets.push_back(hyst_widget); livewire_widget = new LivewireWidget(handler3D, nullptr, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase); diff --git a/iSeg/MainWindow.h b/iSeg/MainWindow.h index 2dc226b9..9919eadd 100755 --- a/iSeg/MainWindow.h +++ b/iSeg/MainWindow.h @@ -72,6 +72,7 @@ class VesselWidget; class WatershedWidget; class SmoothingWidget; class ThresholdWidget; +class ThresholdWidgetQt4; class MeasurementWidget; class ImageViewerWidget; class SurfaceViewerWidget; @@ -223,6 +224,7 @@ class MainWindow : public QMainWindow QCheckBox* tissue3Dopt; QStackedWidget* methodTab; ThresholdWidget* threshold_widget; + ThresholdWidgetQt4* threshold_widget_qt4; MeasurementWidget* measurement_widget; VesselWidget* vesselextr_widget; SmoothingWidget* smoothing_widget; diff --git a/iSeg/ThresholdWidgetQt4.cpp b/iSeg/ThresholdWidgetQt4.cpp new file mode 100644 index 00000000..f1908051 --- /dev/null +++ b/iSeg/ThresholdWidgetQt4.cpp @@ -0,0 +1,756 @@ +/* + * Copyright (c) 2018 The Foundation for Research on Information Technologies in Society (IT'IS). + * + * This file is part of iSEG + * (see https://github.com/ITISFoundation/osparc-iseg). + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "ThresholdWidgetQt4.h" +#include "SlicesHandler.h" +#include "bmp_read_1.h" +#include +#include +#include + +using namespace iseg; + + +ThresholdWidgetQt4::ThresholdWidgetQt4(SlicesHandler* hand3D, + QWidget *parent, + const char* name, + Qt::WindowFlags wFlags): +WidgetInterface(parent, name, wFlags), +handler3D(hand3D) +{ + activeslice = handler3D->active_slice(); + bmphand = handler3D->get_activebmphandler(); + + initUi(); + updateUi(); +} + +ThresholdWidgetQt4::~ThresholdWidgetQt4() +{ + +} + +void ThresholdWidgetQt4::init() +{ + if (activeslice != handler3D->active_slice()) + { + activeslice = handler3D->active_slice(); + bmphand = handler3D->get_activebmphandler(); + auto range = get_range(); + auto range_validator = new QDoubleValidator(range.first, range.second, 1000, ui.mThresholdBorderLineEdit); + ui.mThresholdBorderLineEdit->setValidator(range_validator); + + threshs[0] = float(ui.mManualNrTissuesSpinBox->value() - 1); + for (unsigned i = 0; i < 20; ++i) + { + bits1[i] = 0; + threshs[i + 1] = range.second; + weights[i] = 1.0f; + } + } + else { + bmphand = handler3D->get_activebmphandler(); + auto range = get_range(); + for (unsigned i = 0; i < 20; i++) + { + if (threshs[i + 1] > range.second) + threshs[i + 1] = range.second; + if (threshs[i + 1] < range.first) + threshs[i + 1] = range.first; + } + } + + + updateUi(); +} + +void ThresholdWidgetQt4::newloaded() +{ + init(); +} + +void ThresholdWidgetQt4::hideparams_changed() +{ + init(); +} + +FILE* ThresholdWidgetQt4::SaveParams(FILE* fp, int version) +{ + if (version >= 2) + { + int dummy; + dummy = slider->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = ratio->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_nrtissues->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_dim->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_tissuenr->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_px->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_py->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_lx->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_ly->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_iternr->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_converge->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = sb_minpix->value(); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = (int)(subsect->isOn()); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = (int)(rb_manual->isOn()); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = (int)(rb_histo->isOn()); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = (int)(rb_kmeans->isOn()); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = (int)(rb_EM->isOn()); + fwrite(&(dummy), 1, sizeof(int), fp); + dummy = (int)(allslices->isOn()); + fwrite(&(dummy), 1, sizeof(int), fp); + + fwrite(&upper, 1, sizeof(float), fp); + fwrite(&lower, 1, sizeof(float), fp); + fwrite(threshs, 21, sizeof(float), fp); + fwrite(weights, 20, sizeof(float), fp); + } + + return fp; +} + +FILE* ThresholdWidgetQt4::LoadParams(FILE* fp, int version) +{ + if (version >= 2) + { + QObject::disconnect(sb_nrtissues, SIGNAL(valueChanged(int)), this, + SLOT(nrtissues_changed(int))); + QObject::disconnect(sb_dim, SIGNAL(valueChanged(int)), this, + SLOT(dim_changed(int))); + QObject::disconnect(sb_tissuenr, SIGNAL(valueChanged(int)), this, + SLOT(tissuenr_changed(int))); + QObject::disconnect(slider, SIGNAL(sliderMoved(int)), this, + SLOT(slider_changed(int))); + QObject::disconnect(le_borderval, SIGNAL(returnPressed()), this, + SLOT(le_borderval_returnpressed())); + QObject::disconnect(subsect, SIGNAL(clicked()), this, + SLOT(subsect_toggled())); + QObject::disconnect(modegroup, SIGNAL(buttonClicked(int)), this, + SLOT(method_changed(int))); + + int dummy; + fread(&dummy, sizeof(int), 1, fp); + slider->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + ratio->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + sb_nrtissues->setValue(dummy); + sb_tissuenr->setMaxValue(dummy - 1); + fread(&dummy, sizeof(int), 1, fp); + sb_dim->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + sb_tissuenr->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + sb_px->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + sb_py->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + sb_lx->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + sb_ly->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + sb_iternr->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + sb_converge->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + sb_minpix->setValue(dummy); + fread(&dummy, sizeof(int), 1, fp); + subsect->setChecked(dummy > 0); + fread(&dummy, sizeof(int), 1, fp); + rb_manual->setChecked(dummy > 0); + fread(&dummy, sizeof(int), 1, fp); + rb_histo->setChecked(dummy > 0); + fread(&dummy, sizeof(int), 1, fp); + rb_kmeans->setChecked(dummy > 0); + fread(&dummy, sizeof(int), 1, fp); + rb_EM->setChecked(dummy > 0); + fread(&dummy, sizeof(int), 1, fp); + allslices->setChecked(dummy > 0); + + fread(&upper, sizeof(float), 1, fp); + fread(&lower, sizeof(float), 1, fp); + fread(threshs, sizeof(float), 21, fp); + fread(weights, sizeof(float), 20, fp); + + dummy = sb_tissuenr->value(); + method_changed(0); + subsect_toggled(); + nrtissues_changed(sb_nrtissues->value()); + dim_changed(sb_dim->value()); + sb_tissuenr->setValue(dummy); + on_tissuenr_changed(dummy); + + QObject::connect(subsect, SIGNAL(clicked()), this, + SLOT(subsect_toggled())); + QObject::connect(modegroup, SIGNAL(buttonClicked(int)), this, + SLOT(method_changed(int))); + QObject::connect(sb_nrtissues, SIGNAL(valueChanged(int)), this, + SLOT(nrtissues_changed(int))); + QObject::connect(sb_dim, SIGNAL(valueChanged(int)), this, + SLOT(dim_changed(int))); + QObject::connect(sb_tissuenr, SIGNAL(valueChanged(int)), this, + SLOT(tissuenr_changed(int))); + QObject::connect(slider, SIGNAL(sliderMoved(int)), this, + SLOT(slider_changed(int))); + QObject::connect(le_borderval, SIGNAL(returnPressed()), this, + SLOT(le_borderval_returnpressed())); + } + return fp; +} + +void ThresholdWidgetQt4::on_mManualNrTissuesSpinBox_valueChanged(int newValue) +{ + threshs[0] = float(newValue - 1); + ui.mManualLimitNrSpinBox->setMaxValue(newValue - 1); + + updateUi(); +} + +void ThresholdWidgetQt4::on_mManualLimitNrSpinBox_valueChanged(int newValue) +{ + updateUi(); +} + +void ThresholdWidgetQt4::on_mLoadBordersPushButton_clicked() +{ + auto loadfilename = + QFileDialog::getOpenFileName(this, "Select Boarder file", QString::null, + "Boarders (*.txt)\n" + "All (*.*)"); + + if (loadfilename.isEmpty()) { + return; + } + + std::vector fvec; + // hope it's only american english... ;) + FILE* fp = fopen(loadfilename.ascii(), "r"); + float f; + if (fp != nullptr) + { + while (fscanf(fp, "%f", &f) == 1) + { + fvec.push_back(f); + } + } + fclose(fp); + + if (fvec.size() > 0 && fvec.size() < 20) + { + ui.mManualNrTissuesSpinBox->setValue(static_cast(fvec.size() + 1)); + threshs[0] = float(fvec.size()); + ui.mManualLimitNrSpinBox->setMaxValue(static_cast(fvec.size())); + + auto range = get_range(); + for (unsigned i = 0; i < (unsigned)fvec.size(); i++) + { + if (fvec[i] > range.second) + f = range.second; + else if (fvec[i] < range.first) + f = range.first; + else + f = fvec[i]; + threshs[i + 1] = f; + } + ui.mManualLimitNrSpinBox->setValue(1); + } + + updateUi(); +} + +void ThresholdWidgetQt4::on_mSaveBordersPushButton_clicked() +{ + auto savefilename = QFileDialog::getSaveFileName(this, "Save file", + QString::null, "Boarders (*.txt)\n"); + + if (savefilename.length() > 4 && !savefilename.endsWith(QString(".txt"))) + savefilename.append(".txt"); + + if (!savefilename.isEmpty()) + { + FILE* fp = fopen(savefilename.ascii(), "w"); + for (int i = 1; i <= ui.mManualLimitNrSpinBox->maxValue(); i++) + fprintf(fp, "%f\n", threshs[i]); + fclose(fp); + } +} + +void ThresholdWidgetQt4::on_mThresholdHorizontalSlider_valueChanged(int newValue) +{ + auto range = get_range(); + threshs[ui.mManualLimitNrSpinBox->value()] = + newValue * 0.005f * (range.second - range.first) + range.first; + + if (ui.mAllSlicesCheckBox->isChecked()) + handler3D->threshold(threshs); + else + bmphand->threshold(threshs); + + emit end_datachange(this, iseg::NoUndo); + + updateUi(); +} + +void ThresholdWidgetQt4::on_mThresholdBorderLineEdit_editingFinished() +{ + bool b1; + float val = ui.mThresholdBorderLineEdit->text().toFloat(&b1); + if (b1) + { + threshs[ui.mManualLimitNrSpinBox->value()] = val; + { + iseg::DataSelection dataSelection; + dataSelection.allSlices = ui.mAllSlicesCheckBox->isChecked(); + dataSelection.sliceNr = handler3D->active_slice(); + dataSelection.work = true; + emit begin_datachange(dataSelection, this); + + if (ui.mAllSlicesCheckBox->isChecked()) + handler3D->threshold(threshs); + else + bmphand->threshold(threshs); + + emit end_datachange(this); + } + } + + updateUi(); +} + +void ThresholdWidgetQt4::on_mHistoPxSpinBox_valueChanged(int newValue) +{ + // nothing done +} + +void ThresholdWidgetQt4::on_mHistoLxSpinBox_valueChanged(int newValue) +{ + // nothing done +} + +void ThresholdWidgetQt4::on_mHistoPySpinBox_valueChanged(int newValue) +{ + // nothing done +} + +void ThresholdWidgetQt4::on_mHistoLySpinBox_valueChanged(int newValue) +{ + // nothing done +} + +void ThresholdWidgetQt4::on_mHistoMinPixelsSpinBox_valueChanged(int newValue) +{ + // nothing done +} + +void ThresholdWidgetQt4::on_mHistoMinPixelsRatioHorizontalSlider_valueChanged(int newValue) +{ + // nothing done +} + +void ThresholdWidgetQt4::on_mKMeansNrTissuesSpinBox_valueChanged(int newValue) +{ +} + +void ThresholdWidgetQt4::on_mKMeansDimsSpinBox_valueChanged(int newValue) +{ + const size_t cursize = filenames.size(); + if (newValue > cursize + 1) + { + filenames.resize(newValue - 1); + for (size_t i = cursize; i + 1 < newValue; ++i) + filenames[i] = QString(""); + } + + ui.mKMeansImageNrSpinBox->setMaxValue(newValue); + ui.mKMeansImageNrSpinBox->setValue(1); + + updateUi(); +} + +void ThresholdWidgetQt4::on_mKMeansImageNrSpinBox_valueChanged(int newValue) +{ + updateUi(); +} + +void ThresholdWidgetQt4::on_mKMeansWeightHorizontalSlider_valueChanged(int newValue) +{ +} + +void ThresholdWidgetQt4::on_mKMeansFilenameLineEdit_editingFinished() +{ + +} + +void ThresholdWidgetQt4::on_mKMeansFilenamePushButton_clicked() +{ + QString loadfilename = QFileDialog::getOpenFileName(this, "Select an image" + QString::null, + "Images (*.png)\n" + "Images (*.mhd)\n" + "All (*.*)" //"Images (*.bmp)\n" "All (*.*)", QString::null, + ); //, filename); + ui.mKMeansFilenameLineEdit_2->setText(loadfilename); + filenames[ui.mKMeansImageNrSpinBox->value() - 2] = loadfilename; + + ui.mKMeansRRadioButton_2->setEnabled(false); + ui.mKMeansGRadioButton_2->setEnabled(false); + ui.mKMeansBRadioButton_2->setEnabled(false); + ui.mKMeansARadioButton_2->setEnabled(false); + + QFileInfo fi(loadfilename); + QString ext = fi.extension(); + if (ext == "png") + { + QImage image(loadfilename); + + if (image.depth() > 8) + { + ui.mKMeansRRadioButton_2->setEnabled(true); + ui.mKMeansGRadioButton_2->setEnabled(true); + ui.mKMeansBRadioButton_2->setEnabled(true); + if (image.hasAlphaChannel()) + ui.mKMeansARadioButton_2->setEnabled(true); + } + } +} + +void ThresholdWidgetQt4::on_mKMeansRRadioButton_clicked() +{ + +} + +void ThresholdWidgetQt4::on_mKMeansGRadioButton_clicked() +{ + +} + +void ThresholdWidgetQt4::on_mKMeansBRadioButton_clicked() +{ + +} + +void ThresholdWidgetQt4::on_mKMeansARadioButton_clicked() +{ + +} + +void ThresholdWidgetQt4::on_mKMeansIterationsSpinBox_valueChanged(int newValue) +{ + +} + +void ThresholdWidgetQt4::on_mKMeansConvergeSpinBox_valueChanged(int newValue) +{ + +} + +void ThresholdWidgetQt4::on_mUseCenterFileCheckBox_toggled(bool newValue) +{ + if (!newValue) { + ui.mCenterFilenameLineEdit->setText(""); + } + updateUi(); +} + +void ThresholdWidgetQt4::on_mCenterFilenameLineEdit_editingFinished() +{ + // never happens +} + +void ThresholdWidgetQt4::on_mSelectCenterFilenamePushButton_clicked() +{ + auto center_file_name = QFileDialog::getOpenFileName(nullptr, + "Select center file", QString(), "Text File (*.txt*)"); + ui.mCenterFilenameLineEdit->setText(center_file_name); +} + +void ThresholdWidgetQt4::on_mAllSlicesCheckBox_toggled(bool newValue) +{ + // does nothing... +} + +void ThresholdWidgetQt4::on_mExecutePushButton_clicked() +{ + unsigned char modedummy; + + iseg::DataSelection dataSelection; + dataSelection.allSlices = ui.mAllSlicesCheckBox->isChecked(); + dataSelection.sliceNr = handler3D->active_slice(); + dataSelection.work = true; + emit begin_datachange(dataSelection, this); + + if (ui.mManualModeRadioButton->isChecked()) + { + if (ui.mAllSlicesCheckBox->isChecked()) + handler3D->threshold(threshs); + else + bmphand->threshold(threshs); + } + else if (ui.mHistoModeRadioButton->isChecked()) + { + bmphand->swap_bmpwork(); + + if (ui.mSubsectionGroupBox->isChecked()) + { + Point p; + p.px = (unsigned short)ui.mHistoPxSpinBox->value(); + p.py = (unsigned short)ui.mHistoPySpinBox->value(); + bmphand->make_histogram(p, ui.mHistoLxSpinBox->value(), ui.mHistoLySpinBox->value(), true); + } + else + bmphand->make_histogram(true); + + bmphand->gaussian_hist(1.0f); + bmphand->swap_bmpwork(); + + float* thresh1 = bmphand->find_modal((unsigned)ui.mHistoMinPixelsSpinBox->value(), + 0.005f * ui.mHistoMinPixelsRatioHorizontalSlider->value()); + if (ui.mAllSlicesCheckBox->isChecked()) + handler3D->threshold(thresh1); + else + bmphand->threshold(thresh1); + free(thresh1); + } + else if (ui.mKMeansRadioButton->isChecked()) + { + FILE* fp = fopen("C:\\gamma.txt", "r"); // really???? + if (fp != nullptr) + { + float** centers = new float*[ui.mKMeansNrTissuesSpinBox->value()]; + for (int i = 0; i < ui.mKMeansNrTissuesSpinBox->value(); i++) + centers[i] = new float[ui.mKMeansDimsSpinBox->value()]; + float* tol_f = new float[ui.mKMeansDimsSpinBox->value()]; + float* tol_d = new float[ui.mKMeansDimsSpinBox->value()]; + for (int i = 0; i < ui.mKMeansNrTissuesSpinBox->value(); i++) + { + for (int j = 0; j < ui.mKMeansDimsSpinBox->value(); j++) + fscanf(fp, "%f", &(centers[i][j])); + } + for (int j = 0; j < ui.mKMeansDimsSpinBox->value(); j++) + fscanf(fp, "%f", &(tol_f[j])); + for (int j = 1; j < ui.mKMeansDimsSpinBox->value(); j++) + fscanf(fp, "%f", &(tol_d[j])); + tol_d[0] = 0.0f; + fclose(fp); + std::vector mhdfiles; + for (int i = 0; i + 1 < ui.mKMeansDimsSpinBox->value(); i++) + mhdfiles.push_back(std::string(filenames[i].ascii())); + if (ui.mAllSlicesCheckBox->isChecked()) + handler3D->gamma_mhd(handler3D->active_slice(), + (short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), mhdfiles, weights, + centers, tol_f, tol_d); + else + bmphand->gamma_mhd( + (short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), + mhdfiles, handler3D->active_slice(), weights, centers, + tol_f, tol_d, handler3D->get_pixelsize()); + delete[] tol_d; + delete[] tol_f; + for (int i = 0; i < ui.mKMeansNrTissuesSpinBox->value(); i++) + delete[] centers[i]; + delete[] centers; + } + else + { + std::vector kmeansfiles; + for (int i = 0; i + 1 < ui.mKMeansDimsSpinBox->value(); i++) + kmeansfiles.push_back(std::string(filenames[i].ascii())); + if (kmeansfiles.size() > 0) + { + if (kmeansfiles[0].substr(kmeansfiles[0].find_last_of(".") + + 1) == "png") + { + std::vector extractChannels; + if (ui.mKMeansRRadioButton_2->isChecked()) + extractChannels.push_back(0); + if (ui.mKMeansGRadioButton_2->isChecked()) + extractChannels.push_back(1); + if (ui.mKMeansBRadioButton_2->isChecked()) + extractChannels.push_back(2); + if (ui.mKMeansARadioButton_2->isChecked()) + extractChannels.push_back(3); + if (ui.mKMeansDimsSpinBox->value() != extractChannels.size() + 1) + return; + if (ui.mAllSlicesCheckBox->isChecked()) + handler3D->kmeans_png( + handler3D->active_slice(), + (short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, + extractChannels, weights, + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value(), + ui.mCenterFilenameLineEdit->text().toStdString()); + else + bmphand->kmeans_png( + (short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, + extractChannels, handler3D->active_slice(), + weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value(), + ui.mCenterFilenameLineEdit->text().toStdString()); + } + else + { + if (ui.mAllSlicesCheckBox->isChecked()) + handler3D->kmeans_mhd( + handler3D->active_slice(), + (short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, weights, + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); + else + bmphand->kmeans_mhd((short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, + handler3D->active_slice(), + weights, + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); + } + } + else + { + if (ui.mAllSlicesCheckBox->isChecked()) + handler3D->kmeans_mhd( + handler3D->active_slice(), + (short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), + kmeansfiles, weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); + else + bmphand->kmeans_mhd((short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, + handler3D->active_slice(), weights, + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); + } + } + } + else + { + // EM em; + for (int i = 0; i < ui.mKMeansDimsSpinBox->value(); i++) + { + if (bits1[i] == 0) + bits[i] = bmphand->return_bmp(); + else + bits[i] = bmphand->getstack(bits1[i], modedummy); + } + + if (ui.mAllSlicesCheckBox->isChecked()) + handler3D->em(handler3D->active_slice(), + (short)ui.mKMeansNrTissuesSpinBox->value(), + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); + else + bmphand->em((short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), + bits, weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); + } + + emit end_datachange(this); +} + +void ThresholdWidgetQt4::on_tissuenr_changed(int newValue) +{ + updateUi(); +} + +void ThresholdWidgetQt4::on_slicenr_changed() +{ + init(); +} + +void ThresholdWidgetQt4::initUi() +{ + ui.setupUi(this); + + activeslice = handler3D->active_slice(); + bmphand = handler3D->get_activebmphandler(); + + + auto mode_signal_mapping = new QSignalMapper(this); + mode_signal_mapping->setMapping(ui.mManualModeRadioButton, ui.mManualWidget); + mode_signal_mapping->setMapping(ui.mHistoModeRadioButton, ui.mHistoWidget); + mode_signal_mapping->setMapping(ui.mKMeansRadioButton, ui.mKmeansEMWidget); + mode_signal_mapping->setMapping(ui.mEMModeRadioButton, ui.mKmeansEMWidget); + QObject::connect(ui.mManualModeRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); + QObject::connect(ui.mHistoModeRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); + QObject::connect(ui.mKMeansRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); + QObject::connect(ui.mEMModeRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); + QObject::connect(mode_signal_mapping, SIGNAL(mapped(QWidget*)), ui.mModeStackedWidget, SLOT(setCurrentWidget(QWidget*))); + + // init with manual mode + ui.mManualModeRadioButton->setChecked(true); + ui.mModeStackedWidget->setCurrentWidget(ui.mManualWidget); +} + +void ThresholdWidgetQt4::updateUi() +{ + auto range = get_range(); + // manual + ui.mLoadBordersPushButton->setDisabled(hideparams); + ui.mSaveBordersPushButton->setDisabled(hideparams); + ui.mThresholdLowerLabel->setText(QString::number(range.first, 'g', 3)); + ui.mThresholdUpperLabel->setText(QString::number(range.second, 'g', 3)); + if (range.second != range.first) { + const int slider_value = static_cast((threshs[ui.mManualLimitNrSpinBox->value()] - range.first) * 200 / + (range.second - range.first) + .5f); + ui.mThresholdHorizontalSlider->setValue(slider_value); + ui.mThresholdBorderLineEdit->setText(QString::number(threshs[ui.mManualLimitNrSpinBox->value()], 'g', 3)); + } + + //ui.mWeightBorderLineEdit->setText(QString::number(threshs[sb_tissuenr->value()], 'g', 3)); + ui.mManualLimitNrLabel->setEnabled(ui.mManualNrTissuesSpinBox->value() != 2); + ui.mManualLimitNrSpinBox->setEnabled(ui.mManualNrTissuesSpinBox->value() != 2); + + // histo + ui.mSubsectionGroupBox->setDisabled(hideparams); + ui.mMinPixelsFrame->setDisabled(hideparams); + + // kmeans + ui.mKMeansDimsLabel->setDisabled(hideparams); + ui.mKMeansDimsSpinBox->setDisabled(hideparams); + ui.mKMeansIterationsFrame->setDisabled(hideparams); + ui.mKMeansWeightHorizontalSlider->setValue(int(200 * weights[ui.mKMeansImageNrSpinBox->value() - 1])); + ui.mKMeansFilenameFrame->setEnabled(ui.mKMeansImageNrSpinBox->value() > 1); + ui.mKMeansFilenameLineEdit_2->setText(ui.mKMeansImageNrSpinBox->value() > 1 ? filenames[ui.mKMeansImageNrSpinBox->value() - 2] : ""); + + // general + ui.mCenterFilenameLineEdit->setEnabled(ui.mUseCenterFileCheckBox->isChecked()); + ui.mSelectCenterFilenamePushButton->setEnabled(ui.mUseCenterFileCheckBox->isChecked()); +} + +std::pair ThresholdWidgetQt4::get_range() const +{ + std::pair range(0, 0); + if (bmphand) { + Pair p; + bmphand->get_bmprange(&p); + range.first = p.low; + range.second = p.high; + } + return range; +} \ No newline at end of file diff --git a/iSeg/ThresholdWidgetQt4.h b/iSeg/ThresholdWidgetQt4.h new file mode 100644 index 00000000..a770a944 --- /dev/null +++ b/iSeg/ThresholdWidgetQt4.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018 The Foundation for Research on Information Technologies in Society (IT'IS). + * + * This file is part of iSEG + * (see https://github.com/ITISFoundation/osparc-iseg). + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ +#pragma once + +#include "Interface/WidgetInterface.h" + +#include "ui_ThresholdWidgetQt4.h" + + + +namespace iseg { + +class SlicesHandler; +class bmphandler; + +class ThresholdWidgetQt4 : public WidgetInterface +{ + Q_OBJECT +public: + explicit ThresholdWidgetQt4(SlicesHandler *hand3D, QWidget *parent, + const char* name, Qt::WindowFlags wFlags); + virtual ~ThresholdWidgetQt4(); + + virtual void init() override; + virtual void newloaded() override; + virtual void hideparams_changed() override; + // should be const'ed + virtual std::string GetName() override { return std::string("Threshold"); } + virtual QIcon GetIcon(QDir picdir) override { return QIcon(picdir.absFilePath(QString("thresholding.png"))); } + virtual FILE *SaveParams(FILE *fp, int version) override; + virtual FILE *LoadParams(FILE *fp, int version) override; + +private slots: + // manual + void on_mManualNrTissuesSpinBox_valueChanged(int newValue); + void on_mManualLimitNrSpinBox_valueChanged(int newValue); + void on_mLoadBordersPushButton_clicked(); + void on_mSaveBordersPushButton_clicked(); + void on_mThresholdHorizontalSlider_valueChanged(int newValue); + void on_mThresholdBorderLineEdit_editingFinished(); + + // histo + void on_mHistoPxSpinBox_valueChanged(int newValue); + void on_mHistoLxSpinBox_valueChanged(int newValue); + void on_mHistoPySpinBox_valueChanged(int newValue); + void on_mHistoLySpinBox_valueChanged(int newValue); + void on_mHistoMinPixelsSpinBox_valueChanged(int newValue); + void on_mHistoMinPixelsRatioHorizontalSlider_valueChanged(int newValue); + + // kmeans + void on_mKMeansNrTissuesSpinBox_valueChanged(int newValue); + void on_mKMeansDimsSpinBox_valueChanged(int newValue); + void on_mKMeansImageNrSpinBox_valueChanged(int newValue); + void on_mKMeansWeightHorizontalSlider_valueChanged(int newValue); + void on_mKMeansFilenameLineEdit_editingFinished(); + void on_mKMeansFilenamePushButton_clicked(); + void on_mKMeansRRadioButton_clicked(); + void on_mKMeansGRadioButton_clicked(); + void on_mKMeansBRadioButton_clicked(); + void on_mKMeansARadioButton_clicked(); + void on_mKMeansIterationsSpinBox_valueChanged(int newValue); + void on_mKMeansConvergeSpinBox_valueChanged(int newValue); + + + // general + void on_mUseCenterFileCheckBox_toggled(bool newValue); + void on_mCenterFilenameLineEdit_editingFinished(); + void on_mSelectCenterFilenamePushButton_clicked(); + + void on_mAllSlicesCheckBox_toggled(bool newValue); + void on_mExecutePushButton_clicked(); + +private: + void on_tissuenr_changed(int i) override; + void on_slicenr_changed() override; + void initUi(); + void updateUi(); + + std::pair get_range() const; + + bmphandler *bmphand = nullptr; + SlicesHandler *handler3D = nullptr; + unsigned short activeslice = std::numeric_limits::max(); + float threshs[21]; // ugly + float weights[20]; // ugly + float *bits[20]; // ugly + unsigned bits1[20]; // ugly + std::vector filenames; + Ui::ThresholdWidgetQt4 ui; + +}; + +} // namespace iseg diff --git a/iSeg/ThresholdWidgetQt4.ui b/iSeg/ThresholdWidgetQt4.ui new file mode 100644 index 00000000..1fdd742a --- /dev/null +++ b/iSeg/ThresholdWidgetQt4.ui @@ -0,0 +1,702 @@ + + + ThresholdWidgetQt4 + + + + 0 + 0 + 520 + 227 + + + + Form + + + Segment tissues based on thresholding techniques. + + + + + + + + + + + + + + + + + + + + Manual + + + + + + + Histo + + + + + + + k-means + + + + + + + EM + + + + + + + + + + + + 2 + + + + + + + + + #Tissues + + + + + + + 2 + + + 30 + + + 2 + + + + + + + Limit-Nr: + + + + + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Open... + + + + + + + Save... + + + + + + + + + + + Threshold: + + + + + + + xxxxxxx + + + + + + + 200 + + + 1 + + + 200 + + + Qt::Horizontal + + + + + + + xxxxxxx + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Subsection + + + false + + + true + + + + 0 + + + + + + + px: + + + + + + + + + + + + + + py: + + + + + + + + + + + + + + lx + + + + + + + + + + + + + + ly: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + + + Min. Pixels: + + + + + + + 100000 + + + 10 + + + 50 + + + + + + + Ratio: + + + + + + + 200 + + + 160 + + + Qt::Horizontal + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + #Tissues + + + + + + + 2 + + + 30 + + + 2 + + + + + + + + + + + #Dims + + + + + + + + + + 1 + + + 10 + + + + + + + + + + + Image-Nr: + + + + + + + + + + 1 + + + 10 + + + + + + + Qt::Horizontal + + + + 13 + 20 + + + + + + + + + + + + + + Weight: + + + + + + + 200 + + + 200 + + + Qt::Horizontal + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + + + Filename: + + + + + + + + + + Select + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + + + R + + + + + + + G + + + + + + + B + + + + + + + A + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + + + #Iterations: + + + + + + + 1000 + + + 5 + + + 100 + + + + + + + Converge: + + + + + + + 100000 + + + 100 + + + 100 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Use InitCenters: + + + + + + + false + + + true + + + + + + + false + + + Select + + + + + + + + + + + Apply to all slices + + + + + + + Execute + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + From a6447338a1eaad0e9202bac5c4c13000c4fc2e13 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Fri, 22 Feb 2019 22:26:56 +0100 Subject: [PATCH 21/26] remove dead code --- Core/PolyLines.h | 2 -- Core/PolyLines.inl | 59 -------------------------------- iSeg/OutlineCorrectionWidget.cpp | 2 +- 3 files changed, 1 insertion(+), 62 deletions(-) diff --git a/Core/PolyLines.h b/Core/PolyLines.h index 0c80d4a6..361638a2 100644 --- a/Core/PolyLines.h +++ b/Core/PolyLines.h @@ -36,8 +36,6 @@ void PolylinesToEdges(const std::vector>& polylines, std::vec template void RemoveDuplicateEdges(std::vector& edges); -template -void WritePolylinesToVtk(std::vector>& polylines, const std::string& file_name); } // namespace iseg #include "PolyLines.inl" diff --git a/Core/PolyLines.inl b/Core/PolyLines.inl index cd1bd5bc..59bc93ed 100644 --- a/Core/PolyLines.inl +++ b/Core/PolyLines.inl @@ -1,7 +1,5 @@ #pragma once -#include - namespace iseg { namespace detail { @@ -248,61 +246,4 @@ void RemoveDuplicateEdges(std::vector& edges) std::swap(new_edges, edges); } -template -void WritePolylinesToVtk(std::vector>& polylines, const std::string& file_name) -{ - using bit32 = unsigned int; - std::vector> polylines_idx; - std::vector points; - bit32 point_count = 0; - size_t lines_counts = 0; - for (auto pline : polylines) - { - bool is_closed = (pline.front() == pline.back()); - - std::vector iline; - for (size_t i = 0; i < (is_closed ? pline.size() - 1 : pline.size()); i++) - { - iline.push_back(point_count++); - points.push_back(pline[i]); - } - if (is_closed) - { - iline.push_back(iline.front()); - } - polylines_idx.push_back(iline); - lines_counts += iline.size(); - } - - const bit32 num_points = (bit32)points.size(); - const bit32 num_lines = (bit32)polylines_idx.size(); - - std::ofstream ofile; - ofile.open(file_name.c_str()); - - ofile << "# vtk DataFile Version 3.0\n"; - ofile << "vtk output\n"; - ofile << "ASCII\n"; - ofile << "DATASET POLYDATA\n"; - - ofile << "POINTS " << num_points << " float\n"; - for (bit32 i = 0; i < num_points; i++) - { - auto p = points[i]; - ofile << p[0] << " " << p[1] << " " << p[2] << "\n"; - } - - ofile << "LINES " << num_lines << " " << lines_counts + num_lines << "\n"; - for (bit32 i = 0; i < num_lines; i++) - { - auto line = polylines_idx[i]; - ofile << line.size(); - for (auto id : line) - ofile << " " << id; - ofile << "\n"; - } - - ofile.close(); -} - } // namespace iseg diff --git a/iSeg/OutlineCorrectionWidget.cpp b/iSeg/OutlineCorrectionWidget.cpp index a9ff2970..3844971d 100755 --- a/iSeg/OutlineCorrectionWidget.cpp +++ b/iSeg/OutlineCorrectionWidget.cpp @@ -120,7 +120,7 @@ OutlineCorrectionWidget::OutlineCorrectionWidget(SlicesHandler* hand3D, QWidget* smooth_tissues_params = new SmoothTissuesParamView; // layouts - stacked_params = new QStackedWidget; + stacked_params = new QStackedWidget(this); stacked_params->addWidget(brush_params); stacked_params->addWidget(olc_params); stacked_params->addWidget(fill_holes_params); From e553b5162dcd401c7c55e382d348b6c20747184d Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Mon, 25 Feb 2019 22:22:13 +0100 Subject: [PATCH 22/26] minor edits --- CMake/ThirdPartyEigen.cmake | 14 +++++++------- iSeg/MainWindow.cpp | 25 ++++++++++--------------- iSeg/MeasurementWidget.cpp | 1 + iSeg/MorphologyWidget.h | 4 +--- iSeg/PickerWidget.cpp | 6 ++---- iSeg/bmp_read_1.cpp | 28 +--------------------------- 6 files changed, 22 insertions(+), 56 deletions(-) diff --git a/CMake/ThirdPartyEigen.cmake b/CMake/ThirdPartyEigen.cmake index e40220eb..81c4ceb6 100755 --- a/CMake/ThirdPartyEigen.cmake +++ b/CMake/ThirdPartyEigen.cmake @@ -5,14 +5,14 @@ # - preprocessor definitions needed by package # -#SET(EigenRootDir "" CACHE PATH "Directory containing Eigen/Cholesky") -#SET(EIGEN_INCLUDE_DIR ${EigenRootDir}) - MACRO(USE_EIGEN) - find_package (Eigen3 3.3 REQUIRED NO_MODULE) - - #INCLUDE_DIRECTORIES( ${EIGEN_INCLUDE_DIR} ) - LIST( APPEND MY_EXTERNAL_LINK_LIBRARIES Eigen3::Eigen ) + FIND_PACKAGE (Eigen3 3.3 REQUIRED QUIET NO_MODULE) + IF (Eigen3_FOUND) + LIST( APPEND MY_EXTERNAL_LINK_LIBRARIES Eigen3::Eigen ) + ELSE() + FIND_PATH(EIGEN_INCLUDE_DIR NAMES Eigen/Dense Eigen/Dense PATHS /usr/local/include/eigen3) + INCLUDE_DIRECTORIES( ${EIGEN_INCLUDE_DIR} ) + ENDIF() ENDMACRO() # tell Eigen to use MKL BLAS, LAPACK and Intel VML (for vector operations) diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index d9878737..e3795c64 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -339,21 +339,11 @@ void style_dockwidget(QDockWidget* dockwidg) bool MenuWTT::event(QEvent* e) { + // not needed from Qt 5.1 -> see QMenu::setToolTipVisible const QHelpEvent* helpEvent = static_cast(e); - if (helpEvent->type() == QEvent::ToolTip) + if (helpEvent->type() == QEvent::ToolTip && activeAction() != 0) { - // call QToolTip::showText on that QAction's tooltip. - QPoint gpos = helpEvent->globalPos(); - QPoint pos = helpEvent->pos(); - if (pos.x() > 0 && pos.y() > 0 && pos.x() < 400 && pos.y() < 600) - { - QString textActive = activeAction()->text(); - QString justShow("Import RTstruct..."); - if (textActive == justShow) - QToolTip::showText(gpos, activeAction()->toolTip()); - else - QToolTip::hideText(); - } + QToolTip::showText(helpEvent->globalPos(), activeAction()->toolTip()); } else QToolTip::hideText(); @@ -1304,8 +1294,9 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, { toolmenu->insertItem("Merge Projects...", this, SLOT(execute_mergeprojects())); } - toolmenu->insertItem("Remove Unused Tissues", this, SLOT(execute_remove_unused_tissues())); - toolmenu->insertItem("Supplant Selected Tissue", this, SLOT(execute_voting_replace_labels())); + toolmenu->addAction("Remove Unused Tissues", this, SLOT(execute_remove_unused_tissues())); + auto action = toolmenu->addAction("Supplant Selected Tissue", this, SLOT(execute_voting_replace_labels())); + action->setToolTip("Remove selected tissue by iteratively assigning it to adjacent tissues."); toolmenu->insertItem("Split Disconnected Tissue Regions", this, SLOT(execute_split_tissue())); toolmenu->insertItem("Compute Target Connectivity", this, SLOT(execute_target_connected_components())); toolmenu->addSeparator(); @@ -7679,6 +7670,10 @@ void MainWindow::execute_voting_replace_labels() emit begin_datachange(dataSelection, this); auto remaining_voxels = VotingReplaceLabel(handler3D, FG, 0, radius, 1, 10); + if (remaining_voxels != 0) + { + VotingReplaceLabel(handler3D, FG, 0, radius, 0, 1); + } emit end_datachange(this, iseg::EndUndo); } diff --git a/iSeg/MeasurementWidget.cpp b/iSeg/MeasurementWidget.cpp index 48afa0e8..312c7ace 100755 --- a/iSeg/MeasurementWidget.cpp +++ b/iSeg/MeasurementWidget.cpp @@ -76,6 +76,7 @@ MeasurementWidget::MeasurementWidget(SlicesHandler* hand3D, QWidget* parent, // layout auto method_layout = make_vbox({rb_vector, rb_dist, rb_thick, rb_angle, rb_4ptangle, rb_vol}); + method_layout->addSpacerItem(new QSpacerItem(1,1,QSizePolicy::Minimum, QSizePolicy::Expanding)); auto method_area = new QFrame; method_area->setLayout(method_layout); method_area->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); diff --git a/iSeg/MorphologyWidget.h b/iSeg/MorphologyWidget.h index 6cfb96f8..addfaccd 100755 --- a/iSeg/MorphologyWidget.h +++ b/iSeg/MorphologyWidget.h @@ -7,8 +7,7 @@ * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ -#ifndef MORPHO_4MARCH05 -#define MORPHO_4MARCH05 +#pragma once #include "SlicesHandler.h" #include "bmp_read_1.h" @@ -66,4 +65,3 @@ private slots: } // namespace iseg -#endif diff --git a/iSeg/PickerWidget.cpp b/iSeg/PickerWidget.cpp index d58a3ff2..14be9280 100755 --- a/iSeg/PickerWidget.cpp +++ b/iSeg/PickerWidget.cpp @@ -192,8 +192,7 @@ void PickerWidget::on_mouse_clicked(Point p) if (rb_work->isChecked()) bmphand->change2mask_connectedwork(currentselection, p, addorsub); else - bmphand->change2mask_connectedtissue( - handler3D->active_tissuelayer(), currentselection, p, addorsub); + bmphand->change2mask_connectedtissue(handler3D->active_tissuelayer(), currentselection, p, addorsub); showborder(); } @@ -304,8 +303,7 @@ void PickerWidget::copy_pressed() } else { - tissues_size_t* tissues = - bmphand->return_tissues(handler3D->active_tissuelayer()); + auto tissues = bmphand->return_tissues(handler3D->active_tissuelayer()); for (unsigned int i = 0; i < area; i++) { valuedistrib[i] = (float)tissues[i]; diff --git a/iSeg/bmp_read_1.cpp b/iSeg/bmp_read_1.cpp index 221e5c57..27e3de0e 100755 --- a/iSeg/bmp_read_1.cpp +++ b/iSeg/bmp_read_1.cpp @@ -13822,7 +13822,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, counter1 = 0; while (!found && it != vvPit->end()) { - // if(it->px==(limit1.begin())->px&&it->py==(limit1.begin())->py){ if (p1.px == it->px && p1.py == it->py) { found = true; @@ -13843,7 +13842,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, counter2 = 0; while (!found && it != vvPit->end()) { - // if(it->px==(limit2.begin())->px&&it->py==(limit2.begin())->py){ if (p2.px == it->px && p2.py == it->py) { endP = it; @@ -13870,8 +13868,7 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, } std::vector oldline, oldline1; - if (counter2 - counter1 + 1 < - (int)vvPit->size() - counter2 + counter1) + if (counter2 - counter1 + 1 < (int)vvPit->size() - counter2 + counter1) { oldline.insert(oldline.begin(), startP, ++endP); oldline1.insert(oldline1.begin(), startP, endP); @@ -13898,8 +13895,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, itold = it; it++; - // FILE *fp3=fopen("D:\\Development\\segmentation\\sample images\\test100.txt","w"); - while (it != newline->end()) { if ((work_bits[unsigned(width) * it->py + it->px] == f) != in) @@ -13907,23 +13902,12 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, if (in) { changePts.push_back(*itold); - // fprintf(fp3,"*%i %i\n",(int)itold->px,(int)itold->py); } else { changePts.push_back(*it); - // fprintf(fp3,"*%i %i\n",(int)it->px,(int)it->py); } - /* if(work_bits[unsigned(width)*itold->py+it->px]==f){ - p.px=it->px; - p.py=itold->py; - } else { - p.px=itold->px; - p.py=it->py; - } - changePts.push_back(p);*/ - p.px = it->px; p.py = itold->py; changePts.push_back(p); @@ -13961,8 +13945,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, for (it = newline->begin(); it != newline->end(); it++) bkp[unsigned(width) * it->py + it->px] = f; - // it=newline->begin(); - // in=(work_bits[unsigned(width)*it->py+it->px]!=f); Point p1, p2, p3; it = changePts.begin(); p1 = *it; @@ -13979,7 +13961,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, { if (it1->px == p1.px && it1->py == p1.py) { - // fprintf(fp3,"a%i %i\n",(int)it1->px,(int)it1->py); in1 = !in1; p1 = *it; it++; @@ -13997,7 +13978,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, if (it1 == oldline1.end() || it1->px != p1.px || it1->py != p1.py) { - // fprintf(fp3,"b%i %i\n",(int)it1->px,(int)it1->py); in1 = true; p1 = *it; it++; @@ -14013,7 +13993,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, (it1->px == p3.px && it1->py == p3.py))) { bkp[unsigned(width) * it1->py + it1->px] = f; - // fprintf(fp3,"c%i %i\n",(int)it1->px,(int)it1->py); in1 = false; p1 = *it; it++; @@ -14036,7 +14015,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, { if (it1->px == p1.px && it1->py == p1.py) { - // fprintf(fp3,"d%i %i\n",(int)it1->px,(int)it1->py); in1 = !in1; p1 = *it; it++; @@ -14054,7 +14032,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, if (it1 == oldline1.rend() || it1->px != p1.px || it1->py != p1.py) { - // fprintf(fp3,"e%i %i\n",(int)it1->px,(int)it1->py); in1 = true; p1 = *it; it++; @@ -14070,7 +14047,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, (it1->px == p3.px && it1->py == p3.py))) { bkp[unsigned(width) * it1->py + it1->px] = f; - // fprintf(fp3,"f%i %i\n",(int)it1->px,(int)it1->py); in1 = false; p1 = *it; it++; @@ -14087,8 +14063,6 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, } } - // fclose(fp3); - sliceprovide->take_back(work_bits); work_bits = bkp; } From 39a5ecc2cedafc6c8547820a7d935b62330e6fa4 Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Tue, 26 Feb 2019 10:47:54 +0100 Subject: [PATCH 23/26] refactoringadded kmeans codeadded SaveParams/LoadParams stuff --- iSeg/ThresholdWidgetQt4.cpp | 279 +++++++++++++++++------------------- iSeg/ThresholdWidgetQt4.h | 7 +- iSeg/ThresholdWidgetQt4.ui | 19 +-- 3 files changed, 147 insertions(+), 158 deletions(-) diff --git a/iSeg/ThresholdWidgetQt4.cpp b/iSeg/ThresholdWidgetQt4.cpp index f1908051..5f5111f8 100644 --- a/iSeg/ThresholdWidgetQt4.cpp +++ b/iSeg/ThresholdWidgetQt4.cpp @@ -15,6 +15,7 @@ #include #include + using namespace iseg; @@ -25,9 +26,6 @@ ThresholdWidgetQt4::ThresholdWidgetQt4(SlicesHandler* hand3D, WidgetInterface(parent, name, wFlags), handler3D(hand3D) { - activeslice = handler3D->active_slice(); - bmphand = handler3D->get_activebmphandler(); - initUi(); updateUi(); } @@ -39,33 +37,11 @@ ThresholdWidgetQt4::~ThresholdWidgetQt4() void ThresholdWidgetQt4::init() { - if (activeslice != handler3D->active_slice()) - { - activeslice = handler3D->active_slice(); - bmphand = handler3D->get_activebmphandler(); - auto range = get_range(); - auto range_validator = new QDoubleValidator(range.first, range.second, 1000, ui.mThresholdBorderLineEdit); - ui.mThresholdBorderLineEdit->setValidator(range_validator); - - threshs[0] = float(ui.mManualNrTissuesSpinBox->value() - 1); - for (unsigned i = 0; i < 20; ++i) - { - bits1[i] = 0; - threshs[i + 1] = range.second; - weights[i] = 1.0f; - } - } - else { - bmphand = handler3D->get_activebmphandler(); - auto range = get_range(); - for (unsigned i = 0; i < 20; i++) - { - if (threshs[i + 1] > range.second) - threshs[i + 1] = range.second; - if (threshs[i + 1] < range.first) - threshs[i + 1] = range.first; - } - } + auto range = get_range(); + auto range_validator = new QDoubleValidator(range.first, range.second, 1000, ui.mThresholdBorderLineEdit); + ui.mThresholdBorderLineEdit->setValidator(range_validator); + + resetThresholds(); updateUi(); @@ -86,45 +62,46 @@ FILE* ThresholdWidgetQt4::SaveParams(FILE* fp, int version) if (version >= 2) { int dummy; - dummy = slider->value(); + dummy = ui.mThresholdHorizontalSlider->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = ratio->value(); + dummy = ui.mHistoMinPixelsRatioHorizontalSlider->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_nrtissues->value(); + dummy = ui.mManualNrTissuesSpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_dim->value(); + dummy = ui.mKMeansDimsSpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_tissuenr->value(); + dummy = ui.mManualLimitNrSpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_px->value(); + dummy = ui.mHistoPxSpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_py->value(); + dummy = ui.mHistoPySpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_lx->value(); + dummy = ui.mHistoLxSpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_ly->value(); + dummy = ui.mHistoLySpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_iternr->value(); + dummy = ui.mKMeansIterationsSpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_converge->value(); + dummy = ui.mKMeansConvergeSpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = sb_minpix->value(); + dummy = ui.mHistoMinPixelsSpinBox->value(); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(subsect->isOn()); + dummy = (int)(ui.mSubsectionGroupBox->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_manual->isOn()); + dummy = (int)(ui.mManualModeRadioButton->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_histo->isOn()); + dummy = (int)(ui.mHistoModeRadioButton->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_kmeans->isOn()); + dummy = (int)(ui.mKMeansRadioButton->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(rb_EM->isOn()); + dummy = (int)(ui.mEMModeRadioButton->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - dummy = (int)(allslices->isOn()); + dummy = (int)(ui.mAllSlicesCheckBox->isChecked()); fwrite(&(dummy), 1, sizeof(int), fp); - fwrite(&upper, 1, sizeof(float), fp); - fwrite(&lower, 1, sizeof(float), fp); + auto range = get_range(); + fwrite(&range.second, 1, sizeof(float), fp); + fwrite(&range.first, 1, sizeof(float), fp); fwrite(threshs, 21, sizeof(float), fp); fwrite(weights, 20, sizeof(float), fp); } @@ -136,87 +113,55 @@ FILE* ThresholdWidgetQt4::LoadParams(FILE* fp, int version) { if (version >= 2) { - QObject::disconnect(sb_nrtissues, SIGNAL(valueChanged(int)), this, - SLOT(nrtissues_changed(int))); - QObject::disconnect(sb_dim, SIGNAL(valueChanged(int)), this, - SLOT(dim_changed(int))); - QObject::disconnect(sb_tissuenr, SIGNAL(valueChanged(int)), this, - SLOT(tissuenr_changed(int))); - QObject::disconnect(slider, SIGNAL(sliderMoved(int)), this, - SLOT(slider_changed(int))); - QObject::disconnect(le_borderval, SIGNAL(returnPressed()), this, - SLOT(le_borderval_returnpressed())); - QObject::disconnect(subsect, SIGNAL(clicked()), this, - SLOT(subsect_toggled())); - QObject::disconnect(modegroup, SIGNAL(buttonClicked(int)), this, - SLOT(method_changed(int))); - int dummy; fread(&dummy, sizeof(int), 1, fp); - slider->setValue(dummy); + ui.mThresholdHorizontalSlider->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - ratio->setValue(dummy); + ui.mHistoMinPixelsRatioHorizontalSlider->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - sb_nrtissues->setValue(dummy); - sb_tissuenr->setMaxValue(dummy - 1); + ui.mManualNrTissuesSpinBox->setValue(dummy); + ui.mManualLimitNrSpinBox->setMaxValue(dummy - 1); fread(&dummy, sizeof(int), 1, fp); - sb_dim->setValue(dummy); + ui.mKMeansDimsSpinBox->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - sb_tissuenr->setValue(dummy); + ui.mManualLimitNrSpinBox->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - sb_px->setValue(dummy); + ui.mHistoPxSpinBox->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - sb_py->setValue(dummy); + ui.mHistoPySpinBox->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - sb_lx->setValue(dummy); + ui.mHistoLxSpinBox->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - sb_ly->setValue(dummy); + ui.mHistoLySpinBox->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - sb_iternr->setValue(dummy); + ui.mKMeansIterationsSpinBox->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - sb_converge->setValue(dummy); + ui.mKMeansConvergeSpinBox->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - sb_minpix->setValue(dummy); + ui.mHistoMinPixelsSpinBox->setValue(dummy); fread(&dummy, sizeof(int), 1, fp); - subsect->setChecked(dummy > 0); + ui.mSubsectionGroupBox->setChecked(dummy > 0); fread(&dummy, sizeof(int), 1, fp); - rb_manual->setChecked(dummy > 0); + ui.mManualModeRadioButton->setChecked(dummy > 0); fread(&dummy, sizeof(int), 1, fp); - rb_histo->setChecked(dummy > 0); + ui.mHistoModeRadioButton->setChecked(dummy > 0); fread(&dummy, sizeof(int), 1, fp); - rb_kmeans->setChecked(dummy > 0); + ui.mKMeansRadioButton->setChecked(dummy > 0); fread(&dummy, sizeof(int), 1, fp); - rb_EM->setChecked(dummy > 0); + ui.mEMModeRadioButton->setChecked(dummy > 0); fread(&dummy, sizeof(int), 1, fp); - allslices->setChecked(dummy > 0); + ui.mAllSlicesCheckBox->setChecked(dummy > 0); + float upper = 0, lower = 0; fread(&upper, sizeof(float), 1, fp); fread(&lower, sizeof(float), 1, fp); fread(threshs, sizeof(float), 21, fp); fread(weights, sizeof(float), 20, fp); - dummy = sb_tissuenr->value(); - method_changed(0); - subsect_toggled(); - nrtissues_changed(sb_nrtissues->value()); - dim_changed(sb_dim->value()); - sb_tissuenr->setValue(dummy); + dummy = ui.mManualNrTissuesSpinBox->value(); on_tissuenr_changed(dummy); - QObject::connect(subsect, SIGNAL(clicked()), this, - SLOT(subsect_toggled())); - QObject::connect(modegroup, SIGNAL(buttonClicked(int)), this, - SLOT(method_changed(int))); - QObject::connect(sb_nrtissues, SIGNAL(valueChanged(int)), this, - SLOT(nrtissues_changed(int))); - QObject::connect(sb_dim, SIGNAL(valueChanged(int)), this, - SLOT(dim_changed(int))); - QObject::connect(sb_tissuenr, SIGNAL(valueChanged(int)), this, - SLOT(tissuenr_changed(int))); - QObject::connect(slider, SIGNAL(sliderMoved(int)), this, - SLOT(slider_changed(int))); - QObject::connect(le_borderval, SIGNAL(returnPressed()), this, - SLOT(le_borderval_returnpressed())); + } return fp; } @@ -307,7 +252,7 @@ void ThresholdWidgetQt4::on_mThresholdHorizontalSlider_valueChanged(int newValue if (ui.mAllSlicesCheckBox->isChecked()) handler3D->threshold(threshs); else - bmphand->threshold(threshs); + handler3D->get_activebmphandler()->threshold(threshs); emit end_datachange(this, iseg::NoUndo); @@ -331,7 +276,7 @@ void ThresholdWidgetQt4::on_mThresholdBorderLineEdit_editingFinished() if (ui.mAllSlicesCheckBox->isChecked()) handler3D->threshold(threshs); else - bmphand->threshold(threshs); + handler3D->get_activebmphandler()->threshold(threshs); emit end_datachange(this); } @@ -397,6 +342,7 @@ void ThresholdWidgetQt4::on_mKMeansImageNrSpinBox_valueChanged(int newValue) void ThresholdWidgetQt4::on_mKMeansWeightHorizontalSlider_valueChanged(int newValue) { + weights[ui.mKMeansImageNrSpinBox->value() - 1] = newValue * 0.005f; } void ThresholdWidgetQt4::on_mKMeansFilenameLineEdit_editingFinished() @@ -406,19 +352,19 @@ void ThresholdWidgetQt4::on_mKMeansFilenameLineEdit_editingFinished() void ThresholdWidgetQt4::on_mKMeansFilenamePushButton_clicked() { - QString loadfilename = QFileDialog::getOpenFileName(this, "Select an image" - QString::null, + QString loadfilename = QFileDialog::getOpenFileName(this, "Select an image", + QString(), "Images (*.png)\n" "Images (*.mhd)\n" "All (*.*)" //"Images (*.bmp)\n" "All (*.*)", QString::null, ); //, filename); - ui.mKMeansFilenameLineEdit_2->setText(loadfilename); + ui.mKMeansFilenameLineEdit->setText(loadfilename); filenames[ui.mKMeansImageNrSpinBox->value() - 2] = loadfilename; - ui.mKMeansRRadioButton_2->setEnabled(false); - ui.mKMeansGRadioButton_2->setEnabled(false); - ui.mKMeansBRadioButton_2->setEnabled(false); - ui.mKMeansARadioButton_2->setEnabled(false); + ui.mKMeansRRadioButton->setEnabled(false); + ui.mKMeansGRadioButton->setEnabled(false); + ui.mKMeansBRadioButton->setEnabled(false); + ui.mKMeansARadioButton->setEnabled(false); QFileInfo fi(loadfilename); QString ext = fi.extension(); @@ -428,33 +374,33 @@ void ThresholdWidgetQt4::on_mKMeansFilenamePushButton_clicked() if (image.depth() > 8) { - ui.mKMeansRRadioButton_2->setEnabled(true); - ui.mKMeansGRadioButton_2->setEnabled(true); - ui.mKMeansBRadioButton_2->setEnabled(true); + ui.mKMeansRRadioButton->setEnabled(true); + ui.mKMeansGRadioButton->setEnabled(true); + ui.mKMeansBRadioButton->setEnabled(true); if (image.hasAlphaChannel()) - ui.mKMeansARadioButton_2->setEnabled(true); + ui.mKMeansARadioButton->setEnabled(true); } } } void ThresholdWidgetQt4::on_mKMeansRRadioButton_clicked() { - + RGBA_changed(); } void ThresholdWidgetQt4::on_mKMeansGRadioButton_clicked() { - + RGBA_changed(); } void ThresholdWidgetQt4::on_mKMeansBRadioButton_clicked() { - + RGBA_changed(); } void ThresholdWidgetQt4::on_mKMeansARadioButton_clicked() { - + RGBA_changed(); } void ThresholdWidgetQt4::on_mKMeansIterationsSpinBox_valueChanged(int newValue) @@ -507,31 +453,31 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() if (ui.mAllSlicesCheckBox->isChecked()) handler3D->threshold(threshs); else - bmphand->threshold(threshs); + handler3D->get_activebmphandler()->threshold(threshs); } else if (ui.mHistoModeRadioButton->isChecked()) { - bmphand->swap_bmpwork(); + handler3D->get_activebmphandler()->swap_bmpwork(); if (ui.mSubsectionGroupBox->isChecked()) { Point p; p.px = (unsigned short)ui.mHistoPxSpinBox->value(); p.py = (unsigned short)ui.mHistoPySpinBox->value(); - bmphand->make_histogram(p, ui.mHistoLxSpinBox->value(), ui.mHistoLySpinBox->value(), true); + handler3D->get_activebmphandler()->make_histogram(p, ui.mHistoLxSpinBox->value(), ui.mHistoLySpinBox->value(), true); } else - bmphand->make_histogram(true); + handler3D->get_activebmphandler()->make_histogram(true); - bmphand->gaussian_hist(1.0f); - bmphand->swap_bmpwork(); + handler3D->get_activebmphandler()->gaussian_hist(1.0f); + handler3D->get_activebmphandler()->swap_bmpwork(); - float* thresh1 = bmphand->find_modal((unsigned)ui.mHistoMinPixelsSpinBox->value(), + float* thresh1 = handler3D->get_activebmphandler()->find_modal((unsigned)ui.mHistoMinPixelsSpinBox->value(), 0.005f * ui.mHistoMinPixelsRatioHorizontalSlider->value()); if (ui.mAllSlicesCheckBox->isChecked()) handler3D->threshold(thresh1); else - bmphand->threshold(thresh1); + handler3D->get_activebmphandler()->threshold(thresh1); free(thresh1); } else if (ui.mKMeansRadioButton->isChecked()) @@ -564,7 +510,7 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() (short)ui.mKMeansDimsSpinBox->value(), mhdfiles, weights, centers, tol_f, tol_d); else - bmphand->gamma_mhd( + handler3D->get_activebmphandler()->gamma_mhd( (short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), mhdfiles, handler3D->active_slice(), weights, centers, tol_f, tol_d, handler3D->get_pixelsize()); @@ -585,13 +531,13 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() 1) == "png") { std::vector extractChannels; - if (ui.mKMeansRRadioButton_2->isChecked()) + if (ui.mKMeansRRadioButton->isChecked()) extractChannels.push_back(0); - if (ui.mKMeansGRadioButton_2->isChecked()) + if (ui.mKMeansGRadioButton->isChecked()) extractChannels.push_back(1); - if (ui.mKMeansBRadioButton_2->isChecked()) + if (ui.mKMeansBRadioButton->isChecked()) extractChannels.push_back(2); - if (ui.mKMeansARadioButton_2->isChecked()) + if (ui.mKMeansARadioButton->isChecked()) extractChannels.push_back(3); if (ui.mKMeansDimsSpinBox->value() != extractChannels.size() + 1) return; @@ -605,7 +551,7 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() (unsigned int)ui.mKMeansConvergeSpinBox->value(), ui.mCenterFilenameLineEdit->text().toStdString()); else - bmphand->kmeans_png( + handler3D->get_activebmphandler()->kmeans_png( (short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, extractChannels, handler3D->active_slice(), @@ -623,7 +569,7 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() (unsigned int)ui.mKMeansIterationsSpinBox->value(), (unsigned int)ui.mKMeansConvergeSpinBox->value()); else - bmphand->kmeans_mhd((short)ui.mKMeansNrTissuesSpinBox->value(), + handler3D->get_activebmphandler()->kmeans_mhd((short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, handler3D->active_slice(), weights, @@ -640,7 +586,7 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() kmeansfiles, weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), (unsigned int)ui.mKMeansConvergeSpinBox->value()); else - bmphand->kmeans_mhd((short)ui.mKMeansNrTissuesSpinBox->value(), + handler3D->get_activebmphandler()->kmeans_mhd((short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, handler3D->active_slice(), weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), @@ -654,9 +600,9 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() for (int i = 0; i < ui.mKMeansDimsSpinBox->value(); i++) { if (bits1[i] == 0) - bits[i] = bmphand->return_bmp(); + bits[i] = handler3D->get_activebmphandler()->return_bmp(); else - bits[i] = bmphand->getstack(bits1[i], modedummy); + bits[i] = handler3D->get_activebmphandler()->getstack(bits1[i], modedummy); } if (ui.mAllSlicesCheckBox->isChecked()) @@ -665,7 +611,7 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() (unsigned int)ui.mKMeansIterationsSpinBox->value(), (unsigned int)ui.mKMeansConvergeSpinBox->value()); else - bmphand->em((short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), + handler3D->get_activebmphandler()->em((short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), bits, weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), (unsigned int)ui.mKMeansConvergeSpinBox->value()); } @@ -673,6 +619,11 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() emit end_datachange(this); } +void ThresholdWidgetQt4::bmp_changed() +{ + resetThresholds(); +} + void ThresholdWidgetQt4::on_tissuenr_changed(int newValue) { updateUi(); @@ -687,8 +638,13 @@ void ThresholdWidgetQt4::initUi() { ui.setupUi(this); - activeslice = handler3D->active_slice(); - bmphand = handler3D->get_activebmphandler(); + threshs[0] = float(ui.mManualNrTissuesSpinBox->value() - 1); + for (unsigned i = 0; i < 20; ++i) + { + bits1[i] = 0; + threshs[i + 1] = 255; + weights[i] = 1.0f; + } auto mode_signal_mapping = new QSignalMapper(this); @@ -708,7 +664,7 @@ void ThresholdWidgetQt4::initUi() } void ThresholdWidgetQt4::updateUi() -{ +{ auto range = get_range(); // manual ui.mLoadBordersPushButton->setDisabled(hideparams); @@ -721,7 +677,7 @@ void ThresholdWidgetQt4::updateUi() ui.mThresholdHorizontalSlider->setValue(slider_value); ui.mThresholdBorderLineEdit->setText(QString::number(threshs[ui.mManualLimitNrSpinBox->value()], 'g', 3)); } - + //ui.mWeightBorderLineEdit->setText(QString::number(threshs[sb_tissuenr->value()], 'g', 3)); ui.mManualLimitNrLabel->setEnabled(ui.mManualNrTissuesSpinBox->value() != 2); ui.mManualLimitNrSpinBox->setEnabled(ui.mManualNrTissuesSpinBox->value() != 2); @@ -733,10 +689,14 @@ void ThresholdWidgetQt4::updateUi() // kmeans ui.mKMeansDimsLabel->setDisabled(hideparams); ui.mKMeansDimsSpinBox->setDisabled(hideparams); + ui.mKMeansImageNrLabel->setEnabled(ui.mKMeansDimsSpinBox->value() != 2); + ui.mKMeansImageNrSpinBox->setEnabled(ui.mKMeansDimsSpinBox->value() != 2); ui.mKMeansIterationsFrame->setDisabled(hideparams); + ui.mKMeansWeightLabel->setEnabled(ui.mKMeansDimsSpinBox->value() != 2); + ui.mKMeansWeightHorizontalSlider->setEnabled(ui.mKMeansDimsSpinBox->value() != 2); ui.mKMeansWeightHorizontalSlider->setValue(int(200 * weights[ui.mKMeansImageNrSpinBox->value() - 1])); ui.mKMeansFilenameFrame->setEnabled(ui.mKMeansImageNrSpinBox->value() > 1); - ui.mKMeansFilenameLineEdit_2->setText(ui.mKMeansImageNrSpinBox->value() > 1 ? filenames[ui.mKMeansImageNrSpinBox->value() - 2] : ""); + ui.mKMeansFilenameLineEdit->setText(ui.mKMeansImageNrSpinBox->value() > 1 ? filenames[ui.mKMeansImageNrSpinBox->value() - 2] : ""); // general ui.mCenterFilenameLineEdit->setEnabled(ui.mUseCenterFileCheckBox->isChecked()); @@ -745,12 +705,35 @@ void ThresholdWidgetQt4::updateUi() std::pair ThresholdWidgetQt4::get_range() const { - std::pair range(0, 0); - if (bmphand) { + std::pair range(0.0f, 0.0f); + if (handler3D->get_activebmphandler()) { Pair p; - bmphand->get_bmprange(&p); + handler3D->get_activebmphandler()->get_bmprange(&p); range.first = p.low; range.second = p.high; } return range; +} + +void ThresholdWidgetQt4::resetThresholds() +{ + auto range = get_range(); + for (unsigned i = 0; i < 20; i++) + { + if (threshs[i + 1] > range.second) + threshs[i + 1] = range.second; + if (threshs[i + 1] < range.first) + threshs[i + 1] = range.first; + } +} + +void ThresholdWidgetQt4::RGBA_changed() +{ + // amazing code here... + int buttonsChecked = ui.mKMeansRRadioButton->isChecked() + ui.mKMeansGRadioButton->isChecked() + + ui.mKMeansBRadioButton->isChecked() + ui.mKMeansARadioButton->isChecked(); + ui.mKMeansDimsSpinBox->setValue(buttonsChecked + 1); + + if (buttonsChecked > 0) + ui.mKMeansImageNrSpinBox->setValue(2); } \ No newline at end of file diff --git a/iSeg/ThresholdWidgetQt4.h b/iSeg/ThresholdWidgetQt4.h index a770a944..4b188100 100644 --- a/iSeg/ThresholdWidgetQt4.h +++ b/iSeg/ThresholdWidgetQt4.h @@ -77,17 +77,20 @@ private slots: void on_mAllSlicesCheckBox_toggled(bool newValue); void on_mExecutePushButton_clicked(); + // override + void bmp_changed(); + private: void on_tissuenr_changed(int i) override; void on_slicenr_changed() override; void initUi(); void updateUi(); + void resetThresholds(); + void RGBA_changed(); std::pair get_range() const; - bmphandler *bmphand = nullptr; SlicesHandler *handler3D = nullptr; - unsigned short activeslice = std::numeric_limits::max(); float threshs[21]; // ugly float weights[20]; // ugly float *bits[20]; // ugly diff --git a/iSeg/ThresholdWidgetQt4.ui b/iSeg/ThresholdWidgetQt4.ui index 1fdd742a..38a2f61d 100644 --- a/iSeg/ThresholdWidgetQt4.ui +++ b/iSeg/ThresholdWidgetQt4.ui @@ -482,24 +482,24 @@ 0 - + Filename: - + - + Select - + QFrame::StyledPanel @@ -511,28 +511,28 @@ 0 - + R - + G - + B - + A @@ -667,6 +667,9 @@ Apply to all slices + + true + From ed81399204ae3a389b366a0dddfb2764253ee0d7 Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Tue, 26 Feb 2019 10:50:13 +0100 Subject: [PATCH 24/26] removed thresholdwidget --- iSeg/CMakeLists.txt | 6 ++---- iSeg/MainWindow.cpp | 5 +---- iSeg/MainWindow.h | 3 +-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/iSeg/CMakeLists.txt b/iSeg/CMakeLists.txt index 70352d37..bb7a46f1 100755 --- a/iSeg/CMakeLists.txt +++ b/iSeg/CMakeLists.txt @@ -66,8 +66,7 @@ SET(ViewerSrcs SliceTransform.cpp SliceViewerWidget.cpp SmoothingWidget.cpp - SurfaceViewerWidget.cpp - ThresholdWidget.cpp + SurfaceViewerWidget.cpp ThresholdWidgetQt4.cpp TissueCleaner.cpp TissueHierarchy.cpp @@ -116,8 +115,7 @@ SET(MyMocHeaders SliceViewerWidget.h SmoothingWidget.h SurfaceViewerWidget.h - TissueTreeWidget.h - ThresholdWidget.h + TissueTreeWidget.h ThresholdWidgetQt4.h TransformWidget.h UndoConfigurationDialog.h diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index e93fe106..c7218579 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -34,7 +34,6 @@ #include "SmoothingWidget.h" #include "StdStringToQString.h" #include "SurfaceViewerWidget.h" -#include "ThresholdWidget.h" #include "ThresholdWidgetQt4.h" #include "TissueCleaner.h" #include "TissueInfos.h" @@ -613,10 +612,8 @@ MainWindow::MainWindow(SlicesHandler* hand3D, const QString& locationstring, lb_inactivewarning = new QLabel(" 3D Inactive Slice! ", this); lb_inactivewarning->setStyleSheet("QLabel { color: red; }"); - threshold_widget = new ThresholdWidget(handler3D, nullptr, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase); + threshold_widget = new ThresholdWidgetQt4(handler3D, nullptr, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase); tabwidgets.push_back(threshold_widget); - threshold_widget_qt4 = new ThresholdWidgetQt4(handler3D, nullptr, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase); - tabwidgets.push_back(threshold_widget_qt4); hyst_widget = new HystereticGrowingWidget(handler3D, nullptr, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase); tabwidgets.push_back(hyst_widget); livewire_widget = new LivewireWidget(handler3D, nullptr, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase); diff --git a/iSeg/MainWindow.h b/iSeg/MainWindow.h index 9919eadd..bb56646c 100755 --- a/iSeg/MainWindow.h +++ b/iSeg/MainWindow.h @@ -223,8 +223,7 @@ class MainWindow : public QMainWindow std::vector showtab_action; QCheckBox* tissue3Dopt; QStackedWidget* methodTab; - ThresholdWidget* threshold_widget; - ThresholdWidgetQt4* threshold_widget_qt4; + ThresholdWidgetQt4* threshold_widget; MeasurementWidget* measurement_widget; VesselWidget* vesselextr_widget; SmoothingWidget* smoothing_widget; From e96d97533c04e6ffe0d362b5315fb0990cbb06ee Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 26 Feb 2019 14:41:42 +0100 Subject: [PATCH 25/26] fix: mode (stack index) was no initialized to last mode correctly style: move updaterUi, InitUi to top style: headers & new lines were auto-changed via clang-format --- iSeg/ThresholdWidgetQt4.cpp | 320 ++++++++++++++++++------------------ 1 file changed, 159 insertions(+), 161 deletions(-) diff --git a/iSeg/ThresholdWidgetQt4.cpp b/iSeg/ThresholdWidgetQt4.cpp index 5f5111f8..05c3c84e 100644 --- a/iSeg/ThresholdWidgetQt4.cpp +++ b/iSeg/ThresholdWidgetQt4.cpp @@ -9,41 +9,116 @@ */ #include "ThresholdWidgetQt4.h" + #include "SlicesHandler.h" #include "bmp_read_1.h" -#include -#include -#include +#include +#include +#include using namespace iseg; - -ThresholdWidgetQt4::ThresholdWidgetQt4(SlicesHandler* hand3D, - QWidget *parent, - const char* name, - Qt::WindowFlags wFlags): -WidgetInterface(parent, name, wFlags), -handler3D(hand3D) +ThresholdWidgetQt4::ThresholdWidgetQt4(SlicesHandler* hand3D, QWidget* parent, const char* name, Qt::WindowFlags wFlags) + : WidgetInterface(parent, name, wFlags), handler3D(hand3D) { - initUi(); + initUi(); updateUi(); } ThresholdWidgetQt4::~ThresholdWidgetQt4() { +} + +void ThresholdWidgetQt4::initUi() +{ + ui.setupUi(this); + + threshs[0] = float(ui.mManualNrTissuesSpinBox->value() - 1); + for (unsigned i = 0; i < 20; ++i) + { + bits1[i] = 0; + threshs[i + 1] = 255; + weights[i] = 1.0f; + } + + auto mode_signal_mapping = new QSignalMapper(this); + mode_signal_mapping->setMapping(ui.mManualModeRadioButton, ui.mManualWidget); + mode_signal_mapping->setMapping(ui.mHistoModeRadioButton, ui.mHistoWidget); + mode_signal_mapping->setMapping(ui.mKMeansRadioButton, ui.mKmeansEMWidget); + mode_signal_mapping->setMapping(ui.mEMModeRadioButton, ui.mKmeansEMWidget); + QObject::connect(ui.mManualModeRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); + QObject::connect(ui.mHistoModeRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); + QObject::connect(ui.mKMeansRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); + QObject::connect(ui.mEMModeRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); + QObject::connect(mode_signal_mapping, SIGNAL(mapped(QWidget*)), ui.mModeStackedWidget, SLOT(setCurrentWidget(QWidget*))); + // init with manual mode + ui.mManualModeRadioButton->setChecked(true); + ui.mModeStackedWidget->setCurrentWidget(ui.mManualWidget); +} + +void ThresholdWidgetQt4::updateUi() +{ + auto range = get_range(); + // manual + ui.mLoadBordersPushButton->setDisabled(hideparams); + ui.mSaveBordersPushButton->setDisabled(hideparams); + ui.mThresholdLowerLabel->setText(QString::number(range.first, 'g', 3)); + ui.mThresholdUpperLabel->setText(QString::number(range.second, 'g', 3)); + if (range.second != range.first) + { + const int slider_value = static_cast((threshs[ui.mManualLimitNrSpinBox->value()] - range.first) * 200 / (range.second - range.first) + .5f); + ui.mThresholdHorizontalSlider->setValue(slider_value); + ui.mThresholdBorderLineEdit->setText(QString::number(threshs[ui.mManualLimitNrSpinBox->value()], 'g', 3)); + } + + //ui.mWeightBorderLineEdit->setText(QString::number(threshs[sb_tissuenr->value()], 'g', 3)); + ui.mManualLimitNrLabel->setEnabled(ui.mManualNrTissuesSpinBox->value() != 2); + ui.mManualLimitNrSpinBox->setEnabled(ui.mManualNrTissuesSpinBox->value() != 2); + + // histo + ui.mSubsectionGroupBox->setDisabled(hideparams); + ui.mMinPixelsFrame->setDisabled(hideparams); + + // kmeans + ui.mKMeansDimsLabel->setDisabled(hideparams); + ui.mKMeansDimsSpinBox->setDisabled(hideparams); + ui.mKMeansIterationsFrame->setDisabled(hideparams); + ui.mKMeansImageNrLabel->setEnabled(ui.mKMeansDimsSpinBox->value() != 1); + ui.mKMeansImageNrSpinBox->setEnabled(ui.mKMeansDimsSpinBox->value() != 1); + ui.mKMeansWeightLabel->setEnabled(ui.mKMeansDimsSpinBox->value() != 1); + ui.mKMeansWeightHorizontalSlider->setEnabled(ui.mKMeansDimsSpinBox->value() != 1); + ui.mKMeansWeightHorizontalSlider->setValue(int(200 * weights[ui.mKMeansImageNrSpinBox->value() - 1])); + ui.mKMeansFilenameFrame->setEnabled(ui.mKMeansImageNrSpinBox->value() > 1); + ui.mKMeansFilenameLineEdit->setText(ui.mKMeansImageNrSpinBox->value() > 1 ? filenames[ui.mKMeansImageNrSpinBox->value() - 2] : ""); + + // general + ui.mCenterFilenameLineEdit->setEnabled(ui.mUseCenterFileCheckBox->isChecked()); + ui.mSelectCenterFilenamePushButton->setEnabled(ui.mUseCenterFileCheckBox->isChecked()); +} + +std::pair ThresholdWidgetQt4::get_range() const +{ + std::pair range(0.0f, 0.0f); + if (handler3D->get_activebmphandler()) + { + Pair p; + handler3D->get_activebmphandler()->get_bmprange(&p); + range.first = p.low; + range.second = p.high; + } + return range; } void ThresholdWidgetQt4::init() { auto range = get_range(); auto range_validator = new QDoubleValidator(range.first, range.second, 1000, ui.mThresholdBorderLineEdit); - ui.mThresholdBorderLineEdit->setValidator(range_validator); - + ui.mThresholdBorderLineEdit->setValidator(range_validator); + resetThresholds(); - updateUi(); } @@ -161,7 +236,12 @@ FILE* ThresholdWidgetQt4::LoadParams(FILE* fp, int version) dummy = ui.mManualNrTissuesSpinBox->value(); on_tissuenr_changed(dummy); - + if (ui.mManualModeRadioButton->isChecked()) + ui.mModeStackedWidget->setCurrentWidget(ui.mManualWidget); + else if (ui.mHistoModeRadioButton->isChecked()) + ui.mModeStackedWidget->setCurrentWidget(ui.mHistoWidget); + else + ui.mModeStackedWidget->setCurrentWidget(ui.mKmeansEMWidget); } return fp; } @@ -182,11 +262,12 @@ void ThresholdWidgetQt4::on_mManualLimitNrSpinBox_valueChanged(int newValue) void ThresholdWidgetQt4::on_mLoadBordersPushButton_clicked() { auto loadfilename = - QFileDialog::getOpenFileName(this, "Select Boarder file", QString::null, - "Boarders (*.txt)\n" - "All (*.*)"); + QFileDialog::getOpenFileName(this, "Select Boarder file", QString::null, + "Boarders (*.txt)\n" + "All (*.*)"); - if (loadfilename.isEmpty()) { + if (loadfilename.isEmpty()) + { return; } @@ -229,7 +310,7 @@ void ThresholdWidgetQt4::on_mLoadBordersPushButton_clicked() void ThresholdWidgetQt4::on_mSaveBordersPushButton_clicked() { auto savefilename = QFileDialog::getSaveFileName(this, "Save file", - QString::null, "Boarders (*.txt)\n"); + QString::null, "Boarders (*.txt)\n"); if (savefilename.length() > 4 && !savefilename.endsWith(QString(".txt"))) savefilename.append(".txt"); @@ -247,7 +328,7 @@ void ThresholdWidgetQt4::on_mThresholdHorizontalSlider_valueChanged(int newValue { auto range = get_range(); threshs[ui.mManualLimitNrSpinBox->value()] = - newValue * 0.005f * (range.second - range.first) + range.first; + newValue * 0.005f * (range.second - range.first) + range.first; if (ui.mAllSlicesCheckBox->isChecked()) handler3D->threshold(threshs); @@ -316,7 +397,7 @@ void ThresholdWidgetQt4::on_mHistoMinPixelsRatioHorizontalSlider_valueChanged(in } void ThresholdWidgetQt4::on_mKMeansNrTissuesSpinBox_valueChanged(int newValue) -{ +{ } void ThresholdWidgetQt4::on_mKMeansDimsSpinBox_valueChanged(int newValue) @@ -331,13 +412,13 @@ void ThresholdWidgetQt4::on_mKMeansDimsSpinBox_valueChanged(int newValue) ui.mKMeansImageNrSpinBox->setMaxValue(newValue); ui.mKMeansImageNrSpinBox->setValue(1); - + updateUi(); } void ThresholdWidgetQt4::on_mKMeansImageNrSpinBox_valueChanged(int newValue) { - updateUi(); + updateUi(); } void ThresholdWidgetQt4::on_mKMeansWeightHorizontalSlider_valueChanged(int newValue) @@ -347,17 +428,16 @@ void ThresholdWidgetQt4::on_mKMeansWeightHorizontalSlider_valueChanged(int newVa void ThresholdWidgetQt4::on_mKMeansFilenameLineEdit_editingFinished() { - } void ThresholdWidgetQt4::on_mKMeansFilenamePushButton_clicked() { QString loadfilename = QFileDialog::getOpenFileName(this, "Select an image", - QString(), - "Images (*.png)\n" - "Images (*.mhd)\n" - "All (*.*)" //"Images (*.bmp)\n" "All (*.*)", QString::null, - ); //, filename); + QString(), + "Images (*.png)\n" + "Images (*.mhd)\n" + "All (*.*)" //"Images (*.bmp)\n" "All (*.*)", QString::null, + ); //, filename); ui.mKMeansFilenameLineEdit->setText(loadfilename); filenames[ui.mKMeansImageNrSpinBox->value() - 2] = loadfilename; @@ -405,17 +485,16 @@ void ThresholdWidgetQt4::on_mKMeansARadioButton_clicked() void ThresholdWidgetQt4::on_mKMeansIterationsSpinBox_valueChanged(int newValue) { - } void ThresholdWidgetQt4::on_mKMeansConvergeSpinBox_valueChanged(int newValue) { - } void ThresholdWidgetQt4::on_mUseCenterFileCheckBox_toggled(bool newValue) { - if (!newValue) { + if (!newValue) + { ui.mCenterFilenameLineEdit->setText(""); } updateUi(); @@ -429,7 +508,7 @@ void ThresholdWidgetQt4::on_mCenterFilenameLineEdit_editingFinished() void ThresholdWidgetQt4::on_mSelectCenterFilenamePushButton_clicked() { auto center_file_name = QFileDialog::getOpenFileName(nullptr, - "Select center file", QString(), "Text File (*.txt*)"); + "Select center file", QString(), "Text File (*.txt*)"); ui.mCenterFilenameLineEdit->setText(center_file_name); } @@ -473,7 +552,7 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() handler3D->get_activebmphandler()->swap_bmpwork(); float* thresh1 = handler3D->get_activebmphandler()->find_modal((unsigned)ui.mHistoMinPixelsSpinBox->value(), - 0.005f * ui.mHistoMinPixelsRatioHorizontalSlider->value()); + 0.005f * ui.mHistoMinPixelsRatioHorizontalSlider->value()); if (ui.mAllSlicesCheckBox->isChecked()) handler3D->threshold(thresh1); else @@ -506,14 +585,14 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() mhdfiles.push_back(std::string(filenames[i].ascii())); if (ui.mAllSlicesCheckBox->isChecked()) handler3D->gamma_mhd(handler3D->active_slice(), - (short)ui.mKMeansNrTissuesSpinBox->value(), - (short)ui.mKMeansDimsSpinBox->value(), mhdfiles, weights, - centers, tol_f, tol_d); + (short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), mhdfiles, weights, + centers, tol_f, tol_d); else handler3D->get_activebmphandler()->gamma_mhd( - (short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), - mhdfiles, handler3D->active_slice(), weights, centers, - tol_f, tol_d, handler3D->get_pixelsize()); + (short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), + mhdfiles, handler3D->active_slice(), weights, centers, + tol_f, tol_d, handler3D->get_pixelsize()); delete[] tol_d; delete[] tol_f; for (int i = 0; i < ui.mKMeansNrTissuesSpinBox->value(); i++) @@ -528,7 +607,7 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() if (kmeansfiles.size() > 0) { if (kmeansfiles[0].substr(kmeansfiles[0].find_last_of(".") + - 1) == "png") + 1) == "png") { std::vector extractChannels; if (ui.mKMeansRRadioButton->isChecked()) @@ -543,54 +622,54 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() return; if (ui.mAllSlicesCheckBox->isChecked()) handler3D->kmeans_png( - handler3D->active_slice(), - (short)ui.mKMeansNrTissuesSpinBox->value(), - (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, - extractChannels, weights, - (unsigned int)ui.mKMeansIterationsSpinBox->value(), - (unsigned int)ui.mKMeansConvergeSpinBox->value(), - ui.mCenterFilenameLineEdit->text().toStdString()); + handler3D->active_slice(), + (short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, + extractChannels, weights, + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value(), + ui.mCenterFilenameLineEdit->text().toStdString()); else handler3D->get_activebmphandler()->kmeans_png( - (short)ui.mKMeansNrTissuesSpinBox->value(), - (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, - extractChannels, handler3D->active_slice(), - weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), - (unsigned int)ui.mKMeansConvergeSpinBox->value(), - ui.mCenterFilenameLineEdit->text().toStdString()); + (short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, + extractChannels, handler3D->active_slice(), + weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value(), + ui.mCenterFilenameLineEdit->text().toStdString()); } else { if (ui.mAllSlicesCheckBox->isChecked()) handler3D->kmeans_mhd( - handler3D->active_slice(), - (short)ui.mKMeansNrTissuesSpinBox->value(), - (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, weights, - (unsigned int)ui.mKMeansIterationsSpinBox->value(), - (unsigned int)ui.mKMeansConvergeSpinBox->value()); + handler3D->active_slice(), + (short)ui.mKMeansNrTissuesSpinBox->value(), + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, weights, + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); else handler3D->get_activebmphandler()->kmeans_mhd((short)ui.mKMeansNrTissuesSpinBox->value(), - (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, - handler3D->active_slice(), - weights, - (unsigned int)ui.mKMeansIterationsSpinBox->value(), - (unsigned int)ui.mKMeansConvergeSpinBox->value()); + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, + handler3D->active_slice(), + weights, + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); } } else { if (ui.mAllSlicesCheckBox->isChecked()) handler3D->kmeans_mhd( - handler3D->active_slice(), - (short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), - kmeansfiles, weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), - (unsigned int)ui.mKMeansConvergeSpinBox->value()); + handler3D->active_slice(), + (short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), + kmeansfiles, weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); else handler3D->get_activebmphandler()->kmeans_mhd((short)ui.mKMeansNrTissuesSpinBox->value(), - (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, - handler3D->active_slice(), weights, - (unsigned int)ui.mKMeansIterationsSpinBox->value(), - (unsigned int)ui.mKMeansConvergeSpinBox->value()); + (short)ui.mKMeansDimsSpinBox->value(), kmeansfiles, + handler3D->active_slice(), weights, + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); } } } @@ -607,13 +686,13 @@ void ThresholdWidgetQt4::on_mExecutePushButton_clicked() if (ui.mAllSlicesCheckBox->isChecked()) handler3D->em(handler3D->active_slice(), - (short)ui.mKMeansNrTissuesSpinBox->value(), - (unsigned int)ui.mKMeansIterationsSpinBox->value(), - (unsigned int)ui.mKMeansConvergeSpinBox->value()); + (short)ui.mKMeansNrTissuesSpinBox->value(), + (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); else handler3D->get_activebmphandler()->em((short)ui.mKMeansNrTissuesSpinBox->value(), (short)ui.mKMeansDimsSpinBox->value(), - bits, weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), - (unsigned int)ui.mKMeansConvergeSpinBox->value()); + bits, weights, (unsigned int)ui.mKMeansIterationsSpinBox->value(), + (unsigned int)ui.mKMeansConvergeSpinBox->value()); } emit end_datachange(this); @@ -634,87 +713,6 @@ void ThresholdWidgetQt4::on_slicenr_changed() init(); } -void ThresholdWidgetQt4::initUi() -{ - ui.setupUi(this); - - threshs[0] = float(ui.mManualNrTissuesSpinBox->value() - 1); - for (unsigned i = 0; i < 20; ++i) - { - bits1[i] = 0; - threshs[i + 1] = 255; - weights[i] = 1.0f; - } - - - auto mode_signal_mapping = new QSignalMapper(this); - mode_signal_mapping->setMapping(ui.mManualModeRadioButton, ui.mManualWidget); - mode_signal_mapping->setMapping(ui.mHistoModeRadioButton, ui.mHistoWidget); - mode_signal_mapping->setMapping(ui.mKMeansRadioButton, ui.mKmeansEMWidget); - mode_signal_mapping->setMapping(ui.mEMModeRadioButton, ui.mKmeansEMWidget); - QObject::connect(ui.mManualModeRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); - QObject::connect(ui.mHistoModeRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); - QObject::connect(ui.mKMeansRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); - QObject::connect(ui.mEMModeRadioButton, SIGNAL(clicked()), mode_signal_mapping, SLOT(map())); - QObject::connect(mode_signal_mapping, SIGNAL(mapped(QWidget*)), ui.mModeStackedWidget, SLOT(setCurrentWidget(QWidget*))); - - // init with manual mode - ui.mManualModeRadioButton->setChecked(true); - ui.mModeStackedWidget->setCurrentWidget(ui.mManualWidget); -} - -void ThresholdWidgetQt4::updateUi() -{ - auto range = get_range(); - // manual - ui.mLoadBordersPushButton->setDisabled(hideparams); - ui.mSaveBordersPushButton->setDisabled(hideparams); - ui.mThresholdLowerLabel->setText(QString::number(range.first, 'g', 3)); - ui.mThresholdUpperLabel->setText(QString::number(range.second, 'g', 3)); - if (range.second != range.first) { - const int slider_value = static_cast((threshs[ui.mManualLimitNrSpinBox->value()] - range.first) * 200 / - (range.second - range.first) + .5f); - ui.mThresholdHorizontalSlider->setValue(slider_value); - ui.mThresholdBorderLineEdit->setText(QString::number(threshs[ui.mManualLimitNrSpinBox->value()], 'g', 3)); - } - - //ui.mWeightBorderLineEdit->setText(QString::number(threshs[sb_tissuenr->value()], 'g', 3)); - ui.mManualLimitNrLabel->setEnabled(ui.mManualNrTissuesSpinBox->value() != 2); - ui.mManualLimitNrSpinBox->setEnabled(ui.mManualNrTissuesSpinBox->value() != 2); - - // histo - ui.mSubsectionGroupBox->setDisabled(hideparams); - ui.mMinPixelsFrame->setDisabled(hideparams); - - // kmeans - ui.mKMeansDimsLabel->setDisabled(hideparams); - ui.mKMeansDimsSpinBox->setDisabled(hideparams); - ui.mKMeansImageNrLabel->setEnabled(ui.mKMeansDimsSpinBox->value() != 2); - ui.mKMeansImageNrSpinBox->setEnabled(ui.mKMeansDimsSpinBox->value() != 2); - ui.mKMeansIterationsFrame->setDisabled(hideparams); - ui.mKMeansWeightLabel->setEnabled(ui.mKMeansDimsSpinBox->value() != 2); - ui.mKMeansWeightHorizontalSlider->setEnabled(ui.mKMeansDimsSpinBox->value() != 2); - ui.mKMeansWeightHorizontalSlider->setValue(int(200 * weights[ui.mKMeansImageNrSpinBox->value() - 1])); - ui.mKMeansFilenameFrame->setEnabled(ui.mKMeansImageNrSpinBox->value() > 1); - ui.mKMeansFilenameLineEdit->setText(ui.mKMeansImageNrSpinBox->value() > 1 ? filenames[ui.mKMeansImageNrSpinBox->value() - 2] : ""); - - // general - ui.mCenterFilenameLineEdit->setEnabled(ui.mUseCenterFileCheckBox->isChecked()); - ui.mSelectCenterFilenamePushButton->setEnabled(ui.mUseCenterFileCheckBox->isChecked()); -} - -std::pair ThresholdWidgetQt4::get_range() const -{ - std::pair range(0.0f, 0.0f); - if (handler3D->get_activebmphandler()) { - Pair p; - handler3D->get_activebmphandler()->get_bmprange(&p); - range.first = p.low; - range.second = p.high; - } - return range; -} - void ThresholdWidgetQt4::resetThresholds() { auto range = get_range(); @@ -731,9 +729,9 @@ void ThresholdWidgetQt4::RGBA_changed() { // amazing code here... int buttonsChecked = ui.mKMeansRRadioButton->isChecked() + ui.mKMeansGRadioButton->isChecked() + - ui.mKMeansBRadioButton->isChecked() + ui.mKMeansARadioButton->isChecked(); + ui.mKMeansBRadioButton->isChecked() + ui.mKMeansARadioButton->isChecked(); ui.mKMeansDimsSpinBox->setValue(buttonsChecked + 1); if (buttonsChecked > 0) ui.mKMeansImageNrSpinBox->setValue(2); -} \ No newline at end of file +} From 8fa26bbdc72274d9b5ccc91a129e878b49c47769 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Thu, 14 Mar 2019 21:00:04 +0100 Subject: [PATCH 26/26] cleanup add message after cleanup --- iSeg/Levelset.cpp | 6 ------ iSeg/MainWindow.cpp | 7 ++++++- iSeg/bmp_read_1.cpp | 29 ++++++++--------------------- 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/iSeg/Levelset.cpp b/iSeg/Levelset.cpp index 27dd59a5..130ac8f0 100755 --- a/iSeg/Levelset.cpp +++ b/iSeg/Levelset.cpp @@ -389,9 +389,6 @@ void Levelset::return_zerolevelset(vector>* v1, vector>* v2, int minsize) { image->swap_bmpwork(); - // image->swap_workhelp(); - // image->set_bmp(levset); - // image->copy2bmp(levset); float thresh[2]; thresh[0] = 1; @@ -403,9 +400,6 @@ void Levelset::return_zerolevelset(vector>* v1, image->get_contours(255.0f, v1, v2, minsize); image->swap_bmpwork(); - // image->swap_workhelp(); - - return; } Levelset::~Levelset() diff --git a/iSeg/MainWindow.cpp b/iSeg/MainWindow.cpp index e3795c64..0f4a079a 100755 --- a/iSeg/MainWindow.cpp +++ b/iSeg/MainWindow.cpp @@ -7672,7 +7672,12 @@ void MainWindow::execute_voting_replace_labels() auto remaining_voxels = VotingReplaceLabel(handler3D, FG, 0, radius, 1, 10); if (remaining_voxels != 0) { - VotingReplaceLabel(handler3D, FG, 0, radius, 0, 1); + remaining_voxels = VotingReplaceLabel(handler3D, FG, 0, radius, 0, 1); + } + + if (remaining_voxels != 0) + { + ISEG_INFO("Remaining voxels after relabeling: " << remaining_voxels); } emit end_datachange(this, iseg::EndUndo); diff --git a/iSeg/bmp_read_1.cpp b/iSeg/bmp_read_1.cpp index 27e3de0e..837ac0a6 100755 --- a/iSeg/bmp_read_1.cpp +++ b/iSeg/bmp_read_1.cpp @@ -9511,8 +9511,7 @@ void bmphandler::get_contours(float f, std::vector>* outer_li float linelength; short directionchange; - float* tmp_bits = - (float*)malloc(sizeof(float) * (width + 2) * (height + 2)); + float* tmp_bits = (float*)malloc(sizeof(float) * (width + 2) * (height + 2)); bool* visited = (bool*)malloc(sizeof(bool) * (width + 2) * (height + 2)); for (unsigned i = 0; i < unsigned(width + 2) * (height + 2); i++) visited[i] = false; @@ -9659,11 +9658,7 @@ void bmphandler::get_contours(float f, std::vector>* outer_li done = true; } } - // while(pos1!=pos||(inner==1&&pos2!=possecond)); while (pos1 != pos || pos2 != possecond); - // while(pos1!=pos||(inner==1&&!visited[pos2])); - // while(pos1!=pos); - // vec_pt.pop_back(); if (inner == 1) { @@ -10397,7 +10392,6 @@ unsigned* bmphandler::dead_reckoning_squared(float f) } std::vector> vo, vi; - std::vector::iterator vuit; std::vector::iterator vpit; swap_bmpwork(); @@ -10411,7 +10405,6 @@ unsigned* bmphandler::dead_reckoning_squared(float f) work_bits[pt2coord(*vpit)] = 0; P[pt2coord(*vpit)] = pt2coord(*vpit); } - // cout << ";"<begin()), &limit1); - - it = newline->end(); - it--; - IFTdist.return_path(*it, &limit2); + // BL here I think we get closest connection from start/end point + // to contour of selected tissue 'f'. + IFTdist.return_path(newline->front(), &limit1); + IFTdist.return_path(newline->back(), &limit2); int counter1, counter2; - Point p1, p2; - it = limit1.end(); - it--; - p1 = *it; - it = limit2.end(); - it--; - p2 = *it; + Point p1 = limit1.back(); + Point p2 = limit2.back(); bool found = false; vvPit = vvPouter.begin(); @@ -14068,6 +14054,7 @@ void bmphandler::correct_outlinetissue(tissuelayers_size_t idx, } } + // copy temporary 'work' image to tissues for (unsigned ineu = 0; ineu < area; ineu++) tissues[ineu] = (tissues_size_t)(work_bits[ineu] + 0.1f);