1 //******************************************************************* 2 // Copyright (C) 2000 ImageLinks Inc. 3 // 4 // License: MIT 5 // 6 // See LICENSE.txt file in the top level directory for more details. 7 // 8 // Author: Garrett Potts 9 // 10 //******************************************************************* 11 // $Id: ossimImageViewAffineTransform.h 23477 2015-08-26 14:39:12Z gpotts $ 12 #ifndef ossimImageViewAffineTransform_HEADER 13 #define ossimImageViewAffineTransform_HEADER 14 #include <ossim/projection/ossimImageViewTransform.h> 15 #include <ossim/matrix/newmat.h> 16 17 class OSSIMDLLEXPORT ossimImageViewAffineTransform: public ossimImageViewTransform 18 { 19 public: 20 /** 21 * Initialize transform completely here. The image-to-view transform is a chain of 3x3 matrix 22 * multiplies as: [translation] [view scale] [rotation (about pivot pt)] [image scale]. 23 * The view to image is stored as the inverse transform. 24 * @param rotateDegrees 25 * @param imageScaleX Image-side scale, applied before rotation 26 * @param imageScaleY ditto 27 * @param scaleXValue View-side scale 28 * @param scaleYValue ditto 29 * @param translateXValue View-side translation 30 * @param translateYValue ditto 31 * @param pivotXValue Pivot point in image space 32 * @param pivotYValue ditto 33 */ 34 ossimImageViewAffineTransform(double rotateDegrees = 0.0, 35 double imageScaleX = 1.0, 36 double imageScaleY = 1.0, 37 double scaleXValue = 1.0, 38 double scaleYValue = 1.0, 39 double translateXValue = 0.0, 40 double translateYValue = 0.0, 41 double pivotXValue = 0.0, 42 double pivotYValue = 0.0 ); 43 virtual ~ossimImageViewAffineTransform(); 44 ossimImageViewAffineTransform(const ossimImageViewAffineTransform & src)45 ossimImageViewAffineTransform(const ossimImageViewAffineTransform& src) 46 :ossimImageViewTransform(src), 47 m_transform(src.m_transform), 48 m_inverseTransform(src.m_inverseTransform), 49 m_rotation(src.m_rotation), 50 m_imageSpaceScale(src.m_imageSpaceScale), 51 m_scale(src.m_scale), 52 m_translate(src.m_translate), 53 m_pivot(src.m_pivot) 54 { 55 } dup()56 virtual ossimObject* dup()const 57 { 58 return new ossimImageViewAffineTransform(*this); 59 } 60 // virtual void inverse(const ossimDpt& input, 61 // ossimDpt& output) const 62 // { 63 // viewToImage(input, output); 64 // } 65 66 virtual void imageToView(const ossimDpt& imagePoint, 67 ossimDpt& viewPoint)const; 68 virtual void viewToImage(const ossimDpt& viewPoint, 69 ossimDpt& imagePoint)const; 70 void setMatrix(NEWMAT::Matrix& matrix); 71 const NEWMAT::Matrix& getMatrix()const; 72 isIdentity()73 virtual bool isIdentity()const 74 { 75 return ((m_transform[0][0] == 1.0)&& 76 (m_transform[0][1] == 0.0)&& 77 (m_transform[0][2] == 0.0)&& 78 (m_transform[1][0] == 0.0)&& 79 (m_transform[1][1] == 1.0)&& 80 (m_transform[1][2] == 0.0)&& 81 (m_transform[2][0] == 0.0)&& 82 (m_transform[2][1] == 0.0)&& 83 (m_transform[2][2] == 1.0)); 84 } 85 86 virtual bool isValid()const; 87 virtual bool setView(ossimObject* obj); 88 virtual ossimObject* getView(); 89 virtual const ossimObject* getView()const; 90 91 /** @return (1, 1) ???????(drb) */ 92 virtual ossimDpt getInputMetersPerPixel()const; 93 94 /** @return (nan, nan) ????????? (drb) */ 95 virtual ossimDpt getOutputMetersPerPixel()const; 96 97 /*! 98 * Translate in the x and y direction. 99 */ 100 virtual void translate(double deltaX, double deltaY); 101 102 /*! 103 * Translate in the x direction. 104 */ 105 virtual void translateX(double deltaX); 106 107 /*! 108 * Translate in the Y direction. 109 */ 110 virtual void translateY(double deltaY); 111 112 /*! 113 * Translate the origin for rotation in the x and y direction. 114 */ 115 virtual void pivot(double originX, double originY); 116 117 /*! 118 * Translate the origin for rotation in the x direction. 119 */ 120 virtual void pivotX(double originX); 121 122 /*! 123 * Translate the origin for rotation in the y direction. 124 */ 125 virtual void pivotY(double originY); 126 127 /*! 128 * Will allow you to specify an image scale 129 * for both the x and y direction. 130 */ 131 virtual void imageSpaceScale(double x, double y); 132 133 /*! 134 * Will allow you to specify an image scale along the X direction. 135 */ 136 virtual void imageSpaceScaleX(double x); 137 138 /*! 139 * Will allow you to an image scale along the Y direction. 140 */ 141 virtual void imageSpaceScaleY(double y); 142 143 /*! 144 * will allow you to specify a scale 145 * for both the x and y direction. 146 */ 147 virtual void scale(double x, double y); 148 149 /*! 150 * will alow you to specify a scale 151 * along the X direction. 152 */ 153 virtual void scaleX(double x); 154 155 /*! 156 * Will allow you to scale along the Y 157 * direction. 158 */ 159 virtual void scaleY(double y); 160 161 /*! 162 * Will apply a rotation 163 */ 164 virtual void rotate(double degrees); 165 getRotation()166 ossim_float64 getRotation()const{return m_rotation;} getScale()167 const ossimDpt& getScale()const{return m_scale;} getTranslate()168 const ossimDpt& getTranslate()const{return m_translate;} getPivot()169 const ossimDpt& getPivot()const{return m_pivot;} 170 171 172 virtual bool isEqualTo(const ossimObject& obj, ossimCompareType compareType = OSSIM_COMPARE_FULL)const; 173 174 virtual bool loadState(const ossimKeywordlist& kwl, 175 const char* prefix =0); 176 177 virtual bool saveState(ossimKeywordlist& kwl, 178 const char* prefix =0)const; 179 180 181 protected: 182 void buildCompositeTransform(); 183 184 /*! 185 * This is the transformation from image to 186 * viewing coordinates. If this matrix is 187 * changed it will perform an inverse to solve 188 * the inverse transform. 189 */ 190 NEWMAT::Matrix m_transform; 191 NEWMAT::Matrix m_inverseTransform; 192 ossim_float64 m_rotation; 193 ossimDpt m_imageSpaceScale; 194 ossimDpt m_scale; 195 ossimDpt m_translate; 196 ossimDpt m_pivot; 197 198 TYPE_DATA 199 }; 200 201 #endif 202