Example #1
0
QRectF boundsOfChildren( QGraphicsItem const * qgi )
{
    typedef QList<QGraphicsItem*> QGIL;
    QGIL ch( qboard::childItems(qgi) );
    QRectF r;
    for( QGIL::const_iterator it = ch.begin();
	 ch.end() != it; ++it )
    {
	QGraphicsItem const * x = *it;
	QRectF r2( x->mapToParent(x->pos()), x->boundingRect().size() );
	r = r.unite( r2 );
    }
    if(1  && ! r.isNull() ) qDebug() << "bounds of children ="<<r;
    return r;
}
QRectF k9CanvasSprite::boundingRect() const {

    QRectF r;
    if (m_pixmap){
        r=m_pixmap->boundingRect();
        r.moveTopLeft(m_pixmap->pos());
    }
    if (m_text) {
        QRectF r2=m_text->boundingRect();
        r2.moveTopLeft(m_text->pos());
        r=r.unite(r2);
    }
    r.adjust(-m_selsize,-m_selsize,m_selsize,m_selsize);

    return r;

}
Example #3
0
ShapeMoveStrategy::ShapeMoveStrategy( KoTool *tool, KoCanvasBase *canvas, const QPointF &clicked)
: KoInteractionStrategy(tool, canvas)
, m_start(clicked)
{
    QList<KoShape*> selectedShapes = canvas->shapeManager()->selection()->selectedShapes(KoFlake::TopLevelSelection);
    QRectF boundingRect;
    foreach(KoShape *shape, selectedShapes) {
        if( ! shape->isEditable() )
            continue;
        m_selectedShapes << shape;
        m_previousPositions << shape->position();
        m_newPositions << shape->position();
        boundingRect = boundingRect.unite( shape->boundingRect() );
    }
    KoSelection * selection = m_canvas->shapeManager()->selection();
    m_initialOffset = selection->absolutePosition( SelectionDecorator::hotPosition() ) - m_start;
    m_initialSelectionPosition = selection->position();
    m_canvas->snapGuide()->setIgnoredShapes( selection->selectedShapes( KoFlake::FullSelection ) );

    tool->setStatusText( i18n("Press ALT to hold x- or y-position.") );
}
Example #4
0
void MavPlot::_updateDataBounds () {
    bool first = true;
    QRectF allrect;
    for (dataplotmap::const_iterator s = _series.begin(); s != _series.end(); ++s) {
        const QWT_ABSTRACT_SERIESITEM * const that = s->second;
        // FIXME: now we can only do curves
        const QwtPlotCurve * const q = dynamic_cast<const QwtPlotCurve * const>(that);
        if (q) {
            QRectF rect = q->boundingRect();
            if (first) {
                first=false;
                allrect = rect;
            } else {
                #if (QT_VERSION > QT_VERSION_CHECK(5,0,0))
                    allrect = allrect.united(rect);
                #else
                    allrect = allrect.unite(rect);
                #endif
            }
        }
    }
    _databounds = allrect;
}