本文整理汇总了C++中QRectF::united方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::united方法的具体用法?C++ QRectF::united怎么用?C++ QRectF::united使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::united方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: objectsBoundingRect
QRectF ObjectGroup::objectsBoundingRect() const
{
QRectF boundingRect;
foreach (const MapObject *object, mObjects)
boundingRect = boundingRect.united(object->bounds());
return boundingRect;
}
示例2: calculate_extent
static QRectF calculate_extent(QRectF r)
{
// 确保image的大小,从左上角的(0,0)位置位起点。
return r.united(QRectF(0, 0, 1, 1));
// 测试的范围
//return QRectF(0, 0, 1000, 10000);
}
示例3: buildObjects
void TemplateSCgObjectsBuilder::buildObjects(const TypeToObjectsMap& objects)
{
mDecoratedBuilder->buildObjects(objects);
QList<SCgObject*> l = mDecoratedBuilder->objects();
foreach(SCgObject* obj, l)
if(! obj->parentItem())
obj->setDead(true);
QRectF bounds;
foreach(SCgObject* obj, l)
bounds = bounds.united(obj->sceneBoundingRect());
foreach(SCgObject* obj, l)
{
if(! obj->parentItem())
obj->setPos(obj->scenePos() - bounds.topLeft());
}
foreach(SCgObject* obj, l)
{
if( obj->type() == QGraphicsItem::UserType + 3 ) // type SCgPair
obj->positionChanged();
}
}
示例4: relayout
void MFreestyleLayoutPolicy::relayout()
{
Q_D(MFreestyleLayoutPolicy);
QPointF topLeft = contentsArea().topLeft();
QList<QRectF> new_geometries;
const int size = count();
for (int i = 0; i < size; ++i) {
new_geometries << itemGeometry(i);
d->placeItem(i, new_geometries, topLeft, contentsArea().width());
}
QRectF area = contentsArea();
for (int i = 0; i < size; ++i) {
area = area.united(new_geometries.at(i));
setItemGeometry(i, new_geometries.at(i));
}
//if we have moved items outside of the bounding box, we need to invalidate the layout
//causing another relayout, but we have to be careful that we don't end up in an
//infinite loop because of this.
if (area.isValid() && !contentsArea().adjusted(-0.0000001, -0.0000001, 0.0000001, 0.0000001).contains(area)) //adjust for rounding errors
updateGeometry();
}
示例5: sizeHint
QSizeF MFreestyleLayoutPolicy::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
Q_D(const MFreestyleLayoutPolicy);
if (which == Qt::MaximumSize) {
// maximum size is the QWIDGETSIZE_MAX
QSizeF new_size = constraint;
if (new_size.width() < 0)
new_size.setWidth(QWIDGETSIZE_MAX);
if (new_size.height() < 0)
new_size.setHeight(QWIDGETSIZE_MAX);
return new_size;
}
// minimum and preferred size of a layout is the bounding box of the children
int i = count();
QRectF boundingBox;
while (--i >= 0) {
// iterate through children
boundingBox = boundingBox.united(itemGeometry(i));
}
qreal right, bottom;
d->layout->getContentsMargins(NULL, NULL, &right, &bottom);
return QSizeF(boundingBox.right() + right - d->layout->geometry().left(), boundingBox.bottom() + bottom - d->layout->geometry().top());
}
示例6: pageItemBounds
QRectF QgsLayout::pageItemBounds( int page, bool visibleOnly ) const
{
//start with an empty rectangle
QRectF bounds;
//add all QgsLayoutItems on page
const QList<QGraphicsItem *> itemList = items();
for ( QGraphicsItem *item : itemList )
{
const QgsLayoutItem *layoutItem = dynamic_cast<const QgsLayoutItem *>( item );
if ( layoutItem && layoutItem->type() != QgsLayoutItemRegistry::LayoutPage && layoutItem->page() == page )
{
if ( visibleOnly && !layoutItem->isVisible() )
continue;
//expand bounds with current item's bounds
if ( bounds.isValid() )
bounds = bounds.united( item->sceneBoundingRect() );
else
bounds = item->sceneBoundingRect();
}
}
return bounds;
}
示例7: boundingRectFor
QRectF ShadowEffect::boundingRectFor(const QRectF &rect) const
{
qreal padding = m_blurRadius * 2;
return rect.united(
rect.translated(m_xOffset, m_yOffset)
.adjusted(-padding, -padding, padding, padding)
);
}
示例8: boundingRect
QRectF CopyFilterGUIConnectionItem::boundingRect() const
{
QRectF rect = QGraphicsLineItem::boundingRect();
QPointF p2 = line().p2();
QRectF rect2 = QRectF(p2.x() - maxArrowSize, p2.y() - maxArrowSize, 2 * maxArrowSize, 2 * maxArrowSize);
return rect.united(rect2);
}
示例9: foreach
void RuntimeController::Private::updateActiveRegion()
{
Configuration configuration = q->activeConfiguration();
// Calculate the bounding rect of all states in that are currently active
QRectF activeRegion;
foreach (State* state, configuration) {
activeRegion = activeRegion.united(state->boundingRect());
}
示例10: onStitchClicked
void StitcherWorkspace::onStitchClicked() {
QList<QGraphicsItem *> it = _stitcherView->items();
if(it.size() < 2) {
return;
}
QRectF combined;
for(int i = 0; i < it.size(); i++) {
if(QString("ImageItem") == it[i]->data(0)) {
/* we have an image item */
ImageItem * ii = qgraphicsitem_cast<ImageItem *>(it[i]);
combined = combined.united(ii->sceneBoundingRect());
}
}
/* we're gonna assume they all have the same scaling */
combined = _stitcherView->selectedImage()->mapRectFromScene(combined);
qDebug("Combined with relative positions:");
Image * a = sp_image_alloc(combined.width(),combined.height(),1);
for(int i = 0; i < it.size(); i++) {
if(QString("ImageItem") == it[i]->data(0)) {
QPointF p = it[i]->mapToScene(0,0);
QPointF local_p = _stitcherView->selectedImage()->mapFromScene(p);
qDebug("x = %f y = %f",local_p.x()-combined.x(),local_p.y()-combined.y());
}
}
for(int x = 0; x<sp_image_x(a); x++) {
for(int y = 0; y<sp_image_y(a); y++) {
int mask = 0;
Complex value = sp_cinit(0,0);
QPointF p = _stitcherView->selectedImage()->mapToScene(QPointF(combined.x()+x,combined.y()+y));
for(int i = 0; i < it.size(); i++) {
if(QString("ImageItem") == it[i]->data(0)) {
/* we have an image item */
ImageItem * ii = qgraphicsitem_cast<ImageItem *>(it[i]);
QPointF local_p = it[i]->mapFromScene(p);
if(it[i]->contains(local_p)) {
/* we're in business */
value = sp_cadd(value,sp_image_get(ii->getImage(),local_p.x(),local_p.y(),0));
mask++;
}
}
}
if(mask) {
sp_cscale(value,1.0/mask);
}
a->detector->image_center[0] = -combined.x();
a->detector->image_center[1] = -combined.y();
a->detector->image_center[2] = 0;
sp_image_set(a,x,y,0,value);
sp_image_mask_set(a,x,y,0,mask);
}
}
ImageItem * item = new ImageItem(a,QString(),_stitcherView,NULL);
_stitcherView->addImage(item);
item->update();
}
示例11: updateMultiSelectionRect
void ChatLog::updateMultiSelectionRect()
{
if (selectionMode == Multi && selFirstRow >= 0 && selLastRow >= 0)
{
QRectF selBBox;
selBBox = selBBox.united(lines[selFirstRow]->sceneBoundingRect());
selBBox = selBBox.united(lines[selLastRow]->sceneBoundingRect());
if (selGraphItem->rect() != selBBox)
scene->invalidate(selGraphItem->rect());
selGraphItem->setRect(selBBox);
selGraphItem->show();
}
else
{
selGraphItem->hide();
}
}
示例12: boundingRect
QRectF PolyQtAnnotation::boundingRect() const {
QRectF bRect;
if (_annotation) {
QRectF cpRect = _currentPath.controlPointRect();
QPointF tl = cpRect.topLeft() - QPointF(3 * _lineAnnotationSelectedThickness, 3 * _lineAnnotationSelectedThickness);
QPointF br = cpRect.bottomRight() + QPointF(3 * _lineAnnotationSelectedThickness, 3 * _lineAnnotationSelectedThickness);
bRect = bRect.united(QRectF(tl, br));
}
return bRect;
}
示例13: boundingRect
QRectF UBGraphicsProtractor::boundingRect() const
{
QPointF center = rect().center();
qreal centerX = center.x();
qreal centerY = center.y();
QRectF bounds = resizeButtonRect().adjusted(centerX, centerY, centerX, centerY);
bounds = bounds.united(closeButtonRect().adjusted(centerX, centerY, centerX, centerY));
bounds = bounds.united(resetButtonRect().adjusted(centerX, centerY, centerX, centerY));
QTransform t;
t.translate(centerX, centerY);
t.rotate(-mStartAngle);
t.translate(-centerX, -centerY);
bounds = t.mapRect(bounds);
bounds = bounds.united(QGraphicsEllipseItem::boundingRect());
return bounds;
}
示例14: frameRect
QRectF NonPdfCropping::frameRect () const
{
// The x(), y(), pos(), rect() and boundingRect() will return coordinates assuming origin at the initial position of
// each handle. So to get the coordinates in the window reference frame it takes a two step process like
// QGraphicsRectItem::mapRectToScene (QGraphicsRectItem::rect())
QRectF rectTL = m_handleTL->mapRectToScene (m_handleTL->boundingRect());
QRectF rectBR = m_handleBR->mapRectToScene (m_handleBR->boundingRect());
QRectF rectUnited = rectTL.united (rectBR);
return rectUnited;
}
示例15: boundingRect
QRectF KoShapeLayer::boundingRect() const
{
QRectF bb;
Q_FOREACH (KoShape* shape, shapes()) {
if (bb.isEmpty())
bb = shape->boundingRect();
else
bb = bb.united(shape->boundingRect());
}
return bb;
}