Free Electron
ViewCommon.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __draw_ViewCommon_h__
8 #define __draw_ViewCommon_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief general-implementation methods for ViewI
17 
18  @ingroup draw
19 *//***************************************************************************/
20 class FE_DL_EXPORT ViewCommon: virtual public ViewI
21 {
22  public:
23  ViewCommon(void);
24 
25  //* as ViewI
26 virtual void setWindow(sp<WindowI> a_spWindowI)
27  { m_spWindowI=a_spWindowI; }
28 virtual sp<WindowI> window(void) const
29  { return m_spWindowI; }
30 
31 virtual void setViewport(const Box2i& a_rect)
32  { m_viewport=a_rect; }
33 virtual Box2i viewport(void) const
34  { return m_viewport; }
35 
36 virtual void setCamera(sp<CameraI> a_spCameraI);
37 virtual sp<CameraI> camera(void) const
38  { return m_spCameraI; }
39 
40 virtual ViewI::Projection projection(void) const
41  { return m_projection; }
42 virtual void setProjection(Projection a_projection)
43  { m_projection=a_projection; }
44 
45 virtual void screenAlignment(SpatialTransform& a_rotation);
46 
47 virtual void screenInfo(Real &a_screenScale,
48  SpatialVector &a_screenLocation,
49  const SpatialTransform& a_rotation,
50  const SpatialVector &a_location);
51 
52 virtual void setScissor(const Box2i* a_pBox) {}
53 virtual const Box2i* scissor(void) const { return NULL; }
54 
55 virtual void use(ViewI::Projection a_projection);
56 
57 virtual SpatialVector unproject(Real a_winx,Real a_winy,Real a_winz,
58  ViewI::Projection a_projection=
59  ViewI::e_current) const;
60 
61 virtual SpatialVector project(const SpatialVector& a_point,
62  ViewI::Projection a_projection=
63  ViewI::e_current) const;
64 
65 virtual Real pixelSize(const SpatialVector& a_center,
66  Real a_radius) const;
67 
68 virtual Real worldSize(const SpatialVector& a_center,
69  Real a_pixels) const;
70 
71 static Matrix<4,4,Real> computeOrtho(Real a_zoom,
72  const Vector<2,Real> &a_center,
73  const Vector<2,Real> &a_size);
74 
75  private:
76  sp<CameraI> m_spCameraI;
77  sp<CameraEditable> m_spCameraInternal;
78  ViewI::Projection m_projection;
79 
80  sp<WindowI> m_spWindowI;
81  Box2i m_viewport;
82 };
83 
84 } /* namespace ext */
85 } /* namespace fe */
86 
87 #endif /* __draw_ViewCommon_h__ */
A rendering region.
Definition: ViewI.h:20
virtual void setViewport(const Box2i &a_rect)
Define region where to draw.
Definition: ViewCommon.h:31
void unproject(Vector< 4, T > &a_r, const Matrix< 4, 4, T > &a_m, const Vector< 4, T > &a_v)
reverse project vector through matrix. reverses w division
Definition: Matrix.h:1197
virtual ViewI::Projection projection(void) const
Get current projection.
Definition: ViewCommon.h:40
kernel
Definition: namespace.dox:3
virtual sp< CameraI > camera(void) const
Get current camera.
Definition: ViewCommon.h:37
general-implementation methods for ViewI
Definition: ViewCommon.h:20
void project(Vector< 4, T > &a_r, const Matrix< 4, 4, T > &a_m, const Vector< 4, T > &a_v)
project vector through matrix. divides by transformed w
Definition: Matrix.h:1182
virtual void setScissor(const Box2i *a_pBox)
Clip all drawing operations to a 2D box.
Definition: ViewCommon.h:52
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
virtual void setProjection(Projection a_projection)
Set whether ortho or perspective.
Definition: ViewCommon.h:42
virtual const Box2i * scissor(void) const
Get current scissor region.
Definition: ViewCommon.h:53
virtual void setWindow(sp< WindowI > a_spWindowI)
Specify window where to draw.
Definition: ViewCommon.h:26