本文整理汇总了C++中QPolygonF::boundingRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygonF::boundingRect方法的具体用法?C++ QPolygonF::boundingRect怎么用?C++ QPolygonF::boundingRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygonF
的用法示例。
在下文中一共展示了QPolygonF::boundingRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sprawdzOtoczki
bool Logika::sprawdzOtoczki(QPolygonF& otoczka1, QPolygonF& otoczka2) const{
if(!otoczka1.boundingRect().intersects(otoczka2.boundingRect()))
return false;
for(int i = 0; i < otoczka1.size(); i++){
int j = 1;
while(j < otoczka2.size() && this->wyznacznikMacierzyWspolliniowosci(otoczka2[j - 1], otoczka2[j], otoczka1[i]) > 0.0)
j++;
if(j == otoczka2.size() && this->wyznacznikMacierzyWspolliniowosci(otoczka2.last(), otoczka2.first(), otoczka1[i]) > 0.0)
return true;
}
for(int i = 0; i < otoczka2.size(); i++){
int j = 1;
while(j < otoczka1.size() && this->wyznacznikMacierzyWspolliniowosci(otoczka1[j - 1], otoczka1[j], otoczka2[i]) > 0.0)
j++;
if(j == otoczka1.size() && this->wyznacznikMacierzyWspolliniowosci(otoczka1.last(), otoczka1.first(), otoczka2[i]) > 0.0)
return true;
}
return false;
}
示例2: drawTileSelection
void IsometricRenderer::drawTileSelection(QPainter *painter,
const QRegion ®ion,
const QColor &color,
const QRectF &exposed) const
{
painter->setBrush(color);
painter->setPen(Qt::NoPen);
foreach (const QRect &r, region.rects()) {
QPolygonF polygon = tileRectToPolygon(r);
if (QRectF(polygon.boundingRect()).intersects(exposed))
painter->drawConvexPolygon(polygon);
}
}
示例3:
QRectF QgsFillSymbolV2::polygonBounds( const QPolygonF& points, const QList<QPolygonF>* rings ) const
{
QRectF bounds = points.boundingRect();
if ( rings )
{
QList<QPolygonF>::const_iterator it = rings->constBegin();
for ( ; it != rings->constEnd(); ++it )
{
bounds = bounds.united(( *it ).boundingRect() );
}
}
return bounds;
}
示例4: rect
QRectF ModelCurve::rect() const
{
const QPointF &from = m_points_pos[0];
const QPointF &mid1 = m_points_pos[1];
const QPointF &mid2 = m_points_pos[2];
const QPointF &to = m_points_pos[3];
QPolygonF poly;
poly << from << mid1 << mid2 << to;
return poly.boundingRect()
.normalized();
}
示例5: index
/*!
\fn QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QPolygonF
&polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const
QTransform &deviceTransform) const
\overload
Returns all visible items that, depending on \a mode, are either inside or
intersect with the specified \a polygon and return a list sorted using \a order.
The default value for \a mode is Qt::IntersectsItemShape; all items whose
exact shape intersects with or is contained by \a polygon are returned.
\a deviceTransform is the transformation apply to the view.
This method use the estimation of the index (estimateItems) and refine
the list to get an exact result. If you want to implement your own
refinement algorithm you can reimplement this method.
\sa estimateItems()
*/
QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode,
Qt::SortOrder order, const QTransform &deviceTransform) const
{
Q_D(const QGraphicsSceneIndex);
QList<QGraphicsItem *> itemList;
QRectF exposeRect = polygon.boundingRect();
_q_adjustRect(&exposeRect);
QPainterPath path;
path.addPolygon(polygon);
d->pathIntersector->scenePath = path;
d->items_helper(exposeRect, d->pathIntersector, &itemList, deviceTransform, mode, order);
return itemList;
}
示例6: boundingRect
QRectF OrthogonalRenderer::boundingRect(const MapObject *object) const
{
const QRectF bounds = object->bounds();
QRectF boundingRect;
if (!object->cell().isEmpty()) {
const QPointF bottomLeft = bounds.topLeft();
const Tile *tile = object->cell().tile;
const QSize imgSize = tile->image().size();
const QPoint tileOffset = tile->tileset()->tileOffset();
boundingRect = QRectF(bottomLeft.x() + tileOffset.x(),
bottomLeft.y() + tileOffset.y() - imgSize.height(),
imgSize.width(),
imgSize.height()).adjusted(-1, -1, 1, 1);
} else {
const qreal extraSpace = qMax(objectLineWidth() / 2, qreal(1));
switch (object->shape()) {
case MapObject::Ellipse:
case MapObject::Rectangle:
if (bounds.isNull()) {
boundingRect = bounds.adjusted(-10 - extraSpace,
-10 - extraSpace,
10 + extraSpace + 1,
10 + extraSpace + 1);
} else {
const int nameHeight = object->name().isEmpty() ? 0 : 15;
boundingRect = bounds.adjusted(-extraSpace,
-nameHeight - extraSpace,
extraSpace + 1,
extraSpace + 1);
}
break;
case MapObject::Polygon:
case MapObject::Polyline: {
const QPointF &pos = object->position();
const QPolygonF polygon = object->polygon().translated(pos);
QPolygonF screenPolygon = pixelToScreenCoords(polygon);
boundingRect = screenPolygon.boundingRect().adjusted(-extraSpace,
-extraSpace,
extraSpace + 1,
extraSpace + 1);
break;
}
}
}
return boundingRect;
}
示例7: origin
QTransform
ImageTransformation::calcPostRotateXform(double const degrees)
{
QTransform xform;
if (degrees != 0.0) {
QPointF const origin(m_cropArea.boundingRect().center());
xform.translate(-origin.x(), -origin.y());
xform *= QTransform().rotate(degrees);
xform *= QTransform().translate(origin.x(), origin.y());
// Calculate size changes.
QPolygonF const pre_rotate_poly(m_cropXform.map(m_cropArea));
QRectF const pre_rotate_rect(pre_rotate_poly.boundingRect());
QPolygonF const post_rotate_poly(xform.map(pre_rotate_poly));
QRectF const post_rotate_rect(post_rotate_poly.boundingRect());
xform *= QTransform().translate(
pre_rotate_rect.left() - post_rotate_rect.left(),
pre_rotate_rect.top() - post_rotate_rect.top()
);
}
return xform;
}
示例8: QgsComposerItem
QgsComposerNodesItem::QgsComposerNodesItem( QString tagName,
QPolygonF polygon,
QgsComposition* c )
: QgsComposerItem( c )
, mTagName( tagName )
, mSelectedNode( -1 )
, mDrawNodes( false )
{
const QRectF boundingRect = polygon.boundingRect();
setSceneRect( boundingRect );
const QPointF topLeft = boundingRect.topLeft();
mPolygon = polygon.translated( -topLeft );
}
示例9: boundingRect
QRectF Stroke::boundingRect() const
{
QPolygonF tmpPoints = points;
QRectF bRect = tmpPoints.boundingRect();
qreal maxPressure = 0.0;
for (qreal p : pressures)
{
if (p > maxPressure)
{
maxPressure = p;
}
}
qreal pad = maxPressure * penWidth;
return bRect.adjusted(-pad, -pad, pad, pad);
}
示例10: splitTriangles
QRegion KRITAIMAGE_EXPORT splitTriangles(const QPointF ¢er,
const QVector<QPointF> &points)
{
Q_ASSERT(points.size());
Q_ASSERT(!(points.size() & 1));
QVector<QPolygonF> triangles;
QRect totalRect;
for (int i = 0; i < points.size(); i += 2) {
QPolygonF triangle;
triangle << center;
triangle << points[i];
triangle << points[i+1];
totalRect |= triangle.boundingRect().toAlignedRect();
triangles << triangle;
}
const int step = 64;
const int right = totalRect.x() + totalRect.width();
const int bottom = totalRect.y() + totalRect.height();
QRegion dirtyRegion;
for (int y = totalRect.y(); y < bottom;) {
int nextY = qMin((y + step) & ~(step-1), bottom);
for (int x = totalRect.x(); x < right;) {
int nextX = qMin((x + step) & ~(step-1), right);
QRect rect(x, y, nextX - x, nextY - y);
foreach(const QPolygonF &triangle, triangles) {
if(checkInTriangle(rect, triangle)) {
dirtyRegion |= rect;
break;
}
}
x = nextX;
}
y = nextY;
}
return dirtyRegion;
}
示例11: path
QPainterPath BallItem::path() const
{
QPainterPath path;
QPolygonF collidingPlgn = collidingPolygon();
QMatrix m;
m.rotate(rotation());
QPointF firstP = collidingPlgn.at(0);
collidingPlgn.translate(-firstP.x(), -firstP.y());
path.addEllipse(collidingPlgn.boundingRect());
path = m.map(path);
path.translate(firstP.x(), firstP.y());
return path;
}
示例12:
void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context )
{
if ( !p )
{
return;
}
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
if ( points.size() <= 5 &&
( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) &&
QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) &&
( p->renderHints() & QPainter::Antialiasing ) )
{
p->setRenderHint( QPainter::Antialiasing, false );
p->drawRect( points.boundingRect() );
p->setRenderHint( QPainter::Antialiasing, true );
return;
}
// polygons outlines are sometimes rendered wrongly with drawPolygon, when
// clipped (see #13343), so use drawPath instead.
if ( !rings && p->pen().style() == Qt::NoPen )
{
// simple polygon without holes
p->drawPolygon( points );
}
else
{
// polygon with holes must be drawn using painter path
QPainterPath path;
QPolygonF outerRing = points;
path.addPolygon( outerRing );
if ( rings )
{
QList<QPolygonF>::const_iterator it = rings->constBegin();
for ( ; it != rings->constEnd(); ++it )
{
QPolygonF ring = *it;
path.addPolygon( ring );
}
}
p->drawPath( path );
}
}
示例13: clipRect
QRectF clipRect() const
{
// Start with an invalid rect.
QRectF resultRect(0, 0, -1, -1);
for (const QSGClipNode* clip = clipList(); clip; clip = clip->clipList()) {
QMatrix4x4 clipMatrix;
if (pageNode()->devicePixelRatio() != 1.0) {
clipMatrix.scale(pageNode()->devicePixelRatio());
if (clip->matrix())
clipMatrix *= (*clip->matrix());
} else if (clip->matrix())
clipMatrix = *clip->matrix();
QRectF currentClip;
if (clip->isRectangular())
currentClip = clipMatrix.mapRect(clip->clipRect());
else {
const QSGGeometry* geometry = clip->geometry();
// Assume here that clipNode has only coordinate data.
const QSGGeometry::Point2D* geometryPoints = geometry->vertexDataAsPoint2D();
// Clip region should be at least triangle to make valid clip.
if (geometry->vertexCount() < 3)
continue;
QPolygonF polygon;
for (int i = 0; i < geometry->vertexCount(); i++)
polygon.append(clipMatrix.map(QPointF(geometryPoints[i].x, geometryPoints[i].y)));
currentClip = polygon.boundingRect();
}
if (currentClip.isEmpty())
continue;
if (resultRect.isValid())
resultRect &= currentClip;
else
resultRect = currentClip;
}
return resultRect;
}
示例14: drawTileSelection
void StaggeredRenderer::drawTileSelection(QPainter *painter,
const QRegion ®ion,
const QColor &color,
const QRectF &exposed) const
{
painter->setBrush(color);
painter->setPen(Qt::NoPen);
foreach (const QRect &r, region.rects()) {
for (int y = r.top(); y <= r.bottom(); ++y) {
for (int x = r.left(); x <= r.right(); ++x) {
const QPolygonF polygon = tileToPolygon(x, y);
if (QRectF(polygon.boundingRect()).intersects(exposed))
painter->drawConvexPolygon(polygon);
}
}
}
}
示例15: digitalPattern_Scale
bool DataConverter::digitalPattern_Scale(QPolygonF &points, qreal width, qreal height)
{
QRectF boundingRect;
qreal originalWidth, originalHeight;
qreal widthScaleRate, heightScaleRate;
int i;
if (width <= 0.0 || height <= 0.0)
{
qDebug("[DataConverter::digitalPattern_Scale] Error: Width: [%f], Height: [%f]", width, height);
return false;
}
int count = points.size();
if (count < 10)
{
qDebug("[DataConverter::digitalPattern_Scale] Error: Polygon Point Count: [%d]", points.size());
return false;
}
boundingRect = points.boundingRect();
originalWidth = boundingRect.width();
originalHeight = boundingRect.height();
widthScaleRate = width / originalWidth;
heightScaleRate = height / originalHeight;
if (width == originalWidth && height == originalHeight)
return true;
for (i = 0; i < count; i ++)
{
points[i].setX(points.at(i).x() * widthScaleRate);
points[i].setY(points.at(i).y() * heightScaleRate);
}
//qDebug("*** Width: [%f] -> [%f]", originalWidth, points.boundingRect().width());
//qDebug("*** Height: [%f] -> [%f]", originalHeight, points.boundingRect().height());
return true;
}