9 #include <QIntValidator>
12 #include <QMouseEvent>
14 #include <QRadioButton>
15 #include <QScrollArea>
17 #include <QStackedWidget>
19 #include <QToolButton>
42 p_dialog->setWindowTitle(
"Statistics");
52 QCheckBox *checkBox =
new QCheckBox(
"Hide Display");
53 connect(checkBox, SIGNAL(toggled(
bool)),
this, SLOT(
hideDisplay(
bool)));
55 QLabel *boxLabel =
new QLabel(
"Box Size:");
62 QHBoxLayout *boxLabelLayout =
new QHBoxLayout;
64 boxLabelLayout->addWidget(checkBox);
65 boxLabelLayout->addStretch(1);
66 boxLabelLayout->addWidget(boxLabel);
69 QSlider *slider =
new QSlider(Qt::Vertical);
70 slider->setRange(2, 18);
71 slider->setSliderPosition(10);
72 slider->setSingleStep(1);
73 slider->setTickInterval(1);
74 slider->setTickPosition(QSlider::TicksBelow);
75 connect(slider, SIGNAL(valueChanged(
int)),
p_visualDisplay, SLOT(setBoxSize(
int)));
79 QGroupBox *displayMode =
new QGroupBox(
"Display Mode");
80 QRadioButton *displayText =
new QRadioButton(
"Show Text");
81 displayText->setToolTip(
"Display the pixels of a region as text");
82 QRadioButton *displayPixels =
new QRadioButton(
"Show Pixel Values");
83 displayPixels->setToolTip(
"Display the pixels of a region");
84 QRadioButton *displayDeviation =
new QRadioButton(
"Show Deviation");
85 displayDeviation->setToolTip(
"Display standard deviation over a region,\n where red denotes a larger deviation");
87 QHBoxLayout *displayModeLayout =
new QHBoxLayout;
88 displayModeLayout->addWidget(displayText);
89 displayModeLayout->addWidget(displayPixels);
90 displayModeLayout->addWidget(displayDeviation);
92 displayMode->setLayout(displayModeLayout);
94 connect(displayText, SIGNAL(toggled(
bool)),
p_visualDisplay, SLOT(showText(
bool)));
95 connect(displayText, SIGNAL(toggled(
bool)), slider, SLOT(setDisabled(
bool)));
96 connect(displayPixels, SIGNAL(toggled(
bool)),
p_visualDisplay, SLOT(showPixels(
bool)));
97 connect(displayDeviation, SIGNAL(toggled(
bool)),
p_visualDisplay, SLOT(showDeviation(
bool)));
99 displayText->setChecked(
true);
101 QHBoxLayout *visualHBoxLayout =
new QHBoxLayout;
103 visualHBoxLayout->addWidget(slider);
105 QVBoxLayout *visualVBoxLayout =
new QVBoxLayout;
106 visualVBoxLayout->addLayout(visualHBoxLayout);
107 visualVBoxLayout->addWidget(displayMode);
111 QGroupBox *statsBox =
new QGroupBox(
"Statistics");
114 p_minLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
120 p_maxLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
126 p_avgLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
132 p_stdevLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
139 labelFont.setPointSize(8);
154 QGridLayout *statsLayout =
new QGridLayout;
155 statsLayout->addWidget(
p_minLabel, 0, 0, 1, 2);
156 statsLayout->addWidget(
p_maxLabel, 1, 0, 1, 2);
157 statsLayout->addWidget(
p_avgLabel, 0, 2, 1, 2);
163 statsBox->setLayout(statsLayout);
165 QVBoxLayout *dialogLayout =
new QVBoxLayout;
166 dialogLayout->addLayout(boxLabelLayout);
168 dialogLayout->addWidget(statsBox);
172 checkBox->setChecked(
true);
184 action->setIcon(QPixmap(
toolIconDir() +
"/statistics.png"));
185 action->setToolTip(
"Statistics");
186 QObject::connect(action, SIGNAL(triggered()),
p_dialog, SLOT(show()));
190 action->setWhatsThis(text);
204 QIntValidator *ival =
new QIntValidator(hbox);
205 ival->setRange(1, 100);
207 QLabel *sampleLabel =
new QLabel(
"Box Samples:");
218 QLabel *lineLabel =
new QLabel(
"Box Lines:");
229 QToolButton *showButton =
new QToolButton();
230 showButton->setText(
"Show");
231 showButton->setToolTip(
"");
233 showButton->setWhatsThis(text);
235 connect(showButton, SIGNAL(clicked()),
p_dialog, SLOT(show()));
237 QHBoxLayout *layout =
new QHBoxLayout;
238 layout->setMargin(0);
239 layout->addWidget(sampleLabel);
241 layout->addWidget(lineLabel);
243 layout->addWidget(showButton);
244 layout->addStretch(1);
245 hbox->setLayout(layout);
256 if(s == Qt::LeftButton) {
295 if(cvp == NULL)
return;
301 if((sample < 0.5) || (line < 0.5) ||
306 int isamp = (int)(sample + 0.5);
307 int iline = (int)(line + 0.5);
318 p_ulSamp = isamp - (int)floor(sampDiff);
319 p_ulLine = iline - (int)floor(lineDiff);
339 pixelData[i][j] = brick->
at(0);
372 if(samps !=
"" && samps.toInt() !=
p_boxSamps && samps.toInt() > 0) {
392 if(lines !=
"" && lines.toInt() !=
p_boxLines && lines.toInt() > 0) {
413 hbar->setSliderPosition((hbar->maximum() + hbar->minimum()) / 2);
414 vbar->setSliderPosition((vbar->maximum() + vbar->minimum()) / 2);
434 p_showDeviation(false) {
445 setMouseTracking(
true);
446 setBackgroundRole(QPalette::Dark);
447 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
457 return QSize(460, 460);
510 resize(this->
sizeHint().width(), this->size().height());
517 resize(this->size().width(), this->
sizeHint().height());
587 for(
int i = 0; i < data.size(); i++) {
588 for(
int j = 0; j < data[i].size(); j++) {
596 for(
int i = 0; i < data.size(); i++) {
597 hist.
AddData(data[i].data(), data[i].size());
601 if(hist.Percent(0.5) != hist.Percent(99.5)) {
628 QRect rect(0, 0, p_boxWidth, p_boxHeight);
655 int i = (int)(diff * 255.0);
656 c = QColor(i, 255 - i, 0);
665 c = QColor(visualValue, visualValue, visualValue);
675 p.drawText(rect, Qt::AlignCenter, QString::number(dn));
689 p.setPen(QPen(Qt::red, 1));
691 p.translate(midX, midY);
704 QPainter painter(
this);
709 painter.drawPixmap(midX, midY,
p_pixmap);
721 int x = (int)ceil((event->x() - startX) /
p_boxWidth);
722 int y = (int)ceil((event->y() - startY) /
p_boxHeight);
727 emit
setDn(
"DN: n/a");
736 emit
setDn(QString(
"DN: %1").arg(dn));
748 emit
setDn(
"DN: n/a");
Cube display widget for certain Isis MDI applications.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the histogram counters.
bool p_showPixels
Display pixels?
const double Null
Value for an Isis Null pixel.
int p_oldWidth
Previous box width in pixels.
int p_ulSamp
Upper left sample of region captured.
bool p_showDeviation
Display deviation?
PixelType pixelType() const
int p_oldHeight
Previous box height in pixels.
QSize sizeHint() const
Size hint for this widget.
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
double Map(const double value) const
Maps an input value to an output value based on the stretch pairs and/or special pixel mappings...
int p_boxWidth
Box width in pixels.
Stretch p_stretch
Stretch used to display pixels.
QVector< QVector< double > > p_pixelData
Stored pixel values.
double BestMaximum(const double percent=99.5) const
This method returns the better of the absolute maximum or the Chebyshev maximum.
void SetLis(const double value)
Sets the mapping for LIS pixels.
int cubeSamples() const
Return the number of samples in the cube.
Buffer for containing a three dimensional section of an image.
void SetBasePosition(const int start_sample, const int start_line, const int start_band)
This method is used to set the base position of the shape buffer.
void mouseMoveEvent(QMouseEvent *event)
Called when the mouse moves over this widget.
int p_boxSamps
Sample size for box.
void read(Blob &blob) const
This method will read data from the specified Blob object.
void paintPixmap()
Paint the pixmap.
double StandardDeviation() const
Computes and returns the standard deviation.
This class is used to accumulate statistics on double arrays.
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
void setSample(const QString st)
Signal to set the Sample label to st.
void SetHrs(const double value)
Sets the mapping for HRS pixels.
Cube * cube() const
Return the cube associated with viewport.
BigInt TotalPixels() const
Returns the total number of pixels processed (valid and invalid).
bool p_showText
Display text?
int grayBand() const
Return the gray band currently viewed.
Container of a cube histogram.
void setSamples(int samps)
Set box sample size.
BigInt ValidPixels() const
Returns the total number of valid pixels processed.
int p_boxLines
Line size for box.
void SetLrs(const double value)
Sets the mapping for LRS pixels.
double Average() const
Computes and returns the average.
bool p_set
Boolean to see if data is set.
void leaveEvent(QEvent *event)
Mouse left widget, update labels.
void Reset()
Reset all accumulators and counters to zero.
void SetHis(const double value)
Sets the mapping for HIS pixels.
void setDn(const QString st)
Signal to set the DN label to st.
Tool to visualize statistics in an n * m box.
void setBoxSize(int size)
Set box size in pixels.
int p_boxHeight
Box height in pixels.
int p_ulLine
Upper left line of region captured.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
void setLine(const QString st)
Signal to set the Line label to st.
bool IsSpecial(const double d)
Returns if the input pixel is special.
QPixmap p_pixmap
Pixmap used for drawing.
void viewportToCube(int x, int y, double &sample, double &line) const
Convert a viewport x/y to a cube sample/line (may be outside the cube)
void updateSize()
Update the size of the box.
void showDeviation(bool b)
Show/Hide deviation.
void setPixelData(QVector< QVector< double > > data, int samp, int line)
Set pixel data and upper left sample/line.
void paintEvent(QPaintEvent *event)
Paint pixmap to the widget.
void ClearPairs()
Clears the stretch pairs.
void setLines(int lines)
Set box line size.
QString PixelToString(double d)
Takes a double pixel value and returns the name of the pixel type as a string.
void showText(bool b)
Show/Hide text.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
double BestMinimum(const double percent=99.5) const
This method returns the better of the absolute minimum or the Chebyshev minimum.
int cubeLines() const
Return the number of lines in the cube.
void SetNull(const double value)
Sets the mapping for NULL pixels.
void showPixels(bool b)
Show/Hide pixels.
Statistics p_stats
Stats used for calculating stretch and deviation.
double at(const int index) const
Returns the value in the shape buffer at the given index.
VisualDisplay(QWidget *parent=0)
Constructor for visual display.