Beispiel #1
0
void
Serialiser::deserialise_point(OrderedTask& data)
{
  tstring type;
  if (!m_node.get_attribute(_T("type"),type)) {
    assert(1);
    return;
  }

  DataNode* wp_node = m_node.get_child_by_name(_T("Waypoint"));
  if (wp_node==NULL)
    return;
  Serialiser wser(*wp_node);
  Waypoint *wp = wser.deserialise_waypoint();
  if (wp==NULL) {
    delete wp_node;
    return;
  }

  DataNode* oz_node = m_node.get_child_by_name(_T("ObservationZone"));
  if (oz_node==NULL) {
    delete wp_node;
    delete wp;
    return;
  }
  Serialiser oser(*oz_node);

  AbstractTaskFactory& fact = data.get_factory();

  ObservationZonePoint* oz = NULL;
  OrderedTaskPoint *pt = NULL;

  if (_tcscmp(type.c_str(), _T("Start")) == 0) {
    if ((oz = oser.deserialise_oz(*wp, false)) != NULL) {
      pt = fact.createStart(oz, *wp);
    }
  } else if (_tcscmp(type.c_str(), _T("Turn")) == 0) {
    if ((oz = oser.deserialise_oz(*wp, true)) != NULL) {
      pt = fact.createAST(oz, *wp);
    }
  } else if (_tcscmp(type.c_str(), _T("Area")) == 0) {
    if ((oz = oser.deserialise_oz(*wp, true)) != NULL) {
      pt = fact.createAAT(oz, *wp);
    }
  } else if (_tcscmp(type.c_str(), _T("Finish")) == 0) {
    if ((oz = oser.deserialise_oz(*wp, false)) != NULL) {
      pt = fact.createFinish(oz, *wp);
    }
  } 

  if (pt != NULL) {
    fact.append(pt,false);
  }

  delete wp;
  delete wp_node;
  delete oz_node;
}
void
TaskDefaultsConfigPanel::Init(WndForm *_wf)
{
  assert(_wf != NULL);
  wf = _wf;
  WndProperty *wp;
  const SETTINGS_COMPUTER &settings_computer = XCSoarInterface::SettingsComputer();
  OrderedTask* temptask = protected_task_manager->task_blank();
  temptask->set_factory(TaskBehaviour::FACTORY_RT);


  wp = (WndProperty*)wf->FindByName(_T("prpStartType"));
  if (wp) {
    const AbstractTaskFactory::LegalPointVector point_types =
        temptask->get_factory().getValidStartTypes();
    DataFieldEnum* dfe = (DataFieldEnum*)wp->GetDataField();
    dfe->EnableItemHelp(true);

    for (unsigned i = 0; i < point_types.size(); i++) {
      dfe->addEnumText(OrderedTaskPointName(point_types[i]), (unsigned)point_types[i],
          OrderedTaskPointDescription(point_types[i]));
      if (point_types[i] == settings_computer.sector_defaults.start_type)
        dfe->Set((unsigned)point_types[i]);
    }
    wp->RefreshDisplay();
  }

  LoadFormProperty(*wf, _T("prpStartRadius"), ugDistance,
                   settings_computer.sector_defaults.start_radius);

  wp = (WndProperty*)wf->FindByName(_T("prpFinishType"));
  if (wp) {
    const AbstractTaskFactory::LegalPointVector point_types =
        temptask->get_factory().getValidFinishTypes();
    DataFieldEnum* dfe = (DataFieldEnum*)wp->GetDataField();
    dfe->EnableItemHelp(true);

    for (unsigned i = 0; i < point_types.size(); i++) {
      dfe->addEnumText(OrderedTaskPointName(point_types[i]), (unsigned)point_types[i],
          OrderedTaskPointDescription(point_types[i]));
      if (point_types[i] == settings_computer.sector_defaults.finish_type)
        dfe->Set((unsigned)point_types[i]);
    }
    wp->RefreshDisplay();
  }

  LoadFormProperty(*wf, _T("prpFinishRadius"), ugDistance,
                   settings_computer.sector_defaults.finish_radius);

  wp = (WndProperty*)wf->FindByName(_T("prpTurnpointType"));
  if (wp) {
    const AbstractTaskFactory::LegalPointVector point_types =
        temptask->get_factory().getValidIntermediateTypes();
    DataFieldEnum* dfe = (DataFieldEnum*)wp->GetDataField();
    dfe->EnableItemHelp(true);

    for (unsigned i = 0; i < point_types.size(); i++) {
      dfe->addEnumText(OrderedTaskPointName(point_types[i]),
          (unsigned)point_types[i],
          OrderedTaskPointDescription(point_types[i]));
      if (point_types[i] == settings_computer.sector_defaults.turnpoint_type) {
        dfe->Set((unsigned)point_types[i]);
      }
    }
    wp->RefreshDisplay();
  }

  LoadFormProperty(*wf, _T("prpTurnpointRadius"), ugDistance,
                   settings_computer.sector_defaults.turnpoint_radius);

  wp = (WndProperty*)wf->FindByName(_T("prpTaskType"));
  if (wp) {
    const std::vector<TaskBehaviour::Factory_t> factory_types =
        temptask->get_factory_types();
    DataFieldEnum* dfe = (DataFieldEnum*)wp->GetDataField();
    dfe->EnableItemHelp(true);

    for (unsigned i = 0; i < factory_types.size(); i++) {
      dfe->addEnumText(OrderedTaskFactoryName(factory_types[i]),
          (unsigned)factory_types[i], OrderedTaskFactoryDescription(
              factory_types[i]));
      if (factory_types[i] == settings_computer.task_type_default)
        dfe->Set((unsigned)factory_types[i]);
    }
    wp->RefreshDisplay();
  }

  LoadFormProperty(*wf, _T("prpAATMinTime"),
                   (unsigned)(settings_computer.ordered_defaults.aat_min_time / 60));

  LoadFormProperty(*wf, _T("prpAATTimeMargin"),
                   (unsigned)(settings_computer.optimise_targets_margin / 60));

  delete temptask;
}