QCAD
Open Source 2D CAD
RGraphicsViewQt Class Reference

QWidget based 2d graphics view. More...

#include <RGraphicsViewQt.h>

Inheritance diagram for RGraphicsViewQt:
RGraphicsViewImage RGraphicsView RNonCopyable AutoZoomView

Signals

void dragEnter (QDragEnterEvent *event)
 
void drop (QDropEvent *event)
 
void updateSnapInfo (QPainter *painter, RSnap *snap, RSnapRestriction *restriction)
 
void updateTextLabel (QPainter *painter, const RTextLabel &textLabel)
 
void viewportChanged ()
 

Public Member Functions

void disableGestures ()
 
virtual void emitUpdateSnapInfo (RSnap *snap, RSnapRestriction *restriction)
 
virtual void emitUpdateTextLabel (const RTextLabel &textLabel)
 
virtual QCursor getCursor ()
 
virtual double getDevicePixelRatio () const
 
virtual int getHeight () const
 
virtual QRect getRect () const
 
virtual int getWidth () const
 
virtual void giveFocus ()
 
virtual bool hasFocus ()
 
virtual void removeFocus ()
 
virtual void repaintNow ()
 
virtual void repaintView ()
 Triggers a paintEvent based on a buffered offscreen bitmap (very fast). More...
 
 RGraphicsViewQt (QWidget *parent=NULL, bool showFocus=true)
 Copyright (c) 2011-2015 by Andrew Mustun. More...
 
virtual void setCursor (Qt::CursorShape cursorShape)
 
virtual void setCursor (const QCursor &cursor)
 
void setFocusFrameWidget (QFrame *w)
 
virtual void simulateMouseMoveEvent ()
 
virtual void viewportChangeEvent ()
 
virtual ~RGraphicsViewQt ()
 
- Public Member Functions inherited from RGraphicsViewImage
void addToBackground (const RPainterPath &path)
 
void autoZoom (int margin=RDEFAULT_MIN1, bool ignoreEmpty=false)
 
void centerToBox (const RBox &box)
 Centers the view on the given box. More...
 
void centerToPoint (const RVector &point)
 Centers the view on the given point. More...
 
void clearBackground ()
 
virtual void emitDecorateBackground (QPainter *painter)
 
virtual void emitDecorateForeground (QPainter *painter)
 
bool getAntialiasing () const
 
QColor getBackgroundColor ()
 
RBox getBox () const
 
QImage getBuffer () const
 
bool getColorCorrectionOverride () const
 
RDocumentgetDocument ()
 
RDocumentInterfacegetDocumentInterface ()
 
double getFactor (bool includeStepFactor=true) const
 
RGridgetGrid ()
 
bool getHairlineMode ()
 
RVector getOffset (bool includeStepOffset=true) const
 
bool getPanOptimization ()
 
RGraphicsScenegetScene ()
 
int getTextHeightThresholdOverride () const
 
QTransform getTransform () const
 
int getViewportNumber () const
 
bool isGridVisible () const
 
bool isPrinting () const
 
bool isPrintPreview () const
 
virtual double mapDistanceFromView (double d) const
 Maps the given view distance in pixels to a model distance. More...
 
virtual double mapDistanceToView (double d) const
 Maps the given model distance to a screen distance in pixels. More...
 
virtual RVector mapFromView (const RVector &v, double z=0.0) const
 Maps the given view coordinate in pixels to a model coordinate. More...
 
virtual RVector mapToView (const RVector &v) const
 Maps the given model coordinate to a view coordinate in pixels. More...
 
virtual void paintEntities (QPainter *painter, const RBox &queryBox)
 
virtual void paintEntity (QPainter *painter, REntity::Id id)
 
virtual void paintGridLine (const RLine &ucsPosition)
 
virtual void paintGridPoint (const RVector &ucsPosition)
 
virtual void regenerate (bool force=false)
 Regenerates the view from the underlying scene. More...
 
void resizeImage (int w, int h)
 
void restoreViewport ()
 
 RGraphicsViewImage ()
 Copyright (c) 2011-2015 by Andrew Mustun. More...
 
void saveViewport ()
 
void setAntialiasing (bool on)
 
virtual void setBackgroundColor (const QColor &col)
 
void setBackgroundTransform (double bgFactor, const RVector &bgOffset)
 
void setColorCorrectionOverride (bool on)
 
void setColorMode (RGraphicsView::ColorMode cm)
 
void setFactor (double f, bool regen=true)
 
void setGrid (RGrid *grid)
 
void setGridVisible (bool on)
 
void setHairlineMode (bool on)
 
void setMargin (int m)
 
void setNavigationAction (RAction *action)
 
void setOffset (const RVector &offset, bool regen=true)
 
void setPaintOrigin (bool val)
 
void setPanOptimization (bool on)
 
void setPrinting (bool on)
 
void setPrintPointSize (const RVector &s)
 
void setPrintPreview (bool on)
 
virtual void setScene (RGraphicsSceneQt *scene, bool regen=true)
 
void setTextHeightThresholdOverride (int v)
 
void setViewportNumber (int n)
 
virtual void updateImage ()
 Repaints the view. More...
 
void zoom (const RVector &center, double factor)
 Zooms in / out by the given factor towards / from the given center in scene coordinates. More...
 
void zoomTo (const RBox &window, int margin=0)
 Zooms the view in a way that the given window is visible and fills the view. More...
 
virtual ~RGraphicsViewImage ()
 
- Public Member Functions inherited from RGraphicsView
void addTextLabel (const RTextLabel &textLabel)
 
void autoZoom (int margin=RDEFAULT_MIN1, bool ignoreEmpty=false)
 
void clearCaches ()
 
void clearTextLabels ()
 
bool getAntialiasing () const
 
QColor getBackgroundColor ()
 
REntity::Id getClosestEntity (const RVector &screenPosition, int range, int strictRange, bool includeLockedLayers=true)
 Finds the entity that is the closest to the given screen coordinate (in pixels). More...
 
RVector getClosestReferencePoint (const RVector &screenPosition, int range)
 Finds the reference point that is the closest to the given screen coordinate (in pixels). More...
 
RVector getClosestReferencePoint (REntity::Id entityId, const RVector &screenPosition)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
RGraphicsView::ColorMode getColorMode ()
 
RVector getCurrentStepOffset () const
 
double getCurrentStepScaleFactor () const
 
RDocumentgetDocument () const
 
RDocumentInterfacegetDocumentInterface ()
 
double getFactor (bool includeStepFactor=true) const
 
RGridgetGrid ()
 
bool getHairlineMode ()
 
RVector getLastKnownMousePosition () const
 
int getMargin ()
 
virtual RVector getMaximum () const
 
virtual RVector getMinimum () const
 
RVector getOffset (bool includeStepOffset=true) const
 
RGraphicsScenegetScene ()
 
int getTextHeightThresholdOverride () const
 
QList< RTextLabelgetTextLabels ()
 
int getViewportNumber () const
 
virtual void handleKeyPressEvent (QKeyEvent &event)
 
virtual void handleKeyReleaseEvent (QKeyEvent &event)
 
virtual void handleMouseDoubleClickEvent (RMouseEvent &event)
 This should be called by the mouse double click event handler of a higher level GUI toolkit. More...
 
virtual void handleMouseMoveEvent (RMouseEvent &event)
 This should be called by the mouse move event handler of a higher level GUI toolkit. More...
 
virtual void handleMousePressEvent (RMouseEvent &event)
 This should be called by the mouse press event handler of a higher level GUI toolkit. More...
 
virtual void handleMouseReleaseEvent (RMouseEvent &event)
 This should be called by the mouse release event handler of a higher level GUI toolkit. More...
 
virtual void handlePanGestureEvent (QPanGesture &gesture)
 
virtual void handlePinchGestureEvent (QPinchGesture &gesture)
 
virtual void handleSwipeGestureEvent (QSwipeGesture &gesture)
 
virtual void handleTabletEvent (RTabletEvent &event)
 This should be called by the tablet event handler of a higher level GUI toolkit. More...
 
virtual void handleTerminateEvent (RTerminateEvent &event)
 
virtual void handleWheelEvent (RWheelEvent &event)
 This should be called by the mouse wheel event handler of a higher level GUI toolkit. More...
 
bool isGridVisible () const
 
bool isPathVisible (const RPainterPath &path) const
 
bool isPrinting () const
 
bool isPrintPreview () const
 
virtual QList< RVectormapCornersFromView () const
 
virtual RBox mapToView (const RBox &box) const
 Finds the entity that is the closest to the given screen coordinate (in pixels) and inside the current UCS (read floor). More...
 
virtual void pan (const RVector &delta, bool regen=true)
 Pans (scrolls) by the given amount delta which is a vector in screen coordinates (pixels). More...
 
void restoreViewport ()
 
 RGraphicsView (RGraphicsScene *scene=NULL)
 Copyright (c) 2011-2015 by Andrew Mustun. More...
 
void saveViewport ()
 
void setAntialiasing (bool val)
 
void setColorMode (RGraphicsView::ColorMode cm)
 
void setCurrentStepOffset (const RVector &s)
 
void setCurrentStepScaleFactor (double f)
 
void setDisplayOnlyCurrentUcs (bool on)
 If on is true, only the current UCS and the entities that are in its range are displayed. More...
 
void setFactor (double f, bool regen=true)
 
void setGrid (RGrid *g)
 Sets the current grid. More...
 
void setGridVisible (bool on)
 
void setHairlineMode (bool on)
 
void setMargin (int m)
 
void setNavigationAction (RAction *action)
 Sets an action object that is typically used to handle all navigation interaction (zooming, panning, ...). More...
 
void setOffset (const RVector &offset, bool regen=true)
 
void setPrinting (bool on)
 
void setPrintPointSize (const RVector &s)
 
void setPrintPreview (bool on)
 
virtual void setScene (RGraphicsScene *scene, bool regen=true)
 
void setTextHeightThresholdOverride (int v)
 
void setViewportNumber (int n)
 
void startPan ()
 
void updateTextHeightThreshold ()
 
void zoomIn ()
 Zooms in by factor 1.2. More...
 
void zoomIn (const RVector &center)
 Zooms in by factor 1.2. More...
 
void zoomOut ()
 Zooms out by factor 1.2. More...
 
void zoomOut (const RVector &center)
 Zooms out by factor 1.0/1.2. More...
 
void zoomPrevious ()
 
bool zoomToSelection ()
 
virtual ~RGraphicsView ()
 

Protected Member Functions

virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
bool event (QEvent *e)
 Handle terminate events and gestures. More...
 
virtual void focusInEvent (QFocusEvent *event)
 Called when this view gets the focus. More...
 
virtual void focusOutEvent (QFocusEvent *event)
 Called when this view lost the focus. More...
 
bool gestureEvent (QGestureEvent *event)
 Handle gesture events. More...
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 Relays the Qt mouse event to the scene. More...
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void paintEvent (QPaintEvent *)
 Repaints the view. More...
 
virtual void resizeEvent (QResizeEvent *event)
 
virtual QSize sizeHint () const
 
virtual void tabletEvent (QTabletEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Member Functions inherited from RGraphicsViewImage
virtual void drawCircle (QPainter *painter, QPointF pt, double pSize)
 
virtual void drawDot (QPainter *painter, QPointF pt)
 
virtual void drawEx (QPainter *painter, QPointF pt, double pSize)
 
virtual void drawPlus (QPainter *painter, QPointF pt, double pSize)
 
virtual void drawSquare (QPainter *painter, QPointF pt, double pSize)
 
virtual void drawVBar (QPainter *painter, QPointF pt, double pSize)
 
double getPointSize (double pSize)
 
QPainter * initPainter (QPaintDevice &device, bool erase, bool screen=false, const QRect &rect=QRect())
 
void invalidate (bool force=false)
 
virtual void paintBackground (QPainter *painter, const QRect &rect=QRect())
 
virtual void paintCursor (QPaintDevice &device)
 
virtual void paintDocument (const QRect &rect=QRect())
 
virtual void paintErase (QPaintDevice &device, const QRect &rect=QRect())
 
virtual void paintGrid (QPaintDevice &device, const QRect &rect=QRect())
 
virtual void paintImage (QPainter *painter, RImageData &image)
 
virtual void paintMetaGrid (QPaintDevice &device, const QRect &rect=QRect())
 
virtual void paintOrigin (QPaintDevice &device)
 Paints the absolute zero point (origin). More...
 
virtual void paintReferencePoint (QPainter &painter, const RVector &pos, bool highlight)
 
virtual void paintRelativeZero (QPaintDevice &device)
 
void updateGraphicsBuffer ()
 Updates the graphics buffer from scratch. More...
 
void updateTransformation () const
 

Private Attributes

QFrame * focusFrameWidget
 
bool gesturesEnabled
 
Qt::MouseButtons lastButtonState
 remember last mouse button state for wacom bug workaround More...
 
QCursor lastCursor
 
QTransform previousView
 
bool showFocus
 

Additional Inherited Members

- Public Types inherited from RGraphicsView
enum  ColorMode { FullColor, GrayScale, BlackWhite }
 
- Protected Attributes inherited from RGraphicsViewImage
QList< RPainterPathbackgroundDecoration
 
double backgroundFactor
 
RVector backgroundOffset
 
int bgColorLightness
 
RBox clipBox
 
bool colorCorrection
 
bool colorCorrectionOverride
 
int colorThreshold
 
double currentScale
 
bool doPaintOrigin
 
double drawingScale
 
QImage graphicsBuffer
 
bool graphicsBufferNeedsUpdate
 
QImage graphicsBufferWithPreview
 
QPainter * gridPainter
 
bool isSelected
 
double lastFactor
 
RVector lastOffset
 
QSize lastSize
 
QMutex mutexSi
 
bool panOptimization
 
QTransform previousView
 
RGraphicsSceneQtsceneQt
 
QSet< RObject::IdselectedIds
 
QTransform transform
 
- Protected Attributes inherited from RGraphicsView
bool antialiasing
 
bool autoScalePatterns
 
QColor backgroundColor
 
ColorMode colorMode
 
RVector currentStepOffset
 
double currentStepScaleFactor
 Current scale factor caused by a pinch gesture. More...
 
bool displayOnlyCurrentUcs
 True to only display entities within the horizontal slice that is defined by the current UCS. More...
 
double factor
 Scale factor from model coordinates to view coordinates. More...
 
RGridgrid
 Grid that is currently displayed by this view or NULL. More...
 
int gridVisible
 
bool hairlineMode
 
RVector lastKnownModelPosition
 
RVector lastKnownScreenPosition
 
int margin
 
RActionnavigationAction
 The navigation action of this view or NULL if no navigation action has been set. More...
 
RVector offset
 Offset of the zero point from the lower left corner of the view in model coordinates. More...
 
double previousFactor
 
RVector previousOffset
 
bool printing
 
RVector printPointSize
 
bool printPreview
 
RGraphicsScenescene
 The scene this view is attached to. More...
 
int textHeightThreshold
 
int textHeightThresholdOverride
 
QList< RTextLabeltextLabels
 Internal list of text labels that were added to this view. More...
 
int viewportNumber
 

Detailed Description

QWidget based 2d graphics view.

This graphics view displays a rectangular area of a RGraphicsSceneQt.

Scriptable:
This class is available in script environments.

Constructor & Destructor Documentation

RGraphicsViewQt::RGraphicsViewQt ( QWidget *  parent = NULL,
bool  showFocus = true 
)

Copyright (c) 2011-2015 by Andrew Mustun.

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.

RGraphicsViewQt::~RGraphicsViewQt ( )
virtual

Member Function Documentation

void RGraphicsViewQt::disableGestures ( )
inline
void RGraphicsViewQt::dragEnter ( QDragEnterEvent *  event)
signal
void RGraphicsViewQt::dragEnterEvent ( QDragEnterEvent *  event)
protectedvirtual
void RGraphicsViewQt::drop ( QDropEvent *  event)
signal
void RGraphicsViewQt::dropEvent ( QDropEvent *  event)
protectedvirtual
void RGraphicsViewQt::emitUpdateSnapInfo ( RSnap snap,
RSnapRestriction restriction 
)
virtual

Reimplemented from RGraphicsViewImage.

void RGraphicsViewQt::emitUpdateTextLabel ( const RTextLabel textLabel)
virtual

Reimplemented from RGraphicsViewImage.

bool RGraphicsViewQt::event ( QEvent *  e)
protected

Handle terminate events and gestures.

void RGraphicsViewQt::focusInEvent ( QFocusEvent *  event)
protectedvirtual

Called when this view gets the focus.

Highlights the view to show to the user that events go to this view.

void RGraphicsViewQt::focusOutEvent ( QFocusEvent *  event)
protectedvirtual

Called when this view lost the focus.

Resets the focus highlighting.

bool RGraphicsViewQt::gestureEvent ( QGestureEvent *  event)
protected

Handle gesture events.

QCursor RGraphicsViewQt::getCursor ( )
virtual

Reimplemented from RGraphicsView.

double RGraphicsViewQt::getDevicePixelRatio ( ) const
virtual

Reimplemented from RGraphicsView.

int RGraphicsViewQt::getHeight ( ) const
virtual
Returns
Height of the view in pixels.

Reimplemented from RGraphicsViewImage.

QRect RGraphicsViewQt::getRect ( ) const
virtual
int RGraphicsViewQt::getWidth ( ) const
virtual
Returns
Width of the view in pixels.

Reimplemented from RGraphicsViewImage.

void RGraphicsViewQt::giveFocus ( )
virtual

Reimplemented from RGraphicsViewImage.

bool RGraphicsViewQt::hasFocus ( )
virtual
Returns
True if this view currently has the focus.

Reimplemented from RGraphicsViewImage.

void RGraphicsViewQt::keyPressEvent ( QKeyEvent *  event)
protectedvirtual
void RGraphicsViewQt::keyReleaseEvent ( QKeyEvent *  event)
protectedvirtual
void RGraphicsViewQt::mouseDoubleClickEvent ( QMouseEvent *  event)
protectedvirtual
void RGraphicsViewQt::mouseMoveEvent ( QMouseEvent *  event)
protectedvirtual

Relays the Qt mouse event to the scene.

void RGraphicsViewQt::mousePressEvent ( QMouseEvent *  event)
protectedvirtual
void RGraphicsViewQt::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual
void RGraphicsViewQt::paintEvent ( QPaintEvent *  e)
protectedvirtual

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
void RGraphicsViewQt::removeFocus ( )
virtual

Reimplemented from RGraphicsViewImage.

void RGraphicsViewQt::repaintNow ( )
virtual
void RGraphicsViewQt::repaintView ( )
virtual

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

Reimplemented from RGraphicsViewImage.

void RGraphicsViewQt::resizeEvent ( QResizeEvent *  event)
protectedvirtual
void RGraphicsViewQt::setCursor ( Qt::CursorShape  cursorShape)
virtual

Reimplemented from RGraphicsView.

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

Reimplemented from RGraphicsView.

void RGraphicsViewQt::setFocusFrameWidget ( QFrame *  w)
void RGraphicsViewQt::simulateMouseMoveEvent ( )
virtual

Reimplemented from RGraphicsViewImage.

QSize RGraphicsViewQt::sizeHint ( ) const
protectedvirtual
void RGraphicsViewQt::tabletEvent ( QTabletEvent *  event)
protectedvirtual
void RGraphicsViewQt::updateSnapInfo ( QPainter *  painter,
RSnap snap,
RSnapRestriction restriction 
)
signal
void RGraphicsViewQt::updateTextLabel ( QPainter *  painter,
const RTextLabel textLabel 
)
signal
void RGraphicsViewQt::viewportChanged ( )
signal
void RGraphicsViewQt::viewportChangeEvent ( )
virtual

Reimplemented from RGraphicsView.

void RGraphicsViewQt::wheelEvent ( QWheelEvent *  event)
protectedvirtual

Member Data Documentation

QFrame* RGraphicsViewQt::focusFrameWidget
private
bool RGraphicsViewQt::gesturesEnabled
private
Qt::MouseButtons RGraphicsViewQt::lastButtonState
private

remember last mouse button state for wacom bug workaround

QCursor RGraphicsViewQt::lastCursor
private
QTransform RGraphicsViewQt::previousView
private
bool RGraphicsViewQt::showFocus
private

The documentation for this class was generated from the following files: