#include "Settings.h"

WaypointManager::Settings::Settings()
    : _missionController(nullptr)
    , _isFlyView(true)
    , _arrivalReturnSpeed(5)
    , _flightSpeed(2)
    , _altitude(5)
{

}

bool WaypointManager::Settings::valid() const
{
    return    _missionController != nullptr
           && _homePosition.isValid();
}

void WaypointManager::Settings::setHomePosition(const QGeoCoordinate &c)
{
    _homePosition = c;
}

void WaypointManager::Settings::setMissionController(MissionController *controller)
{
    _missionController = controller;
}

void WaypointManager::Settings::setMasterController(PlanMasterController *controller)
{
    _masterController = controller;
}

void WaypointManager::Settings::setIsFlyView(bool isFlyView)
{
    _isFlyView = isFlyView;
}

void WaypointManager::Settings::setArrivalReturnSpeed(double speed)
{
    if (speed > 0)
        _arrivalReturnSpeed = speed;
}

void WaypointManager::Settings::setFlightSpeed(double speed)
{
    if ( speed > 0)
        _flightSpeed = speed;
}

void WaypointManager::Settings::setAltitude(double altitude)
{
    if ( altitude > 0)
        _altitude = altitude;
}

const QGeoCoordinate &WaypointManager::Settings::homePosition() const
{
    return _homePosition;
}

QGeoCoordinate &WaypointManager::Settings::homePosition()
{
    return _homePosition;
}

MissionController *WaypointManager::Settings::missionController() const
{
    return _missionController;
}

PlanMasterController *WaypointManager::Settings::masterController() const
{
    return _masterController;
}

Vehicle *WaypointManager::Settings::vehicle() const
{
    return _masterController->managerVehicle();
}

bool WaypointManager::Settings::isFlyView() const
{
    return _isFlyView;
}

double WaypointManager::Settings::arrivalReturnSpeed() const
{
    return _arrivalReturnSpeed;
}

double WaypointManager::Settings::flightSpeed() const
{
    return _flightSpeed;
}

double WaypointManager::Settings::altitude() const
{
    return _altitude;
}
