Skip to content

Commit

Permalink
refs #6767. Fix and unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Apr 4, 2013
1 parent 4514b7b commit 1179322
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace MantidQt
/// Peak background inner radius
const double m_backgroundInnerRadius;
/// Peak background outer radius
const double m_backgroundOuterRadius;
double m_backgroundOuterRadius;
/// Max opacity
const double m_opacityMax;
/// Min opacity
Expand All @@ -108,7 +108,7 @@ namespace MantidQt
/// Cached background inner radius sq.
const double m_backgroundInnerRadiusSQ;
/// Cached background outer radius sq.
const double m_backgroundOuterRadiusSQ;
double m_backgroundOuterRadiusSQ;
/// Flag to indicate that the background radius should be drawn.
bool m_showBackgroundRadius;
/// Inner radius at distance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ namespace MantidQt
m_backgroundOuterRadiusSQ(backgroundOuterRadius*backgroundOuterRadius),
m_showBackgroundRadius(false)
{
//This possibility can arise from IntegratePeaksMD.
if(m_backgroundOuterRadiusSQ <= m_backgroundInnerRadiusSQ)
{
m_backgroundOuterRadius = m_backgroundInnerRadius;
m_backgroundOuterRadiusSQ = m_backgroundInnerRadiusSQ;
}
}

/// Destructor
Expand Down
27 changes: 27 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/test/PhysicalSphericalPeakTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,33 @@ class PhysicalSphericalPeakTest : public CxxTest::TestSuite
TSM_ASSERT("Should NOT be viewable if a slice point > r is set.", !physicalPeak.isViewablePeak());
}

void test_handleBackgroundOuterRadius_zero()
{
V3D origin(0, 0, 0);
const double radius = 1;
const double innerBackgroundRadius = 2;
const double outerBackgroundRadius = 0; // This can happen using IntegratePeaksMD.
PhysicalSphericalPeak physicalPeak(origin, radius, innerBackgroundRadius, outerBackgroundRadius);

const double slicePoint = innerBackgroundRadius;
physicalPeak.setSlicePoint(slicePoint);

// Scale 1:1 on both x and y for simplicity.
const double windowHeight = 1;
const double windowWidth = 1;
const double viewHeight = 1;
const double viewWidth = 1;

physicalPeak.showBackgroundRadius(true);
auto drawObject = physicalPeak.draw(windowHeight, windowWidth, viewHeight, viewWidth);

// The Return object should be initialized to zero in every field.
TS_ASSERT_EQUALS(drawObject.backgroundOuterRadiusX, drawObject.backgroundInnerRadiusX);
TS_ASSERT_EQUALS(drawObject.backgroundOuterRadiusY, drawObject.backgroundInnerRadiusY);

TSM_ASSERT("Should be viewable since slice point == Background Inner Radius.", physicalPeak.isViewableBackground());
}

void test_draw_defaults()
{
V3D origin(0, 0, 0);
Expand Down

0 comments on commit 1179322

Please sign in to comment.