Commit 99a7b1c5 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Add grouping option for pixel and tube

Adds the possibility to select and group individual pixel and tube.
HOWEVER due to these selections being dependent of the detector, contrary
to every other shape used for masking etc, the selection cannot be
printed on screen, as it would require to create a shape that follows
the detector if it is moved and is rendered using the correct
perspective.
Moreover, contrary to what happens with masking and ROIing, there are
two options for grouping, which means the operation cannot be applied
immediatly on click in this case.
Since this means that a) the user should input after doing their selection
and b) this selection cannot be shown to the user on the instrument
view, the compromise solution was to only take into account and store
the last tube or pixel selected for grouping. In other words, the user
can only sum or extract the last pixel / tube they selected.
parent 22024e52
......@@ -154,6 +154,7 @@ protected:
Activity m_activity;
/// True if there is a mask not applied to the data workspace
bool m_hasMaskToApply;
QList<Mantid::detid_t> m_detectorsToGroup;
QRadioButton *m_masking_on;
QRadioButton *m_grouping_on;
......
......@@ -121,13 +121,13 @@ InstrumentWidgetMaskTab::InstrumentWidgetMaskTab(InstrumentWidget *instrWidget)
m_pixel->setCheckable(true);
m_pixel->setAutoExclusive(true);
m_pixel->setIcon(QIcon(":/PickTools/selection-pointer.png"));
m_pixel->setToolTip("Mask a pixel");
m_pixel->setToolTip("Select a pixel");
m_tube = new QPushButton();
m_tube->setCheckable(true);
m_tube->setAutoExclusive(true);
m_tube->setIcon(QIcon(":/PickTools/selection-tube.png"));
m_tube->setToolTip("Mask a tube/bank");
m_tube->setToolTip("Select a tube/bank");
m_ring_ellipse = new QPushButton();
m_ring_ellipse->setCheckable(true);
......@@ -587,6 +587,22 @@ void InstrumentWidgetMaskTab::singlePixelPicked(size_t pickID) {
} catch (...) {
}
}
} else if (m_grouping_on->isChecked()) {
if (m_pixel->isChecked()) {
Mantid::detid_t detId = actor.getDetID(pickID);
m_detectorsToGroup.clear();
m_detectorsToGroup.append(detId);
} else if (m_tube->isChecked()) {
if (!componentInfo.hasParent(pickID)) {
return;
}
auto parent = componentInfo.parent(pickID);
auto dets = actor.getDetIDs(componentInfo.detectorsInSubtree(parent));
m_detectorsToGroup.clear();
for (auto det : dets)
m_detectorsToGroup.append(det);
}
}
// update detector colours
m_instrWidget->getInstrumentActor().updateColors();
......@@ -864,7 +880,10 @@ void InstrumentWidgetMaskTab::extractDetsToWorkspace() {
std::vector<size_t> dets;
m_instrWidget->getSurface()->getMaskedDetectors(dets);
const auto &actor = m_instrWidget->getInstrumentActor();
DetXMLFile mapFile(actor.getDetIDs(dets));
QList<int> detectorIDs = actor.getDetIDs(dets);
if (m_pixel->isChecked() || m_tube->isChecked())
detectorIDs.append(m_detectorsToGroup);
DetXMLFile mapFile(detectorIDs);
std::string fname = mapFile();
if (!fname.empty()) {
std::string workspaceName = m_instrWidget->getWorkspaceName().toStdString();
......@@ -884,8 +903,10 @@ void InstrumentWidgetMaskTab::sumDetsToWorkspace() {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
std::vector<size_t> dets;
m_instrWidget->getSurface()->getMaskedDetectors(dets);
DetXMLFile mapFile(m_instrWidget->getInstrumentActor().getDetIDs(dets),
DetXMLFile::Sum);
QList<int> detectorIDs = m_instrWidget->getInstrumentActor().getDetIDs(dets);
if (m_pixel->isChecked() || m_tube->isChecked())
detectorIDs.append(m_detectorsToGroup);
DetXMLFile mapFile(detectorIDs, DetXMLFile::Sum);
std::string fname = mapFile();
if (!fname.empty()) {
......
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