Skip to content

Commit

Permalink
Merge branch 'master' into myocpn
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakansv committed Jan 17, 2025
2 parents 6ca1ec6 + 60468c0 commit 8f4713e
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 110 deletions.
8 changes: 8 additions & 0 deletions gui/include/gui/ocpn_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,15 @@ class MyFrame : public wxFrame {
void ConfigureStatusBar();

private:
void ProcessUnitTest();
void ProcessQuitFlag();
void ProcessDeferredTrackOn();
void SendFixToPlugins();
void ProcessAnchorWatch();
void ProcessLogAndBells();

void CheckToolbarPosition();

void ODoSetSize(void);
void DoCOGSet(void);

Expand Down
26 changes: 18 additions & 8 deletions gui/src/chcanv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ extern int g_nAIS_activity_timer;
extern bool g_bskew_comp;
extern float g_compass_scalefactor;
extern int g_COGAvgSec; // COG average period (sec.) for Course Up Mode
extern bool g_btenhertz;

wxGLContext *g_pGLcontext; // shared common context

Expand Down Expand Up @@ -1696,7 +1697,7 @@ bool ChartCanvas::DoCanvasUpdate(void) {
GetCanvasScaleFactor() / proposed_scale_onscreen,
0, GetVPRotation());
}
if (m_bFollow) {
if (m_bFollow && g_btenhertz) {
StartTimedMovementVP(vpLat, vpLon);
} else {
bNewView |= SetViewPoint(vpLat, vpLon, GetVPScale(), 0, GetVPRotation());
Expand Down Expand Up @@ -3380,9 +3381,9 @@ bool ChartCanvas::DoCanvasCOGSet(void) {
m_VPRotate = -g_COGAvg * PI / 180.;

SetVPRotation(m_VPRotate);
bool bnew_chart = DoCanvasUpdate();
// bool bnew_chart = DoCanvasUpdate();

if ((bnew_chart) || (old_VPRotate != m_VPRotate)) ReloadVP();
// if ((bnew_chart) || (old_VPRotate != m_VPRotate)) ReloadVP();

return true;
}
Expand Down Expand Up @@ -3429,7 +3430,7 @@ bool ChartCanvas::StartTimedMovement(bool stoptimer) {

return true;
}

int stvpc;
void ChartCanvas::StartTimedMovementVP(double target_lat, double target_lon) {
// Save the target
m_target_lat = target_lat;
Expand All @@ -3441,21 +3442,30 @@ void ChartCanvas::StartTimedMovementVP(double target_lat, double target_lon) {

m_VPMovementTimer.Start(1, true); // oneshot
m_timed_move_vp_active = true;
stvpc = 0;
}
void ChartCanvas::DoTimedMovementVP() {
if (!m_timed_move_vp_active) return; // not active

// Stop condition
double one_pix = (1. / (1852 * 60)) / GetVP().view_scale_ppm;
double d2 =
pow(m_run_lat - m_target_lat, 2) + pow(m_run_lon - m_target_lon, 2);

if ((fabs(m_run_lat - m_target_lat) < one_pix) ||
(fabs(m_run_lat - m_target_lat) < one_pix)) {
if (d2 < one_pix) {
SetViewPoint(m_target_lat, m_target_lon); // Embeds a refresh
StopMovementVP();
return;
}

double new_lat = GetVP().clat + (m_target_lat - m_start_lat) / 10;
double new_lon = GetVP().clon + (m_target_lon - m_start_lon) / 10;
// if ((fabs(m_run_lat - m_target_lat) < one_pix) &&
// (fabs(m_run_lon - m_target_lon) < one_pix)) {
// StopMovementVP();
// return;
// }

double new_lat = GetVP().clat + (m_target_lat - m_start_lat) / 5;
double new_lon = GetVP().clon + (m_target_lon - m_start_lon) / 5;

m_run_lat = new_lat;
m_run_lon = new_lon;
Expand Down
Loading

0 comments on commit 8f4713e

Please sign in to comment.