Skip to content

Commit

Permalink
Refs #3882 handle inf in color scale
Browse files Browse the repository at this point in the history
by limiting the scale to finite numbers.
  • Loading branch information
Janik Zikovsky committed Nov 9, 2011
1 parent 44c8fba commit 54b7294
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <qwt_scale_widget.h>
#include <vector>
#include "MantidQtAPI/MantidColorMap.h"
#include "MantidAPI/IMDIterator.h"


class EXPORT_OPT_MANTIDQT_SLICEVIEWER SliceViewer : public QWidget
Expand Down Expand Up @@ -55,6 +56,7 @@ public slots:
void updateDisplay(bool resetAxes = false);
void updateDimensionSliceWidgets();
void resetAxis(int axis, Mantid::Geometry::IMDDimension_const_sptr dim);
QwtDoubleInterval getRange(Mantid::API::IMDIterator * it);

void findRangeFull();
void findRangeSlice();
Expand Down Expand Up @@ -116,6 +118,8 @@ public slots:
QMenu * m_menuColorOptions;
QMenu * m_menuView;

/// Cached double for infinity
double m_inf;
};

#endif // SLICEVIEWER_H
13 changes: 10 additions & 3 deletions Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <sstream>
#include <vector>
#include <qfiledialog.h>
#include <limits>

using namespace Mantid;
using namespace Mantid::Kernel;
Expand All @@ -43,6 +44,8 @@ SliceViewer::SliceViewer(QWidget *parent)
{
ui.setupUi(this);

m_inf = std::numeric_limits<double>::infinity();

// Create the plot
m_spectLayout = new QHBoxLayout(ui.frmPlot);
m_plot = new QwtPlot();
Expand Down Expand Up @@ -462,7 +465,7 @@ void SliceViewer::resetAxis(int axis, Mantid::Geometry::IMDDimension_const_sptr
* @param it :: IMDIterator of what to find
* @return the min/max range, or 0-1.0 if not found
*/
QwtDoubleInterval getRange(IMDIterator * it)
QwtDoubleInterval SliceViewer::getRange(IMDIterator * it)
{
if (!it)
return QwtDoubleInterval(0., 1.0);
Expand All @@ -474,8 +477,12 @@ QwtDoubleInterval getRange(IMDIterator * it)
do
{
double signal = it->getNormalizedSignal();
if (signal > 0 && signal < minSignal) minSignal = signal;
if (signal > maxSignal) maxSignal = signal;
// Skip any 'infs' as it screws up the color scale
if (signal != m_inf)
{
if (signal > 0 && signal < minSignal) minSignal = signal;
if (signal > maxSignal) maxSignal = signal;
}
} while (it->next());

if (minSignal == DBL_MAX)
Expand Down

0 comments on commit 54b7294

Please sign in to comment.