void counter::paint(QPainter &p, bool drawScore, int score, bool drawTimer, const QColor &c1, const QColor &c2, const QColor &c3, QSvgRenderer *renderer) { p.save(); p.translate(45, 15); p.setPen(QPen(Qt::black, 3)); p.setBrush(QColor(40, 40, 40)); if (drawTimer) { p.fillRect(-44, -13, 98, 48, p.brush()); p.drawRoundRect(-45, -15, 100, 50, 15, 15); } else { p.fillRect(-44, -13, 70, 48, p.brush()); p.drawRoundRect(-45, -15, 73, 50, 15, 15); } if (drawTimer) { p.fillRect(35, -6, 11, 9, c1); p.fillRect(35, 6, 11, 9, c2); p.fillRect(35, 18, 11, 9, c3); } if (drawScore) { p.translate(-5, -5); number n(score); n.paint(p, 2, renderer); } p.restore(); }
void GraphicsContext::fillPath() { if (paintingDisabled()) return; QPainter *p = m_data->p(); QPainterPath path = m_data->currentPath; switch (m_common->state.fillColorSpace) { case SolidColorSpace: if (fillColor().alpha()) p->fillPath(path, p->brush()); break; case PatternColorSpace: { TransformationMatrix affine; p->fillPath(path, QBrush(m_common->state.fillPattern->createPlatformPattern(affine))); break; } case GradientColorSpace: QGradient* gradient = m_common->state.fillGradient->platformGradient(); *gradient = applySpreadMethod(*gradient, spreadMethod()); p->fillPath(path, QBrush(*gradient)); break; } m_data->currentPath = QPainterPath(); }
void SdLostFoundMsgSupportCanvas::draw(QPainter & p) { if (! visible()) return; QRect r = rect(); if (selected()) p.fillRect(r, ::Qt::black); else { QBrush brsh = p.brush(); p.setBrush(::Qt::black); p.drawEllipse(r.left(), r.top(), LOSTFOUND_SIZE, LOSTFOUND_SIZE); p.setBrush(brsh); } FILE * fp = svg(); if (fp != 0) { const float rr = LOSTFOUND_SIZE / (float) 2.0; fprintf(fp, "<ellipse fill=\"black\" stroke=\"none\" cx=\"%g\" cy=\"%g\" rx=\"%g\" ry=\"%g\" />\n", (float)(r.left() + rr), (float)(r.top() + rr), rr, rr); } // don't use show_mark is selected : too small }
void WTextSourceViewerLine::drawFoldingLineHidden(QPainter &p,const QPointF &pt) { float demi_char_space=char_space/2.0f; QPointF pos(0,pt.y()-demi_char_space); QRectF text_pos(pos,QSizeF(char_space,char_space)); QPointF p3(pt.x(),pt.y()); QPointF p1c(char_space,pt.y()); QBrush b=p.brush(); p.setBrush(Qt::black); QRectF endPoint3(p3.x()-2,p3.y()-2,4,4); p.drawEllipse(endPoint3); p.setBrush(b); p.drawLine(p1c,p3); float pos_size=char_space; QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size); p.drawRoundRect(rectangle); float _x1=pos.x()+3.0f; float _y=pos.y()+pos_size/2.0f; float _x2=pos.x()+pos_size-3.0f; float _x=pos.x()+pos_size/2; float _y1=pos.y()+3; float _y2=pos.y()+pos_size-3; p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y)); p.drawLine(QPointF(_x,_y1),QPointF(_x,_y2)); }
static void drawBrushStyle(QPainter& painter, QRect rect, const QStyle::State& state, Qt::BrushStyle brushStyle) { rect.adjust(2, 2, -2, -2); switch (brushStyle) { case Qt::NoBrush: case Qt::LinearGradientPattern: case Qt::RadialGradientPattern: case Qt::ConicalGradientPattern: case Qt::TexturePattern: { auto str = QtnPropertyQBrushStyleBase::brushStyleToStr(brushStyle); qtnDrawValueText(str, painter, rect, state, nullptr); break; } default: { auto brush = painter.brush(); brush.setStyle(brushStyle); painter.save(); painter.setBrush(brush); painter.drawRect(rect); painter.restore(); } } }
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); }
// ******************************************************** ImageBufferData::ImageBufferData(const IntSize& size, bool accelerated) { QPainter* painter = new QPainter; m_painter = adoptPtr(painter); #if ENABLE(ACCELERATED_2D_CANVAS) if (accelerated) { m_impl = adoptPtr(new ImageBufferDataPrivateAccelerated(size)); } else #endif m_impl = adoptPtr(new ImageBufferDataPrivateUnaccelerated(size)); if (!m_impl->paintDevice()) return; if (!painter->begin(m_impl->paintDevice())) return; painter->setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing); QPen pen = painter->pen(); pen.setColor(Qt::black); pen.setWidth(1); pen.setCapStyle(Qt::FlatCap); pen.setJoinStyle(Qt::SvgMiterJoin); pen.setMiterLimit(10); painter->setPen(pen); QBrush brush = painter->brush(); brush.setColor(Qt::black); painter->setBrush(brush); painter->setCompositionMode(QPainter::CompositionMode_SourceOver); }
ImageBufferData::ImageBufferData(const IntSize& size) : m_pixmap(size) { if (m_pixmap.isNull()) return; m_pixmap.fill(QColor(Qt::transparent)); QPainter* painter = new QPainter; m_painter = adoptPtr(painter); if (!painter->begin(&m_pixmap)) return; // Since ImageBuffer is used mainly for Canvas, explicitly initialize // its painter's pen and brush with the corresponding canvas defaults // NOTE: keep in sync with CanvasRenderingContext2D::State QPen pen = painter->pen(); pen.setColor(Qt::black); pen.setWidth(1); pen.setCapStyle(Qt::FlatCap); pen.setJoinStyle(Qt::SvgMiterJoin); pen.setMiterLimit(10); painter->setPen(pen); QBrush brush = painter->brush(); brush.setColor(Qt::black); painter->setBrush(brush); painter->setCompositionMode(QPainter::CompositionMode_SourceOver); m_image = StillImage::createForRendering(&m_pixmap); }
void DSelector::paintEvent(QPaintEvent*) { QPainter painter; int w = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); int iw = (w < d->arrowsize) ? d->arrowsize : w; painter.begin(this); drawContents(&painter); QBrush brush; QPoint pos = calcArrowPos(value()); drawArrow(&painter, pos); if (indent()) { QStyleOptionFrame opt; opt.initFrom(this); opt.state = QStyle::State_Sunken; if (orientation() == Qt::Vertical) opt.rect.adjust(0, iw - w, -5, w - iw); else opt.rect.adjust(iw - w, 0, w - iw, -5); QBrush oldBrush = painter.brush(); painter.setBrush(Qt::NoBrush); style()->drawPrimitive(QStyle::PE_Frame, &opt, &painter, this); painter.setBrush(oldBrush); } painter.end(); }
void ParameterSetCanvas::draw(QPainter & p) { if (! visible()) return; QBrush brsh = p.brush(); QColor bckgrnd = p.backgroundColor(); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); QColor co = color(used_color); QRect r = rect(); FILE * fp = svg(); p.setBackgroundColor(co); if (used_color != UmlTransparent) p.setBrush(co); if (fp != 0) fprintf(fp, "<g>\n" "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n" "</g>\n", svg_color(used_color), r.x(), r.y(), r.width() - 1, r.height() - 1); p.drawRect(r); p.setBackgroundColor(bckgrnd); p.setBrush(brsh); if (selected()) show_mark(p, r); }
void ImageDisplayer::drawSavedContour(QPainter &painter) { //cout << "seeds size: " << seeds.size() << endl; //cout << "paths size: " << paths.size() << endl; if(seeds.size() == paths.size()) { for(int i=0; i<seeds.size(); i++) { // draw seed QBrush o = painter.brush(); painter.setBrush(QColor(255, 0, 0, 255)); int x = seeds[i].pos[0]; int y = seeds[i].pos[1]; int* tem = img2dis(x, y); painter.drawRect(tem[0]-3, tem[1]-3, 7, 7); painter.setBrush(o); // draw path QPainterPath path; vector<vec2i> p = paths[i]; int* tem2 = img2dis(p[0].pos[0], p[0].pos[1]); path.moveTo(tem2[0], tem2[1]); for(int j=1; j<p.size(); j++) { tem2 = img2dis(p[j].pos[0], p[j].pos[1]); path.lineTo(tem2[0], tem2[1]); } QPen op = painter.pen(); QPen pen(Qt::green, 3); painter.setPen(pen); painter.drawPath(path); painter.setPen(op); } } }
void ImageDisplayer::drawSeed(QPainter &painter) { QBrush o = painter.brush(); painter.setBrush(QColor(255, 0, 0, 255)); int* tem = img2dis(img_x, img_y); painter.drawRect(tem[0]-3, tem[1]-3, 7, 7); painter.setBrush(o); }
void CanvasRenderingContext2D::fillRect(float x, float y, float width, float height, ExceptionCode& ec) { ec = 0; if (!(width >= 0 && height >= 0)) { ec = INDEX_SIZE_ERR; return; } GraphicsContext* c = drawingContext(); if (!c) return; // FIXME: Do this through platform-independent GraphicsContext API. #if PLATFORM(CG) CGRect rect = CGRectMake(x, y, width, height); willDraw(rect); if (state().m_fillStyle->gradient()) { // Shading works on the entire clip region, so convert the rect to a clip. c->save(); CGContextClipToRect(c->platformContext(), rect); CGContextDrawShading(c->platformContext(), state().m_fillStyle->gradient()->platformShading()); c->restore(); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); CGContextFillRect(c->platformContext(), rect); } #elif PLATFORM(QT) QRectF rect(x, y, width, height); willDraw(rect); QPainter* p = static_cast<QPainter*>(c->platformContext()); if (state().m_fillStyle->gradient()) { p->fillRect(rect, QBrush(*(state().m_fillStyle->gradient()->platformShading()))); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); p->fillRect(rect, p->brush()); } #elif PLATFORM(CAIRO) FloatRect rect(x, y, width, height); willDraw(rect); cairo_t* cr = c->platformContext(); cairo_save(cr); if (state().m_fillStyle->gradient()) { cairo_set_source(cr, state().m_fillStyle->gradient()->platformShading()); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); } cairo_rectangle(cr, x, y, width, height); cairo_fill(cr); cairo_restore(cr); #endif }
void TabBarPrivate::drawMoveMarker(QPainter& painter, int x, int y) { QPolygon movmark; movmark << QPoint(x, y) << QPoint(x + 7, y) << QPoint(x + 4, y + 6); QBrush oldBrush = painter.brush(); painter.setBrush(Qt::black); painter.drawPolygon(movmark); painter.setBrush(oldBrush); }
void CanvasRenderingContext2D::fill() { GraphicsContext* c = drawingContext(); if (!c) return; // FIXME: Do this through platform-independent GraphicsContext API. #if PLATFORM(CG) CGContextBeginPath(c->platformContext()); CGContextAddPath(c->platformContext(), state().m_path.platformPath()); if (!state().m_path.isEmpty()) willDraw(CGContextGetPathBoundingBox(c->platformContext())); if (state().m_fillStyle->gradient()) { // Shading works on the entire clip region, so convert the current path to a clip. c->save(); CGContextClip(c->platformContext()); CGContextDrawShading(c->platformContext(), state().m_fillStyle->gradient()->platformShading()); c->restore(); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); CGContextFillPath(c->platformContext()); } #elif PLATFORM(QT) QPainterPath* path = state().m_path.platformPath(); QPainter* p = static_cast<QPainter*>(c->platformContext()); willDraw(path->controlPointRect()); if (state().m_fillStyle->gradient()) { p->fillPath(*path, QBrush(*(state().m_fillStyle->gradient()->platformShading()))); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); p->fillPath(*path, p->brush()); } #elif PLATFORM(CAIRO) cairo_t* pathCr = state().m_path.platformPath()->m_cr; cairo_t* cr = c->platformContext(); cairo_save(cr); willDraw(state().m_path.boundingRect()); if (state().m_fillStyle->gradient()) { cairo_set_source(cr, state().m_fillStyle->gradient()->platformShading()); c->addPath(state().m_path); cairo_fill(cr); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); c->addPath(state().m_path); cairo_fill(cr); } cairo_restore(cr); #endif clearPathForDashboardBackwardCompatibilityMode(); }
void CanvasRenderingContext2D::fill() { GraphicsContext* c = drawingContext(); if (!c) return; c->beginPath(); c->addPath(m_path); if (!m_path.isEmpty()) willDraw(m_path.boundingRect()); #if PLATFORM(CG) if (state().m_fillStyle->canvasGradient()) { // Shading works on the entire clip region, so convert the current path to a clip. c->save(); CGContextClip(c->platformContext()); CGContextDrawShading(c->platformContext(), state().m_fillStyle->canvasGradient()->gradient().platformGradient()); c->restore(); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); CGContextFillPath(c->platformContext()); } #elif PLATFORM(QT) QPainterPath* path = m_path.platformPath(); QPainter* p = static_cast<QPainter*>(c->platformContext()); if (state().m_fillStyle->canvasGradient()) { p->fillPath(*path, QBrush(*(state().m_fillStyle->canvasGradient()->gradient().platformGradient()))); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); p->fillPath(*path, p->brush()); } #elif PLATFORM(CAIRO) && !PLATFORM(BAL) cairo_t* cr = c->platformContext(); cairo_save(cr); if (state().m_fillStyle->canvasGradient()) { cairo_set_source(cr, state().m_fillStyle->canvasGradient()->gradient().platformGradient()); cairo_fill(cr); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); cairo_fill(cr); } cairo_restore(cr); #elif PLATFORM(BAL) //FIXME notImplemented(); #endif #if ENABLE(DASHBOARD_SUPPORT) clearPathForDashboardBackwardCompatibilityMode(); #endif }
void LettersDrawer::draw(QPainter& painter, Letter letter) { QBrush oldBrush = painter.brush(); QPen oldPen = painter.pen(); QBrush brush(m_color, Qt::BrushStyle::SolidPattern); QPen pen(m_color, Qt::PenStyle::SolidLine); painter.setBrush(brush); painter.setPen(pen); letter.draw(painter); painter.setBrush(oldBrush); painter.setPen(oldPen); }
void WorldPainter::paint(QPainter &p, Turtle &turtle, int xt, int yt) { auto oldPen = p.pen(); auto oldBrush = p.brush(); p.setPen(pen(turtle.getColor())); p.setBrush(brush(turtle.getColor())); auto triangle = getTriangle(); auto position = turtle.getPosition(); paint(p, triangle, position.getValue(0) + xt, position.getValue(1) + yt, turtle.getAngle(), 5.0); p.setPen(oldPen); p.setBrush(oldBrush); }
static void draw(unsigned icam, unsigned ncam, QPainter& painter, bool draw_fast) { int a0 = int(round(double(icam)/double(ncam)*5760)); int a1 = int(round(double(icam+1)/double(ncam)*5760)); if(painter.brush().style() == Qt::NoBrush) { painter.drawArc(QRectF(-1,-1,2,2),a0,a1-a0); } else if(painter.pen().color() != painter.brush().color()) { QPen pen = painter.pen(); painter.setPen(QPen(painter.brush().color())); painter.drawPie(QRectF(-1,-1,2,2),a0,a1-a0); painter.setPen(pen); painter.drawArc(QRectF(-1,-1,2,2),a0,a1-a0); } else { painter.drawPie(QRectF(-1,-1,2,2),a0,a1-a0); } }
void CanvasRenderingContext2D::fillRect(float x, float y, float width, float height) { if (!validateRectForCanvas(x, y, width, height)) return; GraphicsContext* c = drawingContext(); if (!c) return; FloatRect rect(x, y, width, height); willDraw(rect); // FIXME: Do this through platform-independent GraphicsContext API. #if PLATFORM(CG) if (state().m_fillStyle->canvasGradient()) { // Shading works on the entire clip region, so convert the rect to a clip. c->save(); CGContextClipToRect(c->platformContext(), rect); CGContextDrawShading(c->platformContext(), state().m_fillStyle->canvasGradient()->gradient().platformGradient()); c->restore(); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); CGContextFillRect(c->platformContext(), rect); } #elif PLATFORM(QT) QPainter* p = static_cast<QPainter*>(c->platformContext()); if (state().m_fillStyle->canvasGradient()) { p->fillRect(rect, QBrush(*(state().m_fillStyle->canvasGradient()->gradient().platformGradient()))); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); p->fillRect(rect, p->brush()); } #elif PLATFORM(CAIRO) && !PLATFORM(BAL) cairo_t* cr = c->platformContext(); cairo_save(cr); if (state().m_fillStyle->canvasGradient()) { cairo_set_source(cr, state().m_fillStyle->canvasGradient()->gradient().platformGradient()); } else { if (state().m_fillStyle->pattern()) applyFillPattern(); } cairo_rectangle(cr, x, y, width, height); cairo_fill(cr); cairo_restore(cr); #elif PLATFORM(BAL) //FIXME notImplemented(); #endif }
void KviCanvasEllipticItem::draw(QPainter &p) { if(isEnabled()) { QBrush b = p.brush(); if(m_properties["bHasBackground"].asBool())p.setBrush(m_properties["clrBackground"].asColor()); else p.setBrush(QBrush()); p.setPen(pen()); drawContent(p); p.setBrush(b); } if(isSelected())drawSelection(p); }
void Screen::drawCurrentStateArea(const World::City& city, QPainter& painter) const { if(!m_currentState) return; if(!m_mousePosition) return; // qDebug() << m_mousePosition->x() << ", " << m_mousePosition->y(); auto area = m_currentState->area(*m_mousePosition); // qDebug() << "{" << rect.topLeft().x() << ", " << rect.topLeft().y() << "}, {" << rect.bottomRight().x() << ", " << rect.bottomRight().y() << "}"; auto b = painter.brush(); QColor c = city.isAreaFreeToBuild(area) ? Qt::yellow : c = Qt::red; c.setAlphaF(.6); b.setColor(c); painter.setBrush(b); painter.drawRect(QRectF(QPoint(area.topLeft().x(), area.topLeft().y()), QSize(area.size().width(), area.size().height()))); }
TransparencyLayer(const QPainter& p, int width, int height) { pixmap = new QPixmap(width, height); painter = new QPainter(pixmap); painter->setPen(p.pen()); painter->setBrush(p.brush()); painter->setMatrix(p.matrix()); #if QT_VERSION >= 0x040200 painter->setOpacity(p.opacity()); #endif painter->setFont(p.font()); painter->setCompositionMode(p.compositionMode()); painter->setClipPath(p.clipPath()); }
void QtSpecialDigitPainter::paint(QPainter& aPainter, const QPoint& aPoint, int aMask) { aPainter.save(); QPen pen(aPainter.brush(), thickness); aPainter.setPen(pen); QPoint point(aPoint.x()+xOffset, aPoint.y()+yOffset); if(aMask & D_TOP) aPainter.drawLine(point.x(), point.y(), point.x()+width, point.y()); if(aMask & D_TL) aPainter.drawLine(point.x(), point.y(), point.x(), point.y()+height/2); if(aMask & D_TR) aPainter.drawLine(point.x()+width, point.y(), point.x()+width, point.y()+height/2); if(aMask & D_MIDDLE) aPainter.drawLine(point.x(), point.y()+height/2, point.x()+width, point.y()+height/2); if(aMask & D_BL) aPainter.drawLine(point.x(), point.y()+height/2, point.x(), point.y()+height); if(aMask & D_BR) aPainter.drawLine(point.x()+width, point.y()+height/2, point.x()+width, point.y()+height); if(aMask & D_BOTTOM) aPainter.drawLine(point.x(), point.y()+height, point.x()+width, point.y()+height); aPainter.restore(); }
void Screen::drawGround(const World::City& city, QPainter& painter) const { for(std::size_t i = 0; i < city.map().width(); i++) for(std::size_t j = 0; j < city.map().height(); j++) { QPen p = painter.pen(); p.setColor(Qt::black); p.setWidthF(.05); painter.setPen(p); QBrush b = painter.brush(); b.setStyle(Qt::SolidPattern); b.setColor(type2color(city.map().squareType({i, j}))); painter.setBrush(b); painter.drawRect(QRectF(QPointF(i, j), QSizeF(1, 1))); } }
// Note : should be called with lock held static inline bool maskPainter(int qtGraphDesc, QPainter &p) { bool r = false; QColor c; switch (QtGraphDescPool[qtGraphDesc].blendmode) { case java_awt_AlphaComposite_SRC_OVER: if((QtGraphDescPool[qtGraphDesc].currentalpha & 0x80) != 0) { c = Qt::color1; r = true; } break; case java_awt_AlphaComposite_SRC: c = (QtGraphDescPool[qtGraphDesc].currentalpha & 0x80) ? Qt::color1 : Qt::color0; r = true; break; case java_awt_AlphaComposite_CLEAR: c = Qt::color0; r = true; break; default: r = false; } if(r) { QPen qp(p.pen()); QBrush qb(p.brush()); qp.setColor(c); qb.setColor(c); if(p.isActive()) p.end(); p.begin((QPaintDevice *)(QtImageDescPool[QtGraphDescPool[qtGraphDesc].qid].mask)); p.setPen(qp); p.setBrush(qb); setPainterClip(&p, qtGraphDesc) ; } return r; }
/* static */ void AbstractAreaBase::paintFrameAttributes( QPainter& painter, const QRect& rect, const KChart::FrameAttributes& attributes ) { if ( !attributes.isVisible() ) return; // Note: We set the brush to NoBrush explicitly here. // Otherwise we might get a filled rectangle, so any // previously drawn background would be overwritten by that area. const QPen oldPen( painter.pen() ); const QBrush oldBrush( painter.brush() ); painter.setPen( PrintingParameters::scalePen( attributes.pen() ) ); painter.setBrush( Qt::NoBrush ); painter.drawRoundedRect( rect.adjusted( 0, 0, -1, -1 ), attributes.cornerRadius(), attributes.cornerRadius() ); painter.setBrush( oldBrush ); painter.setPen( oldPen ); }
void GraphicsContext::fillRect(const FloatRect& rect) { if (paintingDisabled()) return; QPainter *p = m_data->p(); switch (m_common->state.fillColorSpace) { case SolidColorSpace: if (fillColor().alpha()) p->fillRect(rect, p->brush()); break; case PatternColorSpace: p->fillRect(rect, QBrush(m_common->state.fillPattern.get()->createPlatformPattern(getCTM()))); break; case GradientColorSpace: p->fillRect(rect, QBrush(*(m_common->state.fillGradient.get()->platformGradient()))); break; } }
void QCPBase::redrawPins(QPainter & painter) { if (cpOwner->resReading) return; realignPins(painter); QPen op=painter.pen(); QBrush ob=painter.brush(); QFont of=painter.font(); QPen penPin=QPen(pinColor); QBrush brshPin=QBrush(pinColor,Qt::SolidPattern); painter.setPen(penPin); painter.setBrush(brshPin); QFont n=of; n.setBold(false); painter.setFont(n); for (int i=0;i<fInputs.count();i++) { QCPInput* a=fInputs[i]; painter.fillRect(QRect( a->relCoord.x()-QCP_PINSIZE/2, a->relCoord.y()-QCP_PINSIZE/2, QCP_PINSIZE, QCP_PINSIZE),brshPin); painter.drawText(QPoint( a->relCoord.x()+QCP_PINSIZE/2+1, a->relCoord.y()+painter.fontMetrics().height()/4), a->pinName); } for (int i=0;i<fOutputs.count();i++) { QCPOutput* a=fOutputs[i]; painter.fillRect(QRect( a->relCoord.x()-QCP_PINSIZE/2, a->relCoord.y()-QCP_PINSIZE/2, QCP_PINSIZE, QCP_PINSIZE),brshPin); painter.drawText(QPoint( a->relCoord.x()-QCP_PINSIZE/2-1 - painter.fontMetrics().width(a->pinName), a->relCoord.y()+painter.fontMetrics().height()/4), a->pinName); } painter.setFont(of); painter.setBrush(ob); painter.setPen(op); }
void WTextSourceViewerLine::drawFoldingLineVisible(QPainter &p,const QPointF &p1,const QPointF &p2) { QPolygonF area; float demi_char_space=char_space/2.0f; QPointF pos(0.0f,(p1.y()+p2.y())/2.0f-demi_char_space); QRectF text_pos(pos,QSizeF(char_space,char_space)); QPointF p3(demi_char_space,p2.y()); QRectF endPoint2(p2.x()-2,p2.y()-2,4,4); QBrush b=p.brush(); p.setBrush(Qt::black); if (p1!=p2) { QPointF p0(demi_char_space,p1.y()); QPointF p1b(demi_char_space,pos.y()); QPointF p2b(demi_char_space,pos.y()+char_space); QRectF endPoint1(p1.x()-2,p1.y()-2,4,4); area << p0 << p1 ; area << p0 << p1b ; area << p2b << p3 ; area << p3 << p2 ; p.drawEllipse(endPoint1); } else { QPointF p1c(char_space,p2.y()); area << p1c << p2 ; } p.drawEllipse(endPoint2); p.setBrush(b); p.drawLines(area); float pos_size=char_space; QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size); p.drawRoundRect(rectangle); float _x1=pos.x()+3.0f; float _y=pos.y()+pos_size/2.0f; float _x2=pos.x()+pos_size-3.0f; p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y)); }