OpenCPN Partial API docs
Loading...
Searching...
No Matches
connection_edit.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2022 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 ***************************************************************************/
17
24#ifndef COnnect_EDIT_H
25#define COnnect_EDIT_H
26
27#include <functional>
28
29#include <wx/checkbox.h>
30#include <wx/listctrl.h>
31#include <wx/radiobut.h>
32#include <wx/stattext.h>
33#include <wx/timer.h>
34
35#include "observable/observable.h"
36
37#include "model/conn_params.h"
38
39#include "expand_icon.h"
40#include "options.h"
41#include "conn_params_panel.h"
42
47class ConnectionEditDialog : public wxPanel {
48public:
49 const std::string kDefaultTcpPort = "10110";
50 const std::string kDefaultUdpPort = "10110";
51 const std::string kDefaultGpsdPort = "2947";
52 const std::string kDefaultSignalkPort = "3000";
53 const std::string kDefaultIpAddress = "localhost";
54 const std::string kDefaultMulticastAddr = "224.0.2.21";
55 // "LIMITED BROADCAST" address
56 // Deprecated, but still useful on simple mobile networks.
57 const wxString DEFAULT_UDP_OUT_ADDRESS = "255.255.255.255";
58
61 wxWindow* parent,
62 std::function<void(ConnectionParams* p, bool editing, bool ok_cancel)>
63 on_edit_click);
64
65 ~ConnectionEditDialog() override;
66 void SetPropsLabel(const wxString& label);
67 void SetDefaultConnectionParams();
68 void SetNewMode(bool mode) { m_new_mode = mode; }
69 void AddOKCancelButtons();
70
73 void PreloadControls(ConnectionParams* cp);
74 void InitiateNewConnection();
75
78
81
82private:
83#ifdef __ANDROID__
84 wxPanel* m_scroll_win_connections;
85#else
86 wxScrolledWindow* m_scroll_win_connections;
87#endif
88 std::function<void(ConnectionParams*, bool, bool)> m_on_edit_click;
89 ConnectionParams* m_selected_conn_params;
90 ConnectionParams* m_cp_original;
91 obs::Listener m_new_device_listener;
92
93 bool m_is_conn_saved;
94 bool m_is_editing;
95 bool m_is_nmea_params_shown;
96 bool m_new_mode;
97 bool m_advanced = false;
98 bool m_conn_enabled;
99
100 wxRadioButton* m_accept_radiobtn;
101 wxButton* m_add_btn;
102 wxCheckBox* m_advanced_chkbox;
103 wxCheckBox* m_aps_magnetic_chkbox;
104 wxTextCtrl* m_auth_token_tctrl;
105 wxStaticText* m_auth_token_text;
106 wxChoice* m_baud_rate_choice;
107 wxChoice* m_bt_data_sources_choice;
108 int m_bt_last_result_count;
109 int m_bt_no_change_counter;
110 wxStaticText* m_bt_pairs_text;
111 int m_bt_scanning;
112 wxArrayString m_bt_scan_results;
113 wxTimer m_bt_scan_timer;
114 wxGridSizer* m_can_props_sizer;
115 wxChoice* m_can_source_choice;
116 wxArrayString m_can_source_choice2;
117 wxStaticText* m_can_source_text;
118 wxSizer* m_collapse_box;
119 wxStaticBoxSizer* m_connection_props_sizer;
120 wxBoxSizer* m_connections_sizer;
121 wxStaticBox* m_conn_edit_statbox;
122 wxButton* m_dlg_buttons_apply_btn;
123 wxButton* m_dlg_buttons_cancel_btn;
124 wxButton* m_dlg_buttons_ok_btn;
125 wxButton* m_dlg_cancel_btn;
126 wxButton* m_dlg_ok_btn;
127 wxCheckBox* m_filter_cog_sog_chkbox;
128 wxTextCtrl* m_filter_sec_tctrl;
129 wxStaticText* m_filter_sec_text;
130 wxCheckBox* m_furuno_gp3x_chkbox;
131 wxCheckBox* m_garmin_host_chkbox;
132 wxCheckBox* m_garmin_upload_host_chkbox;
133 wxRadioButton* m_ignore_radiobtn;
134 wxStaticBoxSizer* m_in_filter_sizer;
135 wxCheckBox* m_input_chkbox;
136 wxButton* m_input_stc_list_btn;
137 wxTextCtrl* m_input_stc_tctrl;
138 wxTextCtrl* m_net_address_tctrl;
139 wxStaticText* m_net_addr_text;
140 wxTextCtrl* m_net_comment_tctrl;
141 wxStaticText* m_net_comment_text;
142 wxChoice* m_net_data_protocol_choice;
143 wxStaticText* m_net_data_protocol_text;
144 wxStaticText* m_net_expert_box_text;
145 wxCheckBox* m_net_expert_chkbox;
146 wxTextCtrl* m_net_port_tctrl;
147 wxStaticText* m_net_port_text;
148 wxGridSizer* m_net_props_sizer;
149 wxChoice* m_net_view_choice;
150 wxStaticText* m_net_type_choice_text;
151 wxRadioButton* m_o_accept_radiobtn;
152 wxRadioButton* m_o_ignore_radiobtn;
153 wxStaticBoxSizer* m_out_filter_sizer;
154 wxCheckBox* m_output_chkbox;
155 wxButton* m_output_stc_list_btn;
156 wxTextCtrl* m_output_stc_tctrl;
157 wxWindow* m_parent;
158 wxComboBox* m_port_combo;
159 wxChoice* m_precision_choice;
160 wxStaticText* m_precision_text;
161 wxChoice* m_priority_choice;
162 wxButton* m_priority_dialog_btn;
163 wxButton* m_remove_btn;
164 wxButton* m_scan_bt_btn;
165 wxStaticText* m_ser_baudrate_text;
166 wxStaticText* m_ser_comment_text;
167 wxTextCtrl* m_serial_comment_tctrl;
168 wxChoice* m_serial_protocol_choice;
169 wxStaticText* m_ser_port_text;
170 wxGridSizer* m_ser_props_sizer;
171 wxStaticText* m_ser_protocol_text;
172 wxBoxSizer* m_sizer_box_btn;
173 wxCheckBox* m_sk_check_discover_chkbox;
174 wxButton* m_sk_discover_btn;
175 wxStaticText* m_sk_server_status_text;
176 wxStdDialogButtonSizer* m_std_dialog_btn_sizer;
177 wxStaticText* m_talker_id_text;
178 wxRadioButton* m_type_can_radiobtn;
179 wxRadioButton* m_type_internal_bt_radiobtn;
180 wxRadioButton* m_type_internal_gps_radiobtn;
181 wxRadioButton* m_type_net_radiobtn;
182 wxRadioButton* m_type_serial_radiobtn;
183
184 ConnectionParams* UpdateConnectionParamsFromControls(ConnectionParams* cp);
185
186 void ClearNMEAForm();
187 void ConfigureControlsForView(const std::string& view);
188 void ConnectControls();
189 void EnableConnection(ConnectionParams* conn, bool value);
190 void Init();
191 void LayoutDialog();
192 void OnAddressChange(wxFocusEvent& ev);
193 void OnExpertModeChange();
194 void OnBaudrateChoice(wxCommandEvent& event) { OnConnValChange(event); }
195 void OnBtnIStcs(wxCommandEvent& event);
196 void OnBtnOStcs(wxCommandEvent& event);
197 void OnBtScanTimer(wxTimerEvent& event);
198 void OnCancelClick();
199 void OnCbAdvanced(wxCommandEvent& event);
200 void OnCbInput(wxCommandEvent& event);
201 void OnCbOutput(wxCommandEvent& event);
202 void OnCollapsedToggle(bool collapsed);
203 void OnConnValChange(wxCommandEvent& event);
204 void OnDiscoverButton(wxCommandEvent& event);
205 void OnNetProtocolSelected(wxCommandEvent& event);
206 void OnOKClick();
207 void OnPriorityDialog(wxCommandEvent& event);
208 void OnProtocolChoice(wxCommandEvent& event);
209 void OnRbAcceptInput(wxCommandEvent& event);
210 void OnRbIgnoreInput(wxCommandEvent& event);
211 void OnRbOutput(wxCommandEvent& event);
212 void OnScanBtClick(wxCommandEvent& event);
213 void OnSelectDatasource(wxListEvent& event);
214 void OnTypeBTSelected(wxCommandEvent& event);
215 void OnTypeCANSelected(wxCommandEvent& event);
216 void OnTypeGPSSelected(wxCommandEvent& event);
217 void OnTypeNetSelected(wxCommandEvent& event);
218 void OnTypeSerialSelected(wxCommandEvent& event);
219 void OnUploadFormatChange(wxCommandEvent& event);
220 void OnValChange(wxCommandEvent& event);
221 void SetConnectionParams(ConnectionParams* cp);
222 void SetDSFormOptionVizStates();
223 void SetDSFormRWStates();
224 void SetInitialSettings();
225 void SetNMEAFormForNetProtocol();
226 void SetNMEAFormForSerialProtocol();
227 void SetNMEAFormToBT();
228 void SetNMEAFormToCAN();
229 void SetNMEAFormToGPS();
230 void SetNMEAFormToNet();
231 void SetNMEAFormToSerial();
232 void SetSelectedConnectionPanel(ConnectionParamsPanel* panel);
233 void ShowInFilter(bool bshow = true);
234 void ShowNMEABT(bool visible);
235 void ShowNMEACAN(bool visible);
236 void ShowNMEACommon(bool visible);
237 void ShowNMEAGPS(bool visible);
238 void ShowNMEANet(bool visible);
239 void ShowNMEASerial(bool visible);
240 void ShowOutFilter(bool bshow = true);
241 void ShowTypeCommon(bool visible = true);
242 void StopBtScan();
243 void UpdateDiscoverStatus(const wxString& stat);
244 void UpdateSourceList(bool bResort);
245};
246
247class SentenceListDlg : public wxDialog {
248public:
249 explicit SentenceListDlg(wxWindow* parent, FilterDirection dir, ListType type,
250 const wxArrayString& list);
251 wxString GetSentences();
252
253private:
254 void OnAddClick(wxCommandEvent& event);
255 void OnDeleteClick(wxCommandEvent& event);
256 void OnCLBSelect(wxCommandEvent& event);
257 void OnCheckAllClick(wxCommandEvent& event);
258 void OnClearAllClick(wxCommandEvent& event);
259
260 void Populate(const wxArrayString& list);
261 [[nodiscard]] wxString GetBoxLabel() const;
262
263 wxCheckListBox* m_sentences_clb;
264 wxButton* m_del_btn;
265
266 ListType m_type;
267 FilterDirection m_dir;
268 wxArrayString m_sentences;
269};
270
271#endif // COnnect_EDIT_H
Dialog for editing connection parameters.
void OnConnectionTypeChange()
Initiate a network connection view with new data.
void RefreshAdvancedDetails()
Refresh visible states in a network connection view.
ConnectionParams * GetParamsFromControls()
Return parameters instance populated from UI elements owned by caller.
Panel for displaying and editing connection parameters.
Connection parameters.
Panel for editing a connection.
Options dialog.