static void RefreshView() { wTaskView->invalidate(); OrderedTaskPoint* tp = ordered_task->get_tp(active_index); if (!tp) return; Refreshing = true; // tell onChange routines not to save form! TPLabelObservationZone ozv; ObservationZoneConstVisitor &visitor = ozv; visitor.Visit(*tp->get_oz()); WndFrame* wfrm = NULL; wfrm = ((WndFrame*)wf->FindByName(_T("lblType"))); if (wfrm) wfrm->SetCaption(OrderedTaskPointName(ordered_task->get_factory().getType(*tp))); WndButton* wb; wb = ((WndButton*)wf->FindByName(_T("butPrevious"))); if (wb) wb->set_enabled(active_index > 0); wb = ((WndButton*)wf->FindByName(_T("butNext"))); if (wb) wb->set_enabled(active_index < (ordered_task->task_size() - 1)); wb = (WndButton*)wf->FindByName(_T("cmdOptionalStarts")); assert(wb); wb->set_visible(active_index == 0); if (ordered_task->optional_start_points_size() == 0) wb->SetCaption(_("Enable Alternate Starts")); else { TCHAR tmp[50]; _stprintf(tmp, _T("%s (%d)"), _("Edit Alternates"), ordered_task->optional_start_points_size()); wb->SetCaption(tmp); } EnableSizeEdit(ordered_task->get_factory_type() != TaskBehaviour::FACTORY_FAI_GENERAL); TCHAR bufType[100]; TCHAR bufNamePrefix[100]; TPLabelTaskPoint tpv(bufType, bufNamePrefix); TaskPointConstVisitor &tp_visitor = tpv; tp_visitor.Visit(*tp); wf->SetCaption(tpv.textType); wfrm = ((WndFrame*)wf->FindByName(_T("lblLocation"))); if (wfrm) { TCHAR buff[100]; _stprintf(buff, _T("%s %s"), tpv.textNamePrefix, tp->get_waypoint().Name.c_str()); wfrm->SetCaption(buff); } Refreshing = false; // reactivate onChange routines }
void MutateTaskPointRenderer::OnPaintItem(Canvas &canvas, PixelRect rc, unsigned DrawListIndex) { assert(DrawListIndex < point_types.size()); if (point_types[DrawListIndex] == current_type) rc.left = row_renderer.DrawColumn(canvas, rc, _T("*")); row_renderer.DrawTextRow(canvas, rc, OrderedTaskPointName(point_types[DrawListIndex])); }
static void OnPointPaintListItem(Canvas &canvas, const PixelRect rc, unsigned DrawListIndex) { assert(DrawListIndex < point_types.size()); StaticString<120> buffer; const TCHAR* text = OrderedTaskPointName(point_types[DrawListIndex]); if (point && (point_types[DrawListIndex] == get_point_type())) buffer.Format(_T("*%s"), text); else buffer.Format(_T(" %s"), text); canvas.text(rc.left + Layout::FastScale(2), rc.top + Layout::FastScale(2), buffer); }
void TaskPointWidget::RefreshView() { map.Invalidate(); OrderedTaskPoint &tp = ordered_task.GetPoint(active_index); properties_dock.DeleteWidget(); ObservationZonePoint &oz = tp.GetObservationZone(); const bool is_fai_general = ordered_task.GetFactoryType() == TaskFactoryType::FAI_GENERAL; auto *properties_widget = CreateObservationZoneEditWidget(oz, is_fai_general); if (properties_widget != nullptr) { properties_widget->SetListener(this); properties_dock.SetWidget(properties_widget); } else properties_dock.SetWidget(new PanelWidget()); type_label.SetCaption(OrderedTaskPointName(ordered_task.GetFactory().GetType(tp))); previous_button->SetEnabled(active_index > 0); next_button->SetEnabled(active_index < (ordered_task.TaskSize() - 1)); optional_starts.SetVisible(active_index == 0); if (!ordered_task.HasOptionalStarts()) optional_starts.SetCaption(_("Enable Alternate Starts")); else { StaticString<50> tmp; tmp.Format(_T("%s (%d)"), _("Edit Alternates"), ordered_task.GetOptionalStartPointCount()); optional_starts.SetCaption(tmp); } if (tp.GetType() == TaskPointType::AST) { const ASTPoint &ast = (const ASTPoint &)tp; score_exit.Show(); score_exit.SetState(ast.GetScoreExit()); } else score_exit.Hide(); StaticString<100> name_prefix_buffer, type_buffer; switch (tp.GetType()) { case TaskPointType::START: type_buffer = _("Start point"); name_prefix_buffer = _T("Start: "); break; case TaskPointType::AST: type_buffer = _("Task point"); name_prefix_buffer.Format(_T("%d: "), active_index); break; case TaskPointType::AAT: type_buffer = _("Assigned area point"); name_prefix_buffer.Format(_T("%d: "), active_index); break; case TaskPointType::FINISH: type_buffer = _("Finish point"); name_prefix_buffer = _T("Finish: "); break; default: gcc_unreachable(); } dialog.SetCaption(type_buffer); { StaticString<100> buffer; buffer.Format(_T("%s %s"), name_prefix_buffer.c_str(), tp.GetWaypoint().name.c_str()); waypoint_name.SetCaption(buffer); } }
static void RefreshView() { wTaskView->Invalidate(); OrderedTaskPoint &tp = ordered_task->GetPoint(active_index); dock->SetWidget(new PanelWidget()); ObservationZonePoint &oz = tp.GetObservationZone(); const bool is_fai_general = ordered_task->GetFactoryType() == TaskFactoryType::FAI_GENERAL; properties_widget = CreateObservationZoneEditWidget(oz, is_fai_general); if (properties_widget != nullptr) { properties_widget->SetListener(&listener); dock->SetWidget(properties_widget); } WndFrame* wfrm = nullptr; wfrm = ((WndFrame*)wf->FindByName(_T("lblType"))); if (wfrm) wfrm->SetCaption(OrderedTaskPointName(ordered_task->GetFactory().GetType(tp))); SetFormControlEnabled(*wf, _T("butPrevious"), active_index > 0); SetFormControlEnabled(*wf, _T("butNext"), active_index < (ordered_task->TaskSize() - 1)); WndButton* wb; wb = (WndButton*)wf->FindByName(_T("cmdOptionalStarts")); assert(wb); wb->SetVisible(active_index == 0); if (!ordered_task->HasOptionalStarts()) wb->SetCaption(_("Enable Alternate Starts")); else { StaticString<50> tmp; tmp.Format(_T("%s (%d)"), _("Edit Alternates"), ordered_task->GetOptionalStartPointCount()); wb->SetCaption(tmp); } CheckBoxControl &score_exit = *(CheckBoxControl *) wf->FindByName(_T("ScoreExit")); if (tp.GetType() == TaskPointType::AST) { const ASTPoint &ast = (const ASTPoint &)tp; score_exit.Show(); score_exit.SetState(ast.GetScoreExit()); } else score_exit.Hide(); StaticString<100> name_prefix_buffer, type_buffer; switch (tp.GetType()) { case TaskPointType::START: type_buffer = _("Start point"); name_prefix_buffer = _T("Start: "); break; case TaskPointType::AST: type_buffer = _("Task point"); name_prefix_buffer.Format(_T("%d: "), active_index); break; case TaskPointType::AAT: type_buffer = _("Assigned area point"); name_prefix_buffer.Format(_T("%d: "), active_index); break; case TaskPointType::FINISH: type_buffer = _("Finish point"); name_prefix_buffer = _T("Finish: "); break; default: gcc_unreachable(); } wf->SetCaption(type_buffer); wfrm = ((WndFrame*)wf->FindByName(_T("lblLocation"))); if (wfrm) { StaticString<100> buffer; buffer.Format(_T("%s %s"), name_prefix_buffer.c_str(), tp.GetWaypoint().name.c_str()); wfrm->SetCaption(buffer); } }
static void RefreshView() { wTaskView->invalidate(); OrderedTaskPoint* tp = ordered_task->get_tp(active_index); if (!tp) return; Refreshing = true; // tell onChange routines not to save form! ShowFormControl(*wf, _T("frmOZLine"), false); ShowFormControl(*wf, _T("frmOZSector"), false); ShowFormControl(*wf, _T("frmOZCylinder"), false); const ObservationZonePoint &oz = *tp->get_oz(); switch (oz.shape) { case ObservationZonePoint::SECTOR: case ObservationZonePoint::ANNULAR_SECTOR: ShowFormControl(*wf, _T("frmOZSector"), true); LoadFormProperty(*wf, _T("prpOZSectorRadius"), ugDistance, ((const SectorZone &)oz).getRadius()); LoadFormProperty(*wf, _T("prpOZSectorStartRadial"), ((const SectorZone &)oz).getStartRadial().value_degrees()); LoadFormProperty(*wf, _T("prpOZSectorFinishRadial"), ((const SectorZone &)oz).getEndRadial().value_degrees()); if (oz.shape == ObservationZonePoint::ANNULAR_SECTOR) { LoadFormProperty(*wf, _T("prpOZSectorInnerRadius"), ugDistance, ((const AnnularSectorZone &)oz).getInnerRadius()); ShowFormControl(*wf, _T("prpOZSectorInnerRadius"), true); } else ShowFormControl(*wf, _T("prpOZSectorInnerRadius"), false); break; case ObservationZonePoint::LINE: ShowFormControl(*wf, _T("frmOZLine"), true); LoadFormProperty(*wf, _T("prpOZLineLength"), ugDistance, ((const LineSectorZone &)oz).getLength()); break; case ObservationZonePoint::CYLINDER: ShowFormControl(*wf, _T("frmOZCylinder"), true); LoadFormProperty(*wf, _T("prpOZCylinderRadius"), ugDistance, ((const CylinderZone &)oz).getRadius()); break; default: break; } WndFrame* wfrm = NULL; wfrm = ((WndFrame*)wf->FindByName(_T("lblType"))); if (wfrm) wfrm->SetCaption(OrderedTaskPointName(ordered_task->get_factory().getType(*tp))); SetFormControlEnabled(*wf, _T("butPrevious"), active_index > 0); SetFormControlEnabled(*wf, _T("butNext"), active_index < (ordered_task->TaskSize() - 1)); WndButton* wb; wb = (WndButton*)wf->FindByName(_T("cmdOptionalStarts")); assert(wb); wb->set_visible(active_index == 0); if (ordered_task->optional_start_points_size() == 0) wb->SetCaption(_("Enable Alternate Starts")); else { TCHAR tmp[50]; _stprintf(tmp, _T("%s (%d)"), _("Edit Alternates"), ordered_task->optional_start_points_size()); wb->SetCaption(tmp); } EnableSizeEdit(ordered_task->get_factory_type() != TaskBehaviour::FACTORY_FAI_GENERAL); TCHAR bufType[100]; TCHAR bufNamePrefix[100]; switch (tp->GetType()) { case TaskPoint::START: _tcscpy(bufType, _T("Start point")); _tcscpy(bufNamePrefix, _T("Start: ")); break; case TaskPoint::AST: _tcscpy(bufType, _T("Task point")); _stprintf(bufNamePrefix, _T("%d: "), active_index); break; case TaskPoint::AAT: _tcscpy(bufType, _T("Assigned area point")); _stprintf(bufNamePrefix, _T("%d: "), active_index); break; case TaskPoint::FINISH: _tcscpy(bufType, _T("Finish point")); _tcscpy(bufNamePrefix, _T("Finish: ")); break; default: assert(true); break; } wf->SetCaption(bufType); wfrm = ((WndFrame*)wf->FindByName(_T("lblLocation"))); if (wfrm) { TCHAR buff[100]; _stprintf(buff, _T("%s %s"), bufNamePrefix, tp->GetWaypoint().name.c_str()); wfrm->SetCaption(buff); } Refreshing = false; // reactivate onChange routines }
void TaskDefaultsConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) { WndProperty *wp; const ComputerSettings &settings_computer = XCSoarInterface::GetComputerSettings(); const TaskBehaviour &task_behaviour = settings_computer.task; OrderedTask temptask(task_behaviour); temptask.SetFactory(TaskFactoryType::RACING); RowFormWidget::Prepare(parent, rc); wp = AddEnum(_("Start point"), _("Default start type for new tasks you create."), this); if (wp) { const auto point_types = temptask.GetFactory().GetValidStartTypes(); DataFieldEnum* dfe = (DataFieldEnum*)wp->GetDataField(); dfe->EnableItemHelp(true); for (auto i = point_types.begin(), end = point_types.end(); i != end; ++i) { const AbstractTaskFactory::LegalPointType type = *i; dfe->addEnumText(OrderedTaskPointName(type), (unsigned)type, OrderedTaskPointDescription(type)); if (type == task_behaviour.sector_defaults.start_type) dfe->Set((unsigned)type); } wp->RefreshDisplay(); } AddFloat(Caption_GateWidth, _("Default radius or gate width of the start zone for new tasks."), _T("%.1f %s"), _T("%.1f"), fixed(0.1), fixed(100), fixed(1.0), true, UnitGroup::DISTANCE, task_behaviour.sector_defaults.start_radius); AddSpacer(); wp = AddEnum(_("Finish point"), _("Default finish type for new tasks you create."), this); if (wp) { const auto point_types = temptask.GetFactory().GetValidFinishTypes(); DataFieldEnum* dfe = (DataFieldEnum*)wp->GetDataField(); dfe->EnableItemHelp(true); for (auto i = point_types.begin(), end = point_types.end(); i != end; ++i) { const AbstractTaskFactory::LegalPointType type = *i; dfe->addEnumText(OrderedTaskPointName(type), (unsigned)type, OrderedTaskPointDescription(type)); if (type == task_behaviour.sector_defaults.finish_type) dfe->Set((unsigned)type); } wp->RefreshDisplay(); } AddFloat(Caption_GateWidth, _("Default radius or gate width of the finish zone in new tasks."), _T("%.1f %s"), _T("%.1f"), fixed(0.1), fixed(100), fixed(1.0), true, UnitGroup::DISTANCE, task_behaviour.sector_defaults.finish_radius); AddSpacer(); wp = AddEnum(_("Turn point"), _("Default turn point type for new tasks you create.")); if (wp) { const auto point_types = temptask.GetFactory().GetValidIntermediateTypes(); DataFieldEnum* dfe = (DataFieldEnum*)wp->GetDataField(); dfe->EnableItemHelp(true); for (auto i = point_types.begin(), end = point_types.end(); i != end; ++i) { const AbstractTaskFactory::LegalPointType type = *i; dfe->addEnumText(OrderedTaskPointName(type), (unsigned)type, OrderedTaskPointDescription(type)); if (type == task_behaviour.sector_defaults.turnpoint_type) { dfe->Set((unsigned)type); } } wp->RefreshDisplay(); } AddFloat(Caption_Radius, _("Default radius of turnpoint cylinders and sectors in new tasks."), _T("%.1f %s"), _T("%.1f"), fixed(0.1), fixed(100), fixed(1.0), true, UnitGroup::DISTANCE, task_behaviour.sector_defaults.turnpoint_radius); AddSpacer(); wp = AddEnum(_("Task"), _("Default task type for new tasks you create.")); if (wp) { const std::vector<TaskFactoryType> factory_types = temptask.GetFactoryTypes(); 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] == task_behaviour.task_type_default) dfe->Set((unsigned)factory_types[i]); } wp->RefreshDisplay(); } AddTime(_("AAT min. time"), _("Default AAT min. time for new AAT tasks."), 60, 10 * 60 * 60, 60, (unsigned)task_behaviour.ordered_defaults.aat_min_time); AddTime(_("Optimisation margin"), _("Safety margin for AAT task optimisation. Optimisation " "seeks to complete the task at the minimum time plus this margin time."), 0, 30 * 60, 60, (unsigned)task_behaviour.optimise_targets_margin); SetExpertRow(AATTimeMargin); SetStartLabel(); SetFinishLabel(); }
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; }