|
13 | 13 | #include "vc/core/util/Iteration.hpp" |
14 | 14 | #include "vc/core/util/Logging.hpp" |
15 | 15 | #include "vc/meshing/OrderedPointSetMesher.hpp" |
| 16 | +#include "vc/segmentation/LocalResliceParticleSim.hpp" |
16 | 17 |
|
17 | 18 | namespace vc = volcart; |
| 19 | +namespace vcs = volcart::segmentation; |
18 | 20 | using namespace ChaoVis; |
19 | 21 | using qga = QGuiApplication; |
20 | 22 |
|
@@ -216,10 +218,17 @@ void CWindow::CreateWidgets(void) |
216 | 218 | SLOT(OnPathItemClicked(QListWidgetItem*))); |
217 | 219 |
|
218 | 220 | // segmentation methods |
219 | | - QComboBox* aSegMethodsComboBox = |
220 | | - this->findChild<QComboBox*>("cmbSegMethods"); |
| 221 | + auto* aSegMethodsComboBox = this->findChild<QComboBox*>("cmbSegMethods"); |
221 | 222 | aSegMethodsComboBox->addItem(tr("Local Reslice Particle Simulation")); |
| 223 | + connect( |
| 224 | + aSegMethodsComboBox, SIGNAL(currentIndexChanged(int)), this, |
| 225 | + SLOT(OnChangeSegAlgo(int))); |
| 226 | + |
| 227 | + // ADD NEW SEGMENTATION ALGORITHM NAMES HERE |
| 228 | + // aSegMethodsComboBox->addItem(tr("My custom algorithm")); |
222 | 229 |
|
| 230 | + // LRPS segmentation parameters |
| 231 | + // all of these are contained in the this->ui.lrpsParams |
223 | 232 | fEdtAlpha = this->findChild<QLineEdit*>("edtAlphaVal"); |
224 | 233 | fEdtBeta = this->findChild<QLineEdit*>("edtBetaVal"); |
225 | 234 | fEdtDelta = this->findChild<QLineEdit*>("edtDeltaVal"); |
@@ -259,6 +268,9 @@ void CWindow::CreateWidgets(void) |
259 | 268 | fEdtEndIndex, SIGNAL(editingFinished()), this, |
260 | 269 | SLOT(OnEdtEndingSliceValChange())); |
261 | 270 |
|
| 271 | + // INSERT OTHER SEGMENTATION PARAMETER WIDGETS HERE |
| 272 | + // this->ui.segParamsStack->addWidget(new QLabel("Parameter widgets here")); |
| 273 | + |
262 | 274 | // start segmentation button |
263 | 275 | QPushButton* aBtnStartSeg = this->findChild<QPushButton*>("btnStartSeg"); |
264 | 276 | connect( |
@@ -570,29 +582,39 @@ void CWindow::DoSegmentation(void) |
570 | 582 | { |
571 | 583 | statusBar->clearMessage(); |
572 | 584 |
|
573 | | - // REVISIT - do we need to get the latest value from the widgets since we |
574 | | - // constantly get the values? |
575 | | - if (!SetUpSegParams()) { |
| 585 | + // Make sure our seg params structure has the current values |
| 586 | + if (not SetUpSegParams()) { |
576 | 587 | QMessageBox::information( |
577 | 588 | this, tr("Info"), tr("Invalid parameter for segmentation")); |
578 | 589 | return; |
579 | 590 | } |
580 | 591 |
|
581 | | - // 2) do segmentation from the starting slice |
582 | | - vc::segmentation::LocalResliceSegmentation segmenter; |
583 | | - segmenter.setChain(fStartingPath); |
584 | | - segmenter.setVolume(currentVolume); |
585 | | - segmenter.setMaterialThickness(fVpkg->materialThickness()); |
586 | | - segmenter.setTargetZIndex(fSegParams.targetIndex); |
587 | | - segmenter.setOptimizationIterations(fSegParams.fNumIters); |
588 | | - segmenter.setResliceSize(fSegParams.fWindowWidth); |
589 | | - segmenter.setAlpha(fSegParams.fAlpha); |
590 | | - segmenter.setK1(fSegParams.fK1); |
591 | | - segmenter.setK2(fSegParams.fK2); |
592 | | - segmenter.setBeta(fSegParams.fBeta); |
593 | | - segmenter.setDelta(fSegParams.fDelta); |
594 | | - segmenter.setDistanceWeightFactor(fSegParams.fPeakDistanceWeight); |
595 | | - segmenter.setConsiderPrevious(fSegParams.fIncludeMiddle); |
| 592 | + // Setup LRPS |
| 593 | + auto segIdx = this->ui.cmbSegMethods->currentIndex(); |
| 594 | + Segmenter::Pointer segmenter; |
| 595 | + if (segIdx == 0) { |
| 596 | + auto lrps = vcs::LocalResliceSegmentation::New(); |
| 597 | + lrps->setMaterialThickness(fVpkg->materialThickness()); |
| 598 | + lrps->setTargetZIndex(fSegParams.targetIndex); |
| 599 | + lrps->setOptimizationIterations(fSegParams.fNumIters); |
| 600 | + lrps->setResliceSize(fSegParams.fWindowWidth); |
| 601 | + lrps->setAlpha(fSegParams.fAlpha); |
| 602 | + lrps->setK1(fSegParams.fK1); |
| 603 | + lrps->setK2(fSegParams.fK2); |
| 604 | + lrps->setBeta(fSegParams.fBeta); |
| 605 | + lrps->setDelta(fSegParams.fDelta); |
| 606 | + lrps->setDistanceWeightFactor(fSegParams.fPeakDistanceWeight); |
| 607 | + lrps->setConsiderPrevious(fSegParams.fIncludeMiddle); |
| 608 | + segmenter = lrps; |
| 609 | + } |
| 610 | + // ADD OTHER SEGMENTER SETUP HERE. MATCH THE IDX TO THE IDX IN THE |
| 611 | + // DROPDOWN LIST |
| 612 | + |
| 613 | + // set common parameters |
| 614 | + segmenter->setChain(fStartingPath); |
| 615 | + segmenter->setVolume(currentVolume); |
| 616 | + |
| 617 | + // setup |
596 | 618 | submitSegmentation(segmenter); |
597 | 619 | setWidgetsEnabled(false); |
598 | 620 | worker_progress_.show(); |
@@ -1036,6 +1058,11 @@ void CWindow::ToggleSegmentationTool(void) |
1036 | 1058 | UpdateView(); |
1037 | 1059 | } |
1038 | 1060 |
|
| 1061 | +void CWindow::OnChangeSegAlgo(int index) |
| 1062 | +{ |
| 1063 | + this->ui.segParamsStack->setCurrentIndex(index); |
| 1064 | +} |
| 1065 | + |
1039 | 1066 | // Handle gravity value change |
1040 | 1067 | void CWindow::OnEdtAlphaValChange() |
1041 | 1068 | { |
|
0 commit comments