/** * Get the center X/Y Dn values for the bin at index. * * @param index The bin to get the center X/Y DN Values for * * @return The center DN value of the given bin */ QPair<double, double> ScatterPlotData::binXY(int index) const { QPair<int, int> indices = binXYIndices(index); int xIndex = indices.first; int yIndex = indices.second; if (xIndex != -1 && yIndex != -1) { int xSize = 0; int ySize = m_counts->size(); // Assume square 2D structurs if (ySize > 0) xSize = (*m_counts)[0].size(); double percentAcrossXRange = ((double)xIndex / (double)xSize); double xDnValue = m_xCubeMin + percentAcrossXRange * (m_xCubeMax - m_xCubeMin); double percentAcrossYRange = ((double)yIndex / (double)ySize); double yDnValue = m_yCubeMin + percentAcrossYRange * (m_yCubeMax - m_yCubeMin); return QPair<double, double>(xDnValue, yDnValue); } IString msg = "Bin at index [" + IString(index) + "] not found. " "There are [" + IString(numberOfBins()) + "] bins"; throw IException(IException::Programmer, msg, _FILEINFO_); }
QString Histogram::descriptionTip() const { QString tip; tip = tr("Histogram: %1").arg(Name()); if (realTimeAutoBin()) { tip+= tr("\n Auto-bin"); } else { tip += tr("\n %1 bins from %2 to %3").arg(numberOfBins()).arg(xMin()).arg(xMax()); } tip += tr("\nInput: %1").arg(_inputVectors[RAWVECTOR]->descriptionTip()); return tip; }
/** * Get the 2D index index position given a 1D (flat) index position. * * @param binIndex The 1D (flat) index of the bin * @return The x/y 2D index position */ QPair<int, int> ScatterPlotData::binXYIndices(int binIndex) const { int xSize = 0; int ySize = m_counts->size(); // Assume square 2D structurs if (ySize > 0) xSize = (*m_counts)[0].size(); int yIndex = (binIndex / xSize); binIndex -= yIndex * xSize; int xIndex = binIndex; if (xIndex < 0 || yIndex < 0 || xIndex >= xSize || yIndex >= ySize) { IString msg = "Bin at index [" + IString(binIndex) + "] not found. " "There are [" + IString(numberOfBins()) + "] bins"; throw IException(IException::Programmer, msg, _FILEINFO_); } return QPair<int, int>(xIndex, yIndex); }