8 #include <QIntValidator>
11 #include <QMouseEvent>
13 #include <QRadioButton>
14 #include <QScrollArea>
16 #include <QStackedWidget>
18 #include <QToolButton>
41 p_dialog->setWindowTitle(
"Statistics");
51 QCheckBox *checkBox =
new QCheckBox(
"Hide Display");
52 connect(checkBox, SIGNAL(toggled(
bool)),
this, SLOT(
hideDisplay(
bool)));
54 QLabel *boxLabel =
new QLabel(
"Box Size:");
61 QHBoxLayout *boxLabelLayout =
new QHBoxLayout;
63 boxLabelLayout->addWidget(checkBox);
64 boxLabelLayout->addStretch(1);
65 boxLabelLayout->addWidget(boxLabel);
68 QSlider *slider =
new QSlider(Qt::Vertical);
69 slider->setRange(2, 18);
70 slider->setSliderPosition(10);
71 slider->setSingleStep(1);
72 slider->setTickInterval(1);
73 slider->setTickPosition(QSlider::TicksBelow);
74 connect(slider, SIGNAL(valueChanged(
int)),
p_visualDisplay, SLOT(setBoxSize(
int)));
78 QGroupBox *displayMode =
new QGroupBox(
"Display Mode");
79 QRadioButton *displayText =
new QRadioButton(
"Show Text");
80 displayText->setToolTip(
"Display the pixels of a region as text");
81 QRadioButton *displayPixels =
new QRadioButton(
"Show Pixel Values");
82 displayPixels->setToolTip(
"Display the pixels of a region");
83 QRadioButton *displayDeviation =
new QRadioButton(
"Show Deviation");
84 displayDeviation->setToolTip(
"Display standard deviation over a region,\n where red denotes a larger deviation");
86 QHBoxLayout *displayModeLayout =
new QHBoxLayout;
87 displayModeLayout->addWidget(displayText);
88 displayModeLayout->addWidget(displayPixels);
89 displayModeLayout->addWidget(displayDeviation);
91 displayMode->setLayout(displayModeLayout);
93 connect(displayText, SIGNAL(toggled(
bool)),
p_visualDisplay, SLOT(showText(
bool)));
94 connect(displayText, SIGNAL(toggled(
bool)), slider, SLOT(setDisabled(
bool)));
95 connect(displayPixels, SIGNAL(toggled(
bool)),
p_visualDisplay, SLOT(showPixels(
bool)));
96 connect(displayDeviation, SIGNAL(toggled(
bool)),
p_visualDisplay, SLOT(showDeviation(
bool)));
98 displayText->setChecked(
true);
100 QHBoxLayout *visualHBoxLayout =
new QHBoxLayout;
102 visualHBoxLayout->addWidget(slider);
104 QVBoxLayout *visualVBoxLayout =
new QVBoxLayout;
105 visualVBoxLayout->addLayout(visualHBoxLayout);
106 visualVBoxLayout->addWidget(displayMode);
110 QGroupBox *statsBox =
new QGroupBox(
"Statistics");
113 p_minLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
119 p_maxLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
125 p_avgLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
131 p_stdevLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
138 labelFont.setPointSize(8);
153 QGridLayout *statsLayout =
new QGridLayout;
154 statsLayout->addWidget(
p_minLabel, 0, 0, 1, 2);
155 statsLayout->addWidget(
p_maxLabel, 1, 0, 1, 2);
156 statsLayout->addWidget(
p_avgLabel, 0, 2, 1, 2);
162 statsBox->setLayout(statsLayout);
164 QVBoxLayout *dialogLayout =
new QVBoxLayout;
165 dialogLayout->addLayout(boxLabelLayout);
167 dialogLayout->addWidget(statsBox);
171 checkBox->setChecked(
true);
183 action->setIcon(QPixmap(
toolIconDir() +
"/statistics.png"));
184 action->setToolTip(
"Statistics");
185 QObject::connect(action, SIGNAL(activated()),
p_dialog, SLOT(show()));
189 action->setWhatsThis(text);
203 QIntValidator *ival =
new QIntValidator(hbox);
204 ival->setRange(1, 100);
206 QLabel *sampleLabel =
new QLabel(
"Box Samples:");
217 QLabel *lineLabel =
new QLabel(
"Box Lines:");
228 QToolButton *showButton =
new QToolButton();
229 showButton->setText(
"Show");
230 showButton->setToolTip(
"");
232 showButton->setWhatsThis(text);
234 connect(showButton, SIGNAL(clicked()),
p_dialog, SLOT(show()));
236 QHBoxLayout *layout =
new QHBoxLayout;
237 layout->setMargin(0);
238 layout->addWidget(sampleLabel);
240 layout->addWidget(lineLabel);
242 layout->addWidget(showButton);
243 layout->addStretch(1);
244 hbox->setLayout(layout);
255 if(s == Qt::LeftButton) {
294 if(cvp == NULL)
return;
300 if((sample < 0.5) || (line < 0.5) ||
305 int isamp = (int)(sample + 0.5);
306 int iline = (int)(line + 0.5);
317 p_ulSamp = isamp - (int)floor(sampDiff);
318 p_ulLine = iline - (int)floor(lineDiff);
338 pixelData[i][j] = brick->
at(0);
371 if(samps !=
"" && samps.toInt() !=
p_boxSamps && samps.toInt() > 0) {
391 if(lines !=
"" && lines.toInt() !=
p_boxLines && lines.toInt() > 0) {
412 hbar->setSliderPosition((hbar->maximum() + hbar->minimum()) / 2);
413 vbar->setSliderPosition((vbar->maximum() + vbar->minimum()) / 2);
433 p_showDeviation(false) {
444 setMouseTracking(
true);
445 setBackgroundRole(QPalette::Dark);
446 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
456 return QSize(460, 460);
509 resize(this->
sizeHint().width(), this->size().height());
516 resize(this->size().width(), this->
sizeHint().height());
586 for(
int i = 0; i < data.size(); i++) {
587 for(
int j = 0; j < data[i].size(); j++) {
595 for(
int i = 0; i < data.size(); i++) {
596 hist.
AddData(data[i].data(), data[i].size());
600 if(hist.Percent(0.5) != hist.Percent(99.5)) {
627 QRect rect(0, 0, p_boxWidth, p_boxHeight);
654 int i = (int)(diff * 255.0);
655 c = QColor(i, 255 - i, 0);
664 c = QColor(visualValue, visualValue, visualValue);
674 p.drawText(rect, Qt::AlignCenter, QString::number(dn));
688 p.setPen(QPen(Qt::red, 1));
690 p.translate(midX, midY);
703 QPainter painter(
this);
708 painter.drawPixmap(midX, midY,
p_pixmap);
720 int x = (int)ceil((event->x() - startX) /
p_boxWidth);
721 int y = (int)ceil((event->y() - startY) /
p_boxHeight);
726 emit
setDn(
"DN: n/a");
735 emit
setDn(QString(
"DN: %1").arg(dn));
747 emit
setDn(
"DN: n/a");