本文整理汇总了C++中QPolygonF::length方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygonF::length方法的具体用法?C++ QPolygonF::length怎么用?C++ QPolygonF::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygonF
的用法示例。
在下文中一共展示了QPolygonF::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pixmapForCurrentSettings
QPixmap ViewPointStyle::pixmapForCurrentSettings () const
{
LOG4CPP_INFO_S ((*mainCat)) << "ViewPointStyle::pixmapForCurrentSettings";
// Polygon that is sized for the main drawing window.
QPolygonF polygonUnscaled = m_pointStyle.polygon();
// Resize polygon to fit icon, by builiding a new scaled polygon from the unscaled polygon
double xMinGot = polygonUnscaled.boundingRect().left();
double xMaxGot = polygonUnscaled.boundingRect().right();
double yMinGot = polygonUnscaled.boundingRect().top();
double yMaxGot = polygonUnscaled.boundingRect().bottom();
QPolygonF polygonScaled;
for (int i = 0; i < polygonUnscaled.length(); i++) {
QPointF pOld = polygonUnscaled.at(i);
polygonScaled.append (QPointF ((width () - 1) * (pOld.x() - xMinGot) / (xMaxGot - xMinGot),
(height () - 1) * (pOld.y() - yMinGot) / (yMaxGot - yMinGot)));
}
// Color
QColor color = ColorPaletteToQColor(m_pointStyle.paletteColor());
if (!m_enabled) {
color = QColor (Qt::black);
}
// Image for drawing
QImage img (width (),
height (),
QImage::Format_RGB32);
QPainter painter (&img);
painter.fillRect (0,
0,
width (),
height (),
QBrush (m_enabled ? COLOR_FOR_BRUSH_ENABLED : COLOR_FOR_BRUSH_DISABLED));
if (m_enabled) {
painter.setPen (QPen (color, m_pointStyle.lineWidth()));
painter.drawPolygon (polygonScaled);
}
// Create pixmap from image
QPixmap pixmap = QPixmap::fromImage (img);
return pixmap;
}
示例2: rectSlice
/*!
* \fn Util::cullLine
* Slice \a poly so that the segments that are left are those which remain inside \a rect.
*/
QList<QPolygonF> Util::cullLine(QPolygonF poly, QRectF rect)
{
// When the plot is zoomed closer, drawing the line as a single poly
// gets slower - weird and annoying. Therefore, here, the lines are "cut"
// by the view frame so that excess segment aren't drawn.
QList<QPolygonF> lines;
QPointF latestPoint;
QPolygonF latestPoly;
bool starting = true;
// If there's only 1 point, the forloop will not run
if (poly.size() == 1) {
if (rect.contains(poly[0])) {
latestPoly << poly[0];
lines << latestPoly;
}
return lines;
}
for (int i=0; i<poly.size() - 1; ++i) {
QPointF p1 = poly[i], p2 = poly[i+1];
QLineF l = rectSlice(p1, p2, rect);
if (l.isNull()) continue;
// Check if the line has been broken, or is starting
if (l.p1() != latestPoint || starting) {
// Throw the current poly in and start a new one
if (latestPoly.length() > 0) {
lines << latestPoly;
latestPoly = QPolygonF();
}
starting = false;
latestPoly << l.p1();
}
latestPoly << l.p2();
latestPoint = l.p2();
}
// Need the final whole section
lines << latestPoly;
return lines;
}