OpenCPN Partial API docs
Loading...
Searching...
No Matches
ViewPort Class Reference

Represents the view port for chart display in OpenCPN. More...

#include <viewport.h>

Public Member Functions

wxPoint GetPixFromLL (double lat, double lon)
 Convert latitude and longitude on the ViewPort to physical pixel coordinates.
 
void GetLLFromPix (const wxPoint &p, double *lat, double *lon)
 Convert physical pixel coordinates on the ViewPort to latitude and longitude.
 
void GetLLFromPix (const wxPoint2DDouble &p, double *lat, double *lon)
 Convert physical pixel coordinates on the ViewPort to latitude and longitude using double precision.
 
wxPoint2DDouble GetDoublePixFromLL (double lat, double lon)
 Convert latitude and longitude on the ViewPort to physical pixel coordinates with double precision.
 
LLRegion GetLLRegion (const OCPNRegion &region)
 
OCPNRegion GetVPRegionIntersect (const OCPNRegion &region, const LLRegion &llregion, int chart_native_scale)
 Get the intersection of the viewport with a given region.
 
OCPNRegion GetVPRegionIntersect (const OCPNRegion &Region, int nPoints, float *llpoints, int chart_native_scale, wxPoint *ppoints)
 Get the intersection of the viewport with a polygon defined by lat/lon points.
 
wxRect GetVPRectIntersect (size_t n, float *llpoints)
 Get the viewport rectangle intersecting with a set of lat/lon points.
 
ViewPort BuildExpandedVP (int width, int height)
 
void SetBoxes (void)
 
void SetPixelScale (double scale)
 Set the physical to logical pixel ratio for the display.
 
void Invalidate ()
 
void Validate ()
 
bool IsValid () const
 
void SetRotationAngle (double angle_rad)
 
void SetProjectionType (int type)
 
LLBBox & GetBBox ()
 
void SetBBoxDirect (const LLBBox &bbox)
 
void SetBBoxDirect (double latmin, double lonmin, double latmax, double lonmax)
 
bool ContainsIDL ()
 
void InvalidateTransformCache ()
 
void SetVPTransformMatrix ()
 
bool operator== (const ViewPort &rhs) const
 

Public Attributes

double clat
 Center latitude of the viewport in degrees.
 
double clon
 Center longitude of the viewport in degrees.
 
double view_scale_ppm
 Requested view scale in physical pixels per meter (ppm), before applying projections.
 
double skew
 Angular distortion (shear transform) applied to the viewport in radians.
 
double rotation
 Rotation angle of the viewport in radians.
 
double tilt
 Tilt angle for perspective view in radians.
 
double chart_scale
 Chart scale denominator (e.g., 50000 for a 1:50000 scale).
 
double ref_scale
 The nominal scale of the "reference chart" for this view.
 
int pix_width
 Width of the viewport in physical pixels.
 
int pix_height
 Height of the viewport in physical pixels.
 
bool b_quilt
 
bool b_FullScreenQuilt
 
int m_projection_type
 
bool b_MercatorProjectionOverride
 
wxRect rv_rect
 
float vp_matrix_transform [16]
 
float norm_transform [16]
 

Detailed Description

Represents the view port for chart display in OpenCPN.

Encapsulates all parameters that define the current view of the chart, including position, scale, rotation, and projection type. Provides methods for coordinate conversions and viewport manipulations.

Definition at line 84 of file viewport.h.

Constructor & Destructor Documentation

◆ ViewPort()

ViewPort::ViewPort ( )

Definition at line 119 of file viewport.cpp.

Member Function Documentation

◆ BuildExpandedVP()

ViewPort ViewPort::BuildExpandedVP ( int  width,
int  height 
)

Definition at line 974 of file viewport.cpp.

◆ ContainsIDL()

bool ViewPort::ContainsIDL ( )

Definition at line 967 of file viewport.cpp.

◆ GetBBox()

LLBBox & ViewPort::GetBBox ( )
inline

Definition at line 180 of file viewport.h.

◆ GetDoublePixFromLL()

wxPoint2DDouble ViewPort::GetDoublePixFromLL ( double  lat,
double  lon 
)

Convert latitude and longitude on the ViewPort to physical pixel coordinates with double precision.

Parameters
latLatitude in degrees.
lonLongitude in degrees.
Returns
wxPoint2DDouble Physical pixel coordinates.

Definition at line 145 of file viewport.cpp.

◆ GetLLFromPix() [1/2]

void ViewPort::GetLLFromPix ( const wxPoint &  p,
double *  lat,
double *  lon 
)
inline

Convert physical pixel coordinates on the ViewPort to latitude and longitude.

Parameters
pPhysical pixel coordinates.
latPointer to store resulting latitude.
lonPointer to store resulting longitude.

Definition at line 104 of file viewport.h.

◆ GetLLFromPix() [2/2]

void ViewPort::GetLLFromPix ( const wxPoint2DDouble &  p,
double *  lat,
double *  lon 
)

Convert physical pixel coordinates on the ViewPort to latitude and longitude using double precision.

Parameters
pPhysical pixel coordinates as wxPoint2DDouble.
latPointer to store resulting latitude.
lonPointer to store resulting longitude.

Definition at line 268 of file viewport.cpp.

◆ GetLLRegion()

LLRegion ViewPort::GetLLRegion ( const OCPNRegion region)

Definition at line 343 of file viewport.cpp.

◆ GetPixFromLL()

wxPoint ViewPort::GetPixFromLL ( double  lat,
double  lon 
)

Convert latitude and longitude on the ViewPort to physical pixel coordinates.

Parameters
latLatitude in degrees.
lonLongitude in degrees.
Returns
wxPoint Pixel coordinates.

Definition at line 136 of file viewport.cpp.

◆ GetVPRectIntersect()

wxRect ViewPort::GetVPRectIntersect ( size_t  n,
float *  llpoints 
)

Get the viewport rectangle intersecting with a set of lat/lon points.

Parameters
nNumber of points
llpointsArray of lat/lon points
Returns
wxRect Intersecting rectangle

Definition at line 798 of file viewport.cpp.

◆ GetVPRegionIntersect() [1/2]

OCPNRegion ViewPort::GetVPRegionIntersect ( const OCPNRegion region,
const LLRegion &  llregion,
int  chart_native_scale 
)

Get the intersection of the viewport with a given region.

Parameters
regionOCPNRegion to intersect with
llregionLLRegion to use for the intersection
chart_native_scaleNative scale of the chart
Returns
OCPNRegion Resulting intersected region

Definition at line 419 of file viewport.cpp.

◆ GetVPRegionIntersect() [2/2]

OCPNRegion ViewPort::GetVPRegionIntersect ( const OCPNRegion Region,
int  nPoints,
float *  llpoints,
int  chart_native_scale,
wxPoint *  ppoints 
)

Get the intersection of the viewport with a polygon defined by lat/lon points.

Parameters
RegionOCPNRegion to intersect with
nPointsNumber of points in the polygon
llpointsArray of lat/lon points defining the polygon
chart_native_scaleNative scale of the chart
ppointsArray to store resulting pixel coordinates
Returns
OCPNRegion Resulting intersected region

Definition at line 480 of file viewport.cpp.

◆ Invalidate()

void ViewPort::Invalidate ( )
inline

Definition at line 173 of file viewport.h.

◆ InvalidateTransformCache()

void ViewPort::InvalidateTransformCache ( )
inline

Definition at line 187 of file viewport.h.

◆ IsValid()

bool ViewPort::IsValid ( ) const
inline

Definition at line 175 of file viewport.h.

◆ operator==()

bool ViewPort::operator== ( const ViewPort rhs) const
inline

Definition at line 235 of file viewport.h.

◆ SetBBoxDirect() [1/2]

void ViewPort::SetBBoxDirect ( const LLBBox &  bbox)
inline

Definition at line 182 of file viewport.h.

◆ SetBBoxDirect() [2/2]

void ViewPort::SetBBoxDirect ( double  latmin,
double  lonmin,
double  latmax,
double  lonmax 
)

Definition at line 963 of file viewport.cpp.

◆ SetBoxes()

void ViewPort::SetBoxes ( void  )

Definition at line 821 of file viewport.cpp.

◆ SetPixelScale()

void ViewPort::SetPixelScale ( double  scale)

Set the physical to logical pixel ratio for the display.

On standard displays, one logical pixel equals one physical pixel, so this value is 1.0. On high-DPI/Retina displays, one logical pixel may equal multiple physical pixels:

  • MacBook Pro Retina: 2.0 (2x2 physical pixels per logical pixel)
  • Other HiDPI displays: May be 1.5, 1.75, etc.
Parameters
scaleThe ratio of physical pixels to logical pixels.

Definition at line 133 of file viewport.cpp.

◆ SetProjectionType()

void ViewPort::SetProjectionType ( int  type)
inline

Definition at line 178 of file viewport.h.

◆ SetRotationAngle()

void ViewPort::SetRotationAngle ( double  angle_rad)
inline

Definition at line 177 of file viewport.h.

◆ SetVPTransformMatrix()

void ViewPort::SetVPTransformMatrix ( )

Definition at line 984 of file viewport.cpp.

◆ Validate()

void ViewPort::Validate ( )
inline

Definition at line 174 of file viewport.h.

Member Data Documentation

◆ b_FullScreenQuilt

bool ViewPort::b_FullScreenQuilt

Definition at line 224 of file viewport.h.

◆ b_MercatorProjectionOverride

bool ViewPort::b_MercatorProjectionOverride

Definition at line 227 of file viewport.h.

◆ b_quilt

bool ViewPort::b_quilt

Definition at line 223 of file viewport.h.

◆ chart_scale

double ViewPort::chart_scale

Chart scale denominator (e.g., 50000 for a 1:50000 scale).

Definition at line 214 of file viewport.h.

◆ clat

double ViewPort::clat

Center latitude of the viewport in degrees.

Definition at line 192 of file viewport.h.

◆ clon

double ViewPort::clon

Center longitude of the viewport in degrees.

Definition at line 194 of file viewport.h.

◆ m_projection_type

int ViewPort::m_projection_type

Definition at line 226 of file viewport.h.

◆ norm_transform

float ViewPort::norm_transform[16]

Definition at line 232 of file viewport.h.

◆ pix_height

int ViewPort::pix_height

Height of the viewport in physical pixels.

Definition at line 221 of file viewport.h.

◆ pix_width

int ViewPort::pix_width

Width of the viewport in physical pixels.

Definition at line 219 of file viewport.h.

◆ ref_scale

double ViewPort::ref_scale

The nominal scale of the "reference chart" for this view.

Definition at line 216 of file viewport.h.

◆ rotation

double ViewPort::rotation

Rotation angle of the viewport in radians.

Definition at line 209 of file viewport.h.

◆ rv_rect

wxRect ViewPort::rv_rect

Definition at line 228 of file viewport.h.

◆ skew

double ViewPort::skew

Angular distortion (shear transform) applied to the viewport in radians.

The skew parameter represents a shear transformation applied to the viewport, which maintains parallel lines while changing their angles relative to the axes.

Definition at line 207 of file viewport.h.

◆ tilt

double ViewPort::tilt

Tilt angle for perspective view in radians.

Definition at line 211 of file viewport.h.

◆ view_scale_ppm

double ViewPort::view_scale_ppm

Requested view scale in physical pixels per meter (ppm), before applying projections.

Definition at line 199 of file viewport.h.

◆ vp_matrix_transform

float ViewPort::vp_matrix_transform[16]

Definition at line 231 of file viewport.h.


The documentation for this class was generated from the following files: