SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
proj_ui.h
1#pragma once
2
3#include "imgui/imgui.h"
4#include "nlohmann/json.hpp"
6
7namespace satdump
8{
9 namespace proj
10 {
11 // TODOREWORK allow setting proj as well, and redo this better...
13 {
14 public:
15 int projections_image_width = 2048;
16 int projections_image_height = 1024;
17
18 int projections_mode_radio = 0;
19
20 bool projection_auto_mode = false, projection_auto_scale_mode = false;
21 double projection_autoscale_x = 0.016, projection_autoscale_y = 0.016;
22
23 int projections_current_selected_proj = 0;
25 float projections_equirectangular_tl_lon = -180;
26 float projections_equirectangular_tl_lat = 90;
27 float projections_equirectangular_br_lon = 180;
28 float projections_equirectangular_br_lat = -90;
30 float projections_utm_center_lon = 0;
31 float projections_utm_offset_y = 0;
32 float projections_utm_scale = 2400;
33 int projections_utm_zone = 30;
34 bool projections_utm_south = false;
36 float projections_stereo_center_lon = 0;
37 float projections_stereo_center_lat = 0;
38 float projections_stereo_scale = 2400;
40 float projections_tpers_lon = 0;
41 float projections_tpers_lat = 0;
42 float projections_tpers_alt = 30000000;
43 float projections_tpers_ang = 0;
44 float projections_tpers_azi = 0;
45 float projections_tpers_scale = 8000;
47 float projections_azeq_lon = 0;
48 float projections_azeq_lat = 90;
49
50 NLOHMANN_DEFINE_TYPE_INTRUSIVE(ProjectionConfigUI, projections_image_width, projections_image_height, projections_mode_radio, projection_auto_mode, projection_auto_scale_mode,
51 projection_autoscale_x, projection_autoscale_y, projections_current_selected_proj, projections_equirectangular_tl_lon, projections_equirectangular_tl_lat,
52 projections_equirectangular_br_lon, projections_equirectangular_br_lat, projections_utm_center_lon, projections_utm_offset_y, projections_utm_scale,
53 projections_utm_zone, projections_utm_south, projections_stereo_center_lon, projections_stereo_center_lat, projections_stereo_scale, projections_tpers_lon,
54 projections_tpers_lat, projections_tpers_alt, projections_tpers_ang, projections_tpers_azi, projections_tpers_scale, projections_azeq_lon,
55 projections_azeq_lat);
56
57 public:
58 nlohmann::json get_proj()
59 {
60 nlohmann::json cfg;
61
62 if (projections_current_selected_proj == 0)
63 {
64 cfg["type"] = "equirec";
65 cfg["offset_x"] = projections_equirectangular_tl_lon;
66 cfg["offset_y"] = projections_equirectangular_tl_lat;
67 cfg["scalar_x"] = (projections_equirectangular_br_lon - projections_equirectangular_tl_lon) / double(projections_image_width);
68 cfg["scalar_y"] = (projections_equirectangular_br_lat - projections_equirectangular_tl_lat) / double(projections_image_height);
69 }
70 else if (projections_current_selected_proj == 1)
71 {
72 cfg["type"] = "utm";
73 cfg["scale"] = projections_utm_scale;
74 cfg["zone"] = projections_utm_zone;
75 cfg["south"] = projections_utm_south;
76 cfg["offset_y"] = projections_utm_offset_y;
77 }
78 else if (projections_current_selected_proj == 2)
79 {
80 cfg["type"] = "stereo";
81 cfg["center_lon"] = projections_stereo_center_lon;
82 cfg["center_lat"] = projections_stereo_center_lat;
83 cfg["scale"] = projections_stereo_scale;
84 cfg["width"] = projections_image_width;
85 cfg["height"] = projections_image_height;
86 }
87 else if (projections_current_selected_proj == 3)
88 {
89 cfg["type"] = "tpers";
90 cfg["center_lon"] = projections_tpers_lon;
91 cfg["center_lat"] = projections_tpers_lat;
92 cfg["altitude"] = projections_tpers_alt;
93 cfg["tilt"] = projections_tpers_ang;
94 cfg["azimuth"] = projections_tpers_azi;
95 cfg["scale"] = projections_tpers_scale;
96 cfg["width"] = projections_image_width;
97 cfg["height"] = projections_image_height;
98 }
99 /*else if (projections_current_selected_proj == 4)
100 {
101 cfg["type"] = "azeq";
102 cfg["lon"] = projections_azeq_lon;
103 cfg["lat"] = projections_azeq_lat;
104 }*/
105
106 // Automatic projection settings!
107 if (projection_auto_scale_mode)
108 {
109 cfg["scale_x"] = projection_autoscale_x;
110 cfg["scale_y"] = projection_autoscale_y;
111 }
112 else
113 {
114 cfg["width"] = projections_image_width;
115 cfg["height"] = projections_image_height;
116 }
117
118 return cfg;
119 }
120
121 void drawUI()
122 {
123 ImGui::Text("Output image : ");
124 ImGui::SetNextItemWidth(ImGui::GetWindowWidth() * 0.40f);
125 ImGui::InputInt("##width", &projections_image_width, 0);
126 ImGui::SameLine();
127 ImGui::Text(u8"\uea76");
128 ImGui::SameLine();
129 ImGui::SetNextItemWidth(ImGui::GetWindowWidth() * 0.40f);
130 ImGui::InputInt("##height", &projections_image_height, 0);
131
132 ImGui::Spacing();
133 ImGui::Separator();
134 ImGui::Spacing();
135
136 ImGui::SetNextItemWidth(ImGui::GetWindowWidth() * 0.96f);
137 ImGui::Combo("##targetproj", &projections_current_selected_proj,
138 "Equirectangular\0"
139 "UTM (Mercator)\0"
140 "Stereo\0"
141 "Satellite (TPERS)\0"
142 // "Azimuthal Equidistant\0"
143 );
144
145 if (projections_current_selected_proj == 0)
146 {
147 if (!projection_auto_mode)
148 {
149 ImGui::Text("Top Left Coordinates :");
150 ImGui::InputFloat("Lat##tl", &projections_equirectangular_tl_lat);
151 ImGui::InputFloat("Lon##tl", &projections_equirectangular_tl_lon);
152 ImGui::Spacing();
153 ImGui::Text("Bottom Right Coordinates :");
154 ImGui::InputFloat("Lat##br", &projections_equirectangular_br_lat);
155 ImGui::InputFloat("Lon##br", &projections_equirectangular_br_lon);
156 }
157 }
158 else if (projections_current_selected_proj == 1)
159 {
160 ImGui::InputInt("UTM Zone###projutmzone", &projections_utm_zone);
161 if (projections_utm_zone > 60)
162 projections_utm_zone = 60;
163 if (projections_utm_zone < 1)
164 projections_utm_zone = 1;
165 ImGui::Checkbox("South###projutmsouth", &projections_utm_south);
166 ImGui::InputFloat("Northing (m)##utm", &projections_utm_offset_y);
167 ImGui::Spacing();
168 ImGui::InputFloat("Scale (m/px)##utm", &projections_utm_scale);
169 }
170 else if (projections_current_selected_proj == 2)
171 {
172 ImGui::Text("Center Coordinates :");
173 ImGui::InputFloat("Lat##stereo", &projections_stereo_center_lat);
174 ImGui::InputFloat("Lon##stereo", &projections_stereo_center_lon);
175 ImGui::Spacing();
176 ImGui::InputFloat("Scale (m/px)##stereo", &projections_stereo_scale);
177 }
178 else if (projections_current_selected_proj == 3)
179 {
180 ImGui::Text("Center Coordinates :");
181 ImGui::InputFloat("Lat##tpers", &projections_tpers_lat);
182 ImGui::InputFloat("Lon##tpers", &projections_tpers_lon);
183 ImGui::Spacing();
184 ImGui::InputFloat("Altitude (m)##tpers", &projections_tpers_alt);
185 ImGui::InputFloat("Angle##tpers", &projections_tpers_ang);
186 ImGui::InputFloat("Azimuth##tpers", &projections_tpers_azi);
187 ImGui::Spacing();
188 ImGui::InputFloat("Scale##tpers", &projections_tpers_scale);
189 }
190
191 if (projections_current_selected_proj == 0 || projections_current_selected_proj == 2)
192 {
193 ImGui::Checkbox("Auto Mode###pojautomode", &projection_auto_mode);
194 ImGui::Checkbox("Auto Scale Mode##projautoscalemode", &projection_auto_scale_mode);
195 if (projection_auto_scale_mode)
196 {
197 ImGui::InputDouble("Scale X (m/px)##projscalexauto", &projection_autoscale_x);
198 ImGui::InputDouble("Scale Y (m/px)##projscalexauto", &projection_autoscale_y);
199 }
200 }
201 }
202 };
203 } // namespace proj
204} // namespace satdump
Definition proj_ui.h:13