OSVR-Core
DisplayDescriptorSchema1.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_DisplayDescriptorSchema1_h_GUID_E976C3C5_C76D_4781_6930_A133E598D5B1
26 #define INCLUDED_DisplayDescriptorSchema1_h_GUID_E976C3C5_C76D_4781_6930_A133E598D5B1
27 
28 // Internal Includes
29 #include <osvr/Util/Angles.h>
30 
31 // Library/third-party includes
32 #include <json/value.h>
33 
34 // Standard includes
35 #include <string>
36 #include <iostream>
37 #include <stdexcept>
38 #include <vector>
39 
40 namespace osvr {
41 namespace client {
42  namespace display_schema_1 {
43  struct DisplayDescriptorParseException : public std::runtime_error {
44  DisplayDescriptorParseException(const std::string &message)
45  : std::runtime_error("Display descriptor parse error: " +
46  message) {}
47  };
49  public:
50  enum DisplayMode {
51  HORIZONTAL_SIDE_BY_SIDE,
52  VERTICAL_SIDE_BY_SIDE,
53  FULL_SCREEN
54  };
55 
57  DisplayDescriptor(const std::string &display_description);
58 
59  void parse(const std::string &display_description);
60 
61  void print() const;
62 
65  std::string getHumanReadableDescription() const;
66 
68  std::string getVendor() const;
69  std::string getModel() const;
70  std::string getVersion() const;
71  std::string getNote() const;
72  // Since the original "numDisplays" value in descriptors is
73  // redundant and inconsistent, this "accessor" actually computes
74  // what that value should be. Usually, you either want this computed
75  // value, or activeResolution().videoInputs (which should generally
76  // be in sync)
77  int getNumDisplays() const;
78 
79  int getDisplayTop() const;
80  int getDisplayLeft() const;
81  int getDisplayWidth() const;
82  int getDisplayHeight() const;
83  DisplayMode getDisplayMode() const;
84 
85  util::Angle getVerticalFOV() const;
86  util::Angle getHorizontalFOV() const;
87 #if 0
88  double getVerticalFOV() const;
89  double getVerticalFOVRadians() const;
90  double getHorizontalFOV() const;
91  double getHorizontalFOVRadians() const;
92 #endif
93  double getOverlapPercent() const;
94 #if 0
95  double getPitchTilt() const;
96 #endif
97  util::Angle getPitchTilt() const;
98 
99  double getIPDMeters() const;
100 
102  double k1_red = 0.;
103  double k1_green = 0.;
104  double k1_blue = 0.;
105  };
106 
107  DistortionParams getDistortion() const { return m_distort; }
108 
110  class EyeInfo {
111  public:
112  double m_CenterProjX = 0.5;
113  double m_CenterProjY = 0.5;
114  bool m_rotate180 = false;
115 
116  void print() const;
117  };
118 
119  std::vector<EyeInfo> const &getEyes() const;
120 
121  struct Resolution {
122  int width;
123  int height;
124  int video_inputs = 1;
125  DisplayMode display_mode;
126  };
127 
128  Resolution const &activeResolution() const {
129  return m_resolutions.at(m_activeResolution);
130  }
131 
132  private:
133  Resolution &activeResolution() {
134  return m_resolutions.at(m_activeResolution);
135  }
136 
137  void m_processResolution(Json::Value const &resolution);
138 
139  std::string m_vendor;
140  std::string m_model;
141  std::string m_version;
142  std::string m_note;
143 
144  util::Angle m_monocularHorizontalFOV;
145  util::Angle m_monocularVerticalFOV;
146  double m_overlapPercent;
147  util::Angle m_pitchTilt;
148 
149  std::vector<Resolution> m_resolutions;
150 
152  DistortionParams m_distort;
153 
154  // Rendering
155  double m_rightRoll = 0.;
156  double m_leftRoll = 0.;
157 
158  // Eyes
159  std::vector<EyeInfo> m_eyes;
160 
161  // Active resolution
162  size_t m_activeResolution = 0;
163  };
164  } // namespace display_schema_1
165 
166 } // namespace client
167 } // namespace osvr
168 #endif // INCLUDED_DisplayConfiguration_h_GUID_E976C3C5_C76D_4781_6930_A133E598D5B1
AngleRadiansd Angle
Default angle type.
Definition: Angles.h:63
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Structure holding the information for one eye.
Definition: DisplayDescriptorSchema1.h:110
Definition: DisplayDescriptorSchema1.h:48
Header.
Definition: DisplayDescriptorSchema1.h:121