void QgsAnnotationItem::drawMarkerSymbol( QPainter* p ) { if ( !p ) { return; } QgsRenderContext renderContext; if ( !setRenderContextVariables( p, renderContext ) ) { return; } if ( mMarkerSymbol ) { mMarkerSymbol->startRender( renderContext ); mMarkerSymbol->renderPoint( QPointF( 0, 0 ), nullptr, renderContext ); mMarkerSymbol->stopRender( renderContext ); } }
void QgsGCPCanvasItem::paint( QPainter* p ) { QgsRenderContext context; if ( !setRenderContextVariables( p, context ) ) { return; } p->setRenderHint( QPainter::Antialiasing ); bool enabled = true; QgsPoint worldCoords; int id = -1; if ( mDataPoint ) { enabled = mDataPoint->isEnabled(); worldCoords = mDataPoint->mapCoords(); id = mDataPoint->id(); } p->setOpacity( enabled ? 1.0 : 0.3 ); // draw the point p->setPen( Qt::black ); p->setBrush( mPointBrush ); p->drawEllipse( -2, -2, 5, 5 ); QSettings s; bool showIDs = s.value( "/Plugin-GeoReferencer/Config/ShowId" ).toBool(); bool showCoords = s.value( "/Plugin-GeoReferencer/Config/ShowCoords" ).toBool(); QString msg; if ( showIDs && showCoords ) { msg = QString( "%1\nX %2\nY %3" ).arg( QString::number( id ) ).arg( QString::number( worldCoords.x(), 'f' ) ).arg( QString::number( worldCoords.y(), 'f' ) ); } else if ( showIDs ) { msg = msg = QString::number( id ); } else if ( showCoords ) { msg = QString( "X %1\nY %2" ).arg( QString::number( worldCoords.x(), 'f' ) ).arg( QString::number( worldCoords.y(), 'f' ) ); } if ( !msg.isEmpty() ) { p->setBrush( mLabelBrush ); QFont textFont( "helvetica" ); textFont.setPixelSize( fontSizePainterUnits( 12, context ) ); p->setFont( textFont ); QRectF textBounds = p->boundingRect( 3 * context.scaleFactor(), 3 * context.scaleFactor(), 5 * context.scaleFactor(), 5 * context.scaleFactor(), Qt::AlignLeft, msg ); mTextBoxRect = QRectF( textBounds.x() - context.scaleFactor() * 1, textBounds.y() - context.scaleFactor() * 1, \ textBounds.width() + 2 * context.scaleFactor(), textBounds.height() + 2 * context.scaleFactor() ); p->drawRect( mTextBoxRect ); p->drawText( textBounds, Qt::AlignLeft, msg ); } if ( data( 0 ) != "composer" ) //draw residuals only on screen { drawResidualArrow( p, context ); } }