本文整理汇总了C++中range_t::length方法的典型用法代码示例。如果您正苦于以下问题:C++ range_t::length方法的具体用法?C++ range_t::length怎么用?C++ range_t::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类range_t
的用法示例。
在下文中一共展示了range_t::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintMid
void TracePlot::paintMid(QPainter &painter, QRect &rect, range_t<off_t> sampleRange)
{
int samplesPerColumn = sampleRange.length() / rect.width();
int samplesPerTile = tileWidth * samplesPerColumn;
off_t tileID = sampleRange.minimum / samplesPerTile;
off_t tileOffset = sampleRange.minimum % samplesPerTile; // Number of samples to skip from first image tile
int xOffset = tileOffset / samplesPerColumn; // Number of columns to skip from first image tile
// Paint first (possibly partial) tile
painter.drawPixmap(
QRect(rect.x(), rect.y(), tileWidth - xOffset, height()),
getTile(tileID++, samplesPerTile),
QRect(xOffset, 0, tileWidth - xOffset, height())
);
// Paint remaining tiles
for (int x = tileWidth - xOffset; x < rect.right(); x += tileWidth) {
painter.drawPixmap(
QRect(x, rect.y(), tileWidth, height()),
getTile(tileID++, samplesPerTile)
);
}
}
示例2: drawTile
void TracePlot::drawTile(QString key, const QRect &rect, range_t<off_t> sampleRange)
{
QImage image(rect.size(), QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter painter(&image);
painter.setRenderHint(QPainter::Antialiasing, true);
auto firstSample = sampleRange.minimum;
auto length = sampleRange.length();
// Is it a 2-channel (complex) trace?
if (auto src = dynamic_cast<SampleSource<std::complex<float>>*>(sampleSource.get())) {
auto samples = src->getSamples(firstSample, length);
if (samples == nullptr)
return;
painter.setPen(Qt::red);
plotTrace(painter, rect, reinterpret_cast<float*>(samples.get()), length, 2);
painter.setPen(Qt::blue);
plotTrace(painter, rect, reinterpret_cast<float*>(samples.get())+1, length, 2);
// Otherwise is it single channel?
} else if (auto src = dynamic_cast<SampleSource<float>*>(sampleSource.get())) {
auto samples = src->getSamples(firstSample, length);
if (samples == nullptr)
return;
painter.setPen(Qt::green);
plotTrace(painter, rect, samples.get(), length, 1);
} else {
throw std::runtime_error("TracePlot::paintMid: Unsupported source type");
}
emit imageReady(key, image);
}