Commit 4bc9ad31 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Support ROI tube and pixel

Even if it does probably not make much sense by itself, the ROI option
now behave similarly the pixel and tube picking that it does from the
other buttons.
parent cf3877fe
......@@ -520,6 +520,10 @@ void InstrumentWidgetMaskTab::singlePixelPicked(size_t pickID) {
std::vector<size_t> detectorId{pickID};
m_instrWidget->updateInstrumentView(); // to refresh the pick image
auto wsMask = actor.getMaskWorkspace();
// two cases : either we are on roi mode, or on masking mode
if (m_masking_on->isChecked()) {
// then either we are on single pixel picking mode, on on tube picking mode
if (m_pixel->isChecked()) {
actor.addMaskBinsData(detectorId);
......@@ -546,6 +550,44 @@ void InstrumentWidgetMaskTab::singlePixelPicked(size_t pickID) {
}
}
}
} else if (m_roi_on->isChecked()) {
// first, find the oldest ancestor
auto ancestorID = pickID;
while (componentInfo.hasParent(ancestorID)) {
ancestorID = componentInfo.parent(ancestorID);
}
auto detectorsToMask = componentInfo.detectorsInSubtree(ancestorID);
if (m_pixel->isChecked()) {
// remove the picked pixel from the list of detectors to mask
std::remove(detectorsToMask.begin(), detectorsToMask.end(), pickID);
} else if (m_tube->isChecked()) {
if (!componentInfo.hasParent(pickID)) {
return;
}
auto parent = componentInfo.parent(pickID);
auto detectorsToKeep = componentInfo.detectorsInSubtree(parent);
// remove all the detectors from the picked tube from the list of
// detectors to mask
for (auto toKeep : detectorsToKeep) {
std::remove(detectorsToMask.begin(), detectorsToMask.end(), toKeep);
}
}
// then mask selected detectors
actor.addMaskBinsData(detectorsToMask);
for (auto det : detectorsToMask) {
Mantid::detid_t detId = actor.getDetID(det);
try {
wsMask->setMasked(detId);
} catch (...) {
}
}
}
// update detector colours
m_instrWidget->getInstrumentActor().updateColors();
m_instrWidget->updateInstrumentDetectors();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment