Skip to content

Commit

Permalink
Cherry pick pull request #18875
Browse files Browse the repository at this point in the history
Refs #18869 Fix U correction view rect

(cherry picked from commit 25d21c2)

Refs #18869 Fix code formatting

This code is badly indented. While we're herewe should fix it

(cherry picked from commit 9fff85c)

Revert "Refs #18869 Fix code formatting"

This reverts commit 9fff85c.

(cherry picked from commit 0deffd9)

Refs #18869 Fix blank view with no U correction

(cherry picked from commit 9667cea)

Add patch release note
  • Loading branch information
samueljackson92 authored and martyngigg committed Feb 23, 2017
1 parent 9078e19 commit 2cd3b15
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 20 deletions.
Expand Up @@ -46,6 +46,11 @@ class RotationSurface : public UnwrappedSurface {
/// UnwrappedSurface::project().
double applyUCorrection(double u) const;

/// Update the view rect to offset for the U correction
void updateViewRectForUCorrection();
/// Calculate UV offsets from the view rect
std::pair<double, double> calculateViewRectOffsets();

const Mantid::Kernel::V3D m_pos; ///< Origin (sample position)
const Mantid::Kernel::V3D
m_zaxis; ///< The z axis of the surface specific coord system
Expand Down
55 changes: 37 additions & 18 deletions MantidQt/MantidWidgets/src/InstrumentView/RotationSurface.cpp
Expand Up @@ -162,26 +162,43 @@ void RotationSurface::init() {
udet.u = applyUCorrection(udet.u);
}
}
updateViewRectForUCorrection();
}

double dU = fabs(m_u_max - m_u_min);
double dV = fabs(m_v_max - m_v_min);
double du = dU * 0.05;
double dv = dV * 0.05;
if (m_width_max > du && std::isfinite(m_width_max)) {
if (du > 0 && !(dU >= m_width_max)) {
m_width_max = dU;
}
du = m_width_max;
}
if (m_height_max > dv && std::isfinite(m_height_max)) {
if (dv > 0 && !(dV >= m_height_max)) {
m_height_max = dV;
}
dv = m_height_max;
}
/** Update the view rect to account for the U correction
*/
void RotationSurface::updateViewRectForUCorrection() {
const auto offsets = calculateViewRectOffsets();
const auto min = QPointF(m_u_min - offsets.first, m_v_min - offsets.second);
const auto max = QPointF(m_u_max + offsets.first, m_v_max + offsets.second);
m_viewRect = RectF(min, max);
}

/** Calculate UV offsets to the view rect
*
* @return a std::pair containing the u & v offsets for the view rect
*/
std::pair<double, double> RotationSurface::calculateViewRectOffsets() {
const auto dU = fabs(m_u_max - m_u_min);
const auto dV = fabs(m_v_max - m_v_min);
auto du = dU * 0.05;
auto dv = dV * 0.05;

if (m_width_max > du && std::isfinite(m_width_max)) {
if (du > 0 && !(dU >= m_width_max)) {
m_width_max = dU;
}
du = m_width_max;
}

if (m_height_max > dv && std::isfinite(m_height_max)) {
if (dv > 0 && !(dV >= m_height_max)) {
m_height_max = dV;
}
dv = m_height_max;
}

m_viewRect = RectF(QPointF(m_u_min - du, m_v_min - dv),
QPointF(m_u_max + du, m_v_max + dv));
return std::make_pair(du, dv);
}

void RotationSurface::findUVBounds() {
Expand Down Expand Up @@ -308,6 +325,7 @@ void RotationSurface::setUCorrection(double umin, double umax) {
}
m_manual_u_correction = true;
updateDetectors();
updateViewRectForUCorrection();
}

/**
Expand All @@ -316,6 +334,7 @@ void RotationSurface::setUCorrection(double umin, double umax) {
void RotationSurface::setAutomaticUCorrection() {
m_manual_u_correction = false;
updateDetectors();
updateViewRectForUCorrection();
}

} // MantidWidgets
Expand Down
9 changes: 7 additions & 2 deletions docs/source/release/v3.9.1/index.rst
Expand Up @@ -26,12 +26,13 @@ Changes in this version

* `18833 <https://www.github.com/mantidproject/mantid/pull/18833>`_ Added check for if nonorthogonal axes should be displayed
* `18865 <https://www.github.com/mantidproject/mantid/pull/18865>`_ Fix bug in reflectometry GUI
* `18875 <https://www.github.com/mantidproject/mantid/pull/18875>`_ U correction not correctly applied to viewport
* `18891 <https://www.github.com/mantidproject/mantid/pull/18891>`_ Fix bug in gd_prtn_chrg for chunked data
* `18907 <https://www.github.com/mantidproject/mantid/pull/18907>`_ Fix zeropadding for IMAT in Facilities.XML
* `18914 <https://www.github.com/mantidproject/mantid/pull/18914>`_ Fix mass ws deletion bug
* `18915 <https://www.github.com/mantidproject/mantid/pull/18915>`_ Add missing parameter in function call in performance test
* `18926 <https://www.github.com/mantidproject/mantid/pull/18926>`_ Fix wrong detector selection when loading high angle bank user files in ISIS SANS

* `18959 <https://www.github.com/mantidproject/mantid/pull/18959>`_ Blank instrument view with U correction

Summary of impact
-----------------
Expand All @@ -44,6 +45,8 @@ Summary of impact
+-------+-----------------------------------------------------------------------------------+---------------------------------------------+--------------+
| 18865 | Correct behaviour when no transmission run is provided | Add check if runs are provided | **low** |
+-------+-----------------------------------------------------------------------------------+---------------------------------------------+--------------+
| 18875 | Displays all of instrument when U correction applied | Apply U correction in appropriate all places| **medium** |
+-------+-----------------------------------------------------------------------------------+---------------------------------------------+--------------+
| 18891 | Fixes bug in gd_prtn_chrg for chunked data | Recalculate proton charge just prior to use | **low** |
+-------+-----------------------------------------------------------------------------------+---------------------------------------------+--------------+
| 18907 | Allows IMAT to use general file finding mechanism | Facilities file update | **low** |
Expand All @@ -52,7 +55,9 @@ Summary of impact
+-------+-----------------------------------------------------------------------------------+---------------------------------------------+--------------+
| 18915 | Fixes test builds | Fix function calls | **low** |
+-------+-----------------------------------------------------------------------------------+---------------------------------------------+--------------+
| 18926 | Enables ISIS SANS to select the correct bank of the detector | Fix interpreation of list indices in GUI | **low** |
| 18926 | Enables ISIS SANS to select the correct bank of the detector | Fix interpretation of list indices in GUI | **low** |
+-------+-----------------------------------------------------------------------------------+---------------------------------------------+--------------+
| 18959 | Fixes blank view when U correction applied | Fix missing call after #18875 | **medium** |
+-------+-----------------------------------------------------------------------------------+---------------------------------------------+--------------+


Expand Down

0 comments on commit 2cd3b15

Please sign in to comment.