示例#1
0
void HistPlot::populate()
{
	setTitle("Watching TV during a weekend");
	setAxisTitle(QwtPlot::yLeft, "Number of People");
	setAxisTitle(QwtPlot::xBottom, "Number of Hours");

	QwtPlotGrid *grid = new QwtPlotGrid;
	grid->enableX(false);
	grid->enableY(true);
	grid->enableXMin(false);
	grid->enableYMin(false);
	grid->setMajPen(QPen(Qt::black, 0, Qt::SolidLine));
	grid->attach(this);

	const double juneValues[] = { 7, 19, 24, 32, 10, 5, 3 };
	const double novemberValues[] = { 4, 15, 22, 34, 13, 8, 4 };

	Histogram *histogramJune = new Histogram("Summer", Qt::red);
	histogramJune->setValues(
		sizeof(juneValues) / sizeof(double), juneValues);
	histogramJune->attach(this);

	Histogram *histogramNovember = new Histogram("Winter", Qt::blue);
	histogramNovember->setValues(
		sizeof(novemberValues) / sizeof(double), novemberValues);
	histogramNovember->attach(this);
}
示例#2
0
void TVPlot::populate()
{
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableX( false );
    grid->enableY( true );
    grid->enableXMin( false );
    grid->enableYMin( false );
    grid->setMajorPen( Qt::black, 0, Qt::DotLine );
    grid->attach( this );

    const double juneValues[] = { 7, 19, 24, 32, 10, 5, 3 };
    const double novemberValues[] = { 4, 15, 22, 34, 13, 8, 4 };

    Histogram *histogramJune = new Histogram( "Summer", Qt::red );
    histogramJune->setValues(
        sizeof( juneValues ) / sizeof( double ), juneValues );
    histogramJune->attach( this );

    Histogram *histogramNovember = new Histogram( "Winter", Qt::blue );
    histogramNovember->setValues(
        sizeof( novemberValues ) / sizeof( double ), novemberValues );
    histogramNovember->attach( this );
}
示例#3
0
void HistPlot::setValueHist(const vector<double>& histogram, int origin)
{
	setTitle("Histogram");
	setAxisTitle(QwtPlot::yLeft, "Count");
	setAxisTitle(QwtPlot::xBottom, "Value");

	QwtPlotGrid *grid = new QwtPlotGrid;
	grid->enableX(false);
	grid->enableY(true);
	grid->enableXMin(false);
	grid->enableYMin(false);
	grid->setMajPen(QPen(Qt::darkGreen, 0, Qt::SolidLine));
	grid->attach(this);

	Histogram *histogramJune = new Histogram("Summer", Qt::red);
	histogramJune->setValues(
		histogram.size(), &histogram[0], origin);
	histogramJune->attach(this);
}
示例#4
0
void Histograma::populate(QImage *img)
{
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableX(false);
    grid->enableY(true);
    grid->enableXMin(true);
    grid->enableYMin(true);
    grid->setMajorPen(QPen(Qt::black, 0, Qt::DotLine));
    grid->setMinorPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->attach(this);

    int cinza, mQtd = 0;
    int x, y;
    // Quantidade de pontos de 0 a 255
    const int pts = 256;

    QVector<float> valores(pts);

    // inicializa os valores com 0
    for (int i = 0; i < pts; i++)
            valores[i] = 0.0;

    for (x = 0; x < img->width(); x++) {
        for (y = 0; y < img->height(); y++) {
            cinza = qGray(img->pixel(QPoint(x,y)));
            valores[cinza]++;

            if (valores[cinza] > mQtd)
                mQtd = valores[cinza];
        }
    }

    Histogram *hist = new Histogram("", Qt::black);
    hist->setValues(pts, &valores);

    hist->attach(this);
    this->replot();
}