Skip to content

Commit

Permalink
ADD improved apparent wind on BarbsOnRoute
Browse files Browse the repository at this point in the history
This is now an option, and the wind barbs have a different color if user
selects apparent wind to distinguish from true wind.
  • Loading branch information
theeko74 committed Sep 7, 2018
1 parent 19c6f94 commit 92a2dea
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 50 deletions.
166 changes: 127 additions & 39 deletions WeatherRouting.fbp

Large diffs are not rendered by default.

47 changes: 37 additions & 10 deletions src/RouteMapOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,9 @@ void RouteMapOverlay::Render(wxDateTime time, SettingsDialog &settingsdialog,

// Start WindBarbsOnRoute customization
int lineWidth = settingsdialog.m_sWindBarbsOnRouteThickness->GetValue();
bool apparent = settingsdialog.m_cbDisplayApparentWindBarbs->GetValue();
if (lineWidth > 0)
RenderWindBarbsOnRoute(dc, vp, lineWidth);
RenderWindBarbsOnRoute(dc, vp, lineWidth, apparent);

if(MarkAtPolarChange) {
SetColor(dc, Darken(DestinationColor), true);
Expand Down Expand Up @@ -693,7 +694,8 @@ void RouteMapOverlay::RenderBoatOnCourse(bool cursor_route, wxDateTime time, wrD
}
}

void RouteMapOverlay::RenderWindBarbsOnRoute(wrDC &dc, PlugIn_ViewPort &vp, int lineWidth)
void RouteMapOverlay::RenderWindBarbsOnRoute(wrDC &dc, PlugIn_ViewPort &vp, int lineWidth,
bool apparentWind)
{
/* Method to render wind barbs on the route that has been generated
* by WeatherRouting plugin. The idead is to visualize the wind
Expand Down Expand Up @@ -727,23 +729,48 @@ void RouteMapOverlay::RenderWindBarbsOnRoute(wrDC &dc, PlugIn_ViewPort &vp, int
wxPoint p;
GetCanvasPixLL(&nvp, &p, it->lat, it->lon);

// Calculate apparent wind direction
float apparentWindSpeed = Polar::VelocityApparentWind(it->VB, it->W, it->VW);
float apparentWindDirection = Polar::DirectionApparentWind(apparentWindSpeed, it->VB, it->W, it->VW);
float windSpeed = it->VW;
float windDirection = it->W; // heading_resolve(it->B - it->W);

// By default, display true wind
float finalWindSpeed = windSpeed;
float finalWindDirection = windDirection;

if (apparentWind)
{
finalWindSpeed = Polar::VelocityApparentWind(it->VB,
heading_resolve(it->B - windDirection),
windSpeed);
finalWindDirection = heading_resolve(
it->B -
Polar::DirectionApparentWind(finalWindSpeed, it->VB,
heading_resolve(it->B - windDirection),
it->VW));
}

// Draw barbs
g_barbsOnRoute_LineBufferOverlay.setLineWidth(lineWidth);
g_barbsOnRoute_LineBufferOverlay.pushWindArrowWithBarbs(
wind_barb_route_cache, p.x, p.y, apparentWindSpeed,
deg2rad(apparentWindDirection) + nvp.rotation, it->lat < 0, true
);
g_barbsOnRoute_LineBufferOverlay.pushWindArrowWithBarbs(wind_barb_route_cache,
p.x, p.y, finalWindSpeed,
deg2rad(finalWindDirection)
+nvp.rotation, it->lat < 0, true);
}
wind_barb_route_cache.Finalize();

// Draw the wind barbs
wxPoint point;
GetCanvasPixLL(&vp, &point, configuration.StartLat, configuration.StartLon);
wxColour colour(170, 0, 170);
wxColour colour;
if (apparentWind)
{
wxColour blue(20, 83, 186);
colour = blue;
}
else
{
wxColour purple(170, 0, 170);
colour = purple;
}

if(dc.GetDC())
{
Expand Down
2 changes: 1 addition & 1 deletion src/RouteMapOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class RouteMapOverlay : public RouteMap
void RenderCourse(bool cursor_route, wrDC &dc, PlugIn_ViewPort &vp, bool comfortRoute = false);

// Customization WindBarbsOnRoute
void RenderWindBarbsOnRoute(wrDC &dc, PlugIn_ViewPort &vp, int lineWidth);
void RenderWindBarbsOnRoute(wrDC &dc, PlugIn_ViewPort &vp, int lineWidth, bool apparentWind);
int sailingConditionLevel(const PlotData &plot) const;

virtual bool TestAbort() { return Finished(); }
Expand Down
5 changes: 5 additions & 0 deletions src/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ void SettingsDialog::LoadSettings()
pConf->Read( _T("WindBarbsOnRouteThickness"), &WindBarbsOnRouteThickness,
WindBarbsOnRouteThickness);
m_sWindBarbsOnRouteThickness->SetValue(WindBarbsOnRouteThickness);
bool WindBarbsOnRouteApparent = m_cbDisplayApparentWindBarbs->GetValue();
pConf->Read( _T("WindBarbsOnRouteApparent"), &WindBarbsOnRouteApparent,
WindBarbsOnRouteApparent);
m_cbDisplayApparentWindBarbs->SetValue(WindBarbsOnRouteApparent);

// ComfortOnRoute Customization
bool DisplayComfortOnRoute = m_cbDisplayComfort->GetValue();
Expand Down Expand Up @@ -160,6 +164,7 @@ void SettingsDialog::SaveSettings( )
pConf->Write( _T("DisplayWindBarbs"), m_cbDisplayWindBarbs->GetValue());
// WindBarbsOnRoute Customization
pConf->Write( _T("WindBarbsOnRouteThickness"), m_sWindBarbsOnRouteThickness->GetValue());
pConf->Write( _T("WindBarbsOnRouteApparent"), m_cbDisplayApparentWindBarbs->GetValue());
pConf->Write( _T("DisplayComfortOnRoute"), m_cbDisplayComfort->GetValue());
pConf->Write( _T("DisplayCurrent"), m_cbDisplayCurrent->GetValue());

Expand Down
5 changes: 5 additions & 0 deletions src/WeatherRoutingUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ SettingsDialogBase::SettingsDialogBase( wxWindow* parent, wxWindowID id, const w
m_cbDisplayWindBarbs = new wxCheckBox( sbSizer25->GetStaticBox(), wxID_ANY, _("Display Wind Barbs"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer82->Add( m_cbDisplayWindBarbs, 0, wxALL, 5 );

m_cbDisplayApparentWindBarbs = new wxCheckBox( sbSizer25->GetStaticBox(), wxID_ANY, _("Apparent Wind for Barbs On Route (not True Wind)"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer82->Add( m_cbDisplayApparentWindBarbs, 0, wxALL, 5 );

m_cbDisplayComfort = new wxCheckBox( sbSizer25->GetStaticBox(), wxID_ANY, _("Display Sailing Comfort on Route"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer82->Add( m_cbDisplayComfort, 0, wxALL, 5 );

Expand Down Expand Up @@ -507,6 +510,7 @@ SettingsDialogBase::SettingsDialogBase( wxWindow* parent, wxWindowID id, const w
m_cbMarkAtPolarChange->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cbDisplayCurrent->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cbDisplayWindBarbs->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cbDisplayApparentWindBarbs->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cbDisplayComfort->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cblFields->Connect( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, wxCommandEventHandler( SettingsDialogBase::OnUpdateColumns ), NULL, this );
m_cbUseLocalTime->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdateColumns ), NULL, this );
Expand All @@ -527,6 +531,7 @@ SettingsDialogBase::~SettingsDialogBase()
m_cbMarkAtPolarChange->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cbDisplayCurrent->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cbDisplayWindBarbs->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cbDisplayApparentWindBarbs->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cbDisplayComfort->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdate ), NULL, this );
m_cblFields->Disconnect( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, wxCommandEventHandler( SettingsDialogBase::OnUpdateColumns ), NULL, this );
m_cbUseLocalTime->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SettingsDialogBase::OnUpdateColumns ), NULL, this );
Expand Down
1 change: 1 addition & 0 deletions src/WeatherRoutingUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class SettingsDialogBase : public wxDialog
wxCheckBox* m_cbMarkAtPolarChange;
wxCheckBox* m_cbDisplayCurrent;
wxCheckBox* m_cbDisplayWindBarbs;
wxCheckBox* m_cbDisplayApparentWindBarbs;
wxCheckBox* m_cbDisplayComfort;
wxSpinCtrl* m_sConcurrentThreads;
wxCheckListBox* m_cblFields;
Expand Down

0 comments on commit 92a2dea

Please sign in to comment.