Free Electron
ViewI.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_ViewI_h__
8 #define __draw_ViewI_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief A rendering region
17 
18  @ingroup draw
19 *//***************************************************************************/
20 class FE_DL_EXPORT ViewI:
21  virtual public Component,
22  public CastableAs<ViewI>
23 {
24  public:
25 
26  enum Projection
27  {
28  e_none,
29  e_perspective,
30  e_ortho,
31  e_current
32  };
33 
34  /// @brief Specify window where to draw
35 virtual void setWindow(sp<WindowI> a_spWindowI) =0;
36 virtual sp<WindowI> window(void) const =0;
37 
38  /// @brief Define region where to draw
39 virtual void setViewport(const Box2i& a_rect) =0;
40 virtual Box2i viewport(void) const =0;
41 
42  /** @brief Get current camera
43 
44  This is the most recent camera set with setCamera().
45  */
46 virtual sp<CameraI> camera(void) const =0;
47 virtual void setCamera(sp<CameraI> a_spCameraI) =0;
48 
49 virtual void use(Projection a_projection) =0;
50 
51  /// @brief Set whether ortho or perspective
52 virtual void setProjection(Projection a_projection) =0;
53  /// @brief Get current projection
54 virtual Projection projection(void) const =0;
55 
56  /** @brief Determine 3D location of screen coordinate
57 
58  By default, the current Projection
59  determines the projection method.
60 
61  Window coordinates orginate from bottom left. */
62 virtual SpatialVector unproject(Real a_winx,Real a_winy,Real a_winz,
63  Projection a_projection=e_current) const =0;
64 
65  /** @brief Project 3D location into screen coordinates
66 
67  By default, the current Projection
68  determines the projection method.
69 
70  Window coordinates orginate from bottom left. */
71 virtual SpatialVector project(const SpatialVector& a_point,
72  Projection a_projection= e_current) const =0;
73 
74  /** @brief Estimate object's screen size
75 
76  The input is a sphere center and radius. */
77 virtual Real pixelSize(const SpatialVector& a_center,
78  Real a_radius) const =0;
79 
80  /** @brief Estimate object's world size
81 
82  The input is a sphere center and projected
83  pixel radius. */
84 virtual Real worldSize(const SpatialVector& a_center,
85  Real a_pixels) const =0;
86 
87  /** Return a screen aligned rotation. */
88 virtual void screenAlignment(SpatialTransform &a_rotation) =0;
89 
90  /** Given a screen aligned rotation and world location,
91  return the screen projected location and scale.
92  Useful for normalizing object scale to
93  the screen. */
94 virtual void screenInfo(Real &a_screenScale,
95  SpatialVector &a_screenLocation,
96  const SpatialTransform &a_rotation,
97  const SpatialVector &a_location) =0;
98 
99  /** @brief Clip all drawing operations to a 2D box
100 
101  Use NULL pointer to stop scissoring. */
102 virtual void setScissor(const Box2i* a_pBox) =0;
103 
104  /** @brief Get current scissor region
105 
106  NULL indicates no scissoring. */
107 virtual const Box2i* scissor(void) const =0;
108 
109 };
110 
111 } /* namespace ext */
112 } /* namespace fe */
113 
114 #endif /* __draw_ViewI_h__ */
A rendering region.
Definition: ViewI.h:20
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
kernel
Definition: namespace.dox:3
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
Base for all interfacable components.
Definition: Component.h:20
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192