CViewport.h
Go to the documentation of this file.
1 #ifndef iview_CConsoleWidget_included
2 #define iview_CConsoleWidget_included
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>
17 
18 #include <imath/CFixedPointManip.h>
19 
21 #include <iview/CConsoleBase.h>
23 #include <iview/CImageShape.h>
24 
25 
26 namespace iview
27 {
28 
29 
30 class CViewport:
31  public QWidget,
32  public CCalibratedViewBase,
33  virtual public IViewEventObserver
34 {
35  Q_OBJECT
36 
37 public:
39  typedef QWidget BaseClass2;
40 
41  CViewport(CConsoleBase* framePtr, QWidget* parent = NULL);
42  virtual ~CViewport();
43 
44  CConsoleBase* GetFramePtr() const;
45 
46  void UpdateFitTransform();
47 
48  virtual void SetEditMode(int mode);
49 
50  // reimplemented (iview::IShapeView)
51  virtual void SetFitArea(const i2d::CRectangle& area);
52  virtual i2d::CRect GetClientRect() const;
53 
54  // reimplemented (iview::IViewEventObserver)
55  virtual bool OnSelectChange(
56  const iview::IShapeView& view,
57  const istd::CIndex2d& position,
58  const iview::IInteractiveShape& shape,
59  bool state);
60  virtual bool OnViewMouseButton(
61  const iview::IShapeView& view,
62  const istd::CIndex2d& position,
63  Qt::MouseButton buttonType,
64  bool state,
65  const iview::IInteractiveShape* shapePtr);
66 
67  // reimplemented (iview::IMouseActionObserver)
68  virtual bool OnMouseMove(istd::CIndex2d position);
69 
70  // reimplemented (iview::CCalibratedViewBase)
71  virtual void ConnectCalibrationShape(iview::IShape* shapePtr);
72 
73 Q_SIGNALS:
77  void ShapesChanged();
78 
79 protected:
80  virtual void SetBackgroundBufferValid(bool state = true);
81  virtual void OnResize();
82  virtual bool CanBeMoved() const;
83 
84  // reimplemented (QWidget)
85  virtual void paintEvent(QPaintEvent* event);
86  virtual void resizeEvent (QResizeEvent* event);
87  virtual void mousePressEvent(QMouseEvent* event);
88  virtual void mouseReleaseEvent(QMouseEvent* event);
89  virtual void mouseMoveEvent(QMouseEvent* event);
90 
91  // reimplemented (iview::CViewBase)
92  virtual void SetMousePointer(MousePointerMode mode);
93  void UpdateRectArea(const i2d::CRect& rect);
94  virtual void OnBoundingBoxChanged();
95 
96  // reimplemented (iview::IDisplay)
97  virtual void OnAreaInvalidated(const i2d::CRect& beforeBox, const i2d::CRect& afterBox);
98 
99  // static methods
100  int GetMouseKeysState(const QMouseEvent& event);
101 
102 private:
103  QCursor m_mousePointerModes[MPM_LAST + 1];
104 
105  imath::CFixedPointManip m_pixelPositionFormatter;
106  imath::CFixedPointManip m_logicalPositionFormatter;
107  CConsoleBase* m_framePtr;
108 
109  friend class CConsoleBase;
110 };
111 
112 
113 } // namespace iview
114 
115 
116 #endif // !iview_CConsoleWidget_included
117 
118 
int GetMouseKeysState(const QMouseEvent &event)
virtual bool OnViewMouseButton(const iview::IShapeView &view, const istd::CIndex2d &position, Qt::MouseButton buttonType, bool state, const iview::IInteractiveShape *shapePtr)
Message handler for mouse button click.
virtual void mousePressEvent(QMouseEvent *event)
virtual void mouseMoveEvent(QMouseEvent *event)
Abstract base class for all calibrated view.
void UpdateRectArea(const i2d::CRect &rect)
Start updating specified rectangle area.
CViewport(CConsoleBase *framePtr, QWidget *parent=NULL)
MousePointerMode
Defines possible states of mouse pointer.
Definition: ISelectable.h:29
Simple rectangle with integer bounds.
Definition: CRect.h:21
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
void ShapesChanged()
Called when some shapes has been changed.
Common interface for a general shape view implementations.
Definition: IShapeView.h:24
virtual i2d::CRect GetClientRect() const
Get bounding box of client area.
virtual bool OnMouseMove(istd::CIndex2d position)
It is called, when mouse is moved.
void UpdateFitTransform()
Common interface for all display console shapes which can interacts with user.
virtual void SetFitArea(const i2d::CRectangle &area)
Set area will be used to fit in some zoom modes.
CConsoleBase * GetFramePtr() const
virtual ~CViewport()
Definition of rectangle area orthogonal to axis of coordination system.
Definition: CRectangle.h:26
QWidget BaseClass2
Definition: CViewport.h:39
Interface for external view event observer.
virtual void OnResize()
Called if found that display area was resized.
virtual void SetEditMode(int mode)
Set edit mode.
virtual void OnBoundingBoxChanged()
Called when bounding box has been changed.
Common interface for all display console shapes.
Definition: IShape.h:27
virtual bool CanBeMoved() const
This method is internal used to check, if drag mode is allowed.
virtual void ConnectCalibrationShape(iview::IShape *shapePtr)
Connect visualisation shape for calibration object.
Implementation of imath::IDoubleManip interface for fixed point arithmentic.
#define NULL
Definition: istd.h:64
virtual void mouseReleaseEvent(QMouseEvent *event)
CCalibratedViewBase BaseClass
Definition: CViewport.h:38
virtual void paintEvent(QPaintEvent *event)
virtual void SetMousePointer(MousePointerMode mode)
Set mouse pointer.
virtual void OnAreaInvalidated(const i2d::CRect &beforeBox, const i2d::CRect &afterBox)
Invalidate display area.
virtual void resizeEvent(QResizeEvent *event)
virtual void SetBackgroundBufferValid(bool state=true)
Set validate flag of background buffer.
virtual bool OnSelectChange(const iview::IShapeView &view, const istd::CIndex2d &position, const iview::IInteractiveShape &shape, bool state)
Message handler for selection changes.

© 2007-2017 Witold Gantzke and Kirill Lepskiy