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