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 }
static void ReadValues() { TPReadObservationZone tpv; OrderedTaskPoint* tp = ordered_task->get_tp(active_index); ObservationZoneVisitor &visitor = tpv; visitor.Visit(*tp->get_oz()); }
gcc_pure static unsigned get_radius(const OrderedTaskPoint &tp) { const ObservationZonePoint *oz = tp.get_oz(); if (oz == NULL) return Declaration::TurnPoint::SECTOR; return (unsigned)((const CylinderZone *)oz)->getRadius(); }
gcc_pure static Declaration::TurnPoint::Shape get_shape(const OrderedTaskPoint &tp) { const ObservationZonePoint *oz = tp.get_oz(); if (oz == NULL) return Declaration::TurnPoint::SECTOR; switch (oz->shape) { case ObservationZonePoint::LINE: return Declaration::TurnPoint::LINE; case ObservationZonePoint::CYLINDER: return Declaration::TurnPoint::CYLINDER; default: return Declaration::TurnPoint::SECTOR; } }
AbstractTaskFactory::LegalPointType_t AbstractTaskFactory::getType(const OrderedTaskPoint &point) const { const ObservationZonePoint* oz = point.get_oz(); switch (point.GetType()) { case TaskPoint::START: switch (oz->shape) { case ObservationZonePoint::FAI_SECTOR: return START_SECTOR; case ObservationZonePoint::LINE: return START_LINE; case ObservationZonePoint::CYLINDER: case ObservationZonePoint::SECTOR: case ObservationZonePoint::KEYHOLE: case ObservationZonePoint::BGAFIXEDCOURSE: case ObservationZonePoint::BGAENHANCEDOPTION: case ObservationZonePoint::ANNULAR_SECTOR: return START_CYLINDER; case ObservationZonePoint::BGA_START: return START_BGA; } break; case TaskPoint::AAT: switch (oz->shape) { case ObservationZonePoint::SECTOR: case ObservationZonePoint::FAI_SECTOR: case ObservationZonePoint::KEYHOLE: case ObservationZonePoint::BGAFIXEDCOURSE: case ObservationZonePoint::BGAENHANCEDOPTION: case ObservationZonePoint::BGA_START: case ObservationZonePoint::LINE: return AAT_SEGMENT; case ObservationZonePoint::ANNULAR_SECTOR: return AAT_ANNULAR_SECTOR; case ObservationZonePoint::CYLINDER: return AAT_CYLINDER; } break; case TaskPoint::AST: switch (oz->shape) { case ObservationZonePoint::FAI_SECTOR: return FAI_SECTOR; case ObservationZonePoint::KEYHOLE: return KEYHOLE_SECTOR; case ObservationZonePoint::BGAFIXEDCOURSE: return BGAFIXEDCOURSE_SECTOR; case ObservationZonePoint::BGAENHANCEDOPTION: return BGAENHANCEDOPTION_SECTOR; case ObservationZonePoint::BGA_START: case ObservationZonePoint::CYLINDER: case ObservationZonePoint::SECTOR: case ObservationZonePoint::LINE: case ObservationZonePoint::ANNULAR_SECTOR: return AST_CYLINDER; } break; case TaskPoint::FINISH: switch (oz->shape) { case ObservationZonePoint::BGA_START: case ObservationZonePoint::FAI_SECTOR: return FINISH_SECTOR; case ObservationZonePoint::LINE: return FINISH_LINE; case ObservationZonePoint::CYLINDER: case ObservationZonePoint::SECTOR: case ObservationZonePoint::KEYHOLE: case ObservationZonePoint::BGAFIXEDCOURSE: case ObservationZonePoint::BGAENHANCEDOPTION: case ObservationZonePoint::ANNULAR_SECTOR: return FINISH_CYLINDER; } break; case TaskPoint::UNORDERED: case TaskPoint::ROUTE: /* obviously, when we check the type of an OrderedTaskPoint, we should never get type==UNORDERED or ROUTE. */ assert(false); break; } // fail, should never get here assert(1); return START_LINE; }
static fixed GetRadius(const OrderedTaskPoint &tp) { return GetRadius(*tp.get_oz()); }
virtual void Visit(const OrderedTaskPoint& tp) { printf("# got an otp\n"); ozv.Visit(*tp.get_oz()); }
bool test_task_aat(TaskManager& task_manager, const Waypoints &waypoints) { const TaskProjection &projection = task_manager.get_ordered_task().get_task_projection(); task_manager.set_factory(OrderedTask::FACTORY_AAT); AbstractTaskFactory &fact = task_manager.get_factory(); const Waypoint *wp; task_report(task_manager, "# adding start\n"); wp = waypoints.lookup_id(1); if (wp) { if (!fact.append(fact.createStart(*wp),false)) { return false; } } task_manager.setActiveTaskPoint(0); task_manager.resume(); task_report(task_manager, "# adding intermediate\n"); wp = waypoints.lookup_id(2); if (wp) { OrderedTaskPoint* tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(30000.0)); tp->update_oz(projection); } if (!fact.append(tp,false)) { return false; } } task_report(task_manager, "# adding intermediate\n"); wp = waypoints.lookup_id(3); if (wp) { OrderedTaskPoint* tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(40000.0)); tp->update_oz(projection); } if (!fact.append(tp,false)) { return false; } } task_report(task_manager, "# adding finish\n"); wp = waypoints.lookup_id(1); if (wp) { if (!fact.append(fact.createFinish(*wp),false)) { return false; } } task_report(task_manager, "# checking task..\n"); if (!fact.validate()) { return false; } if (!task_manager.check_ordered_task()) { return false; } return true; }
bool test_task_mixed(TaskManager& task_manager, const Waypoints &waypoints) { const TaskProjection &projection = task_manager.get_ordered_task().get_task_projection(); OrderedTaskPoint *tp; const Waypoint *wp; task_manager.set_factory(TaskBehaviour::FACTORY_MIXED); AbstractTaskFactory &fact = task_manager.get_factory(); task_report(task_manager, "# adding start\n"); wp = waypoints.lookup_id(1); if (wp) { tp = fact.createStart(AbstractTaskFactory::START_LINE,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(5000.0)); tp->update_oz(projection); } if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_manager.setActiveTaskPoint(0); task_manager.resume(); task_report(task_manager, "# adding intermdiate\n"); wp = waypoints.lookup_id(2); if (wp) { tp = fact.createIntermediate(AbstractTaskFactory::AST_CYLINDER,*wp); if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# adding intermdiate\n"); wp = waypoints.lookup_id(3); if (wp) { tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(30000.0)); tp->update_oz(projection); } if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# adding intermediate\n"); wp = waypoints.lookup_id(4); if (wp) { tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# adding intermediate\n"); wp = waypoints.lookup_id(5); if (wp) { tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(30000.0)); tp->update_oz(projection); } if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# adding finish\n"); wp = waypoints.lookup_id(1); if (wp) { tp = fact.createFinish(AbstractTaskFactory::FINISH_LINE,*wp); if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# checking task\n"); if (!fact.validate()) { return false; } if (!task_manager.check_ordered_task()) { return false; } return true; }
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 }
static void ReadValues() { OrderedTaskPoint* tp = ordered_task->get_tp(active_index); ObservationZonePoint &oz = *tp->get_oz(); switch (oz.shape) { case ObservationZonePoint::ANNULAR_SECTOR: { fixed radius = Units::ToSysDistance( GetFormValueFixed(*wf, _T("prpOZSectorInnerRadius"))); if (fabs(radius - ((AnnularSectorZone &)oz).getInnerRadius()) > fixed(49)) { ((AnnularSectorZone &)oz).setInnerRadius(radius); task_modified = true; } } case ObservationZonePoint::SECTOR: { fixed radius = Units::ToSysDistance( GetFormValueFixed(*wf, _T("prpOZSectorRadius"))); if (fabs(radius - ((SectorZone &)oz).getRadius()) > fixed(49)) { ((SectorZone &)oz).setRadius(radius); task_modified = true; } fixed start_radial = GetFormValueFixed(*wf, _T("prpOZSectorStartRadial")); if (start_radial != ((SectorZone &)oz).getStartRadial().value_degrees()) { ((SectorZone &)oz).setStartRadial(Angle::degrees(start_radial)); task_modified = true; } fixed finish_radial = GetFormValueFixed(*wf, _T("prpOZSectorFinishRadial")); if (finish_radial != ((SectorZone &)oz).getEndRadial().value_degrees()) { ((SectorZone &)oz).setEndRadial(Angle::degrees(finish_radial)); task_modified = true; } break; } case ObservationZonePoint::LINE: { fixed line_length = Units::ToSysDistance( GetFormValueFixed(*wf, _T("prpOZLineLength"))); if (fabs(line_length - ((LineSectorZone &)oz).getLength()) > fixed(49)) { ((LineSectorZone &)oz).setLength(line_length); task_modified = true; } break; } case ObservationZonePoint::CYLINDER: { fixed radius = Units::ToSysDistance( GetFormValueFixed(*wf, _T("prpOZCylinderRadius"))); if (fabs(radius - ((CylinderZone &)oz).getRadius()) > fixed(49)) { ((CylinderZone &)oz).setRadius(radius); task_modified = true; } break; } default: break; } }