Beispiel #1
0
static bool
SetPointType(AbstractTaskFactory::LegalPointType type)
{
  bool apply = false;

  if (!point) {
    apply = true;
    // empty point, don't ask confirmation
  } else {
    if (type == get_point_type())
      // no change
      return true;

    if (MessageBoxX(_("Change point type?"), _("Task Point"),
                    MB_YESNO | MB_ICONQUESTION) == IDYES)
      apply = true;
  }

  if (apply) {
    AbstractTaskFactory &factory = ordered_task->GetFactory();

    if (point) {
      point = factory.CreateMutatedPoint(*point, type);
      if (point == NULL)
        return false;

      if (factory.Replace(*point, active_index, true))
        task_modified = true;
      delete point;
    } else {
      if (factory.IsValidFinishType(type) &&
          ordered_task->get_ordered_task_behaviour().is_closed)
        way_point = &(ordered_task->get_tp(0)->GetWaypoint());
      else
        way_point =
          dlgWaypointSelect(wf->GetMainWindow(),
                              ordered_task->TaskSize() > 0 ?
                              ordered_task->get_tp(ordered_task->
                                  TaskSize() - 1)->GetLocation() :
                              XCSoarInterface::Basic().location);
      if (!way_point)
        return false;

      point = factory.CreatePoint(type, *way_point);
      if (point == NULL)
        return false;

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

      delete point;
    }
    return true;
  }
  return false;
}
static void
OnWaypointEditClicked(gcc_unused WndButton &Sender)
{
  const Waypoint *way_point = dlgWaypointSelect(XCSoarInterface::main_window,
                                                XCSoarInterface::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);
    }
  }
}
Beispiel #3
0
void
InputEvents::eventGotoLookup(gcc_unused const TCHAR *misc)
{
  const NMEAInfo &basic = CommonInterface::Basic();

  if (protected_task_manager == NULL)
    return;

  const Waypoint* wp = dlgWaypointSelect(XCSoarInterface::main_window,
                                         basic.location);
  if (wp != NULL) {
    protected_task_manager->DoGoto(*wp);
    trigger_redraw();
  }
}
static void
OnRelocateClicked(gcc_unused WndButton &Sender)
{
  const GeoPoint &gpBearing = (active_index ?
                               ordered_task->get_tp(active_index - 1)->get_location() :
                               XCSoarInterface::Basic().Location);

  const Waypoint *wp = dlgWaypointSelect(wf->GetMainWindow(), gpBearing,
                                         ordered_task,
                                         active_index);
  if (wp == NULL)
    return;

  ordered_task->get_factory().relocate(active_index, *wp);
  task_modified = true;
  RefreshView();
}
static void
OnWaypointDeleteClicked(gcc_unused WndButton &Sender)
{
#ifdef OLD_TASK
  int res;
  res = dlgWaypointSelect(XCSoarInterface::Basic().Location);
  if (res != -1){
    if(MessageBoxX(way_points.get(res).Name,
                   _("Delete Waypoint?"),
                   MB_YESNO|MB_ICONQUESTION) == IDYES) {
      Waypoint &waypoint = way_points.set(res);

      waypoint.FileNum = -1;
      waypoint.original_id = 0;
      WaypointsNeedSave = true;
    }
  }
#endif
}