void ConfigurationDialog::SetConfigurations(std::list<RouteMapConfiguration> configurations)
{
    m_bBlockUpdate = true;

    SET_CHOICE(Start);

    bool ult = m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue();
#define STARTTIME (ult ? it->StartTime.FromUTC() : it->StartTime)

    SET_CONTROL_VALUE(STARTTIME, m_dpStartDate, SetValue, wxDateTime, wxDateTime());
    SET_CONTROL_VALUE(wxString::Format(_T("%.2f"), STARTTIME.GetHour()
                                       + (double)STARTTIME.GetMinute()/60.0),
                m_tStartHour, SetValue, wxString, _T(""));

    SET_SPIN_VALUE(TimeStepHours, (int)((*it).dt / 3600));
    SET_SPIN_VALUE(TimeStepMinutes, ((int)(*it).dt / 60) % 60);
    SET_SPIN_VALUE(TimeStepSeconds, (int)(*it).dt%60);

    SET_CONTROL(boatFileName, m_tBoat, SetValue, wxString, _T(""));

    SET_CHOICE(End);

    SET_SPIN(FromDegree);
    SET_SPIN(ToDegree);
    SET_CONTROL_VALUE(wxString::Format(_T("%f"), (*it).ByDegrees), m_tByDegrees, SetValue, wxString, _T(""));

    SET_CONTROL_VALUE(((*it).Integrator == RouteMapConfiguration::RUNGE_KUTTA ?
                       _T("Runge Kutta") : _T("Newton")), m_cIntegrator, SetValue, wxString, _T(""));

    SET_SPIN(MaxDivertedCourse);
    SET_SPIN(MaxCourseAngle);
    SET_SPIN(MaxSearchAngle);
    SET_SPIN(MaxTrueWindKnots);
    SET_SPIN(MaxApparentWindKnots);

    SET_SPIN(MaxSwellMeters);
    SET_SPIN(MaxLatitude);
    SET_SPIN(TackingTime);
    SET_SPIN(WindVSCurrent);

    SET_CHECKBOX(AvoidCycloneTracks);
    SET_SPIN(CycloneMonths);
    SET_SPIN(CycloneDays);

    SET_CHECKBOX(DetectLand);
    SET_CHECKBOX(Currents);
    SET_CHECKBOX(InvertedRegions);
    SET_CHECKBOX(Anchoring);

    SET_CHECKBOX(UseGrib);
    SET_CONTROL(ClimatologyType, m_cClimatologyType, SetSelection, int, -1);
    SET_CHECKBOX(AllowDataDeficient);
    SET_SPIN_VALUE(WindStrength, (int)((*it).WindStrength * 100));

    m_bBlockUpdate = false;
}
void ConfigurationDialog::SetConfigurations(std::list<RouteMapConfiguration> configurations)
{
    m_bBlockUpdate = true;
    
    m_edited_controls.clear();

    SET_CHOICE(Start);


    bool ult = m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue();
#define STARTTIME (ult ? it->StartTime.FromUTC() : it->StartTime)

    SET_CONTROL_VALUE(STARTTIME.GetDateOnly(), m_dpStartDate, SetValue, wxDateTime, wxDateTime());
    SET_CONTROL_VALUE(STARTTIME, m_tpTime, SetValue, wxDateTime, wxDateTime());
    
    m_bCurrentTime->Enable(m_tpTime->IsEnabled() && m_dpStartDate->IsEnabled());
    m_bGribTime->Enable(m_tpTime->IsEnabled() && m_dpStartDate->IsEnabled());

    SET_SPIN_VALUE(TimeStepHours, (int)((*it).DeltaTime / 3600));
    SET_SPIN_VALUE(TimeStepMinutes, ((int)(*it).DeltaTime / 60) % 60);
    SET_SPIN_VALUE(TimeStepSeconds, (int)(*it).DeltaTime%60);
    
    SET_CONTROL(boatFileName, m_tBoat, SetValue, wxString, _T(""));
    long l = m_tBoat->GetValue().Length();
    m_tBoat->SetSelection(l, l);

    SET_CHOICE(End);

    // if there's a GUID it's an OpenCPN route, for now disable start and end
    // which would invalidate the it
    bool oRoute = false;
    for(auto it : configurations ) {
        if (!it.RouteGUID.IsEmpty()) {
            oRoute = true;
            break;
        }
    }
    m_cStart->Enable(!oRoute);
    m_cEnd->Enable(!oRoute);

    SET_SPIN(FromDegree);
    SET_SPIN(ToDegree);
    SET_CONTROL_VALUE(wxString::Format(_T("%f"), (*it).ByDegrees), m_tByDegrees, SetValue, wxString, _T(""));

    SET_CHOICE_VALUE(Integrator, ((*it).Integrator == RouteMapConfiguration::RUNGE_KUTTA ?
                                  _T("Runge Kutta") : _T("Newton")));

    SET_SPIN(MaxDivertedCourse);
    SET_SPIN(MaxCourseAngle);
    SET_SPIN(MaxSearchAngle);
    SET_SPIN(MaxTrueWindKnots);
    SET_SPIN(MaxApparentWindKnots);

    SET_SPIN(MaxSwellMeters);
    SET_SPIN(MaxLatitude);
    SET_SPIN(TackingTime);
    SET_SPIN(WindVSCurrent);

    SET_CHECKBOX(AvoidCycloneTracks);
    SET_SPIN(CycloneMonths);
    SET_SPIN(CycloneDays);
    SET_SPIN(SafetyMarginLand);

    SET_CHECKBOX(DetectLand);
    SET_CHECKBOX(DetectBoundary);
    SET_CHECKBOX(Currents);
    SET_CHECKBOX(OptimizeTacking);
    
    SET_CHECKBOX(InvertedRegions);
    SET_CHECKBOX(Anchoring);

    SET_CHECKBOX(UseGrib);
    SET_CONTROL(ClimatologyType, m_cClimatologyType, SetSelection, int, -1);
    SET_CHECKBOX(AllowDataDeficient);
    SET_SPIN_VALUE(WindStrength, (int)((*it).WindStrength * 100));

    m_bBlockUpdate = false;
}