Skip to content

Commit 41b2c79

Browse files
author
RooieDirk
committed
prepare for alpha release
1 parent d052cad commit 41b2c79

File tree

8 files changed

+148
-103
lines changed

8 files changed

+148
-103
lines changed

Help page.odt

181 Bytes
Binary file not shown.

src/SharedStuff.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Meassurement::Meassurement ()
3333
lon=181.0;
3434
methode=0;
3535
enabled=true;
36+
MeassurementRemarks=wxEmptyString;
3637
}
3738

3839
Meassurement::~Meassurement ()
@@ -74,14 +75,15 @@ ship_data::~ship_data()
7475

7576
double SolarAzimuth( wxDateTime dt, double latitude, double longitude)
7677
{
78+
//dt.MakeUTC();
7779
spa_data spa; //declare the SPA structure
7880
int result;
7981
//float min, sec;
8082

8183
//enter required input values into SPA structure
8284

83-
spa.year = dt.GetHour(0);
84-
spa.month = dt.GetMonth(0);
85+
spa.year = dt.GetYear();
86+
spa.month = dt.GetMonth(0)+1; //GetMonth returns 0-11
8587
spa.day = dt.GetDay(0);
8688
spa.hour = dt.GetHour(0);
8789
spa.minute = dt.GetMinute(0);
@@ -100,15 +102,12 @@ double SolarAzimuth( wxDateTime dt, double latitude, double longitude)
100102
spa.function = SPA_ZA; //calculate zenith and azimuth
101103

102104
//call the SPA calculate function and pass the SPA structure
103-
104105
result = spa_calculate(&spa);
105106

106107
if (result == 0) //check for SPA errors
107108
{
108109
return spa.azimuth;
109-
//display the results inside the SPA structure
110-
111-
110+
//display the results inside the SPA structure
112111
} else printf("SPA Error Code: %d\n", result);
113112

114113
return 0;

src/SharedStuff.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class Meassurement : public wxObject
4949
double lon;
5050
int methode;
5151
bool enabled;
52+
wxString MeassurementRemarks;
5253
compass_data* c_data;
5354
wxString Choise1 = _("Relative bearing (Righthand bearing)");
5455
wxString Choise2 = _("Bearing using \'Navigate to\'");

src/bearingdlg.cpp

Lines changed: 72 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ const long BearingDlg::ID_STATICTEXT9 = wxNewId();
4848
const long BearingDlg::ID_STATICTEXT10 = wxNewId();
4949
const long BearingDlg::ID_STATICTEXT11 = wxNewId();
5050
const long BearingDlg::ID_VARCTRL = wxNewId();
51+
const long BearingDlg::ID_REMARKSCTRL = wxNewId();
5152
//*)
5253

5354
BearingDlg::BearingDlg(wxWindow* parent, Meassurement* Mess, wxWindowID id,const wxPoint& pos,const wxSize& size, bool fullsize )
5455
{
5556
//(*Initialize(BearingDlg)
5657
localMesData = Mess;
57-
58+
Remarks_value = wxEmptyString;
5859
wxFlexGridSizer* FlexGridSizer1;
5960
wxGridBagSizer* GridBagSizer1;
6061
wxStdDialogButtonSizer* StdDialogButtonSizer1;
@@ -65,14 +66,14 @@ BearingDlg::BearingDlg(wxWindow* parent, Meassurement* Mess, wxWindowID id,const
6566
Move(wxDefaultPosition);
6667
FlexGridSizer1 = new wxFlexGridSizer(3, 1, 0, 0);
6768
StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Methode"));
68-
Choice = new wxChoice(this, ID_CHOICE, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE"));
69-
Choice->SetSelection( Choice->Append(_("Bearing")) );
70-
//Choice->Append(_("Relative bearing (Righthand bearing)"));
71-
Choice->Append(_("Bearing using \'Navigate to\'"));
72-
//Choice->Append(_("Steaming into \'Navigate to\'"));
73-
Choice->Append(_("Steaming into"));// leading line"));
74-
Choice->Append(_("Sun bearing"));
75-
Choice->Append(_("Sun bearing shadowline"));
69+
wxArrayString aS;
70+
aS.Insert(_("Bearing"), devBEARING);
71+
aS.Insert(_("Sun bearing"), devSUN_BEARING);
72+
aS.Insert(_("Sun bearing shadowline"), devSUN_SHADOW);
73+
//aS.Insert(_("Bearing from Route"), devBEARING_FROM_ROUTE);
74+
75+
Choice = new wxChoice (this, ID_CHOICE, wxDefaultPosition, wxDefaultSize, aS, 0, wxDefaultValidator, _T("ID_CHOICE"));
76+
Choice->SetSelection( devBEARING );
7677
StaticBoxSizer1->Add(Choice, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
7778
FlexGridSizer1->Add(StaticBoxSizer1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
7879
GridBagSizer1 = new wxGridBagSizer(0, 0);
@@ -84,10 +85,13 @@ BearingDlg::BearingDlg(wxWindow* parent, Meassurement* Mess, wxWindowID id,const
8485
GridBagSizer1->Add(DPickerCtrl, wxGBPosition(0, 1), wxDefaultSpan, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
8586
TPickerCtrl = new wxTimePickerCtrl(this, ID_TIMEPICKERCTRL, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxTP_DEFAULT, wxDefaultValidator, _T("ID_TIMEPICKERCTRL"));
8687
GridBagSizer1->Add(TPickerCtrl, wxGBPosition(0, 2), wxDefaultSpan, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
87-
88-
BearingChoice = new wxChoice(this, ID_CHOICE, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_STATICTEXT2"));
89-
BearingChoice->Append(_("Compass bearing"));
90-
BearingChoice->Append(_("Righthand bearing"));
88+
wxArrayString aSb;
89+
aSb.Insert(_("Compass bearing"), devCOMPASBEARING);
90+
aSb.Insert(_("Righthand bearing"), devRIGHTHANDBEARING);
91+
BearingChoice = new wxChoice (this, ID_CHOICE, wxDefaultPosition, wxDefaultSize, aSb, 0, wxDefaultValidator, _T("ID_CHOICE"));
92+
BearingChoice->SetSelection( 0);
93+
GridBagSizer1->Add(BearingChoice, wxGBPosition(2, 0), wxDefaultSpan, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
94+
9195
StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Compass Course"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
9296
GridBagSizer1->Add(StaticText2, wxGBPosition(1, 0), wxDefaultSpan, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
9397
// Allow floating point numbers from 0 to 360 with 1 decimal
@@ -135,19 +139,18 @@ BearingDlg::BearingDlg(wxWindow* parent, Meassurement* Mess, wxWindowID id,const
135139
StaticText6 = new wxStaticText(this, ID_STATICTEXT6, _("True Bearing"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
136140
GridBagSizer1->Add(StaticText6, wxGBPosition(3, 0), wxDefaultSpan, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
137141

138-
BearingChoice = new wxChoice(this, ID_STATICTEXT4, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_STATICTEXT4"));
139-
BearingChoice->Append(_("Compass bearing"));
140-
BearingChoice->Append(_("Righthand bearing"));
141-
BearingChoice->SetSelection( 0);
142+
StaticText12 = new wxStaticText(this, ID_STATICTEXT6, _("Remarks"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
143+
GridBagSizer1->Add(StaticText12, wxGBPosition(6, 0), wxDefaultSpan, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
144+
145+
RemarksCtr = new wxTextCtrl(this, ID_REMARKSCTRL, _("Text"), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE, wxTextValidator(wxFILTER_ALPHA, &Remarks_value), _T("ID_REMARKSCTRL"));
146+
GridBagSizer1->Add(RemarksCtr, wxGBPosition(6, 1), wxGBSpan(1, 2), wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
142147

143-
//StaticText4 = new wxStaticText(this, ID_STATICTEXT4, _("Compass Bearing"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
144-
GridBagSizer1->Add(BearingChoice, wxGBPosition(2, 0), wxDefaultSpan, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
145148
StdDialogButtonSizer1 = new wxStdDialogButtonSizer();
146149
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_OK, wxEmptyString));
147150
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_CANCEL, wxEmptyString));
148151
StdDialogButtonSizer1->Realize();
149152

150-
GridBagSizer1->Add(StdDialogButtonSizer1, wxGBPosition(6, 1), wxGBSpan(1, 2), wxALL|wxEXPAND|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
153+
GridBagSizer1->Add(StdDialogButtonSizer1, wxGBPosition(7, 1), wxGBSpan(1, 2), wxALL|wxEXPAND|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
151154

152155
FlexGridSizer1->Add(GridBagSizer1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
153156
SetSizer(FlexGridSizer1);
@@ -157,7 +160,7 @@ BearingDlg::BearingDlg(wxWindow* parent, Meassurement* Mess, wxWindowID id,const
157160
CopyMessObjToDlg();
158161
GPS_UpdateTime = 0;
159162

160-
Connect(ID_CHOICE,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&BearingDlg::ChoiseSelect);
163+
Connect(ID_CHOICE,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&BearingDlg::OnChoiseSelect);
161164
//Connect(wxID_ANY,wxEVT_CLOSE_WINDOW,(wxObjectEventFunction)&BearingDlg::OnClose);
162165
Connect(wxID_ANY,wxEVT_COMMAND_TEXT_ENTER,(wxObjectEventFunction)&BearingDlg::OnTextCtrlEnter);
163166
Connect(wxID_ANY,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&BearingDlg::OnTextCtrlEnter);
@@ -177,10 +180,11 @@ bool BearingDlg::Show(bool show)
177180
{
178181
bool temp = wxDialog::Show(show);
179182
UpdateFlag = true; //Set updateflag after Textctr's are updated
183+
Dev_PI->DoRouteLegRequest();
180184
return temp;
181185
}
182186

183-
void BearingDlg::ChoiseSelect(wxCommandEvent& event)
187+
void BearingDlg::OnChoiseSelect(wxCommandEvent& event)
184188
{
185189
SetSunBearing(GetDateTime());
186190
}
@@ -228,12 +232,11 @@ void BearingDlg::SetDateTime(wxDateTime dt)
228232
DT_value = dt;
229233
DPickerCtrl->SetValue(DT_value);
230234
TPickerCtrl->SetValue(DT_value);
231-
if (Choice->GetSelection()==3) //SunBearing
232-
TrueBearingCtrl->ChangeValue( (wxString::Format(_("%03.1f"), SolarAzimuth( GetDateTime(), localMesData->lat, localMesData->lon) ) ) );
235+
if (Choice->GetSelection()==devSUN_BEARING) //SunBearing
236+
TrueBearingCtrl->ChangeValue( (wxString::Format(_("%05.1f"), SolarAzimuth( GetDateTime(), localMesData->lat, localMesData->lon) ) ) );
233237

234-
if (Choice->GetSelection()==4) //SunBearing shadow {
235-
TrueBearingCtrl->ChangeValue( (wxString::Format(_("%03.1f"), limit_degrees(SolarAzimuth( GetDateTime(), localMesData->lat, localMesData->lon )+180) ) ) );
236-
238+
if (Choice->GetSelection()==devSUN_SHADOW) //SunBearing shadow {
239+
TrueBearingCtrl->ChangeValue( (wxString::Format(_("%05.1f"), limit_degrees(SolarAzimuth( GetDateTime(), localMesData->lat, localMesData->lon )+180) ) ) );
237240
}
238241

239242
wxDateTime BearingDlg::GetDateTime()
@@ -255,6 +258,7 @@ void BearingDlg::CopyDlgToMessObj ()
255258
localMesData->datetime = GetDateTime();
256259
localMesData->enabled = true;
257260
localMesData->methode = Choice->GetSelection();
261+
localMesData->MeassurementRemarks = Remarks_value;
258262
}
259263
void BearingDlg::CopyMessObjToDlg()
260264
{
@@ -265,6 +269,7 @@ void BearingDlg::CopyMessObjToDlg()
265269
DEV_value =localMesData->deviation;
266270
SetDateTime( localMesData->datetime );
267271
Choice->SetSelection(localMesData->methode);
272+
Remarks_value = localMesData->MeassurementRemarks;
268273
}
269274
void BearingDlg::SetPositionFix(PlugIn_Position_Fix_Ex &pfix)
270275
{
@@ -278,7 +283,7 @@ void BearingDlg::SetPositionFix(PlugIn_Position_Fix_Ex &pfix)
278283
if ( UpdateFlag)
279284
{
280285
GetMessageVariation(localMesData->lat, localMesData->lon);
281-
VariationCtrl->SetValue(wxString::Format(_("%f"), pfix.Var));
286+
Dev_PI->DoRouteLegRequest();
282287

283288
if (GPS_UpdateTime <= 0)
284289
{
@@ -306,7 +311,6 @@ void BearingDlg::SetNMEATimeFix(wxDateTime dt)
306311
SetSunBearing(GetDateTime());
307312

308313
w->SetFocus(); // restore focus
309-
wxPuts(_("BearingDlg::SetNMEATimeFix ") + dt.FormatISOTime());
310314
}
311315
UpdateFlag = TempFlag;
312316

@@ -315,10 +319,10 @@ void BearingDlg::SetSunBearing(wxDateTime t)
315319
{
316320
bool TempFlag = UpdateFlag;
317321
wxWindow *w = FindFocus();
318-
if (Choice->GetSelection()==3) //SunBearing
319-
TrueBearingCtrl->ChangeValue( (wxString::Format(_("%03.1f"), SolarAzimuth( GetDateTime(), localMesData->lat, localMesData->lon) ) ) );
320-
if (Choice->GetSelection()==4) //SunBearing shadow
321-
TrueBearingCtrl->ChangeValue( (wxString::Format(_("%03.1f"), limit_degrees(SolarAzimuth( GetDateTime(), localMesData->lat, localMesData->lon )+180) ) ) );
322+
if (Choice->GetSelection()==devSUN_BEARING) //SunBearing
323+
TrueBearingCtrl->ChangeValue( (wxString::Format(_("%05.1f"), SolarAzimuth( GetDateTime(), localMesData->lat, localMesData->lon) ) ) );
324+
if (Choice->GetSelection()==devSUN_SHADOW) //SunBearing shadow
325+
TrueBearingCtrl->ChangeValue( (wxString::Format(_("%05.1f"), limit_degrees(SolarAzimuth( GetDateTime(), localMesData->lat, localMesData->lon )+180) ) ) );
322326
w->SetFocus(); // restore focus
323327
UpdateFlag = TempFlag;
324328
}
@@ -336,9 +340,6 @@ void BearingDlg::SetNMEAHeading(double hd)
336340
w->SetFocus(); // restore focus
337341
}
338342
UpdateFlag = TempFlag;
339-
340-
341-
wxPuts(_("BearingDlg::SetNMEAHeading"));
342343
}
343344

344345
void BearingDlg::SetMessageVariation(wxString &message_id, wxString &message_body)
@@ -350,25 +351,52 @@ void BearingDlg::SetMessageVariation(wxString &message_id, wxString &message_bod
350351

351352
//TODO check lat/lon to make sure it is our requested message and not an otherone.
352353
// get the DECL value from the JSON message
353-
VariationCtrl->ChangeValue( v[_T("Decl")].AsString() );
354-
wxPuts(_("VariationCtrl->ChangeValue Variation changed from messgae"));
354+
VariationCtrl->ChangeValue( wxString::Format( _T("%05.1f"), v[_T("Decl")].AsDouble()) );
355355
}
356356
}
357+
void BearingDlg::SetMessageRouteActiveLeg(wxString &message_id, wxString &message_body)
358+
{
359+
if ( UpdateFlag){
360+
wxJSONReader r;
361+
wxJSONValue v;
362+
r.Parse(message_body, &v);
363+
364+
if ( v[_("error")].AsBool() ) // error means no active route avalable
365+
{
366+
if (Choice != NULL) // then we remove the option from the choice control
367+
if(Choice->GetCount() > devBEARING_FROM_ROUTE )
368+
Choice->Delete(devBEARING_FROM_ROUTE);
369+
}
370+
else // no error so there is an active route
371+
{
372+
if (Choice != NULL)
373+
{
374+
//If there was no active route choice available make it and select it.
375+
if (Choice->GetCount() <= devBEARING_FROM_ROUTE )
376+
{
377+
Choice->Insert(_("Bearing from Route"), devBEARING_FROM_ROUTE);
378+
Choice->SetSelection(devBEARING_FROM_ROUTE);
379+
}
380+
381+
if ( Choice->GetSelection() == devBEARING_FROM_ROUTE )
382+
{
383+
TrueBearingCtrl->ChangeValue( wxString::Format( _T("%05.1f"), v[_T("bearing")].AsDouble() ) );
384+
}
385+
}
386+
}
387+
}
388+
}
357389
void BearingDlg::GetMessageVariation(double lat, double lon)
358390
{
359-
if ( (abs(lat) < 90.0) && (abs(lon) < 180.0) ) //valid position
391+
if ( (abs(lat) < 90.0) && (abs(lon) <= 180.0) ) //valid position
360392
{
361393
wxJSONValue v;
362394
v[_T("Lat")] = lat;
363395
v[_T("Lon")] = lon;
364396
v[_T("Year")] = GetDateTime().GetYear();
365397
v[_T("Month")] = GetDateTime().GetMonth();
366398
v[_T("Day")] = GetDateTime().GetDay();
367-
Dev_PI->RequestPliginMessage( _T("WMM_VARIATION_REQUEST"), v);
399+
Dev_PI->RequestPluginMessage( _T("WMM_VARIATION_REQUEST"), v);
368400
}
369401
}
370-
// void BearingDlg::UpdateContrs()
371-
// {
372-
//
373-
// }
374402

src/bearingdlg.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@
4141
// class BearingDlg;
4242
// BearingDlg* B_Dlg;
4343

44+
enum {
45+
devBEARING = 0,
46+
devSUN_BEARING = 1,
47+
devSUN_SHADOW = 2,
48+
devBEARING_FROM_ROUTE = 3
49+
};
50+
enum{
51+
devCOMPASBEARING = 0,
52+
devRIGHTHANDBEARING = 1
53+
};
54+
4455
class BearingDlg: public wxDialog
4556
{
4657
public:
@@ -65,9 +76,11 @@ class BearingDlg: public wxDialog
6576
wxStaticText* StaticText9;
6677
wxStaticText* StaticText10;
6778
wxStaticText* StaticText11;
79+
wxStaticText* StaticText12;
6880
wxTextCtrl* TrueBearingCtrl;
6981
wxTextCtrl* CompassBearingCtrl;
7082
wxTextCtrl* VariationCtrl;
83+
wxTextCtrl* RemarksCtr;
7184
void SetDateTime(wxDateTime dt);
7285
wxDateTime GetDateTime();
7386

@@ -79,12 +92,13 @@ class BearingDlg: public wxDialog
7992
wxDateTime DT_value;
8093
float LAT_value;
8194
float LON_value;
82-
95+
wxString Remarks_value;
8396
void SetPositionFix(PlugIn_Position_Fix_Ex &pfix);
8497
void SetNMEATimeFix(wxDateTime dt);
8598
void SetNMEAHeading(double hd);
8699
void SetSunBearing(wxDateTime t);
87100
void SetMessageVariation(wxString &message_id, wxString &message_body);
101+
void SetMessageRouteActiveLeg(wxString &message_id, wxString &message_body);
88102

89103
protected:
90104
//(*Identifiers(BearingDlg)
@@ -106,12 +120,13 @@ class BearingDlg: public wxDialog
106120
static const long ID_STATICTEXT10;
107121
static const long ID_STATICTEXT11;
108122
static const long ID_VARCTRL;
123+
static const long ID_REMARKSCTRL;
109124

110125
//*)
111126

112127
private:
113128
void OnClose(wxCloseEvent& event);
114-
void ChoiseSelect(wxCommandEvent& event);
129+
void OnChoiseSelect(wxCommandEvent& event);
115130
void OnTimeSelect(wxCommandEvent& event);
116131
void OnTextCtrlEnter(wxCommandEvent& event);
117132
//void OnChoiceCtrlEnter(wxCommandEvent& event);

0 commit comments

Comments
 (0)