Ejemplo n.º 1
0
void FancyRectangle::drawShape(QPainter &p)
{
    QPen oldPen = p.pen();

    // draw rectangle
    p.setPen(QPen(QColor(118, 118, 118), 1));
    p.drawRect((int)x(), (int)y(),
               width(), height());

    // draw decorations
    p.setPen(QPen(QColor(192, 192, 192), 1));
    p.drawPoint((int)x(), (int)y());
    p.drawPoint((int)x(), (int)y() + height() - 1);
    p.drawPoint((int)x() + width() - 1, (int)y());
    p.drawPoint((int)x() + width() - 1, (int)y() + height() - 1);

    //    p.setPen(QPen(QColor(196, 194, 205), 1));
    p.setPen(QPen(p.brush().color().dark(120), 1));
    p.drawLine((int)x() + 1, (int)y() + height() - 2,
               (int)x() + width() - 2, (int)y() + height() - 2);
    p.drawLine((int)x() + width() - 2, (int)y() + height() - 1,
               (int)x() + width() - 2, (int)y() + 1);

    p.setPen(oldPen);
}
Ejemplo n.º 2
0
void QVectorMap::paintEvent(QPaintEvent * ev) {
   int w=size().width();
   int h=size().height();

   QPen dotPen;
   QPixmap buffer(size());
   QPainter p;
   buffer.fill(Qt::black); // erasing buffer
   p.begin(&buffer);
   p.initFrom(this);
   // drawing scale
   if (scale_ != 1) {
      int fix=80;
      int greyLevel=fix+(255-fix)*scale_/100;
      dotPen.setColor(QColor(greyLevel,greyLevel,greyLevel));
      p.setPen(dotPen);
      for(int i=-w/scale_;
          i<w/scale_;
          ++i) {
         for(int j=-h/scale_;
             j<h/scale_;
             ++j) {
            p.drawPoint(i*scale_+w/2,h-(j*scale_+h/2));
         }
      }
   }
   if (!vectorList_.empty()) {
      VectorList::const_iterator it=vectorList_.begin();
      Vector2D previous=*it;
      int NbPoint=vectorList_.size();
      int curPoint=1;
      while(it != vectorList_.end()) {
         dotPen.setColor(QColor(255-(255*curPoint/NbPoint),
                                255*curPoint/NbPoint,
                                0));
         p.setPen(dotPen);
         switch (mode_) {
         case DrawPoint:
            p.drawPoint((int)round((*it).x()*scale_+w/2),
                        (int)round(h-((*it).y()*scale_+h/2)));
            break;
         case DrawLine:
            p.drawLine((int)round(previous.x()*scale_+w/2),
                       (int)round(h-(previous.y()*scale_+h/2)),
                       (int)round((*it).x()*scale_+w/2),
                       (int)round(h-((*it).y()*scale_+h/2)));
            break;
         }
         previous=*it;
         ++curPoint;
         ++it;
      }
   }
   p.end();
   QPainter q(this);
   q.drawPixmap(0,0,buffer);
}
Ejemplo n.º 3
0
/*!

 */
void
FieldPainter::drawPenaltyAreaLines( QPainter & painter ) const
{
    const Options & opt = Options::instance();

    // set gdi objects
    painter.setPen( M_line_pen );
    painter.setBrush( Qt::NoBrush );

    // set screen coordinates of field
    int left_x   = opt.screenX( - Options::PITCH_HALF_LENGTH );
    int right_x  = opt.screenX( + Options::PITCH_HALF_LENGTH );

    // set penalty area params
    int pen_top_y    = opt.screenY( - Options::PENALTY_AREA_WIDTH*0.5 );
    int pen_bottom_y = opt.screenY( + Options::PENALTY_AREA_WIDTH*0.5 );
    double pen_circle_y_degree_abs
        = std::acos( ( Options::PENALTY_AREA_LENGTH - Options::PENALTY_SPOT_DIST )
                     / Options::PENALTY_CIRCLE_R )
        * ( 180.0 / M_PI );
    int span_angle = qRound( pen_circle_y_degree_abs * 2.0 * 16 );
    int pen_circle_r = opt.scale( Options::PENALTY_CIRCLE_R );
    int pen_circle_size = opt.scale( Options::PENALTY_CIRCLE_R * 2.0 );

    // left penalty area X
    int pen_x = opt.screenX( -( Options::PITCH_HALF_LENGTH - Options::PENALTY_AREA_LENGTH ) );
    // left arc
    int pen_spot_x = opt.screenX( -( Options::PITCH_HALF_LENGTH - Options::PENALTY_SPOT_DIST ) );
    painter.drawArc( pen_spot_x - pen_circle_r + 1,
                     opt.fieldCenter().y() - pen_circle_r,
                     pen_circle_size,
                     pen_circle_size,
                     qRound( -pen_circle_y_degree_abs * 16 ),
                     span_angle );
    // left rectangle
    painter.drawLine( left_x, pen_top_y, pen_x, pen_top_y );
    painter.drawLine( pen_x, pen_top_y, pen_x, pen_bottom_y );
    painter.drawLine( pen_x, pen_bottom_y, left_x, pen_bottom_y );
    // left spot
    painter.drawPoint( pen_spot_x, opt.fieldCenter().y() );

    // right penalty area X
    pen_x = opt.screenX( +( Options::PITCH_HALF_LENGTH - Options::PENALTY_AREA_LENGTH ) );
    // right arc
    pen_spot_x = opt.screenX( +( Options::PITCH_HALF_LENGTH - Options::PENALTY_SPOT_DIST ) );
    painter.drawArc( pen_spot_x - pen_circle_r,
                     opt.fieldCenter().y() - pen_circle_r,
                     pen_circle_size, pen_circle_size,
                     qRound( ( 180.0 - pen_circle_y_degree_abs + 0.5 ) * 16 ),
                     span_angle );
    // right rectangle
    painter.drawLine( right_x, pen_top_y, pen_x, pen_top_y );
    painter.drawLine( pen_x, pen_top_y, pen_x, pen_bottom_y );
    painter.drawLine( pen_x, pen_bottom_y, right_x, pen_bottom_y );
    // right spot
    painter.drawPoint( pen_spot_x, opt.fieldCenter().y() );
}
Ejemplo n.º 4
0
void MapView::drawDot(QPainter &painter, const QPoint &pos, const QColor &color)
{
    painter.setPen(color);

    painter.drawPoint(pos);
    painter.drawPoint(pos + QPoint(1, 0));
    painter.drawPoint(pos + QPoint(0, 1));
    painter.drawPoint(pos + QPoint(1, 1));
}
Ejemplo n.º 5
0
void LaptopClient::updateActiveBuffer( )
{
    QRect rTitle = titleRect();
    if( !bufferDirty && (lastBufferWidth == rTitle.width()))
        return;
    if ( rTitle.width() <= 0 || rTitle.height() <= 0 )
	return;
    lastBufferWidth = rTitle.width();
    bufferDirty = false;

    activeBuffer = QPixmap(rTitle.width(), rTitle.height());
    QPainter p;
    QRect r(0, 0, activeBuffer.width(), activeBuffer.height());
    p.begin(&activeBuffer);
    if(aUpperGradient){
        p.drawTiledPixmap(r, *aUpperGradient);
    }
    else{
        p.fillRect(r, options()->color(KDecoration::ColorTitleBar, true));
    }
    if(titlePix)
        p.drawTiledPixmap(r, *titlePix);

    p.setFont(options()->font(true, isToolWindow() ));
    QFontMetrics fm(options()->font(true));
    QPalette g = options()->palette(KDecoration::ColorTitleBar, true);
    g.setCurrentColorGroup( QPalette::Active );
    if(aUpperGradient)
        p.drawTiledPixmap(r.x()+((r.width()-fm.width(caption()))/2)-4,
                          r.y(), fm.width(caption())+8, r.height()-1,
                          *aUpperGradient);
    else
        p.fillRect(r.x()+((r.width()-fm.width(caption()))/2)-4, 0,
                   fm.width(caption())+8, r.height(),
                   g.brush(QPalette::Background));
    p.setPen(g.mid().color());
    p.drawLine(r.x(), r.y(), r.right(), r.y());
    p.drawLine(r.x(), r.y(), r.x(), r.bottom());
    p.setPen(g.color(QPalette::Button));
    p.drawLine(r.right(), r.y(), r.right(), r.bottom());
    p.drawLine(r.x(), r.bottom(), r.right(), r.bottom());
    p.setPen(options()->color(KDecoration::ColorFont, true));
    p.drawText(r.x(), r.y()+1, r.width(), r.height()-1,
               Qt::AlignCenter, caption() );
    g = options()->palette(KDecoration::ColorFrame, true);
    g.setCurrentColorGroup( QPalette::Active );
    p.setPen(g.background().color());
    p.drawPoint(r.x(), r.y());
    p.drawPoint(r.right(), r.y());
    p.drawLine(r.right()+1, r.y(), r.right()+1, r.bottom());
    p.end();
}
Ejemplo n.º 6
0
void VpGrid::drawDotGrid(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);

    // Set the pen.
    QPen pen;
    pen.setColor(m_color);
    pen.setStyle(Qt::SolidLine);
    gc->setPen(pen);

    for (int i = 0; i < gridGC.m_ynum + 1; i++) {
        y = gridGC.m_yll + (i * gridGC.m_dy);
        for (int j = 0; j < gridGC.m_xnum; j++) {
            x = gridGC.m_xll + (j * gridGC.m_dx);
            gc->drawPoint(x, y);
        }
    }

    // Flush graphics to display.
    //gc.flush();

    //delete gc;
}
Ejemplo n.º 7
0
int main( int argc, char *argv[] ){
#ifdef APP
    QApplication a(argc, argv);
    MainWindow w(800, 600);
    w.show();

    return a.exec();
#else
    QImage image(400, 400, QImage::Format_RGB888);

    QPainter painter;
    image.fill(Qt::white);
    painter.begin(&image);
    painter.setPen(QPen(Qt::black,1));

    int s = 1;
    int c = 0;
    for (int i = 0; i < 400; i+=s) {
        for (int j = 0; j < 400; j+=s) {
            //painter.drawRect( i, 0 , i, 399 );
            //painter.drawRect( 0, j , 399, j );
            if( c % 2 ){
                painter.drawPoint( i+1, j+1 );
            }
            c++;
        }
        c++;
    }
    painter.end();
    image.save("шахматы2.png");

#endif
    

}
Ejemplo n.º 8
0
void ClusterView::eraseTheLastMovingLine(QColor polygonColor){
  //The user moved since the last left click, a line has been drawn in the mouseMoveEvent
  if(nbSelectionPoints != selectionPolygon.size()){
    //set existLastMovingLine to true to correctely erase the closed polygon
    existLastMovingLine = true;
    
    //Paint in the buffer to allow the selection to be redrawn after a refresh
    QPainter painter;
    painter.begin(&doublebuffer);
    //set the window (part of the word I want to show)
    QRect r((QRect)window);
    painter.setWindow(r.left(),r.top(),r.width()-1,r.height()-1);//hack because Qt QRect is used differently in this function
    painter.setRasterOp(XorROP);
    painter.setPen(polygonColor);
  
    //Treat the case when we reach the first point of the selection
    if(nbSelectionPoints == 1){
      //Erase the last line drawn (in mouseMoveEvent).
      painter.drawPolyline(selectionPolygon,selectionPolygon.size()-2);
    }
    else{
      //CAUTION, Do not remove this line otherwise strang dots will appear
      painter.drawPoint(selectionPolygon.point(selectionPolygon.size()-2));
      //Erase the last line drawn (in mouseMoveEvent)
      painter.drawPolyline(selectionPolygon,selectionPolygon.size()-2);
    }
    //Resize selectionPolygon to remove the last point
    //(the one set in mouseMoveEvent) from selectionPolygon
    selectionPolygon.resize(selectionPolygon.size()-1);

    nbSelectionPoints = selectionPolygon.size();  

    painter.end();
  }
}
Ejemplo n.º 9
0
void ClusterView::drawClusters(QPainter& painter,const QValueList<int>& clustersList,bool drawCircles){  
  //Loop on the clusters to be drawn
  QValueList<int>::const_iterator clusterIterator;

  ItemColors& clusterColors = doc.clusterColors();
  Data& clusteringData = doc.data();
         
  for(clusterIterator = clustersList.begin(); clusterIterator != clustersList.end(); ++clusterIterator){        
    //Get the color associated with the cluster and set the color to use to this color
    painter.setPen(clusterColors.color(*clusterIterator));
    //Get the iterator on the spikes of the current cluster
    Data::Iterator spikeIterator = clusteringData.iterator(static_cast<dataType>(*clusterIterator));
    //Iterate over the spikes of the cluster and draw them
    if(drawCircles) for(;spikeIterator.hasNext();spikeIterator.next()){
     QPoint point = spikeIterator(dimensionX,dimensionY);
     painter.setBrush(clusterColors.color(*clusterIterator));
     painter.drawEllipse(point.x() - 1,point.y() - 1,2,2);
    }
    else for(;spikeIterator.hasNext();spikeIterator.next()){
     painter.drawPoint(spikeIterator(dimensionX,dimensionY));
    }
  }

  painter.setBrush(NoBrush);
}
Ejemplo n.º 10
0
void EditorArea::paintGrid(QPainter& painter)
{
    painter.setPen(QPen(Qt::black, 0.5, Qt::SolidLine, Qt::RoundCap,
                            Qt::RoundJoin));

    float gridSpacing = workspace->getGridSpacing();

    float spacingOnScreen = size2screen(gridSpacing);

    QPointF screenOrigin(0, 0);
    QPointF screenEnd(width(), height());
    QPointF originPhysCoord = screen2graph(screenOrigin);

    float A = (originPhysCoord.x() - int(originPhysCoord.x() / gridSpacing) * gridSpacing) / gridSpacing;

    float B = (originPhysCoord.y() - int(originPhysCoord.y() / gridSpacing) * gridSpacing) / gridSpacing;

    int countX = 0;
    int countY = 0;
    while (- size2screen(A * gridSpacing) + countX * spacingOnScreen <= screenEnd.x() + 2 * spacingOnScreen) {
        while (- size2screen(B * gridSpacing) + countY * spacingOnScreen <= screenEnd.y() + 2 * spacingOnScreen) {

            painter.drawPoint(QPoint( - size2screen(A * gridSpacing) + countX * spacingOnScreen,
                                      - size2screen(B * gridSpacing) + countY * spacingOnScreen ));
            countY++;
        }
        countY = 0;
        countX++;
    }

}
void paintFoliation(const balazs::Foliation& foliation, QPainter &painter, int folW, int folH)
{
    painter.save();
    painter.setPen(Qt::SolidLine);
    painter.drawRect(0, 0, folW, folH);

    for(std::size_t i = 0; i < foliation.numIntervals(); i++){
        double singularityHeight = heightOfSingularity(foliation, i, folH);

        QPointF topPoint(folW * foliation.topDivPoints()[i], 0);
        QPointF middlePoint(folW * foliation.topDivPoints()[i], singularityHeight);
        QPointF bottomPoint(folW * foliation.topDivPoints()[i], folH);

        painter.setPen(Qt::SolidLine);
        painter.drawLine(topPoint, middlePoint);
        painter.setPen(Qt::DotLine);
        painter.drawLine(bottomPoint, middlePoint);

        painter.save();
        painter.setPen(QPen(Qt::black, 4));
        painter.drawPoint(middlePoint);
        painter.restore();
    }

    painter.setPen(Qt::DashLine);
    for(std::size_t i = 0; i < foliation.numIntervals(); i++){
        QPointF topPoint(folW * foliation.bottomDivPoints()[i], folH);
        QPointF bottomPoint(folW * foliation.bottomDivPoints()[i], 1.05 * folH);
        painter.drawLine(topPoint, bottomPoint);
    }
    painter.restore();
}
Ejemplo n.º 12
0
void My_Painter::drawCoordinates(QPainter &painter)
 {

     painter.setPen(QPen(Qt::black, 4, Qt::SolidLine));
     painter.setRenderHints(QPainter::Antialiasing, true);
     painter.drawPoint(10, 200);

     painter.setPen(Qt::black);

     painter.drawText(2 - xBoundingRect.width() / 2,
                      203 + xBoundingRect.height() / 2, tr("0") );

//---------------| t |------------------------------------------
     painter.drawLine(10, 10, 10, 200);
     painter.drawLine(10, 10, 15, 15);
     painter.drawLine(10, 10, 5, 15);
     painter.drawText( 2 - xBoundingRect.width() / 2,
                       5 + xBoundingRect.height() / 2, tr("t") );
//--------------------------------------------------------------

//---------------| n |------------------------------------------
     painter.drawLine(10, 200, 320, 200);
     painter.drawLine(320, 200, 315, 195);
     painter.drawLine(320, 200, 315, 205);
     painter.drawText(326 - yBoundingRect.width() / 2,
                      201 + yBoundingRect.height() / 2, tr("n"));
//--------------------------------------------------------------
 }
Ejemplo n.º 13
0
void
DewarpingView::paintXSpline(
	QPainter& painter, InteractionState const& interaction,
	InteractiveXSpline const& ispline)
{
	XSpline const& spline = ispline.spline();

	painter.save();
	painter.setBrush(Qt::NoBrush);

#if 0 // No point in drawing the curve itself - we already draw the grid.
	painter.setWorldTransform(imageToVirtual() * virtualToWidget());
	
	QPen curve_pen(Qt::blue);
	curve_pen.setWidthF(1.5);
	curve_pen.setCosmetic(true);
	painter.setPen(curve_pen);
	
	std::vector<QPointF> const polyline(spline.toPolyline());
	painter.drawPolyline(&polyline[0], polyline.size());
#endif

	// Drawing cosmetic points in transformed coordinates seems unreliable,
	// so let's draw them in widget coordinates.
	painter.setWorldMatrixEnabled(false);

	QPen existing_point_pen(Qt::red);
	existing_point_pen.setWidthF(4.0);
	existing_point_pen.setCosmetic(true);
	painter.setPen(existing_point_pen);

	int const num_control_points = spline.numControlPoints();
	for (int i = 0; i < num_control_points; ++i) {
		painter.drawPoint(sourceToWidget(spline.controlPointPosition(i)));
	}

	QPointF pt;
	if (ispline.curveIsProximityLeader(interaction, &pt)) {
		QPen new_point_pen(existing_point_pen);
		new_point_pen.setColor(QColor(0x00ffff));
		painter.setPen(new_point_pen);
		painter.drawPoint(pt);
	}

	painter.restore();
}
Ejemplo n.º 14
0
 void operator()
     ( QPainter & painter
     , const DrawPoint & d
     ) const
 {
     painter.setPen( d.pen );
     painter.drawPoint( d.p );
 }
Ejemplo n.º 15
0
void doPaint(QPainter & p)
{
    QRgb rgb = qRgb(161, 161, 161);

    p.setBackground(QBrush(rgb));
    p.eraseRect(0, 0, LCD_W, LCD_H);

    if (1) {
#if !defined(PCBTARANIS)
        rgb = qRgb(0, 0, 0);
        p.setPen(rgb);
        p.setBrush(QBrush(rgb));
#endif

#if defined(PCBTARANIS)
        unsigned int previousDepth = 0xFF;
#endif

        for (int y=0; y<LCD_H; y++) {
#if defined(PCBTARANIS)
            unsigned int idx = (y/2) * LCD_W;
#else
            unsigned int idx = (y/8) * LCD_W;
            unsigned int mask = (1 << (y%8));
#endif
            for (int x=0; x<LCD_W; x++, idx++) {
#if !defined(PCBTARANIS)
                if (lcd_buf[idx] & mask) {
                    p.drawPoint(x, y);
                }
#else
                unsigned int z = (y & 1) ? (lcd_buf[idx] >> 4) : (lcd_buf[idx] & 0x0F);
                if (z) {
                    if (z != previousDepth) {
                        previousDepth = z;
                        rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
                        p.setPen(rgb);
                        p.setBrush(QBrush(rgb));
                    }
                    p.drawPoint(x, y);
                }
#endif
            }
        }
    }
Ejemplo n.º 16
0
// =============================================================================
// Desenha a grade
// =============================================================================
void DesignerSurface::drawGrid(QPainter& painter)
{
    const int xSpacing = m_gridSize.x();
    const int ySpacing = m_gridSize.y();
    painter.setPen(Qt::darkGray);
    for (int y = ySpacing; y < size().height(); y += ySpacing)
        for (int x = xSpacing; x < size().width(); x += xSpacing)
            painter.drawPoint(x, y);
}
void DrawAlgo::draw8Points(QPainter& painter,int xc,int yc,int X,int Y)
{
    painter.drawPoint(X+xc,Y+yc);
    painter.drawPoint(-X+xc,Y+yc);
    painter.drawPoint(-X+xc,-Y+yc);
    painter.drawPoint(X+xc,-Y+yc);
    painter.drawPoint(Y+xc,X+yc);
    painter.drawPoint(-Y+xc,X+yc);
    painter.drawPoint(-Y+xc,-X+yc);
    painter.drawPoint(Y+xc,-X+yc);

}
Ejemplo n.º 18
0
void TestWidget::paintEvent(QPaintEvent *evt)
{
    QPainter painter;
    painter.begin(pixmap);
    painter.drawPoint(pt);
    painter.end();
    painter.begin(this);
    painter.drawPixmap(0, 0, *pixmap);
    painter.end();
}
Ejemplo n.º 19
0
void Pencil::drawPoint(const QPointF &st)
{
    QPainter painter;
    if(!painter.begin(surface_->imagePtr())){
        return;
    }
    painter.setPen(pencil);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.drawPoint(st);
    painter.end();
}
Ejemplo n.º 20
0
void KateRenderer::paintTrailingSpace(QPainter &paint, qreal x, qreal y)
{
  QPen penBackup( paint.pen() );
  QPen pen( config()->tabMarkerColor() );
  pen.setWidthF(spaceWidth() / 3.5);
  pen.setCapStyle(Qt::RoundCap);
  paint.setPen( pen );

  paint.drawPoint( QPointF(x, y) );
  paint.setPen( penBackup );
}
void RenderArea::drawTraj(QPainter &painter)
{
    for (int i = 0; i < points.size(); i++) {
        painter.setPen(QPen(pointsColors[i], 2, Qt::SolidLine, Qt::RoundCap));
        painter.drawPoint(points[i]);
        if (showVelocities) {
            painter.setPen(QPen(Qt::black, 0.2, Qt::SolidLine, Qt::RoundCap));
            painter.drawPolygon(pointsPolygons[i]);
        }
    }
}
Ejemplo n.º 22
0
int drv_painter(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QPainter *self = (QPainter*)head->native;
    switch (drvid) {
    case PAINTER_INIT: {
        drvNewHead(a0,new QPainter);
        break;
    }
    case PAINTER_DESTROY: {
        drvDelObj(a0,self);
        break;
    }
    case PAINTER_BEGIN: {
        self->begin(drvGetWidget(a1));
        break;
    }
    case PAINTER_END: {
        self->end();
        break;
    }
    case PAINTER_SETFONT: {
        self->setFont(drvGetFont(a1));
        break;
    }
    case PAINTER_FONT: {
        drvSetFont(a1,self->font());
        break;
    }
    case PAINTER_DRAWPOINT: {
        self->drawPoint(drvGetPoint(a1));
        break;
    }
    case PAINTER_DRAWLINE: {
        self->drawLine(drvGetPoint(a1),drvGetPoint(a2));
        break;
    }
    case PAINTER_DRAWLINES: {
        self->drawLines(drvGetPoints(a1));
        break;
    }
    case PAINTER_DRAWPOLYLINE: {
        self->drawPolyline(drvGetPoints(a1));
        break;
    }
    case PAINTER_DRAWTEXT: {
        self->drawText(drvGetPoint(a1),drvGetString(a2));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
Ejemplo n.º 23
0
void TikzEditor::paintSpace(QPainter &painter, qreal x, qreal y)
{
	QPen penBackup(painter.pen());
	QPen pen(m_whiteSpacesColor);
	pen.setWidthF(spaceWidth() / 3.5);
	pen.setCapStyle(Qt::RoundCap);
	painter.setPen(pen);

	painter.drawPoint(QPointF(x, y));
	painter.setPen(penBackup);
}
Ejemplo n.º 24
0
void Pencil::drawPoint(const QPointF &st)
{
    QPainter painter;
    if(directDraw_ && surface_ ){
        painter.begin(surface_);
    }else{
        painter.begin(&result);
    }
    painter.setPen(pencil);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.drawPoint(st);
}
Ejemplo n.º 25
0
void tst_QPicture::boundaryValues()
{
    QPicture picture;

    QPainter painter;
    painter.begin(&picture);

    QFETCH(int, x);
    QFETCH(int, y);
    painter.drawPoint(QPoint(x, y));

    painter.end();
}
Ejemplo n.º 26
0
void UMLViewCanvas::drawBackground( QPainter & painter, const QRect & clip ) {
    QCanvas::drawBackground( painter, clip );
    if( m_pView -> getShowSnapGrid() ) {
        painter.setPen( Qt::gray );
        int gridX = m_pView -> getSnapX();
        int gridY = m_pView -> getSnapY();
        int numX = width() / gridX;
        int numY = height() / gridY;
        for( int x = 0; x <= numX; x++ )
            for( int y = 0; y < numY; y++ )
                painter.drawPoint( x * gridX, y * gridY );
    }
}
Ejemplo n.º 27
0
QRect Brush::mousePress(const QString &brush, QPainter &painter,
                                   const QPoint &pos)
{
	painter.save();
	painter.setCompositionMode(QPainter::CompositionMode_Plus);
	painter.drawPoint(pos);
	painter.restore();

	int rad = painter.pen().width() / 2;
    QRect boundingRect = QRect(pos, pos).normalized()
                                              .adjusted(-rad, -rad, +rad, +rad);
    return boundingRect;
}
Ejemplo n.º 28
0
void Plotter::doPaint(QPainter &painter)
{
    QColor c1(127, 0, 0);
    QColor c2(0, 127, 0);
    QColor c3(0, 0, 127);
    QPen p(c1);
    p.setWidth(2);
    painter.setPen(p);

    QPainterPath path_sign;
    QPainterPath path_res;

    //////////////////////////////////
    door_.setMainData(E_, tlim_);
    //////////////////////////////////

    //for rand()
    QTime time = QTime::currentTime();
    qsrand((uint)time.msec());

    //for signal
    QPointF p_sign;
    float sig_end = 6*M_PI;
    float sig_count = width()/2;
    float sig_step = sig_end/sig_count;
    float count = 0;

    for (float i=sig_step; i<sig_end; i+=sig_step) {
        int k = randInt(noise_,-1*noise_);

        //drawing signal
        p_sign.setX(count++);
        p_sign.setY(MyFunc(i)+k);
        path_sign.lineTo(p_sign);

        door_.hadlePoint(p_sign);
        if (door_.storePointChanged()) {
            path_res.lineTo(door_.getLastStoredPoint());
            painter.drawPoint(door_.getLastStoredPoint());
        }
    }

    p.setColor(c2);
    p.setWidth(0.5);
    painter.setPen(p);
    painter.drawPath(path_sign);
    p.setColor(c3);
    p.setWidth(0.5);
    painter.setPen(p);
    painter.drawPath(path_res);
}
kpToolWidgetSpraycanSize::kpToolWidgetSpraycanSize (QWidget *parent, const char *name)
    : kpToolWidgetBase (parent, name)
{
#if DEBUG_KP_TOOL_WIDGET_SPRAYCAN_SIZE
    kdDebug () << "kpToolWidgetSpraycanSize::kpToolWidgetSpraycanSize() CALLED!" << endl;
#endif

    for (int i = 0; i < int (sizeof (spraycanSizes) / sizeof (spraycanSizes [0])); i++)
    {
        int s = spraycanSizes [i];
        QString iconName = QString ("tool_spraycan_%1x%1").arg (s).arg(s);
        
    #if DEBUG_KP_TOOL_WIDGET_SPRAYCAN_SIZE
        kdDebug () << "\ticonName=" << iconName << endl;
    #endif

        QPixmap pixmap (s, s);
        pixmap.fill (Qt::white);
        
        QPainter painter (&pixmap);
        painter.drawPixmap (0, 0, UserIcon (iconName));
        painter.end ();

        QImage image = kpPixmapFX::convertToImage (pixmap);

        QBitmap mask (pixmap.width (), pixmap.height ());
        mask.fill (Qt::color0);

        painter.begin (&mask);
        painter.setPen (Qt::color1);
        
        for (int y = 0; y < image.height (); y++)
        {
            for (int x = 0; x < image.width (); x++)
            {
                if ((image.pixel (x, y) & RGB_MASK) == 0/*black*/)
                    painter.drawPoint (x, y);  // mark as opaque
            }
        }

        painter.end ();

        pixmap.setMask (mask);
        
        addOption (pixmap, i18n ("%1x%2").arg (s).arg (s)/*tooltip*/);
        if (i == 1)
            startNewOptionRow ();
    }

    finishConstruction (0, 0);
}
Ejemplo n.º 30
0
void FrameHeadGadget::drawPlayingHead(QPainter &p, const QColor &lightColor, const QColor &darkColor)
{
	int currentFrame = getCurrentFrame();
	int yy = index2y(currentFrame);

	std::vector<QPointF> pts;
	int xa = 12; // m_a;
	int xx = xa; // m_a
	pts.push_back(QPointF(xx, yy));
	pts.push_back(QPointF(xx + 10, yy));
	pts.push_back(QPointF(xx + 13, yy + 1));
	pts.push_back(QPointF(xx + 17, yy + 5));
	pts.push_back(QPointF(xx + 13, yy + 9));
	pts.push_back(QPointF(xx + 10, yy + 10));
	pts.push_back(QPointF(xx, yy + 10));
	drawPolygon(p, pts, true, lightColor);
	p.setPen(darkColor);
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 4; j++)
			p.drawPoint(xx + 3 + i * 2, yy + 2 + j * 2);

	p.fillRect(QRect(xx - 7, yy + 1, 7, 9), QBrush(lightColor));
	p.setPen(darkColor);
	p.drawLine(xx - 9, yy + 5, xx - 8, yy + 5);

	p.setPen(Qt::black);
	p.drawLine(xx - 7, yy, xx - 1, yy);
	p.drawLine(xx - 7, yy + 10, xx - 1, yy + 10);

	p.setPen(Qt::black);
	xx = xa - 6;
	p.drawPoint(xx - 4, yy + 5);
	p.drawRect(QRect(xx - 6, yy, 4, 4));
	p.drawRect(QRect(xx - 6, yy + 6, 4, 4));

	p.fillRect(QRect(xx - 5, yy + 1, 3, 3), QBrush(lightColor));
	p.fillRect(QRect(xx - 5, yy + 7, 3, 3), QBrush(lightColor));
}