From daeb81acb18fa914bfde00ac45d205cf00053871 Mon Sep 17 00:00:00 2001 From: Owen Arnold <owen.arnold@stfc.ac.uk> Date: Tue, 12 May 2015 10:48:22 +0100 Subject: [PATCH] refs #11741. Norm dropdown. --- .../inc/MantidQtSliceViewer/SliceViewer.h | 5 ++ .../inc/MantidQtSliceViewer/SliceViewer.ui | 88 +++++++++++++++++-- .../MantidQt/SliceViewer/src/SliceViewer.cpp | 45 +++++++++- 3 files changed, 128 insertions(+), 10 deletions(-) diff --git a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h index 44d1de62fe2..471dde7ae27 100644 --- a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h +++ b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h @@ -178,6 +178,7 @@ public slots: void changeNormalizationNone(); void changeNormalizationVolume(); void changeNormalizationNumEvents(); + void onNormalizationChanged(const QString& normalizationKey); // Buttons or actions void clearLine(); @@ -354,6 +355,10 @@ private: /// Object for choosing a PeakTransformFactory based on the workspace type. Mantid::API::PeakTransformSelector m_peakTransformSelector; + static const QString NoNormalizationKey; + static const QString VolumeNormalizationKey; + static const QString NumEventsNormalizationKey; + }; } // namespace SliceViewer diff --git a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.ui b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.ui index 2101640e5e8..3958ba8a8c3 100644 --- a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.ui +++ b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.ui @@ -17,7 +17,16 @@ <property name="spacing"> <number>3</number> </property> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item> @@ -53,7 +62,16 @@ <property name="sizeConstraint"> <enum>QLayout::SetMinimumSize</enum> </property> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> </layout> @@ -69,7 +87,16 @@ <property name="spacing"> <number>2</number> </property> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item> @@ -585,10 +612,13 @@ </widget> </item> <item> - <spacer name="horizontalSpacer"> + <spacer name="horizontalSpacer_6"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> <property name="sizeHint" stdset="0"> <size> <width>40</width> @@ -605,6 +635,9 @@ <property name="fieldGrowthPolicy"> <enum>QFormLayout::FieldsStayAtSizeHint</enum> </property> + <property name="verticalSpacing"> + <number>0</number> + </property> <item row="0" column="0"> <widget class="QLabel" name="label"> <property name="text"> @@ -683,8 +716,11 @@ </item> <item row="2" column="0"> <widget class="QLabel" name="label_3"> + <property name="toolTip"> + <string/> + </property> <property name="text"> - <string>z=</string> + <string>Intensity=</string> </property> </widget> </item> @@ -719,6 +755,37 @@ </property> </widget> </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Norm=</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QComboBox" name="comboNormalization"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>80</width> + <height>0</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>13</pointsize> + </font> + </property> + <property name="toolTip"> + <string>Normalization option</string> + </property> + </widget> + </item> </layout> </item> </layout> @@ -736,7 +803,16 @@ <property name="spacing"> <number>4</number> </property> - <property name="margin"> + <property name="leftMargin"> + <number>2</number> + </property> + <property name="topMargin"> + <number>2</number> + </property> + <property name="rightMargin"> + <number>2</number> + </property> + <property name="bottomMargin"> <number>2</number> </property> <item> diff --git a/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp b/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp index 21ac4ff3106..a84838533c9 100644 --- a/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp +++ b/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp @@ -68,6 +68,10 @@ using MantidQt::API::AlgorithmRunner; namespace MantidQt { namespace SliceViewer { +const QString SliceViewer::NoNormalizationKey = "No"; +const QString SliceViewer::VolumeNormalizationKey = "Volume"; +const QString SliceViewer::NumEventsNormalizationKey = "# Events"; + //------------------------------------------------------------------------------ /** Constructor */ SliceViewer::SliceViewer(QWidget *parent) @@ -135,6 +139,7 @@ SliceViewer::SliceViewer(QWidget *parent) SLOT(autoRebin_toggled(bool))); QObject::connect(ui.btnPeakOverlay, SIGNAL(clicked()), this, SLOT(peakOverlay_clicked())); + // ----------- Other signals ---------------- QObject::connect(m_colorBar, SIGNAL(colorBarDoubleClicked()), this, SLOT(loadColorMapSlot())); @@ -222,7 +227,7 @@ void SliceViewer::saveSettings() { settings.setValue("TransparentZeros", (m_actionTransparentZeros->isChecked() ? 1 : 0)); settings.setValue("Normalization", - static_cast<int>(this->getNormalization())); + static_cast<int>(this->getNormalization())); settings.endGroup(); } @@ -336,14 +341,15 @@ void SliceViewer::initMenus() { QActionGroup *group = new QActionGroup(this); - action = new QAction(QPixmap(), "No Normalization", this); + const QString normalization = " Normalization"; + action = new QAction(QPixmap(), SliceViewer::NoNormalizationKey + normalization, this); m_menuView->addAction(action); action->setActionGroup(group); action->setCheckable(true); connect(action, SIGNAL(triggered()), this, SLOT(changeNormalizationNone())); m_actionNormalizeNone = action; - action = new QAction(QPixmap(), "Volume Normalization", this); + action = new QAction(QPixmap(), SliceViewer::VolumeNormalizationKey + normalization, this); m_menuView->addAction(action); action->setActionGroup(group); action->setCheckable(true); @@ -351,7 +357,7 @@ void SliceViewer::initMenus() { connect(action, SIGNAL(triggered()), this, SLOT(changeNormalizationVolume())); m_actionNormalizeVolume = action; - action = new QAction(QPixmap(), "Num. Events Normalization", this); + action = new QAction(QPixmap(), SliceViewer::NumEventsNormalizationKey + normalization, this); m_menuView->addAction(action); action->setActionGroup(group); action->setCheckable(true); @@ -359,6 +365,12 @@ void SliceViewer::initMenus() { SLOT(changeNormalizationNumEvents())); m_actionNormalizeNumEvents = action; + ui.comboNormalization->addItem(SliceViewer::NoNormalizationKey); + ui.comboNormalization->addItem(SliceViewer::VolumeNormalizationKey); + ui.comboNormalization->addItem(SliceViewer::NumEventsNormalizationKey); + + connect(this->ui.comboNormalization, SIGNAL(currentIndexChanged(const QString&)), SLOT(onNormalizationChanged(const QString&))); + // --------------- Color options Menu ---------------------------------------- m_menuColorOptions = new QMenu("&ColorMap", this); @@ -789,6 +801,20 @@ void SliceViewer::changeNormalizationNumEvents() { this->setNormalization(Mantid::API::NumEventsNormalization, true); } +/** + * @brief Slot to handle change in normalization kicked-off from the combo box. + * @param normalizationKey : Text key for type of normalization switched to. + */ +void SliceViewer::onNormalizationChanged(const QString& normalizationKey) { + if (normalizationKey == SliceViewer::NoNormalizationKey) { + changeNormalizationNone(); + } else if (normalizationKey == SliceViewer::VolumeNormalizationKey) { + changeNormalizationVolume(); + } else { + changeNormalizationNumEvents(); + } +} + //------------------------------------------------------------------------------ /** Set the normalization mode for viewing the data * @@ -811,6 +837,17 @@ void SliceViewer::setNormalization(Mantid::API::MDNormalization norm, m_actionNormalizeVolume->blockSignals(false); m_actionNormalizeNumEvents->blockSignals(false); + // Sync the normalization combobox. + this->ui.comboNormalization->setEnabled(false); // Avoid firing signals + if(norm == Mantid::API::NoNormalization) { + this->ui.comboNormalization->setCurrentIndex(0); + } else if (norm == Mantid::API::VolumeNormalization) { + this->ui.comboNormalization->setCurrentItem(1); + } else { + this->ui.comboNormalization->setCurrentIndex(2); + } + this->ui.comboNormalization->setEnabled(true); + m_data->setNormalization(norm); if (update) this->updateDisplay(); -- GitLab