Beispiel #1
0
// WaypointDetails
// Displays waypoint details
//         current: the current active waypoint
//          select: brings up the waypoint selector, if the user then
//                  selects a waypoint, then the details dialog is shown.
//  See the waypoint dialog section of the reference manual
// for more info.
void
InputEvents::eventWaypointDetails(const TCHAR *misc)
{
  const NMEAInfo &basic = CommonInterface::Basic();
  WaypointPtr wp;

  bool allow_navigation = true;
  bool allow_edit = true;

  if (StringIsEqual(misc, _T("current"))) {
    if (protected_task_manager == NULL)
      return;

    wp = protected_task_manager->GetActiveWaypoint();
    if (!wp) {
      Message::AddMessage(_("No active waypoint!"));
      return;
    }

    /* due to a code limitation, we can't currently manipulate
       Waypoint instances taken from the task, because it would
       require updating lots of internal task state, and the waypoint
       editor doesn't know how to do that */
    allow_navigation = false;
    allow_edit = false;
  } else if (StringIsEqual(misc, _T("select"))) {
    wp = ShowWaypointListDialog(basic.location);
  }
  if (wp)
    dlgWaypointDetailsShowModal(std::move(wp),
                                allow_navigation, allow_edit);
}
Beispiel #2
0
inline void
TeamCodeWidget::OnSetWaypointClicked()
{
  const auto wp =
    ShowWaypointListDialog(CommonInterface::Basic().location);
  if (wp != nullptr) {
    CommonInterface::SetComputerSettings().team_code.team_code_reference_waypoint = wp->id;
    Profile::Set(ProfileKeys::TeamcodeRefWaypoint, wp->id);
  }
}
Beispiel #3
0
static void
OnSetWaypointClicked()
{
  const Waypoint* wp =
    ShowWaypointListDialog(CommonInterface::Basic().location);
  if (wp != NULL) {
    CommonInterface::SetComputerSettings().team_code.team_code_reference_waypoint = wp->id;
    Profile::Set(ProfileKeys::TeamcodeRefWaypoint, wp->id);
  }
}
void
OptionStartsWidget::Relocate(unsigned ItemIndex)
{
  assert(ItemIndex <= task.GetOptionalStartPointCount()
      +  (RealStartExists ? 2 : 1));
  assert(GetList().GetLength() ==
         task.GetOptionalStartPointCount() + (RealStartExists ? 2 : 1));

  if (ItemIndex == 0 && RealStartExists)
    return;

  const unsigned index_optional_starts = ItemIndex - (RealStartExists ? 1 : 0);

  if (index_optional_starts < task.GetOptionalStartPointCount()) {
    const GeoPoint &location = task.TaskSize() > 0
      ? task.GetPoint(0).GetLocation()
      : CommonInterface::Basic().location;
    const Waypoint* way_point =
      ShowWaypointListDialog(location);
    if (!way_point)
      return;

    if (task.RelocateOptionalStart(index_optional_starts, *way_point))
      modified = true;

  } else if (!task.IsFull()) {

    const GeoPoint &location = task.TaskSize() > 0
      ? task.GetPoint(0).GetLocation()
      : CommonInterface::Basic().location;
    const Waypoint* way_point =
      ShowWaypointListDialog(location);
    if (!way_point)
      return;

    AbstractTaskFactory &factory = task.GetFactory();
    if (factory.AppendOptionalStart(*way_point)) {
      modified = true;
    }
  }
  RefreshView();
}
void
InputEvents::eventGotoLookup(gcc_unused const TCHAR *misc)
{
  const NMEAInfo &basic = CommonInterface::Basic();

  if (protected_task_manager == NULL)
    return;

  auto wp = ShowWaypointListDialog(basic.location);
  if (wp != NULL) {
    protected_task_manager->DoGoto(std::move(wp));
    trigger_redraw();
  }
}
Beispiel #6
0
inline void
TaskPointWidget::OnRelocateClicked()
{
  const GeoPoint &gpBearing = active_index > 0
    ? ordered_task.GetPoint(active_index - 1).GetLocation()
    : CommonInterface::Basic().location;

  auto wp = ShowWaypointListDialog(gpBearing, &ordered_task, active_index);
  if (wp == nullptr)
    return;

  ordered_task.GetFactory().Relocate(active_index, std::move(wp));
  ordered_task.ClearName();
  ordered_task.UpdateGeometry();
  task_modified = true;
  RefreshView();
}
Beispiel #7
0
static void
OnRelocateClicked()
{
  const GeoPoint &gpBearing = active_index > 0
    ? ordered_task->GetPoint(active_index - 1).GetLocation()
    : CommonInterface::Basic().location;

  const Waypoint *wp = ShowWaypointListDialog(gpBearing,
                                         ordered_task, active_index);
  if (wp == nullptr)
    return;

  ordered_task->GetFactory().Relocate(active_index, *wp);
  ordered_task->ClearName();
  task_modified = true;
  RefreshView();
}
Beispiel #8
0
static void
OnWaypointEditClicked()
{
  if (!WaypointGlue::IsWritable()) {
    ShowMessageBox(_("Waypoints not editable"), _("Error"), MB_OK);
    return;
  }

  const Waypoint *way_point =
    ShowWaypointListDialog(CommonInterface::Basic().location);
  if (way_point) {
    Waypoint wp_copy = *way_point;
    if (dlgWaypointEditShowModal(wp_copy)) {
      WaypointsNeedSave = true;

      ScopeSuspendAllThreads suspend;
      way_points.Replace(*way_point, wp_copy);
      way_points.Optimise();
    }
  }
}
// WaypointDetails
// Displays waypoint details
//         current: the current active waypoint
//          select: brings up the waypoint selector, if the user then
//                  selects a waypoint, then the details dialog is shown.
//  See the waypoint dialog section of the reference manual
// for more info.
void
InputEvents::eventWaypointDetails(const TCHAR *misc)
{
  const NMEAInfo &basic = CommonInterface::Basic();
  WaypointPtr wp;

  if (StringIsEqual(misc, _T("current"))) {
    if (protected_task_manager == NULL)
      return;

    wp = protected_task_manager->GetActiveWaypoint();
    if (!wp) {
      Message::AddMessage(_("No active waypoint!"));
      return;
    }
  } else if (StringIsEqual(misc, _T("select"))) {
    wp = ShowWaypointListDialog(basic.location);
  }
  if (wp)
    dlgWaypointDetailsShowModal(std::move(wp));
}
Beispiel #10
0
void
TaskEditPanel::EditTaskPoint(unsigned ItemIndex)
{
  if (ItemIndex < ordered_task->TaskSize()) {
    if (dlgTaskPointShowModal(*ordered_task, ItemIndex)) {
      *task_modified = true;
      ordered_task->ClearName();
      ordered_task->UpdateGeometry();
      RefreshView();
    }
  } else if (!ordered_task->IsFull()) {

    OrderedTaskPoint* point = nullptr;
    AbstractTaskFactory &factory = ordered_task->GetFactory();
    const Waypoint* way_point =
      ShowWaypointListDialog(ordered_task->TaskSize() > 0
                             ? ordered_task->GetPoint(ordered_task->TaskSize() - 1).GetLocation()
                             : CommonInterface::Basic().location,
                        ordered_task, ItemIndex);
    if (!way_point)
      return;

    if (ItemIndex == 0) {
      point = (OrderedTaskPoint*)factory.CreateStart(*way_point);
    } else {
      point = (OrderedTaskPoint*)factory.CreateIntermediate(*way_point);
     }
    if (point == nullptr)
      return;

    if (factory.Append(*point, true)) {
      *task_modified = true;
      ordered_task->ClearName();
      ordered_task->UpdateGeometry();
      RefreshView();
    }

    delete point;
  }
}
Beispiel #11
0
static void
OnWaypointDeleteClicked()
{
  if (!WaypointGlue::IsWritable()) {
    ShowMessageBox(_("Waypoints not editable"), _("Error"), MB_OK);
    return;
  }

  const Waypoint *way_point =
    ShowWaypointListDialog(CommonInterface::Basic().location);
  if (way_point == nullptr)
    return;

  if (ShowMessageBox(way_point->name.c_str(), _("Delete waypoint?"),
                     MB_YESNO | MB_ICONQUESTION) == IDYES) {
    WaypointsNeedSave = true;

    ScopeSuspendAllThreads suspend;
    way_points.Erase(*way_point);
    way_points.Optimise();
  }
}
Beispiel #12
0
void
ATCReferencePanel::OnAction(int id) noexcept
{
  GeoPoint &location =
    CommonInterface::SetComputerSettings().poi.atc_reference;

  switch (id) {
  case RELOCATE: {
    auto waypoint = ShowWaypointListDialog(CommonInterface::Basic().location);
    if (waypoint != nullptr) {
      location = waypoint->location;
      UpdateValues();
    }
  }
    break;

  case CLEAR:
    location.SetInvalid();
    UpdateValues();
    break;
  }
}
Beispiel #13
0
void
TaskEditPanel::EditTaskPoint(unsigned ItemIndex)
{
  if (ItemIndex < ordered_task->TaskSize()) {
    if (dlgTaskPointShowModal(wf.GetMainWindow(), &ordered_task, ItemIndex)) {
      *task_modified = true;
      RefreshView();
    }
  } else if (!ordered_task->IsFull()) {

    OrderedTaskPoint* point = NULL;
    AbstractTaskFactory &factory = ordered_task->GetFactory();
    const Waypoint* way_point =
      ShowWaypointListDialog(wf.GetMainWindow(),
                             ordered_task->TaskSize() > 0
                             ? ordered_task->GetPoint(ordered_task->TaskSize() - 1).GetLocation()
                             : XCSoarInterface::Basic().location,
                        ordered_task, ItemIndex);
    if (!way_point)
      return;

    if (ItemIndex == 0) {
      point = (OrderedTaskPoint*)factory.CreateStart(*way_point);
    } else {
      point = (OrderedTaskPoint*)factory.CreateIntermediate(*way_point);
     }
    if (point == NULL)
      return;

    if (factory.Append(*point, true))
      *task_modified = true;

    delete point;

    RefreshView();
  }
}
Beispiel #14
0
inline void
WaypointManagerWidget::OnWaypointImportClicked()
{
  const Waypoint *way_point =
    ShowWaypointListDialog(CommonInterface::Basic().location);
  if (way_point) {
    Waypoint wp_copy = *way_point;

    /* move to user.cup */
    wp_copy.origin = WaypointOrigin::USER;

    if (dlgWaypointEditShowModal(wp_copy)) {
      modified = true;

      {
        ScopeSuspendAllThreads suspend;
        way_points.Replace(*way_point, wp_copy);
        way_points.Optimise();
      }

      UpdateList();
    }
  }
}