ACF $AcfVersion:0$
CViewport.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtGui/QPainter>
7#include <QtGui/QCursor>
8#include <QtGui/QPainter>
9#if QT_VERSION >= 0x050000
10#include <QtWidgets/QWidget>
11#else
12#include <QtGui/QWidget>
13#endif
14
15// ACF includes
16#include <iimg/IBitmap.h>
19#include <iview/CConsoleBase.h>
21#include <iview/CImageShape.h>
22
23
24namespace iview
25{
26
27
29 public QWidget,
31 virtual public IViewEventObserver
32{
33 Q_OBJECT
34
35public:
37 typedef QWidget BaseClass2;
38
39 CViewport(CConsoleBase* framePtr, QWidget* parent = NULL);
40 virtual ~CViewport();
41
43
45
46 bool MoveViewBy(int dx, int dy);
47
48 void SetShowInfoText(bool on);
49
50 void SetMousePointerCursor(int mode, const QCursor& cursor);
51
52 virtual void SetEditMode(int mode);
53
54 // reimplemented (iview::IShapeView)
55 virtual void SetFitArea(const i2d::CRectangle& area) override;
56 virtual i2d::CRect GetClientRect() const override;
57 virtual void Update() override;
58
59 // reimplemented (iview::IViewEventObserver)
60 virtual bool OnSelectChange(
61 const iview::IShapeView& view,
62 const istd::CIndex2d& position,
63 const iview::IInteractiveShape& shape,
64 bool state) override;
65 virtual bool OnViewMouseButton(
66 const iview::IShapeView& view,
67 const istd::CIndex2d& position,
68 Qt::MouseButton buttonType,
69 bool state,
70 const iview::IInteractiveShape* shapePtr) override;
71 virtual bool OnViewMouseMove(
72 const iview::IShapeView& view,
73 const istd::CIndex2d& position) override;
74
75 // reimplemented (iview::IMouseActionObserver)
76 virtual bool OnMouseMove(istd::CIndex2d position) override;
77
78 // reimplemented (iview::CCalibratedViewBase)
79 virtual void ConnectCalibrationShape(iview::IShape* shapePtr) override;
80
81Q_SIGNALS:
86
88
89protected:
90 virtual void SetBackgroundBufferValid(bool state = true);
91 virtual void OnResize();
92 virtual bool CanBeMoved() const;
93
94 // reimplemented (QWidget)
95 virtual void paintEvent(QPaintEvent* event) override;
96 virtual void resizeEvent (QResizeEvent* event) override;
97 virtual void keyPressEvent(QKeyEvent* event) override;
98 virtual void keyReleaseEvent(QKeyEvent* event) override;
99 virtual void mousePressEvent(QMouseEvent* event) override;
100 virtual void mouseReleaseEvent(QMouseEvent* event) override;
101 virtual void mouseMoveEvent(QMouseEvent* event) override;
102 virtual void leaveEvent(QEvent* event) override;
103
104 // reimplemented (iview::CViewBase)
105 virtual void SetMousePointer(MousePointerMode mode) override;
106 virtual void UpdateRectArea(const i2d::CRect& rect) override;
107 virtual void OnBoundingBoxChanged() override;
108
109 // reimplemented (iview::IDisplay)
110 virtual void OnAreaInvalidated(const i2d::CRect& beforeBox, const i2d::CRect& afterBox) override;
111
112 // static methods
113 int GetMouseKeysState(const QMouseEvent& event);
114
115protected:
117
121
122 bool m_showInfoText = false;
123 QString m_infoText;
124
125 friend class CConsoleBase;
126};
127
128
129} // namespace iview
130
131
Simple rectangle with integer bounds.
Definition CRect.h:22
Definition of rectangle area orthogonal to axis of coordination system.
Definition CRectangle.h:27
Implementation of double value manipulator with fixed-point arithmetic and rounding.
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:21
Abstract base class for all calibrated view.
virtual void mouseMoveEvent(QMouseEvent *event) override
virtual void UpdateRectArea(const i2d::CRect &rect) override
Start updating specified rectangle area.
QWidget BaseClass2
Definition CViewport.h:37
void ShapesChanged()
Called when some shapes has been changed.
virtual void SetEditMode(int mode)
Changes the edit mode.
CConsoleBase * m_framePtr
Definition CViewport.h:120
virtual void paintEvent(QPaintEvent *event) override
virtual void Update() override
Updates all invalidates shapes.
virtual ~CViewport()
virtual i2d::CRect GetClientRect() const override
Get bounding box of client area.
void BoundingBoxChanged()
virtual void mousePressEvent(QMouseEvent *event) override
void SetShowInfoText(bool on)
imath::CFixedPointManip m_logicalPositionFormatter
Definition CViewport.h:119
virtual bool OnViewMouseMove(const iview::IShapeView &view, const istd::CIndex2d &position) override
Event handler for mouse move event.
virtual void keyReleaseEvent(QKeyEvent *event) override
virtual bool CanBeMoved() const
This method is internal used to check, if drag mode is allowed.
QString m_infoText
Definition CViewport.h:123
virtual bool OnMouseMove(istd::CIndex2d position) override
It is called, when mouse is moved.
virtual void SetBackgroundBufferValid(bool state=true)
Set validate flag of background buffer.
virtual bool OnViewMouseButton(const iview::IShapeView &view, const istd::CIndex2d &position, Qt::MouseButton buttonType, bool state, const iview::IInteractiveShape *shapePtr) override
Event handler for mouse button click.
virtual void ConnectCalibrationShape(iview::IShape *shapePtr) override
Connect visualisation shape for calibration object.
virtual void OnAreaInvalidated(const i2d::CRect &beforeBox, const i2d::CRect &afterBox) override
Invalidate display area.
int GetMouseKeysState(const QMouseEvent &event)
virtual void SetFitArea(const i2d::CRectangle &area) override
Set area used for fitting of the view contents.
virtual bool OnSelectChange(const iview::IShapeView &view, const istd::CIndex2d &position, const iview::IInteractiveShape &shape, bool state) override
Event handler for selection changes.
virtual void resizeEvent(QResizeEvent *event) override
virtual void OnBoundingBoxChanged() override
Called when bounding box has been changed.
bool MoveViewBy(int dx, int dy)
virtual void keyPressEvent(QKeyEvent *event) override
virtual void SetMousePointer(MousePointerMode mode) override
Set mouse pointer.
CCalibratedViewBase BaseClass
Definition CViewport.h:36
void SetMousePointerCursor(int mode, const QCursor &cursor)
void UpdateFitTransform()
virtual void leaveEvent(QEvent *event) override
CViewport(CConsoleBase *framePtr, QWidget *parent=NULL)
virtual void mouseReleaseEvent(QMouseEvent *event) override
QCursor m_mousePointerModes[MPM_LAST]
Definition CViewport.h:116
CConsoleBase * GetFramePtr() const
imath::CFixedPointManip m_pixelPositionFormatter
Definition CViewport.h:118
virtual void OnResize()
Called if found that display area was resized.
Common interface for all display console shapes which can interacts with user.
MousePointerMode
Defines possible states of mouse pointer.
Definition ISelectable.h:29
Common interface for all display console shapes.
Definition IShape.h:32
Common interface for a general shape view implementations.
Definition IShapeView.h:30
Interface for external view event observer.
#define NULL
Definition istd.h:74
In this library is defined 2D view concept and standard visualisation objects.