24#ifndef OCPNVIEWPORT_H_
25#define OCPNVIEWPORT_H_
30#include "color_types.h"
34extern ColorScheme global_color_scheme;
37static const long long lNaN = 0xfff8000000000000;
38#define NAN (*(double *)&lNaN)
41#define INVALID_COORD (-2147483647 - 1)
90 void GetLLFromPix(
const wxPoint2DDouble &p,
double *lat,
double *lon);
100 LLRegion GetLLRegion(
const OCPNRegion ®ion);
109 const LLRegion &llregion,
110 int chart_native_scale);
123 float *llpoints,
int chart_native_scale,
132 ViewPort BuildExpandedVP(
int width,
int height);
178 void Invalidate() { bValid =
false; }
179 void Validate() { bValid =
true; }
180 bool IsValid()
const {
return bValid; }
182 void SetRotationAngle(
double angle_rad) {
rotation = angle_rad; }
183 void SetProjectionType(
int type) { m_projection_type = type; }
185 LLBBox &GetBBox() {
return vpBBox; }
187 void SetBBoxDirect(
const LLBBox &bbox) { vpBBox = bbox; }
188 void SetBBoxDirect(
double latmin,
double lonmin,
double latmax,
192 void InvalidateTransformCache() { lat0_cache = NAN; }
193 void SetVPTransformMatrix();
236 bool b_FullScreenQuilt;
238 int m_projection_type;
239 bool b_MercatorProjectionOverride;
243 float vp_matrix_transform[16];
244 float norm_transform[16];
247 bool operator==(
const ViewPort &rhs)
const {
253 (b_quilt == rhs.b_quilt) &&
254 (b_FullScreenQuilt == rhs.b_FullScreenQuilt) &&
255 (m_projection_type == rhs.m_projection_type) &&
256 (b_MercatorProjectionOverride == rhs.b_MercatorProjectionOverride);
266 double lat0_cache, cache0, cache1;
269 double m_displayScale;
A wrapper class for wxRegion with additional functionality.
ViewPort - Core geographic projection and coordinate transformation engine.
void SetBoxes()
Computes the bounding box coordinates for the current viewport.
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.
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).