LibrePCB Developers Documentation
GraphicsView Class Referencefinal

The GraphicsView class. More...

#include <graphicsview.h>

Inherits QGraphicsView.

+ Collaboration diagram for GraphicsView:

Classes

struct  RulerGauge
 

Public Types

enum class  CursorOption
 

Public Slots

void zoomIn () noexcept
 
void zoomOut () noexcept
 
void zoomAll () noexcept
 
void zoomToRect (const QRectF &rect) noexcept
 
void showWaitingSpinner () noexcept
 
void hideWaitingSpinner () noexcept
 

Signals

void cursorScenePositionChanged (const Point &pos)
 Cursor scene position changed signal. More...
 

Public Member Functions

 GraphicsView (const GraphicsView &other)=delete
 
 GraphicsView (QWidget *parent=nullptr, IF_GraphicsViewEventHandler *eventHandler=nullptr) noexcept
 
 ~GraphicsView () noexcept
 
GraphicsScenegetScene () const noexcept
 
QRectF getVisibleSceneRect () const noexcept
 
bool getUseOpenGl () const noexcept
 
const PositiveLengthgetGridInterval () const noexcept
 
Theme::GridStyle getGridStyle () const noexcept
 
bool isMouseButtonPressed (Qt::MouseButtons btn) const noexcept
 
qint64 getIdleTimeMs () const noexcept
 
void setBackgroundColors (const QColor &fill, const QColor &grid) noexcept
 
void setOverlayColors (const QColor &fill, const QColor &content) noexcept
 
void setInfoBoxColors (const QColor &fill, const QColor &text) noexcept
 
void setUseOpenGl (bool useOpenGl) noexcept
 
void setGrayOut (bool grayOut) noexcept
 
void setGridStyle (Theme::GridStyle style) noexcept
 
void setGridInterval (const PositiveLength &interval) noexcept
 
void setScene (GraphicsScene *scene) noexcept
 
void setVisibleSceneRect (const QRectF &rect) noexcept
 
void setSceneRectMarker (const QRectF &rect) noexcept
 Setup the marker for a specific scene rect. More...
 
void setSceneCursor (const tl::optional< std::pair< Point, CursorOptions > > &cursor) noexcept
 
void setRulerPositions (const tl::optional< std::pair< Point, Point > > &pos) noexcept
 
void setInfoBoxText (const QString &text) noexcept
 
void setOriginCrossVisible (bool visible) noexcept
 
void setEventHandlerObject (IF_GraphicsViewEventHandler *eventHandler) noexcept
 
Point mapGlobalPosToScenePos (const QPoint &globalPosPx, bool boundToView, bool mapToGrid) const noexcept
 
QPainterPath calcPosWithTolerance (const Point &pos, qreal multiplier=1) const noexcept
 
void handleMouseWheelEvent (QGraphicsSceneWheelEvent *event) noexcept
 
GraphicsViewoperator= (const GraphicsView &rhs)=delete
 

Private Slots

void zoomAnimationValueChanged (const QVariant &value) noexcept
 

Private Member Functions

void wheelEvent (QWheelEvent *event)
 
bool eventFilter (QObject *obj, QEvent *event)
 
void drawBackground (QPainter *painter, const QRectF &rect)
 
void drawForeground (QPainter *painter, const QRectF &rect)
 

Private Attributes

QScopedPointer< WaitingSpinnerWidgetmWaitingSpinnerWidget
 
QScopedPointer< QLabel > mInfoBoxLabel
 
IF_GraphicsViewEventHandlermEventHandlerObject
 
GraphicsScenemScene
 
QVariantAnimation * mZoomAnimation
 
Theme::GridStyle mGridStyle
 
PositiveLength mGridInterval
 
QColor mBackgroundColor
 
QColor mGridColor
 
QColor mOverlayFillColor
 
QColor mOverlayContentColor
 
QRectF mSceneRectMarker
 
bool mOriginCrossVisible
 
bool mUseOpenGl
 
bool mGrayOut
 
tl::optional< std::pair< Point, CursorOptions > > mSceneCursor
 If not nullopt, a cursor will be shown at the given position. More...
 
QVector< RulerGaugemRulerGauges
 
tl::optional< std::pair< Point, Point > > mRulerPositions
 
volatile bool mPanningActive
 
Qt::MouseButton mPanningButton
 
Qt::MouseButtons mPressedMouseButtons
 
QCursor mCursorBeforePanning
 
qint64 mIdleTimeMs
 

Static Private Attributes

static constexpr qreal sZoomStepFactor = 1.3
 

Detailed Description

The GraphicsView class.

Member Enumeration Documentation

◆ CursorOption

enum class CursorOption
strong
Enumerator
Cross 
Circle 

Constructor & Destructor Documentation

◆ GraphicsView() [1/2]

GraphicsView ( const GraphicsView other)
delete

◆ GraphicsView() [2/2]

GraphicsView ( QWidget *  parent = nullptr,
IF_GraphicsViewEventHandler eventHandler = nullptr 
)
explicitnoexcept
+ Here is the call graph for this function:

◆ ~GraphicsView()

~GraphicsView ( )
noexcept

Member Function Documentation

◆ getScene()

GraphicsScene * getScene ( ) const
inlinenoexcept

◆ getVisibleSceneRect()

QRectF getVisibleSceneRect ( ) const
noexcept

◆ getUseOpenGl()

bool getUseOpenGl ( ) const
inlinenoexcept

◆ getGridInterval()

const PositiveLength & getGridInterval ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getGridStyle()

Theme::GridStyle getGridStyle ( ) const
inlinenoexcept

◆ isMouseButtonPressed()

bool isMouseButtonPressed ( Qt::MouseButtons  btn) const
inlinenoexcept

◆ getIdleTimeMs()

qint64 getIdleTimeMs ( ) const
inlinenoexcept

◆ setBackgroundColors()

void setBackgroundColors ( const QColor &  fill,
const QColor &  grid 
)
noexcept

◆ setOverlayColors()

void setOverlayColors ( const QColor &  fill,
const QColor &  content 
)
noexcept

◆ setInfoBoxColors()

void setInfoBoxColors ( const QColor &  fill,
const QColor &  text 
)
noexcept

◆ setUseOpenGl()

void setUseOpenGl ( bool  useOpenGl)
noexcept

◆ setGrayOut()

void setGrayOut ( bool  grayOut)
noexcept

◆ setGridStyle()

void setGridStyle ( Theme::GridStyle  style)
noexcept

◆ setGridInterval()

void setGridInterval ( const PositiveLength interval)
noexcept

◆ setScene()

void setScene ( GraphicsScene scene)
noexcept

◆ setVisibleSceneRect()

void setVisibleSceneRect ( const QRectF &  rect)
noexcept

◆ setSceneRectMarker()

void setSceneRectMarker ( const QRectF &  rect)
noexcept

Setup the marker for a specific scene rect.

This is intended to mark a specific area in a scene, with a line starting from the top left of the view, so the user can easily locate the specified area, even if it is very small.

Parameters
rectThe rect to mark. Pass an empty rect to clear the marker.

◆ setSceneCursor()

void setSceneCursor ( const tl::optional< std::pair< Point, CursorOptions > > &  cursor)
noexcept
+ Here is the caller graph for this function:

◆ setRulerPositions()

void setRulerPositions ( const tl::optional< std::pair< Point, Point > > &  pos)
noexcept

◆ setInfoBoxText()

void setInfoBoxText ( const QString &  text)
noexcept
+ Here is the caller graph for this function:

◆ setOriginCrossVisible()

void setOriginCrossVisible ( bool  visible)
noexcept

◆ setEventHandlerObject()

void setEventHandlerObject ( IF_GraphicsViewEventHandler eventHandler)
noexcept

◆ mapGlobalPosToScenePos()

Point mapGlobalPosToScenePos ( const QPoint &  globalPosPx,
bool  boundToView,
bool  mapToGrid 
) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calcPosWithTolerance()

QPainterPath calcPosWithTolerance ( const Point pos,
qreal  multiplier = 1 
) const
noexcept

◆ handleMouseWheelEvent()

void handleMouseWheelEvent ( QGraphicsSceneWheelEvent *  event)
noexcept
+ Here is the caller graph for this function:

◆ operator=()

GraphicsView & operator= ( const GraphicsView rhs)
delete

◆ zoomIn

void zoomIn ( )
slotnoexcept

◆ zoomOut

void zoomOut ( )
slotnoexcept

◆ zoomAll

void zoomAll ( )
slotnoexcept
+ Here is the call graph for this function:

◆ zoomToRect

void zoomToRect ( const QRectF &  rect)
slotnoexcept
+ Here is the caller graph for this function:

◆ showWaitingSpinner

void showWaitingSpinner ( )
slotnoexcept
+ Here is the caller graph for this function:

◆ hideWaitingSpinner

void hideWaitingSpinner ( )
slotnoexcept
+ Here is the caller graph for this function:

◆ cursorScenePositionChanged

void cursorScenePositionChanged ( const Point pos)
signal

Cursor scene position changed signal.

Parameters
posThe new cursor position (not mapped to grid!)
+ Here is the caller graph for this function:

◆ zoomAnimationValueChanged

void zoomAnimationValueChanged ( const QVariant &  value)
privateslotnoexcept

◆ wheelEvent()

void wheelEvent ( QWheelEvent *  event)
private

◆ eventFilter()

bool eventFilter ( QObject *  obj,
QEvent *  event 
)
private
+ Here is the call graph for this function:

◆ drawBackground()

void drawBackground ( QPainter *  painter,
const QRectF &  rect 
)
private

◆ drawForeground()

void drawForeground ( QPainter *  painter,
const QRectF &  rect 
)
private
+ Here is the call graph for this function:

Member Data Documentation

◆ mWaitingSpinnerWidget

QScopedPointer<WaitingSpinnerWidget> mWaitingSpinnerWidget
private

◆ mInfoBoxLabel

QScopedPointer<QLabel> mInfoBoxLabel
private

◆ mEventHandlerObject

IF_GraphicsViewEventHandler* mEventHandlerObject
private

◆ mScene

GraphicsScene* mScene
private

◆ mZoomAnimation

QVariantAnimation* mZoomAnimation
private

◆ mGridStyle

Theme::GridStyle mGridStyle
private

◆ mGridInterval

PositiveLength mGridInterval
private

◆ mBackgroundColor

QColor mBackgroundColor
private

◆ mGridColor

QColor mGridColor
private

◆ mOverlayFillColor

QColor mOverlayFillColor
private

◆ mOverlayContentColor

QColor mOverlayContentColor
private

◆ mSceneRectMarker

QRectF mSceneRectMarker
private

◆ mOriginCrossVisible

bool mOriginCrossVisible
private

◆ mUseOpenGl

bool mUseOpenGl
private

◆ mGrayOut

bool mGrayOut
private

◆ mSceneCursor

tl::optional<std::pair<Point, CursorOptions> > mSceneCursor
private

If not nullopt, a cursor will be shown at the given position.

◆ mRulerGauges

QVector<RulerGauge> mRulerGauges
private

◆ mRulerPositions

tl::optional<std::pair<Point, Point> > mRulerPositions
private

◆ mPanningActive

volatile bool mPanningActive
private

◆ mPanningButton

Qt::MouseButton mPanningButton
private

◆ mPressedMouseButtons

Qt::MouseButtons mPressedMouseButtons
private

◆ mCursorBeforePanning

QCursor mCursorBeforePanning
private

◆ mIdleTimeMs

qint64 mIdleTimeMs
private

◆ sZoomStepFactor

constexpr qreal sZoomStepFactor = 1.3
staticconstexprprivate

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