@@ -48,13 +48,14 @@ const long BearingDlg::ID_STATICTEXT9 = wxNewId();
4848const long BearingDlg::ID_STATICTEXT10 = wxNewId();
4949const long BearingDlg::ID_STATICTEXT11 = wxNewId();
5050const long BearingDlg::ID_VARCTRL = wxNewId();
51+ const long BearingDlg::ID_REMARKSCTRL = wxNewId();
5152// *)
5253
5354BearingDlg::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
239242wxDateTime 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}
259263void 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}
269274void 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
344345void 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+ }
357389void 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
0 commit comments