inline void TaskPointWidget::OnTypeClicked() { if (dlgTaskPointType(&ordered_task, active_index)) { ordered_task->ClearName(); task_modified = true; RefreshView(); } }
void Deserialiser::Deserialise(OrderedTask &task) { task.Clear(); task.SetFactory(GetTaskFactoryType()); task.Reset(); OrderedTaskBehaviour beh = task.GetOrderedTaskBehaviour(); Deserialise(beh); task.SetOrderedTaskBehaviour(beh); const DataNode::List children = node.ListChildrenNamed(_T("Point")); for (const auto &i : children) { std::unique_ptr<DataNode> point_node(i); Deserialiser pser(*point_node, waypoints); pser.DeserialiseTaskpoint(task); } }
static OrderedTask * LoadTask2(const TCHAR *path, const TaskBehaviour &task_behaviour) { OrderedTask *task = LoadTask(path, task_behaviour); if (task == nullptr) { fprintf(stderr, "Failed to parse XML\n"); return nullptr; } task->UpdateGeometry(); if (!task->CheckTask()) { fprintf(stderr, "Failed to load task from XML\n"); delete task; return NULL; } return task; }
inline void TaskPointWidget::OnNextClicked() { if (active_index >= ordered_task->TaskSize() - 1 || !ReadValues()) return; ++active_index; RefreshView(); }
void LoadTask(OrderedTask &task, const ConstDataNode &node, const Waypoints *waypoints) { task.Clear(); task.SetFactory(GetTaskFactoryType(node)); task.Reset(); OrderedTaskSettings beh = task.GetOrderedTaskSettings(); Deserialise(beh, node); task.SetOrderedTaskSettings(beh); const auto children = node.ListChildrenNamed(_T("Point")); for (const auto &i : children) { std::unique_ptr<ConstDataNode> point_node(i); DeserialiseTaskpoint(task, *point_node, waypoints); } }
/** * displays dlgTaskOptionalStarts * @param Sender */ inline void TaskPointWidget::OnOptionalStartsClicked() { if (dlgTaskOptionalStarts(&ordered_task)) { ordered_task->ClearName(); task_modified = true; RefreshView(); } }
void Serialiser::deserialise(OrderedTask& data) { data.clear(); data.set_factory(task_factory_type()); data.reset(); OrderedTaskBehaviour beh = data.get_ordered_task_behaviour(); deserialise(beh); data.set_ordered_task_behaviour(beh); DataNode* point_node; unsigned i=0; while ((point_node = m_node.get_child_by_name(_T("Point"),i)) != NULL) { Serialiser pser(*point_node); pser.deserialise_point(data); delete point_node; i++; } }
bool TaskPointWidget::ReadValues() { OrderedTaskPoint &tp = ordered_task->GetPoint(active_index); if (tp.GetType() == TaskPointType::AST) { const bool new_score_exit = score_exit.GetState(); ASTPoint &ast = (ASTPoint &)tp; if (new_score_exit != ast.GetScoreExit()) { ast.SetScoreExit(new_score_exit); ordered_task->ClearName(); task_modified = true; } } return properties_widget == nullptr || properties_widget->Save(task_modified); }
static int GetIndexInTask(const OrderedTask &task, const Waypoint &waypoint) { if (task.TaskSize() == 0) return -1; unsigned i = task.GetActiveIndex(); if (i >= task.TaskSize()) return -1; int TPindex = -1; for (unsigned i = task.TaskSize(); i--;) { const OrderedTaskPoint &tp = task.GetPoint(i); if (tp.GetWaypoint() == waypoint) { TPindex = i; break; } } return TPindex; }
void TaskRenderer::Draw(const OrderedTask &task) { tpv.SetBoundingBox(task.GetBoundingBox(screen_bounds)); tpv.SetActiveIndex(task.GetActiveIndex()); for (unsigned i = 0; i < 4; i++) { tpv.ResetIndex(); if (i != TaskPointRenderer::LAYER_SYMBOLS && i != TaskPointRenderer::LAYER_LEG) { tpv.SetModeOptional(true); for (const auto &tp : task.GetOptionalStartPoints()) tpv.Draw(tp, (TaskPointRenderer::Layer)i); } tpv.SetModeOptional(false); for (const auto &tp : task.GetPoints()) tpv.Draw(tp, (TaskPointRenderer::Layer)i); } }
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; } }
void TaskRenderer::Draw(const OrderedTask &task) { tpv.SetBoundingBox(task.GetBoundingBox(screen_bounds)); tpv.SetActiveIndex(task.GetActiveIndex()); for (unsigned i = 0; i < 4; i++) { tpv.ResetIndex(); if (i != TaskPointRenderer::LAYER_SYMBOLS && i != TaskPointRenderer::LAYER_LEG) { tpv.SetModeOptional(true); for (const auto &tp : task.GetOptionalStartPoints()) tpv.Draw(tp, (TaskPointRenderer::Layer)i); } tpv.SetModeOptional(false); for (const auto &tp : task.GetPoints()) tpv.Draw(tp, (TaskPointRenderer::Layer)i); } if (task.GetFactoryType() == TaskFactoryType::MAT) { // now draw MAT circles tpv.ResetIndex(); tpv.SetModeOptional(false); for (const auto *i : task.GetMatPoints()) tpv.Draw(*i, (TaskPointRenderer::Layer)2); } }
static OrderedTask * LoadTask(const TCHAR *path, const TaskBehaviour &task_behaviour) { DataNode *node = DataNodeXML::Load(path); if (node == NULL) { fprintf(stderr, "Failed to parse XML\n"); return NULL; } Deserialiser des(*node); OrderedTask *task = new OrderedTask(task_behaviour); des.Deserialise(*task); delete node; if (!task->CheckTask()) { fprintf(stderr, "Failed to load task from XML\n"); delete task; return NULL; } return task; }
static void AfterStartup() { StartupLogFreeRamAndStorage(); #ifdef USE_LUA { Error error; const auto lua_path = LocalPath(_T("lua")); if (!Lua::StartFile(AllocatedPath::Build(lua_path, _T("init.lua")), error)) LogError(error); } #endif if (is_simulator()) { InputEvents::processGlideComputer(GCE_STARTUP_SIMULATOR); } else { InputEvents::processGlideComputer(GCE_STARTUP_REAL); } OrderedTask *defaultTask = LoadDefaultTask(CommonInterface::GetComputerSettings().task, &way_points); if (defaultTask) { { ScopeSuspendAllThreads suspend; defaultTask->CheckDuplicateWaypoints(way_points); way_points.Optimise(); } protected_task_manager->TaskCommit(*defaultTask); delete defaultTask; } task_manager->Resume(); InfoBoxManager::SetDirty(); ForceCalculation(); }
void TaskEditPanel::RefreshView() { UpdateButtons(); dialog.InvalidateTaskView(); unsigned length = ordered_task->TaskSize(); if (!ordered_task->IsFull()) ++length; GetList().SetLength(length); GetList().Invalidate(); { TCHAR text[300]; OrderedTaskSummary(ordered_task, text, false); summary.SetText(text); } if (GetList().IsVisible() && two_widgets != nullptr) two_widgets->UpdateLayout(); }
bool OrderedTaskSave(OrderedTask &task) { TCHAR fname[69] = _T(""); if (!TextEntryDialog(fname, 64, _("Enter a task name"))) return false; const auto tasks_path = MakeLocalPath(_T("tasks")); _tcscat(fname, _T(".tsk")); task.SetName(StaticString<64>(fname)); SaveTask(AllocatedPath::Build(tasks_path, fname), task); return true; }
/** * @return true if the task was modified */ static bool SetPointType(OrderedTask &task, unsigned index, TaskPointFactoryType type) { AbstractTaskFactory &factory = task.GetFactory(); const auto &old_point = task.GetPoint(index); const auto current_type = factory.GetType(old_point); if (type == current_type) // no change return false; bool task_modified = false; auto point = factory.CreateMutatedPoint(old_point, type); if (point == nullptr) return false; if (factory.Replace(*point, index, true)) task_modified = true; delete point; return task_modified; }
static void AfterStartup() { StartupLogFreeRamAndStorage(); CommonInterface::status_messages.Startup(true); if (is_simulator()) { InputEvents::processGlideComputer(GCE_STARTUP_SIMULATOR); } else { InputEvents::processGlideComputer(GCE_STARTUP_REAL); } const TaskFactoryType task_type_default = CommonInterface::GetComputerSettings().task.task_type_default; OrderedTask *defaultTask = protected_task_manager->TaskCreateDefault(&way_points, task_type_default); if (defaultTask) { { ScopeSuspendAllThreads suspend; defaultTask->CheckDuplicateWaypoints(way_points); way_points.Optimise(); } protected_task_manager->TaskCommit(*defaultTask); delete defaultTask; } task_manager->Resume(); CommonInterface::main_window->Fullscreen(); InfoBoxManager::SetDirty(); ForceCalculation(); CommonInterface::status_messages.Startup(false); }
void XCSoarInterface::AfterStartup() { LogStartUp(_T("ProgramStarted = 3")); StartupLogFreeRamAndStorage(); status_messages.Startup(true); if (is_simulator()) { LogStartUp(_T("GCE_STARTUP_SIMULATOR")); InputEvents::processGlideComputer(GCE_STARTUP_SIMULATOR); } else { LogStartUp(_T("GCE_STARTUP_REAL")); InputEvents::processGlideComputer(GCE_STARTUP_REAL); } OrderedTask *defaultTask = protected_task_manager->TaskCreateDefault( &way_points, GetComputerSettings().task.task_type_default); if (defaultTask) { { ScopeSuspendAllThreads suspend; defaultTask->CheckDuplicateWaypoints(way_points); way_points.Optimise(); } protected_task_manager->TaskCommit(*defaultTask); delete defaultTask; } task_manager->Resume(); main_window.Fullscreen(); InfoBoxManager::SetDirty(); TriggerGPSUpdate(); status_messages.Startup(false); }
void TaskEditPanel::MoveUp() { unsigned index = GetList().GetCursorIndex(); if (index == 0) return; if (!ordered_task->GetFactory().Swap(index - 1, true)) return; GetList().SetCursorIndex(index - 1); *task_modified = true; RefreshView(); }
// TaskLoad // Loads the task of the specified filename void InputEvents::eventTaskLoad(const TCHAR *misc) { if (protected_task_manager == NULL) return; if (!StringIsEmpty(misc)) { OrderedTask *task = TaskFile::GetTask(LocalPath(misc), CommonInterface::GetComputerSettings().task, &way_points, 0); if (task) { { ScopeSuspendAllThreads suspend; task->CheckDuplicateWaypoints(way_points); way_points.Optimise(); } protected_task_manager->TaskCommit(*task); delete task; } } trigger_redraw(); }
void TaskEditPanel::UpdateButtons() { const unsigned index = GetList().GetCursorIndex(); buttons.Update(index < ordered_task->TaskSize(), index > 0 && (index == ordered_task->TaskSize() - 1) && !ordered_task->HasFinish(), (int)index < ((int)(ordered_task->TaskSize()) - 1), index > 0 && index < ordered_task->TaskSize(), ordered_task->TaskSize() >= 2); }
static void PaintTask(Canvas &canvas, const WindowProjection &projection, const OrderedTask &task, const GeoPoint &location, const MapSettings &settings_map, const TaskLook &task_look, const AirspaceLook &airspace_look, const RasterTerrain *terrain) { BackgroundRenderer background; background.SetTerrain(terrain); background.Draw(canvas, projection, settings_map.terrain); OZRenderer ozv(task_look, airspace_look, settings_map.airspace); RenderTaskPoint tpv(canvas, projection, task_look, task.GetTaskProjection(), ozv, false, RenderTaskPoint::NONE, location); TaskRenderer dv(tpv, projection.GetScreenBounds()); dv.Draw(task); }
bool OrderedTaskSave(OrderedTask &task) { assert(protected_task_manager != nullptr); TCHAR fname[69] = _T(""); if (!TextEntryDialog(fname, 64, _("Enter a task name"))) return false; TCHAR path[MAX_PATH]; LocalPath(path, _T("tasks")); Directory::Create(path); _tcscat(fname, _T(".tsk")); task.SetName(StaticString<64>(fname)); LocalPath(path, _T("tasks"), fname); protected_task_manager->TaskSave(path, task); return true; }
void TaskPointWidget::PaintMap(Canvas &canvas, const PixelRect &rc) { const OrderedTaskPoint &tp = ordered_task->GetPoint(active_index); #ifdef ENABLE_OPENGL /* enable clipping */ GLCanvasScissor scissor(canvas); #endif const MapLook &look = UIGlobals::GetMapLook(); const NMEAInfo &basic = CommonInterface::Basic(); PaintTaskPoint(canvas, rc, *ordered_task, tp, basic.location_available ? basic.location : GeoPoint::Invalid(), CommonInterface::GetMapSettings(), look.task, look.airspace, terrain, &airspace_database); }
static void PaintTask(Canvas &canvas, const WindowProjection &projection, const OrderedTask &task, const GeoPoint &location, const SETTINGS_MAP &settings_map, const TaskLook &task_look, const AirspaceLook &airspace_look, const RasterTerrain *terrain) { BackgroundDrawHelper background; background.set_terrain(terrain); background.Draw(canvas, projection, settings_map.terrain); RenderObservationZone ozv(task_look, airspace_look); RenderTaskPoint tpv(canvas, NULL, projection, settings_map, task_look, task.get_task_projection(), ozv, false, false, location); RenderTask dv(tpv, projection.GetScreenBounds()); dv.Visit(task); }
static void PaintTask(Canvas &canvas, const WindowProjection &projection, const OrderedTask &task, const GeoPoint &location, const MapSettings &settings_map, const TaskLook &task_look, const AirspaceLook &airspace_look, const RasterTerrain *terrain, const Airspaces *airspaces) { BackgroundRenderer background; background.SetTerrain(terrain); background.Draw(canvas, projection, settings_map.terrain); if (airspaces != NULL) { AirspaceRenderer airspace_renderer(airspace_look); airspace_renderer.SetAirspaces(airspaces); #ifndef ENABLE_OPENGL BufferCanvas buffer_canvas, stencil_canvas; buffer_canvas.set(canvas); stencil_canvas.set(canvas); #endif airspace_renderer.Draw(canvas, #ifndef ENABLE_OPENGL buffer_canvas, stencil_canvas, #endif projection, settings_map.airspace); } #ifdef ENABLE_OPENGL /* desaturate the map background, to focus on the task */ canvas.FadeToWhite(0xc0); #endif OZRenderer ozv(task_look, airspace_look, settings_map.airspace); RenderTaskPoint tpv(canvas, projection, task_look, task.GetTaskProjection(), ozv, false, RenderTaskPoint::NONE, location); TaskRenderer dv(tpv, projection.GetScreenBounds()); dv.Draw(task); }
void ExternalLogger::Declare(const OrderedTask& task) { DeclaredToDevice = false; bool found_logger = false; // don't do anything if task is not valid if (!task.check_task()) return; const Declaration decl(&task); for (unsigned i = 0; i < NUMDEV; ++i) if (DeviceDeclare(&DeviceList[i], decl)) found_logger = true; if (!found_logger) MessageBoxX(_("No logger connected"), _("Declare task"), MB_OK | MB_ICONINFORMATION); }
void TaskRenderer::Draw(const OrderedTask &task) { tpv.SetBoundingBox(task.get_bounding_box(screen_bounds)); tpv.SetActiveIndex(task.GetActiveIndex()); for (unsigned i = 0; i < 4; i++) { tpv.ResetIndex(); if (i != RenderTaskPoint::LAYER_SYMBOLS && i != RenderTaskPoint::LAYER_LEG) { tpv.SetModeOptional(true); for (unsigned j = 0, end = task.optional_start_points_size(); j < end; ++j) tpv.Draw(*task.get_optional_start(j), (RenderTaskPoint::Layer)i); } tpv.SetModeOptional(false); for (unsigned j = 0, end = task.TaskSize(); j < end; ++j) tpv.Draw(task.GetTaskPoint(j), (RenderTaskPoint::Layer)i); } }
static void RenderFAISectors(Canvas &canvas, const WindowProjection &projection, const OrderedTask &task) { const FAITriangleSettings &settings = task.GetOrderedTaskSettings().fai_triangle; const unsigned size = task.TaskSize(); const unsigned end = size - 1; for (unsigned i = 0; i != end; ++i) RenderFAISector(canvas, projection, task.GetPoint(i).GetLocation(), task.GetPoint(i + 1).GetLocation(), true, settings); for (unsigned i = 0; i != end; ++i) RenderFAISector(canvas, projection, task.GetPoint(i).GetLocation(), task.GetPoint(i + 1).GetLocation(), false, settings); }