20#ifndef __OCPNVIEWPORT_H__
21#define __OCPNVIEWPORT_H__
24#include "color_types.h"
29static const long long lNaN = 0xfff8000000000000;
30#define NAN (*(double *)&lNaN)
35typedef enum ChartTypeEnum
37 CHART_TYPE_UNKNOWN = 0,
49typedef enum ChartFamilyEnum
51 CHART_FAMILY_UNKNOWN = 0,
57typedef enum ColorScheme
59 GLOBAL_COLOR_SCHEME_RGB,
60 GLOBAL_COLOR_SCHEME_DAY,
61 GLOBAL_COLOR_SCHEME_DUSK,
62 GLOBAL_COLOR_SCHEME_NIGHT,
67extern ColorScheme global_color_scheme;
69#define INVALID_COORD (-2147483647 - 1)
118 void GetLLFromPix(
const wxPoint2DDouble &p,
double *lat,
double *lon);
128 LLRegion GetLLRegion(
const OCPNRegion ®ion);
137 const LLRegion &llregion,
138 int chart_native_scale);
151 float *llpoints,
int chart_native_scale,
160 ViewPort BuildExpandedVP(
int width,
int height);
206 void Invalidate() { bValid =
false; }
207 void Validate() { bValid =
true; }
208 bool IsValid()
const {
return bValid; }
210 void SetRotationAngle(
double angle_rad) {
rotation = angle_rad; }
211 void SetProjectionType(
int type) { m_projection_type = type; }
213 LLBBox &GetBBox() {
return vpBBox; }
215 void SetBBoxDirect(
const LLBBox &bbox) { vpBBox = bbox; }
216 void SetBBoxDirect(
double latmin,
double lonmin,
double latmax,
220 void InvalidateTransformCache() { lat0_cache = NAN; }
221 void SetVPTransformMatrix();
264 bool b_FullScreenQuilt;
266 int m_projection_type;
267 bool b_MercatorProjectionOverride;
271 float vp_matrix_transform[16];
272 float norm_transform[16];
275 bool operator==(
const ViewPort &rhs)
const {
281 (b_quilt == rhs.b_quilt) &&
282 (b_FullScreenQuilt == rhs.b_FullScreenQuilt) &&
283 (m_projection_type == rhs.m_projection_type) &&
284 (b_MercatorProjectionOverride == rhs.b_MercatorProjectionOverride);
294 double lat0_cache, cache0, cache1;
297 double m_displayScale;
A wrapper class for wxRegion with additional functionality.
ViewPort - Core geographic projection and coordinate transformation engine.
double view_scale_ppm
Requested view scale in physical pixels per meter (ppm), before applying projections.
double ref_scale
The nominal scale of the "reference chart" for this view.
int pix_height
Height of the viewport in physical pixels.
void SetBoxes(void)
Computes the bounding box coordinates for the current viewport.
double rotation
Rotation angle of the viewport in radians.
void SetPixelScale(double scale)
Set the physical to logical pixel ratio for the display.
wxRect GetVPRectIntersect(size_t n, float *llpoints)
Get the viewport rectangle intersecting with a set of lat/lon points.
int pix_width
Width of the viewport in physical pixels.
wxPoint2DDouble GetDoublePixFromLL(double lat, double lon)
Convert latitude and longitude on the ViewPort to physical pixel coordinates with double precision.
double tilt
Tilt angle for perspective view in radians.
double skew
Angular distortion (shear transform) applied to the viewport in radians.
void GetLLFromPix(const wxPoint &p, double *lat, double *lon)
Convert physical pixel coordinates on the ViewPort to latitude and longitude.
OCPNRegion GetVPRegionIntersect(const OCPNRegion ®ion, const LLRegion &llregion, int chart_native_scale)
Get the intersection of the viewport with a given region.
double clon
Center longitude of the viewport in degrees.
double clat
Center latitude of the viewport in degrees.
wxPoint GetPixFromLL(double lat, double lon)
Convert latitude and longitude on the ViewPort to physical pixel coordinates.
double chart_scale
Chart scale denominator (e.g., 50000 for a 1:50000 scale).