1 #pragma once 2 3 #ifndef TCAMERA_INCLUDED 4 #define TCAMERA_INCLUDED 5 6 #include "tgeometry.h" 7 8 #undef DVAPI 9 #undef DVVAR 10 #ifdef TOONZLIB_EXPORTS 11 #define DVAPI DV_EXPORT_API 12 #define DVVAR DV_EXPORT_VAR 13 #else 14 #define DVAPI DV_IMPORT_API 15 #define DVVAR DV_IMPORT_VAR 16 #endif 17 18 // forward declaration 19 class TIStream; 20 class TOStream; 21 22 //============================================================================= 23 //! The TCamera class provides a camera and allows its management. 24 /*!A camera is specified by size, getSize() and resolution, getRes(). 25 It can be changed using the setSize(), setRes() functions.tcamera 26 27 The class moreover gives methods to know camera Dpi getDpi(), camera aspect 28 ratio 29 getAspectRatio() and stage rect getStageRect(). 30 */ 31 //============================================================================= 32 33 class DVAPI TCamera { 34 TDimensionD m_size; 35 TDimension m_res; 36 bool m_xPrevalence; 37 TRect m_interestRect; 38 39 public: 40 /*! 41 Constructs TCamera with default value, size (12,9) and resolution (768,576). 42 Constructs TCamera with default value, size (36, 20.25) and resolution 43 (1920,1080). 44 - 05/31/16 45 Constructs TCamera with default value, size (16, 9) and resolution 46 (1920,1080). 47 - 08/16/16 48 */ 49 TCamera(); 50 51 /*! 52 Return camera size. 53 \sa setSize() 54 */ getSize()55 const TDimensionD &getSize() const { return m_size; } 56 /*! 57 Set camera size to \b size. 58 \sa getSize() 59 */ 60 void setSize(const TDimensionD &size, bool preserveDpi = false, 61 bool preserveAR = false); 62 63 /*! 64 Return camera aspect ratio. 65 */ 66 double getAspectRatio() const; 67 68 /*! 69 Return camera resolution. 70 \sa setRes() 71 */ getRes()72 const TDimension &getRes() const { return m_res; } 73 /*! 74 Set camera resolution to \b res. 75 \sa getRes() 76 */ 77 void setRes(const TDimension &res); 78 79 /*! 80 Return camera Dpi. 81 */ 82 TPointD getDpi() const; 83 84 /*! 85 Return true if "resolution width per size height" is equal to 86 "resolution height per size width". 87 */ 88 bool isPixelSquared() const; 89 90 /*! 91 Returns the reference change matrix from stage reference to camera (resolution) 92 reference 93 */ 94 TAffine getStageToCameraRef() const; 95 96 /*! 97 Returns the reference change matrix from camera (resolution) reference to stage 98 reference 99 */ 100 TAffine getCameraToStageRef() const; 101 102 /*! 103 Return stage rect. 104 */ 105 TRectD getStageRect() const; 106 107 /*! 108 Sets the camera's interest rect. Typically used in preview modes. 109 */ 110 void setInterestRect(const TRect &rect); 111 112 /*! 113 Returns the camera's interest rect. 114 */ getInterestRect()115 TRect getInterestRect() const { return m_interestRect; } 116 117 /*! 118 Sets the interest rect from stage coordinates 119 */ 120 void setInterestStageRect(const TRectD &rect); 121 122 /*! 123 Returns the interest rect in stage coordinates. 124 */ 125 TRectD getInterestStageRect() const; 126 setXPrevalence(bool value)127 void setXPrevalence(bool value) { m_xPrevalence = value; } isXPrevalence()128 bool isXPrevalence() { return m_xPrevalence; } 129 130 void saveData(TOStream &os) const; 131 void loadData(TIStream &is); 132 }; 133 134 #endif 135