void Tab::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    brush.setColor(backgroundColor());
    painter.setOpacity(1);
    painter.setBrush(brush);
    painter.setPen(Qt::NoPen);
    painter.drawRect(rect());

    paintHalo(&painter);

    QStylePainter style(this);

    if (!icon().isNull()) {
        style.translate(0, 12);
    }

    QStyleOptionButton option;
    initStyleOption(&option);
    option.features |= QStyleOptionButton::Flat;
    option.iconSize = QSize(-1, -1);  // Prevent icon from being drawn twice

    style.drawControl(QStyle::CE_PushButtonLabel, option);

    if (!icon().isNull()) {
        const QSize &size = iconSize();
        QRect iconRect(QPoint((width()-size.width())/2, 0), size);
        icon().paint(&painter, iconRect, Qt::AlignCenter, QIcon::Normal);
    }

    if (!_active) {
        QColor overlayColor = backgroundColor();
        overlayColor.setAlphaF(0.36);

        QBrush overlay;
        overlay.setStyle(Qt::SolidPattern);
        overlay.setColor(overlayColor);
        painter.fillRect(rect(), overlay);
    }

#ifdef DEBUG_LAYOUT
    QPainter debug(this);
    QPen pen;
    pen.setColor(Qt::red);
    pen.setWidth(2);
    debug.setPen(pen);
    debug.setBrush(Qt::NoBrush);
    debug.drawRect(rect());
#endif
}
Exemplo n.º 2
1
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
// -----------------------------------------------------------------------
    ui->setupUi(this);
    QGraphicsScene *scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);
// -----------------------------------------------------------------------
    // kolor pedzla
    QBrush brush = QBrush(Qt::red);
    brush.setStyle(Qt::DiagCrossPattern);
    // tworzymy obiekts
    QGraphicsRectItem *rect = new QGraphicsRectItem(10, 10, 90, 90);
    rect->setBrush(brush);
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
    // definiujemy czas trwania animacji
    QTimeLine *timeLine = new QTimeLine(1000);
    timeLine->setFrameRange(0, 100);

    // definiujemy animacje
    QGraphicsItemAnimation *animation = new QGraphicsItemAnimation();
    animation->setItem(rect);
    animation->setTimeLine(timeLine);

    // animacja
    int odcinek = 100;
    for (int i = 0; i < 100; ++i)
        animation->setPosAt(i / 100.0, QPointF(i, i));

    // uruchamiamy scenę i animację
    scene->addItem(rect);
    timeLine->start();
}
Exemplo n.º 3
0
void Hex::setOwner(QString player){
    // set the owner
    owner = player;

    // change the color
    if (player == QString("NOONE")){
        QBrush brush;
        brush.setStyle(Qt::SolidPattern);
        brush.setColor(Qt::lightGray);
        setBrush(brush);
    }

    if (player == QString("PLAYER1")){
        QBrush brush;
        brush.setStyle(Qt::SolidPattern);
        brush.setColor(Qt::blue);
        setBrush(brush);
    }

    if (player == QString("PLAYER2")){
        QBrush brush;
        brush.setStyle(Qt::SolidPattern);
        brush.setColor(Qt::red);
        setBrush(brush);
    }
}
Exemplo n.º 4
0
void QtArrowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
  painter->setRenderHint(QPainter::Antialiasing);
  if (this->isSelected())
  {
    const QColor color(255,0,0);
    QPen pen;
    pen.setColor(color);
    pen.setWidth(3);
    painter->setPen(pen);
    QBrush brush;
    brush.setColor(color);
    brush.setStyle(Qt::SolidPattern);
    painter->setBrush(brush);
  }
  else
  {
    const QColor color(0,0,0);
    QPen pen;
    pen.setColor(color);
    pen.setWidth(1);
    painter->setPen(pen);
    QBrush brush;
    brush.setColor(color);
    brush.setStyle(Qt::SolidPattern);
    painter->setBrush(brush);
  }
  painter->drawLine(this->line());

  //The angle from tail to head
  double angle = GetAngle(line().dx(),line().dy());
  if (line().dy() >= 0.0) angle = (1.0 * M_PI) + angle;
  const double sz = 10.0; //pixels
  {
    const QPointF p0 = this->line().p1();
    const QPointF p1
      = p0 + QPointF(
         std::sin(angle + M_PI + (M_PI * 0.1)) * sz,
        -std::cos(angle + M_PI + (M_PI * 0.1)) * sz);
    const QPointF p2
      = p0 + QPointF(
         std::sin(angle + M_PI - (M_PI * 0.1)) * sz,
        -std::cos(angle + M_PI - (M_PI * 0.1)) * sz);
    painter->drawPolygon(QPolygonF() << p0 << p1 << p2);
  }
  {
    const QPointF p0 = this->line().p2();

    const QPointF p1
      = p0 + QPointF(
         std::sin(angle +  0.0 + (M_PI * 0.1)) * sz,
        -std::cos(angle +  0.0 + (M_PI * 0.1)) * sz);
    const QPointF p2
      = p0 + QPointF(
         std::sin(angle +  0.0 - (M_PI * 0.1)) * sz,
        -std::cos(angle +  0.0 - (M_PI * 0.1)) * sz);

    painter->drawPolygon(QPolygonF() << p0 << p1 << p2);
  }
}
Exemplo n.º 5
0
void QgsLayoutItemPolyline::drawArrowHead( QPainter *p, const double x, const double y, const double angle, const double arrowHeadWidth )
{
  if ( !p )
    return;

  double angleRad = angle / 180.0 * M_PI;
  QPointF middlePoint( x, y );

  //rotate both arrow points
  QPointF p1 = QPointF( -arrowHeadWidth / 2.0, arrowHeadWidth );
  QPointF p2 = QPointF( arrowHeadWidth / 2.0, arrowHeadWidth );

  QPointF p1Rotated, p2Rotated;
  p1Rotated.setX( p1.x() * std::cos( angleRad ) + p1.y() * -std::sin( angleRad ) );
  p1Rotated.setY( p1.x() * std::sin( angleRad ) + p1.y() * std::cos( angleRad ) );
  p2Rotated.setX( p2.x() * std::cos( angleRad ) + p2.y() * -std::sin( angleRad ) );
  p2Rotated.setY( p2.x() * std::sin( angleRad ) + p2.y() * std::cos( angleRad ) );

  QPolygonF arrowHeadPoly;
  arrowHeadPoly << middlePoint;
  arrowHeadPoly << QPointF( middlePoint.x() + p1Rotated.x(), middlePoint.y() + p1Rotated.y() );
  arrowHeadPoly << QPointF( middlePoint.x() + p2Rotated.x(), middlePoint.y() + p2Rotated.y() );
  QPen arrowPen = p->pen();
  arrowPen.setJoinStyle( Qt::RoundJoin );
  QBrush arrowBrush = p->brush();
  arrowBrush.setStyle( Qt::SolidPattern );
  p->setPen( arrowPen );
  p->setBrush( arrowBrush );
  arrowBrush.setStyle( Qt::SolidPattern );
  p->drawPolygon( arrowHeadPoly );
}
Exemplo n.º 6
0
QBrush FillTab::brush(QBrush b) const {

  QColor this_color = colorDirty() ? color() : b.color();
  Qt::BrushStyle this_style = styleDirty() ? style() : b.style();

  if (useGradientDirty()) {
    // Apply / unapply gradient
    if (useGradient()) {
      b = QBrush(gradient());
    } else {
      b.setColor(this_color);
      b.setStyle(this_style);
    }
  } else {
    // Leave gradient but make other changes.
    QGradient this_gradient;
    if (const QGradient *grad = b.gradient()) {
      if (gradientDirty()) {
        this_gradient = gradient();
      } else {
        this_gradient = *grad;
      }
      b = QBrush(this_gradient);
    } else {
      b.setColor(this_color);
      b.setStyle(this_style);
    }
  }

  return b;
}
Exemplo n.º 7
0
void KnotRendererBatch::PaintInterfaceData::set(int fillColour, int outlineColour, int outlineWidth, const QList< QColor > colorList)
{
    QPen pen = p->pen();
    pen.setWidth(outlineWidth);
    if (outlineColour != -1)
        pen.setColor(colorList[outlineColour]);
    else
    {
        QBrush brush = pen.brush();
        brush.setStyle(Qt::NoBrush);
        pen.setBrush(brush);
    }
    p->setPen(pen);
    
    QBrush brush = p->brush();
    if (fillColour == -1)
    {
        brush.setStyle(Qt::NoBrush);
    }
    else
    {
        brush.setStyle(Qt::SolidPattern);
        brush.setColor(colorList[fillColour]);
    }
    p->setBrush(brush);
}
Exemplo n.º 8
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;
 }
Exemplo n.º 9
0
void KoSectionStyle::loadOdf(const KoXmlElement *element, KoOdfLoadingContext &context)
{
    if (element->hasAttributeNS(KoXmlNS::style, "display-name"))
        d->name = element->attributeNS(KoXmlNS::style, "display-name", QString());

    if (d->name.isEmpty()) // if no style:display-name is given us the style:name
        d->name = element->attributeNS(KoXmlNS::style, "name", QString());

    context.styleStack().save();
    // Load all parents - only because we don't support inheritance.
    QString family = element->attributeNS(KoXmlNS::style, "family", "section");
    context.addStyles(element, family.toLocal8Bit().constData());   // Load all parents - only because we don't support inheritance.

    context.styleStack().setTypeProperties("section");   // load all style attributes from "style:section-properties"

    KoStyleStack &styleStack = context.styleStack();

    // in 1.6 this was defined at KoParagLayout::loadOasisParagLayout(KoParagLayout&, KoOasisContext&)

    if (styleStack.hasProperty(KoXmlNS::style, "writing-mode")) {     // http://www.w3.org/TR/2004/WD-xsl11-20041216/#writing-mode
        QString writingMode = styleStack.property(KoXmlNS::style, "writing-mode");
        setTextProgressionDirection(KoText::directionFromString(writingMode));
    }

    // Indentation (margin)
    bool hasMarginLeft = styleStack.hasProperty(KoXmlNS::fo, "margin-left");
    bool hasMarginRight = styleStack.hasProperty(KoXmlNS::fo, "margin-right");
    if (hasMarginLeft)
        setLeftMargin(KoUnit::parseValue(styleStack.property(KoXmlNS::fo, "margin-left")));
    if (hasMarginRight)
        setRightMargin(KoUnit::parseValue(styleStack.property(KoXmlNS::fo, "margin-right")));


    // The fo:background-color attribute specifies the background color of a paragraph.
    if (styleStack.hasProperty(KoXmlNS::fo, "background-color")) {
        const QString bgcolor = styleStack.property(KoXmlNS::fo, "background-color");
        QBrush brush = background();
        if (bgcolor == "transparent")
            brush.setStyle(Qt::NoBrush);
        else {
            if (brush.style() == Qt::NoBrush)
                brush.setStyle(Qt::SolidPattern);
            brush.setColor(bgcolor); // #rrggbb format
        }
        setBackground(brush);
    }

    styleStack.restore();
}
Exemplo n.º 10
0
void Button::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
    // change color to dark cyan
    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    brush.setColor(Qt::darkCyan);
    setBrush(brush);
}
Exemplo n.º 11
0
void AssetDecodePopup::paintEvent(QPaintEvent *)
{
    QStyleOption opt;
    opt.init(this);
    QPainter p(this);
    //style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
    itemMutex.lock();

    QBrush brush;
    brush.setColor(QColor(51, 51, 51));
    brush.setStyle(Qt::BrushStyle::SolidPattern);
    p.fillRect(0, 0, width(), height(), brush);
    
    QPen pen;
    pen.setColor(QColor(41, 41, 41));
    p.setPen(pen);
    p.drawRect(0, 0, width()-1, height()-1);

    
    int yPos = 2;
    for (const auto& item : m_items)
    {
        drawItem(item.displayFilename, item.status, QRect(2, yPos, width() - 5, SingleItemHeight), item.progress);
        yPos += SingleItemHeight;
    }
    itemMutex.unlock();
}
Exemplo n.º 12
0
void pigalePaint::DrawText(QPainter *p,Tpoint &a,tvertex v,int col,int center)
// draw text centered at a, with a surrounding rectangle
// center=1 center
// center=0 horizontal
  {QString t =  getVertexLabel(GCP,v);
  QPen pn = p->pen();pn.setWidth(1);pn.setColor(color[Black]);p->setPen(pn);
  QSize size = QFontMetrics(p->font()).size(Qt::AlignCenter,t);
  double nx = size.width() + 4; double ny = size.height();
  if(t.length() == 0)nx = ny= 8;
  QRect rect;
  //if pn.setWidth() > 1 => rect increase
  if(center)
      rect = QRect((int)(to_x(a.x())-nx/2+.5),(int)(to_y(a.y())-ny/2+.5),(int)(nx+.5),(int)(ny+.5));
  else
      rect = QRect((int)(to_x(a.x())-nx/2+.5),(int)(to_y(a.y())-ny+1.),(int)(nx+.5),(int)(ny+.5));
  QBrush pb = p->brush();
  pb.setStyle(Qt::SolidPattern);
  pb.setColor(color[bound(col,0,16)]);
  //pb.setColor(color[White]);
  p->setBrush(pb);
  //pn.setColor(color[col]);pn.setWidth(1);p->setPen(pn);
  pn.setWidth(1);pn.setColor(color[Black]);p->setPen(pn);
  p->drawRect(rect);
  if(ny < 6)return;
  p->drawText(rect,Qt::AlignCenter,t);
  }
Exemplo n.º 13
0
void Draw_Arc::setEdgeRects()
{
    QBrush rectbrush;
    rectbrush.setColor(QColor(0,175,225));
    rectbrush.setStyle(Qt::SolidPattern);
    qDebug()<<"strt pnt "<<StrtPnt<<" "<<"end pnt "<<EndPnt<<"\n";
    Strt_Rect = new QGraphicsRectItem(QRectF(QPointF(StrtPnt.x()-5.0,StrtPnt.y()-5.0),QPointF(StrtPnt.x()+5.0,StrtPnt.y()+5.0)));
    Strt_Rect->setBrush(rectbrush);

    End_Rect = new QGraphicsRectItem(QRectF(QPointF(EndPnt.x()-5.0,EndPnt.y()-5.0),QPointF(EndPnt.x()+5.0,EndPnt.y()+5.0)));
    End_Rect->setBrush(rectbrush);

    Curve_Rect = new QGraphicsRectItem(QRectF(QPointF(CurvePnt.x()-5.0,CurvePnt.y()-5.0),QPointF(CurvePnt.x()+5.0,CurvePnt.y()+5.0)));
    Curve_Rect->setBrush(rectbrush);

    QPen bound_rect;
    bound_rect.setStyle(Qt::DashLine);
    Bounding_Rect = new QGraphicsRectItem(QRectF(item->boundingRect().topLeft(),item->boundingRect().bottomRight()));
    Bounding_Rect->setPen(bound_rect);

  QPointF pnt1,pnt2;

    pnt1.setX(((item->boundingRect().topLeft().x()+item->boundingRect().bottomRight().x())/2)-5);
    pnt1.setY(item->boundingRect().topLeft().y()-20);

    pnt2.setX(((item->boundingRect().topLeft().x()+item->boundingRect().bottomRight().x())/2)+5);
    pnt2.setY(item->boundingRect().topLeft().y()-10);

    Rot_Rect = new QGraphicsEllipseItem(QRectF(pnt1,pnt2));
    Rot_Rect->setBrush(rectbrush);


}
Exemplo n.º 14
0
void CursorRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    painter->save();
    QBrush brush;
    int w = width();
    int h = height();
    brush.setColor(Qt::black);
    brush.setStyle(Qt::SolidPattern);
    painter->setPen(Qt::NoPen);
    painter->setBrush(brush);
    painter->drawRect(0,0,w,h);


    int beatLength = 120 / _beatCount;

    for(int i=0;i<w;i += 120)
    {
        painter->setPen(Qt::lightGray);
        painter->drawLine(i,0,i,h-4);
        for(int j=1;j<_beatCount;++j)
        {
            painter->setPen(Qt::darkGray);
            painter->drawLine(i+j*beatLength,0,i+j*beatLength,h-8);
        }
    }


    painter->restore();
}
Exemplo n.º 15
0
void Dialog::paintEvent(QPaintEvent *e)
{
    QPainter painter(this);

    // make our polygon
    QPolygon poly;
    poly << QPoint(10, 10);
    poly << QPoint(10, 100);
    poly << QPoint(100, 10);
    poly << QPoint(100, 100);

    // make a pen
    QPen linePen;
    linePen.setWidth(8);
    linePen.setColor(Qt::red);
    //linePen.setJoinStyle(Qt::RoundJoin);
    linePen.setJoinStyle(Qt::MiterJoin);
    linePen.setStyle(Qt::DotLine);
    painter.setPen(linePen);

    // make a brush
    QBrush fillBrush;
    fillBrush.setColor(Qt::green);
    fillBrush.setStyle(Qt::SolidPattern);

    // fill the polygon
    QPainterPath path;
    path.addPolygon(poly);
    painter.fillPath(path, fillBrush);

    // draw polygon
    painter.drawPolygon(poly);

}
Exemplo n.º 16
0
void 
RSceneDevice::Rect(double x0, double y0, double x1, double y1,
		   R_GE_gcontext *gc)
{
    if (debug) Rprintf("RSceneDevice::Rect\n");
    QPen pen(Qt::NoPen);
    QBrush brush;
    QRectF rect(x0, y0, x1 - x0, y1 - y0);
    int col = gc->col;
    int fill = gc->fill;
    //double gamma = gc->gamma;
    double lwd = gc->lwd;
    int lty = gc->lty;
    if (col != NA_INTEGER && !R_TRANSPARENT(col)) {
	pen.setStyle(lty2style(lty));
	pen.setColor(r2qColor(col));
	pen.setWidthF(lwd);
    }
    if (fill != NA_INTEGER && !R_TRANSPARENT(fill)) {
	brush.setColor(r2qColor(fill));
	brush.setStyle(Qt::SolidPattern);
    }
    addClippedItem(addRect(rect, pen, brush));
    return;
}
Exemplo n.º 17
0
void GameWindow::drawShip(Ship &ship) {
    QPainter painter(this);
    QBrush brush;
    for(int i=0; i<ship.size; i++) {
        if( ship.blocks[i] == HEALTHY ) {
            brush.setColor(Qt::black);
            brush.setStyle(Qt::SolidPattern);
        }
        else if( ship.blocks[i] == KILLED ) {
            brush.setColor(Qt::red);
            brush.setStyle(Qt::Dense4Pattern);
        }
        painter.setBrush(brush);
        painter.drawRect( ship.X+i*80, ship.Y+20, 80, 40);
    }
}
void QvkAnimateWindow::paintEvent( QPaintEvent *event ) 
{
  (void)event;
  QPainter painter( this );
  painter.setRenderHints( QPainter::Antialiasing, true );

    QBrush brush;
    if ( radiant == false )
    {
      brush.setStyle( Qt::SolidPattern );
      brush.setColor( color );
    }
    else
    {
      QRadialGradient radialGradient( width()/2, height()/2, diameter/2 );
      radialGradient.setColorAt( 0, color );
      radialGradient.setColorAt( 1, Qt::transparent );
      QBrush brushRadial( radialGradient );
      brush.swap( brushRadial );
    }
  
  painter.setPen( Qt::NoPen );
  painter.setBrush( brush );
  painter.setOpacity ( opacity );
  painter.drawEllipse ( QPoint( width()/2, height()/2 ), diameter/2, diameter/2 );
  
}
Exemplo n.º 19
0
void Box::setFillColour(QColor q)
{
  QBrush br;
  br.setColor(q);
  br.setStyle(Qt::SolidPattern);
  setBrush(br);
}
Exemplo n.º 20
0
void Draw_Ellipse::setEdgeRects()
{
    QBrush rectbrush;
    rectbrush.setColor(QColor(0,175,225));
    rectbrush.setStyle(Qt::SolidPattern);

    Strt_Rect = new QGraphicsRectItem(QRectF(QPointF(StrtPnt.x()-5.0,StrtPnt.y()-5.0),QPointF(StrtPnt.x()+5.0,StrtPnt.y()+5.0)));
    Strt_Rect->setBrush(rectbrush);

    End_Rect = new QGraphicsRectItem(QRectF(QPointF(EndPnt.x()-5.0,EndPnt.y()-5.0),QPointF(EndPnt.x()+5.0,EndPnt.y()+5.0)));
    End_Rect->setBrush(rectbrush);


    QPointF pnt1,pnt2;

    pnt1.setX(((StrtPnt.x()+EndPnt.x())/2)-5);
    pnt1.setY(StrtPnt.y()-20);

    pnt2.setX(((StrtPnt.x()+EndPnt.x())/2)+5);
    pnt2.setY(StrtPnt.y()-10);

    Rot_Rect = new QGraphicsEllipseItem(QRectF(pnt1,pnt2));
    Rot_Rect->setBrush(rectbrush);

}
Exemplo n.º 21
0
void graph2_1::paintEvent(QPaintEvent *)
{
    /***********�����α߿���������**************/
    QPainter *painter=new QPainter(this);
    painter->setRenderHint(QPainter::Antialiasing,true);
    painter->drawRect(10,10,380,230);
    QPoint beginPoint(50,200);
    QPoint xEndPoint(xEndX,xEndY);
    QPoint yEndPoint(yEndX,yEndY);
    painter->drawLine(beginPoint,xEndPoint);
    painter->drawLine(beginPoint,yEndPoint);

    //*****************����������ͷ*********/
    int xOffset=13;
    brush.setColor(Qt::black);
    brush.setStyle(Qt::SolidPattern);
    painter->setBrush(brush);

    QPoint xarrowRightPoint(xEndX+xOffset,xEndY);
    QPoint xarrowTopPoint(xEndX,-xOffset*tan(PI/6)+xEndY);
    QPoint xarrowBotPoint(xEndX,xOffset*tan(PI/6)+xEndY);
    static const QPoint xarrowPoints[3] = {
    xarrowRightPoint,xarrowTopPoint,xarrowBotPoint,
    };
    painter->drawPolygon(xarrowPoints,3);

    QPoint yarrowTopPoint(yEndX,yEndY-xOffset);
    QPoint yarrowRightPoint(xOffset*tan(PI/6)+yEndX,yEndY);
    QPoint yarrowLeftPoint(-xOffset*tan(PI/6)+yEndX,yEndY);
    static const QPoint yarrowPoints[3] = {
    yarrowTopPoint,yarrowLeftPoint,yarrowRightPoint,
    };
    painter->drawPolygon(yarrowPoints,3);
    painter->setBrush(Qt::NoBrush);

    /************��ע������**********/
    painter->drawText(xEndX,xEndY+20,tr("HZ"));
    //painter->rotate(270);
    painter->drawText(yEndY,yEndX+20,tr("dB"));
    //painter->rotate(90);


    /*************************/
    QVector<qreal> dashes;
    qreal space = 3;
    dashes << 5 << space << 5 << space;
    pen.setDashPattern(dashes);
    pen.setWidth(2);
    pen.setColor(Qt::blue);
    painter->setPen(pen);

    QPoint point5(90,200);
    QPoint point6(100,155);
    QPoint point7(250,110);
    QPoint point8(300,80);

    painter->drawPath(drawBezierCurve(point5,point6));
    painter->drawPath(drawBezierCurve(point6,point7));
    painter->drawPath(drawBezierCurve(point7,point8));
}
Exemplo n.º 22
0
 void Editor::onMapReady()
 {
   myUi->graphicsView->scene()->setSceneRect(0, 0, myGame->generator()->width(), myGame->generator()->height());
   for (unsigned int i = 0; i < myGame->generator()->regions().size(); i++)
   {
     QPolygonF qring, sqring;
     auto ring = boost::geometry::exterior_ring(myGame->generator()->regions()[i].poly);
     boost::geometry::convert(ring, qring);
     boost::geometry::simplify(qring, sqring, 1);
     QPen pen;
     pen.setColor(QColor(0,0,0));
     pen.setStyle(Qt::PenStyle::DashLine);
     QBrush brush;
     brush.setStyle(Qt::BrushStyle::SolidPattern);
     std::string colour = myGame->biomes()[myGame->generator()->regions()[i].biome]->jsonValue["mapColour"].asString();
     pen.setColor(QColor(colour.c_str()));
     brush.setColor(QColor(colour.c_str()));
     QGraphicsPolygonItem * pi = new RegionPolygonItem(this);
     pi->setPen(pen);
     pi->setBrush(brush);
     pi->setPolygon(sqring);
     QPolygonF convex;
     boost::geometry::convex_hull(sqring, convex);
     double area = boost::geometry::area(convex);
     pi->setZValue(-area);
     pi->setData(0, i);
     pi->setFlag(QGraphicsItem::GraphicsItemFlag::ItemIsFocusable, true);
     pi->setFlag(QGraphicsItem::GraphicsItemFlag::ItemIsSelectable, true);
     myUi->graphicsView->scene()->addItem(pi);
   }
 }
Exemplo n.º 23
0
void koregui::FrameBufferStageItem::paint(QPainter* painter,
                                     const QStyleOptionGraphicsItem* option,
                                     QWidget* widget) {
  QBrush b;
  QPen p;
  QFont font("Arial");
  QStaticText text;
 
  p.setStyle(Qt::PenStyle::NoPen);
  b.setColor((isSelected())?QColor(86,86,86):QColor(44,44,44));
  b.setStyle(Qt::BrushStyle::SolidPattern);
  painter->setPen(p);
  painter->setBrush(b);
  painter->drawRect(0, 0, _bufferwidth, _bufferheight);
 
  font.setBold(true);
  font.setPointSize(12);
  painter->setFont(font);
 
  text.setText(_name.c_str());
  p.setColor(QColor(255,255,255));
  p.setStyle(Qt::PenStyle::SolidLine);
  painter->setPen(p);
  painter->drawStaticText(10,10, text);
  painter->drawImage(_bufferwidth - 26, 10, QImage("./assets/icons/gear.png"));
}
Exemplo n.º 24
0
bool readBrushNode( const QDomElement& element, QBrush& brush )
{
    bool ok = true;
    QColor tempColor;
    Qt::BrushStyle tempStyle;
    QPixmap tempPixmap;
    QDomNode node = element.firstChild();
    while( !node.isNull() ) {
        QDomElement element = node.toElement();
        if( !element.isNull() ) { // was really an element
            QString tagName = element.tagName();
            if( tagName == "Color" ) {
                ok = ok & readColorNode( element, tempColor );
            } else if( tagName == "Style" ) {
		QString value;
                ok = ok & readStringNode( element, value );
		tempStyle = stringToBrushStyle( value );
            } else if( tagName == "Pixmap" ) {
                ok = ok & readPixmapNode( element, tempPixmap );
            } else {
                qDebug( "Unknown tag in brush" );
            }
        }
        node = node.nextSibling();
    }

    if( ok ) {
	brush.setColor( tempColor );
	brush.setStyle( tempStyle );
        if( !tempPixmap.isNull() )
            brush.setPixmap( tempPixmap );
    }

    return ok;
}
Exemplo n.º 25
0
BrushPropertyManager::ValueChangedResult BrushPropertyManager::valueChanged(QtVariantPropertyManager *vm, QtProperty *property, const QVariant &value)
{
    switch (value.type()) {
    case QVariant::Int: // Style subproperty?
        if (QtProperty *brushProperty = m_brushStyleSubPropertyToProperty.value(property, 0)) {
            const QBrush oldValue = m_brushValues.value(brushProperty);
            QBrush newBrush = oldValue;
            const int index = value.toInt();
            newBrush.setStyle(brushStyleIndexToStyle(index));
            if (newBrush == oldValue)
                return Unchanged;
            vm->variantProperty(brushProperty)->setValue(newBrush);
            return Changed;
        }
        break;
    case QVariant::Color: // Color  subproperty?
        if (QtProperty *brushProperty = m_brushColorSubPropertyToProperty.value(property, 0)) {
            const QBrush oldValue = m_brushValues.value(brushProperty);
            QBrush newBrush = oldValue;
            newBrush.setColor(qvariant_cast<QColor>(value));
            if (newBrush == oldValue)
                return Unchanged;
            vm->variantProperty(brushProperty)->setValue(newBrush);
            return Changed;
        }
        break;
    default:
        break;
    }
    return NoMatch;
}
Exemplo n.º 26
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);
}
Exemplo n.º 27
0
void Canvas::paintEvent(QPaintEvent *event)
{

    QPainter painter(this);
    QRect dirtyRect = event->rect();
    if(dirtyRect.isEmpty())return;
    //    painter.setOpacity(opacity);
    combineLayers(dirtyRect);

    painter.drawPixmap(dirtyRect, image, dirtyRect);

    if(!isEnabled()){
        QBrush brush;
        brush.setStyle(Qt::BDiagPattern);
        brush.setColor(Qt::lightGray);
        painter.setBrush(brush);
        QRect rect = this->rect();
        rect.setWidth(rect.width());
        rect.setHeight(rect.height());
        painter.drawRect(rect);
    }

    QStyleOption opt;
    opt.init(this);
    style()->drawPrimitive(QStyle::PE_Widget,
                           &opt, &painter, this);

}
Exemplo n.º 28
0
void 
RSceneDevice::Circle(double x, double y, double r,
		     R_GE_gcontext *gc)
{
    if (debug) Rprintf("RSceneDevice::Circle\n");
    QPen pen(Qt::NoPen);
    QBrush brush;
    QRectF rect(x - r, y - r, 2 * r, 2 * r);
    int col = gc->col;
    int fill = gc->fill;
    // double gamma = gc->gamma;
    double lwd = gc->lwd;
    int lty = gc->lty;     // FIXME: should be easy to add
    if (col != NA_INTEGER && !R_TRANSPARENT(col)) {
	pen.setStyle(lty2style(lty));
	pen.setColor(r2qColor(col));
	pen.setWidthF(lwd);
    }
    if (fill != NA_INTEGER && !R_TRANSPARENT(fill)) {
	brush.setColor(r2qColor(fill));
	brush.setStyle(Qt::SolidPattern);
    }
    // FIXME: We can either create items separately and add them in
    // addClippedItem() as here, or do addClippedItem(addEllipse(...))
    // which removes and adds (as in the other callbacks currently).
    // The first is probably better, so should fix the others.
    addClippedItem(addEllipse(rect, pen, brush));
//     QGraphicsEllipseItem *item = new QGraphicsEllipseItem(rect);
//     item->setPen(pen);
//     item->setBrush(brush);
//     addClippedItem(item);
    return;
}
Exemplo n.º 29
0
QPixmap KisLightSource::createSelectedBackground()
{
    QPen pen;
    QBrush brush;
    QPixmap harhar(m_icondiameter + m_selecthalothickness * 2 + 2,
                   m_icondiameter + m_selecthalothickness * 2 + 2);
    harhar.fill(QColor(0,0,0,0));

    QPainter painter(&harhar);

    painter.setBackgroundMode(Qt::TransparentMode);
    painter.setRenderHint(QPainter::Antialiasing, 0x08);

    pen.setWidth(m_selecthalothickness);
    pen.setColor(QColor(255, 255, 0));

    brush.setStyle(Qt::SolidPattern);
    brush.setColor(m_color);

    painter.setBrush(brush);
    painter.setPen(pen);
    painter.drawEllipse(m_selecthalothickness,
                        m_selecthalothickness,
                        m_icondiameter - m_selecthalothickness,
                        m_icondiameter - m_selecthalothickness);

    return harhar;
}
Exemplo n.º 30
0
void 
RSceneDevice::Polygon(int n, double *x, double *y,
		      R_GE_gcontext *gc)
{
    if (debug) Rprintf("RSceneDevice::Polygon\n");
    QPen pen(Qt::NoPen);
    QBrush brush;
    QPolygonF polygon;
    if (n > 0) {
	for (int i = 0; i < n; i++) {
	    polygon <<  QPointF(x[i], y[i]);
	}
	// FIXME: do we need to explicitly close the polygon?
	polygon <<  QPointF(x[0], y[0]);
	int col = gc->col;
	int fill = gc->fill;
	//double gamma = gc->gamma;
	double lwd = gc->lwd;
	int lty = gc->lty;
	if (col != NA_INTEGER && !R_TRANSPARENT(col)) {
	    pen.setStyle(lty2style(lty));
	    pen.setColor(r2qColor(col));
	    pen.setWidthF(lwd);
	}
	if (fill != NA_INTEGER && !R_TRANSPARENT(fill)) {
	    brush.setColor(r2qColor(fill));
	    brush.setStyle(Qt::SolidPattern);
	}
	addClippedItem(addPolygon(polygon, pen, brush));
     }
    return;
}