Skip to content

RGraphicsViewImage

Class in GUI Module
Header: #include <src/gui/RGraphicsViewImage.h>
Inherits: QObject, RGraphicsView

QImage based 2d graphics view.

This graphics view renders a rectangular area of a RGraphicsSceneQt into a QImage.

Scriptable: This class is available in script environments.

RGraphicsViewImage(QObject *parent=NULL)
virtual ~RGraphicsViewImage()
void addToBackground(const RGraphicsSceneDrawable &drawable)
void addToOverlay(int overlayId, RObject::Id objectId, const RGraphicsSceneDrawable &drawable)
void clear()
void clearBackground()
void clearOverlay(int overlayId)
void clearOverlay(int overlayId, RObject::Id objectId)
virtual void emitUpdateSnapInfo(RSnap *snap, RSnapRestriction *restriction)
virtual void emitUpdateTextLabel(const RTextLabel &textLabel)
virtual QImage getBuffer() const
getBuffer
bool getColorCorrectionOverride() const
virtual QCursor getCursor()
virtual double getDevicePixelRatio() const
double getDrawingScale() const
QImage getGraphicsBufferWithPreview() const
virtual int getHeight() const
RVector getLastKnownScreenPosition() const
double getMaximumLineweight() const
double getMinimumLineweight() const
int getNumThreads() const
RVector getPaintOffset() const
bool getPanOptimization()
QTransform getTransform() const
virtual int getWidth() const
virtual void giveFocus()
virtual bool hasFocus()
bool isAlphaEnabled() const
virtual bool isShared() const
Reimplementations may return true to prevent this view from being deleted.
virtual double mapDistanceFromView(double d) const
Maps the given view distance in pixels to a model distance.
virtual double mapDistanceToView(double d) const
Maps the given model distance to a screen distance in pixels.
virtual RVector mapFromView(const RVector &v, double z=0.0) const
Maps the given view coordinate in pixels to a model coordinate.
virtual RVector mapToView(const RVector &v) const
Maps the given model coordinate to a view coordinate in pixels.
virtual void paintCursorLine(const RLine &ucsPosition)
virtual void paintDrawableThread(RGraphicsViewWorker *worker, RGraphicsSceneDrawable &drawable, const RBox &clipRectangle, bool preview=false)
virtual void paintEntities(QPainter *painter, const RBox &queryBox)
void paintEntitiesMulti(const RBox &queryBox)
virtual void paintEntityThread(RGraphicsViewWorker *worker, RObject::Id id, bool preview=false)
Looks up entity drawable and paints it using the given worker.
virtual void paintGridLine(const RLine &ucsPosition)
virtual void paintGridPoint(const RVector &ucsPosition)
virtual void paintImage(RGraphicsViewWorker *worker, const RImageData &image, bool workingSet=true)
virtual void paintOverlay()
virtual void paintText(RGraphicsViewWorker *worker, const RTextBasedData &text, bool workingSet=true)
virtual void regenerate(bool force=false)
Regenerates the view from the underlying scene.
virtual bool registerForFocus() const
Reimplementations may return true to register this view and allow it to be returned by RDocumentInterface::getLastKnownViewWithFocus.
virtual void removeFocus()
virtual void repaintView()
Triggers a paintEvent based on a buffered offscreen bitmap (very fast).
virtual void resizeImage(int w, int h)
void restoreViewport()
void saveViewport()
void setAlphaEnabled(bool on)
virtual void setBackgroundColor(const QColor &col)
void setBackgroundTransform(double bgFactor, const RVector &bgOffset)
void setColorCorrectionOverride(bool on)
virtual void setCursor(const QCursor &cursor)
virtual void setCursor(Qt::CursorShape cursorShape)
void setDrawingScale(double s)
void setLastKnownModelPosition(const RVector &p)
void setLastKnownScreenPosition(const RVector &p)
void setMaximumLineweight(double lw)
void setMinimumLineweight(double lw)
void setNumThreads(int n)
void setPaintOffset(const RVector &offset)
void setPaintOrigin(bool val)
void setPanOptimization(bool on)
virtual void setScene(RGraphicsSceneQt *scene, bool regen=true)
virtual void simulateMouseMoveEvent()
virtual void updateImage()
Repaints the view.
virtual void viewportChangeEvent()
void applyColorCorrection(QBrush &brush)
void applyColorCorrection(QPen &pen)
void applyColorMode(QBrush &brush)
void applyColorMode(QPen &pen)
void applyMinimumLineweight(QPen &pen)
void applyPrintingPenWorkaround(RGraphicsViewWorker *worker, QPen &pen)
Works around the way Qt’s PDF paint engine (PDF export, printing on Linux) strokes pens which it cannot write natively: pens with a transparent color (or any pen while the painter opacity is not 1.0).
virtual void drawCircle(RGraphicsViewWorker *worker, QPointF pt, double pSize)
virtual void drawDot(RGraphicsViewWorker *worker, QPointF pt)
virtual void drawEx(RGraphicsViewWorker *worker, QPointF pt, double pSize)
virtual void drawPlus(RGraphicsViewWorker *worker, QPointF pt, double pSize)
virtual void drawSquare(RGraphicsViewWorker *worker, QPointF pt, double pSize)
virtual void drawVBar(RGraphicsViewWorker *worker, QPointF pt, double pSize)
QColor getCorrectedColor(const QColor &col)
double getPointSize(double pSize)
QList< RPainterPath > getTextLayoutsPainterPaths(const RTextBasedData &text, const QList< RTextLayout > &textLayouts)
virtual RGraphicsViewWorker * initWorker(int threadId)
virtual void initWorkers()
Updates the graphics buffer from scratch.
void invalidate(bool force=false)
virtual void paintBackground(RGraphicsViewWorker *worker, const QRect &rect=QRect())
virtual void paintCursor(RGraphicsViewWorker *worker)
virtual void paintDocument(const QRect &rect=QRect())
virtual void paintErase(RGraphicsViewWorker *worker, const QRect &rect=QRect())
virtual void paintGrid(RGraphicsViewWorker *worker, const QRect &rect=QRect())
virtual void paintMetaGrid(RGraphicsViewWorker *worker, const QRect &rect=QRect())
virtual void paintOrigin(RGraphicsViewWorker *worker)
Paints the absolute zero point (origin).
virtual void paintReferencePoint(RGraphicsViewWorker *worker, const RRefPoint &pos, bool highlight)
virtual void paintRelativeZero(RGraphicsViewWorker *worker)
void updateTransformation() const
bool alphaEnabled
QList< RGraphicsSceneDrawable > backgroundDecoration
double backgroundFactor
RVector backgroundOffset
int bgColorLightness
RBox clipBox
bool colorCorrection
bool colorCorrectionDisableForPrinting
int colorCorrectionOverride
int colorThreshold
double currentScale
RGraphicsViewWorker * decorationWorker
bool doPaintOrigin
double drawingScale
bool editingWorkingSet
cached per update: constant while one update is rendered
QImage graphicsBuffer
bool graphicsBufferNeedsUpdate
QImage graphicsBufferWithPreview
bool isSelected
double lastFactor
RVector lastOffset
QString lastScaleString
QSize lastSize
double maximumLineweight
double minimumLineweight
QMutex mutexSi
int numThreads
QList< RObject::Id > orderedIds
cached list of visible entities in draw order and what it is valid for
RBox orderedIdsBox
bool orderedIdsValid
int orderedIdsVersion
QMap< int, QMap< RObject::Id, QList< RGraphicsSceneDrawable > > > overlayDrawables
RVector paintOffset
bool panOptimization
QTransform previousView
RGraphicsSceneQt * sceneQt
QSet< RObject::Id > selectedIds
bool showOnlyPlottable
QTransform transform
QList< RGraphicsViewWorker * > workers
void updateSnapInfo(RGraphicsViewWorker *worker, RSnap *snap, RSnapRestriction *restriction)
void updateTextLabel(RGraphicsViewWorker *worker, const RTextLabel &textLabel)
void viewportChanged()

RGraphicsViewImage::RGraphicsViewImage(QObject *parent=NULL)

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

virtual RGraphicsViewImage::~RGraphicsViewImage()

virtual

void RGraphicsViewImage::addToBackground(const RGraphicsSceneDrawable &drawable)

void RGraphicsViewImage::addToOverlay(int overlayId, RObject::Id objectId, const RGraphicsSceneDrawable &drawable)

void RGraphicsViewImage::clear()

void RGraphicsViewImage::clearBackground()

void RGraphicsViewImage::clearOverlay(int overlayId)

void RGraphicsViewImage::clearOverlay(int overlayId, RObject::Id objectId)

virtual void RGraphicsViewImage::emitUpdateSnapInfo(RSnap *snap, RSnapRestriction *restriction)

virtual

virtual void RGraphicsViewImage::emitUpdateTextLabel(const RTextLabel &textLabel)

virtual

virtual QImage RGraphicsViewImage::getBuffer() const

virtual const

getBuffer

Returns: Buffer to rendered graphics view, if supported by the implementation.

Reimplemented from getBuffer.

bool RGraphicsViewImage::getColorCorrectionOverride() const

inline const

virtual QCursor RGraphicsViewImage::getCursor()

virtual

Reimplemented from getCursor.

virtual double RGraphicsViewImage::getDevicePixelRatio() const

virtual const

Reimplemented from getDevicePixelRatio.

double RGraphicsViewImage::getDrawingScale() const

inline const

QImage RGraphicsViewImage::getGraphicsBufferWithPreview() const

inline const

virtual int RGraphicsViewImage::getHeight() const

virtual const

Returns: Height of the view in pixels.

Reimplemented from getHeight.

RVector RGraphicsViewImage::getLastKnownScreenPosition() const

inline const

double RGraphicsViewImage::getMaximumLineweight() const

inline const

double RGraphicsViewImage::getMinimumLineweight() const

inline const

int RGraphicsViewImage::getNumThreads() const

inline const

RVector RGraphicsViewImage::getPaintOffset() const

inline const

bool RGraphicsViewImage::getPanOptimization()

QTransform RGraphicsViewImage::getTransform() const

const

virtual int RGraphicsViewImage::getWidth() const

virtual const

Returns: Width of the view in pixels.

Reimplemented from getWidth.

virtual void RGraphicsViewImage::giveFocus()

virtual

Reimplemented from giveFocus.

virtual bool RGraphicsViewImage::hasFocus()

virtual

Returns: True if this view currently has the focus.

Reimplemented from hasFocus.

bool RGraphicsViewImage::isAlphaEnabled() const

inline const

virtual bool RGraphicsViewImage::isShared() const

virtual inline const

Reimplementations may return true to prevent this view from being deleted.

Reimplemented from isShared.

virtual double RGraphicsViewImage::mapDistanceFromView(double d) const

virtual const

Maps the given view distance in pixels to a model distance.

If the view projection is not orthogonal the result is undefined.

Reimplemented from mapDistanceFromView.

virtual double RGraphicsViewImage::mapDistanceToView(double d) const

virtual const

Maps the given model distance to a screen distance in pixels.

If the view projection is not orthogonal the result is undefined.

Reimplemented from mapDistanceToView.

virtual RVector RGraphicsViewImage::mapFromView(const RVector &v, double z=0.0) const

virtual const

Maps the given view coordinate in pixels to a model coordinate.

Parameters:

  • v: view coordinate in pixels, v.z is always 0
  • z: known z coordinate in model units

Reimplemented from mapFromView.

virtual RVector RGraphicsViewImage::mapToView(const RVector &v) const

virtual const

Maps the given model coordinate to a view coordinate in pixels.

Reimplemented from mapToView.

virtual void RGraphicsViewImage::paintCursorLine(const RLine &ucsPosition)

virtual

Reimplemented from paintCursorLine.

virtual void RGraphicsViewImage::paintDrawableThread(RGraphicsViewWorker *worker, RGraphicsSceneDrawable &drawable, const RBox &clipRectangle, bool preview=false)

virtual

virtual void RGraphicsViewImage::paintEntities(QPainter *painter, const RBox &queryBox)

virtual

void RGraphicsViewImage::paintEntitiesMulti(const RBox &queryBox)

virtual void RGraphicsViewImage::paintEntityThread(RGraphicsViewWorker *worker, RObject::Id id, bool preview=false)

virtual

Looks up entity drawable and paints it using the given worker.

virtual void RGraphicsViewImage::paintGridLine(const RLine &ucsPosition)

virtual

Reimplemented from paintGridLine.

virtual void RGraphicsViewImage::paintGridPoint(const RVector &ucsPosition)

virtual

Reimplemented from paintGridPoint.

virtual void RGraphicsViewImage::paintImage(RGraphicsViewWorker *worker, const RImageData &image, bool workingSet=true)

virtual

virtual void RGraphicsViewImage::paintOverlay()

virtual

virtual void RGraphicsViewImage::paintText(RGraphicsViewWorker *worker, const RTextBasedData &text, bool workingSet=true)

virtual

virtual void RGraphicsViewImage::regenerate(bool force=false)

virtual

Regenerates the view from the underlying scene.

Reimplemented from regenerate.

virtual bool RGraphicsViewImage::registerForFocus() const

virtual inline const

Reimplementations may return true to register this view and allow it to be returned by RDocumentInterface::getLastKnownViewWithFocus.

Reimplemented from registerForFocus.

virtual void RGraphicsViewImage::removeFocus()

virtual

Reimplemented from removeFocus.

virtual void RGraphicsViewImage::repaintView()

virtual

Triggers a paintEvent based on a buffered offscreen bitmap (very fast).

Reimplemented from repaintView.

virtual void RGraphicsViewImage::resizeImage(int w, int h)

virtual

void RGraphicsViewImage::restoreViewport()

void RGraphicsViewImage::saveViewport()

void RGraphicsViewImage::setAlphaEnabled(bool on)

inline

virtual void RGraphicsViewImage::setBackgroundColor(const QColor &col)

virtual

Reimplemented from setBackgroundColor.

void RGraphicsViewImage::setBackgroundTransform(double bgFactor, const RVector &bgOffset)

void RGraphicsViewImage::setColorCorrectionOverride(bool on)

inline

virtual void RGraphicsViewImage::setCursor(const QCursor &cursor)

virtual

Reimplemented from setCursor.

virtual void RGraphicsViewImage::setCursor(Qt::CursorShape cursorShape)

virtual

Reimplemented from setCursor.

void RGraphicsViewImage::setDrawingScale(double s)

inline

void RGraphicsViewImage::setLastKnownModelPosition(const RVector &p)

inline

void RGraphicsViewImage::setLastKnownScreenPosition(const RVector &p)

inline

void RGraphicsViewImage::setMaximumLineweight(double lw)

inline

void RGraphicsViewImage::setMinimumLineweight(double lw)

inline

void RGraphicsViewImage::setNumThreads(int n)

void RGraphicsViewImage::setPaintOffset(const RVector &offset)

inline

void RGraphicsViewImage::setPaintOrigin(bool val)

void RGraphicsViewImage::setPanOptimization(bool on)

virtual void RGraphicsViewImage::setScene(RGraphicsSceneQt *scene, bool regen=true)

virtual

virtual void RGraphicsViewImage::simulateMouseMoveEvent()

virtual

Reimplemented from simulateMouseMoveEvent.

virtual void RGraphicsViewImage::updateImage()

virtual

Repaints the view.

If the view has been invalidated before, the view is redrawn from scratch. Otherwise, only a cached buffer is drawn (very fast).

See also: invalidate

virtual void RGraphicsViewImage::viewportChangeEvent()

virtual

Reimplemented from viewportChangeEvent.

void RGraphicsViewImage::applyColorCorrection(QBrush &brush)

protected

void RGraphicsViewImage::applyColorCorrection(QPen &pen)

protected

void RGraphicsViewImage::applyColorMode(QBrush &brush)

protected

void RGraphicsViewImage::applyColorMode(QPen &pen)

protected

void RGraphicsViewImage::applyMinimumLineweight(QPen &pen)

protected

void RGraphicsViewImage::applyPrintingPenWorkaround(RGraphicsViewWorker *worker, QPen &pen)

protected

Works around the way Qt’s PDF paint engine (PDF export, printing on Linux) strokes pens which it cannot write natively: pens with a transparent color (or any pen while the painter opacity is not 1.0).

Such pens are stroked by Qt itself in painter coordinates (drawing units here) and the stroke outline is exported as a filled polygon. While doing so, Qt replaces pen widths below 0.0001 painter units with a fixed width of 0.1 painter units and flattens curves with a fixed tolerance of 0.25 painter units (see QPdf::Stroker::setPen, QStrokerOps::strokePath). In a drawing in Meters, the minimum print line weight of 0.01mm is 0.00001 drawing units: a transparent hatch printed from such a drawing (directly or through a viewport) ends up with 100mm wide pattern lines and polygonal arcs.

Cosmetic pens are stroked by Qt in device coordinates instead, with the pen width in device pixels and a curve tolerance of 0.25 device pixels. The given pen is converted to an equivalent cosmetic pen if it would be stroked by Qt, using the current painter transformation to scale the width to device pixels. Opaque pens are not touched since those are written natively with their exact width.

The Windows print engine strokes non-cosmetic pens in painter coordinates in the same way (QWin32PrintEnginePrivate::strokePath), cosmetic pens in device coordinates.

virtual void RGraphicsViewImage::drawCircle(RGraphicsViewWorker *worker, QPointF pt, double pSize)

virtual protected

virtual void RGraphicsViewImage::drawDot(RGraphicsViewWorker *worker, QPointF pt)

virtual protected

virtual void RGraphicsViewImage::drawEx(RGraphicsViewWorker *worker, QPointF pt, double pSize)

virtual protected

virtual void RGraphicsViewImage::drawPlus(RGraphicsViewWorker *worker, QPointF pt, double pSize)

virtual protected

virtual void RGraphicsViewImage::drawSquare(RGraphicsViewWorker *worker, QPointF pt, double pSize)

virtual protected

virtual void RGraphicsViewImage::drawVBar(RGraphicsViewWorker *worker, QPointF pt, double pSize)

virtual protected

QColor RGraphicsViewImage::getCorrectedColor(const QColor &col)

protected

double RGraphicsViewImage::getPointSize(double pSize)

protected

QList< RPainterPath > RGraphicsViewImage::getTextLayoutsPainterPaths(const RTextBasedData &text, const QList< RTextLayout > &textLayouts)

protected

virtual RGraphicsViewWorker * RGraphicsViewImage::initWorker(int threadId)

virtual protected

virtual void RGraphicsViewImage::initWorkers()

virtual protected

Updates the graphics buffer from scratch.

This can be relatively slow and is only called on view port changes or document changes.

void RGraphicsViewImage::invalidate(bool force=false)

protected

virtual void RGraphicsViewImage::paintBackground(RGraphicsViewWorker *worker, const QRect &rect=QRect())

virtual protected

virtual void RGraphicsViewImage::paintCursor(RGraphicsViewWorker *worker)

virtual protected

virtual void RGraphicsViewImage::paintDocument(const QRect &rect=QRect())

virtual protected

virtual void RGraphicsViewImage::paintErase(RGraphicsViewWorker *worker, const QRect &rect=QRect())

virtual protected

virtual void RGraphicsViewImage::paintGrid(RGraphicsViewWorker *worker, const QRect &rect=QRect())

virtual protected

virtual void RGraphicsViewImage::paintMetaGrid(RGraphicsViewWorker *worker, const QRect &rect=QRect())

virtual protected

virtual void RGraphicsViewImage::paintOrigin(RGraphicsViewWorker *worker)

virtual protected

Paints the absolute zero point (origin).

virtual void RGraphicsViewImage::paintReferencePoint(RGraphicsViewWorker *worker, const RRefPoint &pos, bool highlight)

virtual protected

virtual void RGraphicsViewImage::paintRelativeZero(RGraphicsViewWorker *worker)

virtual protected

void RGraphicsViewImage::updateTransformation() const

const protected

bool RGraphicsViewImage::alphaEnabled

protected

QList<RGraphicsSceneDrawable> RGraphicsViewImage::backgroundDecoration

protected

double RGraphicsViewImage::backgroundFactor

protected

RVector RGraphicsViewImage::backgroundOffset

protected

int RGraphicsViewImage::bgColorLightness

protected

RBox RGraphicsViewImage::clipBox

protected

bool RGraphicsViewImage::colorCorrection

protected

bool RGraphicsViewImage::colorCorrectionDisableForPrinting

protected

int RGraphicsViewImage::colorCorrectionOverride

protected

int RGraphicsViewImage::colorThreshold

protected

double RGraphicsViewImage::currentScale

protected

RGraphicsViewWorker* RGraphicsViewImage::decorationWorker

protected

bool RGraphicsViewImage::doPaintOrigin

protected

double RGraphicsViewImage::drawingScale

protected

bool RGraphicsViewImage::editingWorkingSet

protected

cached per update: constant while one update is rendered

QImage RGraphicsViewImage::graphicsBuffer

protected

bool RGraphicsViewImage::graphicsBufferNeedsUpdate

protected

QImage RGraphicsViewImage::graphicsBufferWithPreview

protected

bool RGraphicsViewImage::isSelected

protected

double RGraphicsViewImage::lastFactor

protected

RVector RGraphicsViewImage::lastOffset

protected

QString RGraphicsViewImage::lastScaleString

protected

QSize RGraphicsViewImage::lastSize

protected

double RGraphicsViewImage::maximumLineweight

protected

double RGraphicsViewImage::minimumLineweight

protected

QMutex RGraphicsViewImage::mutexSi

protected

int RGraphicsViewImage::numThreads

protected

QList<RObject::Id> RGraphicsViewImage::orderedIds

protected

cached list of visible entities in draw order and what it is valid for

RBox RGraphicsViewImage::orderedIdsBox

protected

bool RGraphicsViewImage::orderedIdsValid

protected

int RGraphicsViewImage::orderedIdsVersion

protected

QMap<int, QMap<RObject::Id, QList<RGraphicsSceneDrawable> > > RGraphicsViewImage::overlayDrawables

protected

RVector RGraphicsViewImage::paintOffset

protected

bool RGraphicsViewImage::panOptimization

protected

QTransform RGraphicsViewImage::previousView

protected

RGraphicsSceneQt* RGraphicsViewImage::sceneQt

protected

QSet<RObject::Id> RGraphicsViewImage::selectedIds

protected

bool RGraphicsViewImage::showOnlyPlottable

protected

QTransform RGraphicsViewImage::transform

protected

QList<RGraphicsViewWorker*> RGraphicsViewImage::workers

protected

void RGraphicsViewImage::updateSnapInfo(RGraphicsViewWorker *worker, RSnap *snap, RSnapRestriction *restriction)

void RGraphicsViewImage::updateTextLabel(RGraphicsViewWorker *worker, const RTextLabel &textLabel)

void RGraphicsViewImage::viewportChanged()