Custom QGraphicsView for a canvas application.
More...
#include <canvas_view.h>
|
| | CanvasView (QWidget *parent=nullptr) |
| | Constructs a new CanvasView object.
|
| QPointF | getCenter () const |
| | Gets the current center point of the view.
|
| qreal | getScale () const |
| | Gets the current scale factor of the view.
|
| void | setScale (qreal scale) |
| | Sets the scale factor of the view.
|
| void | zoom (float scaleFactor) |
| | Zooms in by a given scale factor.
|
| void | centerOn (const QPointF &pos) |
| | Centers the view on a specific position.
|
| void | centerOn (const QGraphicsItem *item) |
| | Centers the view on a specific QGraphicsItem.
|
| void | onSettingsChanged (const AppearanceSettings &settings) |
| | Handles settings changes, specifically for appearance settings.
|
|
| void | keyPressEvent (QKeyEvent *) override |
| | Overrides the key press event to handle zoom and pan controls.
|
| void | keyReleaseEvent (QKeyEvent *) override |
| | Overrides the key release event to handle zoom and pan controls.
|
| void | mouseMoveEvent (QMouseEvent *) override |
| | Overrides the mouse move event to handle panning.
|
| void | mousePressEvent (QMouseEvent *) override |
| | Overrides the mouse press event to start panning or zooming.
|
| void | mouseReleaseEvent (QMouseEvent *) override |
| | Overrides the mouse release event to stop panning.
|
| void | wheelEvent (QWheelEvent *) override |
| | Overrides the wheel event to handle zooming.
|
| void | drawBackground (QPainter *painter, const QRectF &rect) override |
| | Draws the background of the view, including a grid if enabled.
|
|
|
void | zoomIn () |
| | Zooms in by applying a zoom factor of 1 + mZoomDelta.
|
|
void | zoomOut () |
| | Zooms out by applying a zoom factor of 1 - mZoomDelta.
|
|
void | resetZoom () |
| | Resets the view to its default scale.
|
| qreal | quantisedScale (qreal proposedScale) const |
| | Quantises the proposed scale to ensure it is within valid limits and aligned with grid size.
|
|
void | setMaxSize () |
| | Sets the maximum size of the view's scene rectangle.
|
|
|
bool | mDoMousePanning |
| | Flags to determine if zooming or panning should be done.
|
|
bool | mDoKeyZoom |
| | Flag to determine if key-based zooming is active.
|
|
bool | mShowGrid |
| | Flag to show the grid on the canvas.
|
|
QPoint | mLastMousePos |
| | Last mouse position for panning.
|
|
qreal | mZoomDelta |
| | Delta value for zooming.
|
|
qreal | mZoomKey |
| | Key used for zooming.
|
|
qreal | mMinZoom |
| | Minimum allowed zoom level.
|
|
qreal | mMaxZoom |
| | Maximum allowed zoom level.
|
|
Qt::MouseButton | mPanButton |
| | Mouse button used for panning.
|
Custom QGraphicsView for a canvas application.
◆ CanvasView()
| CanvasView::CanvasView |
( |
QWidget * | parent = nullptr | ) |
|
Constructs a new CanvasView object.
- Parameters
-
| parent | Pointer to the parent widget. |
◆ centerOn() [1/2]
| void CanvasView::centerOn |
( |
const QGraphicsItem * | item | ) |
|
Centers the view on a specific QGraphicsItem.
- Parameters
-
| item | The QGraphicsItem to center on. |
◆ centerOn() [2/2]
| void CanvasView::centerOn |
( |
const QPointF & | pos | ) |
|
Centers the view on a specific position.
- Parameters
-
| pos | The position to center on. |
◆ drawBackground()
| void CanvasView::drawBackground |
( |
QPainter * | painter, |
|
|
const QRectF & | rect ) |
|
overrideprotected |
Draws the background of the view, including a grid if enabled.
- Parameters
-
| painter | Pointer to the QPainter object. |
| rect | The rectangle to draw the background in. |
◆ getCenter()
| QPointF CanvasView::getCenter |
( |
| ) |
const |
Gets the current center point of the view.
- Returns
- QPointF The center point.
◆ getScale()
| qreal CanvasView::getScale |
( |
| ) |
const |
Gets the current scale factor of the view.
- Returns
- qreal The scale factor.
◆ keyPressEvent()
| void CanvasView::keyPressEvent |
( |
QKeyEvent * | event | ) |
|
|
overrideprotected |
Overrides the key press event to handle zoom and pan controls.
- Parameters
-
| event | Pointer to the QKeyEvent object. |
◆ keyReleaseEvent()
| void CanvasView::keyReleaseEvent |
( |
QKeyEvent * | event | ) |
|
|
overrideprotected |
Overrides the key release event to handle zoom and pan controls.
- Parameters
-
| event | Pointer to the QKeyEvent object. |
◆ mouseMoveEvent()
| void CanvasView::mouseMoveEvent |
( |
QMouseEvent * | event | ) |
|
|
overrideprotected |
Overrides the mouse move event to handle panning.
- Parameters
-
| event | Pointer to the QMouseEvent object. |
◆ mousePressEvent()
| void CanvasView::mousePressEvent |
( |
QMouseEvent * | event | ) |
|
|
overrideprotected |
Overrides the mouse press event to start panning or zooming.
- Parameters
-
| event | Pointer to the QMouseEvent object. |
◆ mouseReleaseEvent()
| void CanvasView::mouseReleaseEvent |
( |
QMouseEvent * | event | ) |
|
|
overrideprotected |
Overrides the mouse release event to stop panning.
- Parameters
-
| event | Pointer to the QMouseEvent object. |
◆ onSettingsChanged()
Handles settings changes, specifically for appearance settings.
- Parameters
-
| settings | The new appearance settings. |
◆ quantisedScale()
| qreal CanvasView::quantisedScale |
( |
qreal | proposedScale | ) |
const |
|
private |
Quantises the proposed scale to ensure it is within valid limits and aligned with grid size.
- Parameters
-
| proposedScale | The proposed scale factor. |
- Returns
- qreal The quantised scale factor.
◆ setScale()
| void CanvasView::setScale |
( |
qreal | scale | ) |
|
Sets the scale factor of the view.
- Parameters
-
| scale | The new scale factor. |
◆ wheelEvent()
| void CanvasView::wheelEvent |
( |
QWheelEvent * | event | ) |
|
|
overrideprotected |
Overrides the wheel event to handle zooming.
- Parameters
-
| event | Pointer to the QWheelEvent object. |
◆ zoom()
| void CanvasView::zoom |
( |
float | scaleFactor | ) |
|
Zooms in by a given scale factor.
- Parameters
-
| scaleFactor | The zoom scale factor. |
The documentation for this class was generated from the following files:
- /__w/maki/maki/app/system/canvas_view.h
- /__w/maki/maki/app/system/canvas_view.cpp