19 #include <QDesktopWidget>
30 mContext.
setScaleFactor( QgsApplication::desktop()->logicalDpiX() / 25.4 );
44 p.setRenderHint( QPainter::Antialiasing );
61 QRectF textRect = rect();
62 textRect.setLeft( xtrans );
63 textRect.setWidth( textRect.width() - xtrans );
64 textRect.setTop( ytrans );
65 if ( textRect.height() > 300 )
66 textRect.setHeight( 300 );
67 if ( textRect.width() > 2000 )
68 textRect.setWidth( 2000 );
81 void QgsTextPreview::updateContext()
Perform transforms between map coordinates and device coordinates.
static QgsMapToPixel fromScale(double scale, QgsUnitTypes::DistanceUnit mapUnits, double dpi=96)
Returns a new QgsMapToPixel created using a specified scale and distance unit.
void setParameters(double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation)
Set parameters for use in transforming coordinates.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void setIsGuiPreview(bool preview)
Sets GUI preview mode.
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
@ Antialiasing
Use antialiasing while drawing.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
QSizeF size() const
Returns the size of the background shape.
bool enabled() const
Returns whether the background is enabled.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
double size() const
Returns the size of the buffer.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
bool enabled() const
Returns whether the buffer is enabled.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
Container for all settings relating to text rendering.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
void setScale(double scale)
Sets the scale to use for previewing format sizes in map units.
void paintEvent(QPaintEvent *e) override
QgsTextPreview(QWidget *parent=nullptr)
Constructor for QgsTextPreview.
void setFormat(const QgsTextFormat &format)
Sets the text format for previewing in the widget.
void setMapUnits(QgsUnitTypes::DistanceUnit unit)
Sets the map unit type for previewing format sizes in map units.
static void drawText(const QRectF &rect, double rotation, HAlignment alignment, const QStringList &textLines, QgsRenderContext &context, const QgsTextFormat &format, bool drawAsOutlines=true, VAlignment vAlignment=AlignTop)
Draws text within a rectangle using the specified settings.
DistanceUnit
Units of distance.