Commit b2c76c86 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Tidy code and fix minor issues

parent 2c0cdeb5
......@@ -160,7 +160,7 @@ public:
void addTab(const std::string &tabName);
void hideHelp();
InstrumentWidgetPickTab *getPickTab() { return m_pickTab; };
bool isIntegrable() const { return m_shouldIntegrate; }
bool isIntegrable() const { return m_isIntegrable; }
signals:
void enableLighting(bool /*_t1*/);
......@@ -315,7 +315,7 @@ protected:
std::vector<std::pair<std::string, bool>> m_stateOfTabs;
/// Is the workspace monochromatic ?
bool m_shouldIntegrate;
bool m_isIntegrable;
private:
/// ADS notification handlers
......
......@@ -147,7 +147,7 @@ public:
/// Save settings for the projection surface to a project file
virtual std::string saveToProject() const;
void setCurrentTab(int currentTab) { m_currentTab = currentTab; }
void setCurrentTab(QString currentTab) { m_currentTab = currentTab; }
//-----------------------------------
// Mask methods
......@@ -390,7 +390,7 @@ private:
/// Set when the picking image must be redrawn regardless of the interaction
/// mode
mutable bool m_redrawPicking;
int m_currentTab;
QString m_currentTab;
friend class InstrumentWidgetEncoder;
friend class InstrumentWidgetDecoder;
......
......@@ -159,14 +159,14 @@ InstrumentWidget::InstrumentWidget(const QString &wsName, QWidget *parent,
try {
size_t blockSize = m_instrumentActor->getWorkspace()->blocksize();
m_shouldIntegrate =
m_isIntegrable =
(blockSize > 1 ||
m_instrumentActor->getWorkspace()->id() == "EventWorkspace");
} catch (...) {
m_shouldIntegrate = true;
m_isIntegrable = true;
}
if (m_shouldIntegrate) {
if (m_isIntegrable) {
m_xIntegration = new XIntegrationControl(this);
mainLayout->addWidget(m_xIntegration);
connect(m_xIntegration, SIGNAL(changed(double, double)), this,
......@@ -306,7 +306,7 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling,
new InstrumentActor(m_workspaceName, autoscaling, scaleMin, scaleMax));
}
if (m_shouldIntegrate) {
if (m_isIntegrable) {
m_xIntegration->setTotalRange(m_instrumentActor->minBinValue(),
m_instrumentActor->maxBinValue());
m_xIntegration->setUnits(QString::fromStdString(
......@@ -356,7 +356,7 @@ void InstrumentWidget::resetSurface() {
* Select the tab to be displayed
*/
void InstrumentWidget::selectTab(int tab) {
getSurface()->setCurrentTab(tab);
getSurface()->setCurrentTab(mControlsTab->tabText(tab));
mControlsTab->setCurrentIndex(tab);
}
......@@ -581,7 +581,7 @@ void InstrumentWidget::tabChanged(int /*unused*/) {
updateInfoText();
auto surface = getSurface();
if (surface) {
surface->setCurrentTab(getCurrentTab());
surface->setCurrentTab(mControlsTab->tabText(getCurrentTab()));
}
}
......@@ -894,7 +894,7 @@ void InstrumentWidget::setIntegrationRange(double xmin, double xmax) {
* python.
*/
void InstrumentWidget::setBinRange(double xmin, double xmax) {
if (m_shouldIntegrate) {
if (m_isIntegrable) {
m_xIntegration->setRange(xmin, xmax);
}
}
......@@ -1266,7 +1266,7 @@ void InstrumentWidget::createTabs(QSettings &settings) {
this, SLOT(executeAlgorithm(const QString &, const QString &)));
m_maskTab->loadSettings(settings);
if (m_shouldIntegrate) {
if (m_isIntegrable) {
connect(m_xIntegration, SIGNAL(changed(double, double)), m_maskTab,
SLOT(changedIntegrationRange(double, double)));
}
......
......@@ -529,7 +529,7 @@ void InstrumentWidgetMaskTab::setActivity() {
* Can be used either to mask the picked pixel or its parent.
*/
void InstrumentWidgetMaskTab::singlePixelPicked(size_t pickID) {
auto &actor = m_instrWidget->getInstrumentActor();
const auto &actor = m_instrWidget->getInstrumentActor();
const auto &componentInfo = actor.componentInfo();
if (!componentInfo.isDetector(pickID)) {
return;
......@@ -548,6 +548,7 @@ void InstrumentWidgetMaskTab::singlePixelPicked(size_t pickID) {
detectorsId = componentInfo.detectorsInSubtree(parent);
}
storeDetectorMask(m_roi_on->isChecked(), detectorsId);
} else if (m_grouping_on->isChecked()) {
if (m_pixel->isChecked()) {
Mantid::detid_t detId = actor.getDetID(pickID);
......@@ -558,8 +559,9 @@ void InstrumentWidgetMaskTab::singlePixelPicked(size_t pickID) {
if (!componentInfo.hasParent(pickID)) {
return;
}
auto parent = componentInfo.parent(pickID);
auto dets = actor.getDetIDs(componentInfo.detectorsInSubtree(parent));
const auto parent = componentInfo.parent(pickID);
const auto dets =
actor.getDetIDs(componentInfo.detectorsInSubtree(parent));
m_detectorsToGroup.clear();
for (auto det : dets)
m_detectorsToGroup.append(det);
......@@ -766,7 +768,6 @@ void InstrumentWidgetMaskTab::applyMaskToView() {
*/
void InstrumentWidgetMaskTab::clearMask() {
clearShapes();
m_instrWidget->getInstrumentActor().clearMasks();
m_instrWidget->updateInstrumentView();
enableApplyButtons();
......@@ -1221,15 +1222,17 @@ InstrumentWidgetMaskTab::addDoubleProperty(const QString &name) const {
void InstrumentWidgetMaskTab::storeDetectorMask(
bool isROI, const std::vector<size_t> &onClickDets) {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
m_pointer->setChecked(true);
setActivity();
m_instrWidget->updateInstrumentView(); // to refresh the pick image
Mantid::API::IMaskWorkspace_sptr wsFresh;
const auto &actor = m_instrWidget->getInstrumentActor();
std::vector<size_t> dets;
// get detectors covered by the shapes
m_instrWidget->getSurface()->getMaskedDetectors(dets);
if (onClickDets.size() == 0) {
// get detectors covered by the shapes
m_instrWidget->getSurface()->getMaskedDetectors(dets);
m_pointer->setChecked(true);
setActivity();
}
dets.insert(dets.end(), onClickDets.begin(), onClickDets.end());
if (!dets.empty()) {
auto wsMask = actor.getMaskWorkspace();
......@@ -1273,8 +1276,10 @@ void InstrumentWidgetMaskTab::storeDetectorMask(
m_instrWidget->updateInstrumentDetectors();
}
}
// remove masking shapes
clearShapes();
if (onClickDets.size() == 0) {
// remove masking shapes
clearShapes();
}
QApplication::restoreOverrideCursor();
}
......
......@@ -849,7 +849,7 @@ void ProjectionSurface::selectMultipleMasks(const QRect &rect) {
*/
void ProjectionSurface::pickComponentAt(int x, int y) {
size_t pickID = getPickID(x, y);
if (m_currentTab == 2) {
if (m_currentTab == "Draw") {
emit singleComponentPickedForMasking(pickID);
} else {
emit singleComponentPicked(pickID);
......
......@@ -178,9 +178,6 @@ void XIntegrationScrollBar::updateMinMax() {
XIntegrationControl::XIntegrationControl(InstrumentWidget *instrWindow)
: QFrame(instrWindow), m_instrWindow(instrWindow), m_totalMinimum(0),
m_totalMaximum(1), m_minimum(0), m_maximum(1) {
// if the integration control panel is hidden, most of the fields should not
// be declared
auto *layout = new QHBoxLayout();
m_minText = new QLineEdit(this);
m_minText->setMaximumWidth(100);
......
Markdown is supported
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