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 Dec 29, 2024
2 parents 3180bea + 44774be commit ee6218d
Show file tree
Hide file tree
Showing 104 changed files with 1,941 additions and 1,032 deletions.
16 changes: 5 additions & 11 deletions android/androidUTIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ extern int g_chart_zoom_modifier_raster;
extern int g_NMEAAPBPrecision;

extern wxString *pInit_Chart_Dir;
extern bool g_bfilter_cogsog;
extern int g_COGFilterSec;
extern int g_SOGFilterSec;

extern bool g_bDisplayGrid;

Expand Down Expand Up @@ -3106,8 +3103,7 @@ wxString BuildAndroidSettingsString(void) {
// Connections

// Internal GPS.
for (size_t i = 0; i < TheConnectionParams()->Count(); i++) {
ConnectionParams *cp = TheConnectionParams()->Item(i);
for (auto &cp : TheConnectionParams()) {
if (INTERNAL_GPS == cp->Type) {
result += _T("prefb_internalGPS:");
result += cp->bEnabled ? _T("1;") : _T("0;");
Expand Down Expand Up @@ -3358,8 +3354,7 @@ int androidApplySettingsString(wxString settings, ArrayOfCDI *pACDI) {
ConnectionParams *pExistingParams = NULL;
ConnectionParams *cp = NULL;

for (size_t i = 0; i < TheConnectionParams()->Count(); i++) {
ConnectionParams *xcp = TheConnectionParams()->Item(i);
for (auto &xcp : TheConnectionParams()) {
if (INTERNAL_GPS == xcp->Type) {
pExistingParams = xcp;
cp = xcp;
Expand All @@ -3379,7 +3374,7 @@ int androidApplySettingsString(wxString settings, ArrayOfCDI *pACDI) {
ConnectionParams *new_params = new ConnectionParams(sGPS);

new_params->bEnabled = benable_InternalGPS;
TheConnectionParams()->Add(new_params);
TheConnectionParams().push_back(new_params);
cp = new_params;
}

Expand Down Expand Up @@ -3451,8 +3446,7 @@ int androidApplySettingsString(wxString settings, ArrayOfCDI *pACDI) {

wxString target = AUSBNames[i] + _T("-") + extraString;

for (unsigned int j = 0; j < TheConnectionParams()->Count(); j++) {
ConnectionParams *xcp = TheConnectionParams()->Item(j);
for (auto &xcp : TheConnectionParams()) {
wxLogMessage(_T(" Checking: ") + target + " .. " +
xcp->GetDSPort());

Expand Down Expand Up @@ -3488,7 +3482,7 @@ int androidApplySettingsString(wxString settings, ArrayOfCDI *pACDI) {
ConnectionParams *new_params = new ConnectionParams(sSerial);

new_params->bEnabled = true;
TheConnectionParams()->Add(new_params);
TheConnectionParams().push_back(new_params);
cp = new_params;
rr |= NEED_NEW_OPTIONS;
}
Expand Down
2 changes: 0 additions & 2 deletions gui/include/gui/conn_params_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

#include "model/conn_params.h"

class options;

/**
* Panel for displaying and editing connection parameters. Shows the details of
* a specific connection and allows for enabling/disabling and editing of the
Expand Down
18 changes: 8 additions & 10 deletions gui/include/gui/connection_edit.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
/******************************************************************************
*
* Project: OpenCPN
* Purpose:
* Author: David Register
*
***************************************************************************
/**************************************************************************
* Copyright (C) 2022 by David S. Register *
* *
* This program is free software; you can redistribute it and/or modify *
Expand All @@ -24,6 +18,11 @@
***************************************************************************
*/

/**
* \file
* Dialog and support code for editing a connection
*/

#ifndef _CONNECT_EDIT_H
#define _CONNECT_EDIT_H

Expand Down Expand Up @@ -57,8 +56,7 @@ class ConnectionEditDialog : public wxDialog {
const wxString DEFAULT_UDP_OUT_ADDRESS = "255.255.255.255";

ConnectionEditDialog();
// ConnectionEditDialog(wxScrolledWindow *container, options *parent);
ConnectionEditDialog(options *parent, ConnectionsDialog *client);
ConnectionEditDialog(wxWindow *parent);

~ConnectionEditDialog();

Expand Down Expand Up @@ -149,7 +147,7 @@ class ConnectionEditDialog : public wxDialog {
void ConnectControls();

// private:
options *m_parent;
wxWindow *m_parent;
wxScrolledWindow *m_scrolledwin;

wxGridSizer *gSizerNetProps, *gSizerSerProps, *gSizerCanProps;
Expand Down
3 changes: 0 additions & 3 deletions gui/src/ConfigMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ extern wxString g_config_version_string;

extern bool g_bDebugGPSD;

extern bool g_bfilter_cogsog;
extern int g_COGFilterSec;

extern int g_navobjbackups;

extern bool g_bQuiltEnable;
Expand Down
2 changes: 1 addition & 1 deletion gui/src/OCPNPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,7 @@ void OCPNPlatform::SetDefaultOptions(void) {
ConnectionParams *new_params = new ConnectionParams(sGPS);

new_params->bEnabled = true;
TheConnectionParams()->Add(new_params);
TheConnectionParams().push_back(new_params);

g_default_font_facename = _T("Roboto");

Expand Down
3 changes: 1 addition & 2 deletions gui/src/SendToGpsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ void SendToGpsDlg::CreateControls(const wxString& hint) {

// Add any defined Network connections supporting "output"
wxArrayString netconns;
for (size_t i = 0; i < TheConnectionParams()->Count(); i++) {
ConnectionParams* cp = TheConnectionParams()->Item(i);
for (auto* cp : TheConnectionParams()) {
wxString netident;

if ((cp->IOSelect != DS_TYPE_INPUT) && cp->Type == NETWORK &&
Expand Down
5 changes: 2 additions & 3 deletions gui/src/chcanv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12941,11 +12941,10 @@ wxString ChartCanvas::FindValidUploadPort() {
port = g_uploadConnection;
}

else if (TheConnectionParams()) {
else {
// If there is no persistent upload port recorded (yet)
// then use the first available serial connection which has output defined.
for (size_t i = 0; i < TheConnectionParams()->Count(); i++) {
ConnectionParams *cp = TheConnectionParams()->Item(i);
for (auto *cp : TheConnectionParams()) {
if ((cp->IOSelect != DS_TYPE_INPUT) && cp->Type == SERIAL)
port << _T("Serial:") << cp->Port;
}
Expand Down
30 changes: 12 additions & 18 deletions gui/src/connection_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@
#include "priority_gui.h"
#include "udev_rule_mgr.h"

extern bool g_bfilter_cogsog;
extern int g_COGFilterSec;
extern int g_SOGFilterSec;

extern OCPNPlatform* g_Platform;

static wxString StringArrayToString(const wxArrayString& arr) {
Expand Down Expand Up @@ -182,8 +178,7 @@ static void LoadSerialPorts(wxComboBox* box) {
// Define constructors
ConnectionEditDialog::ConnectionEditDialog() {}

ConnectionEditDialog::ConnectionEditDialog(options* parent,
ConnectionsDialog* client)
ConnectionEditDialog::ConnectionEditDialog(wxWindow* parent)
: wxDialog(parent, wxID_ANY, _("Connection Edit"), wxDefaultPosition,
wxSize(280, 420)) {
m_parent = parent;
Expand Down Expand Up @@ -1568,18 +1563,19 @@ void ConnectionEditDialog::SetDefaultConnectionParams(void) {
}

bool ConnectionEditDialog::SortSourceList(void) {
if (TheConnectionParams()->Count() < 2) return false;
if (TheConnectionParams().size() < 2) return false;

std::vector<int> ivec;
for (size_t i = 0; i < TheConnectionParams()->Count(); i++) ivec.push_back(i);
for (size_t i = 0; i < TheConnectionParams().size(); i++) ivec.push_back(i);

// FIXME (leamas) : This is not the way to sort a vector.
bool did_sort = false;
bool did_swap = true;
while (did_swap) {
did_swap = false;
for (size_t j = 1; j < ivec.size(); j++) {
ConnectionParams* c1 = TheConnectionParams()->Item(ivec[j]);
ConnectionParams* c2 = TheConnectionParams()->Item(ivec[j - 1]);
ConnectionParams* c1 = TheConnectionParams()[ivec[j]];
ConnectionParams* c2 = TheConnectionParams()[ivec[j - 1]];

if (c1->Priority > c2->Priority) {
int t = ivec[j - 1];
Expand All @@ -1598,7 +1594,7 @@ bool ConnectionEditDialog::SortSourceList(void) {

for (size_t i = 0; i < ivec.size(); i++) {
ConnectionParamsPanel* pPanel =
TheConnectionParams()->Item(ivec[i])->m_optionsPanel;
TheConnectionParams()[ivec[i]]->m_optionsPanel;
boxSizerConnections->Add(pPanel, 0, wxEXPAND | wxALL, 0);
}
}
Expand All @@ -1615,10 +1611,9 @@ void ConnectionEditDialog::LayoutDialog() {
}

void ConnectionEditDialog::UpdateSourceList(bool bResort) {
for (size_t i = 0; i < TheConnectionParams()->Count(); i++) {
ConnectionParams* cp = TheConnectionParams()->Item(i);
for (auto* cp : TheConnectionParams()) {
ConnectionParamsPanel* panel = cp->m_optionsPanel;
if (panel) panel->Update(TheConnectionParams()->Item(i));
if (panel) panel->Update(cp);
}

if (bResort) {
Expand All @@ -1629,7 +1624,7 @@ void ConnectionEditDialog::UpdateSourceList(bool bResort) {
}

void ConnectionEditDialog::OnSelectDatasource(wxListEvent& event) {
SetConnectionParams(TheConnectionParams()->Item(event.GetData()));
SetConnectionParams(TheConnectionParams()[event.GetData()]);
m_buttonRemove->Enable();
m_buttonRemove->Show();
event.Skip();
Expand Down Expand Up @@ -1754,8 +1749,7 @@ void ConnectionEditDialog::OnCbOutput(wxCommandEvent& event) {
DEFAULT_UDP_OUT_ADDRESS); // IP address for output
// Check for an UDP input connection on the same port
NetworkProtocol proto = UDP;
for (size_t i = 0; i < TheConnectionParams()->Count(); i++) {
ConnectionParams* cp = TheConnectionParams()->Item(i);
for (auto* cp : TheConnectionParams()) {
if (cp->NetProtocol == proto &&
cp->NetworkPort == wxAtoi(m_tNetPort->GetValue()) &&
cp->IOSelect == DS_TYPE_INPUT) {
Expand Down Expand Up @@ -1847,7 +1841,7 @@ void ConnectionEditDialog::OnShowGpsWindowCheckboxClick(wxCommandEvent& event) {
if (!m_cbNMEADebug->GetValue()) {
NMEALogWindow::GetInstance().DestroyWindow();
} else {
NMEALogWindow::GetInstance().Create((wxWindow*)(m_parent->pParent), 35);
NMEALogWindow::GetInstance().Create((wxWindow*)(m_parent->GetParent()), 35);

// Try to ensure that the log window is a least a little bit visible
wxRect logRect(NMEALogWindow::GetInstance().GetPosX(),
Expand Down
Loading

0 comments on commit ee6218d

Please sign in to comment.