OTB  6.7.0
Orfeo Toolbox
otbGlVectorActor.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_GlVectorActor_h
22 #define otb_GlVectorActor_h
23 
24 
25 #include "otbGenericRSTransform.h"
26 #include "otbGeoInterface.h"
27 #include "otbGlActor.h"
29 #include "otbOGRFeatureWrapper.h"
30 #include "otbOGRLayerWrapper.h"
31 
33 #include "itkVector.h"
34 #include <string>
35 
36 
37 // Forward declaration of GLUtesselator
38 class GLUtesselator;
39 
40 namespace otb
41 {
42 
43 class OTBIce_EXPORT GlVectorActor
44  : public GlActor, public GeoInterface
45 {
46 public:
55 
56  itkNewMacro(Self);
57 
58  // Initialize with a new file
59  void Initialize(const std::string & filename, const std::string & layername = "");
60 
61  // Get all available layers
62  std::vector<std::string> GetAvailableLayers() const;
63 
64  // Get layer name
65  std::string GetCurrentLayer() const;
66 
67  // Set layer name
68  void SetCurrentLayer(const std::string & layername);
69 
70  // Retrieve the full extent of the actor
71  void GetExtent(double & ulx, double & uly, double & lrx, double & lry) const override;
72 
73  // Return actor extent in its own geometry
74  void GetBoundingBox(double & ulx, double & uly, double & lrx, double & lry) const;
75 
76  // Update internal actor state with respect to ViewSettings
77  void ProcessViewSettings() override;
78 
79  // Heavy load/unload operations of data
80  void UpdateData() override;
81 
82  // Gl rendering of current state
83  void Render() override;
84 
85  PointType ViewportToVectorTransform(const PointType & point) const;
86 
87  itkSetMacro(Color,ColorType);
88  itkGetConstReferenceMacro(Color,ColorType);
89 
90  itkSetMacro(Alpha,double);
91  itkGetConstReferenceMacro(Alpha,double);
92 
93  void SetFill(bool flag);
94  itkGetMacro(Fill,bool);
95  itkBooleanMacro(Fill);
96 
97  void SetSolidBorder(bool flag);
98  itkGetMacro(SolidBorder,bool);
99  itkBooleanMacro(SolidBorder);
100 
101  void SetOptimizedRendering(bool flag);
102  itkGetMacro(OptimizedRendering,bool);
103  itkBooleanMacro(OptimizedRendering);
104 
105  itkGetMacro(OptimizedRenderingActive,bool);
106 
107  itkSetMacro(LineWidth,double);
108  itkGetConstReferenceMacro(LineWidth,double);
109 
110  std::string GetWkt() const override;
111 
112  //
113  // otb::GlActor overloads.
114  //
115 
116  bool TransformFromViewport( Point2d & out,
117  const Point2d & in,
118  bool isPhysical = true ) const override;
119 
120 
121 protected:
122  GlVectorActor();
123 
124  ~GlVectorActor() override;
125 
126 
127  // Internal class to hold tiles
129  {
130  public:
131  InternalFeature(OGRFeatureDefn & definition)
132  : m_SourceFeature(definition),
133  m_RenderedFeature(definition)
134  {}
135 
138  };
139 
140 private:
141  // prevent implementation
142  GlVectorActor(const Self&);
143  void operator=(const Self&);
144 
145  void InternalFeaturesTransform();
146 
147  void UpdateTransforms();
148 
149  void UpdateDisplayList();
150 
152  double m_Alpha;
153  bool m_Fill;
155  double m_LineWidth;
156 
159 
161  std::string m_CurrentLayer;
162 
163  std::vector<InternalFeature> m_InternalFeatures;
164 
165  GLUtesselator * m_GluTesselator;
166 
167  unsigned int m_DisplayList;
169 
170  double m_ExtentULX;
171  double m_ExtentULY;
172  double m_ExtentLRX;
173  double m_ExtentLRY;
174 
177 
178  unsigned int m_PointMarkerSize;
179 
182 
183 }; // End class GlVectorActor
184 
185 } // End namespace otb
186 
187 #endif
RSTransformType::Pointer m_VectorToViewportTransform
RigidTransformType::Pointer m_ViewportForwardRotationTransform
RigidTransformType::Pointer m_ViewportBackwardRotationTransform
unsigned int m_DisplayList
GLUtesselator * m_GluTesselator
unsigned int m_PointMarkerSize
RSTransformType::Pointer m_ViewportToVectorTransform
itk::SmartPointer< const Self > ConstPointer
InternalFeature(OGRFeatureDefn &definition)
itk::CenteredRigid2DTransform RigidTransformType
RSTransformType::InputPointType PointType
itk::Vector< double, 3 > ColorType
This is the class to handle generic remote sensing transform.
Geometric objet with descriptive fields.
std::vector< InternalFeature > m_InternalFeatures
itk::SmartPointer< Self > Pointer
std::string m_CurrentLayer
GlVectorActor Self
otb::GenericRSTransform RSTransformType
otb::ogr::DataSource::Pointer m_OGRDataSource