本文整理汇总了C++中QwtArray::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtArray::append方法的具体用法?C++ QwtArray::append怎么用?C++ QwtArray::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtArray
的用法示例。
在下文中一共展示了QwtArray::append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawHistogram
//.........这里部分代码省略.........
grid->setPen( mGridPen );
grid->attach( mpPlot );
// make colors list
mHistoColors.clear();
foreach ( QgsRendererRangeV2 range, mRanges )
{
mHistoColors << ( range.symbol() ? range.symbol()->color() : Qt::black );
}
//draw histogram
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
QwtPlotHistogram * plotHistogram = 0;
plotHistogram = createPlotHistogram( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
mRanges.count() > 0 ? Qt::NoPen : mPen );
#else
HistogramItem *plotHistogramItem = 0;
plotHistogramItem = createHistoItem( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
mRanges.count() > 0 ? Qt::NoPen : mPen );
#endif
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
QVector<QwtIntervalSample> dataHisto;
#else
// we safely assume that QT>=4.0 (min version is 4.7), therefore QwtArray is a QVector, so don't set size here
QwtArray<QwtDoubleInterval> intervalsHisto;
QwtArray<double> valuesHisto;
#endif
int bins = mBinsSpinBox->value();
QList<double> edges = mHistogram.binEdges( bins );
QList<int> counts = mHistogram.counts( bins );
int rangeIndex = 0;
int lastValue = 0;
for ( int bin = 0; bin < bins; ++bin )
{
int binValue = counts.at( bin );
//current bin crosses two graduated ranges, so we split between
//two histogram items
if ( rangeIndex < mRanges.count() - 1 && edges.at( bin ) > mRanges.at( rangeIndex ).upperValue() )
{
rangeIndex++;
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
plotHistogram->setSamples( dataHisto );
plotHistogram->attach( mpPlot );
plotHistogram = createPlotHistogram( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
dataHisto.clear();
dataHisto << QwtIntervalSample( lastValue, mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) );
#else
plotHistogramItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
plotHistogramItem->attach( mpPlot );
plotHistogramItem = createHistoItem( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
intervalsHisto.clear();
valuesHisto.clear();
intervalsHisto.append( QwtDoubleInterval( mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) ) );
valuesHisto.append( lastValue );
#endif
}
double upperEdge = mRanges.count() > 0 ? qMin( edges.at( bin + 1 ), mRanges.at( rangeIndex ).upperValue() )
: edges.at( bin + 1 );
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
dataHisto << QwtIntervalSample( binValue, edges.at( bin ), upperEdge );
#else
intervalsHisto.append( QwtDoubleInterval( edges.at( bin ), upperEdge ) );
valuesHisto.append( double( binValue ) );
#endif
lastValue = binValue;
}
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
plotHistogram->setSamples( dataHisto );
plotHistogram->attach( mpPlot );
#else
plotHistogramItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
plotHistogramItem->attach( mpPlot );
#endif
mRangeMarkers.clear();
foreach ( QgsRendererRangeV2 range, mRanges )
{
QwtPlotMarker* rangeMarker = new QwtPlotMarker();
rangeMarker->attach( mpPlot );
rangeMarker->setLineStyle( QwtPlotMarker::VLine );
rangeMarker->setXValue( range.upperValue() );
rangeMarker->setLabel( QString::number( range.upperValue() ) );
rangeMarker->setLabelOrientation( Qt::Vertical );
rangeMarker->setLabelAlignment( Qt::AlignLeft | Qt::AlignTop );
rangeMarker->show();
mRangeMarkers << rangeMarker;
}