OpenCPN Partial API docs
Loading...
Searching...
No Matches
navutil.h File Reference

Utility functions. More...

#include <cmath>
#include <vector>
#include <wx/colour.h>
#include <wx/config.h>
#include <wx/confbase.h>
#include <wx/datetime.h>
#include <wx/fileconf.h>
#include <wx/progdlg.h>
#include <wx/sound.h>
#include <wx/string.h>
#include "model/navutil_base.h"
#include "model/nav_object_database.h"
#include "model/select_item.h"
#include "model/route.h"
#include "model/route_point.h"
#include "model/track.h"
#include "bbox.h"
#include "canvas_config.h"
#include "chartdbs.h"
#include "ocpndc.h"
#include "vector2D.h"

Go to the source code of this file.

Classes

class  MouseZoom
 
class  MyConfig
 

Macros

#define UTCINPUT   0
 Date/time in UTC.
 
#define LTINPUT   1
 Date/time using PC local timezone.
 
#define LMTINPUT   2
 Date/time using the remote location LMT time.
 
#define GLOBAL_SETTINGS_INPUT   3
 Date/time as of global OpenCPN settings.
 

Functions

bool LogMessageOnce (const wxString &msg)
 
double fromUsrSpeed (double usr_speed, int unit=-1)
 
double fromUsrWindSpeed (double usr_wspeed, int unit=-1)
 
double fromUsrTemp (double usr_temp, int unit=-1)
 
wxString getUsrTempUnit ()
 
wxString formatAngle (double angle)
 
wxString GetLayerName (int id)
 
void navutil::InitGlobals ()
 
void navutil::DeinitGlobals ()
 
wxDateTime toUsrDateTime (const wxDateTime ts, const int format, const double lon=INFINITY - INFINITY)
 Converts a timestamp from UTC to the user's preferred time format.
 
wxDateTime fromUsrDateTime (const wxDateTime ts, const int format, const double lon=INFINITY - INFINITY)
 Converts a timestamp from a user's preferred time format to UTC.
 
void AlphaBlending (ocpnDC &dc, int x, int y, int size_x, int size_y, float radius, wxColour color, unsigned char transparency)
 
void DimeControl (wxWindow *ctrl)
 
void DimeControl (wxWindow *ctrl, wxColour col, wxColour col1, wxColour back_color, wxColour text_color, wxColour uitext, wxColour udkrd, wxColour gridline)
 
bool WptIsInRouteList (RoutePoint *pr)
 
RoutePointWaypointExists (const wxString &name, double lat, double lon)
 
RoutePointWaypointExists (const wxString &guid)
 
RouteRouteExists (const wxString &guid)
 
RouteRouteExists (Route *pTentRoute)
 
TrackTrackExists (const wxString &guid)
 
int BackupDatabase (wxWindow *parent)
 
void ExportGPX (wxWindow *parent, bool bviz_only=false, bool blayer=false)
 
void UI_ImportGPX (wxWindow *parent, bool islayer=false, wxString dirpath="", bool isdirectory=true, bool isPersistent=false)
 
bool ExportGPXRoutes (wxWindow *parent, RouteList *pRoutes, const wxString suggestedName="routes")
 
bool ExportGPXTracks (wxWindow *parent, std::vector< Track * > *pRoutes, const wxString suggestedName="tracks")
 
bool ExportGPXWaypoints (wxWindow *parent, RoutePointList *pRoutePoints, const wxString suggestedName="waypoints")
 
void ImportFileArray (const wxArrayString &file_array, bool islayer, bool isPersistent, wxString dirpath)
 
void SwitchInlandEcdisMode (bool Switch)
 

Variables

MyConfigpConfig
 Global instance.
 

Detailed Description

Utility functions.

Definition in file navutil.h.

Macro Definition Documentation

◆ GLOBAL_SETTINGS_INPUT

#define GLOBAL_SETTINGS_INPUT   3

Date/time as of global OpenCPN settings.

Definition at line 61 of file navutil.h.

◆ LMTINPUT

#define LMTINPUT   2

Date/time using the remote location LMT time.

Definition at line 60 of file navutil.h.

◆ LTINPUT

#define LTINPUT   1

Date/time using PC local timezone.

Definition at line 59 of file navutil.h.

◆ UTCINPUT

#define UTCINPUT   0

Date/time in UTC.

Definition at line 58 of file navutil.h.

Function Documentation

◆ AlphaBlending()

void AlphaBlending ( ocpnDC dc,
int  x,
int  y,
int  size_x,
int  size_y,
float  radius,
wxColour  color,
unsigned char  transparency 
)
extern

Definition at line 3026 of file navutil.cpp.

◆ BackupDatabase()

int BackupDatabase ( wxWindow *  parent)

Definition at line 2400 of file navutil.cpp.

◆ DeinitGlobals()

void navutil::DeinitGlobals ( )

Definition at line 128 of file navutil.cpp.

◆ DimeControl() [1/2]

void DimeControl ( wxWindow *  ctrl)

Definition at line 3103 of file navutil.cpp.

◆ DimeControl() [2/2]

void DimeControl ( wxWindow *  ctrl,
wxColour  col,
wxColour  col1,
wxColour  back_color,
wxColour  text_color,
wxColour  uitext,
wxColour  udkrd,
wxColour  gridline 
)

Definition at line 3140 of file navutil.cpp.

◆ ExportGPX()

void ExportGPX ( wxWindow *  parent,
bool  bviz_only = false,
bool  blayer = false 
)

Definition at line 2546 of file navutil.cpp.

◆ ExportGPXRoutes()

bool ExportGPXRoutes ( wxWindow *  parent,
RouteList *  pRoutes,
const wxString  suggestedName = "routes" 
)

Definition at line 2436 of file navutil.cpp.

◆ ExportGPXTracks()

bool ExportGPXTracks ( wxWindow *  parent,
std::vector< Track * > *  pRoutes,
const wxString  suggestedName = "tracks" 
)

Definition at line 2473 of file navutil.cpp.

◆ ExportGPXWaypoints()

bool ExportGPXWaypoints ( wxWindow *  parent,
RoutePointList *  pRoutePoints,
const wxString  suggestedName = "waypoints" 
)

Definition at line 2509 of file navutil.cpp.

◆ formatAngle()

wxString formatAngle ( double  angle)

Definition at line 3012 of file navutil.cpp.

◆ fromUsrDateTime()

wxDateTime fromUsrDateTime ( const wxDateTime  ts,
const int  format,
const double  lon = INFINITY - INFINITY 
)

Converts a timestamp from a user's preferred time format to UTC.

This function is the inverse of toUsrDateTime, transforming a timestamp from the specified format back to UTC. It handles Universal Time (UTC), Local Mean Time (LMT) based on longitude, and Local time based on the user's system timezone.

Parameters
tsThe input timestamp in the specified format.
formatThe input timestamp format: 0 = UTC, 1 = Local@PC, 2 = LMT@Location, 3 = Global settings.
lonThe longitude for LMT calculation. Default is NaN.
Returns
wxDateTime The converted timestamp in UTC.

Definition at line 2909 of file navutil.cpp.

◆ fromUsrSpeed()

double fromUsrSpeed ( double  usr_speed,
int  unit = -1 
)

Definition at line 2950 of file navutil.cpp.

◆ fromUsrTemp()

double fromUsrTemp ( double  usr_temp,
int  unit = -1 
)

Definition at line 2995 of file navutil.cpp.

◆ fromUsrWindSpeed()

double fromUsrWindSpeed ( double  usr_wspeed,
int  unit = -1 
)

Definition at line 2972 of file navutil.cpp.

◆ GetLayerName()

wxString GetLayerName ( int  id)

Definition at line 137 of file navutil.cpp.

◆ ImportFileArray()

void ImportFileArray ( const wxArrayString &  file_array,
bool  islayer,
bool  isPersistent,
wxString  dirpath 
)

Definition at line 2699 of file navutil.cpp.

◆ InitGlobals()

void navutil::InitGlobals ( )

Definition at line 126 of file navutil.cpp.

◆ LogMessageOnce()

bool LogMessageOnce ( const wxString &  msg)

Definition at line 2850 of file navutil.cpp.

◆ RouteExists() [1/2]

Route * RouteExists ( const wxString &  guid)

Definition at line 1562 of file nav_object_database.cpp.

◆ RouteExists() [2/2]

Route * RouteExists ( Route pTentRoute)

Definition at line 1569 of file nav_object_database.cpp.

◆ SwitchInlandEcdisMode()

void SwitchInlandEcdisMode ( bool  Switch)

Definition at line 2800 of file navutil.cpp.

◆ toUsrDateTime()

wxDateTime toUsrDateTime ( const wxDateTime  ts,
const int  format,
const double  lon = INFINITY - INFINITY 
)

Converts a timestamp from UTC to the user's preferred time format.

This function transforms a timestamp based on the specified format or the global application setting. It supports Universal Time (UTC), Local Mean Time (LMT) based on longitude, and Local time based on the user's system timezone.

Parameters
tsThe timestamp to convert, must be in UTC.
formatThe desired output format: 0 = UTC, 1 = Local@PC, 2 = LMT@Location, 3 = Global settings.
lonThe longitude in degrees for LMT calculation (positive for east, negative for west). Default is NaN.
Returns
wxDateTime The converted timestamp in the specified format, or wxInvalidDateTime if conversion fails.

Definition at line 2869 of file navutil.cpp.

◆ TrackExists()

Track * TrackExists ( const wxString &  guid)

Definition at line 1576 of file nav_object_database.cpp.

◆ UI_ImportGPX()

void UI_ImportGPX ( wxWindow *  parent,
bool  islayer = false,
wxString  dirpath = "",
bool  isdirectory = true,
bool  isPersistent = false 
)

Definition at line 2631 of file navutil.cpp.

◆ WaypointExists() [1/2]

RoutePoint * WaypointExists ( const wxString &  guid)

Definition at line 1538 of file nav_object_database.cpp.

◆ WaypointExists() [2/2]

RoutePoint * WaypointExists ( const wxString &  name,
double  lat,
double  lon 
)

Definition at line 1523 of file nav_object_database.cpp.

◆ WptIsInRouteList()

bool WptIsInRouteList ( RoutePoint pr)

Definition at line 1547 of file nav_object_database.cpp.

Variable Documentation

◆ pConfig

MyConfig* pConfig
extern

Global instance.

Definition at line 110 of file navutil.cpp.