Exemple #1
0
void RBAlbumArt::paint(QPainter *painter,
                       const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QRectF drawArea;

    /* Making sure the alignment flags are sane */
    if(hAlign != 'c' && hAlign != 'l' && hAlign != 'r')
        hAlign = 'c';
    if(vAlign != 'c' && vAlign != 't' && vAlign != 'b')
        vAlign = 'c';

    if(artWidth <= size.width() && artHeight <= size.height())
    {
        /* If the art is smaller than the viewport, just center it up */
        drawArea.setX((size.width() - artWidth) / 2);
        drawArea.setY((size.height() - artHeight) / 2);
        drawArea.setWidth(artWidth);
        drawArea.setHeight(artHeight);
    }
    else
    {
        /* Otherwise, figure out our scale factor, and which dimension needs
         * to be scaled, and how to align said dimension
         */
        double xScale = size.width() / artWidth;
        double yScale = size.height() / artHeight;
        double scale = xScale < yScale ? xScale : yScale;

        double scaleWidth = artWidth * scale;
        double scaleHeight = artHeight * scale;

        if(hAlign == 'l')
            drawArea.setX(0);
        else if(hAlign == 'c')
            drawArea.setX((size.width() - scaleWidth) / 2 );
        else
            drawArea.setX(size.width() - scaleWidth);

        if(vAlign == 't')
            drawArea.setY(0);
        else if(vAlign == 'c')
            drawArea.setY((size.height() - scaleHeight) / 2);
        else
            drawArea.setY(size.height() - scaleHeight);

        drawArea.setWidth(scaleWidth);
        drawArea.setHeight(scaleHeight);

    }

    painter->fillRect(drawArea, texture);

    RBMovable::paint(painter, option, widget);
}
Exemple #2
0
void Playground::renderBubble(int x, int y, GLuint color)
{
    QRectF rect;
    rect.setX(x);
    rect.setY(y);
    rect.setHeight(bubbleSize);
    rect.setWidth(bubbleSize);
    drawTexture(rect, color);
    /*glBindTexture( GL_TEXTURE_2D, color);

    glBegin( GL_QUADS );

    glTexCoord2i( 0, 0 );
    glVertex3f( x, y, 0);

    glTexCoord2i( 1, 0 );
    glVertex3f( x + bubbleSize, y, 0);

    glTexCoord2i( 1, 1 );
    glVertex3f( x + bubbleSize, y + bubbleSize, 0);

    glTexCoord2i( 0, 1 );
    glVertex3f( x, y + bubbleSize, 0);
    glEnd();*/
}
Exemple #3
0
void PlotZoomer::zoomSync(const QRectF &rect)
{
  if (!_ignoreSync)
  {
//    if (QwtPlotZoomer *zoomer = qobject_cast<QwtPlotZoomer *>(sender()))
//    {
//      setZoomStack(zoomer->zoomStack(), zoomer->zoomRectIndex());
//    }
//    else
//    {
//      zoom(rect);
//    }
    // Adjust the zoom rect according to the zoom mode.
    QRectF adjustedRect = rect;
    switch (_zoomMode)
    {
    default:
    case ZoomBoth:
      break;
    case ZoomX:
      adjustedRect.setY(zoomRect().y());
      adjustedRect.setHeight(zoomRect().height());
      break;
    case ZoomY:
      adjustedRect.setX(zoomRect().x());
      adjustedRect.setWidth(zoomRect().width());
      break;
    }
    zoom(adjustedRect);
  }
}
QRectF GraphicNetNode::boundingRect() const {
	QRectF bounds;

	qreal height = icon->boundingRect().height() + (2.0 * CLOUD_Y_MARGIN);
	qreal width = icon->boundingRect().width() + (2.0 * CLOUD_X_MARGIN);

	if(addressText->isVisible()){
		width = fmax(width, addressText->boundingRect().width());
		height += addressText->boundingRect().height();
	}

	if(hostnameText->isVisible()){
		width = fmax(width, hostnameText->boundingRect().width());
		height += hostnameText->boundingRect().height();
	}

	if(secondAddrsText->isVisible()){
		width = fmax(width, secondAddrsText->boundingRect().width());
		height += secondAddrsText->boundingRect().height();
	}

	bounds.setX(0);
	bounds.setY(0);

	bounds.setWidth(width);
	bounds.setHeight(height);

	return bounds;
}
Exemple #5
0
Queue::Queue(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Queue)
{
    ui->setupUi(this);
    QGraphicsScene *scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);
    QPixmap bkgnd(":files/images/bckgnd.png");
    bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio);
    QPalette palette;
    palette.setBrush(QPalette::Background, bkgnd);
    this->setPalette(palette);
    QRectF coords;
    coords.setX(-500); coords.setY(-500);
    coords.setWidth(1000); coords.setHeight(1000);
    rPoint.setX(-500);
    rPoint.setY(-387);
    rLineCoords.setLine(-480, -387, -480, -410);
    qList = new Ui::List(ui->graphicsView, scene, coords, rPoint, rLineCoords, "Rear");

    QFont font;
    fPoint.setX(-500);
    fPoint.setY(-500);
    fLineCoords.setLine(-480, -480, -480, -460);
    fLabel = ui->graphicsView->scene()->addText("Front", font);
    fLabel->setPos(fPoint);
    fLine = ui->graphicsView->scene()->addLine(fLineCoords);
    v = new QIntValidator(0, 65535, this);
    ui->lineEdit->setValidator(v);
}
Exemple #6
0
static QList<FormField> getFormFields(Poppler::Page *popplerPage)
{
    QList<FormField> formFields;

//QTime t = QTime::currentTime();
    QList<Poppler::FormField*> popplerFormFields = popplerPage->formFields();
//qCritical() << t.msecsTo(QTime::currentTime());
    QSizeF popplerPageSizeF = popplerPage->pageSizeF();
    for (int i = 0; i < popplerFormFields.size(); ++i)
    {
        FormField formField;
        Poppler::FormField* popplerFormField = popplerFormFields.at(i);
        const QRectF popplerFormFieldRect = popplerFormField->rect();
        QRectF formFieldRect;
        formFieldRect.setX(popplerFormFieldRect.x() * popplerPageSizeF.width());
        formFieldRect.setY(popplerFormFieldRect.y() * popplerPageSizeF.height());
        formFieldRect.setWidth((popplerFormFieldRect.right() - popplerFormFieldRect.left()) * popplerPageSizeF.width());
        formFieldRect.setHeight((popplerFormFieldRect.bottom() - popplerFormFieldRect.top()) * popplerPageSizeF.height());
        formField.rect = formFieldRect;
//		if (popplerFormField->type() == Poppler::FormField::FormText)
//			formField.text = static_cast<Poppler::FormFieldText*>(popplerFormField)->text();
        formField.field = popplerFormField;
        formFields << formField;
    }

    return formFields;
}
Exemple #7
0
/*!
  Align the legend to the canvas
  \param canvasRect Geometry of the canvas
  \param legendRect Maximum geometry for the legend
  \return Geometry for the aligned legend
*/
QRectF QwtPlotLayout::alignLegend( const QRectF &canvasRect,
    const QRectF &legendRect ) const
{
    QRectF alignedRect = legendRect;

    if ( d_data->legendPos == QwtPlot::BottomLegend
        || d_data->legendPos == QwtPlot::TopLegend )
    {
        if ( d_data->layoutData.legend.hint.width() < canvasRect.width() )
        {
            alignedRect.setX( canvasRect.x() );
            alignedRect.setWidth( canvasRect.width() );
        }
    }
    else
    {
        if ( d_data->layoutData.legend.hint.height() < canvasRect.height() )
        {
            alignedRect.setY( canvasRect.y() );
            alignedRect.setHeight( canvasRect.height() );
        }
    }

    return alignedRect;
}
Exemple #8
0
void PieChart::paint(QPainter *painter)
{
    painter->setRenderHints(QPainter::Antialiasing, true);
    //Обчислення області для малювання
    QRectF fillRect = boundingRect();
    if(fillRect.height() > fillRect.width()){
        fillRect.setY(fillRect.y() + (fillRect.height()-fillRect.width())/2);
        fillRect.setHeight(fillRect.width());
    } else {
        fillRect.setX(fillRect.x() + (fillRect.width()-fillRect.height())/2);
        fillRect.setWidth(fillRect.height());
    }
    fillRect.adjust(pStrokePen->width(), pStrokePen->width(), -pStrokePen->width(),
                    -pStrokePen->width());

    //Малювання сегментів
    painter->setPen(pStrokePen->getPen());
    double beginAngle = pAngleOffset;
    double segmentAngle;
    for(PieSlice* i:slicesList){
        painter->setBrush(QBrush(i->color()));
        segmentAngle = 5760.0 * fabs(i->value())/sumSliceValue;
        painter->drawPie(fillRect, beginAngle, segmentAngle);
        beginAngle += segmentAngle;
    }
}
void ArrowAlu3::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QFont font = painter->font() ;

    painter->setPen(Qt::black);
    font.setPixelSize(13);
    painter->setFont(font);

    QRectF rect = boundingRect();
    rect.setX(rect.x()+22);
    rect.setY(rect.y()-4);
    rect.setHeight(15);
    rect.setWidth(100);

    painter->drawText(rect,Qt::AlignLeft," ALU 3");

    if(!this->isActive) {
        QBrush brush(QColor(150, 150, 150,255));

        painter->setPen(Qt::NoPen);
        painter->setBrush(notActiveColor);
        painter->drawPolygon(polygon());
    } else {
        QBrush brush(QColor(255, 174, 201,255));

        painter->setPen(Qt::NoPen);
        painter->setBrush(activeColor);
        painter->drawPolygon(polygon());
    }
}
Exemple #10
0
bool PlotZoomer::end(bool ok)
{
  // Code here is taken from QwtPlotZoomer. The only modification is around the _zoomMode handling.
  ok = QwtPlotPicker::end(ok);
  if (!ok)
  {
    return false;
  }

  QwtPlot *plot = QwtPlotZoomer::plot();
  if (!plot)
  {
    return false;
  }

  const QPolygon &pa = selection();
  if (pa.count() < 2)
  {
    return false;
  }

  QRect rect = QRect(pa[0], pa[int(pa.count() - 1)]);
  rect = rect.normalized();

  QRectF currentZoomRect = zoomRect();
  QRectF zoomRect = invTransform(rect).normalized();

  switch (_zoomMode)
  {
  default:
  case ZoomBoth:
    // nothing.
    break;

  case ZoomX:
    // Maintain current zoom y and height.
    zoomRect.setY(currentZoomRect.y());
    zoomRect.setHeight(currentZoomRect.height());
    break;

  case ZoomY:
    // Maintain current zoom x and width.
    zoomRect.setX(currentZoomRect.x());
    zoomRect.setWidth(currentZoomRect.width());
    break;
  }

  const QSizeF minSize = minZoomSize();
  if (minSize.isValid())
  {
    const QPointF center = zoomRect.center();
    zoomRect.setSize(zoomRect.size().expandedTo(minZoomSize()));
    zoomRect.moveCenter(center);
  }

  zoom(zoomRect);

  return true;
}
Exemple #11
0
QRectF ItemLocation::GetRect() const {
    QRectF result;
    result.setX(MINIMAP_SIZE * x_ / INVENTORY_SLOTS);
    result.setY(MINIMAP_SIZE * y_ / INVENTORY_SLOTS);
    result.setWidth(MINIMAP_SIZE * w_ / INVENTORY_SLOTS);
    result.setHeight(MINIMAP_SIZE * h_ / INVENTORY_SLOTS);
    return result;
}
Exemple #12
0
void RectF::setY(qreal y)
{
	QRectF s = value().toRectF();
	qreal h = s.height();
	s.setY(y);
	s.setHeight(h);
	setValue(s);
}
KoFilterEffectStack * FilterEffectResource::toFilterStack() const
{
    KoFilterEffectStack * filterStack = new KoFilterEffectStack();
    if (!filterStack)
        return 0;

    QByteArray data = m_data.toByteArray();
    KoXmlDocument doc;
    doc.setContent(data);
    KoXmlElement e = doc.documentElement();

    // only allow obect bounding box units
    if (e.hasAttribute("filterUnits") && e.attribute("filterUnits") != "objectBoundingBox")
        return 0;

    if (e.attribute("primitiveUnits") != "objectBoundingBox")
        return 0;

    // parse filter region rectangle
    QRectF filterRegion;
    filterRegion.setX(fromPercentage(e.attribute("x", "-0.1")));
    filterRegion.setY(fromPercentage(e.attribute("y", "-0.1")));
    filterRegion.setWidth(fromPercentage(e.attribute("width", "1.2")));
    filterRegion.setHeight(fromPercentage(e.attribute("height", "1.2")));
    filterStack->setClipRect(filterRegion);

    KoFilterEffectLoadingContext context(QString(""));

    KoFilterEffectRegistry * registry = KoFilterEffectRegistry::instance();

    // create the filter effects and add them to the shape
    for (KoXmlNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) {
        KoXmlElement primitive = n.toElement();
        KoFilterEffect * filterEffect = registry->createFilterEffectFromXml(primitive, context);
        if (!filterEffect) {
            qWarning() << "filter effect" << primitive.tagName() << "is not implemented yet";
            continue;
        }

        // parse subregion
        qreal x = fromPercentage(primitive.attribute("x", "0"));
        qreal y = fromPercentage(primitive.attribute("y", "0"));
        qreal w = fromPercentage(primitive.attribute("width", "1"));
        qreal h = fromPercentage(primitive.attribute("height", "1"));
        QRectF subRegion(QPointF(x, y), QSizeF(w, h));

        if (primitive.hasAttribute("in"))
            filterEffect->setInput(0, primitive.attribute("in"));
        if (primitive.hasAttribute("result"))
            filterEffect->setOutput(primitive.attribute("result"));

        filterEffect->setFilterRect(subRegion);

        filterStack->appendFilterEffect(filterEffect);
    }

    return filterStack;
}
Exemple #14
0
void GameManager::setSizeScene(qreal w, qreal h)
{
	QRectF sRect;
	sRect.setX((w / 2) * (-1));
	sRect.setY((h / 2) * (-1));
	sRect.setWidth(w);
	sRect.setHeight(h);
	scene->setSceneRect(sRect);
}
Exemple #15
0
QRectF Sprite::boundingRect() const
{
    QRectF t;
    t.setX(this->pos().x());
    t.setY(this->pos().y());
    t.setWidth(stateBox[currState]->getPixmap().rect().width());
    t.setHeight(stateBox[currState]->getPixmap().rect().height());
    return t;
}
Exemple #16
0
QRectF readRectF(QDomElement e)
      {
      QRectF p;
      p.setX(e.attribute("x", "0.0").toDouble());
      p.setY(e.attribute("y", "0.0").toDouble());
      p.setWidth(e.attribute("w", "0.0").toDouble());
      p.setHeight(e.attribute("h", "0.0").toDouble());
      return p;
      }
QRectF QAbstractDiagramGraphicsItem::geometry() const
{
	QRectF r;
	QVariantMap p = m_properties.value("geometry").toMap();
	r.setX(p.value("x").toDouble());
	r.setY(p.value("y").toDouble());
	r.setWidth(p.value("width").toDouble());
	r.setHeight(p.value("height").toDouble());
    return r;
}
Exemple #18
0
QRectF XmlReader::readRect()
      {
      Q_ASSERT(tokenType() == QXmlStreamReader::StartElement);
      QRectF p;
      p.setX(doubleAttribute("x", 0.0));
      p.setY(doubleAttribute("y", 0.0));
      p.setWidth(doubleAttribute("w", 0.0));
      p.setHeight(doubleAttribute("h", 0.0));
      skipCurrentElement();
      return p;
      }
Exemple #19
0
QRectF QwtPlotLayout::layoutLegend( Options options,
    const QRectF &rect ) const
{
    const QSize hint( d_data->layoutData.legend.hint );

    int dim;
    if ( d_data->legendPos == QwtPlot::LeftLegend
        || d_data->legendPos == QwtPlot::RightLegend )
    {
        // We don't allow vertical legends to take more than
        // half of the available space.

        dim = qMin( hint.width(), int( rect.width() * d_data->legendRatio ) );

        if ( !( options & IgnoreScrollbars ) )
        {
            if ( hint.height() > rect.height() )
            {
                // The legend will need additional
                // space for the vertical scrollbar.

                dim += d_data->layoutData.legend.vScrollBarWidth;
            }
        }
    }
    else
    {
        dim = qMin( hint.height(), int( rect.height() * d_data->legendRatio ) );
        dim = qMax( dim, d_data->layoutData.legend.hScrollBarHeight );
    }

    QRectF legendRect = rect;
    switch ( d_data->legendPos )
    {
        case QwtPlot::LeftLegend:
            legendRect.setWidth( dim );
            break;
        case QwtPlot::RightLegend:
            legendRect.setX( rect.right() - dim );
            legendRect.setWidth( dim );
            break;
        case QwtPlot::TopLegend:
            legendRect.setHeight( dim );
            break;
        case QwtPlot::BottomLegend:
            legendRect.setY( rect.bottom() - dim );
            legendRect.setHeight( dim );
            break;
        case QwtPlot::ExternalLegend:
            break;
    }

    return legendRect;
}
Exemple #20
0
QRectF Label::contents_bounding_rect() const {
  QFont font;
  font.setFamily(font.defaultFamily());
  font.setPixelSize(d->m_font_size);
  QFontMetrics metic(font);
  QRectF rect = metic.boundingRect(d->m_label_string);
  rect.setX(0.0);
  rect.setY(0.0);

  return rect;
}
Exemple #21
0
inline QRectF QtViewportHandler::itemRectFromCSS(const QRectF& cssRect) const
{
    QRectF itemRect;

    itemRect.setX(itemCoordFromCSS(cssRect.x()));
    itemRect.setY(itemCoordFromCSS(cssRect.y()));
    itemRect.setWidth(itemCoordFromCSS(cssRect.width()));
    itemRect.setHeight(itemCoordFromCSS(cssRect.height()));

    return itemRect;
}
inline QRectF QtViewportInteractionEngine::itemRectFromCSS(const QRectF& cssRect)
{
    QRectF itemRect;

    itemRect.setX(itemCoordFromCSS(cssRect.x()));
    itemRect.setY(itemCoordFromCSS(cssRect.y()));
    itemRect.setWidth(itemCoordFromCSS(cssRect.width()));
    itemRect.setHeight(itemCoordFromCSS(cssRect.height()));

    return itemRect;
}
void KUnitItem::setZoomOutPercent(float percent)
{
    //qDebug()<<"zoom out percent"<<percent;
    QRectF newFrame;
    newFrame.setX(m_frame.x());
    newFrame.setY(m_frame.y());
    newFrame.setWidth(m_frame.width() * (1 - percent));
    newFrame.setHeight(m_frame.height() * (1 - percent));

    ItemCommand::getItemCommand()->getUndoStack()->push(new ResizeCommand(this,m_frame,newFrame));
}
Exemple #24
0
QRectF VerticalPaintingStrategy::drawBackground(const KoRulerPrivate *d, QPainter &painter)
{
    lengthInPixel = d->viewConverter->documentToViewY(d->rulerLength);
    QRectF rectangle;
    rectangle.setX(0);
    rectangle.setY(qMax(0, d->offset));
    rectangle.setWidth(d->ruler->width() - 1.0);
    rectangle.setHeight(qMin(qreal(d->ruler->height() - 1.0 - rectangle.y()),
                             (d->offset >= 0) ? lengthInPixel : lengthInPixel + d->offset));

    QRectF activeRangeRectangle;
    activeRangeRectangle.setX(rectangle.x() + 1);
    activeRangeRectangle.setY(qMax(rectangle.y() + 1,
        d->viewConverter->documentToViewY(d->effectiveActiveRangeStart()) + d->offset));
    activeRangeRectangle.setWidth(rectangle.width() - 2);
    activeRangeRectangle.setBottom(qMin(rectangle.bottom() - 1,
        d->viewConverter->documentToViewY(d->effectiveActiveRangeEnd()) + d->offset));

    painter.setPen(d->ruler->palette().color(QPalette::Mid));
    painter.drawRect(rectangle);

    if(d->effectiveActiveRangeStart() != d->effectiveActiveRangeEnd())
        painter.fillRect(activeRangeRectangle, d->ruler->palette().brush(QPalette::Base));

    if(d->showSelectionBorders) {
        // Draw first selection border
        if(d->firstSelectionBorder > 0) {
            qreal border = d->viewConverter->documentToViewY(d->firstSelectionBorder) + d->offset;
            painter.drawLine(QPointF(rectangle.x() + 1, border), QPointF(rectangle.right() - 1, border));
        }
        // Draw second selection border
        if(d->secondSelectionBorder > 0) {
            qreal border = d->viewConverter->documentToViewY(d->secondSelectionBorder) + d->offset;
            painter.drawLine(QPointF(rectangle.x() + 1, border), QPointF(rectangle.right() - 1, border));
        }
    }

    return rectangle;
}
void FormEditorItem::paintPlaceHolderForInvisbleItem(QPainter *painter) const
{
    qreal stripesWidth = 12;

    QRegion innerRegion = QRegion(m_boundingRect.adjusted(stripesWidth, stripesWidth, -stripesWidth, -stripesWidth).toRect());
    QRegion outerRegion  = QRegion(m_boundingRect.toRect()) - innerRegion;

    painter->setClipRegion(outerRegion);
    painter->setClipping(true);
    painter->fillRect(m_boundingRect.adjusted(1, 1, -1, -1), Qt::BDiagPattern);
    painter->setClipping(false);

    QString displayText = qmlItemNode().id();

    if (displayText.isEmpty())
        displayText = qmlItemNode().simplifiedTypeName();

    QTextOption textOption;
    textOption.setAlignment(Qt::AlignTop);
    textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);

    if (m_boundingRect.height() > 60) {
        painter->save();

        QFont font;
        font.setStyleHint(QFont::SansSerif);
        font.setBold(true);
        font.setPixelSize(12);
        painter->setFont(font);

        QFontMetrics fm(font);
        painter->rotate(90);
        if (fm.width(displayText) > (m_boundingRect.height() - 32) && displayText.length() > 4) {

            displayText = fm.elidedText(displayText, Qt::ElideRight, m_boundingRect.height() - 32, Qt::TextShowMnemonic);
        }

        QRectF rotatedBoundingBox;
        rotatedBoundingBox.setWidth(m_boundingRect.height());
        rotatedBoundingBox.setHeight(12);
        rotatedBoundingBox.setY(-m_boundingRect.width() + 12);
        rotatedBoundingBox.setX(20);

        painter->setFont(font);
        painter->setPen(QColor(48, 48, 96, 255));
        painter->drawText(rotatedBoundingBox, displayText, textOption);

        painter->restore();
    }
}
void GroupingGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option)
    Q_UNUSED(widget)

    QSettings settings;
    _font = settings.value("Visualisation/Font", QFont("sans-serif", 10)).value<QFont>();
    int displayOptions = settings.value("Visualisation/Grouping/DisplayOptions", (DisplayCapturing | DisplayNamed)).toInt();
    double horizontalPadding = settings.value("Visualisation/Grouping/HorizontalPadding", 8.0).toDouble();
    double verticalPadding   = settings.value("Visualisation/Grouping/VerticalPadding", 6.0).toDouble();
    double cornerRadius   = settings.value("Visualisation/Grouping/CornerRadius", 5.0).toDouble();
    QColor bgColor = settings.value("Visualisation/Grouping/Color", QColor(245,245,245)).value<QColor>();

    painter->setFont(_font);
    painter->setBrush(bgColor);
    painter->setPen(Qt::black);

    if((_capturing && (displayOptions & DisplayCapturing))
            || (!_capturing && (displayOptions & DisplayNonCapturing))
            || (!_name.isEmpty() && (displayOptions & DisplayNamed))
            )
    {
        QRectF drawRect = boundingRect();
        // Align the rect to the pixel grid
        if(qRound(scenePos().x()) == scenePos().x())
        {
            drawRect.setX(0.5);
            drawRect.setWidth(drawRect.width()-.5);
        }
        if(qRound(scenePos().y()) == scenePos().y())
        {
            drawRect.setHeight(drawRect.height()-.5);
            drawRect.setY(0.5);
        }
        painter->drawRoundedRect(drawRect, cornerRadius, cornerRadius);

        if(!_name.isEmpty())
            painter->drawText(QRectF(
                                  horizontalPadding,
                                  verticalPadding,
                                  _metrics.width(_title),
                                  _metrics.height()),
                              Qt::AlignCenter,
                              _title);
    }
}
Exemple #27
0
 bool ScribbleArea::event(QEvent *event)
 {
     switch (event->type()) {
     case QEvent::TouchBegin:
     case QEvent::TouchUpdate:
     case QEvent::TouchEnd:
     {
         QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
         foreach (const QTouchEvent::TouchPoint &touchPoint, touchPoints) {
             switch (touchPoint.state()) {
             case Qt::TouchPointStationary:
                 // don't do anything if this touch point hasn't moved
                 continue;
             default:
                 {
                     QRectF rect = touchPoint.rect();
                     if (rect.isEmpty()) {

                         qreal diameter = qreal(30) * touchPoint.pressure();

                         rect.setSize(QSizeF(diameter, diameter));
                         rect.setX(touchPoint.pos().x() - 15);
                         rect.setY(touchPoint.pos().y() - 15);
                     }

                     QPainter painter(&image);
                     painter.setPen(Qt::NoPen);
                     painter.setBrush(myPenColors.at(touchPoint.id() % myPenColors.count()));
                     painter.drawEllipse(rect);
                     painter.end();

                     modified = true;
                     int rad = 2;
                     update(rect.toRect().adjusted(-rad,-rad, +rad, +rad));
                 }
                 break;
             }
         }
         break;
     }
     default:
         return QWidget::event(event);
     }
     return true;
 }
QRectF GraphicNetCloud::boundingRect() const {
	if(nodes.count() == 1){
		return nodes[0]->boundingRect();
	}

	QRectF bounds = icon->boundingRect();

	//bounds.
	bounds.setHeight(bounds.height()+addressText->boundingRect().height() + (2.0 * CLOUD_Y_MARGIN));
	bounds.setWidth(fmax(bounds.width(), addressText->boundingRect().width()) + (2.0 * CLOUD_X_MARGIN));

	//bounds.setX(-bounds.width()/2.0);
	//bounds.setY(-bounds.height()/2.0);

	bounds.setX(0);
	bounds.setY(0);

	return bounds;
}
	//loop through all screen areas that changed
	foreach(QRectF rect, list)
	{
		//generate a rectangle that is a while number, and fits withing the screen
		if(rect.x() < 0) rect.setX(0);
		if(rect.y() < 0) rect.setY(0);
		if(rect.right() > _width) rect.setRight(_width);
		if(rect.bottom() > _height) rect.setRight(_height);
		rect = QRectF(round(rect.x()),round(rect.y()),round(rect.width()),round(rect.height()));
		
		//Create an image, create a qpainter, fill the image with transparent color, and then render a part of the scene to it
		QImage image(rect.width(),rect.height(),QImage::Format_ARGB32);
		QPainter p(&image);
		image.fill(0);
		render(&p,image.rect(),rect);
		
		//use blitFromMemory to copy the image into the right part of the texture
		Box b(rect.x(),rect.y(),rect.x() + rect.width(),rect.y() + rect.height());
		PixelBox pb(Box(0,0,rect.width(),rect.height()),PF_A8R8G8B8,image.bits());
		_buffer->blitFromMemory(pb,b);
	}
Exemple #30
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    axis_number = 0;
    ui->setupUi(this);

    Canvas* canvas = new Canvas(this);
    canvas->setParent(this);
    //canvas->setSceneRect(ui->graphicsView->width(), ui->graphicsView->height(), 0, 0);
    QRectF rect = ui->graphicsView->rect();

    rect.setX(-rect.width()/2 );
    rect.setY(0);
    rect.setWidth(ui->graphicsView->width()-10);
    rect.setHeight(ui->graphicsView->height()-10);

    canvas->setSceneRect(rect);
    ui->graphicsView->scale(1, -1);

    ui->axisList->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->axisList->item(0)->setSelected(true);
    canvas->setAxesList( ui->axisList);
    canvas->initialize();

    connect(ui->cwiseBtn, SIGNAL(clicked()), canvas, SLOT(rotateCW()));
    connect(ui->ccwiseBtn, SIGNAL(clicked()), canvas, SLOT(rotateCCW()));
    connect(ui->paintBtn, SIGNAL(clicked()), canvas, SLOT(paint()));
    connect(ui->xPlus, SIGNAL(clicked()), canvas, SLOT(addX()));
    connect(ui->xMinus, SIGNAL(clicked()), canvas, SLOT(subX()));
    connect(ui->yPlus, SIGNAL(clicked()), canvas, SLOT(addY()));
    connect(ui->yMinus, SIGNAL(clicked()), canvas, SLOT(subY()));
    connect(ui->brushColor, SIGNAL(clicked()), canvas, SLOT(changeColor()));
    connect(ui->brushSlider, SIGNAL(valueChanged(int)), canvas, SLOT(changeSize(int)));
    connect(ui->graphicsView, SIGNAL(clicked()), canvas, SLOT(findXY()));
    // connect(ui->axisList, SIGNAL(clicked(QModelIndex)), canvas, SLOT(updateList()));

    ui->graphicsView->setScene(canvas);


}