Skip to content

Commit

Permalink
Switch GUI to feet and kts values
Browse files Browse the repository at this point in the history
  • Loading branch information
fboes committed Aug 18, 2019
1 parent ce03a67 commit 7d09bd5
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change log
==========

1.3.0
-----

* 🎁 Switch GUI to feet and kts values

1.2.10
------

Expand Down
Binary file modified docs/aerofly-wx-desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 16 additions & 17 deletions src/WettergeraetDesktop/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ Frame::Frame(const wxString& title, int argc, char * argv[]) : wxFrame(nullptr,
}
wxBoxSizer *hbox8 = new wxBoxSizer(wxHORIZONTAL);
{
wxStaticText *clouds0HeightLabel = new wxStaticText(panel, wxID_ANY, cloudName + " height (%)");
hbox8->Add(clouds0HeightLabel, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, labelBorder);
wxStaticText *cloudsHeightLabel = new wxStaticText(panel, wxID_ANY, cloudName + " height (ft)");
hbox8->Add(cloudsHeightLabel, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, labelBorder);

this->clouds[i].heightInput = new wxSlider(panel, Frame::EL_CTRL_SLIDER, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
this->clouds[i].heightInput = new wxSlider(panel, Frame::EL_CTRL_SLIDER, 20000, 0, 40000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
hbox8->Add(this->clouds[i].heightInput, 1, wxALIGN_CENTER_VERTICAL);

hbox8->Add(10, -1);

wxStaticText *clouds0DensityLabel = new wxStaticText(panel, wxID_ANY, cloudName + " density (%)");
hbox8->Add(clouds0DensityLabel, 1, wxALIGN_CENTER_VERTICAL, labelBorder);
wxStaticText *cloudsDensityLabel = new wxStaticText(panel, wxID_ANY, cloudName + " density (%)");
hbox8->Add(cloudsDensityLabel, 1, wxALIGN_CENTER_VERTICAL, labelBorder);

this->clouds[i].densityInput = new wxSlider(panel, Frame::EL_CTRL_SLIDER, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
hbox8->Add(this->clouds[i].densityInput, 1, wxLEFT | wxALIGN_CENTER_VERTICAL);
Expand All @@ -170,10 +170,10 @@ Frame::Frame(const wxString& title, int argc, char * argv[]) : wxFrame(nullptr,

hbox5->Add(10, -1);

wxStaticText *windStrengthLabel = new wxStaticText(panel, wxID_ANY, wxT("Wind strength (%)"));
wxStaticText *windStrengthLabel = new wxStaticText(panel, wxID_ANY, wxT("Wind strength (kts)"));
hbox5->Add(windStrengthLabel, 1, wxALIGN_CENTER_VERTICAL, labelBorder);

this->windStrengthInput = new wxSlider(panel, Frame::EL_CTRL_SLIDER, 50, 0, 200, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
this->windStrengthInput = new wxSlider(panel, Frame::EL_CTRL_SLIDER, 4, 0, 48, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
hbox5->Add(this->windStrengthInput, 1, wxLEFT | wxALIGN_CENTER_VERTICAL);
}
vbox->Add(hbox5, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
Expand Down Expand Up @@ -202,10 +202,11 @@ Frame::Frame(const wxString& title, int argc, char * argv[]) : wxFrame(nullptr,
// build hbox7
wxBoxSizer *hbox7 = new wxBoxSizer(wxHORIZONTAL);
{
wxStaticText *visbilityLabel = new wxStaticText(panel, wxID_ANY, wxT("Visibility (%)"));
wxStaticText *visbilityLabel = new wxStaticText(panel, wxID_ANY, wxT("Visibility (m)"));
hbox7->Add(visbilityLabel, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, labelBorder);

this->visbilityInput = new wxSlider(panel, Frame::EL_CTRL_SLIDER, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
this->visbilityInput = new wxSlider(panel, Frame::EL_CTRL_SLIDER, 10000, 0, 20000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
this->visbilityInput->SetTickFreq(20);
hbox7->Add(this->visbilityInput, 1, wxALIGN_CENTER_VERTICAL);

hbox7->Add(10, -1);
Expand Down Expand Up @@ -260,15 +261,15 @@ void Frame::fromObjectToInput()
this->utcDateInput->SetValue(this->utcDateValue);

this->windDirectionInput->SetValue(this->aerofly.windDirection);
this->windStrengthInput->SetValue(ceil(this->aerofly.windStrength * 100));
this->windStrengthInput->SetValue(ceil(this->aerofly.getWindKts()));

this->windTurbulenceInput->SetValue(ceil(this->aerofly.windTurbulence * 100));
this->thermalActivityInput->SetValue(ceil(this->aerofly.thermalActivity * 100));

this->visbilityInput->SetValue(ceil(this->aerofly.visibility * 100));
this->visbilityInput->SetValue(floor(this->aerofly.getVisbilityMeters()));

for (int i = 0; i < 3; ++i) {
this->clouds[i].heightInput->SetValue(ceil(this->aerofly.clouds[i].height * 100));
this->clouds[i].heightInput->SetValue(floor(this->aerofly.getCloudHeightFt(i)));
this->clouds[i].densityInput->SetValue(ceil(this->aerofly.clouds[i].density * 100));
}
}
Expand All @@ -283,17 +284,15 @@ void Frame::fromInputToObject()
auto time = this->utcTimeInput->GetValue();
this->aerofly.hours = time.GetHour() + time.GetMinute() / 60.0 + time.GetSecond() / (60.0 * 60.0);

this->aerofly.windDirection = this->windDirectionInput->GetValue();
this->aerofly.windStrength = this->windStrengthInput->GetValue() / 100.0;
this->aerofly.setWind(this->windStrengthInput->GetValue(), this->windDirectionInput->GetValue());

this->aerofly.windTurbulence = this->windTurbulenceInput->GetValue() / 100.0;
this->aerofly.thermalActivity = this->thermalActivityInput->GetValue() / 100.0;

this->aerofly.visibility = this->visbilityInput->GetValue() / 100.0;
this->aerofly.setVisibility(this->visbilityInput->GetValue());

for (int i = 0; i < 3; ++i) {
this->aerofly.clouds[i].height = this->clouds[i].heightInput->GetValue() / 100.0;
this->aerofly.clouds[i].density = this->clouds[i].densityInput->GetValue() / 100.0;
this->aerofly.setCloudPercent(i, this->clouds[i].heightInput->GetValue(), this->clouds[i].densityInput->GetValue() / 100.0);
}
}

Expand Down
25 changes: 23 additions & 2 deletions src/WettergeraetLib/AeroflyWeather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ void AeroflyWeather::setWind(double kts, unsigned int degrees)
this->windDirection = BoShed::rotatingValue(degrees, 359);
this->windStrength = BoShed::percent(combinedWindForce);
}

void AeroflyWeather::setTurbulence(double windSpeed, double gustSpeed, unsigned int degreesFrom, unsigned int degreesTo, char const conditions[4][6])
{
double degreesRange = std::abs((degreesTo - degreesFrom) / 360.0);
Expand Down Expand Up @@ -128,12 +127,34 @@ void AeroflyWeather::setCloud(unsigned short index, double baseFeetAgl, unsigned
densityMinimum--;
}

this->clouds[index].density = (densityMinimum + (
auto density = (densityMinimum + (
(rand() % 100 / 100.0) * (densityMaximum - densityMinimum)
)) / this->maxCloudsDensity;
this->setCloudPercent(index, baseFeetAgl, density);
}

void AeroflyWeather::setCloudPercent(unsigned short index, double baseFeetAgl, double percent)
{
this->clouds[index].density = percent;
this->clouds[index].height = baseFeetAgl / this->maxCloudsHeight;
}

double AeroflyWeather::getWindKts()
{
// f(x) = 8 * (x + x^2)
return 8 * (this->windStrength + this->windStrength * this->windStrength);
}

double AeroflyWeather::getCloudHeightFt(unsigned short index)
{
return this->clouds[index].height * this->maxCloudsHeight;
}

double AeroflyWeather::getVisbilityMeters()
{
return this->visibility * this->maxVisibility;
}

void AeroflyWeather::setFromMetar(const MetarParserSimple& metar)
{
this->setNearestAirport(metar.icao);
Expand Down
11 changes: 11 additions & 0 deletions src/WettergeraetLib/AeroflyWeather.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ class AeroflyWeather
// Set cloud with index 0..2. Density is between 0..8.
void setCloud(unsigned short index, double baseFeetAgl, unsigned short densityMinimum, unsigned short densityMaximum);

// Set cloud with index 0..2. Density is between 0.0..1.0.
void setCloudPercent(unsigned short index, double baseFeetAgl, double percent);

// Convert wind percent into kts
double getWindKts();

// Get cloud height in ft
double getCloudHeightFt(unsigned short index);

double getVisbilityMeters();

// Populate all values from a MetarParser object
void setFromMetar(const MetarParserSimple& metar);

Expand Down
2 changes: 1 addition & 1 deletion src/WettergeraetLib/Argumentor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <sstream>
#include <iterator>

const char* Argumentor::APP_VERSION = "1.2.10";
const char* Argumentor::APP_VERSION = "1.3.0";
#if _WIN64
const char* Argumentor::APP_TARGET = "64-bit";
#else
Expand Down

0 comments on commit 7d09bd5

Please sign in to comment.