4#include <QGraphicsView>
6#include <Kanoop/utility/loggingbaseclass.h>
7#include <Kanoop/gui/libkanoopgui.h>
8#include <Kanoop/geometry/point.h>
21 public LoggingBaseClass
72 virtual bool eventFilter(QObject *watched, QEvent *event)
override;
73 bool processWheelEvent(QWheelEvent* event);
74 bool processMouseButtonPressEvent(QMouseEvent* event);
75 bool processMouseButtonReleaseEvent(QMouseEvent* event);
76 bool processMouseMoveEvent(QMouseEvent* event);
78 enum State { Normal, Pan, Zoom };
80 bool _zoomEnabled =
true;
81 double _zoomFactor = 1.001;
83 bool _panEnabled =
true;
85 Point _panStartCenter;
88 State _state = Normal;
102 void resized(
const Size& newSize,
const Size& oldSize);
QGraphicsView subclass with built-in mouse pan and wheel zoom support.
void setPanEnabled(bool value)
Enable or disable mouse-drag panning.
void setScaleFactor(double factor)
Set the view scale to an absolute factor.
GraphicsView(QWidget *parent=nullptr)
Construct with an optional parent widget.
void setZoomEnabled(bool value)
Enable or disable mouse-wheel zooming.
virtual void resizeEvent(QResizeEvent *event) override
Emit resized() with old and new viewport sizes.
bool panEnabled() const
Return whether mouse-drag panning is enabled.
void resized(const Size &newSize, const Size &oldSize)
Emitted when the viewport is resized.
void scaleChanged(double scale)
Emitted when the view scale changes.
double currentScale() const
Return the current horizontal scale of the view transform.
bool isZoomEnabled() const
Return whether mouse-wheel zooming is enabled.