Exemple #1
0
void AbstractScrollArea::adjustScrollBars()
{
    if (m_horizontalScrollBarPolicy == Qt::ScrollBarAlwaysOff) {
        m_horizontalScrollBar->hide();
    } else {
        m_horizontalScrollBar->show();

        QRectF sbgeom = boundingRect();

        sbgeom.setTop(sbgeom.bottom() - m_horizontalScrollBar->boundingRect().height());
        sbgeom.setRight(sbgeom.right() - m_verticalScrollBar->boundingRect().width());
        m_horizontalScrollBar->setGeometry(sbgeom);
    }

    if (m_verticalScrollBarPolicy == Qt::ScrollBarAlwaysOff) {
        m_verticalScrollBar->hide();
        QRectF sbgeom = boundingRect();
        sbgeom.setLeft(sbgeom.right());
        sbgeom.setBottom(sbgeom.bottom());
        m_verticalScrollBar->setGeometry(sbgeom);
    } else {
        m_verticalScrollBar->show();

        QRectF sbgeom = boundingRect();

        sbgeom.setLeft(sbgeom.right() - m_verticalScrollBar->boundingRect().width());
        if (m_horizontalScrollBarPolicy != Qt::ScrollBarAlwaysOff)
            sbgeom.setBottom(sbgeom.bottom() - m_horizontalScrollBar->boundingRect().height());
        m_verticalScrollBar->setGeometry(sbgeom);
    }
}
void UIGraphicsZoomButton::updateAnimation()
{
    QRectF oldRect = geometry();
    QRectF newRect = oldRect;
    if (m_iDirection & UIGraphicsZoomDirection_Top)
        newRect.setTop(newRect.top() - m_iIndent);
    if (m_iDirection & UIGraphicsZoomDirection_Bottom)
        newRect.setBottom(newRect.bottom() + m_iIndent);
    if (m_iDirection & UIGraphicsZoomDirection_Left)
        newRect.setLeft(newRect.left() - m_iIndent);
    if (m_iDirection & UIGraphicsZoomDirection_Right)
        newRect.setRight(newRect.right() + m_iIndent);
    if (!(m_iDirection & UIGraphicsZoomDirection_Left) &&
        !(m_iDirection & UIGraphicsZoomDirection_Right))
    {
        newRect.setLeft(newRect.left() - m_iIndent / 2);
        newRect.setRight(newRect.right() + m_iIndent / 2);
    }
    if (!(m_iDirection & UIGraphicsZoomDirection_Top) &&
        !(m_iDirection & UIGraphicsZoomDirection_Bottom))
    {
        newRect.setTop(newRect.top() - m_iIndent / 2);
        newRect.setBottom(newRect.bottom() + m_iIndent / 2);
    }
    m_pForwardAnimation->setStartValue(oldRect);
    m_pForwardAnimation->setEndValue(newRect);
    m_pBackwardAnimation->setStartValue(newRect);
    m_pBackwardAnimation->setEndValue(oldRect);
}
Exemple #3
0
QRectF addBBox(QRectF r1, QRectF r2)
{   
    // Find smallest QRectF containing given rectangles

    QRectF n;
    // Set left border
    if (r1.left() <= r2.left() )
	n.setLeft(r1.left() );
    else
	n.setLeft(r2.left() );
	
    // Set top border	    
    if (r1.top() <= r2.top() )
	n.setTop(r1.top() );
    else
	n.setTop(r2.top() );
	
    // Set right border
    if (r1.right() <= r2.right() )
	n.setRight(r2.right() );
    else
	n.setRight(r1.right() );
	
    // Set bottom 
    if (r1.bottom() <= r2.bottom() )
	n.setBottom(r2.bottom() );
    else
	n.setBottom(r1.bottom() );
    return n;
}
void QOpacityTransferFunctionGraphicalView::setOpacityTransferFunction(const OpacityTransferFunction &opacityTransferFunction)
{
    scene()->clear();

    QList<double> keys = opacityTransferFunction.keys();
    QRectF rect;
    bool first = true;
    QOpacityTransferFunctionGraphicalViewNode *previousNode = 0;

    foreach (double x, keys)
    {
        double opacity = opacityTransferFunction.get(x);
        QOpacityTransferFunctionGraphicalViewNode *node = new QOpacityTransferFunctionGraphicalViewNode();
        node->setX(x);
        node->setY(opacity);
        node->setToolTip(QString("(%1, %2)").arg(x).arg(opacity));
        scene()->addItem(node);

        if (previousNode)
        {
            QOpacityTransferFunctionGraphicalViewLine *line = new QOpacityTransferFunctionGraphicalViewLine();
            line->setLeftNode(previousNode);
            line->setRightNode(node);
            previousNode->setRightLine(line);
            node->setLeftLine(line);
            scene()->addItem(line);
        }

        if (first)
        {
            first = false;
            rect.setLeft(x);
            rect.setRight(x);
            rect.setTop(opacity);
            rect.setBottom(opacity);
        }
        else
        {
            if (x < rect.left())
            {
                rect.setLeft(x);
            }
            if (x > rect.right())
            {
                rect.setRight(x);
            }
            if (opacity < rect.top())
            {
                rect.setTop(opacity);
            }
            if (opacity > rect.bottom())
            {
                rect.setBottom(opacity);
            }
        }

        previousNode = node;
    }
Exemple #5
0
void SearchDocumentJob::run()
{
    Q_ASSERT(m_document);

    for (int i = 0; i < m_document->numPages(); ++i) {
        int ipage = (startPage + i) % m_document->numPages();
        Poppler::Page *page = m_document->page(ipage);
    
        double sLeft, sTop, sRight, sBottom;
        float scaleW = 1.f / page->pageSizeF().width();
        float scaleH = 1.f / page->pageSizeF().height();
        bool found;
        found = page->search(m_search, sLeft, sTop, sRight, sBottom,
                             Poppler::Page::FromTop,
                             Poppler::Page::IgnoreCase);
        while (found) {
            QRectF result;
            result.setLeft(sLeft * scaleW);
            result.setTop(sTop * scaleH);
            result.setRight(sRight * scaleW);
            result.setBottom(sBottom * scaleH);
            m_matches.append(QPair<int, QRectF>(ipage, result));
            found = page->search(m_search, sLeft, sTop, sRight, sBottom,
                                 Poppler::Page::NextResult,
                                 Poppler::Page::IgnoreCase);
        }

        delete page;
    }
}
void StaffScene::setBoundries()
{
    QRectF rec = sceneRect();
    rec.setTop(rec.top() - noteProperties::noteDiameter);
    rec.setBottom(rec.bottom() + noteProperties::noteDiameter);
    setSceneRect(rec);
}
Exemple #7
0
void ResizeHandler::expandByChildren(QRectF &contents) const
{
	QVector<int> const sizeOfForestalling = mElementType.sizeOfForestalling();

	for (const QGraphicsItem * const childItem : mTargetNode.childItems()) {
		QRectF curChildItemBoundingRect = childBoundingRect(childItem, contents);

		if (curChildItemBoundingRect.width() == 0 || curChildItemBoundingRect.height() == 0) {
			continue;
		}

		// it seems to be more appropriate to use childItem->pos() but it causes
		// bad behaviour when dropping one element to another
		curChildItemBoundingRect.translate(childItem->scenePos() - mTargetNode.scenePos());

		contents.setLeft(qMin(curChildItemBoundingRect.left() - sizeOfForestalling[0]
						, contents.left()));
		contents.setRight(qMax(curChildItemBoundingRect.right() + sizeOfForestalling[2]
						, contents.right()));
		contents.setTop(qMin(curChildItemBoundingRect.top() - sizeOfForestalling[1]
						, contents.top()));
		contents.setBottom(qMax(curChildItemBoundingRect.bottom() + sizeOfForestalling[3]
						, contents.bottom()));
	}
}
Exemple #8
0
TimelineBar::Marker *TimelineBar::findMarker(QVector<Marker> &markers, QRectF markerRect, QPointF pos)
{
  QFontMetrics fm(Formatter::PreferredFont());

  for(Marker &m : markers)
  {
    QRectF r = markerRect;
    r.setLeft(qMax(m_markerRect.left() + borderWidth * 2, offsetOf(m.eidStart)));
    r.setRight(qMin(m_markerRect.right() - borderWidth, offsetOf(m.eidEnd + 1)));
    r.setHeight(fm.height() + borderWidth * 2);

    if(r.width() <= borderWidth * 2)
      continue;

    if(r.contains(pos))
    {
      return &m;
    }

    if(!m.children.isEmpty() && m.expanded)
    {
      QRectF childRect = r;
      childRect.setTop(r.bottom() + borderWidth * 2);
      childRect.setBottom(markerRect.bottom());

      Marker *res = findMarker(m.children, childRect, pos);

      if(res)
        return res;
    }
  }

  return NULL;
}
Exemple #9
0
/*!
  \return Bounding rectangle of all samples.
  For an empty series the rectangle is invalid.
*/
QRectF QwtPlotHistogram::boundingRect() const
{
    QRectF rect = d_series->boundingRect();
    if ( !rect.isValid() )
        return rect;

    if ( orientation() == Qt::Horizontal )
    {
        rect = QRectF( rect.y(), rect.x(),
            rect.height(), rect.width() );

        if ( rect.left() > d_data->baseline )
            rect.setLeft( d_data->baseline );
        else if ( rect.right() < d_data->baseline )
            rect.setRight( d_data->baseline );
    }
    else
    {
        if ( rect.bottom() < d_data->baseline )
            rect.setBottom( d_data->baseline );
        else if ( rect.top() > d_data->baseline )
            rect.setTop( d_data->baseline );
    }

    return rect;
}
Exemple #10
0
QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const
{
    Q_Q(const QWidgetWindow);
    const QWidget *widget = q->widget();
    if (!widget->isWindow() || !widget->hasHeightForWidth())
        return QRect();
    const QSize oldSize = rect.size().toSize();
    const QSize newSize = QLayout::closestAcceptableSize(widget, oldSize);
    if (newSize == oldSize)
        return QRectF();
    const int dw = newSize.width() - oldSize.width();
    const int dh = newSize.height() - oldSize.height();
    QRectF result = rect;
    const QRectF currentGeometry(widget->geometry());
    const qreal topOffset = result.top() - currentGeometry.top();
    const qreal bottomOffset = result.bottom() - currentGeometry.bottom();
    if (qAbs(topOffset) > qAbs(bottomOffset))
        result.setTop(result.top() - dh); // top edge drag
    else
        result.setBottom(result.bottom() + dh); // bottom edge drag
    const qreal leftOffset = result.left() - currentGeometry.left();
    const qreal rightOffset = result.right() - currentGeometry.right();
    if (qAbs(leftOffset) > qAbs(rightOffset))
        result.setLeft(result.left() - dw); // left edge drag
    else
        result.setRight(result.right() + dw); // right edge drag
    return result;
}
/** If needed, recalculate the cached bounding rectangles of all assemblies. */
void UnwrappedSurface::cacheAllAssemblies() {
  if (!m_assemblies.empty())
    return;

  for (size_t i = 0; i < m_unwrappedDetectors.size(); ++i) {
    const UnwrappedDetector &udet = m_unwrappedDetectors[i];

    if (!udet.detector)
      continue;
    // Get the BARE parent (not parametrized) to speed things up.
    const Mantid::Geometry::IComponent *bareDet =
        udet.detector->getComponentID();
    const Mantid::Geometry::IComponent *parent = bareDet->getBareParent();
    if (parent) {
      QRectF detRect;
      detRect.setLeft(udet.u - udet.width);
      detRect.setRight(udet.u + udet.width);
      detRect.setBottom(udet.v - udet.height);
      detRect.setTop(udet.v + udet.height);
      Mantid::Geometry::ComponentID id = parent->getComponentID();
      QRectF &r = m_assemblies[id];
      r |= detRect;
      calcAssemblies(parent, r);
    }
  }
}
void CallbackBoundingRects::mergeCoordinates (const QPointF &pos,
                                              QRectF &boundingRect)
{
  bool newGraphLeft   = m_isEmpty;
  bool newGraphTop    = m_isEmpty;
  bool newGraphRight  = m_isEmpty;
  bool newGraphBottom = m_isEmpty;

  if (!newGraphLeft) {
    newGraphLeft   = (pos.x() < boundingRect.left());
  }
  if (!newGraphTop) {
    newGraphTop    = (pos.y() < boundingRect.top());
  }
  if (!newGraphRight) {
    newGraphRight  = (boundingRect.right() < pos.x());
  }
  if (!newGraphBottom) {
    newGraphBottom = (boundingRect.bottom() < pos.y());
  }

  if (newGraphLeft) {
    boundingRect.setLeft (pos.x());
  }
  if (newGraphTop) {
    boundingRect.setTop (pos.y());
  }
  if (newGraphRight) {
    boundingRect.setRight (pos.x());
  }
  if (newGraphBottom) {
    boundingRect.setBottom (pos.y());
  }
}
static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect)
{
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_SCISSOR_TEST);
    glDisable(GL_BLEND);
    glViewport(0, 0, viewport.width(), viewport.height());

    QGLShaderProgram *blitProgram =
        QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram();
    blitProgram->bind();
    blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/);

    // The shader manager's blit program does not multiply the
    // vertices by the pmv matrix, so we need to do the effect
    // of the orthographic projection here ourselves.
    QRectF r;
    qreal w = viewport.width();
    qreal h = viewport.height();
    r.setLeft((targetRect.left() / w) * 2.0f - 1.0f);
    if (targetRect.right() == (viewport.width() - 1))
        r.setRight(1.0f);
    else
        r.setRight((targetRect.right() / w) * 2.0f - 1.0f);
    r.setBottom((targetRect.top() / h) * 2.0f - 1.0f);
    if (targetRect.bottom() == (viewport.height() - 1))
        r.setTop(1.0f);
    else
        r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f);

    drawTexture(r, texture, texSize, sourceRect);
}
Exemple #14
0
void QGraphVizPIP::drawForeground(QPainter *painter, const QRectF &rect)
{
    if(!rect.intersects(m_ViewPortRect)) {
        return;
    }

    if(m_ViewPortRect.contains(scene()->sceneRect())) {
        return;
    }

    QColor color(Qt::red);

    QPen pen;
    pen.setColor(color);
    painter->setPen(pen);

    QBrush brush;
    color.setAlphaF(.1);
    brush.setColor(color);
    brush.setStyle(Qt::SolidPattern);
    painter->setBrush(brush);

    QRectF sceneRect = this->sceneRect().adjusted(-10,-10,20,20);

    QRectF viewPortRect;
    viewPortRect.setLeft(qMax(sceneRect.left(), m_ViewPortRect.left()));
    viewPortRect.setTop(qMax(sceneRect.top(), m_ViewPortRect.top()));
    viewPortRect.setRight(qMin(sceneRect.right(), m_ViewPortRect.right()));
    viewPortRect.setBottom(qMin(sceneRect.bottom(), m_ViewPortRect.bottom()));

    painter->drawRect(viewPortRect);
}
Exemple #15
0
static void qsgsimpletexturenode_update(QSGGeometry *g,
                                        QSGTexture *texture,
                                        const QRectF &rect,
                                        QRectF sourceRect,
                                        QSGSimpleTextureNode::TextureCoordinatesTransformMode texCoordMode)
{
    if (!texture)
        return;

    if (!sourceRect.width() || !sourceRect.height()) {
        QSize ts = texture->textureSize();
        sourceRect = QRectF(0, 0, ts.width(), ts.height());
    }

    // Maybe transform the texture coordinates
    if (texCoordMode.testFlag(QSGSimpleTextureNode::MirrorHorizontally)) {
        float tmp = sourceRect.left();
        sourceRect.setLeft(sourceRect.right());
        sourceRect.setRight(tmp);
    }
    if (texCoordMode.testFlag(QSGSimpleTextureNode::MirrorVertically)) {
        float tmp = sourceRect.top();
        sourceRect.setTop(sourceRect.bottom());
        sourceRect.setBottom(tmp);
    }

    QSGGeometry::updateTexturedRectGeometry(g, rect, texture->convertToNormalizedSourceRect(sourceRect));
}
void PDFSelection::copy()
{
    if(d->textReply) {
        d->textReply->close();
        delete d->textReply;
        d->textReply = 0;
    }

    PDFPage *page = d->currentPage;
    if(!page) {
        qDebug() << "Invalid page";
        return;
    }

    QRectF geom = geometry();
    geom.setLeft(geom.left() + d->documentOffset.x());
    geom.setRight(geom.right() + d->documentOffset.x());
    geom.setTop((geom.top() + d->documentOffset.y()) - page->positionInDocument() );
    geom.setBottom((geom.bottom() + d->documentOffset.y()) - page->positionInDocument() );
    QRectF sel(QPointF(geom.left() / page->width(), geom.top() / page->height()), QPointF(geom.right() / page->width(), geom.bottom() / page->height()));
        
    QString arguments = QString("page=%1&top=%2&right=%3&bottom=%4&left=%5").arg(page->pageNumber()).arg(sel.top()).arg(sel.right()).arg(sel.bottom()).arg(sel.left());
    d->textReply = d->document->networkManager()->get(d->document->buildRequest("text", arguments));
    connect(d->textReply, SIGNAL(finished()), SLOT(textRequestFinished()));
}
void RenderedItemInterface::redraw(bool withChildren)
{
    QRectF itemPixelRect = convertUnit(d_ptr->rect, Millimeter, Pixel, d_ptr->dpi);

#if QT_VERSION >= 0x050000
    itemPixelRect.setBottom(itemPixelRect.bottom() -1);
    itemPixelRect.setRight(itemPixelRect.right() -1);
#endif

    QPointF absPos = absolutePixelPos();
    QPointF pos;
    if (parentItem()) {
        pos = parentItem()->mapFromScene(absPos);
        //        qDebug() << "parentPos" << parentItem()->pos();
    } else {
        pos = absPos;
    }
    //    qDebug() << "pos" << pos;
    setRect(0,0, itemPixelRect.width(), itemPixelRect.height());

    setRotation(-d_ptr->rotation);

    QPointF transPos = BaseItemInterface::transformedPos(d_ptr, QRectF(pos, itemPixelRect.size()));
    setPos(transPos);

    if (withChildren) {
        QList<QGraphicsItem *> list = childItems();
        foreach (QGraphicsItem * item, list) {
            if (item->parentItem() == this && item->type() == RenderedItemInterface::Type) {
                RenderedItemInterface * rendItem = static_cast<RenderedItemInterface *>(item);
                rendItem->redraw(true);
            }
        }
    }
}
Exemple #18
0
void MiniMap::updateMap()
{
	QRectF maxRect;
	maxRect.setLeft( sceneRect().x() < visibleRect.x() ? sceneRect().x() : visibleRect.x() );
	maxRect.setTop( sceneRect().y() < visibleRect.y() ? sceneRect().y() : visibleRect.y() );
	maxRect.setRight( (sceneRect().x() + sceneRect().width()) > (visibleRect.x()+visibleRect.width())
			? (sceneRect().x() + sceneRect().width()) : (visibleRect.x()+visibleRect.width()));
	maxRect.setBottom( (sceneRect().y() + sceneRect().height()) > (visibleRect.y()+visibleRect.height())
			? (sceneRect().y() + sceneRect().height()) : (visibleRect.y()+visibleRect.height()));

	qreal xScale = (width() - 2*frameWidth() - 2*margin) / maxRect.width();
	qreal yScale = (height() - 2*frameWidth() - 2*margin) / maxRect.height();
	qreal scale = xScale < yScale ? xScale : yScale;

	qreal rectX = margin + (visibleRect.x() - maxRect.x())*scale;
	qreal rectY = margin + (visibleRect.y() - maxRect.y())*scale;

	if (xScale < yScale) rectY += (height() - 2*(frameWidth() + margin) - maxRect.height()*scale) / 2;
	else rectX += (width() - 2*(frameWidth() + margin) - maxRect.width()*scale) / 2;

	// Below we subtract 0.5 and take the ceiling. This rounds the number. We further subtract 1 in order to compensate
	// for the pen width of the drawn rectangle.
	drawnRect.setRect(rectX, rectY, ceil(visibleRect.width()*scale - 1.5), ceil(visibleRect.height()*scale - 1.5));

	setTransform(QTransform::fromScale(scale,scale).translate(margin, margin));

	viewport()->update();
}
  void HeightMapEditor::onViewChanged(const QRectF & rect)
  {
    if (!myGraph) return;
    if (myUi->renderView->scene()->children().count() > 50)
    {
      QList<QGraphicsItem *> items = myUi->renderView->scene()->items();
      for (QGraphicsItem * i : items)
        if (!i->isVisible())
          myUi->renderView->scene()->removeItem(i);
    }

    QRectF trect;

    trect.setLeft(rect.left() - fmod(rect.left(), myCellSize.width()));
    trect.setTop(rect.top() - fmod(rect.top(), myCellSize.height()));
    trect.setRight(rect.right() - fmod(rect.right(), myCellSize.width()));
    trect.setBottom(rect.bottom() - fmod(rect.bottom(), myCellSize.height()));

    for (double y = trect.top() - fmod(trect.top(), myCellSize.height());
         y < trect.bottom() + myCellSize.height() - fmod(trect.bottom(), myCellSize.height());
         y += myCellSize.height())
      for (double x = trect.left() - fmod(trect.left(), myCellSize.width());
           x < trect.right() + myCellSize.width() - fmod(trect.right(), myCellSize.width());
           x += myCellSize.width())
      {
        QRectF r(x,y,myCellSize.width(), myCellSize.height());
        generateRect(r);
      }
  }
Exemple #20
0
QRectF ODrawClient::getRect(const MSO::OfficeArtClientAnchor& clientAnchor)
{
    const MSO::XlsOfficeArtClientAnchor* anchor = clientAnchor.anon.get<MSO::XlsOfficeArtClientAnchor>();
    if (anchor) {
        QRectF r;
        qreal colWidth = columnWidth(m_sheet, anchor->colL);
        r.setLeft(offset(colWidth, anchor->dxL, 1024));
        if (anchor->colR == anchor->colL) {
            r.setRight(offset(colWidth, anchor->dxR, 1024));
        } else {
            qreal width = colWidth - r.left();
            for (int col = anchor->colL + 1; col < anchor->colR; ++col) {
                width += columnWidth(m_sheet, col);
            }
            width += offset(columnWidth(m_sheet, anchor->colR), anchor->dxR, 1024);
            r.setWidth(width);
        }
        qreal rowHgt = rowHeight(m_sheet, anchor->rwT);
        r.setTop(offset(rowHgt, anchor->dyT, 256));
        if (anchor->rwT == anchor->rwB) {
            r.setBottom(offset(rowHgt, anchor->dyB, 256));
        } else {
            qreal height = rowHgt - r.top();
            for (int row = anchor->rwT + 1; row < anchor->rwB; ++row) {
                height += rowHeight(m_sheet, row);
            }
            height += offset(rowHeight(m_sheet, anchor->rwB), anchor->dyB, 256);
            r.setHeight(height);
        }
        return r;
    } else {
        qDebug() << "Invalid client anchor!";
    }
    return QRectF();
}
Exemple #21
0
void BlurItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
  QGraphicsRectItem::mouseMoveEvent(event);

  const QPointF pos = event->scenePos();
  QRectF r;

  r.setTopLeft(m_point);
  r.setBottomRight(event->scenePos());

  if (r.width() < 0) {
    r.setLeft(pos.x());
    r.setRight(m_point.x());
  }

  if (r.height() < 0) {
    r.setTop(pos.y());
    r.setBottom(m_point.y());
  }

  r = r.intersected(m_item->scene()->sceneRect());

  setRect(r);
  setSelected(true);
  m_item->setOffset(r.topLeft());

  reload(m_pixmap);
}
Exemple #22
0
/*!
  Draw the symbol when it is in Box style.

  \param painter Painter
  \param rect Directed rectangle

  \sa draw()
*/
void QwtColumnSymbol::drawBox( QPainter *painter,
    const QwtColumnRect &rect ) const
{
    QRectF r = rect.toRect();
    if ( QwtPainter::roundingAlignment( painter ) )
    {
        r.setLeft( qRound( r.left() ) );
        r.setRight( qRound( r.right() ) );
        r.setTop( qRound( r.top() ) );
        r.setBottom( qRound( r.bottom() ) );
    }

    switch ( d_data->frameStyle )
    {
        case QwtColumnSymbol::Raised:
        {
            qwtDrawPanel( painter, r, d_data->palette, d_data->lineWidth );
            break;
        }
        case QwtColumnSymbol::Plain:
        {
            qwtDrawBox( painter, r, d_data->palette, d_data->lineWidth );
            break;
        }
        default:
        {
            painter->fillRect( r, d_data->palette.window() );
        }
    }
}
void QReportWidgetResizer::handleMoving(QPointF point)
{
    QReportResizeHandle *s = qobject_cast<QReportResizeHandle*> (sender());
    QRectF rc = resizeRect;

    QReportMoveEvent e(point, point);
    emit pointGridNeeded(&e);

    if (!e.isAccepted()) return;

    if (s->resizeDirection() & ::Top) rc.setTop(e.point().y());
    if (s->resizeDirection() & ::Left) rc.setLeft(e.point().x());
    if (s->resizeDirection() & ::Right) rc.setRight(e.point().x());
    if (s->resizeDirection() & ::Bottom) rc.setBottom(e.point().y());

    if(_selectedWidgets.count() == 1){
        if(rc.width() < _selectedWidgets.at(0)->minimumSize().width())
            rc.setWidth(_selectedWidgets.at(0)->minimumSize().width());
        if(rc.height() < _selectedWidgets.at(0)->minimumSize().height())
            rc.setHeight(_selectedWidgets.at(0)->minimumSize().height());
    }

    if (rc.isValid()) {
        setResezeHandlePos(s, e.point());

        resizeRect = rc;
        proccessNewRect(rc);

        setHandlesOnItem(rc);
    }//if
}
/*!
   \return Bounding rectangle of the data
   \sa QwtPlotRasterItem::interval()
*/
QRectF QwtPlotRasterItem::boundingRect() const
{
    const QwtInterval intervalX = interval( Qt::XAxis );
    const QwtInterval intervalY = interval( Qt::YAxis );

    if ( !intervalX.isValid() && !intervalY.isValid() )
        return QRectF(); // no bounding rect

    QRectF r;

    if ( intervalX.isValid() )
    {
        r.setLeft( intervalX.minValue() );
        r.setRight( intervalX.maxValue() );
    }
    else
    {
        r.setLeft(-0.5 * FLT_MAX);
        r.setWidth(FLT_MAX);
    }

    if ( intervalY.isValid() )
    {
        r.setTop( intervalY.minValue() );
        r.setBottom( intervalY.maxValue() );
    }
    else
    {
        r.setTop(-0.5 * FLT_MAX);
        r.setHeight(FLT_MAX);
    }

    return r.normalized();
}
static QRectF qwtExpandedZoomRect( const QRectF &zoomRect, const QSizeF &minSize,
    const QwtTransform* transformX, const QwtTransform* transformY )
{
    QRectF r = zoomRect;

    if ( minSize.width() > r.width() )
    {
        const QwtInterval intv = qwtExpandedZoomInterval(
            r.left(), r.right(), minSize.width(), transformX );

        r.setLeft( intv.minValue() );
        r.setRight( intv.maxValue() );
    }

    if ( minSize.height() > r.height() )
    {
        const QwtInterval intv = qwtExpandedZoomInterval(
            zoomRect.top(), zoomRect.bottom(), minSize.height(), transformY );

        r.setTop( intv.minValue() );
        r.setBottom( intv.maxValue() );
    }

    return r;
}
Exemple #26
0
void LineSegmentPlot::updateDataLimits()
{
    qDebug() << Q_FUNC_INFO;
    int xLen = xSize(), yLen = ySize(), endXLen = m_endX.size(), endYLen = m_endY.size();
    int N = qMin( qMin(xLen, yLen), qMin(endXLen, endYLen) );
    m_dataSize = N;

    qreal minX = Inf, maxX = -Inf, minY = Inf, maxY = -Inf;
    // Calculate the y limits
    RangeValues yrng = ArrayUtil::limits(yData());
    minY = yrng.min;
    maxY = yrng.max;

    yrng = ArrayUtil::limits(m_endY);
    minY = qMin(minY, yrng.min);
    maxY = qMax(maxY, yrng.max);

    RangeValues xrng = ArrayUtil::limits(xData());
    minX = xrng.min;
    maxX = xrng.max;

    xrng = ArrayUtil::limits(m_endX);
    minX = qMin(minX, xrng.min);
    maxX = qMax(maxX, xrng.max);

    QRectF newLim;
    newLim.setLeft(minX);
    newLim.setTop(minY);
    newLim.setRight(maxX);
    newLim.setBottom(maxY);
    setDataLimits(newLim);
}
void ExperimentGraphSubObjectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
	Q_UNUSED(widget);
	if ((option->state & QStyle::State_Selected) && (nItemStateFlags & QStyle::State_Selected))
	{
		fCurrent.setBold(true);
		pBrush.setColor(Qt::green);
		pBrush.setStyle(Qt::SolidPattern);
		pPen.setColor(Qt::green);
	}
	else if ((option->state & QStyle::State_MouseOver) && (nItemStateFlags & QStyle::State_MouseOver))
	{
		fCurrent.setBold(true);
		pBrush.setColor(Qt::lightGray);
		pBrush.setStyle(Qt::SolidPattern);
		pPen.setColor(Qt::yellow);
	}
	else
	{
		fCurrent.setBold(false);
		pBrush.setColor(Qt::blue);
		//pBrush.setStyle(Qt::NoBrush);
		pBrush.setColor(QColor(233,233,233));
		pBrush.setStyle(Qt::SolidPattern);
		pPen.setColor(Qt::blue);
	}

	////Outer-Box
	painter->setPen(pPen);
	painter->setBrush(pBrush);
	painter->setRenderHint(QPainter::Antialiasing);
	painter->drawPath(sBoundingBoxPath);

	////Header-Text
	QRectF rectInnerObject = QRectF(rBoundingBox.left(), rBoundingBox.top(), rBoundingBox.width(), rBoundingBox.height() / (1 + mapSubItemIDToStringList.count()));
	fCurrent.setPointSizeF(rectInnerObject.height()/3);
	fCurrent.setItalic(false);
	painter->setFont(fCurrent);
	pPen.setColor(Qt::darkBlue);
	painter->setPen(pPen);
	pBrush.setStyle(Qt::NoBrush);
	painter->setBrush(pBrush);
	painter->drawText(rectInnerObject, Qt::AlignCenter | Qt::AlignVCenter, " " + sHeaderText);//Qt::AlignHCenter | Qt::AlignTop, "FINALIZATIONS:"
	
	////Sub-Items
	int nItemHeight = rBoundingBox.height() / (mapSubItemIDToStringList.count() + 1);
	if (mapSubItemIDToStringList.count() == mExpGraphSubObjectNameToTextItems.count())
	{
		QMapIterator<int, QString> iterSub(mapSubItemIDToStringList);
		while (iterSub.hasNext())
		{
			iterSub.next();
			rectInnerObject.setTop(rectInnerObject.top() + nItemHeight);
			rectInnerObject.setBottom(rectInnerObject.top() + nItemHeight);
			ExperimentGraphSubObjectTextItem *tmpExpGraphSubTextItem = mExpGraphSubObjectNameToTextItems.value(iterSub.value(), NULL); //mExpGraphSubObjectNameToTextItems.value(lSubItemTextList[i]);
			if (tmpExpGraphSubTextItem)
				tmpExpGraphSubTextItem->setGeometry(rectInnerObject);
		}
	}
}
Exemple #28
0
 void VpGrid::drawReference(GridGC &gridGC)
 {
     int x,y;
     VpGC *vpgc = gridGC.m_gc;
     QPainter *gc = vpgc->getGC();

     // Assuming QPainter has already established begin().
     gc->setRenderHint(QPainter::Antialiasing, true);

     if (m_referenceStyle == VpGrid::REFSTYLE_SQUARE)
     {
         // Set the pen.
         QPen pen;
         pen.setStyle(Qt::NoPen);
         gc->setPen(pen);
         // Set the brush.
         QBrush brush;
         brush.setColor(m_referenceColor);
         brush.setStyle(Qt::SolidPattern);
         gc->setBrush(brush);

         QRectF origin;
         origin.setLeft(-1.5 + m_xAlignment);
         origin.setRight(1.5 + m_xAlignment);
         origin.setBottom(-1.5 + m_yAlignment);
         origin.setTop(1.5 + m_yAlignment);

         gc->drawRect(origin);
     } else if (m_referenceStyle == VpGrid::REFSTYLE_CIRCLE)
     {
         // Set the pen.
         QPen pen;
         pen.setStyle(Qt::NoPen);
         gc->setPen(pen);
         // Set the brush.
         QBrush brush;
         brush.setColor(m_referenceColor);
         brush.setStyle(Qt::SolidPattern);
         gc->setBrush(brush);

         gc->drawEllipse(QPoint(m_xAlignment, m_yAlignment), 2, 2);
     } else
     {
         // Set the pen, no brush.
         QPen pen;
         pen.setColor(m_referenceColor);
         pen.setStyle(Qt::SolidLine);
         pen.setWidth(2);
         gc->setPen(pen);

         // Create a 'X' pattern.
         QLineF cross[2];
         cross[0].setLine(-1.5 + m_xAlignment, -1.5 + m_yAlignment, 1.5 + m_xAlignment, 1.5 + m_yAlignment);
         cross[1].setLine(-1.5 + m_xAlignment, 1.5 + m_yAlignment, 1.5 + m_xAlignment, -1.5 + m_yAlignment);
         gc->drawLines(cross, 2);
     }

     //delete gc;
 }
/*!
  \return Bounding rectangle of all samples.
  For an empty series the rectangle is invalid.
*/
QRectF QwtPlotMultiBarChart::boundingRect() const
{
    const size_t numSamples = dataSize();

    if ( numSamples == 0 )
        return QwtPlotSeriesItem::boundingRect();

    const double baseLine = baseline();

    QRectF rect;

    if ( d_data->style != QwtPlotMultiBarChart::Stacked )
    {
        rect = QwtPlotSeriesItem::boundingRect();

        if ( rect.height() >= 0 )
        {
            if ( rect.bottom() < baseLine )
                rect.setBottom( baseLine );
            if ( rect.top() > baseLine )
                rect.setTop( baseLine );
        }
    }
    else
    {
        double xMin, xMax, yMin, yMax;

        xMin = xMax = 0.0;
        yMin = yMax = baseLine;

        const QwtSeriesData<QwtSetSample> *series = data();

        for ( size_t i = 0; i < numSamples; i++ )
        {
            const QwtSetSample sample = series->sample( i );
            if ( i == 0 )
            {
                xMin = xMax = sample.value;
            }
            else
            {
                xMin = qMin( xMin, sample.value );
                xMax = qMax( xMax, sample.value );
            }

            const double y = baseLine + sample.added();

            yMin = qMin( yMin, y );
            yMax = qMax( yMax, y );
        }
        rect.setRect( xMin, yMin, xMax - xMin, yMax - yMin );
    }

    if ( orientation() == Qt::Horizontal )
        rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );

    return rect;
}
void KoTextBlockBorderData::paint(QPainter &painter, const QRectF &bounds) const
{
    QRectF innerBounds = bounds;
    if (d->edges[Top].outerPen.widthF() > 0) {
        QPen pen = d->edges[Top].outerPen;
        painter.setPen(pen);
        const qreal t = bounds.top() + pen.widthF() / 2.0;
        painter.drawLine(QLineF(bounds.left(), t, bounds.right(), t));
        innerBounds.setTop(bounds.top() + d->edges[Top].distance + pen.widthF());
    }
    if (d->edges[Bottom].outerPen.widthF() > 0) {
        QPen pen = d->edges[Bottom].outerPen;
        painter.setPen(pen);
        const qreal b = bounds.bottom() - pen.widthF() / 2.0;
        innerBounds.setBottom(bounds.bottom() - d->edges[Bottom].distance - pen.widthF());
        painter.drawLine(QLineF(bounds.left(), b, bounds.right(), b));
    }
    if (d->edges[Left].outerPen.widthF() > 0) {
        QPen pen = d->edges[Left].outerPen;
        painter.setPen(pen);
        const qreal l = bounds.left() + pen.widthF() / 2.0;
        innerBounds.setLeft(bounds.left() + d->edges[Left].distance + pen.widthF());
        painter.drawLine(QLineF(l, bounds.top(), l, bounds.bottom()));
    }
    if (d->edges[Right].outerPen.widthF() > 0) {
        QPen pen = d->edges[Right].outerPen;
        painter.setPen(pen);
        const qreal r = bounds.right() - pen.widthF() / 2.0;
        innerBounds.setRight(bounds.right() - d->edges[Right].distance - pen.widthF());
        painter.drawLine(QLineF(r, bounds.top(), r, bounds.bottom()));
    }
    // inner lines
    if (d->edges[Top].innerPen.widthF() > 0) {
        QPen pen = d->edges[Top].innerPen;
        painter.setPen(pen);
        const qreal t = innerBounds.top() + pen.widthF() / 2.0;
        painter.drawLine(QLineF(innerBounds.left(), t, innerBounds.right(), t));
    }
    if (d->edges[Bottom].innerPen.widthF() > 0) {
        QPen pen = d->edges[Bottom].innerPen;
        painter.setPen(pen);
        const qreal b = innerBounds.bottom() - pen.widthF() / 2.0;
        painter.drawLine(QLineF(innerBounds.left(), b, innerBounds.right(), b));
    }
    if (d->edges[Left].innerPen.widthF() > 0) {
        QPen pen = d->edges[Left].innerPen;
        painter.setPen(pen);
        const qreal l = innerBounds.left() + pen.widthF() / 2.0;
        painter.drawLine(QLineF(l, innerBounds.top(), l, innerBounds.bottom()));
    }
    if (d->edges[Right].innerPen.widthF() > 0) {
        QPen pen = d->edges[Right].innerPen;
        painter.setPen(pen);
        const qreal r = innerBounds.right() - pen.widthF() / 2.0;
        painter.drawLine(QLineF(r, innerBounds.top(), r, innerBounds.bottom()));
    }
}