26 #include <QFileDialog> 
   27 #include <QPrintDialog> 
   30 #include <QMessageBox> 
   32 #include <QVBoxLayout> 
   34 #include <qwt_plot_curve.h> 
   35 #include <qwt_plot_zoomer.h> 
   48     p_zoomer = 
new QwtPlotZoomer(this->canvas());
 
   49     setTitle(
"Histogram Plot");
 
   51     QwtText *leftLabel = 
new QwtText(
"Frequency", QwtText::PlainText);
 
   52     leftLabel->setColor(Qt::red);
 
   53     QFont font = leftLabel->font();
 
   54     font.setPointSize(13);
 
   56     leftLabel->setFont(font);
 
   57     setAxisTitle(QwtPlot::yLeft, *leftLabel);
 
   59     QwtText *rtLabel = 
new QwtText(
"Percentage");
 
   60     rtLabel->setColor(Qt::blue);
 
   61     rtLabel->setFont(font);
 
   62     setAxisTitle(QwtPlot::yRight, *rtLabel);
 
   64     setAxisTitle(QwtPlot::xBottom, 
"Pixel Value (DN)");
 
   66     setAxisScale(QwtPlot::yRight, 0, 100);
 
   67     enableAxis(QwtPlot::yRight, 
true);
 
   68     setCanvasBackground(Qt::white);
 
   88     for(
int i = 0; i < hist.
Bins(); i++) {
 
   94         cdfData.append(QPointF(hist.
BinMiddle(i), cumpct));
 
   97     QPen *pen = 
new QPen(Qt::red);
 
   99     p_histCurve->setData(
new QwtPointSeriesData(histData));
 
  104     pen->setColor(Qt::blue);
 
  105     p_cdfCurve->setData(
new QwtPointSeriesData(cdfData));
 
  120     if(
p_zoomer->trackerMode() == QwtPicker::ActiveOnly) {
 
  121       p_zoomer->setTrackerMode(QwtPicker::AlwaysOn);
 
  124       p_zoomer->setTrackerMode(QwtPicker::ActiveOnly);
 
  145     static QPrinter *printer = NULL;
 
  146     if(printer == NULL) printer = 
new QPrinter;
 
  147     printer->setPageSize(QPrinter::Letter);
 
  148     printer->setColorMode(QPrinter::Color);
 
  150     QPrintDialog printDialog(printer, (
QWidget *)parent());
 
  151     if(printDialog.exec() == QDialog::Accepted) {
 
  153       QPixmap pixmap = this->grab();
 
  154       QImage img = pixmap.toImage();
 
  157       QPainter painter(printer);
 
  158       QRect rect = painter.viewport();
 
  159       QSize size = img.size();
 
  160       size.scale(rect.size(), Qt::KeepAspectRatio);
 
  161       painter.setViewport(rect.x(), rect.y(),
 
  162                           size.width(), size.height());
 
  163       painter.setWindow(img.rect());
 
  164       painter.drawImage(0, 0, img);
 
  176       QFileDialog::getSaveFileName((
QWidget *)parent(),
 
  177                                    "Choose output file",
 
  179                                    QString(
"Images (*.png *.jpg *.tif)"));
 
  180     if(output.isEmpty()) 
return;
 
  182     QString format = QFileInfo(output).suffix();
 
  183     QPixmap pixmap = this->grab();
 
  184     std::string formatString = format.toStdString();
 
  185     if(!pixmap.save(output, formatString.c_str())) {
 
  186       QMessageBox::information((
QWidget *)parent(), 
"Error", 
"Unable to save" + output);
 
  197     QPen *pen = 
new QPen(Qt::white);
 
  198     if(canvasBackground() == Qt::white) {
 
  199       setCanvasBackground(Qt::black);
 
  204       setCanvasBackground(Qt::white);
 
  205       pen->setColor(Qt::black);
 
  219     d->setWindowTitle(
"Basic Help");
 
  221     QLabel *zoomLabel = 
new QLabel(
"Zoom Options:");
 
  223     QLabel(
"  <b>Left click</b> on the mouse, drag, and release to select an area to zoom in on");
 
  224     QLabel *zoomOut = 
new 
  225     QLabel(
"  <b>Middle click</b> on the mouse to zoom out one level");
 
  226     QLabel *zoomReset = 
new 
  227     QLabel(
"  <b>Right click</b> on the mouse to clear the zoom and return to the original plot");
 
  229     QVBoxLayout *layout = 
new QVBoxLayout();
 
  230     layout->addWidget(zoomLabel);
 
  231     layout->addWidget(zoomIn);
 
  232     layout->addWidget(zoomOut);
 
  233     layout->addWidget(zoomReset);
 
  235     d->setLayout(layout);
 
void trackerEnabled()
Enables mouse tracking on the plot. 
 
int Bins() const 
Returns the number of bins in the histogram. 
 
QwtPlotCurve * p_histCurve
Historgram plot curve. 
 
void showHelp()
Provides help text in a dialog box. 
 
BigInt BinCount(const int index) const 
Returns the count at a bin position in the histogram. 
 
void cdfCurveVisible()
Hide/show the cdf curve. 
 
QwtPlotZoomer * p_zoomer
Plot Zoomer. 
 
Container of a cube histogram. 
 
BigInt ValidPixels() const 
Returns the total number of valid pixels processed. 
 
QwtPlotCurve * p_cdfCurve
CDF plot curve. 
 
void printPlot()
Provide printing capabilities. 
 
double BinMiddle(const int index) const 
Returns the value represented by a bin. 
 
void switchBackground()
Switches the plot background color between black and white. 
 
void Load(Histogram &hist)
Plots the given Isis Histogram in the plot window. 
 
void savePlot()
Allows user to save the plot to an image file.