コード例 #1
0
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);
}
コード例 #2
0
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);
}
コード例 #3
0
ファイル: geometry.cpp プロジェクト: wcremeika/thesis
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;
}
コード例 #4
0
/*!
   \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();
}
コード例 #5
0
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;
    }
コード例 #6
0
/*!
  Calculate the the rectangle for the color bar

  \param rect Bounding rectangle for all components of the scale
  \return Rectangle for the color bar
*/
QRectF QwtScaleWidget::colorBarRect( const QRectF& rect ) const
{
    QRectF cr = rect;

    if ( d_data->scaleDraw->orientation() == Qt::Horizontal )
    {
        cr.setLeft( cr.left() + d_data->borderDist[0] );
        cr.setWidth( cr.width() - d_data->borderDist[1] + 1 );
    }
    else
    {
        cr.setTop( cr.top() + d_data->borderDist[0] );
        cr.setHeight( cr.height() - d_data->borderDist[1] + 1 );
    }

    switch ( d_data->scaleDraw->alignment() )
    {
        case QwtScaleDraw::LeftScale:
        {
            cr.setLeft( cr.right() - d_data->margin
                - d_data->colorBar.width );
            cr.setWidth( d_data->colorBar.width );
            break;
        }

        case QwtScaleDraw::RightScale:
        {
            cr.setLeft( cr.left() + d_data->margin );
            cr.setWidth( d_data->colorBar.width );
            break;
        }

        case QwtScaleDraw::BottomScale:
        {
            cr.setTop( cr.top() + d_data->margin );
            cr.setHeight( d_data->colorBar.width );
            break;
        }

        case QwtScaleDraw::TopScale:
        {
            cr.setTop( cr.bottom() - d_data->margin
                - d_data->colorBar.width );
            cr.setHeight( d_data->colorBar.width );
            break;
        }
    }

    return cr;
}
コード例 #7
0
ファイル: QGraphVizPIP.cpp プロジェクト: PTGF/QGraphViz
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);
}
コード例 #8
0
ファイル: ODrawClient.cpp プロジェクト: KDE/calligra-history
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();
}
コード例 #9
0
ファイル: MiniMap.cpp プロジェクト: JurajKubelka/Envision
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();
}
コード例 #10
0
void StaffScene::setBoundries()
{
    QRectF rec = sceneRect();
    rec.setTop(rec.top() - noteProperties::noteDiameter);
    rec.setBottom(rec.bottom() + noteProperties::noteDiameter);
    setSceneRect(rec);
}
コード例 #11
0
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());
  }
}
コード例 #12
0
ファイル: linesegmentplot.cpp プロジェクト: kitizz/nutmeg
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);
}
コード例 #13
0
ファイル: qwidgetwindow.cpp プロジェクト: jhribal/qtbase
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;
}
コード例 #14
0
  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);
      }
  }
コード例 #15
0
ファイル: qwt_plot_histogram.cpp プロジェクト: Aconex/pcp
/*!
  \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;
}
コード例 #16
0
/** 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);
    }
  }
}
コード例 #17
0
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()));
}
コード例 #18
0
ファイル: BlurItem.cpp プロジェクト: impomezia/screenpic
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);
}
コード例 #19
0
ファイル: componentitem.cpp プロジェクト: Munrek/ktechlab
void ComponentItem::initPins()
{
    QDomNode pinsNode;
    QDomNodeList list = m_svgDocument.elementsByTagName("g");
    for (int i=0;i<list.count();i++){
        QDomNamedNodeMap attrs = list.item(i).attributes();
        if (attrs.contains("id") &&
            attrs.namedItem("id").toAttr().value() == QString("pins")){
            pinsNode = list.item(i);
            break;
        }
    }
    if (pinsNode.isNull() || !pinsNode.hasChildNodes()){
        kWarning() << "No pins definition found for this component";
        return;
    }
    QDomElement pin = pinsNode.firstChildElement();
    while (!pin.isNull()) {
        QRectF pinRect;
        double r = pin.attribute("r").toDouble();
        pinRect.setLeft(pin.attribute("cx").toDouble());
        pinRect.setTop(pin.attribute("cy").toDouble());
        pinRect.setWidth(r*2);
        pinRect.setHeight(r*2);
        PinItem* p = new PinItem(pinRect, this, qobject_cast< IDocumentScene* >(scene()));
        p->setId(pin.attribute("id"));
        pin = pin.nextSiblingElement();
    }
}
コード例 #20
0
ファイル: QTable.cpp プロジェクト: Lavoro922/Erd-Creator
void QgraphicsItemTable::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)

    {

        QGraphicsItemResizable::paint(painter,option,widget);
        QPen pen;
        pen.setStyle(Qt::DashDotLine);
        QPen def = painter->pen();
        painter->setPen(pen);
        painter->drawRect(boundingRect());
        painter->setPen(def);
        QRectF bord = boundingRect();
        bord.setTop(bord.top()-my);
        bord.setLeft(bord.left()-mx);
        bord.setWidth(bord.width()-mw);
        bord.setHeight(bord.height()-mh);
        QRectF *bord2 = new QRectF();
        def.setColor(Qt::white);
        painter->setPen(def);
        painter->drawText(bord,Qt::AlignCenter,*(TableData->GetCaption()),bord2);
        qreal px = bord2->left()+TableData->getStrWidth();
        qreal py = bord2->top()+TableData->getStrHeight();
        bord2->setTop(bord2->top()-5);
        bord2->setHeight(bord2->height()+5);
        bord2->setLeft(bord2->left()-5);
        bord2->setWidth(bord2->width()+5);
        painter->fillRect(*bord2,QColor(128,128,128,100));
        painter->drawText(bord,Qt::AlignCenter,*(TableData->GetCaption()),bord2);
        if (GetgrabRefer()->GrabberItem()==this) painter->drawLine(px,py,px+5,py);

}
コード例 #21
0
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);
		}
	}
}
コード例 #22
0
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;
}
コード例 #23
0
ファイル: abstractscrollarea.cpp プロジェクト: Suneal/qt
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);
    }
}
コード例 #24
0
ファイル: QRoundedRect.cpp プロジェクト: maqiangddb/pc_code
void QRoundedRect::setRectA(const QRectF &rect)
{
    QRectF rectA = rect;
    qreal dDelta = 0.0;

    QPen pen = this->pen();
    int iPenWidth = pen.width();
    if (iPenWidth > 0)
    {
        dDelta = (iPenWidth * 1.0) / 2;
        rectA.setTop(rectA.top() + dDelta);
        rectA.setLeft(rectA.left() + dDelta);
        rectA.setWidth(rectA.width() - dDelta);
        rectA.setHeight(rectA.height() - dDelta);
    }

    qHeight = rectA.height();
    qWidth = rectA.width();
    Rpos.setX(rectA.x());
    Rpos.setY(rectA.y());

    QPainterPath path;
    path.addRoundedRect(rectA,xRadius,yRadius,Qt::AbsoluteSize);
    RectPath = path;
    setPath(RectPath);
    SetPattern(nPatternType);
}
コード例 #25
0
ファイル: qwt_column_symbol.cpp プロジェクト: Au-Zone/qwt
/*!
  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() );
        }
    }
}
コード例 #26
0
ファイル: SheetPrint.cpp プロジェクト: KDE/calligra-history
QRectF SheetPrint::documentArea(int page) const
{
    if (d->m_lnewPageListX.isEmpty() || d->m_lnewPageListY.isEmpty()) {
        return QRectF();
    }
    if (page - 1 > pageCount()) {
        return QRectF();
    }

    int horizontalIndex = 0;
    int verticalIndex = 0;
    if (d->m_settings->pageOrder() == PrintSettings::LeftToRight) {
        horizontalIndex = (page - 1) % d->m_lnewPageListX.count();
        verticalIndex = (page - 1) / d->m_lnewPageListX.count();
    } else {
        horizontalIndex = (page - 1) / d->m_lnewPageListY.count();
        verticalIndex = (page - 1) % d->m_lnewPageListY.count();
    }

    const PrintNewPageEntry horizontalParameters = d->m_lnewPageListX[horizontalIndex];
    const PrintNewPageEntry verticalParameters = d->m_lnewPageListY[verticalIndex];

    QRectF documentArea;
    documentArea.setLeft(horizontalParameters.offset());
    documentArea.setWidth(horizontalParameters.size());
    documentArea.setTop(verticalParameters.offset());
    documentArea.setHeight(verticalParameters.size());
    return documentArea;
}
コード例 #27
0
ファイル: QTable.cpp プロジェクト: Lavoro922/Erd-Creator
void QGraphicsItemResizable::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){

        QRectF bord = boundingRect();// prendo la dimensione
        bord.setTop(bord.top()-my);
        bord.setLeft(bord.left()-mx);
        bord.setWidth(bord.width()-mw);
        bord.setHeight(bord.height()-mh);

        QRect  rect(bord.left()+5,bord.top()+5,bord.width()-10,bord.height()-10);// dimensione rettangolo selezionato

        painter->fillRect(bord,QBrush(BColor));// disegno il rettangolo di contorno
        painter->drawRect(bord);
        if (select){ // se è selezionato disegno
                QPen pen;// nuovo Qpen
                QPen pr =  painter->pen();// mi salvo il pen attuale
                pen.setColor(SColor); // setto il colore del pen nuovo
                pen.setStyle(Qt::DashDotLine);// metto il tratteggio al pen
                painter->setPen(pen);// setto il nuovo pen
                painter->drawRect(rect);  // disegno il rettangolo selezionato
                painter->setPen(pr);// ripristino il pen
            }




    }
コード例 #28
0
ファイル: TimelineBar.cpp プロジェクト: etnlGD/renderdoc
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;
}
コード例 #29
0
ファイル: pdfjob.cpp プロジェクト: rainemak/sailfish-office
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;
    }
}
コード例 #30
0
ファイル: windigitaldelegate.cpp プロジェクト: urielyan/F270
/**
 * 功能
 *      当前单元格子元素布局
 */
void WinDigitalDelegate::doLayout(const QStyleOptionViewItem & option, QRectF &valRect, QRectF &unitRect, QRectF &tagRect, QRectF &alarmRect, qreal &alarmSpan) const
{
    /***********测量值***********/
    valRect = option.rect;
    valRect.setHeight(valRect.height()/3);
    valRect.moveTop(valRect.bottom());
    valRect.setRight(valRect.right() - valRect.width()/18- 3);

    /************标记**********/
    tagRect = valRect;
    tagRect.moveBottom(tagRect.top());
    tagRect.setTop(tagRect.top() + option.rect.height()/10);

    /************单位***********/
    unitRect = valRect;
    unitRect.moveTop(unitRect.bottom());
    unitRect.setRight(unitRect.right() - 15);

    /*************报警标记**********/
    alarmRect = unitRect;
    alarmRect.setHeight(alarmRect.height()/3);
    alarmRect.moveTop(alarmRect.bottom());
    alarmRect.setLeft(alarmRect.center().x() - 4*alarmRect.height());
    alarmRect.setWidth(alarmRect.height());
    alarmSpan = alarmRect.width() * 2;
}