1#include "HistogramWidget.h"
10#include <qwt_scale_div.h>
11#include <qwt_plot_zoomer.h>
12#include <qwt_scale_engine.h>
26 setCanvasBackground(Qt::white);
27 enableAxis(QwtPlot::yRight);
28 setAxisScale(QwtPlot::xBottom, 0, 255);
29 setAxisLabelRotation(QwtPlot::xBottom, 45);
30 setAxisScale(QwtPlot::yRight, 0, 255);
34 axisFont.setBold(
true);
35 axisTitle.setFont(axisFont);
36 axisTitle.setText(
"Frequency");
37 setAxisTitle(QwtPlot::yLeft, axisTitle);
38 axisTitle.setText(
"Input (Cube DN)");
39 setAxisTitle(QwtPlot::xBottom, axisTitle);
40 axisTitle.setText(
"Output");
41 setAxisTitle(QwtPlot::yRight, axisTitle);
48 p_stretchCurve->setPen(QPen(QBrush(stretchColor), 2, Qt::DashLine));
49 p_stretchCurve->setSymbol(
new QwtSymbol(QwtSymbol::Ellipse, QBrush(stretchColor), QPen(stretchColor), QSize(5, 5)));
54 p_zoomer =
new QwtPlotZoomer(canvas());
65 std::vector<double> xarray, yarray;
66 for(
int i = 0; i < hist.
Bins(); i++) {
71 yarray.push_back(freq * 100.0);
78 double maxYValue = DBL_MIN;
79 double minYValue = DBL_MAX;
82 for(
unsigned int y = 0; y < yarray.size(); y++) {
83 intervals[y].interval = QwtInterval(xarray[y], xarray[y] + hist.
BinSize());
85 intervals[y].value = yarray[y];
86 if(yarray[y] > maxYValue)
87 maxYValue = yarray[y];
88 if(yarray[y] < minYValue)
89 minYValue = yarray[y];
94 p_histCurve->setData(QwtIntervalSeriesData(intervals));
102 QwtScaleEngine *engine = axisScaleEngine(QwtPlot::xBottom);
103 QwtScaleDiv scale = engine->divideScale(min, max, maxMajor, maxMinor);
104 QwtInterval interval = scale.interval();
105 setAxisScale(QwtPlot::xBottom,
106 interval.minValue() - hist.
BinSize(),
107 interval.maxValue() + hist.
BinSize());
118 for(
int i = 0; i < stretch.
Pairs(); i++) {
119 curvePoints[i] = QPointF(stretch.
Input(i), stretch.
Output(i));
Container of a cube histogram.
double BinSize() const
Returns the size of an individual bin.
BigInt BinCount(const int index) const
Returns the count at a bin position in the histogram.
double BinMiddle(const int index) const
Returns the value represented by a bin.
int Bins() const
Returns the number of bins in the histogram.
BigInt MaxBinCount() const
Returns the highest bin count.
This is the (qwt) plot item for a histogram.
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
double Output(const int index) const
Returns the value of the output side of the stretch pair at the specified index.
double Input(const int index) const
Returns the value of the input side of the stretch pair at the specified index.
int Pairs() const
Returns the number of stretch pairs.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.