void nsRenderingContextQt::UpdateGC() { QPainter *pGC; QColor color(NS_GET_R(mCurrentColor), NS_GET_G(mCurrentColor), NS_GET_B(mCurrentColor)); QPen pen(color,0,mQLineStyle); QBrush brush(color); pGC = mSurface->GetGC(); pGC->setPen(pen); pGC->setBrush(brush); pGC->setRasterOp(mFunction); if (mCurrentFont) pGC->setFont(mCurrentFont->font); if (mClipRegion) { QRegion *rgn = nsnull; pGC->setClipping(TRUE); mClipRegion->GetNativeRegion((void*&)rgn); pGC->setClipRegion(*rgn); } else { pGC->setClipping(FALSE); } }
void MapWidget::drawMarker(const MapMarker &marker, QPainter &painter, const QPointF &markerPosition, const QPointF &rectPosition) { QRectF markerRect = getMarkerRect(marker, rectPosition); QColor bgColor = getMarkerTextBackgroundColor(); painter.setBrush(QBrush(bgColor)); // drawing the line connector painter.setPen(bgColor); painter.setClipping(true); painter.setClipRegion(QRegion(rect()).subtracted(markerRect.toRect())); painter.drawLine(markerRect.center(), markerPosition); // drawing the transparent background painter.setClipping(false); painter.setPen(Qt::NoPen); painter.drawRect(markerRect); // drawing the player marker const static qreal markerSize = 1.6; painter.setBrush(getMarkerColor()); painter.drawEllipse(markerPosition, markerSize, markerSize); qreal hOffset = rectPosition.x() + TEXT_MARGIM; // left margin // draw the player name text QString playerName = marker.getPlayerName(); painter.setFont(userFont); QFontMetrics metrics = painter.fontMetrics(); qreal playerNameWidth = metrics.width(playerName); painter.setPen(getMarkerTextColor()); qreal textY = rectPosition.y() + TEXT_MARGIM + metrics.descent()/2.0; painter.drawText(hOffset, textY, playerName); hOffset += playerNameWidth + TEXT_MARGIM * 3; // draw the player country name painter.setFont(countryFont); metrics = painter.fontMetrics(); QColor countryNameColor(getMarkerTextColor()); countryNameColor.setAlpha(180); // country name is drawed using some alpha painter.setPen(countryNameColor); QString countryName = marker.getCountryName(); painter.drawText(hOffset, textY, countryName); hOffset += metrics.width(countryName); painter.setFont(userFont); //restore the normal font metrics = painter.fontMetrics(); // draw the player country flag const QImage &image = marker.getFlag(); qreal imageX = hOffset + TEXT_MARGIM; qreal imageY = rectPosition.y() - image.height()/2.0; painter.drawImage(QPointF(imageX, imageY), image); }
QPixmap ImageProcessor::drawPiece(int i, int j, const QPainterPath &shape, const Puzzle::Creation::Correction &corr) { QPainter p; QPixmap px(_p->descriptor.unitSize.width() + corr.widthCorrection + 1, _p->descriptor.unitSize.height() + corr.heightCorrection + 1); px.fill(Qt::transparent); p.begin(&px); p.setRenderHint(QPainter::SmoothPixmapTransform); p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::HighQualityAntialiasing); p.setClipping(true); p.setClipPath(shape); p.drawPixmap(_p->descriptor.tabFull + corr.xCorrection + corr.sxCorrection, _p->descriptor.tabFull + corr.yCorrection + corr.syCorrection, _p->pixmap, i * _p->descriptor.unitSize.width() + corr.sxCorrection, j * _p->descriptor.unitSize.height() + corr.syCorrection, _p->descriptor.unitSize.width() * 2, _p->descriptor.unitSize.height() * 2); p.end(); return px; }
void AFCWidget::drawAmplitude(QPainter & painter, QRectF rect) { if(m_dB_points.size()<2) return; painter.setClipping(true); painter.setClipRect(rect); painter.setRenderHint(QPainter::Antialiasing, true); //amplitude painter.setPen( QPen(QColor(0, 0, 0, 255)) ); float prev_x=m_dB_points.first().x(); float prev_y=m_dB_points.first().y(); float dB_range = m_dB2-m_dB1; foreach(QPointF p, m_dB_points){ // QPointF p1( rect.left()+log_coef*log10(prev_x-m_freq1)/freq_range*rect.width(), rect.bottom()-(prev_y-m_dB1)/dB_range*rect.height() ); // QPointF p2( rect.left()+log_coef*log10(p.rx()-m_freq1)/freq_range*rect.width(), rect.bottom()-(p.ry()-m_dB1)/dB_range*rect.height() ); //linear scale // QPointF p1( rect.left()+(prev_x-m_freq1)/(m_freq2-m_freq1)*rect.width(), rect.bottom()-(prev_y-m_dB1)/dB_range*rect.height() ); // QPointF p2( rect.left()+(p.rx()-m_freq1)/(m_freq2-m_freq1)*rect.width(), rect.bottom()-(p.ry()-m_dB1)/dB_range*rect.height() ); //log scale QPointF p1( rect.left()+logFreq(prev_x)*rect.width(), rect.bottom()-(prev_y-m_dB1)/dB_range*rect.height() ); QPointF p2( rect.left()+logFreq(p.rx())*rect.width(), rect.bottom()-(p.ry()-m_dB1)/dB_range*rect.height() ); if(p.x() <= m_freq2) painter.drawLine(p1, p2); prev_x = p.rx(); prev_y = p.ry(); }
void ImageBufferDataPrivateAccelerated::platformTransformColorSpace(const Vector<int>& lookUpTable) { QPainter* painter = paintDevice()->paintEngine()->painter(); QImage image = toQImage().convertToFormat(QImage::Format_ARGB32); ASSERT(!image.isNull()); uchar* bits = image.bits(); const int bytesPerLine = image.bytesPerLine(); for (int y = 0; y < image.height(); ++y) { quint32* scanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine); for (int x = 0; x < image.width(); ++x) { QRgb& pixel = scanLine[x]; pixel = qRgba(lookUpTable[qRed(pixel)], lookUpTable[qGreen(pixel)], lookUpTable[qBlue(pixel)], qAlpha(pixel)); } } painter->save(); painter->resetTransform(); painter->setOpacity(1.0); painter->setClipping(false); painter->setCompositionMode(QPainter::CompositionMode_Source); // Should coordinates be flipped? painter->drawImage(QPoint(0,0), image); painter->restore(); }
void UIPopupPane::paintFrame(QPainter &painter) { /* Paint frame: */ QColor currentColor(palette().color(QPalette::Window).darker(150)); QPainterPath path = painter.clipPath(); painter.setClipping(false); painter.strokePath(path, currentColor); }
void KoChild::setClipRegion( QPainter &painter, bool combine ) { painter.setClipping( true ); if ( combine && !painter.clipRegion().isEmpty() ) painter.setClipRegion( region( painter.worldMatrix() ).intersect( painter.clipRegion() ) ); else painter.setClipRegion( region( painter.worldMatrix() ) ); }
void PlayField::paintPainterClip(QPainter &paint, int x, int y, int w, int h) { QRect rect(x, y, w, h); paint.setClipRect(rect); paint.setClipping(true); paintPainter(paint, rect); }
void MusicShape::constPaint( QPainter& painter, const KoViewConverter& converter ) const { applyConversion( painter, converter ); painter.setClipping(true); painter.setClipRect(QRectF(0, 0, size().width(), size().height())); m_renderer->renderSheet( painter, m_sheet, m_firstSystem, m_lastSystem ); }
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) { Q_ASSERT(painter); SetClip(rc); DrawTextNoClip(rc, font_, ybase, s, len, fore, back); painter->setClipping(false); }
void ItemDocument::print() { static KPrinter *printer = new KPrinter; if (! printer->setup(KTechlab::self())) return; // setup the printer. with Qt, you always "print" to a // QPainter.. whether the output medium is a pixmap, a screen, // or paper QPainter p; p.begin(printer); // we let our view do the actual printing QPaintDeviceMetrics metrics(printer); // Round to 16 so that we cut in the middle of squares int w = metrics.width(); w = (w & 0xFFFFFFF0) + ((w << 1) & 0x10); int h = metrics.height(); h = (h & 0xFFFFFFF0) + ((h << 1) & 0x10); p.setClipping(true); p.setClipRect(0, 0, w, h, QPainter::CoordPainter); // Send off the painter for drawing m_canvas->setBackgroundPixmap(0); QRect bounding = canvasBoundingRect(); unsigned int rows = (unsigned) std::ceil(double(bounding.height()) / double(h)); unsigned int cols = (unsigned) std::ceil(double(bounding.width()) / double(w)); int offset_x = bounding.x(); int offset_y = bounding.y(); for (unsigned row = 0; row < rows; ++row) { for (unsigned col = 0; col < cols; ++col) { if (row != 0 || col != 0) printer->newPage(); QRect drawArea(offset_x + (col * w), offset_y + (row * h), w, h); m_canvas->drawArea(drawArea, & p); p.translate(-w, 0); } p.translate(w * cols, -h); } updateBackground(); // and send the result to the printer p.end(); }
void SeekGraph::paintEvent ( QPaintEvent* event ) { QFrame::paintEvent( event ); QPainter p; p.begin( this ); p.setRenderHint( QPainter::Antialiasing, antialiasing() ); p.fillRect( rect(), backgroundColor() ); p.translate( leftPadding() + 0.5, topPadding() + 0.5 ); p.setClipping( false ); drawAxes( &p ); setPixRect(); p.setClipRect( pixRect() ); p.setClipping( true ); resetPlotMask(); foreach( KPlotObject *po, plotObjects() ) { po->draw( &p, this ); }
void ossimGui::ImageScrollWidget::drawCursor(QPainter& painter) { if(!m_trackPoint.hasNans()) { ossimIpt roundedPoint(m_trackPoint); bool hasClipping = painter.hasClipping(); painter.setClipping(false); painter.setPen(QColor(255, 255, 255)); ossimIrect rect(0,0,size().width()-1, size().height()-1); // ossimIpt ul = rect.ul(); // ossimIpt lr = rect.lr(); int left = rect.ul().x; int right = rect.lr().x; int top = rect.ul().y; int bottom = rect.lr().y; if(rect.pointWithin(roundedPoint)) { // draw horizontal // int x1 = left; int x2 = right; int y1 = roundedPoint.y; int y2 = y1; painter.drawLine(x1, y1, x2, y2); // draw vertical x1 = roundedPoint.x; x2 = x1; y1 = top; y2 = bottom; painter.drawLine(x1, y1, x2, y2); } painter.setClipping(hasClipping); } m_oldTrackPoint = m_trackPoint; }
/*! draw an outline \warning Outlining functionality is obsolete: use QwtPlotPicker or QwtPlotZoomer. */ void QwtPlotCanvas::drawOutline(QPainter &p) { const QRect &r = contentsRect(); QColor bg = ((QwtPlot *)parent())->canvasBackground(); QPen pn = d_pen; pn.setColor(QColor(bg.rgb() ^ d_pen.color().rgb())); p.setPen(pn); p.setRasterOp(XorROP); p.setClipRect(r); p.setClipping(TRUE); switch(d_outline) { case Qwt::VLine: QwtPainter::drawLine(&p, d_lastPoint.x(), r.top(), d_lastPoint.x(), r.bottom()); break; case Qwt::HLine: QwtPainter::drawLine(&p, r.left(), d_lastPoint.y(), r.right(), d_lastPoint.y()); break; case Qwt::Cross: QwtPainter::drawLine(&p, r.left(), d_lastPoint.y(), r.right(), d_lastPoint.y()); QwtPainter::drawLine(&p, d_lastPoint.x(), r.top(), d_lastPoint.x(), r.bottom()); break; case Qwt::Rect: QwtPainter::drawRect(&p, d_entryPoint.x(), d_entryPoint.y(), d_lastPoint.x() - d_entryPoint.x() + 1, d_lastPoint.y() - d_entryPoint.y() + 1); break; case Qwt::Ellipse: p.drawEllipse(d_entryPoint.x(), d_entryPoint.y(), d_lastPoint.x() - d_entryPoint.x() + 1, d_lastPoint.y() - d_entryPoint.y() + 1); break; default: break; } }
/** * Makes the corners of the image rounded */ QImage polishImage(const QImage &img) { const int sz = 48 * 4; QImage roundedImage = QImage(QSize(sz, sz), QImage::Format_ARGB32_Premultiplied); roundedImage.fill(Qt::transparent); QPainter p; p.begin(&roundedImage); QPainterPath clippingPath; QRectF imgRect = QRectF(QPoint(0, 0), roundedImage.size()); clippingPath.addRoundedRect(imgRect, 24, 24); p.setClipPath(clippingPath); p.setClipping(true); p.drawImage(QRectF(QPointF(0, 0), roundedImage.size()), img); return roundedImage; }
void DAbstractSliderSpinBox::paint(QPainter& painter) { Q_D(DAbstractSliderSpinBox); // Create options to draw spin box parts QStyleOptionSpinBox spinOpts = spinBoxOptions(); spinOpts.rect.adjust(0, 2, 0, -2); // Draw "SpinBox".Clip off the area of the lineEdit to avoid double // borders being drawn painter.save(); painter.setClipping(true); QRect eraseRect(QPoint(rect().x(), rect().y()), QPoint(progressRect(spinOpts).right(), rect().bottom())); painter.setClipRegion(QRegion(rect()).subtracted(eraseRect)); style()->drawComplexControl(QStyle::CC_SpinBox, &spinOpts, &painter, d->dummySpinBox); painter.setClipping(false); painter.restore(); QStyleOptionProgressBar progressOpts = progressBarOptions(); progressOpts.rect.adjust(0, 2, 0, -2); style()->drawControl(QStyle::CE_ProgressBar, &progressOpts, &painter, nullptr); // Draw focus if necessary if (hasFocus() && d->edit->hasFocus()) { QStyleOptionFocusRect focusOpts; focusOpts.initFrom(this); focusOpts.rect = progressOpts.rect; focusOpts.backgroundColor = palette().color(QPalette::Window); style()->drawPrimitive(QStyle::PE_FrameFocusRect, &focusOpts, &painter, this); } }
void NativeRenderDialog::render(QPainter& P, QRect theR, RendererOptions opt) { P.setClipRect(theR); P.setClipping(true); P.setRenderHint(QPainter::Antialiasing); mapview->setGeometry(theR); mapview->setViewport(boundingBox(), theR); mapview->setRenderOptions(opt); mapview->invalidate(true, true, false); mapview->drawFeaturesSync(P); if (opt.options & RendererOptions::ScaleVisible) mapview->drawScale(P); if (opt.options & RendererOptions::LatLonGridVisible) mapview->drawLatLonGrid(P); }
void ClusterView::print(QPainter& printPainter,QPaintDeviceMetrics& metrics,bool whiteBackground){ //Draw the double buffer (pixmap) by copying it into the printer device throught the painter. QRect viewportOld = QRect(viewport.left(),viewport.top(),viewport.width(),viewport.height()); viewport = QRect(printPainter.viewport().left(),printPainter.viewport().top(),printPainter.viewport().width(),printPainter.viewport().height()); QRect r = ((QRect)window); //Set the window (part of the world I want to show) printPainter.setWindow(r.left(),r.top(),r.width()-1,r.height()-1);//hack because Qt QRect is used differently in this function //Fill the background with the background color QRect back = QRect(r.left(),r.top(),r.width(),r.height()); QColor colorLegendTmp = colorLegend; QColor background= backgroundColor(); if(whiteBackground){ colorLegend = black; setPaletteBackgroundColor(white); } printPainter.fillRect(back,backgroundColor()); printPainter.setClipRect(back,QPainter::CoordPainter); //Draw the axes drawAxes(printPainter); //Paint all the clusters in the shownClusters list (in the double buffer) drawClusters(printPainter,view.clusters(),true); //reset transformation due to setWindow and setViewport printPainter.resetXForm(); //Draw the time axis information if the time is displayed drawTimeInformation(printPainter); printPainter.setClipping(false); //Restore the colors. if(whiteBackground){ colorLegend = colorLegendTmp; setPaletteBackgroundColor(background); } //Restore the previous state viewport = QRect(viewportOld.left(),viewportOld.top(),viewportOld.width(),viewportOld.height()); }
void CanvasRenderer::paintCameraBorder(QPainter &painter) { for ( int i = 0; i < mObject->getLayerCount(); ++i ) { Layer* layer = mObject->getLayer( i ); if ( layer->type() == Layer::CAMERA && (i == mLayerIndex || mOptions.nShowAllLayers > 0) && layer->visible() ) { if ( i == mLayerIndex || mOptions.nShowAllLayers != 1 ) { painter.setOpacity( 1.0 ); } else { painter.setOpacity( 0.8 ); } QRectF viewRect = painter.viewport(); QRect boundingRect = mViewTransform.inverted().mapRect( viewRect ).toRect(); LayerCamera* cameraLayer = dynamic_cast< LayerCamera* >( layer ); QRect cameraRect = cameraLayer->getViewRect(); painter.setWorldMatrixEnabled( true ); painter.setPen( Qt::NoPen ); painter.setBrush( QColor( 0, 0, 0, 160 ) ); QRegion rg1(boundingRect); QRegion rg2(cameraRect); QRegion rg3=rg1.subtracted(rg2); painter.setClipRegion(rg3); painter.drawRect( boundingRect ); painter.setClipping(false); painter.setPen( Qt::black ); painter.setBrush( Qt::NoBrush ); painter.drawRect( cameraRect ); } } }
void QGraph::DrawGraph(QPainter &painter) { static QColor color; painter.save(); // Paint background // QBrush bg(m_BkColor); // painter.setBackground(bg); // Draw Border if(m_bBorder) color = m_BorderColor; else color = m_BkColor; QPen BorderPen(color); BorderPen.setStyle(GetStyle(m_BorderStyle)); BorderPen.setWidth(m_BorderWidth); painter.setPen(BorderPen); painter.fillRect(m_rCltRect, m_BkColor); painter.drawRect(m_rCltRect); Init(); painter.setClipRect(m_rCltRect); painter.setBackgroundMode(Qt::TransparentMode); if(m_bXMinGrid) DrawXMinGrid(painter); if(m_bYMinGrid) DrawYMinGrid(painter); if(m_bXMajGrid) DrawXMajGrid(painter); if(m_bYMajGrid) DrawYMajGrid(painter); DrawAxes(painter); DrawXTicks(painter); DrawYTicks(painter); for (int nc=0; nc < m_oaCurves.size(); nc++) DrawCurve(nc,painter); DrawTitles(painter); painter.setClipping(false); painter.restore(); }
QPainter *begin(QwtPlotCanvas *canvas) { _canvas = canvas; QMap<QwtPlotCanvas *, QPainter *>::iterator it = _map.find(_canvas); if ( it == _map.end() ) { QPainter *painter = new QPainter(_canvas); painter->setClipping(true); painter->setClipRect(_canvas->contentsRect()); it = _map.insert(_canvas, painter); _canvas->installEventFilter(this); } #if QT_VERSION < 0x040000 return it.data(); #else return it.value(); #endif }
void QvisColorGridWidget::paintEvent(QPaintEvent* e) { // If the pixmap has not been created, create it and draw into it. if (drawPixmap == 0) { drawPixmap = new QPixmap(width(), height()); drawColorArray(); } // Blit the pixmap onto the widget. QPainter paint; paint.begin(this); if (!e->region().isEmpty()) { paint.setClipRegion(e->region()); paint.setClipping(true); } paint.drawPixmap(0, 0, *drawPixmap); paint.end(); }
void GraphQtInteractiveRenderer::clipRegionAddRect(Rectangle *rect) { GraphQtRenderer *renderer = m_data->renderer; QRegion *clip = renderer->clipRegion(); QRect clipRect; clipRect.setX(rect->x()); clipRect.setY(rect->y()); clipRect.setWidth(rect->width()); clipRect.setHeight(rect->height()); *clip = clip->united(clipRect); QPainterPath path; path.addRegion(*clip); QPainter *painter = m_data->renderer->painter(); painter->setClipping(true); painter->setClipPath(path); }
void QUProfileController::drawPlot(QPainter & p) { p.save(); p.setOpacity( m_vars.transparency-> get()); p.setClipRect( m_x1, m_y1, m_x2 - m_x1, m_y2 - m_y1); p.setClipping(true); p.setPen( Qt::NoPen); QColor dotColor( 255, 0, 0); // if fixed colormap double x = 0.0, y = 0.0; // for( size_t i = 0 ; i < m_data.size() ; i ++ ) { auto av = avail(); for( auto i = 0u ; i < av ; i ++ ) { x = ttx1(m_dataQ[i]); y = tty1(m_dataU[i]); if( ! (std::isfinite(x) && std::isfinite(y))) { continue; } if( m_vars.showSunbow-> get() && m_total > 1) { dotColor = m_cmap-> qrgb( double(i) / (m_total - 1)); } p.setBrush( dotColor); p.drawEllipse( QPointF(x,y), m_vars.dotSize-> get(), m_vars.dotSize-> get()); } if( m_vars.showConnectingLines-> get()) { p.setOpacity(1.0); QPointF p1( 0, 0); bool validp1 = false; p.setPen( QPen( QColor(0,0,0), 0.25)); // p.setPen( QPen( QColor(0,0,0), 1)); for( auto i = 0u ; i < av ; i ++ ) { QPointF p2( ttx1(m_dataQ[i]), tty1(m_dataU[i])); bool validp2 = std::isfinite(p2.x()) && std::isfinite(p2.y()); if( validp2 && validp1) { p.drawLine( p1, p2); } p1 = p2; validp1 = validp2; } } p.restore(); }
//графика____________________________________________________________________ void RectWgt::draw() { pPix=new QPixmap(230,230); QPainter painter; painter.begin(pPix); painter.setRenderHint(QPainter::Antialiasing,true); painter.setPen(QPen(Qt::black,2,Qt::SolidLine)); double scale=(pHL->text().toDouble()>pWL->text().toDouble())?(200/pHL->text().toDouble()):200/pWL->text().toDouble(); painter.translate((115.0-scale*(pWL->text().toDouble()/2)),(115.0-scale*(pHL->text().toDouble()/2))); painter.setClipRect(0.0,((pHL->text().toDouble()-phL->text().toDouble())*scale), scale*pWL->text().toDouble(),phL->text().toDouble()*scale); painter.save(); painter.setPen(Qt::NoPen); QLinearGradient gradient(scale*pWL->text().toDouble()/2,((pHL->text().toDouble()-phL->text().toDouble())*scale), scale*pWL->text().toDouble()/2,scale*pHL->text().toDouble()); gradient.setColorAt(0,Qt::blue); gradient.setColorAt(1,Qt::darkBlue); painter.setBrush(gradient); painter.drawRect(0,0,scale*pWL->text().toDouble(),scale*pHL->text().toDouble()); painter.setClipping(false); painter.restore(); QPointF points[4]= { QPointF(0.0,0.0), QPointF(0.0,scale*pHL->text().toDouble()), QPointF(scale*pWL->text().toDouble(),scale*pHL->text().toDouble()), QPointF(scale*pWL->text().toDouble(),0.0) }; painter.drawPolyline(points,4); painter.drawLine(0.0,((pHL->text().toDouble()-phL->text().toDouble())*scale), (scale*pWL->text().toDouble()),((pHL->text().toDouble()-phL->text().toDouble())*scale)); painter.end(); pPixLbl->setPixmap(*pPix); }
void ContinuousPanel::paint(const QRect&, QPainter& painter) { qreal _offsetPanel = 0; qreal _y = 0; qreal _oldWidth = 0; // The last final panel width qreal _newWidth = 0; // New panel width qreal _height = 0; qreal _leftMarginTotal = 0; // Sum of all elments left margin qreal _panelRightPadding = 5; // Extra space for the panel after last element Measure* measure = _score->firstMeasure(); if (!_active || !measure) { _visible = false; return; } if (measure->mmRest()) { measure = measure->mmRest(); } System* system = measure->system(); if (system == 0) { _visible = false; return; } Segment* s = measure->first(); double _spatium = _score->spatium(); if (_width <= 0) _width = s->x(); // // Set panel height for whole system // _height = 6 * _spatium; _y = system->staffYpage(0) + system->page()->pos().y(); double y2 = 0.0; for (int i = 0; i < _score->nstaves(); ++i) { SysStaff* ss = system->staff(i); if (!ss->show() || !_score->staff(i)->show()) continue; y2 = ss->y() + ss->bbox().height(); } _height += y2 + 6*_spatium; _y -= 6 * _spatium; // // Check elements at current panel position // _offsetPanel = -(_sv->xoffset()) / _sv->mag(); _rect = QRect(_offsetPanel + _width, _y, 1, _height); Page* page = _score->pages().front(); QList<Element*> el = page->items(_rect); if (el.empty()) { _visible = false; return; } qStableSort(el.begin(), el.end(), elementLessThan); const Measure*_currentMeasure = 0; for (const Element* e : el) { e->itemDiscovered = 0; if (!e->visible() && !_score->showInvisible()) continue; if (e->isMeasure()) { _currentMeasure = toMeasure(e); break; } } if (!_currentMeasure) return; // Don't show panel if staff names are visible if (_currentMeasure == _score->firstMeasure() && _sv->toPhysical(_currentMeasure->canvasPos()).x() > 0) { _visible = false; return; } qreal _xPosMeasure = _currentMeasure->canvasX(); qreal _measureWidth = _currentMeasure->width(); int tick = _currentMeasure->tick(); Fraction _currentTimeSig = _currentMeasure->timesig(); //qDebug() << "_sv->xoffset()=" <<_sv->xoffset() << " _sv->mag()="<< _sv->mag() <<" s->x=" << s->x() << " width=" << _width << " currentMeasure=" << _currentMeasure->x() << " _xPosMeasure=" << _xPosMeasure; //--------------------------------------------------------- // findElementWidths // determines the max width for each element types //--------------------------------------------------------- // The first pass serves to get the maximum width for each elements qreal lineWidthName = 0; qreal _widthClef = 0; qreal _widthKeySig = 0; qreal _widthTimeSig = 0; qreal _xPosTimeSig = 0; for (const Element* e : el) { e->itemDiscovered = 0; if (!e->visible() && !_score->showInvisible()) continue; if (e->isRest() && toRest(e)->isGap()) continue; if (e->isStaffLines()) { Staff* currentStaff = _score->staff(e->staffIdx()); Segment* parent = _score->tick2segment(tick); // Find maximum width for the staff name QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames(); QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name(); if (staffName == "") { QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames(); staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name(); } Text* newName = new Text(_score); newName->setXmlText(staffName); newName->setParent(parent); newName->setTrack(e->track()); newName->textStyle().setFamily("FreeSans"); newName->textStyle().setSizeIsSpatiumDependent(true); newName->layout(); newName->setPlainText(newName->plainText()); newName->layout(); // Find maximum width for the current Clef Clef* newClef = new Clef(_score); ClefType currentClef = currentStaff->clef(tick); newClef->setClefType(currentClef); newClef->setParent(parent); newClef->setTrack(e->track()); newClef->layout(); if (newClef->width() > _widthClef) _widthClef = newClef->width(); // Find maximum width for the current KeySignature KeySig* newKs = new KeySig(_score); KeySigEvent currentKeySigEvent = currentStaff->keySigEvent(tick); newKs->setKeySigEvent(currentKeySigEvent); // The Parent and the Track must be set to have the key signature layout adjusted to different clefs // This also adds naturals to the key signature (if set in the score style) newKs->setParent(parent); newKs->setTrack(e->track()); newKs->setHideNaturals(true); newKs->layout(); if (newKs->width() > _widthKeySig) _widthKeySig = newKs->width(); // Find maximum width for the current TimeSignature TimeSig* newTs = new TimeSig(_score); // Try to get local time signature, if not, get the current measure one TimeSig* currentTimeSig = currentStaff->timeSig(tick); if (currentTimeSig) newTs->setFrom(currentTimeSig); else newTs->setSig(Fraction(_currentTimeSig.numerator(), _currentTimeSig.denominator()), TimeSigType::NORMAL); newTs->setParent(parent); newTs->setTrack(e->track()); newTs->layout(); if ((newName->width() > lineWidthName) && (newName->xmlText() != "")) lineWidthName = newName->width(); if (newTs->width() > _widthTimeSig) _widthTimeSig = newTs->width(); delete newClef; delete newName; delete newKs; delete newTs; } } _leftMarginTotal = _score->styleP(StyleIdx::clefLeftMargin); _leftMarginTotal += _score->styleP(StyleIdx::keysigLeftMargin); _leftMarginTotal += _score->styleP(StyleIdx::timesigLeftMargin); _newWidth = _widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding; _xPosMeasure -= _offsetPanel; lineWidthName += _score->spatium() + _score->styleP(StyleIdx::clefLeftMargin) + _widthClef; if (_newWidth < lineWidthName) { _newWidth = lineWidthName; _oldWidth = 0; } if (_oldWidth == 0) { _oldWidth = _newWidth; _width = _newWidth; } else if (_newWidth > 0) { if (_newWidth == _width) { _oldWidth = _width; _width = _newWidth; } else if (((_xPosMeasure <= _newWidth) && (_xPosMeasure >= _oldWidth)) || ((_xPosMeasure >= _newWidth) && (_xPosMeasure <= _oldWidth))) _width = _xPosMeasure; else if (((_xPosMeasure+_measureWidth <= _newWidth) && (_xPosMeasure+_measureWidth >= _oldWidth)) || ((_xPosMeasure+_measureWidth >= _newWidth) && (_xPosMeasure+_measureWidth <= _oldWidth))) _width = _xPosMeasure+_measureWidth; else { _oldWidth = _width; _width = _newWidth; } } _rect = QRect(0, _y, _width, _height); //==================== painter.save(); // Draw colored rectangle painter.setClipping(false); QPointF pos(_offsetPanel, 0); painter.translate(pos); QPen pen; pen.setWidthF(0.0); pen.setStyle(Qt::NoPen); painter.setPen(pen); painter.setBrush(preferences.fgColor); QRectF bg(_rect); bg.setWidth(_widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding); QPixmap* fgPixmap = _sv->fgPixmap(); if (fgPixmap == 0 || fgPixmap->isNull()) painter.fillRect(bg, preferences.fgColor); else { painter.setMatrixEnabled(false); painter.drawTiledPixmap(bg, *fgPixmap, bg.topLeft() - QPoint(lrint(_sv->matrix().dx()), lrint(_sv->matrix().dy()))); painter.setMatrixEnabled(true); } painter.setClipRect(_rect); painter.setClipping(true); QColor color(MScore::layoutBreakColor); // Draw measure text number QString text = QString("#%1").arg(_currentMeasure->no()+1); Text* newElement = new Text(_score); newElement->setTextStyleType(TextStyleType::DEFAULT); newElement->setFlag(ElementFlag::MOVABLE, false); newElement->setXmlText(text); newElement->textStyle().setFamily("FreeSans"); newElement->textStyle().setSizeIsSpatiumDependent(true); newElement->setColor(color); newElement->sameLayout(); pos = QPointF(_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, _y + newElement->height()); painter.translate(pos); newElement->draw(&painter); pos += QPointF(_offsetPanel, 0); painter.translate(-pos); delete newElement; // This second pass draws the elements spaced evently using the width of the largest element for (const Element* e : el) { if (!e->visible() && !_score->showInvisible()) continue; if (e->isRest() && toRest(e)->isGap()) continue; if (e->isStaffLines()) { painter.save(); Staff* currentStaff = _score->staff(e->staffIdx()); Segment* parent = _score->tick2segmentMM(tick); pos = QPointF (_offsetPanel, e->pagePos().y()); painter.translate(pos); // Draw staff lines StaffLines newStaffLines(*toStaffLines(e)); newStaffLines.setParent(parent); newStaffLines.setTrack(e->track()); newStaffLines.layout(); newStaffLines.setColor(color); newStaffLines.setWidth(bg.width()); newStaffLines.draw(&painter); // Draw barline BarLine barLine(_score); barLine.setBarLineType(BarLineType::NORMAL); barLine.setParent(parent); barLine.setTrack(e->track()); barLine.setSpan(currentStaff->barLineSpan()); barLine.setSpanFrom(currentStaff->barLineFrom()); barLine.setSpanTo(currentStaff->barLineTo()); barLine.layout(); barLine.setColor(color); barLine.draw(&painter); // Draw the current staff name QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames(); QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name(); if (staffName == "") { QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames(); staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name(); } Text* newName = new Text(_score); newName->setXmlText(staffName); newName->setParent(parent); newName->setTrack(e->track()); newName->setColor(color); newName->textStyle().setFamily("FreeSans"); newName->textStyle().setSizeIsSpatiumDependent(true); newName->layout(); newName->setPlainText(newName->plainText()); newName->layout(); if (currentStaff->part()->staff(0) == currentStaff) { double _spatium = _score->spatium(); pos = QPointF (_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, -_spatium * 2); painter.translate(pos); newName->draw(&painter); painter.translate(-pos); } delete newName; qreal posX = 0.0; // Draw the current Clef Clef clef(_score); clef.setClefType(currentStaff->clef(tick)); clef.setParent(parent); clef.setTrack(e->track()); clef.setColor(color); clef.layout(); posX += _score->styleP(StyleIdx::clefLeftMargin); clef.drawAt(&painter, QPointF(posX, clef.pos().y())); posX += _widthClef; // Draw the current KeySignature KeySig newKs(_score); newKs.setKeySigEvent(currentStaff->keySigEvent(tick)); // The Parent and the track must be set to have the key signature layout adjusted to different clefs // This also adds naturals to the key signature (if set in the score style) newKs.setParent(parent); newKs.setTrack(e->track()); newKs.setColor(color); newKs.setHideNaturals(true); newKs.layout(); posX += _score->styleP(StyleIdx::keysigLeftMargin); newKs.drawAt(&painter, QPointF(posX, 0.0)); posX += _widthKeySig + _xPosTimeSig; // Draw the current TimeSignature TimeSig newTs(_score); // Try to get local time signature, if not, get the current measure one TimeSig* currentTimeSig = currentStaff->timeSig(tick); if (currentTimeSig) { newTs.setFrom(currentTimeSig); newTs.setParent(parent); newTs.setTrack(e->track()); newTs.setColor(color); newTs.layout(); posX += _score->styleP(StyleIdx::timesigLeftMargin); newTs.drawAt(&painter, QPointF(posX, 0.0)); } painter.restore(); } } painter.restore(); _visible = true; }
void HeliCanvas::render(QPainter &p) { int fontHeight = p.fontMetrics().height(); int h = _size.height() - fontHeight*160/100; if ( _rows.empty() ) { p.fillRect(QRect(_labelMargin,0,_size.width()-_labelMargin,h), _palette.color(QPalette::Base)); return; } p.setClipRect(QRect(0,0,_size.width(),h)); int rowHeight = h / (_rows.size()+2); int rowPos = rowHeight; int recordWidth = _size.width(); Core::Time globalEnd = _records->empty()?Core::Time():_records->back()->endTime(); int yGap = h - rowHeight*(_rows.size()+2); int remainingGap = yGap; int heightOfs = yGap > 0?1:0; int skipTextLines = (fontHeight*3/2) / rowHeight; int currentTextLine = skipTextLines; p.setPen(_palette.color(QPalette::Text)); for ( int i = 0; i < _rows.size(); ++i, rowPos += rowHeight + heightOfs ) { if ( currentTextLine == 0 ) { p.drawText(QRect(0, rowPos-fontHeight, _labelMargin, rowHeight+2*fontHeight + heightOfs), Qt::AlignLeft | Qt::AlignVCenter, Gui::timeToString(_rows[i].time, "%H:%M")); currentTextLine = skipTextLines; } else --currentTextLine; --remainingGap; if ( remainingGap <= 0 ) heightOfs = 0; } recordWidth -= _labelMargin; p.fillRect(QRect(_labelMargin, 0, recordWidth, h), _palette.color(QPalette::Base)); heightOfs = yGap > 0?1:0; remainingGap = yGap; rowPos = rowHeight; for ( int i = 0; i < _rows.size(); ++i, rowPos += rowHeight + heightOfs ) { QColor gapColor = _gaps[i % 2]; // Create new sequence if ( _rows[i].dirty ) { if ( !_rows[i].polyline ) _rows[i].polyline = RecordPolylinePtr(new Gui::RecordPolyline); float ofs, min, max; Core::TimeWindow tw(_rows[i].time, _rows[i].time + Core::TimeSpan(_rowTimeSpan)); minmax(_filteredRecords, tw, ofs, min, max); _rows[i].polyline->create(_filteredRecords, tw.startTime(), tw.endTime(), (double)recordWidth / (double)_rowTimeSpan, _amplitudeRange[0], _amplitudeRange[1], ofs, rowHeight); _rows[i].polyline->translate(_labelMargin, 0); _rows[i].dirty = false; } if ( _rows[i].polyline ) { if ( !_rows[i].polyline->empty() ) { // Draw front and back gaps if ( _rows[i].polyline->front().first().x() > _labelMargin ) p.fillRect(_labelMargin, rowPos, _rows[i].polyline->front().first().x() - _labelMargin, rowHeight, gapColor); if ( (globalEnd - _rows[i].time) >= Core::TimeSpan(_rowTimeSpan) ) { if ( _rows[i].polyline->back().last().x() < _size.width()-2 ) p.fillRect(_rows[i].polyline->back().last().x(), rowPos, _size.width()-1 - _rows[i].polyline->back().last().x(), rowHeight, gapColor); } } else if ( (globalEnd - _rows[i].time) >= Core::TimeSpan(_rowTimeSpan) ) p.fillRect(QRect(_labelMargin, rowPos, recordWidth, rowHeight), gapColor); } --remainingGap; if ( remainingGap <= 0 ) heightOfs = 0; } heightOfs = yGap > 0?1:0; remainingGap = yGap; rowPos = rowHeight; int rowColorIndex = 0; bool hadAntialiasing = (p.renderHints() & QPainter::Antialiasing) != 0; p.setRenderHint(QPainter::Antialiasing, _antialiasing); for ( int i = 0; i < _rows.size(); ++i, rowPos += rowHeight + heightOfs ) { QColor gapColor = _gaps[i & 1]; QColor overlapColor = _gaps[i & 1]; p.setPen(QPen(_rowColors[rowColorIndex], _lineWidth)); ++rowColorIndex; if ( rowColorIndex >= _rowColors.size() ) rowColorIndex = 0; if ( !_rows[i].polyline ) continue; p.translate(0, rowPos); _rows[i].polyline->draw(p, 0, rowHeight, gapColor, overlapColor); p.translate(0, -rowPos); --remainingGap; if ( remainingGap <= 0 ) heightOfs = 0; } p.setRenderHint(QPainter::Antialiasing, hadAntialiasing); p.setClipping(false); p.setPen(_palette.color(QPalette::Text)); // Render timescale double pos = 0; double scale = (double)recordWidth / (double)_rowTimeSpan; double dx[2] = {_drx[0], _drx[1]}; // Adapted from gui/libs/ruler int tickLong = fontHeight/2; int tickShort = tickLong/2; int startY = h; h = _size.height()-startY; //p.setPen(p.palette().color(QPalette::WindowText)); p.drawLine(_labelMargin, startY, _size.width(), startY); for ( int k = 0; k < 2; ++k ) { double cpos = pos - fmod(pos, (double)dx[k]); int tick = k==0 ? tickLong : tickShort; int x = (int)((cpos-pos)*scale); while ( x < recordWidth ) { p.drawLine(_labelMargin+x, startY, _labelMargin+x, startY+tick); if ( k == 0 ) { QString str = formatAnnotation(cpos); int tw = p.fontMetrics().width(str); p.drawText(_labelMargin + x-tw/2, startY, tw, h, Qt::AlignHCenter | Qt::AlignBottom, str); } cpos += dx[k]; x = (int)((cpos-pos)*scale); } } }
void QDial::repaintScreen( const QRect *cr ) { QPainter p; p.begin( this ); bool resetClipping = FALSE; // calculate clip-region for erasing background if ( cr ) { p.setClipRect( *cr ); } else if ( !d->onlyOutside && d->eraseAreaValid ) { QRegion reg = d->eraseArea; double a; reg = reg.subtract( calcArrow( a ) ); p.setClipRegion( reg ); resetClipping = TRUE; } QRect br( calcDial() ); p.setPen( NoPen ); // if ( style() == MotifStyle ) // p.setBrush( colorGroup().brush( QColorGroup::Mid ) ); // else { QBrush b; if ( colorGroup().brush( QColorGroup::Light ).pixmap() ) b = QBrush( colorGroup().brush( QColorGroup::Light ) ); else b = QBrush( colorGroup().light(), Dense4Pattern ); p.setBrush( b ); p.setBackgroundMode( OpaqueMode ); // } QRect te = br; te.setWidth(te.width()+2); te.setHeight(te.height()+2); // erase background of dial if ( !d->onlyOutside ) { p.drawEllipse( te ); } // erase remaining space around the dial QRegion remaining( 0, 0, width(), height() ); remaining = remaining.subtract( QRegion( te, QRegion::Ellipse ) ); if ( p.hasClipping() ) remaining = remaining.intersect( p.clipRegion() ); erase(remaining); if ( resetClipping ) { if ( cr ) p.setClipRect( *cr ); else p.setClipRect( QRect( 0, 0, width(), height() ) ); } // draw notches if ( d->showNotches ) { calcLines(); p.setPen( colorGroup().foreground() ); p.drawLineSegments( d->lines ); } // calculate and paint arrow p.setPen( QPen( colorGroup().dark() ) ); p.drawArc( te, 60 * 16, 180 * 16 ); p.setPen( QPen( colorGroup().light() ) ); p.drawArc( te, 240 * 16, 180 * 16 ); double a; QPointArray arrow( calcArrow( a ) ); QRect ea( arrow.boundingRect() ); d->eraseArea = ea; d->eraseAreaValid = TRUE; p.setPen( NoPen ); p.setBrush( colorGroup().brush( QColorGroup::Button ) ); if ( !d->onlyOutside ) p.drawPolygon( arrow ); a = angle( QPoint( width() / 2, height() / 2 ), arrow[ 0 ] ); p.setBrush( Qt::NoBrush ); // that's still a hack... if ( a <= 0 || a > 200 ) { p.setPen( colorGroup().light() ); p.drawLine( arrow[ 2 ], arrow[ 0 ] ); p.drawLine( arrow[ 1 ], arrow[ 2 ] ); p.setPen( colorGroup().dark() ); p.drawLine( arrow[ 0 ], arrow[ 1 ] ); } else if ( a > 0 && a < 45 ) { p.setPen( colorGroup().light() ); p.drawLine( arrow[ 2 ], arrow[ 0 ] ); p.setPen( colorGroup().dark() ); p.drawLine( arrow[ 1 ], arrow[ 2 ] ); p.drawLine( arrow[ 0 ], arrow[ 1 ] ); } else if ( a >= 45 && a < 135 ) { p.setPen( colorGroup().dark() ); p.drawLine( arrow[ 2 ], arrow[ 0 ] ); p.drawLine( arrow[ 1 ], arrow[ 2 ] ); p.setPen( colorGroup().light() ); p.drawLine( arrow[ 0 ], arrow[ 1 ] ); } else if ( a >= 135 && a < 200 ) { p.setPen( colorGroup().dark() ); p.drawLine( arrow[ 2 ], arrow[ 0 ] ); p.setPen( colorGroup().light() ); p.drawLine( arrow[ 0 ], arrow[ 1 ] ); p.drawLine( arrow[ 1 ], arrow[ 2 ] ); } // draw focus rect around the dial if ( hasFocus() ) { p.setClipping( FALSE ); br.setWidth( br.width() + 2 ); br.setHeight( br.height() + 2 ); if ( d->showNotches ) { int r = QMIN( width(), height() ) / 2; br.moveBy( -r / 6, - r / 6 ); br.setWidth( br.width() + r / 3 ); br.setHeight( br.height() + r / 3 ); } // strange, but else we get redraw errors on Windows p.end(); p.begin( this ); p.save(); p.setPen( QPen( colorGroup().background() ) ); p.setBrush( NoBrush ); p.drawRect( br ); p.restore(); style().drawPrimitive( QStyle::PE_FocusRect, &p, br, colorGroup()); } p.end(); }
void LightMaps::paintEvent(QPaintEvent *event) { QPainter p; p.begin(this); m_normalMap->render(&p, event->rect()); p.setPen(Qt::black); p.drawText(rect(), Qt::AlignBottom | Qt::TextWordWrap, "Map data CCBYSA 2009 OpenStreetMap.org contributors"); p.end(); if (zoomed) { int dim = qMin(width(), height()); int magnifierSize = qMin(MAX_MAGNIFIER, dim * 2 / 3); int radius = magnifierSize / 2; int ring = radius - 15; QSize box = QSize(magnifierSize, magnifierSize); // reupdate our mask if (maskPixmap.size() != box) { maskPixmap = QPixmap(box); maskPixmap.fill(Qt::transparent); QRadialGradient g; g.setCenter(radius, radius); g.setFocalPoint(radius, radius); g.setRadius(radius); g.setColorAt(1.0, QColor(255, 255, 255, 0)); g.setColorAt(0.5, QColor(128, 128, 128, 255)); QPainter mask(&maskPixmap); mask.setRenderHint(QPainter::Antialiasing); mask.setCompositionMode(QPainter::CompositionMode_Source); mask.setBrush(g); mask.setPen(Qt::NoPen); mask.drawRect(maskPixmap.rect()); mask.setBrush(QColor(Qt::transparent)); mask.drawEllipse(g.center(), ring, ring); mask.end(); } QPoint center = dragPos - QPoint(0, radius); center = center + QPoint(0, radius / 2); QPoint corner = center - QPoint(radius, radius); QPoint xy = center * 2 - QPoint(radius, radius); // only set the dimension to the magnified portion if (zoomPixmap.size() != box) { zoomPixmap = QPixmap(box); zoomPixmap.fill(Qt::lightGray); } if (true) { QPainter p(&zoomPixmap); p.translate(-xy); m_largeMap->render(&p, QRect(xy, box)); p.end(); } QPainterPath clipPath; clipPath.addEllipse(center, ring, ring); QPainter p(this); p.setRenderHint(QPainter::Antialiasing); p.setClipPath(clipPath); p.drawPixmap(corner, zoomPixmap); p.setClipping(false); p.drawPixmap(corner, maskPixmap); p.setPen(Qt::gray); p.drawPath(clipPath); } if (invert) { QPainter p(this); p.setCompositionMode(QPainter::CompositionMode_Difference); p.fillRect(event->rect(), Qt::white); p.end(); } }
void QUProfileController::drawGrid(QPainter & p) { if( ! m_vars.showGrid-> get()) return; p.save(); // text is outside of the plot area, so disable clipping p.setClipping(false); int labelFontHeight = m_labelFontMetrics-> height(); // int captionFontHeight = m_captionFontMetrics-> height(); QColor captionColor( 0, 0, 128); // y axis labels int textGap = 2; p.setFont ( m_labelFont); p.setPen( QColor(100,100,100)); for( auto label : m_vertLabels) { double yy = m_y2 - label.centerPix; p.drawText( QRectF( m_x2 + textGap, yy, 1, 1), Qt::AlignVCenter | Qt::TextDontClip | Qt::AlignLeft, label.txt1 ); } // x axis labels for( Plot2dLabelers::LabelEntry & label : m_horizLabels) { double xx = m_x1 + label.centerPix; p.drawText( QRectF( xx, m_y2 + labelFontHeight / 2.0, 1, 1), Qt::AlignCenter | Qt::TextDontClip, label.txt1 ); } // draw the grid lines // =================== p.setRenderHint( p.Antialiasing, false); // p.setClipping( false); p.setClipRect( m_x1, m_y1, m_x2 - m_x1, m_y2 - m_y1); p.setClipping(true); p.setPen( QPen(QColor(255,0,0,20), 1.0)); // draw horizontal lines for( auto label : m_vertLabels) { double yy = m_y2 - label.centerPix; p.drawLine( QPointF(m_x1, yy), QPointF(m_x2, yy)); } // draw vertical lines for( auto label : m_horizLabels) { double xx = m_x1 + label.centerPix; p.drawLine( QPointF(xx, m_y1), QPointF(xx, m_y2)); } // highlight 0 axes p.setPen( QPen(QColor(255,0,0, 128), 1.0)); double x0 = ttx1( 0); double y0 = tty1( 0); p.drawLine( QPointF( x0, m_y1), QPointF( x0, m_y2)); p.drawLine( QPointF( m_x1, y0), QPointF( m_x2, y0)); // draw the surrounding rectangle p.setClipping( false); p.setPen( QPen( QColor( 255,70,70,128), 2, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin)); p.drawRect( m_x1, m_y1, m_x2-m_x1, m_y2-m_y1); // put the painter in the original state p.restore(); }