本文整理汇总了C++中Segments::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Segments::empty方法的具体用法?C++ Segments::empty怎么用?C++ Segments::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segments
的用法示例。
在下文中一共展示了Segments::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
Section & unless( bool const skip )
{
if ( skip )
{
if ( segments.empty() )
throw std::runtime_error( "Curve::unless() called, but no segment present" );
segments.pop_back();
}
return *this;
}
示例2: rerenderBox
void MainWindow::rerenderBox()
{
m_pixmap.fill(Qt::white);
QPainter painter(&m_pixmap);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(QPen(Qt::black, 3));
painter.drawRect(m_boxOffset, m_boxOffset, m_boxParameters.boxSize.x, m_boxParameters.boxSize.y);
const Segments trace = getTrace();
if (trace.empty())
{
return;
}
QPen penBuffer(QColor::fromRgb(1, 0, 0), 2, Qt::SolidLine);
double redColorBuffer = m_boxParameters.initialRedColorValue;
Hit firstLeftHit;
Hit firstBottomHit;
Hit firstRightHit;
Hit firstTopHit;
unsigned char seqNum = 0;
for (Segments::const_iterator f = trace.cbegin(); f != trace.cend(); ++f)
{
if (f != trace.cend() - 1)
{
penBuffer.setColor(QColor::fromRgb((int)redColorBuffer, 0, 0));
redColorBuffer = max(min(255.0, redColorBuffer * m_boxParameters.redColorMultiplier), 0.0);
painter.setPen(penBuffer);
painter.drawLine(QPointF(m_boxOffset + f->x, m_boxOffset + f->y),
QPointF(m_boxOffset + (f+1)->x, m_boxOffset + (f+1)->y));
}
if (f != trace.cbegin())
{
const QPointF srcPoint = QPointF(f->x, f->y);
if (!firstLeftHit.found && abs(f->x) < m_eps)
{
firstLeftHit = Hit(srcPoint, seqNum++);
}
else if (!firstRightHit.found && abs(m_boxParameters.boxSize.x - f->x) < m_eps)
{
firstRightHit= Hit(srcPoint, seqNum++);
}
else if (!firstTopHit.found && abs(f->y) < m_eps)
{
firstTopHit = Hit(srcPoint, seqNum++);
}
else if (!firstBottomHit.found && abs(m_boxParameters.boxSize.y - f->y) < m_eps)
{
firstBottomHit = Hit(srcPoint, seqNum++);
}
}
}
painter.setPen(QPen(Qt::black, 4));
const QPointF boxOffset(m_boxOffset, m_boxOffset);
const QPointF labelXOffset(m_boxOffset / 2, 0);
const QPointF labelYOffset(0, m_boxOffset / 2);
if (firstLeftHit.found)
{
painter.drawText(boxOffset + firstLeftHit.point - labelXOffset,
QString::number(firstLeftHit.seqNumber));
}
if (firstBottomHit.found)
{
painter.drawText(boxOffset + firstBottomHit.point + labelYOffset,
QString::number(firstBottomHit.seqNumber));
}
if (firstRightHit.found)
{
painter.drawText(boxOffset + firstRightHit.point + labelXOffset,
QString::number(firstRightHit.seqNumber));
}
if (firstTopHit.found)
{
painter.drawText(boxOffset + firstTopHit.point - labelYOffset,
QString::number(firstTopHit.seqNumber));
}
repaint();
}