1#include "ScatterPlotData.h"
7#include <qwt_interval.h>
11#include "SpecialPixel.h"
29 Cube *xCube,
int xCubeBand,
int xBinCount,
30 Cube *yCube,
int yCubeBand,
int yBinCount,
35 m_alarmedBins(new
QMap<int, bool>) {
36 int startLine = qRound(lineRange.minValue());
37 int endLine = qRound(lineRange.maxValue());
40 sampleRange.minValue(), lineRange.minValue(),
41 sampleRange.maxValue(), lineRange.maxValue(),
48 sampleRange.minValue(), lineRange.minValue(),
49 sampleRange.maxValue(), lineRange.maxValue(),
63 Brick brick1((
int)(sampleRange.maxValue() - sampleRange.minValue() + 1),
64 1, 1, xCube->pixelType());
65 Brick brick2((
int)(sampleRange.maxValue() - sampleRange.minValue() + 1),
66 1, 1, yCube->pixelType());
68 for (
int line = startLine; line <= endLine; line++) {
69 brick1.SetBasePosition(qRound(sampleRange.minValue()), line, xCubeBand);
72 brick2.SetBasePosition(qRound(sampleRange.minValue()), line, yCubeBand);
75 for (
int i = 0; i < brick1.size(); i++) {
76 double xDn = brick1[i];
77 double yDn = brick2[i];
84 int roundedX = qRound(x);
85 int roundedY = qRound(y);
87 if (roundedX >= 0 && roundedX < xBinCount &&
88 roundedY >= 0 && roundedY < yBinCount) {
89 int value = (*m_counts)[roundedY][roundedX] + 1;
90 (*m_counts)[roundedY][roundedX] =
value;
101 setInterval(Qt::ZAxis, QwtInterval(0,
m_maxCount));
115 m_alarmedBins.reset(
new QMap< int, bool>(*other.m_alarmedBins));
155 int index =
binIndex(indices.first, indices.second);
233 int xIndex = indices.first;
234 int yIndex = indices.second;
236 if (xIndex != -1 && yIndex != -1) {
242 xSize = (*m_counts)[0].size();
244 double percentAcrossXRange = ((double)xIndex / (
double)xSize);
248 double percentAcrossYRange = ((double)yIndex / (
double)ySize);
252 return QPair<double, double>(xDnValue, yDnValue);
256 QString msg =
"Bin at index [" + QString::number(index) +
"] not found. "
257 "There are [" + QString::number(
numberOfBins()) +
"] bins";
270 return binCount(indices.first, indices.second);
285 xSize = (*m_counts)[0].size();
287 return xSize * ySize;
297 QVector<double> xValues;
301 int xSize = (*m_counts)[0].size();
302 xValues.resize(xSize);
304 for (
int xIndex = 0; xIndex < xSize; xIndex++) {
305 double percentAcrossXRange = ((double)xIndex / (
double)xSize);
324 if (binToAlarm != -1)
325 (*m_alarmedBins)[binToAlarm] =
true;
383 if (yIndex >= 0 && yIndex < m_counts->size()) {
384 if (xIndex >= 0 && xIndex < (*
m_counts)[yIndex].size()) {
385 count = (*m_counts)[yIndex][xIndex];
407 xSize = (*m_counts)[0].size();
410 if ((xIndex >= 0 && xIndex < xSize) && (yIndex >= 0 && yIndex < ySize))
411 index = xSize * yIndex + xIndex;
426 return binIndex(indices.first, indices.second);
442 xSize = (*m_counts)[0].size();
449 if (xIndex < 0 || yIndex < 0 || xIndex >= xSize || yIndex >= ySize) {
450 QString msg =
"Bin at index [" + QString::number(
binIndex) +
"] not found. "
451 "There are [" + QString::number(
numberOfBins()) +
"] bins";
455 return QPair<int, int>(xIndex, yIndex);
467 QPair<int, int> indices(-1, -1);
474 int discreteXBin = qRound(xBinPosition);
475 int discreteYBin = qRound(yBinPosition);
477 if (discreteXBin >= 0 && discreteXBin < m_counts->at(0).size() &&
478 discreteYBin >= 0 && discreteYBin < m_counts->size()) {
479 indices = QPair<int, int>(discreteXBin, discreteYBin);
Buffer for containing a three dimensional section of an image.
IO Handler for Isis Cubes.
@ Programmer
This error is for when a programmer made an API call that was illegal.
Container of a cube histogram.
This is the QwtRasterData for a scatter plot.
QScopedPointer< QMap< int, bool > > m_alarmedBins
map from bin index to alarm state (true for alarmed)
QScopedPointer< Stretch > m_xDnToBinStretch
Stretch 1.
~ScatterPlotData()
Destructor.
QVector< double > discreteXValues() const
Get a list of all of the x-bin center values for this scatter plot.
ScatterPlotData & operator=(const ScatterPlotData &other)
Take the data from other and copy it into this.
QPair< int, int > binXYIndices(int binIndex) const
Get the 2D index index position given a 1D (flat) index position.
void clearAlarms()
Forget all alarmed bins (viewport->plot).
QScopedPointer< Stretch > m_yDnToBinStretch
Stretch 2.
double m_yCubeMax
The maximum DN value for the y cube.
double xCubeMax() const
Return the max DN value for the y-axis cube's data range.
QScopedPointer< QVector< QVector< int > > > m_counts
The bin counts stored by 2D (x/y) index position.
int binCount(int binIndex) const
Get the count (number of values) which fall into the bin at index.
double yCubeMin() const
Return the min DN value for the y-axis cube's data range.
int binIndex(int xIndex, int yIndex) const
Get the single-index position given an x/y index position.
double m_xCubeMin
The minimum DN value for the x cube.
ScatterPlotData(Cube *xCube, int xCubeBand, int xBinCount, Cube *yCube, int yCubeBand, int yBinCount, QwtInterval sampleRange, QwtInterval lineRange)
ScatterPlotDataConstructor.
double xCubeMin() const
Return the min DN value for the x-axis cube's data range.
virtual double value(double x, double y) const
This gets called every time the scatter plot is re-drawn.
double m_yCubeMin
The minimum DN value for the y cube.
void swap(ScatterPlotData &other)
This is part of the copy-and-swap paradigm.
double m_xCubeMax
The maximum DN value for the x cube.
double yCubeMax() const
Return the max DN value for the y-axis cube's data range.
int m_maxCount
The maximum value in m_counts, stored for efficiency.
QPair< double, double > binXY(int binIndex) const
Get the center X/Y Dn values for the bin at index.
QRectF pixelHint(const QRectF &area) const
This is a hint given to qwt for how to render a pixel in the spectrogram.
void alarm(double x, double y)
Alarm the bin (highlight it) at the given x/y DN value.
int numberOfBins() const
Get the total number of bins (bin count in x * bin count in y).
virtual QwtRasterData * copy() const
Returns a copy of the ScatterPlotData object.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
bool IsSpecial(const double d)
Returns if the input pixel is special.