OTB  6.7.0
Orfeo Toolbox
otbViewSettings.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otb_ViewSettings_h
22 #define otb_ViewSettings_h
23 
24 #include "itkObject.h"
25 #include "itkSmartPointer.h"
26 #include "itkPoint.h"
27 #include "itkVector.h"
28 #include "itkSize.h"
29 
30 #include "otbImageKeywordlist.h"
31 #include "OTBIceExport.h"
32 #include <string>
33 
34 namespace otb
35 {
36 
37 class OTBIce_EXPORT ViewSettings
38  : public itk::Object
39 {
40 public:
41  typedef ViewSettings Self;
45 
50 
51  itkNewMacro(Self);
52 
53  itkSetMacro(Origin,PointType);
54  itkGetConstReferenceMacro(Origin,PointType);
55 
56  itkSetMacro(Spacing,SpacingType);
57  itkGetConstReferenceMacro(Spacing,SpacingType);
58 
59  itkSetMacro(ViewportSize,SizeType);
60  itkGetConstReferenceMacro(ViewportSize,SizeType);
61 
62  void Reset();
63 
64  void SetRotationCenter(const PointType & center)
65  {
66  m_RotationCenter = center;
67  }
68  itkGetConstReferenceMacro(RotationCenter,PointType);
69 
70  void SetRotationAngle(const double & angle)
71  {
72  m_RotationAngle = angle;
73  }
74 
75  itkGetConstReferenceMacro(RotationAngle,double);
76 
77  // Order of priority is Wkt, then keywordlist, then unknown
78  void SetWkt(const std::string & wkt)
79  {
80  // std::cout << "Wkt: '" << m_Wkt << "' -> '" << wkt << "'" << std::endl;
81  // std::cout << std::hex << this << "::SetWkt(" << (m_Wkt!=wkt) << ")" << std::endl;
82 
83  if(m_Wkt != wkt)
84  {
85  // std::cout << "geometry-changed: TRUE" << std::endl;
86 
87  m_Wkt = wkt;
88  m_GeometryChanged = true;
89  }
90  }
91 
92  itkGetConstReferenceMacro( Wkt, std::string );
93 
94  void SetUseProjection(bool usep)
95  {
96  // std::cout << std::hex << this << "::SetUseProjection(" << usep << ")" << std::endl;
97 
98  if(m_UseProjection != usep)
99  {
100  // std::cout << "geometry-changed: TRUE " << std::endl;
101 
102  m_UseProjection = usep;
103  m_GeometryChanged = true;
104  }
105  }
106 
107  itkGetConstMacro(UseProjection, bool);
108  itkBooleanMacro(UseProjection);
109 
110  itkSetMacro(GeometryChanged,bool);
111  itkGetConstMacro(GeometryChanged,bool);
112 
114  {
115  // std::cout << std::hex << this << "::SetKeywordList()" << std::endl;
116 
117  if(!(m_KeywordList==kwl))
118  {
119  // std::cout << "geometry-changed: TRUE" << std::endl;
120 
121  m_KeywordList = kwl;
122  m_GeometryChanged = true;
123  }
124  }
125 
126  itkGetConstReferenceMacro(KeywordList,KeywordListType);
127 
128  // Retrieve the current Viewport extent
129  void GetViewportExtent(double & ulx, double & uly, double & lrx, double & lry) const;
130 
131  PointType GetViewportCenter() const;
132 
133  void ScreenToViewPortTransform(const double & xscreen, const double & yscreen, double & xvp, double & yvp) const;
134 
135  void ViewportToScreenTransform(const double & xvp, const double & yvp, double & xscreen, double & yscreen) const;
136 
137  void Zoom(const PointType & zoomCenter,double scale = 1.1);
138 
139  void Center(const PointType & center);
140 
141  void SetPersepectiveAngle();
142 
143  void SetNorthUpAngle();
144 
145  void UpdateRotation(const PointType & newCenter, double newAngle);
146 
147  double GetScale( const PointType & origin, const PointType & extent, bool isSigned ) const;
148 
149 protected:
150  ViewSettings();
151 
152  ~ViewSettings() override;
153 
154 private:
155  // prevent implementation
156  ViewSettings(const Self&);
157  void operator=(const Self&);
158 
162  std::string m_Wkt;
166  bool m_UseProjection : 1;
167  bool m_GeometryChanged : 1;
168 
169 }; // End class ViewSettings
170 
171 } // End namespace otb
172 
173 #endif
itk::Point< double, 2 > PointType
void SetWkt(const std::string &wkt)
void SetKeywordList(const KeywordListType &kwl)
Storage and conversion for OSSIM metadata.
itk::Object Superclass
void SetRotationAngle(const double &angle)
itk::SmartPointer< Self > Pointer
void SetRotationCenter(const PointType &center)
PointType m_RotationCenter
otb::ImageKeywordlist KeywordListType
SpacingType m_Spacing
itk::Size< 2 > SizeType
KeywordListType m_KeywordList
void SetUseProjection(bool usep)
ViewSettings Self
itk::SmartPointer< const Self > ConstPointer
VectorImageType::PointType PointType
Definition: mvdTypes.h:189
itk::Vector< double, 2 > SpacingType