Example #1
0
void QmitkHistogramWidget::SetHistogram(HistogramType::ConstPointer itkHistogram)
{
  HistogramType::SizeType size = itkHistogram->GetSize();
  HistogramType::IndexType index;
  HistogramType::MeasurementVectorType currentMeasurementVector;

  QVector<QwtIntervalSample> intervalSeries(size[0]);

  for (unsigned int i = 0; i < size[0]; ++i)
  {
    index[0] = static_cast<HistogramType::IndexValueType> (i);
    currentMeasurementVector = itkHistogram->GetMeasurementVector(index);
    if (currentMeasurementVector[0] != 0.0)
    {
      intervalSeries[i] = QwtIntervalSample(static_cast<double> (itkHistogram->GetFrequency(index)),
                                            Round(currentMeasurementVector[0]-1), Round(currentMeasurementVector[0]));
    }
  }

  // rebuild the plot
  m_Plot->detachItems();

  m_Histogram = new QmitkHistogram();
  m_Histogram->setColor(Qt::darkCyan);
  m_Histogram->setData(QwtIntervalSeriesData(intervalSeries));
  m_Histogram->attach(m_Plot);

  this->InitializeMarker();
  this->InitializeZoomer();

  m_Plot->replot();
}
Example #2
0
void QmitkHistogramWidget::SetHistogram(HistogramType::ConstPointer itkHistogram)
{
    HistogramType::SizeType size = itkHistogram->GetSize();
    HistogramType::IndexType index;
    HistogramType::MeasurementVectorType currentMeasurementVector;

    QwtArray<QwtDoubleInterval> xValues(size[0]);
    QwtArray<double> yValues(size[0]);

    for (unsigned int i = 0; i < size[0]; ++i)
    {
#if !defined(ITK_USE_REVIEW_STATISTICS)
        index[0] = static_cast<HistogramType::IndexType::IndexValueType> (i);
#else
        index[0] = static_cast<HistogramType::IndexValueType> (i);
#endif
        currentMeasurementVector = itkHistogram->GetMeasurementVector(index);
        if (currentMeasurementVector[0] != 0.0)
        {
            xValues[i] = QwtDoubleInterval(Round(currentMeasurementVector[0]-1), Round(currentMeasurementVector[0]));
            yValues[i] = static_cast<double> (itkHistogram->GetFrequency(index));
        }
    }

    // rebuild the plot
    m_Plot->clear();

    m_Histogram = new QmitkHistogram();
    m_Histogram->setColor(Qt::darkCyan);
    m_Histogram->setData(QwtIntervalData(xValues, yValues));
    m_Histogram->attach(m_Plot);

    this->InitializeMarker();
    this->InitializeZoomer();

    m_Plot->replot();
}